QtPdCom  1.3.3
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 
36 namespace QtPdCom {
37 
38 /****************************************************************************/
39 
45 {
46  public:
48  parent(parent)
49  {}
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;
100  bool dataPresent;
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
void updateRows()
Calculates the number of table rows.
Definition: TableModel.cpp:619
double upperLimit
Upper limit for value of column (this is a hint for the Input Method to limit the value)...
Definition: TableModelImpl.h:109
quint32 decimals
Number of decimal digits.
Definition: TableModelImpl.h:105
Table Column.
Definition: TableColumn.h:43
QtPdCom::IntVariable visibleRowCount
Definition: TableModelImpl.h:64
double scale
Scale factor for values.
Definition: TableModelImpl.h:98
void newValues(std::chrono::nanoseconds)
Definition: TableModelImpl.h:80
Definition: BroadcastModel.h:32
QHash< unsigned int, bool > enabledRows
Enabled table rows.
Definition: TableModelImpl.h:103
double * editData
Temporary editing data.
Definition: TableModelImpl.h:101
bool dataPresent
Valid data have been received.
Definition: TableModelImpl.h:100
Table model.
Definition: TableModelImpl.h:44
void ensureEditing()
Definition: TableModel.cpp:653
unsigned int rowCapacity
Definition: TableModelImpl.h:55
Impl(TableModel *parent)
Definition: TableModelImpl.h:47
Table model.
Definition: TableModel.h:42
QVector< TableColumn * > ColumnVector
Column vector type.
Definition: TableModelImpl.h:56
double offset
Offset for values.
Definition: TableModelImpl.h:99
std::unique_ptr< Subscription > subscription
Definition: TableModelImpl.h:115
int highlightRow
Index of the row to highlight, or -1.
Definition: TableModelImpl.h:104
unsigned int visibleRows
Definition: TableModelImpl.h:54
TableColumn * parent
Parent object.
Definition: TableModelImpl.h:95
QtPdCom::IntVariable valueHighlightRow
Definition: TableModelImpl.h:63
QColor disabledColor
Definition: TableModelImpl.h:113
QString header
Table column header.
Definition: TableModelImpl.h:96
class Q_DECL_HIDDEN Impl
Definition: TableColumn.h:126
double lowerLimit
Lower limit for value of column (this is a hint for the Input Method to limit the value)...
Definition: TableModelImpl.h:106
TableModel *const parent
Definition: TableModelImpl.h:52
unsigned int rows
Definition: TableModelImpl.h:53
Definition: TableModelImpl.h:71
QColor highlightColor
Definition: TableModelImpl.h:112
bool enabled
Column enabled.
Definition: TableModelImpl.h:102
ColumnVector columnVector
Vector of table columns.
Definition: TableModelImpl.h:58