LibrePCB Developers Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
notificationsmodel.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_NOTIFICATIONSMODEL_H
21#define LIBREPCB_EDITOR_NOTIFICATIONSMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "appwindow.h"
27
28#include <QtCore>
29
30#include <memory>
31#include <vector>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class Workspace;
39
40namespace editor {
41
42class Notification;
43
44/*******************************************************************************
45 * Class NotificationsModel
46 ******************************************************************************/
47
51class NotificationsModel final : public QObject,
52 public slint::Model<ui::NotificationData> {
53 Q_OBJECT
54
55public:
56 // Constructors / Destructor
58 NotificationsModel(const NotificationsModel& other) = delete;
59 explicit NotificationsModel(Workspace& ws,
60 QObject* parent = nullptr) noexcept;
61 ~NotificationsModel() noexcept;
62
63 // General Methods
64 void push(std::shared_ptr<Notification> notification) noexcept;
65 int getUnreadNotificationsCount() const noexcept {
67 }
68 int getCurrentProgressIndex() const noexcept { return mCurrentProgressIndex; }
69
70 // Implementations
71 std::size_t row_count() const override;
72 std::optional<ui::NotificationData> row_data(std::size_t i) const override;
73 void set_row_data(std::size_t i,
74 const ui::NotificationData& obj) noexcept override;
75
76 // Operator Overloadings
78
79signals:
83
84private:
85 int mapIndex(int i) const noexcept;
86 void itemChanged(bool dismissed) noexcept;
87 void removeItem(std::size_t i, int itemIndex) noexcept;
88 void updateUnreadNotificationsCount() noexcept;
89 void updateCurrentProgressIndex() noexcept;
90
91private:
93 std::vector<std::shared_ptr<Notification>> mItems;
96};
97
98/*******************************************************************************
99 * End of File
100 ******************************************************************************/
101
102} // namespace editor
103} // namespace librepcb
104
105#endif
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The Notification class.
Definition notification.h:43
The NotificationsModel class.
Definition notificationsmodel.h:52
int mUnreadNotifications
Definition notificationsmodel.h:94
void updateCurrentProgressIndex() noexcept
Definition notificationsmodel.cpp:209
int mapIndex(int i) const noexcept
Definition notificationsmodel.cpp:148
std::optional< ui::NotificationData > row_data(std::size_t i) const override
Definition notificationsmodel.cpp:106
int mCurrentProgressIndex
Definition notificationsmodel.h:95
void set_row_data(std::size_t i, const ui::NotificationData &obj) noexcept override
Definition notificationsmodel.cpp:116
int getCurrentProgressIndex() const noexcept
Definition notificationsmodel.h:68
void updateUnreadNotificationsCount() noexcept
Definition notificationsmodel.cpp:192
int getUnreadNotificationsCount() const noexcept
Definition notificationsmodel.h:65
void push(std::shared_ptr< Notification > notification) noexcept
Definition notificationsmodel.cpp:67
NotificationsModel(const NotificationsModel &other)=delete
std::size_t row_count() const override
Definition notificationsmodel.cpp:94
Workspace & mWorkspace
Definition notificationsmodel.h:92
NotificationsModel & operator=(const NotificationsModel &rhs)=delete
void removeItem(std::size_t i, int itemIndex) noexcept
Definition notificationsmodel.cpp:185
std::vector< std::shared_ptr< Notification > > mItems
Definition notificationsmodel.h:93
void itemChanged(bool dismissed) noexcept
Definition notificationsmodel.cpp:165
void unreadNotificationsCountChanged(int count)
Definition occmodel.cpp:77
Definition uuid.h:186