[Qt-qml] What's wrong with our XmlListModel?

Ivan De Marino ivan.de.marino at gmail.com
Tue Jul 27 15:22:33 CEST 2010


Hi QML people

We are facing a very weird behaviour of XmlListModel, and after long "try
this and try that", seems like the problem is inside XmlListModel.

BUT, before filing a bug, I ask you to take a quick look to the code, to see
if we are doing anything wrong. Can you :D ?

1. Use of XmlListModel

> *import Qt 4.7*

*
> *

*XmlListModel {*

*    id: xmlFeedModel*

*    source: "../data/help-app-data-v2.xml"*

*    query: "/app/help/sections/section"*

*    XmlRole { name: "bob"; query: "@id/string()"; }*

*    XmlRole { name: "rob"; query: "@title/string()"; }*

*    XmlRole { name: "paul"; query: "@subtitle/string()"; }*

* *

*   onStatusChanged: {*

*        if (status == XmlListModel.Ready) {*

*            console.log ("Ready");*

*        }*

*        else if (status == XmlListModel.Error) {*

*            console.log ("Error");*

*        }*

*    }*

*}*


2. Use of the Model in the a Delegate
*ListView {*
*   // ...*
*   model: OrangeHelpXmlModel { }*
*   // ...*
*   delegate: Rectangle {*
*      // ...*
*      text: model.rob;*
*      // ...*
*      text: model.bob;*
*      // ...*
*      text: model.paul;*
*      // ...*
*   }*
*   // ...*
*}*

3. Local XML file used by the XmlListModel
<?xml version="1.0" encoding="ISO-8859-1"?>
<app xmlns="http://www.orange.co.uk/ns/app/1">
    <help>
        <sections>
            <section id="iphonesoftwareupdate" *title="iOS4 software update"
* *subtitle="info on Apple's latest software"*>
                <link href="file://appbase/article//132678" title="iOS 4
features" subtitle="info on Apple's latest software" />
                <link href="file://appbase/article//132681" title="how to
get iOS 4 " subtitle="info on downloading" />
            </section>
            <section id="calling" title="calling" subtitle="Answer Phone,
Magic Numbers">
                <link href="file://appbase/article//79527" title="Orange
Answer Phone" subtitle="never miss an important call" />
                <link href="file://appbase/article//79537" title="Magic
Numbers" subtitle="stay in touch with those who matter" />
                <link href="file://appbase/article//79525" title="Orange
directory enquiries" subtitle="directory enquiries by phone or text" />
                <link href="file://appbase/article//79538" title="conference
calls" subtitle="talk to more than one person at a time" />
                <link href="file://appbase/article//79512" title="calling
abroad" subtitle="calling abroad from the UK" />
                <link href="file://appbase/article//79526" title="video
calling" subtitle="video calls not currently supported" />
            </section>
...

RESULT? Nothing appears in the ListView. It's empty. It's like the Model is
returning no rows whatsoever.
As you can see, we added some code to check when the Model is loaded. And it
is!!!

NOTE: Something even more weird to notice, if we do something like:

> *XmlListModel {*

*   id: xmlFeedModel*

*   property string title: "The Orange Feed"*

*   property string description: "Latest news from Orange UK"*

*   property alias link: xmlFeedModel.source*

*
> *

*   source: "**http://feeds.feedburner.com/TheFeedOrange?format=xml*<http://feeds.feedburner.com/TheFeedOrange?format=xml>
> *"*

 *   query: "/rss/channel/item"*

*   XmlRole { name: "title"; query: "title/string()"; }*

*   XmlRole { name: "link"; query: "link/string()"; }*

*   XmlRole { name: "date"; query: "pubDate/string()"; }*

*}*

Loading the XML from the network, everything is fine.

Any suggestion of what might be going wrong?

Thanks
Ivan De Marino on behalf of Rachel Liu
-- 
 Ivan De Marino | Software Engineer | France Telecom R&D UK - Orange Labs
 w. +44 20 8849 5806 | m. +44 7515 955 861 | m. +44 7974 156 216
 ivan[dot]demarino[at]orange-ftgroup.com |
ivan[dot]de[dot]marino[at]gmail[dot]com
 www.detronizator.org | www.linkedin.com/in/ivandemarino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100727/eed16a1e/attachment.html 


More information about the Qt-qml mailing list