Mercurial > hg > svcore
comparison base/CommandHistory.cpp @ 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 | 2b6412c1e724 |
children | 5364a9d338a2 |
comparison
equal
deleted
inserted
replaced
43:b8aae4f883b7 | 44:701404725897 |
---|---|
31 CommandHistory *CommandHistory::m_instance = 0; | 31 CommandHistory *CommandHistory::m_instance = 0; |
32 | 32 |
33 CommandHistory::CommandHistory() : | 33 CommandHistory::CommandHistory() : |
34 m_undoLimit(50), | 34 m_undoLimit(50), |
35 m_redoLimit(50), | 35 m_redoLimit(50), |
36 m_savedAt(0) | 36 m_savedAt(0), |
37 m_currentMacro(0), | |
38 m_executeMacro(false) | |
37 { | 39 { |
38 m_undoAction = new QAction(QIcon(":/icons/undo.png"), tr("&Undo"), this); | 40 m_undoAction = new QAction(QIcon(":/icons/undo.png"), tr("&Undo"), this); |
39 m_undoAction->setShortcut(tr("Ctrl+Z")); | 41 m_undoAction->setShortcut(tr("Ctrl+Z")); |
40 connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo())); | 42 connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo())); |
41 | 43 |
103 void | 105 void |
104 CommandHistory::addCommand(Command *command, bool execute) | 106 CommandHistory::addCommand(Command *command, bool execute) |
105 { | 107 { |
106 if (!command) return; | 108 if (!command) return; |
107 | 109 |
110 if (m_currentMacro) { | |
111 addToMacro(command); | |
112 return; | |
113 } | |
114 | |
108 std::cerr << "MVCH::addCommand: " << command->getName().toLocal8Bit().data() << std::endl; | 115 std::cerr << "MVCH::addCommand: " << command->getName().toLocal8Bit().data() << std::endl; |
109 | 116 |
110 // We can't redo after adding a command | 117 // We can't redo after adding a command |
111 clearStack(m_redoStack); | 118 clearStack(m_redoStack); |
112 | 119 |
125 emit commandExecuted(); | 132 emit commandExecuted(); |
126 emit commandExecuted(command); | 133 emit commandExecuted(command); |
127 | 134 |
128 updateActions(); | 135 updateActions(); |
129 } | 136 } |
137 | |
138 void | |
139 CommandHistory::addToMacro(Command *command) | |
140 { | |
141 std::cerr << "MVCH::addToMacro: " << command->getName().toLocal8Bit().data() << std::endl; | |
142 | |
143 if (m_executeMacro) command->execute(); | |
144 m_currentMacro->addCommand(command); | |
145 } | |
146 | |
147 void | |
148 CommandHistory::startCompoundOperation(QString name, bool execute) | |
149 { | |
150 if (m_currentMacro) { | |
151 std::cerr << "MVCH::startCompoundOperation: ERROR: compound operation already in progress!" << std::endl; | |
152 std::cerr << "(name is " << m_currentMacro->getName().toLocal8Bit().data() << ")" << std::endl; | |
153 } | |
154 | |
155 m_currentMacro = new MacroCommand(name); | |
156 m_executeMacro = execute; | |
157 } | |
158 | |
159 void | |
160 CommandHistory::endCompoundOperation() | |
161 { | |
162 if (!m_currentMacro) { | |
163 std::cerr << "MVCH::endCompoundOperation: ERROR: no compound operation in progress!" << std::endl; | |
164 } | |
165 | |
166 Command *toAdd = m_currentMacro; | |
167 m_currentMacro = 0; | |
168 | |
169 // We don't execute the macro command here, because we have been | |
170 // executing the individual commands as we went along if | |
171 // m_executeMacro was true. | |
172 addCommand(toAdd, false); | |
173 } | |
130 | 174 |
131 void | 175 void |
132 CommandHistory::addExecutedCommand(Command *command) | 176 CommandHistory::addExecutedCommand(Command *command) |
133 { | 177 { |
134 addCommand(command, false); | 178 addCommand(command, false); |