Source Code (Use browser search to find items of interest.)
Class Index
killustrator'CommandHistory (./koffice/killustrator/share/CommandHistory.h:32)
class CommandHistory : public QObject {
Q_OBJECT
public:
CommandHistory ();
~CommandHistory() {};
void addCommand (Command *cmd, bool exec = false);
void undo ();
void redo ();
void reset ();
bool isUndoPossible() const { return (index > 0); }
bool isRedoPossible() const { return (index < history.count()); }
QString getUndoName();
QString getRedoName();
void dump ();
signals:
void changed(bool undoPossible, bool redoPossible);
private:
QList<Command> history;
unsigned int index;
};
killustrator'CommandHistory::CommandHistory() (./koffice/killustrator/share/CommandHistory.cc:33)
CommandHistory::CommandHistory () {
index = 0;
history.setAutoDelete (true);
}
killustrator'CommandHistory::addCommand() (./koffice/killustrator/share/CommandHistory.cc:38)
void CommandHistory::addCommand (Command *cmd, bool exec) {
if (exec)
cmd->execute ();
// remove all command objects "behind" the current command
unsigned int num = history.count ();
for (unsigned int i = index; i < num; i++)
history.remove (index);
history.append (cmd);
if (history.count () > MAX_HISTSIZE)
history.removeFirst ();
else
index++;
emit changed(isUndoPossible(), isRedoPossible());
}
killustrator'CommandHistory::undo() (./koffice/killustrator/share/CommandHistory.cc:55)
void CommandHistory::undo () {
if (index > 0) {
// get the last executed command
Command* cmd = history.at (index - 1);
// undo it
cmd->unexecute ();
// and update the history list
index--;
emit changed(isUndoPossible(), isRedoPossible());
}
}
killustrator'CommandHistory::redo() (./koffice/killustrator/share/CommandHistory.cc:67)
void CommandHistory::redo () {
if (index < history.count ()) {
Command* cmd = history.at (index);
cmd->execute ();
index++;
emit changed(isUndoPossible(), isRedoPossible());
}
}
killustrator'CommandHistory::reset() (./koffice/killustrator/share/CommandHistory.cc:76)
void CommandHistory::reset () {
history.clear ();
index = 0;
emit changed(false, false);
}
killustrator'CommandHistory::getUndoName() (./koffice/killustrator/share/CommandHistory.cc:82)
QString CommandHistory::getUndoName()
{
if (index > 0) {
Command* cmd = history.at (index - 1);
return cmd->getName();
} else
return QSTR_NULL;
}
killustrator'CommandHistory::getRedoName() (./koffice/killustrator/share/CommandHistory.cc:91)
QString CommandHistory::getRedoName()
{
if (index < history.count ())
return history.at (index)->getName();
else
return QSTR_NULL;
}
killustrator'CommandHistory::dump() (./koffice/killustrator/share/CommandHistory.cc:99)
void CommandHistory::dump () {
QListIterator<Command> it (history);
for (it += (index - 1); it.current (); --it)
cout << it.current ()->getName () << "\n";
cout << "index = " << index << endl;
}