Mercurial > hg > svcore
diff 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 |
line wrap: on
line diff
--- a/data/model/SparseTimeValueModel.h Thu Oct 10 10:03:31 2019 +0100 +++ b/data/model/SparseTimeValueModel.h Mon Oct 14 14:17:37 2019 +0100 @@ -279,7 +279,10 @@ } } - Command *getSetDataCommand(int row, int column, const QVariant &value, int role) override { + bool isEditable() const override { return true; } + + Command *getSetDataCommand(int row, int column, const QVariant &value, + int role) override { if (row < 0 || row >= m_events.count()) return nullptr; if (role != Qt::EditRole) return nullptr; @@ -299,6 +302,24 @@ command->add(e1); return command->finish(); } + + Command *getInsertRowCommand(int row) override { + if (row < 0 || row >= m_events.count()) return nullptr; + auto command = new ChangeEventsCommand(getId().untyped, + tr("Add Point")); + Event e = m_events.getEventByIndex(row); + command->add(e); + return command->finish(); + } + + Command *getRemoveRowCommand(int row) override { + if (row < 0 || row >= m_events.count()) return nullptr; + auto command = new ChangeEventsCommand(getId().untyped, + tr("Delete Point")); + Event e = m_events.getEventByIndex(row); + command->remove(e); + return command->finish(); + } /** * XmlExportable methods.