15 #include "nodebrowser.h"
20 #include <QTextBrowser>
21 #include <QApplication>
23 #include "ui_nodebrowserform.h"
25 XNodeBrowser::XNodeBrowser
33 m_pTimer =
new QTimer(
this);
34 connect(m_pTimer, SIGNAL (timeout() ),
this, SLOT(process()));
36 form->m_txtDesc->setAcceptRichText(
true);
39 XNodeBrowser::~XNodeBrowser() {
43 XNodeBrowser::connectedNode(QWidget *widget) {
44 if( !widget || (widget == m_pForm->m_txtDesc) ||
45 (widget == m_pForm->m_edValue) || (widget == m_pForm)) {
46 return shared_ptr<XNode>();
48 return XQConnector::connectedNode(widget);
52 XNodeBrowser::process() {
54 shared_ptr<XNode> node;
58 widget = QApplication::widgetAt(QCursor::pos());
59 node = connectedNode(widget);
60 if( !node && widget) {
61 widget = widget->parentWidget();
62 node = connectedNode(widget);
63 if( !node && widget) {
64 widget = widget->parentWidget();
65 node = connectedNode(widget);
72 if((node != m_lastPointed) && node) {
74 auto valuenode(dynamic_pointer_cast<XValueNodeBase>(node));
75 auto listnode(dynamic_pointer_cast<XListNodeBase>(node));
79 m_conValue = xqcon_create<XQLineEditConnector>(valuenode, m_pForm->m_edValue);
81 m_pForm->m_edValue->setText(
"");
83 str +=
"<font color=#005500>Label:</font> ";
84 str += node->getLabel().c_str();
88 if( !shot[ *node].isUIEnabled()) str+=
"UI/scripting disabled.<br>";
89 if(shot[ *node].isRuntime()) str+=
"For run-time only.<br>";
90 str +=
"<font color=#005500>Type:</font> ";
91 str += node->getTypename().c_str();
94 XNode *cnode = node.get();
95 shared_ptr<XNode> rootnode(m_root);
98 if((rbpath.length() > 64) ||
99 (cnode == m_root.lock().get())) {
100 str +=
"<font color=#550000>Ruby object:</font><br> Measurement";
101 str += rbpath.c_str();
102 str +=
"<br><font color=#550000>Supported Ruby methods:</font>"
103 " name() touch() child(<font color=#000088><i>name/idx</i></font>)"
104 " [](<font color=#000088><i>name/idx</i></font>) count() each() to_ary()";
106 str +=
" set(<font color=#000088><i>x</i></font>)"
107 " value=<font color=#000088><i>x</i></font> load(<font color=#000088><i>x</i></font>)"
108 " <<<font color=#000088><i>x</i></font> get() value() to_str()";
110 str +=
" create(<font color=#000088><i>type</i></font>, <font color=#000088><i>name</i></font>)"
115 rbpath = formatString(
"[\"%s\"]%s", cnode->
getName().c_str(), rbpath.c_str());
120 str +=
"Inaccessible from the root.<br>";
123 str += formatString(
"<font color=#005500>%u Child(ren):</font> <br>", (
unsigned int)shot.list()->size()).c_str();
124 for(
auto it = shot.list()->begin(); it != shot.list()->end(); ++it) {
126 str += ( *it)->getName().c_str();
130 trans( *m_desc).str(str);
132 m_lastPointed = node;