From 9bf900ca2973e933e59160dd3e44d7ebb97c543a Mon Sep 17 00:00:00 2001 From: xavier Date: Sun, 11 Mar 2012 16:06:46 +0000 Subject: [PATCH] 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 --- sources/titleblock/templatecommands.cpp | 24 ++++++++++++------------ sources/titleblock/templatecommands.h | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/sources/titleblock/templatecommands.cpp b/sources/titleblock/templatecommands.cpp index faf7d03f5..1f0cd0ece 100644 --- a/sources/titleblock/templatecommands.cpp +++ b/sources/titleblock/templatecommands.cpp @@ -200,6 +200,14 @@ void TitleBlockTemplateCommand::setView(TitleBlockTemplateView *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 that adds a row to \a tbtemplate at \a index. @@ -870,9 +878,7 @@ void CutTemplateCellsCommand::undo() { foreach (TitleBlockCell *cell, cut_cells_.keys()) { cell -> cell_type = cut_cells_.value(cell); } - if (view_) { - view_ -> refresh(); - } + refreshView(); } /** @@ -882,9 +888,7 @@ void CutTemplateCellsCommand::redo() { foreach (TitleBlockCell *cell, cut_cells_.keys()) { cell -> cell_type = TitleBlockCell::EmptyCell; } - if (view_) { - view_ -> refresh(); - } + refreshView(); } void CutTemplateCellsCommand::setCutCells(const QList &cells) { @@ -932,9 +936,7 @@ void PasteTemplateCellsCommand::undo() { foreach (TitleBlockCell *cell, erased_cells_.keys()) { cell -> loadContentFromCell(erased_cells_.value(cell)); } - if (view_) { - view_ -> refresh(); - } + refreshView(); } /** @@ -945,9 +947,7 @@ void PasteTemplateCellsCommand::redo() { foreach (TitleBlockCell *cell, erased_cells_.keys()) { cell -> loadContentFromCell(pasted_cells_.value(cell)); } - if (view_) { - view_ -> refresh(); - } + refreshView(); } /** diff --git a/sources/titleblock/templatecommands.h b/sources/titleblock/templatecommands.h index 896bd7fbc..25585b2d2 100644 --- a/sources/titleblock/templatecommands.h +++ b/sources/titleblock/templatecommands.h @@ -77,6 +77,7 @@ class TitleBlockTemplateCommand : public QUndoCommand { void setTitleBlockTemplate(TitleBlockTemplate *); TitleBlockTemplateView *view() const; void setView(TitleBlockTemplateView *); + void refreshView(); // attributes protected: