diff --git a/telldus-gui/Plugins/SchedulerGUISimple/ActionBar.qml b/telldus-gui/Plugins/SchedulerGUISimple/ActionBar.qml index 71907583..0be54a2e 100644 --- a/telldus-gui/Plugins/SchedulerGUISimple/ActionBar.qml +++ b/telldus-gui/Plugins/SchedulerGUISimple/ActionBar.qml @@ -7,6 +7,7 @@ Rectangle{ property color prevDayColor: "white" //default property double prevDayOpacity: 0 //default property int prevDayWidth: 0 //default + property string firstBar: "false" height: constBarHeight z: 110 @@ -26,7 +27,7 @@ Rectangle{ /*color: barRectangle.prevDayColor //getPreviousDayColor(barRectangle.currentDay, barRectangle.days, hangOnToPoint.deviceId, barRectangle.deviceIndex) opacity: barRectangle.prevDayOpacity - width: barRectangle.prevDayWidth //TODO Scripts.getBarWidth(barRectangle, hangOnToPoint, hangOnToPoint.parent.children); //TEST getNextAndPrevBarWidth before + width: barRectangle.prevDayWidth //TODO Scripts.getBarWidth(barRectangle, hangOnToPoint, hangOnToPoint.parent.children); */ } }, @@ -47,7 +48,7 @@ Rectangle{ anchors.left: hangOnToPoint.horizontalCenter color: hangOnToPoint.actionTypeColor opacity: hangOnToPoint.actionTypeOpacity - width: Scripts.getBarWidth(barRectangle, hangOnToPoint, hangOnToPoint.parent.children) //TEST getNextAndPrevBarWidth before + width: Scripts.getBarWidth(barRectangle, hangOnToPoint, hangOnToPoint.parent.children) } } ] diff --git a/telldus-gui/Plugins/SchedulerGUISimple/ActionPoint.qml b/telldus-gui/Plugins/SchedulerGUISimple/ActionPoint.qml index 01324591..f8eeb287 100644 --- a/telldus-gui/Plugins/SchedulerGUISimple/ActionPoint.qml +++ b/telldus-gui/Plugins/SchedulerGUISimple/ActionPoint.qml @@ -337,11 +337,13 @@ Rectangle{ } function addState(state){ + print("Adding state: " + state); Scripts.addState(state); } function setFirstState(firstState){ + //print("SETTING FIRST STATE"); var activeStates = Scripts.getActiveStates(); if(activeStates == null || activeStates.length == 0){ @@ -366,12 +368,13 @@ Rectangle{ if(!exists){ //no "off", just set state to the first added state + pointRect.state = activeStates[0]; return; } var previousState = Scripts.getPreviousState(pointRect); - if(previousState == "" || previousState == "off"){ + if(previousState == undefined || previousState == "" || previousState == "off"){ //nothing on/dimmed at the moment, use first added state pointRect.state = activeStates[0]; return; diff --git a/telldus-gui/Plugins/SchedulerGUISimple/main.qml b/telldus-gui/Plugins/SchedulerGUISimple/main.qml index 752e5cd9..542b5e46 100644 --- a/telldus-gui/Plugins/SchedulerGUISimple/main.qml +++ b/telldus-gui/Plugins/SchedulerGUISimple/main.qml @@ -182,6 +182,11 @@ import "schedulerscripts.js" as Scripts } ] + onChildrenChanged: { + //TODO REMOVE + print("-------------- CHILDREN CHANGED ----------------"); + } + transitions: [ Transition { from: "hiddenLeft" @@ -245,8 +250,8 @@ import "schedulerscripts.js" as Scripts //onEntered: parent.border.color = onHoverColor //onExited: parent.border.color = borderColor onClicked: { - print("ENDPOINT: " + deviceRow.endPoint); - + //Scripts.debugPrintDeviceIndex(); + Scripts.updateDeviceIndex(); //TODO why is this needed here? (but it is, adding points to empty device will get wrong state otherwise) //print("Mainrow: " + mainRow.parent.children[0].height); var component = Qt.createComponent("ActionPoint.qml") var dynamicPoint = component.createObject(deviceRow) @@ -292,6 +297,7 @@ import "schedulerscripts.js" as Scripts ActionBar{ id: "continuingBar" hangOnToPoint: deviceRow + firstBar: "true" state: "continuing" } @@ -308,6 +314,11 @@ import "schedulerscripts.js" as Scripts function updateContinuingBars(){ Scripts.updateEndsWith(); } + + function getDeviceRow(dayIndex, deviceId){ + print("CALLING getDeviceRow"); + return Scripts.getDeviceRow(dayIndex, deviceId); + } } //} } diff --git a/telldus-gui/Plugins/SchedulerGUISimple/schedulerscripts.js b/telldus-gui/Plugins/SchedulerGUISimple/schedulerscripts.js index d8df81a5..03ec1a2e 100644 --- a/telldus-gui/Plugins/SchedulerGUISimple/schedulerscripts.js +++ b/telldus-gui/Plugins/SchedulerGUISimple/schedulerscripts.js @@ -91,8 +91,8 @@ function hasBarChangingPoints(pointList){ } function getEndsWith(pointList, dayIndex, deviceId){ //previousDayEndsWithPoint){ - print("DAY INDEX: " + dayIndex); - print("DEVICEID: " + deviceId); + //print("DAY INDEX: " + dayIndex); + //print("DEVICEID: " + deviceId); var prevPoint = null; for(var i=0;i prevPoint.x) && pointList[i].state != "bell"){ //TODO when more than "bell", make dynamic prevPoint = pointList[i]; } } + else if(pointList[i].firstBar != undefined && pointList[i].firstBar == "true"){ + firstBarStateIndex = i; + } } if(prevPoint == null){ + //no previous point,see if state continues from previous day + if(firstBarStateIndex != undefined && pointList[firstBarStateIndex].firstBar != undefined){ + //print("ENDPOINT!!"); + + var dayIndex = currentDayIndex - 1; + if(dayIndex == -1){ //too far, begin from end again + dayIndex = days.length - 1; + } + //print("CORRECT DEVICE ID? : " + currentPointRect.deviceRow.deviceId); + var prevDayDevice = currentPointRect.parent.getDeviceRow(dayIndex, currentPointRect.deviceRow.deviceId); + if(prevDayDevice != undefined){ + //print("Setting end point: ** " + prevDayDevice.endPoint); + return prevDayDevice.endPoint; + } + } + return ""; } - return prevPoint.state; } @@ -184,17 +203,27 @@ function updateDeviceIndex(){ //TODO, better way, please... for(var i=0;i