-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXObjectManagement.cpp
More file actions
111 lines (88 loc) · 3.95 KB
/
Copy pathXObjectManagement.cpp
File metadata and controls
111 lines (88 loc) · 3.95 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "XObjectManagement.h"
XObjectManagement m_object;
XObjectManagement::XObjectManagement(QObject *parent) : QObject(parent)
{
}
//==============================================================================
void XObjectManagement::InitializingObject(QObject *m_object)
{
this->m_object = m_object;
}
//==============================================================================
QObject *XObjectManagement::object()
{
return this->m_object;
}
//==============================================================================
QVariant XObjectManagement::get(QString objectName, const char *propertyName)
{
if(m_object->findChild<QObject*>(objectName) == nullptr)
m_object->findChild<QObject*>(objectName, Qt::FindChildrenRecursively);
if(m_object->findChild<QObject*>(objectName) != nullptr){
LOG(QString("objectName '%1' not found.").arg(objectName));
return {};
}
return m_object->findChild<QObject*>(objectName)->property(propertyName);
}
//==============================================================================
void XObjectManagement::set(QString objectName, const char *propertyName, QVariant m_value)
{
if(m_object->findChild<QObject*>(objectName) == nullptr)
m_object->findChild<QObject*>(objectName, Qt::FindChildrenRecursively);
if(m_object->findChild<QObject*>(objectName) != nullptr){
LOG(QString("objectName '%1' not found.").arg(objectName));
return;
}
m_object->findChild<QObject*>(objectName)->setProperty(propertyName, m_value);
}
//==============================================================================
void XObjectManagement::CallFunction(const char *functionName)
{
QMetaObject::invokeMethod(m_object, functionName);
}
//==============================================================================
void XObjectManagement::CallFunction(const char *functionName, QVariantMap mapOfValues)
{
QMetaObject::invokeMethod(m_object, functionName, Q_ARG(QVariant, QVariant::fromValue(mapOfValues)));
}
//==============================================================================
void XObjectManagement::CallFunctionSingle(const char *functionName, QVariant value)
{
QMetaObject::invokeMethod(m_object, functionName, Q_ARG(QVariant, QVariant::fromValue(value)));
}
//==============================================================================
void XObjectManagement::CallFunction(QString objectName, const char *functionName)
{
if(m_object->findChild<QObject*>(objectName) == nullptr)
m_object->findChild<QObject*>(objectName, Qt::FindChildrenRecursively);
if(m_object->findChild<QObject*>(objectName) == nullptr) {
LOG(QString("objectName '%1' not found.").arg(objectName));
return;
}
QObject* myObject = m_object->findChild<QObject*>(objectName);
QMetaObject::invokeMethod(myObject, functionName);
}
//==============================================================================
void XObjectManagement::CallFunction(QString objectName, const char *functionName, QVariantMap mapOfValues)
{
if(m_object->findChild<QObject*>(objectName) == nullptr)
m_object->findChild<QObject*>(objectName, Qt::FindChildrenRecursively);
if(m_object->findChild<QObject*>(objectName) == nullptr) {
LOG(QString("objectName '%1' not found.").arg(objectName));
return;
}
QObject* myObject = m_object->findChild<QObject*>(objectName);
QMetaObject::invokeMethod(myObject, functionName, Q_ARG(QVariant, QVariant::fromValue(mapOfValues)));
}
//==============================================================================
void XObjectManagement::CallFunctionSingle(QString objectName, const char *functionName, QVariant value)
{
if(m_object->findChild<QObject*>(objectName) == nullptr)
m_object->findChild<QObject*>(objectName, Qt::FindChildrenRecursively);
if(m_object->findChild<QObject*>(objectName) == nullptr) {
LOG(QString("objectName '%1' not found.").arg(objectName));
return;
}
QObject* myObject = m_object->findChild<QObject*>(objectName);
QMetaObject::invokeMethod(myObject, functionName, Q_ARG(QVariant, QVariant::fromValue(value)));
}