CuteHMI - Data Acquisition (CuteHMI.DataAcquisition.0)
EventModel.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_DATAACQUISITION_0_INCLUDE_CUTEHMI_DATAACQUISITION_EVENTMODEL_HPP
2 #define H_EXTENSIONS_CUTEHMI_DATAACQUISITION_0_INCLUDE_CUTEHMI_DATAACQUISITION_EVENTMODEL_HPP
3 
4 #include "internal/common.hpp"
5 
6 #include "AbstractListModel.hpp"
7 #include "internal/EventCollective.hpp"
8 #include "internal/ModelMixin.hpp"
9 
10 namespace cutehmi {
11 namespace dataacquisition {
12 
13 class CUTEHMI_DATAACQUISITION_API EventModel:
14  public AbstractListModel,
15  private internal::ModelMixin<EventModel>
16 {
17  Q_OBJECT
18 
19  typedef AbstractListModel Parent;
20 
22 
23  public:
24  enum Role {
25  TAG_ROLE = Qt::UserRole,
28  };
29 
30  Q_PROPERTY(QStringList tags READ tags WRITE setTags NOTIFY tagsChanged)
31 
32  Q_PROPERTY(QDateTime begin READ begin NOTIFY beginChanged)
33 
34  Q_PROPERTY(QDateTime end READ end NOTIFY endChanged)
35 
36  Q_PROPERTY(QDateTime from READ from WRITE setFrom NOTIFY fromChanged)
37 
38  Q_PROPERTY(QDateTime to READ to WRITE setTo NOTIFY toChanged)
39 
40  EventModel(QObject * parent = nullptr);
41 
42  QStringList tags() const;
43 
44  void setTags(const QStringList & tags);
45 
46  QDateTime begin() const;
47 
48  QDateTime end() const;
49 
50  QDateTime from() const;
51 
52  void setFrom(const QDateTime & from);
53 
54  QDateTime to() const;
55 
56  void setTo(const QDateTime & to);
57 
58  bool busy() const override;
59 
60  QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
61 
62  QHash<int, QByteArray> roleNames() const override;
63 
64  int rowCount(const QModelIndex & parent = QModelIndex()) const override;
65 
66  signals:
67  void tagsChanged();
68 
69  void beginChanged();
70 
71  void endChanged();
72 
73  void fromChanged();
74 
75  void toChanged();
76 
77  public slots:
78  void requestUpdate() override;
79 
80  protected slots:
81  void confirmUpdateFinished() override;
82 
83  protected:
84  void setBegin(const QDateTime & begin);
85 
86  void setEnd(const QDateTime & end);
87 
88  private slots:
89  void onSchemaChanged();
90 
91  void onSelected(internal::EventCollective::ColumnValues columnValues, QDateTime minTime, QDateTime maxTime);
92 
93  private:
94  struct Members {
96  internal::EventCollective dbCollective;
97  QStringList tags;
98  QDateTime begin;
99  QDateTime end;
100  QDateTime from;
101  QDateTime to;
102  };
103 
104  MPtr<Members> m;
105 };
106 
107 }
108 }
109 
110 #endif
111 
112 //(c)C: Copyright © 2020, Michał Policht <michal@policht.pl>. All rights reserved.
113 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
114 //(c)C: This file is a part of CuteHMI.
115 //(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.
116 //(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.
117 //(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/>.
118 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
119 //(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:
120 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
121 //(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.
cutehmi::dataacquisition::EventModel::VALUE_ROLE
@ VALUE_ROLE
Definition: EventModel.hpp:26
cutehmi::dataacquisition::AbstractListModel
Definition: AbstractListModel.hpp:15
cutehmi::dataacquisition::EventModel
Definition: EventModel.hpp:13
cutehmi::dataacquisition::EventModel::Role
Role
Definition: EventModel.hpp:24
cutehmi::MPtr< Members >
QObject
cutehmi
Qt
cutehmi::dataacquisition::internal::EventCollective
Definition: EventCollective.hpp:15
cutehmi::dataacquisition::internal::ModelMixin
Definition: ModelMixin.hpp:15
QDateTime
QModelIndex
cutehmi::dataacquisition::internal::EventCollective::ColumnValues
Definition: EventCollective.hpp:23
QVariant
cutehmi::dataacquisition::EventModel::TIME_ROLE
@ TIME_ROLE
Definition: EventModel.hpp:27
QHash
QByteArray
QStringList