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
ZxResultItems.cpp
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  * ZxResultItems.cpp
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 #include <QtQml>
27 #include "ZxResultItems.h"
28 #include "ZblThreadErr.h"
29 #include "ZxQuery.h"
30 #include "ZxItem.h"
31 
32 namespace Zbl
33 {
34 
35 ZxResultItems::ZxResultItems(ZxQuery* zQuery, QObject *parent) :
36  QObject(parent), m_zQuery(zQuery)
37 {
38  //qDebug("ZxResultItems::ZxResultItems - list size = %u", m_items.size());
39 
40 }
41 
43 {
44  qmlRegisterUncreatableType<ZxResultItems>(
45  "org.zuble.qml", 1, 0, "ZxResultItems",
46  "Call ZxQuery::evaluateToItems method to obtain this object");
47 }
48 
50 {
51  int result = m_items.count();
52  //return m_items.count();
53  return result;
54 }
55 
56 
57 
58 QObject* ZxResultItems::getItem(int index)
59 {
60  if(index > m_items.count())
61  {
62  QString msg("ZxResultItems::getItem - Index out of range: %1");
63 
64  zThreadErr.raiseError("ZxResultItems", "getItem Failed", msg.arg(index));
65 
66  return NULL;
67  }
68 
69  ZxItem* item = new ZxItem();
70 
71  item->setValue(*m_items.at(index), m_zQuery);
72 
73  return item;
74 
75 }
76 
77 #if 0
78 QObject* ZxResultItems::getItemById(QString idValue)
79 {
80  QXmlModelIndex
81 
82 }
83 #endif
84 
85 } // Zbl
ZxQuery * m_zQuery
The ZxQuery object that produced this object.
This class allows Javascript programs to access QXmlItem objects.
Definition: ZxItem.h:43
ZxResultItems(ZxQuery *zQuery, QObject *parent=0)
qItemList m_items
A list of QXmlItem objects resulting from an XQuery evaluation.
static void registerType()
Registers ZxResultItems as a QML type. TBD: should we do this?
Q_INVOKABLE QObject * getItem(int index)
returns the specified ZxItem object in the result sequence by index
Definition: ZAndGate.cpp:6
#define zThreadErr
where does this show up?
Definition: ZblThreadErr.h:39
int getCount()
returns the specified ZxItem object from the result model by specifying it&#39;s ID. The XML node must ha...
This class provides access to the QXMLQuery class from Javascript.
Definition: ZxQuery.h:48
void setValue(const QXmlItem &item, ZxQuery *zQuery)
Definition: ZxItem.cpp:45