Mercurial > hg > svcore
diff 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 |
line wrap: on
line diff
--- a/data/model/BoxModel.h Thu Oct 10 10:03:31 2019 +0100 +++ b/data/model/BoxModel.h Mon Oct 14 14:17:37 2019 +0100 @@ -272,6 +272,8 @@ } } + bool isEditable() const override { return true; } + Command *getSetDataCommand(int row, int column, const QVariant &value, int role) override { @@ -298,6 +300,24 @@ 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 Box")); + 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 Box")); + Event e = m_events.getEventByIndex(row); + command->remove(e); + return command->finish(); + } + /** * XmlExportable methods.