comparison data/model/SparseTimeValueModel.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
277 case 3: return e.getLabel(); 277 case 3: return e.getLabel();
278 default: return QVariant(); 278 default: return QVariant();
279 } 279 }
280 } 280 }
281 281
282 Command *getSetDataCommand(int row, int column, const QVariant &value, int role) override { 282 bool isEditable() const override { return true; }
283
284 Command *getSetDataCommand(int row, int column, const QVariant &value,
285 int role) override {
283 if (row < 0 || row >= m_events.count()) return nullptr; 286 if (row < 0 || row >= m_events.count()) return nullptr;
284 if (role != Qt::EditRole) return nullptr; 287 if (role != Qt::EditRole) return nullptr;
285 288
286 Event e0 = m_events.getEventByIndex(row); 289 Event e0 = m_events.getEventByIndex(row);
287 Event e1; 290 Event e1;
295 } 298 }
296 299
297 auto command = new ChangeEventsCommand(getId().untyped, tr("Edit Data")); 300 auto command = new ChangeEventsCommand(getId().untyped, tr("Edit Data"));
298 command->remove(e0); 301 command->remove(e0);
299 command->add(e1); 302 command->add(e1);
303 return command->finish();
304 }
305
306 Command *getInsertRowCommand(int row) override {
307 if (row < 0 || row >= m_events.count()) return nullptr;
308 auto command = new ChangeEventsCommand(getId().untyped,
309 tr("Add Point"));
310 Event e = m_events.getEventByIndex(row);
311 command->add(e);
312 return command->finish();
313 }
314
315 Command *getRemoveRowCommand(int row) override {
316 if (row < 0 || row >= m_events.count()) return nullptr;
317 auto command = new ChangeEventsCommand(getId().untyped,
318 tr("Delete Point"));
319 Event e = m_events.getEventByIndex(row);
320 command->remove(e);
300 return command->finish(); 321 return command->finish();
301 } 322 }
302 323
303 /** 324 /**
304 * XmlExportable methods. 325 * XmlExportable methods.