This repository has been archived by the owner on Aug 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qgtkobject.cpp
68 lines (56 loc) · 1.65 KB
/
qgtkobject.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
57
58
59
60
61
62
63
64
65
66
67
#include "qgtkobject.h"
#include "qgtkwidget.h"
QGtkObject::QGtkObject(QObject *parent)
: QObject(parent)
, m_me(0)
{
}
QQmlListProperty<QObject> QGtkObject::gtkChildren()
{
return QQmlListProperty<QObject>(this, this,
&QGtkObject::appendGtkChild,
&QGtkObject::gtkChildCount,
&QGtkObject::gtkChildrenAt,
&QGtkObject::clearGtkChilds);
}
GObject *QGtkObject::gObject() const
{
return m_me;
}
void QGtkObject::create()
{
m_me = acquireObject();
sync();
for (QObject *c : m_childs) {
if (QGtkObject *co = qobject_cast<QGtkObject*>(c)) {
// acquire, sync props
co->create();
// handle it further (e.g. adding it, if we are a container).
childCreated(co);
}
}
}
void QGtkObject::childCreated(QGtkObject *o)
{
// ### ref_sink (& unref in dtor)
}
void QGtkObject::appendGtkChild(QQmlListProperty<QObject> *prop, QObject *child)
{
QGtkObject *that = static_cast<QGtkObject*>(prop->object);
that->m_childs.append(child);
}
int QGtkObject::gtkChildCount(QQmlListProperty<QObject> *prop)
{
QGtkObject *that = static_cast<QGtkObject*>(prop->object);
return that->m_childs.count();
}
QObject* QGtkObject::gtkChildrenAt(QQmlListProperty<QObject> *prop, int idx)
{
QGtkObject *that = static_cast<QGtkObject*>(prop->object);
return that->m_childs.at(idx);
}
void QGtkObject::clearGtkChilds(QQmlListProperty<QObject> *prop)
{
QGtkObject *that = static_cast<QGtkObject*>(prop->object);
return that->m_childs.clear();
}