Mercurial > hg > svcore
comparison data/model/BoxModel.h @ 1804:343ef2a866a4
Implement missing TabularModel editing methods. Also made these pure in TabularModel, since almost all subclasses want them and (clearly) forgetting to implement them is a problem!
author | Chris Cannam |
---|---|
date | Mon, 14 Oct 2019 14:17:37 +0100 |
parents | cb45c0a1dfe1 |
children | c546429d4c2f |
comparison
equal
deleted
inserted
replaced
1803:6eb3a76c74f7 | 1804:343ef2a866a4 |
---|---|
270 case 5: return e.getLabel(); | 270 case 5: return e.getLabel(); |
271 default: return QVariant(); | 271 default: return QVariant(); |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 bool isEditable() const override { return true; } | |
276 | |
275 Command *getSetDataCommand(int row, int column, const QVariant &value, | 277 Command *getSetDataCommand(int row, int column, const QVariant &value, |
276 int role) override { | 278 int role) override { |
277 | 279 |
278 if (row < 0 || row >= m_events.count()) return nullptr; | 280 if (row < 0 || row >= m_events.count()) return nullptr; |
279 if (role != Qt::EditRole) return nullptr; | 281 if (role != Qt::EditRole) return nullptr; |
293 } | 295 } |
294 | 296 |
295 auto command = new ChangeEventsCommand(getId().untyped, tr("Edit Data")); | 297 auto command = new ChangeEventsCommand(getId().untyped, tr("Edit Data")); |
296 command->remove(e0); | 298 command->remove(e0); |
297 command->add(e1); | 299 command->add(e1); |
300 return command->finish(); | |
301 } | |
302 | |
303 Command *getInsertRowCommand(int row) override { | |
304 if (row < 0 || row >= m_events.count()) return nullptr; | |
305 auto command = new ChangeEventsCommand(getId().untyped, | |
306 tr("Add Box")); | |
307 Event e = m_events.getEventByIndex(row); | |
308 command->add(e); | |
309 return command->finish(); | |
310 } | |
311 | |
312 Command *getRemoveRowCommand(int row) override { | |
313 if (row < 0 || row >= m_events.count()) return nullptr; | |
314 auto command = new ChangeEventsCommand(getId().untyped, | |
315 tr("Delete Box")); | |
316 Event e = m_events.getEventByIndex(row); | |
317 command->remove(e); | |
298 return command->finish(); | 318 return command->finish(); |
299 } | 319 } |
300 | 320 |
301 | 321 |
302 /** | 322 /** |