Alternative implementation of XmlListView
-
Hi,
I'm trying to implement an alternative to XmlListView in C++. Unfortunately, I'm quite new to programming (esp. C++), so I need some help. Essentially, what I want to achieve, is something that looks like this in QML:
@
XmlListModel2 {
id: xmlModel
source: "file.xml"
query: "/xml/something"XmlConnect { name: "one"; query: "name/string()"; source2: "file2.xml"; query2: "/root/something/@name/string()" } XmlSearch { name: "oneEn"; query: "name/string()"; where: "@xml:lang"; is: "en" }
}
@
The XmlConnect creates an List Role element (or whatever that's called) called "one", and basically it looks into file.xml for the string in the name attribute, matches it with the <name> content in file2.xml and returns that value (e.g. string1 or string2 in the example below).The XmlSearch returns the value of the string where the language is English (i.e. "John" in the example below), or if none is found, the value of the tag without any attributes (i.e. "Peter" in the example below)
Essentially, the list created from the example below would look something like this:
{one: "string1"; oneEn: "John"}
{one: "string2"; oneEn: "Peter"}This means that for example, the XML files look like this:
file.xml:
@
<xml>
<something>
<name>Johannes</name>
<name xml:lang="en">John</name>
</something>
<something>
<name>Peter</name>
</something>
</xml>
@
file2.xml:
@
<root>
<something name="Johannes">string1</something>
<something name="Peter">string2</something>
</root>
@
I am not asking you guys to implement this for me, but I am struggling with the C++ side. Basically, I need to know what the code looks like to have this kind of a list implemented. Then, I will add the code doing the XML queries myself. Basically, I need to know how to implement these classes so that I can then use them in QML. Up until now, I can do the queries in C++, but connecting all this to the QML side is where I'm struggling. Note: I'm using a QmlApplicationViewer in main.cpp. Can you help me?
Thank you very much.
Keba