1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#ifndef CONTROLMODEL_H
#define CONTROLMODEL_H
#include <QAbstractTableModel>
#include <QVariant>
#include <QVector>
#include <QHash>
#include <QList>
#include <QModelIndex>
#include <QString>
#include "preferences/usersettings.h"
#include "control/controlobject.h"
#include "control/controlproxy.h"
class ControlModel final : public QAbstractTableModel {
Q_OBJECT
public:
enum ControlColumn {
CONTROL_COLUMN_GROUP = 0,
CONTROL_COLUMN_ITEM,
CONTROL_COLUMN_VALUE,
CONTROL_COLUMN_PARAMETER,
CONTROL_COLUMN_TITLE,
CONTROL_COLUMN_DESCRIPTION,
CONTROL_COLUMN_FILTER,
NUM_CONTROL_COLUMNS
};
ControlModel(QObject* pParent=NULL);
virtual ~ControlModel();
void addControl(const ConfigKey& control, const QString& title,
const QString& description);
////////////////////////////////////////////////////////////////////////////
// QAbstractItemModel methods
////////////////////////////////////////////////////////////////////////////
int rowCount(const QModelIndex& parent = QModelIndex()) const;
int columnCount(const QModelIndex& parent = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
bool setHeaderData(int section, Qt::Orientation orientation,
const QVariant& value, int role = Qt::EditRole);
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex& index) const;
bool setData(const QModelIndex& index, const QVariant& value,
int role = Qt::EditRole);
private:
struct ControlInfo {
ConfigKey key;
QString title;
QString description;
ControlProxy* pControl;
};
QVector<QHash<int, QVariant> > m_headerInfo;
QList<ControlInfo> m_controls;
};
#endif /* CONTROLMODEL_H */
|