GCC Code Coverage Report


Directory: ./
File: qtpdcom/src/TableModelImpl.h
Date: 2024-12-15 04:08:34
Exec Total Coverage
Lines: 0 6 0.0%
Branches: 0 4 0.0%

Line Branch Exec Source
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
40 /** Table model.
41 *
42 * \see TableColumn.
43 */
44 class TableModel::Impl
45 {
46 public:
47 Impl(TableModel *parent):
48 parent(parent)
49 {}
50
51 private:
52 TableModel *const parent;
53 unsigned int rows = 0;
54 unsigned int visibleRows = UINT_MAX;
55 unsigned int rowCapacity = 0;
56 typedef QVector<TableColumn *> ColumnVector; /**< Column vector type.
57 */
58 ColumnVector columnVector; /**< Vector of table columns. */
59
60 void updateRows();
61 void ensureEditing();
62
63 QtPdCom::IntVariable valueHighlightRow;
64 QtPdCom::IntVariable visibleRowCount;
65
66 friend class TableModel;
67 };
68
69 /****************************************************************************/
70
71 class QtPdCom::TableColumn::Impl
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:
95 TableColumn *parent; /**< Parent object */
96 QString header; /**< Table column header. */
97
98 double scale; /**< Scale factor for values. */
99 double offset; /**< Offset for values. */
100 bool dataPresent; /**< Valid data have been received. */
101 double *editData; /**< Temporary editing data. */
102 bool enabled; /**< Column enabled. */
103 QHash<unsigned int, bool> enabledRows; /**< Enabled table rows. */
104 int highlightRow; /**< Index of the row to highlight, or -1. */
105 quint32 decimals; /**< Number of decimal digits. */
106 double lowerLimit; /**< Lower limit for value of column (this is a
107 hint for the Input Method to limit the value).
108 */
109 double upperLimit; /**< Upper limit for value of column (this is a
110 hint for the Input Method to limit the value).
111 */
112 QColor highlightColor;
113 QColor disabledColor;
114
115 class Subscription;
116 std::unique_ptr<Subscription> subscription;
117 };
118
119 /****************************************************************************/
120
121 } // namespace QtPdCom
122
123 #endif
124