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

View file

@ -68,20 +68,17 @@ class AssOverrideTag;
/// " here." (Plain) /// " here." (Plain)
/// ///
/// Also note how {}s are discarded. /// 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 GetText() method generates a new value for the "text" field from
/// the other fields in the specific class, and returns the new value. /// the other fields in the specific class, and returns the new value.
/// @endverbatim /// @endverbatim
class AssDialogueBlock { class AssDialogueBlock {
public: protected:
/// DOCME /// Text of this block
wxString text; wxString text;
public:
/// DOCME AssDialogueBlock(wxString const& text) : text(text) { }
AssDialogue *parent;
AssDialogueBlock() { }
virtual ~AssDialogueBlock() { } virtual ~AssDialogueBlock() { }
virtual ASS_BlockType GetType() = 0; virtual ASS_BlockType GetType() = 0;
@ -92,23 +89,16 @@ public:
virtual wxString GetText() { return text; } virtual wxString GetText() { return text; }
}; };
/// DOCME
/// @class AssDialogueBlockPlain /// @class AssDialogueBlockPlain
/// @brief DOCME /// @brief DOCME
/// ///
/// DOCME /// DOCME
class AssDialogueBlockPlain : public AssDialogueBlock { class AssDialogueBlockPlain : public AssDialogueBlock {
public: public:
ASS_BlockType GetType() { return BLOCK_PLAIN; } ASS_BlockType GetType() { return BLOCK_PLAIN; }
AssDialogueBlockPlain() { } AssDialogueBlockPlain(wxString const& text = "") : AssDialogueBlock(text) { }
}; };
/// DOCME
/// @class AssDialogueBlockDrawing /// @class AssDialogueBlockDrawing
/// @brief DOCME /// @brief DOCME
/// ///
@ -119,20 +109,17 @@ public:
int Scale; int Scale;
ASS_BlockType GetType() { return BLOCK_DRAWING; } 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); void TransformCoords(int trans_x,int trans_y,double mult_x,double mult_y);
}; };
/// DOCME
/// @class AssDialogueBlockOverride /// @class AssDialogueBlockOverride
/// @brief DOCME /// @brief DOCME
/// ///
/// DOCME /// DOCME
class AssDialogueBlockOverride : public AssDialogueBlock { class AssDialogueBlockOverride : public AssDialogueBlock {
public: public:
AssDialogueBlockOverride() { } AssDialogueBlockOverride(wxString const& text = "") : AssDialogueBlock(text) { }
~AssDialogueBlockOverride(); ~AssDialogueBlockOverride();
/// DOCME /// 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) { for (size_t i = 0; i < line->Blocks.size(); ++i) {
AssDialogueBlock *block = line->Blocks[i]; AssDialogueBlock *block = line->Blocks[i];
wxString text = block->GetText();
if (dynamic_cast<AssDialogueBlockPlain*>(block)) { if (dynamic_cast<AssDialogueBlockPlain*>(block)) {
// treat comments as overrides rather than dialogue // treat comments as overrides rather than dialogue
if (block->text[0] == '{') if (text[0] == '{')
syl.ovr_tags[syl.text.size()] += block->text; syl.ovr_tags[syl.text.size()] += text;
else else
syl.text += block->text; syl.text += text;
} }
else if (dynamic_cast<AssDialogueBlockDrawing*>(block)) { else if (dynamic_cast<AssDialogueBlockDrawing*>(block)) {
// drawings aren't override tags but they shouldn't show up in the // drawings aren't override tags but they shouldn't show up in the
// stripped text so pretend they are // 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)) { else if (AssDialogueBlockOverride *ovr = dynamic_cast<AssDialogueBlockOverride*>(block)) {
bool in_tag = false; bool in_tag = false;

View file

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

View file

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

View file

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