CuteHMI - Data Acquisition (CuteHMI.DataAcquisition.1)
HistoryModel.hpp
1#ifndef H_EXTENSIONS_CUTEHMI_DATAACQUISITION_1_INCLUDE_CUTEHMI_DATAACQUISITION_HISTORYMODEL_HPP
2#define H_EXTENSIONS_CUTEHMI_DATAACQUISITION_1_INCLUDE_CUTEHMI_DATAACQUISITION_HISTORYMODEL_HPP
3
4#include "internal/common.hpp"
5
6#include "AbstractListModel.hpp"
7#include "internal/HistoryCollective.hpp"
8#include "internal/ModelMixin.hpp"
9
10#include <QDateTime>
11
12namespace cutehmi {
13namespace dataacquisition {
14
15class CUTEHMI_DATAACQUISITION_API HistoryModel:
17 private internal::ModelMixin<HistoryModel>
18{
19 Q_OBJECT
20 QML_NAMED_ELEMENT(HistoryModel)
21
23
24 friend class internal::ModelMixin<HistoryModel>;
25
26 public:
27 enum Role {
28 TAG_ROLE = Qt::UserRole,
35 COUNT_ROLE
36 };
37
38 Q_PROPERTY(QStringList tags READ tags WRITE setTags NOTIFY tagsChanged)
39
40 Q_PROPERTY(QDateTime begin READ begin NOTIFY beginChanged)
41
42 Q_PROPERTY(QDateTime end READ end NOTIFY endChanged)
43
44 Q_PROPERTY(QDateTime from READ from WRITE setFrom NOTIFY fromChanged)
45
46 Q_PROPERTY(QDateTime to READ to WRITE setTo NOTIFY toChanged)
47
48 HistoryModel(QObject * parent = nullptr);
49
50 QStringList tags() const;
51
52 void setTags(const QStringList & tags);
53
54 QDateTime begin() const;
55
56 QDateTime end() const;
57
58 QDateTime from() const;
59
60 void setFrom(const QDateTime & from);
61
62 QDateTime to() const;
63
64 void setTo(const QDateTime & to);
65
66 bool busy() const override;
67
68 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
69
70 QHash<int, QByteArray> roleNames() const override;
71
72 int rowCount(const QModelIndex & parent = QModelIndex()) const override;
73
74 signals:
76
78
79 void endChanged();
80
82
83 void toChanged();
84
85 public slots:
86 void requestUpdate() override;
87
88 protected slots:
89 void confirmUpdateFinished() override;
90
91 protected:
92 void setBegin(const QDateTime & begin);
93
94 void setEnd(const QDateTime & end);
95
96 private slots:
97 void onSchemaChanged();
98
99 void onSelected(internal::HistoryCollective::ColumnValues columnValues, QDateTime minOpenTime, QDateTime maxCloseTime);
100
101 private:
102 struct Members {
104 internal::HistoryCollective dbCollective;
105 QStringList tags;
106 QDateTime begin;
107 QDateTime end;
108 QDateTime from;
109 QDateTime to;
110 };
111
113};
114
115}
116}
117
118#endif
119
120//(c)C: Copyright © 2022, Michał Policht <michal@policht.pl>. All rights reserved.
121//(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
122//(c)C: This file is a part of CuteHMI.
123//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
124//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
125//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>.
126//(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
127//(c)C: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
128//(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
129//(c)C: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Definition: AbstractListModel.hpp:19
Definition: HistoryModel.hpp:18
Role
Definition: HistoryModel.hpp:27
@ CLOSE_TIME_ROLE
Definition: HistoryModel.hpp:34
@ OPEN_ROLE
Definition: HistoryModel.hpp:29
@ OPEN_TIME_ROLE
Definition: HistoryModel.hpp:33
@ MAX_ROLE
Definition: HistoryModel.hpp:32
@ CLOSE_ROLE
Definition: HistoryModel.hpp:30
@ MIN_ROLE
Definition: HistoryModel.hpp:31
Definition: HistoryCollective.hpp:16
UserRole