Remove unused 'parent' member from AssDialogueBlock and make 'text' protected

Originally committed to SVN as r6165.
This commit is contained in:
Thomas Goyne 2011-12-26 22:21:08 +00:00
parent 7b4759cc13
commit 9cfe230682
6 changed files with 23 additions and 44 deletions

View file

@ -271,15 +271,11 @@ void AssDialogue::ParseASSTags() {
//We've found an override block with no backslashes
//We're going to assume it's a comment and not consider it an override block
//Currently we'll treat this as a plain text block, but feel free to create a new class
AssDialogueBlockPlain *block = new AssDialogueBlockPlain;
block->text = "{" + work + "}";
Blocks.push_back(block);
Blocks.push_back(new AssDialogueBlockPlain("{" + work + "}"));
}
else {
// Create block
AssDialogueBlockOverride *block = new AssDialogueBlockOverride;
block->parent = this;
block->text = work;
AssDialogueBlockOverride *block = new AssDialogueBlockOverride(work);
block->ParseTags();
Blocks.push_back(block);
@ -307,14 +303,11 @@ void AssDialogue::ParseASSTags() {
// Plain-text
if (drawingLevel == 0) {
AssDialogueBlockPlain *block = new AssDialogueBlockPlain;
block->text = work;
Blocks.push_back(block);
Blocks.push_back(new AssDialogueBlockPlain(work));
}
// Drawing
else {
AssDialogueBlockDrawing *block = new AssDialogueBlockDrawing;
block->text = work;
AssDialogueBlockDrawing *block = new AssDialogueBlockDrawing(work);
block->Scale = drawingLevel;
Blocks.push_back(block);
}

View file

@ -68,20 +68,17 @@ class AssOverrideTag;
/// " here." (Plain)
///
/// Also note how {}s are discarded.
/// Override blocks are further divided in AssOverrideTag's.
/// Override blocks are further divided in AssOverrideTags.
///
/// The GetText() method generates a new value for the "text" field from
/// the other fields in the specific class, and returns the new value.
/// @endverbatim
class AssDialogueBlock {
public:
/// DOCME
protected:
/// Text of this block
wxString text;
/// DOCME
AssDialogue *parent;
AssDialogueBlock() { }
public:
AssDialogueBlock(wxString const& text) : text(text) { }
virtual ~AssDialogueBlock() { }
virtual ASS_BlockType GetType() = 0;
@ -92,23 +89,16 @@ public:
virtual wxString GetText() { return text; }
};
/// DOCME
/// @class AssDialogueBlockPlain
/// @brief DOCME
///
/// DOCME
class AssDialogueBlockPlain : public AssDialogueBlock {
public:
ASS_BlockType GetType() { return BLOCK_PLAIN; }
AssDialogueBlockPlain() { }
AssDialogueBlockPlain(wxString const& text = "") : AssDialogueBlock(text) { }
};
/// DOCME
/// @class AssDialogueBlockDrawing
/// @brief DOCME
///
@ -119,20 +109,17 @@ public:
int Scale;
ASS_BlockType GetType() { return BLOCK_DRAWING; }
AssDialogueBlockDrawing() { }
AssDialogueBlockDrawing(wxString const& text = "") : AssDialogueBlock(text) { }
void TransformCoords(int trans_x,int trans_y,double mult_x,double mult_y);
};
/// DOCME
/// @class AssDialogueBlockOverride
/// @brief DOCME
///
/// DOCME
class AssDialogueBlockOverride : public AssDialogueBlock {
public:
AssDialogueBlockOverride() { }
AssDialogueBlockOverride(wxString const& text = "") : AssDialogueBlock(text) { }
~AssDialogueBlockOverride();
/// DOCME

View file

@ -71,18 +71,19 @@ void AssKaraoke::SetLine(AssDialogue *line, bool auto_split) {
for (size_t i = 0; i < line->Blocks.size(); ++i) {
AssDialogueBlock *block = line->Blocks[i];
wxString text = block->GetText();
if (dynamic_cast<AssDialogueBlockPlain*>(block)) {
// treat comments as overrides rather than dialogue
if (block->text[0] == '{')
syl.ovr_tags[syl.text.size()] += block->text;
if (text[0] == '{')
syl.ovr_tags[syl.text.size()] += text;
else
syl.text += block->text;
syl.text += text;
}
else if (dynamic_cast<AssDialogueBlockDrawing*>(block)) {
// drawings aren't override tags but they shouldn't show up in the
// stripped text so pretend they are
syl.ovr_tags[syl.text.size()] += block->text;
syl.ovr_tags[syl.text.size()] += text;
}
else if (AssDialogueBlockOverride *ovr = dynamic_cast<AssDialogueBlockOverride*>(block)) {
bool in_tag = false;

View file

@ -427,8 +427,7 @@ void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto::
break;
}
case VARDATA_BLOCK: {
AssDialogueBlockOverride *temp = new AssDialogueBlockOverride;
temp->text = curtok;
AssDialogueBlockOverride *temp = new AssDialogueBlockOverride(curtok);
temp->ParseTags();
newparam->Set(temp);
break;

View file

@ -194,8 +194,7 @@ void DialogResample::DoResampleTags (wxString name,int n,AssOverrideParameter *c
case PARCLASS_DRAWING:
{
AssDialogueBlockDrawing block;
block.text = curParam->Get<wxString>();
AssDialogueBlockDrawing block(curParam->Get<wxString>());
block.TransformCoords(m[0],m[2],rx,ry);
curParam->Set(block.GetText());
}

View file

@ -214,14 +214,14 @@ void DialogTranslation::UpdateDisplay() {
AssDialogueBlock *block = active_line->Blocks[i];
if (block->GetType() == BLOCK_PLAIN) {
int cur_size = original_text->GetReverseUnicodePosition(original_text->GetLength());
original_text->AppendText(block->text);
original_text->AppendText(block->GetText());
if (i == cur_block) {
original_text->StartUnicodeStyling(cur_size);
original_text->SetUnicodeStyling(cur_size, block->text.size(), 1);
original_text->SetUnicodeStyling(cur_size, block->GetText().size(), 1);
}
}
else if (block->GetType() == BLOCK_OVERRIDE)
original_text->AppendText("{" + block->text + "}");
original_text->AppendText("{" + block->GetText() + "}");
}
original_text->SetReadOnly(true);
@ -233,7 +233,7 @@ void DialogTranslation::UpdateDisplay() {
}
void DialogTranslation::Commit(bool next) {
active_line->Blocks[cur_block]->text = translated_text->GetValue();
*active_line->Blocks[cur_block] = translated_text->GetValue();
active_line->UpdateText();
c->ass->Commit(_("translation assistant"), AssFile::COMMIT_DIAG_TEXT);