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: {
|
Component.onCompleted: {
|
||||||
var dynamicDay = 0;
|
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
|
for(var i=0;i<7;i++){ //One week, TODO dynamic
|
||||||
dynamicDay = dayListViewComponent.createObject(mainContent)
|
dynamicDay = dayListViewComponent.createObject(mainContent)
|
||||||
dynamicDay.state = "hiddenLeft";
|
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)
|
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
|
dynamicDay.state = "visible" //set last one as visible
|
||||||
|
weekDayText.text = Scripts.getCurrentDay().dayName
|
||||||
|
//weekDayText.state = "loaded"
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
|
@ -42,6 +51,7 @@ import "schedulerscripts.js" as Scripts
|
||||||
//step to prev weekday
|
//step to prev weekday
|
||||||
//Scripts.updateEndsWith()
|
//Scripts.updateEndsWith()
|
||||||
Scripts.decrementCurrentDay()
|
Scripts.decrementCurrentDay()
|
||||||
|
weekDayText.text = Scripts.getCurrentDay().dayName
|
||||||
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
|
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
|
||||||
//mainListView.currentIndex = mainListView.currentIndex - 1
|
//mainListView.currentIndex = mainListView.currentIndex - 1
|
||||||
}
|
}
|
||||||
|
@ -50,7 +60,12 @@ import "schedulerscripts.js" as Scripts
|
||||||
Text{
|
Text{
|
||||||
id: weekDayText
|
id: weekDayText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: "TESTAR"
|
//text: ""
|
||||||
|
/*states: State{
|
||||||
|
name: "loaded";
|
||||||
|
PropertyChanges{ target: weekDayText; text: Scripts.getCurrentDay().dayName }
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
Rectangle{
|
Rectangle{
|
||||||
|
@ -69,6 +84,7 @@ import "schedulerscripts.js" as Scripts
|
||||||
//step to next weekday
|
//step to next weekday
|
||||||
//Scripts.updateEndsWith(mainListView)
|
//Scripts.updateEndsWith(mainListView)
|
||||||
Scripts.incrementCurrentDay()
|
Scripts.incrementCurrentDay()
|
||||||
|
weekDayText.text = Scripts.getCurrentDay().dayName
|
||||||
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
|
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
|
||||||
//mainListView.currentIndex = mainListView.currentIndex + 1
|
//mainListView.currentIndex = mainListView.currentIndex + 1
|
||||||
}
|
}
|
||||||
|
@ -148,6 +164,7 @@ import "schedulerscripts.js" as Scripts
|
||||||
id: dayListViewComponent
|
id: dayListViewComponent
|
||||||
ListView {
|
ListView {
|
||||||
id: dayListView
|
id: dayListView
|
||||||
|
property string dayName: ""
|
||||||
//anchors.top: mainListView.bottom
|
//anchors.top: mainListView.bottom
|
||||||
//anchors.left: parent.left
|
//anchors.left: parent.left
|
||||||
width: constDeviceRowWidth
|
width: constDeviceRowWidth
|
||||||
|
@ -220,7 +237,7 @@ import "schedulerscripts.js" as Scripts
|
||||||
//onEntered: parent.border.color = onHoverColor
|
//onEntered: parent.border.color = onHoverColor
|
||||||
//onExited: parent.border.color = borderColor
|
//onExited: parent.border.color = borderColor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
//print("Mainrow: " + mainRow.parent.children[0].height);
|
||||||
var component = Qt.createComponent("ActionPoint.qml")
|
var component = Qt.createComponent("ActionPoint.qml")
|
||||||
var dynamicPoint = component.createObject(deviceRow)
|
var dynamicPoint = component.createObject(deviceRow)
|
||||||
//dynamicPoint.x = mouseX - dynamicPoint.width/2 //xposition
|
//dynamicPoint.x = mouseX - dynamicPoint.width/2 //xposition
|
||||||
|
|
|
@ -20,6 +20,21 @@ function getDays(){
|
||||||
return days;
|
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(){
|
function decrementCurrentDay(){
|
||||||
if(currentDayIndex == 0){ //TODO in the future, add new day instead (if 7 days)
|
if(currentDayIndex == 0){ //TODO in the future, add new day instead (if 7 days)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue