changeset 421:397fe91dc8e0

* Fix for data modification in data edit view... now why isn't the command appearing on the undo menu?
author Chris Cannam
date Wed, 11 Jun 2008 17:00:04 +0000
parents 50a956688baa
children 4caa28a0a8a2
files data/model/ModelDataTableModel.cpp data/model/SparseTimeValueModel.h data/model/TabularModel.h
diffstat 3 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/data/model/ModelDataTableModel.cpp	Wed Jun 11 16:13:25 2008 +0000
+++ b/data/model/ModelDataTableModel.cpp	Wed Jun 11 17:00:04 2008 +0000
@@ -22,7 +22,9 @@
 #include <iostream>
 
 ModelDataTableModel::ModelDataTableModel(TabularModel *m) :
-    m_model(m)
+    m_model(m),
+    m_sortColumn(0),
+    m_sortOrdering(Qt::AscendingOrder)
 {
     Model *baseModel = dynamic_cast<Model *>(m);
 
@@ -46,9 +48,12 @@
 ModelDataTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
 {
     if (!index.isValid()) return false;
-    Command *command = m_model->setData(getUnsorted(index.row()),
-                                        index.column(), value, role);
+    std::cerr << "ModelDataTableModel::setData(" << index.row() << ", " << index.column() << ", " << value.toString().toStdString() << ", " << role << ")" << std::endl;
+    Command *command = m_model->getSetDataCommand(getUnsorted(index.row()),
+                                                  index.column(),
+                                                  value, role);
     if (command) {
+        std::cerr << "emitting executeCommand" << std::endl;
         emit executeCommand(command);
         return true;
     } else {
@@ -177,6 +182,6 @@
 void
 ModelDataTableModel::resort()
 {
-    //...
+    
 }
 
--- a/data/model/SparseTimeValueModel.h	Wed Jun 11 16:13:25 2008 +0000
+++ b/data/model/SparseTimeValueModel.h	Wed Jun 11 17:00:04 2008 +0000
@@ -138,11 +138,16 @@
         }
     }
 
-    virtual Command *setData(int row, int column, QVariant value, int role) 
+    virtual Command *getSetDataCommand(int row, int column, const QVariant &value, int role) const
     {
+        std::cerr << "SparseTimeValueModel::setData: row = " << row << ", column = " << column << ", role = " << role << std::endl;
+
         if (role != Qt::EditRole) return false;
         PointListIterator i = getPointListIteratorForRow(row);
-        if (i == m_points.end()) return false;
+        if (i == m_points.end()) {
+            std::cerr << "Failed to find point iterator for row " << row << std::endl;
+            return false;
+        }
         EditCommand *command = new EditCommand(this, tr("Edit Data"));
 
         Point point(*i);
--- a/data/model/TabularModel.h	Wed Jun 11 16:13:25 2008 +0000
+++ b/data/model/TabularModel.h	Wed Jun 11 17:00:04 2008 +0000
@@ -46,8 +46,7 @@
     virtual bool isColumnTimeValue(int col) const = 0;
 
     virtual bool isEditable() const { return false; }
-    virtual Command *setData(int row, int column, const QVariant &, int role)
-    { return 0; }
+    virtual Command *getSetDataCommand(int row, int column, const QVariant &, int role) const { return 0; }
 };
 
 #endif