Hi,

I am still trying to port my Sailfish App to Android. So far I managed to download a XML file from the web and to store it locally. Using my C++ file handler I am able to read the file but I get an "unknown error" when I try to read the XML file with XmlListModel.

Here is my Code:
Qt Code:
  1. import QtQuick 2.5
  2. import QtQuick.Window 2.2
  3. import QtQuick.Controls 1.4
  4. import QtQuick.Layouts 1.1
  5. import QtQuick.XmlListModel 2.0
  6.  
  7. import com.brkaubing 1.0
  8.  
  9. ApplicationWindow {
  10. visible: true
  11.  
  12. toolBar: ToolBar {
  13. RowLayout {
  14. ToolButton {
  15. text: "Back"
  16. visible: stack.depth > 1
  17.  
  18. onClicked: stack.pop()
  19. }
  20. }
  21. }
  22.  
  23. XmlFileHandler {
  24. id: handler;
  25.  
  26. property bool filesChecked: false
  27. property bool showInternalDates: false
  28. property bool showHvoDates: true
  29. property bool showEventDates: false
  30. property int offset: 0
  31. property string actionItem: ""
  32. property string baItem: ""
  33. property string hvoItem: ""
  34.  
  35. onNextEventsArrayChanged: {
  36. if(fileStat > 0){
  37. for (var i = 0; i < nextEventsArray.length; i++){
  38. console.log(i+": "+nextEventsArray[i])
  39. }
  40. if(showInternalDates)
  41. offset = nextEventsArray[24]
  42.  
  43. actionItem = "am: "+handler.nextEventsArray[20]+" Uhr\n"+handler.nextEventsArray[22]
  44. baItem = "am: "+handler.nextEventsArray[handler.offset]+" Uhr
  45. Thema: "+handler.nextEventsArray[handler.offset+2]
  46. hvoItem = "am: "+handler.nextEventsArray[8]+" Uhr"
  47.  
  48. if(fileStat > 0 && handler.nextEventsArray[20].isEmpty){
  49. var today = new Date()
  50. var tmp = handler.nextEventsArray[20].split('.')
  51. var newEventDate = new Date(("20"+tmp[2]).substring(0,4)*1,tmp[1]*1-1,tmp[0]*1,12,0,0,0)
  52. showEventDates = newEventDate>today+21*24*3600000 ? false:true
  53. }else{
  54. showEventDates = false
  55. }
  56. }
  57. }
  58. }
  59.  
  60. Component.onCompleted: {
  61. if(!handler.filesChecked){
  62. handler.load(path, file);
  63. handler.filesChecked = true;
  64. }
  65. }
  66.  
  67. StackView {
  68. id: stack
  69. initialItem: firstPage
  70. anchors.fill: parent
  71.  
  72. FirstPage {
  73. id:firstPage
  74. }
  75.  
  76. Component {
  77. id:planPage
  78.  
  79. Flickable {
  80. id: planView
  81. anchors.fill: parent
  82.  
  83. ListView {
  84. id: listView
  85. anchors.fill: parent
  86.  
  87. property bool modelDataError: false
  88. property string statusMessage: ""
  89. property string filter: ""
  90. property var date : new Date()
  91. property int now: date.getTime()/1000 - 24*3600 // Termine die schon waren sollen nicht mehr angezeigt werden.
  92.  
  93. model: planModel
  94. delegate: Text {
  95. text: thema
  96. }
  97. }
  98.  
  99. XmlListModel {
  100. id: planModel
  101. source: handler.filePath()
  102. query: "/xml/termin"+listView.filter
  103. XmlRole { name: "type"; query: "@type/number()" }
  104. XmlRole { name: "datum"; query: "datum/string()" }
  105. XmlRole { name: "art"; query: "art/string()" }
  106. XmlRole { name: "thema"; query: "thema/string()" }
  107. XmlRole { name: "anmerkung"; query: "anmerkung/string()"}
  108.  
  109. onStatusChanged: {
  110. listView.modelDataError = false
  111. console.log(planModel.source)
  112. if(status == XmlListModel.Error) {
  113. listView.state = "Offline"
  114. listView.statusMessage = "Ein Fehler ist aufgetreten: " + errorString()
  115. listView.modelDataError = true
  116. console.log("Terminplan: " + listView.statusMessage)
  117. } else if (status == XmlListModel.Ready) {
  118. if(get(0) === undefined){
  119. listView.state = "Offline"
  120. listView.statusMessage = "Die lokalen Daten sind defekt. Bitte starten Sie die App neu."
  121. handler.clear()
  122. listView.modelDataError = true
  123. } else {
  124. listView.state = "Online"
  125. listView.statusMessage = "Aktuelle Daten sind verfügbar. "+now
  126. }
  127. console.log("Terminpaln: "+listView.statusMessage)
  128. } else if (status == XmlListModel.Loading){
  129. listView.state = "Läd..."
  130. listView.statusMessage = "Daten werden geladen."
  131. } else if(status == XmlListModel.Null) {
  132. listView.state = "Loading"
  133. listView.statusMessage = "Forecast data is empty..."
  134. console.log("Terminplan: " + listView.statusMessage)
  135. } else {
  136. listView.modelDataError = fase
  137. console.log("Terminplan: Unklarer Zustand der XML Datei: " + status)
  138. }
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }
To copy to clipboard, switch view to plain text mode 

The path is correct and pointing to the right file. I use the same code on Sailfish and there it is working. Where could I look for my error?