12NotificationService::NotificationService(QObject * ptr): QObject (ptr) {
13 qRegisterMetaType<NotificationData>(
"NotificationData");
14 qRegisterMetaType<QList<NotificationData>> (
"QList<NotificationData>");
15 _history =
new HistoryNotificationsModel();
16 QQmlEngine::setObjectOwnership(_history, QQmlEngine::CppOwnership);
18 connect(_history, &HistoryNotificationsModel::rowsInserted,
this, &NotificationService::countNotificationsChanged);
19 connect(_history, &HistoryNotificationsModel::rowsRemoved,
this, &NotificationService::countNotificationsChanged);
20 connect(_history, &HistoryNotificationsModel::modelReset,
this, &NotificationService::countNotificationsChanged);
37 _history->addHistoryObject(
notify);
47 int questionCode = rand();
48 _question.setCode(questionCode);
51 _listners[questionCode] = listner;
53 return _question.type();
58 if (_listners.contains(code)) {
59 auto listner = _listners.value(code);
61 _listners.remove(code);
77 const QString &listnerMethod,
83 Listner listner = [listnerObject, listnerMethod](
bool accept) {
85 const QByteArray stringData = listnerMethod.toLatin1();
87 method[qMin(99, stringData.size())] =
'\0';
88 std::copy(stringData.constBegin(), stringData.constBegin() + qMin(99, stringData.size()), method);
90 QMetaObject::invokeMethod(listnerObject, method,
91 Qt::QueuedConnection, Q_ARG(
bool, accept));
108 static auto service =
new NotificationService;
121 return _history->rowCount({});
126 return "NotificationService";
The NotificationData class view data for NotificationServiceView. This class contains a structure wit...
Type
The Type enum This enum contatins all available types of the notification messages.
void notifyChanged()
notifyChanged This signal emited whet the notificator (Ths object) received a new notification messag...
void setNotify(const NotificationData ¬ify)
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.
NotificationData question
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.
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 ...