From 65381c0a2bcb03b830ee27b5d8888fbce4e16175 Mon Sep 17 00:00:00 2001 From: Stefan Persson Date: Thu, 27 Jan 2011 15:10:48 +0000 Subject: [PATCH] Continued implementation of own day view --- .../Plugins/SchedulerGUISimple/main.qml | 23 ++++++++++++++++--- .../SchedulerGUISimple/schedulerscripts.js | 15 ++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/telldus-gui/Plugins/SchedulerGUISimple/main.qml b/telldus-gui/Plugins/SchedulerGUISimple/main.qml index a354412c..50ee094d 100644 --- a/telldus-gui/Plugins/SchedulerGUISimple/main.qml +++ b/telldus-gui/Plugins/SchedulerGUISimple/main.qml @@ -11,13 +11,22 @@ import "schedulerscripts.js" as Scripts Component.onCompleted: { var dynamicDay = 0; + var startday = new Date(); + startday.setDate(startday.getDate() - 6); + var weekday_name_array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") for(var i=0;i<7;i++){ //One week, TODO dynamic dynamicDay = dayListViewComponent.createObject(mainContent) dynamicDay.state = "hiddenLeft"; + var currentDay = new Date(startday); + currentDay.setDate(startday.getDate() + i); + var day = currentDay.getDay(); + dynamicDay.dayName = weekday_name_array[day]; Scripts.addDay(dynamicDay) - //även spara datum... ev. veckodag, eller räkna fram + //även spara datum...? ev. räkna fram veckodag? } dynamicDay.state = "visible" //set last one as visible + weekDayText.text = Scripts.getCurrentDay().dayName + //weekDayText.state = "loaded" } Rectangle{ @@ -42,6 +51,7 @@ import "schedulerscripts.js" as Scripts //step to prev weekday //Scripts.updateEndsWith() Scripts.decrementCurrentDay() + weekDayText.text = Scripts.getCurrentDay().dayName //mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center) //mainListView.currentIndex = mainListView.currentIndex - 1 } @@ -50,7 +60,12 @@ import "schedulerscripts.js" as Scripts Text{ id: weekDayText anchors.centerIn: parent - text: "TESTAR" + //text: "" + /*states: State{ + name: "loaded"; + PropertyChanges{ target: weekDayText; text: Scripts.getCurrentDay().dayName } + } + */ } Rectangle{ @@ -69,6 +84,7 @@ import "schedulerscripts.js" as Scripts //step to next weekday //Scripts.updateEndsWith(mainListView) Scripts.incrementCurrentDay() + weekDayText.text = Scripts.getCurrentDay().dayName //mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center) //mainListView.currentIndex = mainListView.currentIndex + 1 } @@ -148,6 +164,7 @@ import "schedulerscripts.js" as Scripts id: dayListViewComponent ListView { id: dayListView + property string dayName: "" //anchors.top: mainListView.bottom //anchors.left: parent.left width: constDeviceRowWidth @@ -220,7 +237,7 @@ import "schedulerscripts.js" as Scripts //onEntered: parent.border.color = onHoverColor //onExited: parent.border.color = borderColor onClicked: { - + //print("Mainrow: " + mainRow.parent.children[0].height); var component = Qt.createComponent("ActionPoint.qml") var dynamicPoint = component.createObject(deviceRow) //dynamicPoint.x = mouseX - dynamicPoint.width/2 //xposition diff --git a/telldus-gui/Plugins/SchedulerGUISimple/schedulerscripts.js b/telldus-gui/Plugins/SchedulerGUISimple/schedulerscripts.js index 23f39fd5..51a47e88 100644 --- a/telldus-gui/Plugins/SchedulerGUISimple/schedulerscripts.js +++ b/telldus-gui/Plugins/SchedulerGUISimple/schedulerscripts.js @@ -20,6 +20,21 @@ function getDays(){ return days; } +function getCurrentDay(){ + return days[currentDayIndex]; +} + +/* +function getCurrentDayName(){ + print("Hittat rätt" + currentDayIndex); + var day = days[currentDayIndex]; + if(day == null){ + return "TOMT-omt-omt"; + } + return day.dayName; +} +*/ + function decrementCurrentDay(){ if(currentDayIndex == 0){ //TODO in the future, add new day instead (if 7 days) return;