diff 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
line wrap: on
line diff
--- a/data/model/RegionModel.h	Thu Oct 10 10:03:31 2019 +0100
+++ b/data/model/RegionModel.h	Mon Oct 14 14:17:37 2019 +0100
@@ -268,6 +268,8 @@
         }
     }
 
+    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;
@@ -291,6 +293,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 Region"));
+        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 Region"));
+        Event e = m_events.getEventByIndex(row);
+        command->remove(e);
+        return command->finish();
+    }
+
     
     /**
      * XmlExportable methods.