QtPdCom  1.5.2
TableColumn.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_TABLECOLUMN_H
24#define QTPDCOM_TABLECOLUMN_H
25
26#include "Transmission.h"
27#include "Export.h"
28
29#include <pdcom5/Process.h>
30
31#include <QColor>
32#include <QObject>
33#include <QString>
34
35namespace QtPdCom {
36
37class TableModel;
38
39/****************************************************************************/
40
43class QTPDCOM_PUBLIC TableColumn: public QObject
44{
45 Q_OBJECT
46
47 public:
48 TableColumn(const QString & = QString(), QObject *parent = nullptr);
50
51 void setHeader(const QString &);
52 const QString &getHeader() const;
53
54 void setVariable(
55 PdCom::Variable,
57 double = 1.0,
58 double = 0.0);
59 void setVariable(
60 PdCom::Process *,
61 const QString &,
63 double = 1.0,
64 double = 0.0);
65 void clearVariable();
66 void clearData();
67
68 quint32 getDecimals() const;
69 void setDecimals(quint32);
70
73 double getLowerLimit() const;
74 void setLowerLimit(double);
75
76 double getUpperLimit() const;
77 void setUpperLimit(double);
78
79 unsigned int getRows() const;
80
81 QVariant data(unsigned int, int) const;
82 QVariant headerData(int) const;
83 Qt::ItemFlags flags(unsigned int) const;
84 bool setData(unsigned int, const QString &, int);
85 void setEnabled(bool, int = -1);
86
87 bool isEditing() const;
88 bool isEnabled() const;
89 void commit();
90 void revert();
91
92 void setHighlightRow(int);
93
94 void setHighlightColor(QColor);
95 void setDisabledColor(QColor);
96
99 struct Exception
100 {
103 Exception(const QString &msg):
104 msg(msg)
105 {}
106 QString msg;
107 };
108
119
120 signals:
124
125 private:
126 class Q_DECL_HIDDEN Impl;
127 std::unique_ptr<Impl> impl;
128
129 friend class TableModel;
130};
131
132/****************************************************************************/
133
134} // namespace QtPdCom
135
136#endif
#define QTPDCOM_PUBLIC
Definition Export.h:30
bool setData(unsigned int, const QString &, int)
Set an edit value.
Definition TableColumn.cpp:555
Qt::ItemFlags flags(unsigned int) const
Implements the Model interface.
Definition TableColumn.cpp:532
TableColumn(const QString &=QString(), QObject *parent=nullptr)
Constructor.
Definition TableColumn.cpp:147
bool isEnabled() const
Definition TableColumn.cpp:635
void clearVariable()
Unsubscribe from a Variable.
Definition TableColumn.cpp:262
void setUpperLimit(double)
Sets the upperlimit for the values of the col.
Definition TableColumn.cpp:340
std::unique_ptr< Impl > impl
Definition TableColumn.h:127
void setEnabled(bool, int=-1)
Set enabled for a column.
Definition TableColumn.cpp:614
void setHighlightRow(int)
Definition TableColumn.cpp:691
quint32 getDecimals() const
Returns the number of decimals.
Definition TableColumn.cpp:289
void setDecimals(quint32)
Sets the number of decimals.
Definition TableColumn.cpp:298
void setVariable(PdCom::Variable, const Transmission &=QtPdCom::event_mode, double=1.0, double=0.0)
Subscribes to a ProcessVariable.
Definition TableColumn.cpp:181
void revert()
Reverts all edited values.
Definition TableColumn.cpp:680
void setHighlightColor(QColor)
Definition TableColumn.cpp:699
void setLowerLimit(double)
Sets the lowerlimit for the values of the col.
Definition TableColumn.cpp:319
QVariant headerData(int) const
Get header data.
Definition TableColumn.cpp:472
Roles
Definition TableColumn.h:109
@ ValidRole
element is not valid due to columncount < nelem
Definition TableColumn.h:111
@ UpperLimitRole
Definition TableColumn.h:116
@ DecimalsRole
Definition TableColumn.h:114
@ LowerLimitRole
Definition TableColumn.h:115
@ HighlightRole
row is highlightRow
Definition TableColumn.h:110
@ IsEnabledRole
Definition TableColumn.h:112
@ IsEditingRole
Definition TableColumn.h:113
void setDisabledColor(QColor)
Definition TableColumn.cpp:707
void commit()
Write edited data to the process.
Definition TableColumn.cpp:644
unsigned int getRows() const
Get number of rows.
Definition TableColumn.cpp:352
QVariant data(unsigned int, int) const
Get display text.
Definition TableColumn.cpp:367
void setHeader(const QString &)
Sets the column header.
Definition TableColumn.cpp:163
const QString & getHeader() const
Definition TableColumn.cpp:172
bool isEditing() const
Definition TableColumn.cpp:628
double getLowerLimit() const
Limits are hints for the input delegate.
Definition TableColumn.cpp:310
friend class TableModel
Definition TableColumn.h:129
double getUpperLimit() const
Returns the upperlimit for the values of the col.
Definition TableColumn.cpp:331
void clearData()
Definition TableColumn.cpp:279
Table model.
Definition TableModel.h:43
Transmission mode for subscriptions.
Definition Transmission.h:86
Definition BroadcastModel.h:32
constexpr struct QtPdCom::event_mode_tag event_mode
Exception(const QString &msg)
Constructor.
Definition TableColumn.h:103
QString msg
Exception message.
Definition TableColumn.h:106