Mercurial > hg > svcore
comparison data/model/NoteModel.h @ 1646:b429750e64a8 single-point
Command tweaks, including executing it!
author | Chris Cannam |
---|---|
date | Thu, 14 Mar 2019 13:11:47 +0000 |
parents | 513192aa9b03 |
children | 29a20719796e |
comparison
equal
deleted
inserted
replaced
1645:82596b4deef6 | 1646:b429750e64a8 |
---|---|
190 | 190 |
191 QString getName() const override { | 191 QString getName() const override { |
192 return m_name; | 192 return m_name; |
193 } | 193 } |
194 | 194 |
195 void setName(QString name) { | |
196 m_name = name; | |
197 } | |
198 | |
195 void add(Event e) { | 199 void add(Event e) { |
196 m_add.insert(e); | 200 m_add.insert(e); |
197 } | 201 } |
198 | 202 |
199 void remove(Event e) { | 203 void remove(Event e) { |
200 m_remove.insert(e); | 204 m_remove.insert(e); |
201 } | 205 } |
202 | 206 |
203 void execute() override { | 207 void execute() override { |
204 for (const Event &e: m_add) m_model->add(e); | 208 for (const Event &e: m_add) { |
205 for (const Event &e: m_remove) m_model->remove(e); | 209 m_model->add(e); |
210 } | |
211 for (const Event &e: m_remove) { | |
212 m_model->remove(e); | |
213 } | |
206 } | 214 } |
207 | 215 |
208 void unexecute() override { | 216 void unexecute() override { |
209 for (const Event &e: m_remove) m_model->add(e); | 217 for (const Event &e: m_remove) { |
210 for (const Event &e: m_add) m_model->remove(e); | 218 m_model->add(e); |
219 } | |
220 for (const Event &e: m_add) { | |
221 m_model->remove(e); | |
222 } | |
211 } | 223 } |
212 | 224 |
213 EditCommand *finish() { | 225 EditCommand *finish() { |
214 if (m_add.empty() && m_remove.empty()) { | 226 if (m_add.empty() && m_remove.empty()) { |
215 delete this; | 227 delete this; |
216 return nullptr; | 228 return nullptr; |
217 } else { | 229 } else { |
230 execute(); | |
218 return this; | 231 return this; |
219 } | 232 } |
220 } | 233 } |
221 | 234 |
222 private: | 235 private: |