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
33namespace QtPdCom {
34
35/****************************************************************************/
36
41class QTPDCOM_PUBLIC TableModel: public QAbstractTableModel
42{
43 Q_OBJECT
44
45 public:
46 TableModel(QObject *parent = nullptr);
48
49 void addColumn(TableColumn *);
50 void clearColumns();
51
52 bool isEditing() const;
53 unsigned int getRowCapacity() const;
54 bool hasVisibleRowsVariable() const;
55 virtual int rowCount(const QModelIndex &) const;
56 virtual int columnCount(const QModelIndex &) const;
57 virtual QVariant data(const QModelIndex &, int) const;
58 virtual QVariant headerData(int, Qt::Orientation, int) const;
59 virtual Qt::ItemFlags flags(const QModelIndex &) const;
60 virtual bool setData(const QModelIndex &, const QVariant &, int);
61
65 void setHighlightRowVariable(
66 PdCom::Variable,
67 const PdCom::Selector & = {},
68 const Transmission & =
70 );
74 void setHighlightRowVariable(
75 PdCom::Process *,
76 const QString &,
77 const PdCom::Selector & = {},
78 const Transmission & =
80 );
81
82 void clearHighlightRowVariable();
83
88 void setVisibleRowsVariable(
89 PdCom::Variable pv,
90 const PdCom::Selector & = {},
91 const Transmission & =
93 );
94
99 void setVisibleRowsVariable(
100 PdCom::Process *,
101 const QString &,
102 const PdCom::Selector & = {},
103 const Transmission & =
105 );
106
107 void clearVisibleRowsVariable();
108
109 void setHighlightColor(QColor, int = -1);
110 void setDisabledColor(QColor, int = -1);
111
115 {
118 Exception(const QString &msg):
119 msg(msg)
120 {}
121 QString msg;
122 };
123
124 signals:
125 void editingChanged(bool);
126
127 public slots:
128 void commit();
129 void revert(); // virtual from AbstractItemModel
130 void addRow();
131 void remRow(); // not to be mixed up with the removeRow()
132 // function from AbstractItemModel
133
134 private:
135 class Q_DECL_HIDDEN Impl;
136
137 std::unique_ptr<Impl> impl;
138
139 private slots:
140 void dimensionChanged();
141 void columnHeaderChanged();
142 void valueChanged();
143 void highlightRowChanged();
144 void visibleRowCountChanged();
145};
146
147/****************************************************************************/
148
149} // namespace QtPdCom
150
151#endif
#define QTPDCOM_PUBLIC
Definition: Export.h:30
Table Column.
Definition: TableColumn.h:43
Table model.
Definition: TableModelImpl.h:41
Table model.
Definition: TableModel.h:42
void editingChanged(bool)
std::unique_ptr< Impl > impl
Definition: TableModel.h:137
Transmission mode for subscriptions.
Definition: Transmission.h:78
Definition: BroadcastModel.h:32
constexpr struct QtPdCom::event_mode_tag event_mode
Exception type.
Definition: TableModel.h:115
Exception(const QString &msg)
Constructor.
Definition: TableModel.h:118
QString msg
Exception message.
Definition: TableModel.h:121