Mercurial > hg > svcore
changeset 44:701404725897
* Use commands for add/delete pane in main window
* Add compound command collection to command history (for add pane, import file
etc)
* Add hide/show pane and hidden pane list to PaneStack
* Various other fixes
author | Chris Cannam |
---|---|
date | Mon, 13 Mar 2006 17:55:19 +0000 |
parents | b8aae4f883b7 |
children | b11edc8b8ea0 |
files | base/CommandHistory.cpp base/CommandHistory.h base/View.cpp base/View.h |
diffstat | 4 files changed, 60 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/base/CommandHistory.cpp Fri Mar 10 12:28:22 2006 +0000 +++ b/base/CommandHistory.cpp Mon Mar 13 17:55:19 2006 +0000 @@ -33,7 +33,9 @@ CommandHistory::CommandHistory() : m_undoLimit(50), m_redoLimit(50), - m_savedAt(0) + m_savedAt(0), + m_currentMacro(0), + m_executeMacro(false) { m_undoAction = new QAction(QIcon(":/icons/undo.png"), tr("&Undo"), this); m_undoAction->setShortcut(tr("Ctrl+Z")); @@ -105,6 +107,11 @@ { if (!command) return; + if (m_currentMacro) { + addToMacro(command); + return; + } + std::cerr << "MVCH::addCommand: " << command->getName().toLocal8Bit().data() << std::endl; // We can't redo after adding a command @@ -129,6 +136,43 @@ } void +CommandHistory::addToMacro(Command *command) +{ + std::cerr << "MVCH::addToMacro: " << command->getName().toLocal8Bit().data() << std::endl; + + if (m_executeMacro) command->execute(); + m_currentMacro->addCommand(command); +} + +void +CommandHistory::startCompoundOperation(QString name, bool execute) +{ + if (m_currentMacro) { + std::cerr << "MVCH::startCompoundOperation: ERROR: compound operation already in progress!" << std::endl; + std::cerr << "(name is " << m_currentMacro->getName().toLocal8Bit().data() << ")" << std::endl; + } + + m_currentMacro = new MacroCommand(name); + m_executeMacro = execute; +} + +void +CommandHistory::endCompoundOperation() +{ + if (!m_currentMacro) { + std::cerr << "MVCH::endCompoundOperation: ERROR: no compound operation in progress!" << std::endl; + } + + Command *toAdd = m_currentMacro; + m_currentMacro = 0; + + // We don't execute the macro command here, because we have been + // executing the individual commands as we went along if + // m_executeMacro was true. + addCommand(toAdd, false); +} + +void CommandHistory::addExecutedCommand(Command *command) { addCommand(command, false);
--- a/base/CommandHistory.h Fri Mar 10 12:28:22 2006 +0000 +++ b/base/CommandHistory.h Mon Mar 13 17:55:19 2006 +0000 @@ -28,6 +28,7 @@ #include <map> class Command; +class MacroCommand; class QAction; class QMenu; class QToolBar; @@ -70,6 +71,12 @@ /// Set the maximum number of items in the redo history. void setRedoLimit(int limit); + /// Start recording commands to batch up into a single compound command. + void startCompoundOperation(QString name, bool execute); + + /// Finish recording commands and store the compound command. + void endCompoundOperation(); + public slots: /** * Checkpoint function that should be called when the document is @@ -143,6 +150,10 @@ int m_redoLimit; int m_savedAt; + MacroCommand *m_currentMacro; + bool m_executeMacro; + void addToMacro(Command *command); + void updateActions(); void clipCommands();
--- a/base/View.cpp Fri Mar 10 12:28:22 2006 +0000 +++ b/base/View.cpp Mon Mar 13 17:55:19 2006 +0000 @@ -154,8 +154,10 @@ } void -View::propertyContainerSelected(PropertyContainer *pc) +View::propertyContainerSelected(View *client, PropertyContainer *pc) { + if (client != this) return; + if (pc == m_propertyContainer) { if (m_haveSelectedLayer) { m_haveSelectedLayer = false;
--- a/base/View.h Fri Mar 10 12:28:22 2006 +0000 +++ b/base/View.h Mon Mar 13 17:55:19 2006 +0000 @@ -232,7 +232,7 @@ virtual void viewManagerPlaybackFrameChanged(unsigned long); virtual void viewManagerZoomLevelChanged(void *, unsigned long, bool); - virtual void propertyContainerSelected(PropertyContainer *pc); + virtual void propertyContainerSelected(View *, PropertyContainer *pc); virtual void selectionChanged(); virtual void toolModeChanged();