WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
ZxItem.h
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2013, 2014 Bob Dinitto
4  *
5  * ZxItem.h
6  *
7  * Created on: 29-Sep, 2013
8  * Author: Bob Dinitto bob@ninzo.com
9  *
10  * Zuble is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 #ifndef ZXITEM_H
27 #define ZXITEM_H
28 
29 #include <QObject>
30 #include <QXmlItem>
31 #include <QVariant>
32 #include "zblcore_global.h"
33 
34 namespace Zbl
35 {
36 
37 class ZxQuery;
38 
43 class ZxItem : public QObject
44 {
45  friend class ZxResultItems;
46  friend class ZxQuery;
47 
48  Q_OBJECT
49 public:
50  explicit ZxItem(QObject *parent = 0);
51 
52 
57  Q_PROPERTY(QString localName READ getLocalName)
58 
59 
63  Q_PROPERTY(QString stringValue READ getStringValue NOTIFY stringValueChanged)
64 
69  Q_PROPERTY(QObject* rootNode READ getRootNode)
70 
76  Q_INVOKABLE bool isAtomicValue() const;
77 
82  Q_INVOKABLE bool isNode() const;
83 
88  Q_INVOKABLE bool isNull() const;
89 
95  Q_INVOKABLE QVariant toAtomicValue() const;
96 
103  QObject* getRootNode();
104 
114  Q_INVOKABLE QObject* elementById(const QString& id);
115 
116 
121  Q_INVOKABLE void setAtomicValue(QVariant value);
122 
123 
128  static void registerType();
129 
135  const QString getLocalName();
136 
142  const QString getStringValue();
143 
144 
145 
146 signals:
147 
148  void stringValueChanged();
149 
150 public slots:
151 
152 protected:
153 
154  void setValue(const QXmlItem& item, ZxQuery* zQuery);
155 
156  bool ensureIntegrity(const QString& code, const QString& message);
157 
158 
163  QXmlItem m_item;
164 
173 
174 };
175 
176 } // Zbl
177 
178 #endif // ZXITEM_H
This class allows Javascript programs to access QXmlItem objects.
Definition: ZxItem.h:43
Q_INVOKABLE void setAtomicValue(QVariant value)
set the item to an atomic value
Definition: ZxItem.cpp:54
ZxItem(QObject *parent=0)
Definition: ZxItem.cpp:35
static void registerType()
Registers ZxItem as a QML type.
Definition: ZxItem.cpp:40
Q_INVOKABLE bool isNull() const
determine if this item is null
Definition: ZxItem.cpp:73
Q_INVOKABLE bool isAtomicValue() const
determine if this item is an atomic value. Atomic values are represented by QVariant objects...
Definition: ZxItem.cpp:63
Q_INVOKABLE QVariant toAtomicValue() const
convert this item to it&#39;s atomic value equivalent.
Definition: ZxItem.cpp:78
Q_INVOKABLE QObject * elementById(const QString &id)
Obtain the element node from this node model that has the specified id attribute. ...
Definition: ZxItem.cpp:142
This class provides access to the QXmlResultItems class from Javascript programs. It accumulates the ...
Definition: ZxResultItems.h:45
bool ensureIntegrity(const QString &code, const QString &message)
Definition: ZxItem.cpp:183
ZxQuery * m_zQuery
Pointer to the ZxQuery object associated with this item.
Definition: ZxItem.h:172
void stringValueChanged()
Definition: ZAndGate.cpp:6
QString localName
get the node local name
Definition: ZxItem.h:57
QXmlItem m_item
Encapsulated QmlItem object.
Definition: ZxItem.h:163
QString stringValue
get the node string value
Definition: ZxItem.h:63
Q_INVOKABLE bool isNode() const
determine if this item is a node value.
Definition: ZxItem.cpp:68
const QString getLocalName()
returns the local name of this item
Definition: ZxItem.cpp:83
const QString getStringValue()
returns the string value of this item
Definition: ZxItem.cpp:102
QObject rootNode
get the root node for the model containing this node
Definition: ZxItem.h:69
This class provides access to the QXMLQuery class from Javascript.
Definition: ZxQuery.h:48
QObject * getRootNode()
Obtain the root node from the node model that contains this node.
Definition: ZxItem.cpp:119
void setValue(const QXmlItem &item, ZxQuery *zQuery)
Definition: ZxItem.cpp:45