CuteHMI - CuteHMI (CuteHMI.2)
NotificationListModel.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_2_INCLUDE_CUTEHMI_NOTIFICATIONLISTMODEL_HPP
2 #define H_EXTENSIONS_CUTEHMI_2_INCLUDE_CUTEHMI_NOTIFICATIONLISTMODEL_HPP
3 
4 #include "internal/common.hpp"
5 #include "Notification.hpp"
6 
7 #include <QAbstractListModel>
8 
9 namespace cutehmi {
10 
14 class CUTEHMI_API NotificationListModel:
15  public QAbstractListModel
16 {
17  Q_OBJECT
18  typedef QAbstractListModel Parent;
19 
20  public:
21  enum Role {
22  TYPE_ROLE = Qt::UserRole,
23  DATE_TIME_ROLE
24  };
25 
26  NotificationListModel(QObject * parent = nullptr);
27 
28  ~NotificationListModel() override;
29 
30  int rowCount(const QModelIndex & parent = QModelIndex()) const override;
31 
32  QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
33 
34  QHash<int, QByteArray> roleNames() const override;
35 
36  void prepend(std::unique_ptr<Notification> notification);
37 
38  void removeLast(int num = 1);
39 
40  void clear();
41 
42  private:
43  typedef QList<Notification *> NotificationsContainer;
44 
45  struct Members
46  {
47  NotificationsContainer notifications;
48  };
49 
50  MPtr<Members> m;
51 };
52 
53 }
54 
55 #endif
56 
57 //(c)C: Copyright © 2018-2019, Michał Policht <michal@policht.pl>. All rights reserved.
58 //(c)C: This file is a part of CuteHMI.
59 //(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.
60 //(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.
61 //(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/>.
QAbstractListModel
QList< Notification * >
QObject
cutehmi
Definition: constants.hpp:6
cutehmi::NotificationListModel::Role
Role
Definition: NotificationListModel.hpp:21
QModelIndex
QVariant
QHash
std::unique_ptr
cutehmi::NotificationListModel
Notification list model.
Definition: NotificationListModel.hpp:14