Mercurial > hg > svcore
diff data/model/SparseOneDimensionalModel.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/SparseOneDimensionalModel.h Thu Oct 10 10:03:31 2019 +0100 +++ b/data/model/SparseOneDimensionalModel.h Mon Oct 14 14:17:37 2019 +0100 @@ -243,6 +243,26 @@ return command->finish(); } + bool isEditable() const override { return true; } + + 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(); + } + /** * NoteExportable methods. */