diff data/model/ModelDataTableModel.h @ 420:50a956688baa

* reorganise tabular data editor model support
author Chris Cannam
date Wed, 11 Jun 2008 16:13:25 +0000
parents 64e7bbb255d3
children 4caa28a0a8a2
line wrap: on
line diff
--- a/data/model/ModelDataTableModel.h	Wed Jun 11 12:54:18 2008 +0000
+++ b/data/model/ModelDataTableModel.h	Wed Jun 11 16:13:25 2008 +0000
@@ -18,8 +18,9 @@
 
 #include <QAbstractItemModel>
 
-#include "Model.h"
+#include <vector>
 
+class TabularModel;
 class Command;
 
 class ModelDataTableModel : public QAbstractItemModel
@@ -27,7 +28,7 @@
     Q_OBJECT
 
 public:
-    ModelDataTableModel(Model *m);
+    ModelDataTableModel(TabularModel *m);
     virtual ~ModelDataTableModel();
 
     QVariant data(const QModelIndex &index, int role) const;
@@ -50,7 +51,7 @@
     QModelIndex getModelIndexForFrame(size_t frame) const;
     size_t getFrameForModelIndex(const QModelIndex &) const;
 
-    static bool canHandleModelType(Model *);
+    void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
 
 signals:
     void frameSelected(size_t);
@@ -61,19 +62,14 @@
     void modelChanged(size_t, size_t);
 
 protected:
-    // We need to have some sort of map between row and time in sample
-    // frames.  I guess this will do for now.
-
-    std::vector<size_t> m_rows; // contains sample frame
-
-    Model *m_model;
-
-    void rebuildRowVector();
-    template <typename PointType> void rebuildRowVectorSparse();
-    template <typename PointType> QVariant dataSparse(int row, int col,
-                                                      bool withUnit) const;
-    template <typename PointType> bool setDataSparse(int row, int col,
-                                                     QVariant value);
+    TabularModel *m_model;
+    int m_sortColumn;
+    Qt::SortOrder m_sortOrdering;
+    typedef std::vector<int> RowList;
+    RowList m_sort;
+    int getSorted(int row);
+    int getUnsorted(int row);
+    void resort();
 };
 
 #endif