QtPdCom  1.0.0
TableModel.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2012-2022 Florian Pose <fp@igh.de>
4  * 2013 Dr. Wilhelm Hagemeister <hm@igh-essen.com>
5  *
6  * This file is part of the QtPdCom library.
7  *
8  * The QtPdCom library is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * The QtPdCom library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with the QtPdCom Library. If not, see <http://www.gnu.org/licenses/>.
20  *
21  ****************************************************************************/
22 
23 #ifndef QTPDCOM_TABLEMODEL_H
24 #define QTPDCOM_TABLEMODEL_H
25 
26 #include "TableColumn.h"
27 #include "ScalarVariable.h"
28 
29 #include <memory>
30 #include <QAbstractTableModel>
31 #include <QColor>
32 
33 namespace QtPdCom {
34 
35 /****************************************************************************/
36 
42  public QAbstractTableModel
43 {
44  Q_OBJECT
45 
46  public:
47  TableModel(QObject *parent = nullptr);
48  ~TableModel();
49 
50  void addColumn(TableColumn *);
51  void clearColumns();
52 
53  bool isEditing() const;
54  unsigned int getRowCapacity() const;
55  bool hasVisibleRowsVariable() const;
56  virtual int rowCount(const QModelIndex &) const;
57  virtual int columnCount(const QModelIndex &) const;
58  virtual QVariant data(const QModelIndex &, int) const;
59  virtual QVariant headerData(int, Qt::Orientation, int) const;
60  virtual Qt::ItemFlags flags(const QModelIndex &) const;
61  virtual bool setData(const QModelIndex &, const QVariant &, int);
62 
66  void setHighlightRowVariable(
67  PdCom::Variable,
68  const PdCom::Selector & = {},
70  );
74  void setHighlightRowVariable(
75  PdCom::Process *,
76  const QString &,
77  const PdCom::Selector & = {},
79  );
80 
81  void clearHighlightRowVariable();
82 
87  void setVisibleRowsVariable(
88  PdCom::Variable pv
89  );
90 
91  void clearVisibleRowsVariable();
92 
93  void setHighlightColor(QColor, int = -1);
94  void setDisabledColor(QColor, int = -1);
95 
98  struct Exception {
101  Exception(const QString &msg): msg(msg) {}
102  QString msg;
103  };
104 
105  signals:
106  void editingChanged(bool);
107 
108  public slots:
109  void commit();
110  void revert(); // virtual from AbstractItemModel
111  void addRow();
112  void remRow(); // not to be mixed up with the removeRow()
113  // function from AbstractItemModel
114 
115  private:
116  class Q_DECL_HIDDEN Impl;
117 
118  std::unique_ptr<Impl> impl;
119 
120  private slots:
121  void dimensionChanged();
122  void columnHeaderChanged();
123  void valueChanged();
124  void highlightRowChanged();
125  void visibleRowCountChanged();
126 };
127 
128 /****************************************************************************/
129 
130 } // namespace
131 
132 #endif
Table Column.
Definition: TableColumn.h:41
Transmission mode for subscriptions.
Definition: Transmission.h:77
Exception type.
Definition: TableModel.h:98
Definition: Message.h:31
Table model.
Definition: TableModelImpl.h:40
std::unique_ptr< Impl > impl
Definition: TableModel.h:118
Exception(const QString &msg)
Constructor.
Definition: TableModel.h:101
Table model.
Definition: TableModel.h:41
#define QTPDCOM_PUBLIC
Definition: Export.h:30
QString msg
Exception message.
Definition: TableModel.h:102
constexpr struct QtPdCom::event_mode_tag event_mode