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