CuteHMI - Services (CuteHMI.Services.2)
ServiceListModel.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_SERVICES_2_INCLUDE_CUTEHMI_SERVICES_SERVICELISTMODEL_HPP
2 #define H_EXTENSIONS_CUTEHMI_SERVICES_2_INCLUDE_CUTEHMI_SERVICES_SERVICELISTMODEL_HPP
3 
4 #include "internal/common.hpp"
5 #include "Service.hpp"
6 
7 #include <QAbstractListModel>
8 
9 namespace cutehmi {
10 namespace services {
11 
15 class CUTEHMI_SERVICES_API ServiceListModel:
16  public QAbstractListModel
17 {
18  Q_OBJECT
19  typedef QAbstractListModel Parent;
20 
21  public:
22  enum Role {
23  NAME_ROLE = Qt::UserRole,
24  STATUS_ROLE
25  };
26 
27  ServiceListModel(QObject * parent = nullptr);
28 
29  ~ServiceListModel() override;
30 
31  int rowCount(const QModelIndex & parent = QModelIndex()) const override;
32 
33  QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
34 
35  QHash<int, QByteArray> roleNames() const override;
36 
37  Q_INVOKABLE Service * at(int row);
38 
39  const Service * at(int row) const;
40 
41  void append(Service * service);
42 
43  void remove(Service * service);
44 
45  void clear();
46 
47  private:
48  typedef QList<Service *> ServicesContainer;
49 
50  struct Members
51  {
52  ServicesContainer services;
53  };
54 
55  MPtr<Members> m;
56 };
57 
58 }
59 }
60 
61 #endif
62 
63 //(c)C: Copyright © 2019-2020, Michał Policht <michal@policht.pl>. All rights reserved.
64 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
65 //(c)C: This file is a part of CuteHMI.
66 //(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.
67 //(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.
68 //(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/>.
69 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
70 //(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:
71 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
72 //(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::services::Service
Service.
Definition: Service.hpp:22
QAbstractListModel
QList< Service * >
cutehmi::MPtr< Members >
QObject
cutehmi
cutehmi::services::ServiceListModel::Role
Role
Definition: ServiceListModel.hpp:22
QModelIndex
QVariant
QHash
cutehmi::services::ServiceListModel
Notification list model.
Definition: ServiceListModel.hpp:15