-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScheduleData.qml
49 lines (41 loc) · 1.13 KB
/
ScheduleData.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import QtQuick 2.0
import QtQml 2.2
import "ScheduleItemModel.js" as Models
Item {
id: scheduleData
property date currentDate: new Date();
property int offsetHours: 1
property int offset: offsetHours * 3600 * 1000;
property int dayOfTheWeek: currentDate.getDay()
property alias busData: dataLoader.item
Loader {
id: dataLoader
source: {
if(dayOfTheWeek == 0)
return "data/SundayData.qml"
if(dayOfTheWeek == 6)
return "data/SaturdayData.qml"
return "data/RegularDayData.qml"
}
}
function notInPast(element, index, array){
return (element.date - currentDate) >= -offset;
}
property var schedule: busData.schedule.filter(notInPast);
property int nextBusIndex: {
for(var i=0;i<schedule.length;i++){
if(schedule[i].date <= currentDate)
continue;
return i;
}
return 5
}
Timer {
running: true
repeat: true
onTriggered: {
scheduleData.currentDate = new Date();
}
interval: 1000
}
}