ViewSolutions 1.0.100.30ae2aa
View solutions of qml for quasarapp projects
Loading...
Searching...
No Matches
notificationservice.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2024 QuasarApp.
3 * Distributed under the GPLv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8#ifndef NOTIFICATIONSERVICE_H
9#define NOTIFICATIONSERVICE_H
10
11#include "imodel.h"
12#include "notificationdata.h"
14
15#include <QHash>
16#include <QObject>
17#include <QQmlEngine>
18
19namespace ViewSolutions {
20
24using Listner = std::function<void(bool accept)>;
25
63class VIEWSOLUTION_EXPORT NotificationService: public QObject, public iModel
64{
65 Q_OBJECT
66
69
70 Q_PROPERTY(QObject* history READ history NOTIFY notifyChanged)
71
73
74public:
80
86
92
99 int setQuestion(const Listner &listner, const NotificationData& question);
100
106 Q_INVOKABLE void questionComplete(bool accepted, int code = 0);
107
115 Q_INVOKABLE void setNotify(const QString& title = "",
116 const QString& text = "",
117 const QString& img = "",
118 int type = NotificationData::Normal);
119
129 Q_INVOKABLE int setQuestion(QObject *listnerObject,
130 const QString &listnerMethod,
131 const QString& title = "",
132 const QString& text = "",
133 const QString& img = "",
134 int code = 0);
135
144 int setQuestion(const Listner &listner,
145 const QString& title = "",
146 const QString& text = "",
147 const QString& img = "",
148 int code = 0);
149
154 static NotificationService* getService();
155
160 QObject* history() const;
161
165
166 Q_INVOKABLE void showHistory();
167
172 Q_INVOKABLE int notificationsCount() const;
173
174 ~NotificationService();
175
176 // iModel interface
177public:
178 QString modelId() const override;
179
180signals:
185
190
197 void questionCompleted(bool accepted, int questionCode);
198
204
210
216
217private:
218
219 explicit NotificationService(QObject *ptr = nullptr);
220
221
222 QHash<int, Listner> _listners;
223 NotificationData _question;
224 NotificationData _notify;
225 HistoryNotificationsModel* _history = nullptr;
226
227
228};
229}
230
231#endif // NOTIFICATIONSERVICE_H
The HistoryNotificationsModel class stores the history of all sent notification messages.
The NotificationData class view data for NotificationServiceView. This class contains a structure wit...
void notifyChanged()
notifyChanged This signal emited whet the notificator (Ths object) received a new notification messag...
void setNotify(const NotificationData &notify)
setNotify This method add new notification message of application.
void sigShowHistory()
sigShowHistory This signal is emitted when the notification history view should be shown (see showHis...
void questionChanged()
questionChanged This signal emited whet the notificator (Ths object) received a new question message.
void countNotificationsChanged()
countNotificationsChanged This signal is emitted when the count of history notifications was changed.
int setQuestion(const Listner &listner, const NotificationData &question)
setQuestion This method sets information of the users question.
Q_INVOKABLE void questionComplete(bool accepted, int code=0)
questionComplete This method is main responce method of the users questions.
Q_INVOKABLE void showHistory()
showHistory - This method used for emit signal by which show notification menu.
void questionCompleted(bool accepted, int questionCode)
questionCompleted This signal emited when youser clcik any buttons on question popup.
static NotificationService * getService()
getService This method return instance to notify service.
void historyListChanged()
historyListChanged This signal is emitted when the notification history list was changed.
QString modelId() const override
modelId returns text model id. override this method to provide access to model in qml or other models...
The ViewSolutions namespace.
std::function< void(bool accept)> Listner
Listner This is listner lyambda function of user ansver. This function has next signature: void(bool ...
#define VIEWSOLUTION_EXPORT
VIEWSOLUTION_EXPORT marks a symbol as part of the public ViewSolutions API.