r19245 by jghali - some refactoring of UndoManager
scribus-commit
scribus-commit at lists.scribus.net
Tue Jun 17 06:46:32 UTC 2014
Author: jghali
Date: Tue Jun 17 06:46:32 2014
New Revision: 19245
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19245
Log:
some refactoring of UndoManager
Modified:
trunk/Scribus/scribus/undomanager.cpp
Modified: trunk/Scribus/scribus/undomanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19245&path=/trunk/Scribus/scribus/undomanager.cpp
==============================================================================
--- trunk/Scribus/scribus/undomanager.cpp (original)
+++ trunk/Scribus/scribus/undomanager.cpp Tue Jun 17 06:46:32 2014
@@ -308,30 +308,32 @@
if ( stacks_[currentDoc_].size() == 0 )
return;
- StateList::iterator itstartU = stacks_[currentDoc_].undoActions_.begin(); // undo actions
- StateList::iterator itendU = stacks_[currentDoc_].undoActions_.end();
-
- StateList::iterator itstartR = stacks_[currentDoc_].redoActions_.begin(); // redo actions
- StateList::iterator itendR = stacks_[currentDoc_].redoActions_.end();
+ UndoStack& currentStack = stacks_[currentDoc_];
+
+ StateList::iterator itstartU = currentStack.undoActions_.begin(); // undo actions
+ StateList::iterator itendU = currentStack.undoActions_.end();
+
+ StateList::iterator itstartR = currentStack.redoActions_.begin(); // redo actions
+ StateList::iterator itendR = currentStack.redoActions_.end();
if (uid > -1)
{ // find the range from where actions are added when in obj. spec. mode
StateList::iterator it2;
- for (it2 = stacks_[currentDoc_].undoActions_.begin();
- it2 != stacks_[currentDoc_].undoActions_.end(); ++it2)
+ for (it2 = currentStack.undoActions_.begin();
+ it2 != currentStack.undoActions_.end(); ++it2)
{
UndoState* tmp = *it2;
TransactionState *ts = dynamic_cast<TransactionState*>(tmp);
if (ts && !ts->containsOnly(uid))
{
- if (it2 != stacks_[currentDoc_].undoActions_.begin())
+ if (it2 != currentStack.undoActions_.begin())
itendU = --it2;
break;
}
}
StateList::iterator it3;
- for (it3 = stacks_[currentDoc_].redoActions_.begin();
- it3 != stacks_[currentDoc_].redoActions_.end(); ++it3)
+ for (it3 = currentStack.redoActions_.begin();
+ it3 != currentStack.redoActions_.end(); ++it3)
{
UndoState* tmp = *it3;
TransactionState *ts = dynamic_cast<TransactionState*>(tmp);
@@ -343,9 +345,9 @@
}
}
- if (stacks_[currentDoc_].undoItems() > 0)
- {
- if (itendU == stacks_[currentDoc_].undoActions_.end())
+ if (currentStack.undoItems() > 0)
+ {
+ if (itendU == currentStack.undoActions_.end())
--itendU;
for (; itendU >= itstartU; --itendU) // insert undo actions
{
@@ -359,7 +361,7 @@
}
}
- if (stacks_[currentDoc_].redoItems() > 0)
+ if (currentStack.redoItems() > 0)
{
if (itendR > itstartR)
--itendR;
@@ -670,27 +672,30 @@
void UndoManager::setTexts()
{
- if (stacks_[currentDoc_].undoItems() > 0)
- {
- UndoState *state = stacks_[currentDoc_].getNextUndo(currentUndoObjectId_);
+ ScribusMainWindow* scMW = ScCore->primaryMainWindow();
+ UndoStack& currentStack = stacks_[currentDoc_];
+
+ if (currentStack.undoItems() > 0)
+ {
+ UndoState *state = currentStack.getNextUndo(currentUndoObjectId_);
if (state)
- ScCore->primaryMainWindow()->scrActions["editUndoAction"]->setTexts(QString(Um::MenuUndo).arg(state->getName()));
+ scMW->scrActions["editUndoAction"]->setTexts(QString(Um::MenuUndo).arg(state->getName()));
else
- ScCore->primaryMainWindow()->scrActions["editUndoAction"]->setTexts(Um::MenuUndoEmpty);
+ scMW->scrActions["editUndoAction"]->setTexts(Um::MenuUndoEmpty);
}
else
- ScCore->primaryMainWindow()->scrActions["editUndoAction"]->setTexts(Um::MenuUndoEmpty);
-
- if (stacks_[currentDoc_].redoItems() > 0)
- {
- UndoState *state = stacks_[currentDoc_].getNextRedo(currentUndoObjectId_);
+ scMW->scrActions["editUndoAction"]->setTexts(Um::MenuUndoEmpty);
+
+ if (currentStack.redoItems() > 0)
+ {
+ UndoState *state = currentStack.getNextRedo(currentUndoObjectId_);
if (state)
- ScCore->primaryMainWindow()->scrActions["editRedoAction"]->setTexts(QString(Um::MenuRedo).arg(state->getName()));
+ scMW->scrActions["editRedoAction"]->setTexts(QString(Um::MenuRedo).arg(state->getName()));
else
- ScCore->primaryMainWindow()->scrActions["editRedoAction"]->setTexts(Um::MenuRedoEmpty);
+ scMW->scrActions["editRedoAction"]->setTexts(Um::MenuRedoEmpty);
}
else
- ScCore->primaryMainWindow()->scrActions["editRedoAction"]->setTexts(Um::MenuRedoEmpty);
+ scMW->scrActions["editRedoAction"]->setTexts(Um::MenuRedoEmpty);
}
void UndoManager::deleteInstance()
More information about the scribus-commit
mailing list