-
Notifications
You must be signed in to change notification settings - Fork 25
/
tqobject.cpp
57 lines (46 loc) · 1.41 KB
/
tqobject.cpp
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
#include "tqobject.h"
#include <QSet>
QSet<TqObject*> tq_object_instances;
TqObject::TqObject(QObject *parent) :
QObject(parent),
mErrorCode(0)
{
tq_object_instances.insert(this);
}
QQmlListProperty<QObject> TqObject::items()
{
return QQmlListProperty<QObject>(this, &_items, QQmlListProperty<QObject>::AppendFunction(append),
QQmlListProperty<QObject>::CountFunction(count),
QQmlListProperty<QObject>::AtFunction(at),
QQmlListProperty<QObject>::ClearFunction(clear) );
}
void TqObject::append(QQmlListProperty<QObject> *p, QObject *v)
{
TqObject *aobj = static_cast<TqObject*>(p->object);
aobj->_items.append(v);
Q_EMIT aobj->itemsChanged();
}
int TqObject::count(QQmlListProperty<QObject> *p)
{
TqObject *aobj = static_cast<TqObject*>(p->object);
return aobj->_items.count();
}
QObject *TqObject::at(QQmlListProperty<QObject> *p, int idx)
{
TqObject *aobj = static_cast<TqObject*>(p->object);
return aobj->_items.at(idx);
}
void TqObject::clear(QQmlListProperty<QObject> *p)
{
TqObject *aobj = static_cast<TqObject*>(p->object);
aobj->_items.clear();
Q_EMIT aobj->itemsChanged();
}
bool TqObject::isValid(TqObject *obj)
{
return tq_object_instances.contains(obj);
}
TqObject::~TqObject()
{
tq_object_instances.remove(this);
}