diff data/model/NoteModel.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 ee3b248bda25
line wrap: on
line diff
--- a/data/model/NoteModel.h	Thu Oct 10 10:03:31 2019 +0100
+++ b/data/model/NoteModel.h	Mon Oct 14 14:17:37 2019 +0100
@@ -322,6 +322,26 @@
         return SortNumeric;
     }
 
+    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 Note"));
+        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 Note"));
+        Event e = m_events.getEventByIndex(row);
+        command->remove(e);
+        return command->finish();
+    }
+
     /**
      * NoteExportable methods.
      */