QtPdCom  1.4.1
Qml_classes.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2024 Bjarne von Horn <vh at igh dot de>
4  *
5  * This file is part of the QtPdCom library.
6  *
7  * The QtPdCom library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation, either version 3 of the License,
10  * or (at your option) any later version.
11  *
12  * The QtPdCom library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with the QtPdCom Library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  *
21  ****************************************************************************/
22 
23 #pragma once
24 
25 #include <QQmlEngine>
27 #include <QtPdCom1/Process.h>
28 #include <QtPdCom1/LoginManager.h>
29 #include <QtPdCom1/MessageModel.h>
31 #include <QTranslator>
32 #include <QJSValue>
33 
34 namespace QtPdCom {
35 
36 
62 class Q_DECL_EXPORT QmlProcess: public QtPdCom::Process
63 {
64  Q_OBJECT
65  QML_NAMED_ELEMENT(Process)
66  QML_ADDED_IN_VERSION(1, 4)
67 
68  public:
70 
89  Q_INVOKABLE void ping(QJSValue jsCallback, double timeout = 0);
90 };
91 
92 class QmlMessage: public QObject
93 {
94  Q_OBJECT
95  QML_ANONYMOUS
96  Q_PROPERTY(QString path READ getPath NOTIFY contentChanged)
97  Q_PROPERTY(QString text READ getText NOTIFY contentChanged)
98  Q_PROPERTY(
100  Q_PROPERTY(bool active READ isActive NOTIFY contentChanged)
101  Q_PROPERTY(double time READ getTime NOTIFY contentChanged)
102  Q_PROPERTY(int index READ getIndex NOTIFY contentChanged)
103  Q_PROPERTY(int type READ getType NOTIFY contentChanged)
104 
105 
106  public:
107  using QObject::QObject;
108 
109  void setMessage(const QtPdCom::Message *message, QString lang);
110 
111  QString getPath() const { return path_; }
112  QString getText() const { return text_; }
113  QString getDescription() const { return description_; }
114  double getTime() const { return time_; }
115  int getType() const { return type_; }
116  int getIndex() const { return index_; }
117  bool isActive() const { return active_; }
118 
119  signals:
120  void contentChanged();
121 
122  private:
124  double time_ = 0.0;
125  int type_ = 0;
126  int index_ = -1;
127  bool active_ = false;
128 };
129 
131 {
132  Q_OBJECT
133  QML_NAMED_ELEMENT(MessageModel)
134  QML_ADDED_IN_VERSION(1, 4)
135 
136  Q_PROPERTY(QString locale READ getLocale WRITE setLocale NOTIFY
138 
140  CONSTANT)
141 
142  public:
143  QmlMessageModel(QObject *parent = nullptr);
144 
145 
146  void setLocale(QString locale)
147  {
148  locale_ = locale;
149  emit localeChanged();
150  }
151  QString getLocale() const { return locale_; }
153 
154  signals:
155  void localeChanged();
156 
157  private:
158  QString locale_;
160 };
161 
163 {
164  Q_GADGET
165  QML_FOREIGN(QtPdCom::MessageModelFilter)
166  QML_NAMED_ELEMENT(MessageModelFilter)
167  QML_ADDED_IN_VERSION(1, 4)
168 };
169 
171 {
172  Q_GADGET
173  QML_FOREIGN(QtPdCom::ClientStatisticsModel)
174  QML_NAMED_ELEMENT(ClientStatisticsModel)
175  QML_ADDED_IN_VERSION(1, 4)
176 };
177 
179 {
180  Q_GADGET
181  QML_FOREIGN(QtPdCom::LoginManager)
182  QML_NAMED_ELEMENT(LoginManager)
183  QML_ADDED_IN_VERSION(1, 4)
184 };
185 
186 class Q_DECL_EXPORT SaslInitializer: public QObject
187 {
188  Q_OBJECT
189  QML_ELEMENT
190  QML_ADDED_IN_VERSION(1, 4)
191 
192  public:
193  explicit SaslInitializer(QObject *parent = nullptr);
194  ~SaslInitializer();
195 };
196 
197 class Q_DECL_EXPORT DefaultProcess: public QtPdCom::QmlProcess
198 {
199  Q_OBJECT
200  QML_SINGLETON
201  QML_NAMED_ELEMENT(DefaultProcess)
202  QML_ADDED_IN_VERSION(1, 4)
203 
204  public:
206 
207  static DefaultProcess *create(QQmlEngine *, QJSEngine *engine);
208 
209  static void createDefaultInstance(QObject *parent = nullptr);
210 
211  private:
212  static QJSEngine *s_engine;
213  explicit DefaultProcess(QObject *parent);
214 };
215 } // namespace QtPdCom
Definition: Qml_classes.h:197
bool isActive() const
Definition: Qml_classes.h:117
Definition: Qml_classes.h:92
List of Messages.
Definition: MessageModel.h:42
Definition: ClientStatisticsModel.h:35
void setLocale(QString locale)
Definition: Qml_classes.h:146
QString description_
Definition: Qml_classes.h:123
Definition: Qml_classes.h:186
QString getPath() const
Definition: Qml_classes.h:111
PdCom::Process implementation for Qt.
Definition: Process.h:70
Definition: BroadcastModel.h:32
QmlMessage * getCurrentMessage()
Definition: Qml_classes.h:152
Proxy model to filter Messages based on their reset time.
Definition: MessageModelFilter.h:42
static QJSEngine * s_engine
Definition: Qml_classes.h:212
Process message.
Definition: Message.h:37
Definition: Qml_classes.h:162
QString text
Definition: Qml_classes.h:97
QString getLocale() const
Definition: Qml_classes.h:151
double time
Definition: Qml_classes.h:101
int getIndex() const
Definition: Qml_classes.h:116
int type
Definition: Qml_classes.h:103
QmlMessage current_message_
Definition: Qml_classes.h:159
int index_
Definition: Qml_classes.h:126
Class to handle the Authentication process.
Definition: LoginManager.h:46
bool active_
Definition: Qml_classes.h:127
QString path_
Definition: Qml_classes.h:123
double getTime() const
Definition: Qml_classes.h:114
bool active
Definition: Qml_classes.h:100
Process(QObject *parent=nullptr)
Constructor.
Definition: Process.cpp:145
int getType() const
Definition: Qml_classes.h:115
QString locale
Definition: Qml_classes.h:137
QString description
Definition: Qml_classes.h:99
int type_
Definition: Qml_classes.h:125
QmlMessage currentMessage
Definition: Qml_classes.h:139
Definition: Qml_classes.h:130
Definition: Qml_classes.h:170
QML-Adapted Process Class.
Definition: Qml_classes.h:62
QString getDescription() const
Definition: Qml_classes.h:113
QString text_
Definition: Qml_classes.h:123
int index
Definition: Qml_classes.h:102
QString getText() const
Definition: Qml_classes.h:112
double time_
Definition: Qml_classes.h:124
Definition: Qml_classes.h:178
void setMessage(const QtPdCom::Message *message, QString lang)
Definition: Qml_classes.cpp:144
QString path
Definition: Qml_classes.h:96
QString locale_
Definition: Qml_classes.h:158
static DefaultProcess * s_singletonInstance
Definition: Qml_classes.h:205