Minor refactoring within TBT commands.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1562 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-03-11 16:06:46 +00:00
parent f6b2037fb9
commit 9bf900ca29
2 changed files with 13 additions and 12 deletions

View File

@@ -200,6 +200,14 @@ void TitleBlockTemplateCommand::setView(TitleBlockTemplateView *view) {
view_ = view; view_ = view;
} }
/**
Refresh the view, if any.
*/
void TitleBlockTemplateCommand::refreshView() {
if (!view_) return;
view_ -> refresh();
}
/** /**
This static method is a convenience to create a ModifyTemplateGridCommand This static method is a convenience to create a ModifyTemplateGridCommand
that adds a row to \a tbtemplate at \a index. that adds a row to \a tbtemplate at \a index.
@@ -870,9 +878,7 @@ void CutTemplateCellsCommand::undo() {
foreach (TitleBlockCell *cell, cut_cells_.keys()) { foreach (TitleBlockCell *cell, cut_cells_.keys()) {
cell -> cell_type = cut_cells_.value(cell); cell -> cell_type = cut_cells_.value(cell);
} }
if (view_) { refreshView();
view_ -> refresh();
}
} }
/** /**
@@ -882,9 +888,7 @@ void CutTemplateCellsCommand::redo() {
foreach (TitleBlockCell *cell, cut_cells_.keys()) { foreach (TitleBlockCell *cell, cut_cells_.keys()) {
cell -> cell_type = TitleBlockCell::EmptyCell; cell -> cell_type = TitleBlockCell::EmptyCell;
} }
if (view_) { refreshView();
view_ -> refresh();
}
} }
void CutTemplateCellsCommand::setCutCells(const QList<TitleBlockCell *> &cells) { void CutTemplateCellsCommand::setCutCells(const QList<TitleBlockCell *> &cells) {
@@ -932,9 +936,7 @@ void PasteTemplateCellsCommand::undo() {
foreach (TitleBlockCell *cell, erased_cells_.keys()) { foreach (TitleBlockCell *cell, erased_cells_.keys()) {
cell -> loadContentFromCell(erased_cells_.value(cell)); cell -> loadContentFromCell(erased_cells_.value(cell));
} }
if (view_) { refreshView();
view_ -> refresh();
}
} }
/** /**
@@ -945,9 +947,7 @@ void PasteTemplateCellsCommand::redo() {
foreach (TitleBlockCell *cell, erased_cells_.keys()) { foreach (TitleBlockCell *cell, erased_cells_.keys()) {
cell -> loadContentFromCell(pasted_cells_.value(cell)); cell -> loadContentFromCell(pasted_cells_.value(cell));
} }
if (view_) { refreshView();
view_ -> refresh();
}
} }
/** /**

View File

@@ -77,6 +77,7 @@ class TitleBlockTemplateCommand : public QUndoCommand {
void setTitleBlockTemplate(TitleBlockTemplate *); void setTitleBlockTemplate(TitleBlockTemplate *);
TitleBlockTemplateView *view() const; TitleBlockTemplateView *view() const;
void setView(TitleBlockTemplateView *); void setView(TitleBlockTemplateView *);
void refreshView();
// attributes // attributes
protected: protected: