import QtQuick 2.5
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.1
import QtQuick.XmlListModel 2.0
import com.brkaubing 1.0
ApplicationWindow {
visible: true
toolBar: ToolBar {
RowLayout {
ToolButton {
text: "Back"
visible: stack.depth > 1
onClicked: stack.pop()
}
}
}
XmlFileHandler {
id: handler;
property bool filesChecked: false
property bool showInternalDates: false
property bool showHvoDates: true
property bool showEventDates: false
property int offset: 0
property string actionItem: ""
property string baItem: ""
property string hvoItem: ""
onNextEventsArrayChanged: {
if(fileStat > 0){
for (var i = 0; i < nextEventsArray.length; i++){
console.log(i+": "+nextEventsArray[i])
}
if(showInternalDates)
offset = nextEventsArray[24]
actionItem = "am: "+handler.nextEventsArray[20]+" Uhr\n"+handler.nextEventsArray[22]
baItem = "am: "+handler.nextEventsArray[handler.offset]+" Uhr
Thema: "+handler.nextEventsArray[handler.offset+2]
hvoItem = "am: "+handler.nextEventsArray[8]+" Uhr"
if(fileStat > 0 && handler.nextEventsArray[20].isEmpty){
var today = new Date()
var tmp = handler.nextEventsArray[20].split('.')
var newEventDate = new Date(("20"+tmp[2]).substring(0,4)*1,tmp[1]*1-1,tmp[0]*1,12,0,0,0)
showEventDates = newEventDate>today+21*24*3600000 ? false:true
}else{
showEventDates = false
}
}
}
}
Component.onCompleted: {
if(!handler.filesChecked){
handler.load(path, file);
handler.filesChecked = true;
}
}
StackView {
id: stack
initialItem: firstPage
anchors.fill: parent
FirstPage {
id:firstPage
}
Component {
id:planPage
Flickable {
id: planView
anchors.fill: parent
ListView {
id: listView
anchors.fill: parent
property bool modelDataError: false
property string statusMessage: ""
property string filter: ""
property var date : new Date()
property int now: date.getTime()/1000 - 24*3600 // Termine die schon waren sollen nicht mehr angezeigt werden.
model: planModel
delegate: Text {
text: thema
}
}
XmlListModel {
id: planModel
source: handler.filePath()
query: "/xml/termin"+listView.filter
XmlRole { name: "type"; query: "@type/number()" }
XmlRole { name: "datum"; query: "datum/string()" }
XmlRole { name: "art"; query: "art/string()" }
XmlRole { name: "thema"; query: "thema/string()" }
XmlRole { name: "anmerkung"; query: "anmerkung/string()"}
onStatusChanged: {
listView.modelDataError = false
console.log(planModel.source)
if(status == XmlListModel.Error) {
listView.state = "Offline"
listView.statusMessage = "Ein Fehler ist aufgetreten: " + errorString()
listView.modelDataError = true
console.log("Terminplan: " + listView.statusMessage)
} else if (status == XmlListModel.Ready) {
if(get(0) === undefined){
listView.state = "Offline"
listView.statusMessage = "Die lokalen Daten sind defekt. Bitte starten Sie die App neu."
handler.clear()
listView.modelDataError = true
} else {
listView.state = "Online"
listView.statusMessage = "Aktuelle Daten sind verfügbar. "+now
}
console.log("Terminpaln: "+listView.statusMessage)
} else if (status == XmlListModel.Loading){
listView.state = "Läd..."
listView.statusMessage = "Daten werden geladen."
} else if(status == XmlListModel.Null) {
listView.state = "Loading"
listView.statusMessage = "Forecast data is empty..."
console.log("Terminplan: " + listView.statusMessage)
} else {
listView.modelDataError = fase
console.log("Terminplan: Unklarer Zustand der XML Datei: " + status)
}
}
}
}
}
}
}
Bookmarks