summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp126
-rw-r--r--src/declarative/extra/qmlxmllistmodel.h40
-rw-r--r--src/declarative/qml/qmlenginedebug.cpp7
-rw-r--r--tools/qmldebugger/engines.qml6
4 files changed, 95 insertions, 84 deletions
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index 4b67074..01efa0e 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -58,20 +58,85 @@
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,XmlRole,XmlListModelRole)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,XmlRole,QmlXmlListModelRole)
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,XmlListModel,QmlXmlListModel)
+/*!
+ \qmlclass XmlRole
+ \brief The XmlRole element allows you to specify a role for an XmlListModel.
+*/
+
+/*!
+ \qmlproperty string XmlRole::name
+ The name for the role. This name is used to access the model data for this role from Qml.
+
+ \qml
+ XmlRole { name: "title"; query: "title/string()" }
+
+ ...
+
+ Component {
+ id: Delegate
+ Text { text: title }
+ }
+ \endqml
+*/
+
+/*!
+ \qmlproperty string XmlRole::query
+ The relative XPath query for this role. The query should not start with a '/' (i.e. it must be
+ relative).
+
+ \qml
+ XmlRole { name: "title"; query: "title/string()" }
+ \endqml
+*/
+
+class Q_DECLARATIVE_EXPORT QmlXmlListModelRole : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString query READ query WRITE setQuery)
+
+public:
+ QmlXmlListModelRole() {}
+ ~QmlXmlListModelRole() {}
+
+ QString name() const { return m_name; }
+ void setName(const QString &name) { m_name = name; }
+
+ QString query() const { return m_query; }
+ void setQuery(const QString &query)
+ {
+ if (query.startsWith(QLatin1Char('/'))) {
+ qmlInfo(this) << "An XmlRole query must not start with '/'";
+ return;
+ }
+ m_query = query;
+ }
+
+ bool isValid() {
+ return !m_name.isEmpty() && !m_query.isEmpty();
+ }
+
+private:
+ QString m_name;
+ QString m_query;
+};
+
+QML_DECLARE_TYPE(QmlXmlListModelRole)
+
class QmlXmlListModelPrivate;
-struct QmlXmlRoleList : public QmlConcreteList<XmlListModelRole *>
+struct QmlXmlRoleList : public QmlConcreteList<QmlXmlListModelRole *>
{
QmlXmlRoleList(QmlXmlListModelPrivate *p)
: model(p) {}
- virtual void append(XmlListModelRole *role);
+ virtual void append(QmlXmlListModelRole *role);
//XXX clear, removeAt, and insert need to invalidate any cached data (in data table) as well
// (and the model should emit the appropriate signals)
virtual void clear();
virtual void removeAt(int i);
- virtual void insert(int i, XmlListModelRole *role);
+ virtual void insert(int i, QmlXmlListModelRole *role);
QmlXmlListModelPrivate *model;
};
@@ -220,7 +285,7 @@ void QmlXmlQuery::doSubQueryJob()
//### we might be able to condense even further (query for everything in one go)
for (int i = 0; i < m_roleObjects->size(); ++i) {
- XmlListModelRole *role = m_roleObjects->at(i);
+ QmlXmlListModelRole *role = m_roleObjects->at(i);
if (!role->isValid()) {
QList<QVariant> resultList;
for (int j = 0; j < m_size; ++j)
@@ -248,7 +313,7 @@ void QmlXmlQuery::doSubQueryJob()
/*for (int j = 0; j < m_size; ++j) {
QList<QVariant> resultList;
for (int i = 0; i < m_roleObjects->size(); ++i) {
- XmlListModelRole *role = m_roleObjects->at(i);
+ QmlXmlListModelRole *role = m_roleObjects->at(i);
subquery.setQuery(m_prefix.arg(j+1) + role->query());
if (role->isStringList()) {
QStringList data;
@@ -274,10 +339,8 @@ void QmlXmlQuery::doSubQueryJob()
}
-//TODO: do something smart while waiting for data to load
-// error handling (currently quite fragile)
+//TODO: error handling (currently quite fragile)
// profile doQuery and doSubquery
-// some sort of loading indication while we wait for initial data load (status property similar to QWebImage?)
// support complex/nested objects?
// how do we handle data updates (like rss feed -- usually items inserted at beginning)
@@ -310,64 +373,33 @@ public:
};
-void QmlXmlRoleList::append(XmlListModelRole *role) {
- QmlConcreteList<XmlListModelRole *>::append(role);
+void QmlXmlRoleList::append(QmlXmlListModelRole *role) {
+ QmlConcreteList<QmlXmlListModelRole *>::append(role);
model->roles << model->highestRole;
model->roleNames << role->name();
++model->highestRole;
}
-/*!
- \qmlclass XmlRole
- \brief The XmlRole element allows you to specify a role for an XmlListModel.
-*/
-
-/*!
- \qmlproperty string XmlRole::name
- The name for the role. This name is used to access the model data for this role from Qml.
-
- \qml
- XmlRole { name: "title"; query: "title/string()" }
-
- ...
-
- Component {
- id: Delegate
- Text { text: title }
- }
- \endqml
-*/
-
-/*!
- \qmlproperty string XmlRole::query
- The relative XPath query for this role. The query should not start with a '/' (i.e. it must be
- relative).
-
- \qml
- XmlRole { name: "title"; query: "title/string()" }
- \endqml
-*/
-
//XXX clear, removeAt, and insert need to invalidate any cached data (in data table) as well
// (and the model should emit the appropriate signals)
void QmlXmlRoleList::clear()
{
model->roles.clear();
model->roleNames.clear();
- QmlConcreteList<XmlListModelRole *>::clear();
+ QmlConcreteList<QmlXmlListModelRole *>::clear();
}
void QmlXmlRoleList::removeAt(int i)
{
model->roles.removeAt(i);
model->roleNames.removeAt(i);
- QmlConcreteList<XmlListModelRole *>::removeAt(i);
+ QmlConcreteList<QmlXmlListModelRole *>::removeAt(i);
}
//### we should enforce unique role names
-void QmlXmlRoleList::insert(int i, XmlListModelRole *role)
+void QmlXmlRoleList::insert(int i, QmlXmlListModelRole *role)
{
- QmlConcreteList<XmlListModelRole *>::insert(i, role);
+ QmlConcreteList<QmlXmlListModelRole *>::insert(i, role);
model->roles.insert(i, model->highestRole);
model->roleNames.insert(i, role->name());
++model->highestRole;
@@ -413,7 +445,7 @@ QmlXmlListModel::~QmlXmlListModel()
The roles to make available for this model.
*/
-QmlList<XmlListModelRole *> *QmlXmlListModel::roleObjects()
+QmlList<QmlXmlListModelRole *> *QmlXmlListModel::roleObjects()
{
Q_D(QmlXmlListModel);
return &d->roleObjects;
diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h
index 5f7c831..1bcc008 100644
--- a/src/declarative/extra/qmlxmllistmodel.h
+++ b/src/declarative/extra/qmlxmllistmodel.h
@@ -53,37 +53,8 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QmlContext;
-class Q_DECLARATIVE_EXPORT XmlListModelRole : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QString query READ query WRITE setQuery)
-public:
- XmlListModelRole() {}
- ~XmlListModelRole() {}
-
- QString name() const { return m_name; }
- void setName(const QString &name) { m_name = name; }
-
- QString query() const { return m_query; }
- void setQuery(const QString &query)
- {
- if (query.startsWith(QLatin1Char('/'))) {
- qmlInfo(this) << "An XmlRole query must not start with '/'";
- return;
- }
- m_query = query;
- }
-
- bool isValid() {
- return !m_name.isEmpty() && !m_query.isEmpty();
- }
-
-private:
- QString m_name;
- QString m_query;
-};
+class QmlXmlListModelRole;
class QmlXmlListModelPrivate;
class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public QmlParserStatus
@@ -98,7 +69,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public
Q_PROPERTY(QString xml READ xml WRITE setXml)
Q_PROPERTY(QString query READ query WRITE setQuery)
Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations)
- Q_PROPERTY(QmlList<XmlListModelRole *> *roles READ roleObjects)
+ Q_PROPERTY(QmlList<QmlXmlListModelRole *> *roles READ roleObjects)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "roles")
@@ -111,7 +82,7 @@ public:
virtual QList<int> roles() const;
virtual QString toString(int role) const;
- QmlList<XmlListModelRole *> *roleObjects();
+ QmlList<QmlXmlListModelRole *> *roleObjects();
QUrl source() const;
void setSource(const QUrl&);
@@ -138,6 +109,10 @@ signals:
void countChanged();
public Q_SLOTS:
+ // ### need to use/expose Expiry to guess when to call this?
+ // ### property to auto-call this on reasonable Expiry?
+ // ### LastModified/Age also useful to guess.
+ // ### Probably also applies to other network-requesting types.
void reload();
private Q_SLOTS:
@@ -152,7 +127,6 @@ private:
QT_END_NAMESPACE
-QML_DECLARE_TYPE(XmlListModelRole)
QML_DECLARE_TYPE(QmlXmlListModel)
QT_END_HEADER
diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp
index 321fe74..7f9e530 100644
--- a/src/declarative/qml/qmlenginedebug.cpp
+++ b/src/declarative/qml/qmlenginedebug.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qmlenginedebug_p.h"
+#include "qmlboundsignal_p.h"
#include <QtCore/qdebug.h>
#include <QtCore/qmetaobject.h>
#include <QtDeclarative/qmlengine.h>
@@ -103,7 +104,11 @@ QmlEngineDebugServer::propertyData(QObject *obj, int propIdx)
if (prop.type() < QVariant::UserType) {
rv.type = QmlObjectProperty::Basic;
- rv.value = prop.read(obj);
+ if (qobject_cast<QmlBoundSignalParameters*>(obj) && prop.name() != QByteArray("objectName"))
+ // these "properties" only have meaning during signal emission
+ rv.value = tr("(signal parameter)");
+ else
+ rv.value = prop.read(obj);
} else if (QmlMetaType::isObject(prop.userType())) {
rv.type = QmlObjectProperty::Object;
} else if (QmlMetaType::isList(prop.userType()) ||
diff --git a/tools/qmldebugger/engines.qml b/tools/qmldebugger/engines.qml
index 1652ebd..1e9335b 100644
--- a/tools/qmldebugger/engines.qml
+++ b/tools/qmldebugger/engines.qml
@@ -9,16 +9,16 @@ Item {
Row {
anchors.fill: parent
Repeater {
- dataSource: engines
+ model: engines
Item {
width: 100; height: 100;
Image {
- id: Image;
+ id: EngineIcon;
source: "qrc:/engine.png"
anchors.horizontalCenter: parent.horizontalCenter
}
Text {
- anchors.top: Image.bottom;
+ anchors.top: EngineIcon.bottom;
text: modelData.name + "(" + modelData.engineId + ")"
anchors.horizontalCenter: parent.horizontalCenter
}