xml - How to load source data in GroupDataModel for ListView in Blackberry 10 cascade? -
here line of code want load source:
data xml file located in device shared folder.
the path of xml file qfile textfile("/accounts/1000/shared/documents/mydata.xml");
my code is:
import bb.cascades 1.0 import bb.data 1.0 page { content: listview { id: listview datamodel: datamodel ... } attachedobjects: [ groupdatamodel { id: datamodel }, datasource { id: datasource //--------------------------------------- //here want load xml file //--------------------------------------- source: "/accounts/1000/shared/documents/mydata.xml" //--------------------------------------- query: "/contacts/contact" ondataloaded: { datamodel.insertlist(data); } } ] oncreationcompleted: { datasource.load(); } }
anyone please me, how load xml file in groupdatamodel located in above device directory location.
thanks in advance.
we have 2 parts :
first 1 allowing application use shared folders
steps:
- go bar-descriptor.xml in project
- select application
- check true in shared files
second 1 correct path using c++ , send qml in context property
this in apllicationui.cpp c++ code
// build path, add context property, , expose // qml qstring workingdir = qdir::currentpath(); qstring path = "file://" + workingdir +"/shared/documents/model.xml"; qdeclarativepropertymap* dirpaths = new qdeclarativepropertymap; dirpaths->insert("documents", qvariant(qstring(path))); qml->setcontextproperty("dirpaths", dirpaths);
qml
datamodel: xmldatamodel { source: dirpaths.documents }
Comments
Post a Comment