diff --git a/telldus-gui/Plugins/SchedulerGUISimple/ActionPoint.qml b/telldus-gui/Plugins/SchedulerGUISimple/ActionPoint.qml index 25900747..fd440e4e 100644 --- a/telldus-gui/Plugins/SchedulerGUISimple/ActionPoint.qml +++ b/telldus-gui/Plugins/SchedulerGUISimple/ActionPoint.qml @@ -22,6 +22,7 @@ Rectangle{ property variant lastRun: 0; //property int parentPointAbsoluteHour //TEST changed from int, want "undefined" property alias deviceRow: pointRect.parent + property variant selectedDate: (deviceRow == null || deviceRow == undefined) ? new Date() : deviceRow.selectedDate Component.onCompleted: { //TODO useless really, still gets Cannot anchor to a null item-warning... @@ -41,27 +42,10 @@ Rectangle{ z: 100 state: "on" focus: true - //actionTypeColor: getColor() - - //TODO make this work: - /*Keys.onLeftPressed: { - pointRect.x = pointRect.x - 1 - } - Keys.onRightPressed: { - pointRect.x = pointRect.x + 1 - } - - Text { - //focus: true - text: pointRect.activeFocus ? "I HAVE active focus!" : "I do NOT have active focus" - } - */ - //reflect changes on parent/siblings: onAbsoluteHourChanged: { updateChanges(); - //print("ABSOLUTE HOUR CHANGED"); } onAbsoluteMinuteChanged: { @@ -167,14 +151,14 @@ Rectangle{ PropertyChanges { target: triggerImage; source: imageTriggerSunrise; opacity: 1 } PropertyChanges { target: triggerTime; opacity: 0 } PropertyChanges { target: pointRectMouseArea; drag.target: undefined } - PropertyChanges { target: pointRect; x: getSunRiseTime.callWith(pointRect.parent.width, pointRect.width) + minutesToTimelineUnits(pointRect.offset) } //TODO se nedan + PropertyChanges { target: pointRect; x: getSunRiseTime.callWith(pointRect.parent.width, pointRect.width, pointRect.selectedDate) + minutesToTimelineUnits(pointRect.offset) } //TODO se nedan }, State { name: "sunset" PropertyChanges { target: triggerImage; source: imageTriggerSunset; opacity: 1 } PropertyChanges { target: triggerTime; opacity: 0 } PropertyChanges { target: pointRectMouseArea; drag.target: undefined } - PropertyChanges { target: pointRect; x: getSunSetTime.callWith(pointRect.parent.width, pointRect.width) + minutesToTimelineUnits(pointRect.offset) } //TODO räkna om till tidsunits + PropertyChanges { target: pointRect; x: getSunSetTime.callWith(pointRect.parent.width, pointRect.width, pointRect.selectedDate) + minutesToTimelineUnits(pointRect.offset) } //TODO räkna om till tidsunits }, State { name: "absolute"; when: !pointRectMouseArea.drag.active @@ -272,8 +256,8 @@ Rectangle{ //print("Different x"); point = pointRect.parentPoint; } - //print("ABSOLUTE X-value: " + (point.absoluteHour * hourSize + hourSize * (point.absoluteMinute/60) - point.width/2)); - //print("AbsoluteHour: " +point.absoluteHour+ " hourSize: " + hourSize + " AbsoluteMinute: " + point.absoluteMinute + " Width: " + point.width); + print("ABSOLUTE X-value: " + (point.absoluteHour * hourSize + hourSize * (point.absoluteMinute/60) - point.width/2)); + print("AbsoluteHour: " +point.absoluteHour+ " hourSize: " + hourSize + " AbsoluteMinute: " + point.absoluteMinute + " Width: " + point.width); return point.absoluteHour * hourSize + hourSize * (point.absoluteMinute/60) - point.width/2; } diff --git a/telldus-gui/Plugins/SchedulerGUISimple/Dialog.qml b/telldus-gui/Plugins/SchedulerGUISimple/Dialog.qml index f3f5f3fd..7e75f866 100644 --- a/telldus-gui/Plugins/SchedulerGUISimple/Dialog.qml +++ b/telldus-gui/Plugins/SchedulerGUISimple/Dialog.qml @@ -11,12 +11,9 @@ focus: true Keys.onPressed: { - tryme(event, "container"); - var hours = 0; var minutes = 0; - if (event.key == Qt.Key_Left) { - //actionPoint.x = actionPoint.x - 1 + if (event.key == Qt.Key_Left && actionPoint.triggerstate == "absolute") { //step left, 1 min var minutes = parseInt(inputAbsoluteMinuteText.text, 10); var hours = parseInt(inputAbsoluteHourText.text, 10); if(minutes == 0){ @@ -31,8 +28,7 @@ } event.accepted = true; } - else if (event.key == Qt.Key_Right) { - //actionPoint.x = actionPoint.x + 1 + else if (event.key == Qt.Key_Right && actionPoint.triggerstate == "absolute") { //step right, 1 min var minutes = parseInt(inputAbsoluteMinuteText.text, 10); var hours = parseInt(inputAbsoluteHourText.text, 10); if(minutes == 59){ @@ -49,9 +45,7 @@ } else if( event.key == Qt.Key_Delete){ //TODO warning? - print("DELETING"); container.actionPoint.remove(); - } else{ return; @@ -69,7 +63,7 @@ //create default actionPoint, to avoid null values and binding errors var component = Qt.createComponent("ActionPoint.qml") var dynamicPoint = component.createObject(container) - dynamicPoint.opacity = 0 //TODO why not use "visible"? Test that... + dynamicPoint.opacity = 0 dynamicPoint.width = 0 dynamicPoint.height = 0 container.actionPoint = dynamicPoint @@ -88,7 +82,7 @@ container.actionPoint = actionPoint var rootCoordinates = actionPoint.mapToItem(null, actionPoint.x, actionPoint.y); - container.y = rootCoordinates.y + actionPoint.height + 10; + container.y = rootCoordinates.y + actionPoint.height + 10; //TODO poistion in other way, too far down in some cases now container.width = actionPoint.parent.width; container.x = (actionPoint.parent.parent.width - container.width)/2; container.opacity = 1; @@ -104,8 +98,7 @@ smooth: true radius: 5 - //width: 500 //TODO - height: 500 // typelist.height * 2 + 50 + height: 500 opacity: 0 Button{ @@ -118,11 +111,6 @@ onClicked: { container.actionPoint.toggleType(); } - - Keys.onLeftPressed: { - debug("Left pressed"); //TODO make it work - - } } Button{ @@ -559,13 +547,10 @@ width: weekColumn.width Column{ id: "weekColumn" - //anchors.verticalCenter: parent.verticalCenter - //anchors.fill: parent spacing: 2 Repeater{ id: weekRepeater - model: 7 //actionPoint.daysOfWeek - //delegate: weekDayDelegate + model: 7 //7 days, one week... Rectangle{ width: 30 height: 30 @@ -582,13 +567,11 @@ anchors.fill: parent onClicked: { actionPoint.toggleTickedWeekDay(index) - print("Just toggled, now update image: " + actionPoint); tickBox.source = actionPoint.getTickedImageSource(index) } } } Text{ - //anchors.fill: parent anchors.left: tickBox.right anchors.leftMargin: 10 text: Scripts.getOffsetWeekdayName(index) @@ -611,9 +594,7 @@ id: closeButton text: "Close" anchors.top: weekDayPanel.bottom - anchors.horizontalCenter: weekDayPanel.right //horizontalCenter - //y: circleTrigger.y + 30 - //x: parent.x + 30 + anchors.horizontalCenter: weekDayPanel.right onClicked: { hide(); } @@ -625,20 +606,19 @@ anchors.topMargin: 20 anchors.left: currentType.right anchors.leftMargin: 10 - width: 100 //TODO relative - height: 100 //TODO relative + width: 100 + height: 100 model: typeSelection delegate: typeSelectionRow highlight: Rectangle { color: "lightsteelblue"; radius: 5 } snapMode: ListView.SnapToItem interactive: false - //TODO can these paths be turned into some kind of constants? Import from common file or something? ListModel{ id: typeSelection ListElement{ name: "on" - imagesource: "on.png" //TODO cannot use javascript properties here... do in some other way, maybe a list with names here? + imagesource: "on.png" } ListElement{ name: "off" @@ -683,17 +663,12 @@ width: 30; height: 30 Image{ anchors.fill: parent - //anchors.left: typeSelectionText.right - //anchors.leftMargin: 10 - //anchors.centerIn: parent source: imagesource MouseArea{ anchors.fill: parent onClicked: { - //pointRect.focus = true container.actionPoint.setType(name) - //typeList.highlight = name } } } @@ -701,10 +676,6 @@ } } - function tryme(event, origin){ - print("KEY: " + event.key + " Från: " + origin); - } - function getMinimumOffset(state){ //TODO this will not work if a value is set to the highest limit, then not reentering scheduler until the sunrise/set has changed so much that the device will be hidden anyway... Not common though var minutes = 0; @@ -735,6 +706,6 @@ return 0 ; } - return 24 * 60 - (parseInt(time[0], 10) * 60 + parseInt(time[1], 10)); + return 24 * 60 - (parseInt(time[0], 10) * 60 + parseInt(time[1], 10)); } } diff --git a/telldus-gui/Plugins/SchedulerGUISimple/__init__.js b/telldus-gui/Plugins/SchedulerGUISimple/__init__.js index 765d735d..3e31376a 100644 --- a/telldus-gui/Plugins/SchedulerGUISimple/__init__.js +++ b/telldus-gui/Plugins/SchedulerGUISimple/__init__.js @@ -8,10 +8,11 @@ __postInit__ = function() { com.telldus.schedulersimplegui = function() { var deviceList; var view; + var restoredJobsTimerKeys; + var sunData; function init() { view = new com.telldus.qml.view({ - addDevice: addDevice, addJobsToSchedule: addJobsToSchedule, getJob: getJob, getMethodFromState: getMethodFromState, @@ -21,7 +22,8 @@ com.telldus.schedulersimplegui = function() { getSunData: getSunData, getTypeFromTriggerstate: getTypeFromTriggerstate, getTriggerstateFromType: getTriggerstateFromType, - restoreJobs: restoreJobs + restoreJobs: restoreJobs, + updateSunData: updateSunData }); //devices: @@ -37,9 +39,8 @@ com.telldus.schedulersimplegui = function() { //Listen for device-change com.telldus.core.deviceChange.connect(deviceChange); - //var storedPoints = loadJobs(); - //view.setProperty('storedPoints', storedPoints); - + updateSunData(new Date()); //default + //set images: view.setProperty("imageTriggerSunrise", "sunrise.png"); view.setProperty("imageTriggerSunset", "sunset.png"); @@ -55,16 +56,14 @@ com.telldus.schedulersimplegui = function() { view.setProperty("constDeviceRowHeight", 50); view.setProperty("constDeviceRowWidth", 600); view.setProperty("constPointWidth", 30); + view.setProperty("mainHeight", 700); //TODO get this from somewhere + view.setProperty("mainWidth", 800); //TODO get this from somewhere view.load("main.qml"); application.addWidget("scheduler.simple", "icon.png", view); } - function addDevice() { - deviceList.push({name:'Stallet istallet'}); - } - function deviceChange( deviceId, eventType ) { if (eventType == com.telldus.core.TELLSTICK_DEVICE_ADDED) { var item = com.telldus.core.deviceList.getDevice(deviceId); @@ -81,6 +80,13 @@ com.telldus.schedulersimplegui = function() { com.telldus.scheduler.removeJob(deviceTimerKeys[i]); } } + if(restoredJobsTimerKeys != undefined && restoredJobsTimerKeys[deviceId] != undefined){ + for(var i=0;i 0){ + deviceTimerKeys[devicekey] = com.telldus.scheduler.addJobs(jobs); //have to do this per device, so that the timerkeys are stored for each device + } } - return com.telldus.scheduler.addJobs(jobs) + return deviceTimerKeys; } function restoreJob(storedJob, updateLastRunInGUI){ @@ -141,7 +149,6 @@ com.telldus.schedulersimplegui = function() { function getJob(pointArray, updateLastRunInGUI){ //deviceId, pointName, startdate, lastrun, pointMethod, pointDimValue, pointTime, pointType, pointFuzzinessBefore, pointFuzzinessAfter, pointOffset, pointDays //updateLastRunInGUI: deviceId, day of week, id var execFunc = function(job){ print("Custom execute function running"); print("Job: " + job.v.name); var lastRun = new Date().getTime(); updateLastRun(job, lastRun); updateLastRunInGUI(job.v.device, job.v.events[job.v.id + "_0"].d.value, job.v.id, lastRun); return job.executeDefault();}; - print("POINTARRAY3: " + pointArray[3]); var job = new com.telldus.scheduler.JobRecurringWeek({id: pointArray[13], executeFunc: execFunc, name: pointArray[1], type: com.telldus.scheduler.JOBTYPE_RECURRING_WEEK, startdate: pointArray[2], lastRun: pointArray[3], device: pointArray[0], method: pointArray[4], value: pointArray[5], absoluteTime: pointArray[12]}); var event = {}; var pointFuzzinessBefore = (pointArray[8]*60); @@ -160,20 +167,13 @@ com.telldus.schedulersimplegui = function() { return job; } + //Update last run for this job from storage, then store it again function updateLastRun(job, lastRun){ - //TODO uppdatera både storage och värdet i pointen... var settings = new com.telldus.settings(); var storedjobs = settings.value("jobs", ""); - //settings.setValue("test", "TESTAR"); - print("UPDATING LAST RUN 3 " + storedjobs); for(var devicekey in storedjobs){ - print("Key: " + devicekey); if(devicekey == job.v.device){ - print("En bra bit"); - for(var i=0;i" - } - MouseArea{ - anchors.fill: parent - onClicked: { - //step to next weekday - dialog.hide() - Scripts.updateEndsWith() //mainListView) - Scripts.incrementCurrentDay() - weekDayText.text = Scripts.getCurrentDayName() - //mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center) - //mainListView.currentIndex = mainListView.currentIndex + 1 - } + arrowText: "->" + onClicked: { + Scripts.incrementCurrentDay(); } } } @@ -108,9 +73,6 @@ import "schedulerscripts.js" as Scripts Column{ id: mainHeader - //anchors.left: parent.left - //anchors.top: parent.top - //anchors.topMargin: dayListHeaderHeight width: main.width - constDeviceRowWidth spacing: 0 @@ -148,6 +110,7 @@ import "schedulerscripts.js" as Scripts //TODO implement setProperty if this is to be stored... or do something else... modelData.setProperty(index, isEnabled, modelData.isEnabled == "enabled" ? "disabled" : "enabled"); //TODO also implement disabled/enabled for all (deviceEnabled=false on all) and per point (set isPoint=false and opacity=0.4)... //take that value into consideration when saving and sending jobs for execution + //else, remove this button deviceNameRect.isEnabled = deviceNameRect.isEnabled == "enabled" ? "disabled" : "enabled" Scripts.deviceEnabled(modelData.id, deviceNameRect.isEnabled); } @@ -159,10 +122,8 @@ import "schedulerscripts.js" as Scripts Rectangle{ id: mainContent - height: 700 //TODO - width: constDeviceRowWidth //TODO - //anchors.top: parent.top - //anchors.left: mainListViewHeaderColumn.right + height: mainHeight + width: constDeviceRowWidth clip: true z: 50 } @@ -175,200 +136,173 @@ import "schedulerscripts.js" as Scripts id: dayListView property date daydate width: constDeviceRowWidth - height: 700 //TODO + height: mainHeight - //anchors.fill: parent model: deviceModel delegate: listRow - //focus: true - //footer: addButtonComponent //TODO move... header: timeline snapMode: ListView.SnapToItem interactive: false //no scroll between devices at the moment - //anchors.top: parent.top; - //state: "hidden" //default states: [ State { - name: "hiddenRight"; //when: parent.left != null + name: "hiddenRight"; AnchorChanges { target: dayListView; anchors.left: parent.right; anchors.right: undefined } - //PropertyChanges { target: dayListView; opacity: 0 } }, State { - name: "hiddenLeft"; //when: parent.left != null + name: "hiddenLeft"; AnchorChanges { target: dayListView; anchors.left: undefined; anchors.right: parent.left } - //PropertyChanges { target: dayListView; opacity: 0 } }, State { - name: "visible"; //when: parent.left != null + name: "visible"; PropertyChanges { target: dayListView; opacity: 1 } AnchorChanges { target: dayListView; anchors.right: undefined; anchors.left: parent.left } } ] - onChildrenChanged: { - //TODO REMOVE - print("-------------- CHILDREN CHANGED ----------------"); - } - transitions: [ Transition { from: "hiddenLeft" to: "visible" - AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } //PropertyAnimation { properties: "x"; duration: 1000; easing.type: Easing.InOutQuad } + AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }, Transition { from: "visible" to: "hiddenRight" - AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } //PropertyAnimation { properties: "x"; duration: 1000; easing.type: Easing.InOutQuad } + AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }, Transition { from: "visible" to: "hiddenLeft" - AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } //PropertyAnimation { properties: "x"; duration: 1000; easing.type: Easing.InOutQuad } + AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }, Transition { from: "hiddenRight" to: "visible" - AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } //PropertyAnimation { properties: "x"; duration: 1000; easing.type: Easing.InOutQuad } + AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } } ] - - //TODO transition between state, animation - } } Component{ id: listRow - /* - Row{ - id: mainRow + Rectangle { id: "deviceRow"; border.color: "blue"; width: constDeviceRowWidth; height: constDeviceRowHeight; + clip: true + property variant endPoint: undefined + property int deviceId: modelData.id; + property alias continuingBar: continuingBar + property variant selectedDate: main.selectedDate + state: "enabled" - width: constDeviceRowWidth //parent.width; //TODO relative - height: constDeviceRowHeight - /* - Rectangle { - border.color: "red"; width: 100; height:parent.height; - Text{ - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - - text: modelData.name + states: [ + State{ + name: "enabled" + PropertyChanges{ target: deviceRow; opacity: 1 } + }, + State{ + name: "disabled" + PropertyChanges{ target: deviceRow; opacity: 0.4 } } - } - */ - Rectangle { id: "deviceRow"; border.color: "blue"; width: constDeviceRowWidth; height: constDeviceRowHeight; - clip: true - property variant endPoint: undefined //: Scripts.getEndsWith(deviceRow.children, index, modelData.id); - property int deviceId: modelData.id; - property alias continuingBar: continuingBar - state: "enabled" - - states: [ - State{ - name: "enabled" - PropertyChanges{ target: deviceRow; opacity: 1 } - }, - State{ - name: "disabled" - PropertyChanges{ target: deviceRow; opacity: 0.4 } - } - ] - - MouseArea { - id: deviceMouseArea - anchors.fill: parent - //hoverEnabled: true - - //TODO ändra muspekaren kanske? - //onEntered: parent.border.color = onHoverColor - //onExited: parent.border.color = borderColor - onClicked: { - //Scripts.debugPrintDeviceIndex(); - Scripts.setChanged(deviceId, true); - 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) - //dynamicPoint.x = mouseX - dynamicPoint.width/2 //xposition - var hourMinute = dynamicPoint.getTimeFromPosition(mouse.x) - dynamicPoint.absoluteHour = hourMinute[0] - dynamicPoint.absoluteMinute = hourMinute[1] - dynamicPoint.x = dynamicPoint.getAbsoluteXValue(); - dynamicPoint.border.color = "blue" - - //TODO different states depending on the device - dynamicPoint.addActiveState("on"); - dynamicPoint.addActiveState("off"); - dynamicPoint.addActiveState("dim"); - dynamicPoint.addActiveState("bell"); - //dynamicPoint.setFirstState("dim"); //when type is a stored value - dynamicPoint.setFirstState(); - dynamicPoint.pointId = new Date().getTime(); //just needed for storage update - - deviceRow.updateContinuingBars(); - dialog.show(dynamicPoint) - } - } - - ActionBar{ - id: "continuingBar" - hangOnToPoint: deviceRow - firstBar: "true" - - state: "continuing" - } - - ListView.onAdd: SequentialAnimation { - PropertyAction { target: mainRow; property: "height"; value: 0 } - NumberAnimation { target: mainRow; property: "height"; to: 50; duration: 250; easing.type: Easing.InOutQuad } - } - - function hasPoints(){ - return Scripts.hasBarChangingPoints(deviceRow.children); - } - - function updateContinuingBars(){ - Scripts.updateEndsWith(); - } - - function getDeviceRow(dayIndex, deviceId){ - print("CALLING getDeviceRow"); - return Scripts.getDeviceRow(dayIndex, deviceId); - } - - function createChildPoint(index, pointRect, deviceId){ - print("CREATING child point"); - return Scripts.createChildPoint(index, pointRect, deviceId); - } - - function setChanged(){ + ] + + MouseArea { + id: deviceMouseArea + anchors.fill: parent + onClicked: { Scripts.setChanged(deviceId, true); - } - - function isLoading(){ - return Scripts.isLoading(); + //TODO really needed? Scripts.updateDeviceIndex(); //needed here, adding points to empty device will get wrong state otherwise + var component = Qt.createComponent("ActionPoint.qml") + var dynamicPoint = component.createObject(deviceRow) + var hourMinute = dynamicPoint.getTimeFromPosition(mouse.x) + dynamicPoint.absoluteHour = hourMinute[0] + dynamicPoint.absoluteMinute = hourMinute[1] + dynamicPoint.x = dynamicPoint.getAbsoluteXValue(); + dynamicPoint.border.color = "blue" + + //TODO different states depending on the device + dynamicPoint.addActiveState("on"); + dynamicPoint.addActiveState("off"); + dynamicPoint.addActiveState("dim"); + dynamicPoint.addActiveState("bell"); + dynamicPoint.setFirstState(); + dynamicPoint.pointId = new Date().getTime(); //just needed for storage update + + deviceRow.updateContinuingBars(); + dialog.show(dynamicPoint) } } - //} + + ActionBar{ + id: "continuingBar" + hangOnToPoint: deviceRow + firstBar: "true" + + state: "continuing" + } + + ListView.onAdd: SequentialAnimation { + PropertyAction { target: mainRow; property: "height"; value: 0 } + NumberAnimation { target: mainRow; property: "height"; to: 50; duration: 250; easing.type: Easing.InOutQuad } + } + + //device functions: + function createChildPoint(index, pointRect, deviceId){ + return Scripts.createChildPoint(index, pointRect, deviceId); + } + + function getDeviceRow(dayIndex, deviceId){ + return Scripts.getDeviceRow(dayIndex, deviceId); + } + + function hasPoints(){ + return Scripts.hasBarChangingPoints(deviceRow.children); + } + + function isLoading(){ + return Scripts.isLoading(); + } + + function setChanged(){ + Scripts.setChanged(deviceId, true); + } + + function updateContinuingBars(){ + Scripts.updateEndsWith(); + } + } } Component{ id: timeline Item{ - width: constDeviceRowWidth //TODO parent.width + id: timelinerange + width: constDeviceRowWidth height: dayListHeaderHeight + property int morningDarkWidth: MainScripts.getMorningDarkWidth() + property double morningDarkStart: MainScripts.getMorningDarkStart() + property int eveningDarkWidth: MainScripts.getEveningDarkWidth() + property double eveningDarkStart: MainScripts.getEveningDarkStart() + property variant currentDate: main.selectedDate; + + onCurrentDateChanged: { + //update values + timelinerange.morningDarkWidth = MainScripts.getMorningDarkWidth() + timelinerange.morningDarkStart = MainScripts.getMorningDarkStart() + timelinerange.eveningDarkWidth = MainScripts.getEveningDarkWidth() + timelinerange.eveningDarkStart = MainScripts.getEveningDarkStart() + } + Rectangle{ id: morningDark color: "black" height: parent.height border.width: 0 - width: getMorningDarkWidth() + width: timelinerange.morningDarkWidth opacity: 0.1 - x: getMorningDarkStart() + x: timelinerange.morningDarkStart } Rectangle{ @@ -376,9 +310,9 @@ import "schedulerscripts.js" as Scripts color: "black" height: parent.height border.width: 0 - width: getEveningDarkWidth() + width: timelinerange.eveningDarkWidth opacity: 0.1 - x: getEveningDarkStart() + x: timelinerange.eveningDarkStart } Rectangle{ @@ -386,13 +320,12 @@ import "schedulerscripts.js" as Scripts border.color: "red" Row{ - //x: 100 anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenterOffset: parent.width/24 - width: parent.width //listRow.width + width: parent.width height: parent.height - spacing: (parent.width-24)/24 //before: -124 + spacing: (parent.width-24)/24 Repeater{ model:24 Rectangle{ @@ -418,116 +351,20 @@ import "schedulerscripts.js" as Scripts } } - /* Not in use, adding all devices always instead - Component{ - id: addButtonComponent - Row { - id: addButton - - Rectangle { - height: 20 - width: 100 - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: 30 - - property color buttonColor: "lightgrey" - - Text{ - text: "Add an item" - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - anchors.margins: 2 - - } - MouseArea { - id: buttonMouseArea - anchors.fill: parent - onClicked: { - addDevice.call() - } - } - - color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor - - } - } - } - */ - Dialog { id: dialog z: 150 } - //TODO move functions, and test odd cases: - function getEveningDarkStart(){ - if(!willSunSet){ - return 0; - } - if(Scripts.isMidnightDark()){ - return sunToTimeUnits(main.sunData[1]); // + 100; - } - else{ - return 0; - } + function mainGetMethodFromState(state){ + return getMethodFromState.callWith(state); } - function getMorningDarkStart(){ - //TODO the day of the year when the sun "begins" not to set, will it work then? - if(!willSunSet){ - return 0; - } - if(Scripts.isMidnightDark()){ - return 0; //100; //TODO constants - } - else{ - return sunToTimeUnits(main.sunData[1]); // + 100; //TODO constants - } + function mainGetTypeFromTriggerstate(triggerstate){ + return getTypeFromTriggerstate.callWith(triggerstate); } - - function getEveningDarkWidth(){ - if(!willSunSet){ - return 0; - } - if(Scripts.isMidnightDark()){ - return constDeviceRowWidth - sunToTimeUnits(main.sunData[1]); //(main.width - 100) - sunToTimeUnits(main.sunData[1]); //TODO constant or something - } - else{ - return 0; - } - } - - function getMorningDarkWidth(){ - if(!willSunSet){ - return 0; - } - if(Scripts.isMidnightDark()){ - return sunToTimeUnits(main.sunData[0]); - } - else{ - return sunToTimeUnits(main.sunData[1]) - sunToTimeUnits(main.sunData[0]); - } - } - - function willSunSet(){ - if(main.sunData == undefined){ - main.sunData = getSunData.call(); - } - - return !(main.sunData[2] && main.sunData[2] != "") - } - - function sunToTimeUnits(suntime){ - suntime = suntime.split(':'); - var hourSize = constDeviceRowWidth/24; //(main.width - 100)/24; //TODO constant or something? - return hourSize * suntime[0] + hourSize * suntime[1]/60; - } - function saveAll(){ - print("Save all and reset jobs"); - //var jobs = new Array(); - //var points = new Array(); var days = Scripts.getDays(); if(dialog.dialogOpacity == 1){ Scripts.setChanged(dialog.actionPoint.deviceRow.deviceId, true); //set the devicerow that the currently visible dialog is connected to as dirty @@ -537,20 +374,17 @@ import "schedulerscripts.js" as Scripts var deviceId = deviceModel.get(i).id; if(!Scripts.hasChanged(deviceId)){ //no point has been updated, removed or added, ignore this device - print("Not updated: " + deviceId); continue; } Scripts.setChanged(deviceId, false); //reset hasChanged-status - print("Updated: " + deviceId); if(Scripts.deviceIsEnabled(deviceId)){ //if device is disabled, don't add any points to schedule (but remove current) - print("Device is enabled: " + deviceId); for(var j=0;j