ViewSolutions 1.0.100.30ae2aa
View solutions of qml for quasarapp projects
Loading...
Searching...
No Matches
notificationdata.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2025 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#include "notificationdata.h"
9namespace ViewSolutions {
10
12 const QString &text,
13 const QString &img, int type) {
14
15 _text = text;
16 _title = title;
17 _img = img;
18 _type = type;
19}
20
21QString NotificationData::text() const {
22 return _text;
23}
24
25QString NotificationData::img() const {
26 const QString imageSrc = imgSrc();
27 if(imageSrc.size())
28 return imageSrc;
29
30 return this->getDefaultImage(_type);
31}
32
33QString NotificationData::imgSrc() const {
34 return _img;
35}
36
37QString NotificationData::title() const {
38 return _title;
39}
40
42 return _title == righ._title &&
43 _text == righ._text &&
44 _img == righ._img &&
45 _type == righ._type;
46}
47
49 return !operator==(righ);
50}
51
52QString NotificationData::getDefaultImage(const int code) const {
53
54 const auto notificationType = static_cast<NotificationData::Type>(code);
55
56 switch (notificationType) {
58 return "qrc:/icons/info";
60 return "qrc:/icons/warning";
62 return "qrc:/icons/error";
63 default:
64 return "";
65 }
66}
67
69 return _type;
70}
71
73 return _text.size() || _title.size() || _img.size();
74}
75
77 _type = code;
78}
79}
Q_INVOKABLE QString title() const
title This method return title of a question/notification object.
NotificationData(const QString &title="", const QString &text="", const QString &img="", int type=Type::Normal)
NotificationData creates a new notification data object.
Q_INVOKABLE QString img() const
img This method return url to image of a question/notification object if url is empty then return def...
QString imgSrc() const
imgSrc This method return url to image of a question/notification object.
Type
The Type enum This enum contatins all available types of the notification messages.
@ Error
This is critical error notifications.
@ Warning
This is warning notification.
@ Normal
This is message for general notification.
Q_INVOKABLE QString text() const
text This method return main text message of a question/notification object.
void setCode(int code)
setCode This method sets new code of the question.
bool operator==(const NotificationData &righ)
Q_INVOKABLE bool isValid() const
isValid This method return true if this object is valid.
Q_INVOKABLE int type() const
type This method return type of the notification message or code of the question.
bool operator!=(const NotificationData &righ)
The ViewSolutions namespace.