diff data/model/SparseOneDimensionalModel.h @ 424:eafef13bb0b3

* Add more data-editor support to various models
author Chris Cannam
date Thu, 12 Jun 2008 14:33:45 +0000
parents 6a96bff0bd59
children f5e8f12d2e58
line wrap: on
line diff
--- a/data/model/SparseOneDimensionalModel.h	Thu Jun 12 10:47:11 2008 +0000
+++ b/data/model/SparseOneDimensionalModel.h	Thu Jun 12 14:33:45 2008 +0000
@@ -132,9 +132,6 @@
 
     virtual QVariant getData(int row, int column, int role) const
     {
-        if (role != Qt::EditRole &&
-            role != Qt::DisplayRole &&
-            role != SortRole) return QVariant();
         PointListIterator i = getPointListIteratorForRow(row);
         if (i == m_points.end()) return QVariant();
 
@@ -150,6 +147,25 @@
         }
     }
 
+    virtual Command *getSetDataCommand(int row, int column, const QVariant &value, int role)
+    {
+        if (role != Qt::EditRole) return false;
+        PointListIterator i = getPointListIteratorForRow(row);
+        if (i == m_points.end()) return false;
+        EditCommand *command = new EditCommand(this, tr("Edit Data"));
+
+        Point point(*i);
+        command->deletePoint(point);
+
+        switch (column) {
+        case 0: case 1: point.frame = value.toInt(); break; 
+        case 2: point.label = value.toString(); break;
+        }
+
+        command->addPoint(point);
+        return command->finish();
+    }
+
     virtual bool isColumnTimeValue(int column) const
     {
         return (column < 2);