Mercurial > hg > svcore
comparison data/model/RegionModel.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 | 13bd41bd8a17 |
children | c546429d4c2f |
comparison
equal
deleted
inserted
replaced
1803:6eb3a76c74f7 | 1804:343ef2a866a4 |
---|---|
266 case 4: return e.getLabel(); | 266 case 4: return e.getLabel(); |
267 default: return QVariant(); | 267 default: return QVariant(); |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 bool isEditable() const override { return true; } | |
272 | |
271 Command *getSetDataCommand(int row, int column, const QVariant &value, int role) override { | 273 Command *getSetDataCommand(int row, int column, const QVariant &value, int role) override { |
272 | 274 |
273 if (row < 0 || row >= m_events.count()) return nullptr; | 275 if (row < 0 || row >= m_events.count()) return nullptr; |
274 if (role != Qt::EditRole) return nullptr; | 276 if (role != Qt::EditRole) return nullptr; |
275 | 277 |
286 } | 288 } |
287 | 289 |
288 auto command = new ChangeEventsCommand(getId().untyped, tr("Edit Data")); | 290 auto command = new ChangeEventsCommand(getId().untyped, tr("Edit Data")); |
289 command->remove(e0); | 291 command->remove(e0); |
290 command->add(e1); | 292 command->add(e1); |
293 return command->finish(); | |
294 } | |
295 | |
296 Command *getInsertRowCommand(int row) override { | |
297 if (row < 0 || row >= m_events.count()) return nullptr; | |
298 auto command = new ChangeEventsCommand(getId().untyped, | |
299 tr("Add Region")); | |
300 Event e = m_events.getEventByIndex(row); | |
301 command->add(e); | |
302 return command->finish(); | |
303 } | |
304 | |
305 Command *getRemoveRowCommand(int row) override { | |
306 if (row < 0 || row >= m_events.count()) return nullptr; | |
307 auto command = new ChangeEventsCommand(getId().untyped, | |
308 tr("Delete Region")); | |
309 Event e = m_events.getEventByIndex(row); | |
310 command->remove(e); | |
291 return command->finish(); | 311 return command->finish(); |
292 } | 312 } |
293 | 313 |
294 | 314 |
295 /** | 315 /** |