comparison data/model/ModelDataTableModel.h @ 413:0b274e1aaf10

* Start adding a spreadsheet-style editor window for model data
author Chris Cannam
date Fri, 06 Jun 2008 15:26:27 +0000
parents
children a00902d5f0ab
comparison
equal deleted inserted replaced
412:5e4238d08caa 413:0b274e1aaf10
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2008 QMUL.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _MODEL_DATA_TABLE_MODEL_H_
17 #define _MODEL_DATA_TABLE_MODEL_H_
18
19 #include <QAbstractItemModel>
20
21 #include "Model.h"
22
23 class ModelDataTableModel : public QAbstractItemModel
24 {
25 Q_OBJECT
26
27 public:
28 ModelDataTableModel(Model *m);
29 virtual ~ModelDataTableModel();
30
31 QVariant data(const QModelIndex &index, int role) const;
32
33 bool setData(const QModelIndex &index, const QVariant &value, int role);
34
35 Qt::ItemFlags flags(const QModelIndex &index) const;
36
37 QVariant headerData(int section, Qt::Orientation orientation,
38 int role = Qt::DisplayRole) const;
39
40 QModelIndex index(int row, int column,
41 const QModelIndex &parent = QModelIndex()) const;
42
43 QModelIndex parent(const QModelIndex &index) const;
44
45 int rowCount(const QModelIndex &parent = QModelIndex()) const;
46 int columnCount(const QModelIndex &parent = QModelIndex()) const;
47
48 static bool canHandleModelType(Model *);
49
50 protected slots:
51 void modelChanged();
52 void modelChanged(size_t, size_t);
53
54 protected:
55 // We need to have some sort of map between row and time in sample
56 // frames. I guess this will do for now.
57
58 std::vector<size_t> m_rows; // contains sample frame
59
60 Model *m_model;
61
62 void rebuildRowVector();
63 template <typename PointType> void rebuildRowVectorSparse();
64 template <typename PointType> QVariant dataSparse(int row, int col) const;
65 };
66
67 #endif