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