QtPdCom  1.5.2
TableModelImpl.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_IMPL_H
24#define QTPDCOM_TABLEMODEL_IMPL_H
25
26#include <QtPdCom1/TableModel.h>
27
28#include <QAbstractTableModel>
29#include <QVector>
30#include <QColor>
31
32#define DEFAULT_DECIMALS 15
33#define DEFAULT_HIGHLIGHT_COLOR QColor(152, 183, 255)
34#define DEFAULT_DISABLED_COLOR QColor(220, 220, 220)
35
36namespace QtPdCom {
37
38/****************************************************************************/
39
45{
46 public:
50
51 private:
53 unsigned int rows = 0;
54 unsigned int visibleRows = UINT_MAX;
55 unsigned int rowCapacity = 0;
56 typedef QVector<TableColumn *> ColumnVector;
60 void updateRows();
61 void ensureEditing();
62
65
66 friend class TableModel;
67};
68
69/****************************************************************************/
70
72{
73 friend class TableColumn;
74
75 public:
76 Impl(TableColumn *parent, const QString &header);
77 ~Impl();
78
79 void stateChanged(PdCom::Subscription::State state);
80 void newValues(std::chrono::nanoseconds)
81 {
82 dataPresent = true;
83 emit parent->valueChanged();
84 }
85
86 void insertRow(int position, int count);
87 void deleteRow(int position, int count);
88
89 QString getRow(int row, const QLocale &locale) const;
90 bool setRow(QString valueStr, int row, const QLocale &locale);
91
92 void ensureEditData();
93
94 private:
96 QString header;
98 double scale;
99 double offset;
101 double *editData;
102 bool enabled;
103 QHash<unsigned int, bool> enabledRows;
105 quint32 decimals;
106 double lowerLimit;
109 double upperLimit;
114
115 class Subscription;
116 std::unique_ptr<Subscription> subscription;
117};
118
119/****************************************************************************/
120
121} // namespace QtPdCom
122
123#endif
Definition TableModelImpl.h:72
double offset
Offset for values.
Definition TableModelImpl.h:99
bool dataPresent
Valid data have been received.
Definition TableModelImpl.h:100
QString getRow(int row, const QLocale &locale) const
Definition TableColumn.cpp:485
quint32 decimals
Number of decimal digits.
Definition TableModelImpl.h:105
TableColumn * parent
Parent object.
Definition TableModelImpl.h:95
double * editData
Temporary editing data.
Definition TableModelImpl.h:101
void stateChanged(PdCom::Subscription::State state)
Definition TableColumn.cpp:127
bool enabled
Column enabled.
Definition TableModelImpl.h:102
QColor disabledColor
Definition TableModelImpl.h:113
void deleteRow(int position, int count)
Definition TableColumn.cpp:762
int highlightRow
Index of the row to highlight, or -1.
Definition TableModelImpl.h:104
bool setRow(QString valueStr, int row, const QLocale &locale)
Definition TableColumn.cpp:503
Impl(TableColumn *parent, const QString &header)
Definition TableColumn.cpp:100
double scale
Scale factor for values.
Definition TableModelImpl.h:98
double lowerLimit
Lower limit for value of column (this is a hint for the Input Method to limit the value).
Definition TableModelImpl.h:106
QHash< unsigned int, bool > enabledRows
Enabled table rows.
Definition TableModelImpl.h:103
void newValues(std::chrono::nanoseconds)
Definition TableModelImpl.h:80
double upperLimit
Upper limit for value of column (this is a hint for the Input Method to limit the value).
Definition TableModelImpl.h:109
void ensureEditData()
Definition TableColumn.cpp:715
std::unique_ptr< Subscription > subscription
Definition TableModelImpl.h:116
QColor highlightColor
Definition TableModelImpl.h:112
QString header
Table column header.
Definition TableModelImpl.h:96
~Impl()
Definition TableColumn.cpp:118
void insertRow(int position, int count)
Definition TableColumn.cpp:739
Table Column.
Definition TableColumn.h:44
Table model.
Definition TableModelImpl.h:45
ColumnVector columnVector
Vector of table columns.
Definition TableModelImpl.h:58
unsigned int rowCapacity
Definition TableModelImpl.h:55
QtPdCom::IntVariable valueHighlightRow
Definition TableModelImpl.h:63
TableModel *const parent
Definition TableModelImpl.h:52
unsigned int visibleRows
Definition TableModelImpl.h:54
QtPdCom::IntVariable visibleRowCount
Definition TableModelImpl.h:64
QVector< TableColumn * > ColumnVector
Column vector type.
Definition TableModelImpl.h:56
Impl(TableModel *parent)
Definition TableModelImpl.h:47
void updateRows()
Calculates the number of table rows.
Definition TableModel.cpp:620
void ensureEditing()
Definition TableModel.cpp:654
unsigned int rows
Definition TableModelImpl.h:53
Table model.
Definition TableModel.h:43
Definition BroadcastModel.h:32