-
Notifications
You must be signed in to change notification settings - Fork 25
/
tqobject.h
60 lines (46 loc) · 1.55 KB
/
tqobject.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef TQOBJECT_H
#define TQOBJECT_H
#include <QObject>
#include <QQmlListProperty>
#include "telegramtools.h"
#include "telegramqml_global.h"
#include "tqbaseobject.h"
#define tqobject_cast(OBJECT) static_cast<TqObject*>(OBJECT)
class TELEGRAMQMLSHARED_EXPORT TqObject : public QObject, public TqBaseObject
{
Q_OBJECT
Q_PROPERTY(QString errorText READ errorText NOTIFY errorChanged)
Q_PROPERTY(qint32 errorCode READ errorCode NOTIFY errorChanged)
Q_PROPERTY(QQmlListProperty<QObject> items READ items NOTIFY itemsChanged)
Q_CLASSINFO("DefaultProperty", "items")
public:
Q_INVOKABLE explicit TqObject(QObject *parent = 0);
virtual ~TqObject();
static bool isValid(TqObject *obj);
QString errorText() const { return mErrorText; }
qint32 errorCode() const { return mErrorCode; }
QQmlListProperty<QObject> items();
static QStringList requiredProperties() {
return QStringList();
}
Q_SIGNALS:
void errorChanged();
void itemsChanged();
protected:
void setError(const QString &errorText, qint32 errorCode) {
mErrorText = TelegramTools::convertErrorToText(errorText);
mErrorCode = errorCode;
Q_EMIT errorChanged();
}
private:
static void append(QQmlListProperty<QObject> *p, QObject *v);
static int count(QQmlListProperty<QObject> *p);
static QObject *at(QQmlListProperty<QObject> *p, int idx);
static void clear(QQmlListProperty<QObject> *p);
protected:
QList<QObject*> _items;
private:
QString mErrorText;
qint32 mErrorCode;
};
#endif // TQOBJECT_H