Continued implementation of own day view
This commit is contained in:
parent
b79b5999c2
commit
65381c0a2b
2 changed files with 35 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue