1
1
#include "rootnode.h"
2
#include "introspection.h"
4
5
#include <QCoreApplication>
5
6
#include <QStringList>
7
9
RootNode::RootNode(QCoreApplication* application)
8
: QtNode(application, std::string())
9
11
, application_(application)
13
QVariant RootNode::IntrospectNode() const
16
NodeIntrospectionData RootNode::GetIntrospectionData() const
15
// return must be (name, state_map)
16
QString object_name = QString::fromStdString(GetPath());
18
NodeIntrospectionData data;
19
data.object_path = QString::fromStdString(GetPath());
20
data.state = GetNodeProperties(application_);
17
21
QStringList child_names;
18
22
foreach(QObject* child, children_)
20
24
child_names.append(child->metaObject()->className());
23
QVariantMap object_properties;
24
object_properties["Children"] = child_names;
25
object_properties["id"] = GetObjectId();
26
QList<QVariant> object_tuple = { QVariant(object_name), QVariant(object_properties) };
27
return QVariant(object_tuple);
30
qint64 RootNode::GetObjectId() const
27
data.state["Children"] = PackProperty(child_names);
28
data.state["id"] = PackProperty(GetId());
35
32
void RootNode::AddChild(QObject* child)
48
45
return "/" + GetName();
51
bool RootNode::MatchProperty(const std::string& name, const std::string& value) const
54
return QString::fromStdString(value).toLongLong() == GetObjectId();
59
xpathselect::NodeList RootNode::Children() const
61
xpathselect::NodeList children;
48
xpathselect::NodeVector RootNode::Children() const
50
xpathselect::NodeVector children;
62
51
foreach(QObject* child, children_)
63
children.push_back(std::make_shared<QtNode>(child, GetPath()));
52
children.push_back(std::make_shared<QtNode>(child, shared_from_this()));