Started with continuing-bar-from-previous-page-logic
This commit is contained in:
parent
8a6f9b8eb9
commit
65b77fc1d2
5 changed files with 304 additions and 70 deletions
37
telldus-gui/Plugins/SchedulerGUISimple/ActionBar.qml
Normal file
37
telldus-gui/Plugins/SchedulerGUISimple/ActionBar.qml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import Qt 4.7
|
||||||
|
import "schedulerscripts.js" as Scripts
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id: barRectangle
|
||||||
|
property variant hangOnToPoint
|
||||||
|
property variant days
|
||||||
|
property int currentDay
|
||||||
|
|
||||||
|
height: constBarHeight
|
||||||
|
z: 110
|
||||||
|
|
||||||
|
states: [
|
||||||
|
State{
|
||||||
|
name: "continuing"
|
||||||
|
PropertyChanges {
|
||||||
|
target: barRectangle
|
||||||
|
anchors.verticalCenter: hangOnToPoint.verticalCenter
|
||||||
|
anchors.left: hangOnToPoint.left
|
||||||
|
color: Scripts.getPreviousDayColor(currentDay, days) //not really point, but deviceRow TODO
|
||||||
|
opacity: 100 //TODO
|
||||||
|
width: 50 //TODO Scripts.getBarWidth(barRectangle, hangOnToPoint, hangOnToPoint.parent.children); //TEST getNextAndPrevBarWidth before
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "pointLoaded" //; when: hangOnToPoint != undefined && hangOnToPoint.isLoaded != undefined && hangOnToPoint.parent != null && hangOnToPoint.parent != undefined && hangOnToPoint.verticalCenter != undefined //TODO might aswell use hangOnToPoint != undefined, still get null item warning, used hangOnToPoint.isLoaded too before, remove this?
|
||||||
|
PropertyChanges {
|
||||||
|
target: barRectangle
|
||||||
|
anchors.verticalCenter: hangOnToPoint.verticalCenter
|
||||||
|
anchors.left: hangOnToPoint.horizontalCenter
|
||||||
|
color: hangOnToPoint.actionTypeColor
|
||||||
|
opacity: hangOnToPoint.actionTypeOpacity
|
||||||
|
width: Scripts.getBarWidth(barRectangle, hangOnToPoint, hangOnToPoint.parent.children) //TEST getNextAndPrevBarWidth before
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -23,8 +23,10 @@ Rectangle{
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
//TODO useless really, still gets Cannot anchor to a null item-warning...
|
//TODO useless really, still gets Cannot anchor to a null item-warning...
|
||||||
isLoaded = "true"
|
isLoaded = "true"
|
||||||
|
var actionBar = Qt.createComponent("ActionBar.qml")
|
||||||
var dynamicBar = actionBar.createObject(pointRect)
|
var dynamicBar = actionBar.createObject(pointRect)
|
||||||
dynamicBar.hangOnToPoint = pointRect
|
dynamicBar.hangOnToPoint = pointRect
|
||||||
|
dynamicBar.state = "pointLoaded"
|
||||||
//pointRect.hangOnToBar = dynamicBar
|
//pointRect.hangOnToBar = dynamicBar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +199,7 @@ Rectangle{
|
||||||
PropertyChanges { target: pointRect; actionTypeColor: getLastPointColor() }
|
PropertyChanges { target: pointRect; actionTypeColor: getLastPointColor() }
|
||||||
PropertyChanges { target: pointRect; actionTypeImage: imageActionBell }
|
PropertyChanges { target: pointRect; actionTypeImage: imageActionBell }
|
||||||
},
|
},
|
||||||
State{
|
State{ //TODO test
|
||||||
name: "test"; when: pointRect.parentPoint != undefined
|
name: "test"; when: pointRect.parentPoint != undefined
|
||||||
PropertyChanges{ target: pointRect; parentPointAbsoluteHour: pointRect.parentPoint.absoluteHour }
|
PropertyChanges{ target: pointRect; parentPointAbsoluteHour: pointRect.parentPoint.absoluteHour }
|
||||||
}
|
}
|
||||||
|
@ -218,30 +220,6 @@ Rectangle{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component{
|
|
||||||
id: actionBar
|
|
||||||
Rectangle{
|
|
||||||
id: barRectangle
|
|
||||||
property variant hangOnToPoint
|
|
||||||
|
|
||||||
height: constBarHeight
|
|
||||||
z: 110
|
|
||||||
|
|
||||||
states: State {
|
|
||||||
name: "pointLoaded"; when: pointRect.parent != null && pointRect.isLoaded != undefined && pointRect.verticalCenter != undefined //TODO might aswell use hangOnToPoint != undefined, still get null item warning
|
|
||||||
PropertyChanges {
|
|
||||||
target: barRectangle
|
|
||||||
anchors.verticalCenter: pointRect.verticalCenter
|
|
||||||
anchors.left: pointRect.horizontalCenter
|
|
||||||
color: pointRect.actionTypeColor
|
|
||||||
opacity: pointRect.actionTypeOpacity
|
|
||||||
width: Scripts.getNextAndPrevBarWidth(actionBar, pointRect, pointRect.parent.children);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAbsoluteXValue(){
|
function getAbsoluteXValue(){
|
||||||
if(pointRect.parent == null){
|
if(pointRect.parent == null){
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -377,7 +355,7 @@ Rectangle{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var previousState = Scripts.getPreviousState(pointRect, pointRect.parent.children);
|
var previousState = Scripts.getPreviousState(pointRect);
|
||||||
if(previousState == "" || previousState == "off"){
|
if(previousState == "" || previousState == "off"){
|
||||||
//nothing on/dimmed at the moment, use first added state
|
//nothing on/dimmed at the moment, use first added state
|
||||||
pointRect.state = activeStates[0];
|
pointRect.state = activeStates[0];
|
||||||
|
|
|
@ -6,6 +6,7 @@ SET( Plugin_NAME "schedulerguisimple" )
|
||||||
|
|
||||||
SET( Plugin_PATH "com.telldus.schedulerguisimple" )
|
SET( Plugin_PATH "com.telldus.schedulerguisimple" )
|
||||||
SET( Plugin_EXTRA
|
SET( Plugin_EXTRA
|
||||||
|
ActionBar.qml
|
||||||
ActionPoint.qml
|
ActionPoint.qml
|
||||||
Button.qml
|
Button.qml
|
||||||
Dialog.qml
|
Dialog.qml
|
||||||
|
|
|
@ -11,6 +11,7 @@ import "schedulerscripts.js" as Scripts
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
var dynamicDay = 0;
|
var dynamicDay = 0;
|
||||||
|
var previousDayEndsWithPoint = null; //previous day, nothing to begin with
|
||||||
var startday = new Date();
|
var startday = new Date();
|
||||||
startday.setDate(startday.getDate() - 6);
|
startday.setDate(startday.getDate() - 6);
|
||||||
for(var i=0;i<7;i++){ //One week, TODO dynamic
|
for(var i=0;i<7;i++){ //One week, TODO dynamic
|
||||||
|
@ -19,12 +20,15 @@ import "schedulerscripts.js" as Scripts
|
||||||
var currentDay = new Date(startday);
|
var currentDay = new Date(startday);
|
||||||
currentDay.setDate(startday.getDate() + i);
|
currentDay.setDate(startday.getDate() + i);
|
||||||
dynamicDay.daydate = currentDay;
|
dynamicDay.daydate = currentDay;
|
||||||
Scripts.addDay(dynamicDay)
|
//TODO previousDayEndsWith =
|
||||||
|
Scripts.addDay(dynamicDay);
|
||||||
|
Scripts.updateDeviceIndex(); //TODO, don't run in every iteration
|
||||||
}
|
}
|
||||||
dynamicDay.state = "visible" //set last one as visible
|
dynamicDay.state = "visible" //set last one as visible
|
||||||
weekDayText.text = Scripts.getCurrentDayName()
|
weekDayText.text = Scripts.getCurrentDayName()
|
||||||
Scripts.updateDeviceIndex();
|
//Scripts.updateDeviceIndex();
|
||||||
Scripts.initiatePointsInGUI();
|
Scripts.initiatePointsInGUI();
|
||||||
|
Scripts.updateEndsWith();
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
|
@ -47,7 +51,7 @@ import "schedulerscripts.js" as Scripts
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
//step to prev weekday
|
//step to prev weekday
|
||||||
//Scripts.updateEndsWith()
|
Scripts.updateEndsWith()
|
||||||
Scripts.decrementCurrentDay()
|
Scripts.decrementCurrentDay()
|
||||||
weekDayText.text = Scripts.getCurrentDayName()
|
weekDayText.text = Scripts.getCurrentDayName()
|
||||||
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
|
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
|
||||||
|
@ -80,7 +84,7 @@ import "schedulerscripts.js" as Scripts
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
//step to next weekday
|
//step to next weekday
|
||||||
//Scripts.updateEndsWith(mainListView)
|
Scripts.updateEndsWith() //mainListView)
|
||||||
Scripts.incrementCurrentDay()
|
Scripts.incrementCurrentDay()
|
||||||
weekDayText.text = Scripts.getCurrentDayName()
|
weekDayText.text = Scripts.getCurrentDayName()
|
||||||
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
|
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
|
||||||
|
@ -144,6 +148,9 @@ import "schedulerscripts.js" as Scripts
|
||||||
ListView {
|
ListView {
|
||||||
id: dayListView
|
id: dayListView
|
||||||
property date daydate
|
property date daydate
|
||||||
|
//property alias devices2: dayListView.children
|
||||||
|
//property alias devices: dayListView.devices2[0]
|
||||||
|
//property string endsWith
|
||||||
//anchors.top: mainListView.bottom
|
//anchors.top: mainListView.bottom
|
||||||
//anchors.left: parent.left
|
//anchors.left: parent.left
|
||||||
width: constDeviceRowWidth
|
width: constDeviceRowWidth
|
||||||
|
@ -200,6 +207,7 @@ import "schedulerscripts.js" as Scripts
|
||||||
AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } //PropertyAnimation { properties: "x"; duration: 1000; easing.type: Easing.InOutQuad }
|
AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } //PropertyAnimation { properties: "x"; duration: 1000; easing.type: Easing.InOutQuad }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
//TODO transition between state, animation
|
//TODO transition between state, animation
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -208,6 +216,7 @@ import "schedulerscripts.js" as Scripts
|
||||||
Component{
|
Component{
|
||||||
id: listRow
|
id: listRow
|
||||||
|
|
||||||
|
/*
|
||||||
Row{
|
Row{
|
||||||
id: mainRow
|
id: mainRow
|
||||||
|
|
||||||
|
@ -224,8 +233,11 @@ import "schedulerscripts.js" as Scripts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
Rectangle { id: "deviceRow"; border.color: "blue"; width: parent.width; height: parent.height;
|
Rectangle { id: "deviceRow"; border.color: "blue"; width: constDeviceRowWidth; height: constDeviceRowHeight;
|
||||||
clip: true
|
clip: true
|
||||||
|
property variant endPoint: undefined //: Scripts.getEndsWith(deviceRow.children, index, modelData.id);
|
||||||
|
property int deviceId: modelData.id;
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: deviceMouseArea
|
id: deviceMouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -235,6 +247,8 @@ 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("ENDPOINT: " + deviceRow.endPoint);
|
||||||
|
/*
|
||||||
//print("Mainrow: " + mainRow.parent.children[0].height);
|
//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)
|
||||||
|
@ -272,17 +286,38 @@ import "schedulerscripts.js" as Scripts
|
||||||
*/
|
*/
|
||||||
//SLUT TEST
|
//SLUT TEST
|
||||||
|
|
||||||
dialog.show(dynamicPoint)
|
//dialog.show(dynamicPoint)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionBar{
|
||||||
|
id: "continuingBar"
|
||||||
|
hangOnToPoint: deviceRow
|
||||||
|
days: Scripts.getDays()
|
||||||
|
currentDay: Scripts.currentDayIndex
|
||||||
|
|
||||||
|
state: "continuing"
|
||||||
|
}
|
||||||
|
|
||||||
|
Item{
|
||||||
|
//TODO eller ska detta VARA början-rektanglen?
|
||||||
|
id: previousDay
|
||||||
|
states: State{
|
||||||
|
name: "isFirst"; when: daydate > getPreviousDayDate()
|
||||||
|
PropertyChanges{ target: dayListView; endsWith: "NÅGOT" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.hasPoints(deviceRow.children);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
ListView.onAdd: SequentialAnimation {
|
|
||||||
PropertyAction { target: mainRow; property: "height"; value: 0 }
|
|
||||||
NumberAnimation { target: mainRow; property: "height"; to: 50; duration: 250; easing.type: Easing.InOutQuad }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component{
|
Component{
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
//TODO pragma instead? Which is best in this case?
|
//TODO pragma library instead? Which is best in this case? "pad" can be moved there
|
||||||
|
|
||||||
var deviceIndex = [];
|
var deviceIndex = [];
|
||||||
|
|
||||||
|
//TODO active states - move to actionPoint-only-js file
|
||||||
var activeStates = new Array();
|
var activeStates = new Array();
|
||||||
|
|
||||||
function addState(state){
|
function addState(state){
|
||||||
|
@ -20,20 +22,6 @@ function addDay(day){
|
||||||
days.push(day);
|
days.push(day);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDays(){
|
|
||||||
return days;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCurrentDay(){
|
|
||||||
return days[currentDayIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCurrentDayName(){
|
|
||||||
var day = getCurrentDay().daydate;
|
|
||||||
return weekday_name_array[day.getDay()] + " " + day.getDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function decrementCurrentDay(){
|
function decrementCurrentDay(){
|
||||||
days[currentDayIndex].state = "hiddenRight";
|
days[currentDayIndex].state = "hiddenRight";
|
||||||
var workDate = days[currentDayIndex].daydate;
|
var workDate = days[currentDayIndex].daydate;
|
||||||
|
@ -49,6 +37,19 @@ function decrementCurrentDay(){
|
||||||
days[currentDayIndex].state = "visible";
|
days[currentDayIndex].state = "visible";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCurrentDay(){
|
||||||
|
return days[currentDayIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentDayName(){
|
||||||
|
var day = getCurrentDay().daydate;
|
||||||
|
return weekday_name_array[day.getDay()] + " " + day.getDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDays(){
|
||||||
|
return days;
|
||||||
|
}
|
||||||
|
|
||||||
function incrementCurrentDay(){
|
function incrementCurrentDay(){
|
||||||
days[currentDayIndex].state = "hiddenLeft";
|
days[currentDayIndex].state = "hiddenLeft";
|
||||||
var workDate = days[currentDayIndex].daydate;
|
var workDate = days[currentDayIndex].daydate;
|
||||||
|
@ -79,8 +80,57 @@ function getBarWidth(currentBar, currentPointRect, pointList){
|
||||||
return (nextX - currentPointRect.x);
|
return (nextX - currentPointRect.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPreviousState(currentPointRect, pointList){
|
function hasPoints(pointList){
|
||||||
|
|
||||||
|
for(var i=0;i<pointList.length;i++){
|
||||||
|
if (pointList[i].isPoint != undefined && pointList[i].isPoint == "true") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEndsWith(pointList, dayIndex, deviceId){ //previousDayEndsWithPoint){
|
||||||
|
print("DAY INDEX: " + dayIndex);
|
||||||
|
print("DEVICEID: " + deviceId);
|
||||||
|
var prevPoint = null;
|
||||||
|
for(var i=0;i<pointList.length;i++){
|
||||||
|
if(pointList[i].isPoint != undefined && pointList[i].isPoint == "true"){
|
||||||
|
if((prevPoint == null || pointList[i].x > prevPoint.x) && pointList[i].state != "bell"){ //TODO when more than "bell", make dynamic
|
||||||
|
prevPoint = pointList[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(prevPoint == null){
|
||||||
|
dayIndex = dayIndex - 1;
|
||||||
|
if(dayIndex == -1){ //too far, begin from end again
|
||||||
|
dayIndex = days.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO Avoid loop here!
|
||||||
|
var prevDayDevice = getDeviceRow(dayIndex, deviceId);
|
||||||
|
print("PREVDAYHERE: index: " + dayIndex + " id: " + deviceId + " Daydevice: " + prevDayDevice);
|
||||||
|
//print("Test1: " + prevDayDevice.children.length);
|
||||||
|
//print("Test2: " + prevDayDevice.children[0]);
|
||||||
|
if(prevDayDevice == undefined){ // || prevDayDevice.endPoint == undefined){ //TODO this is due to an error, but in the future use it to avoid loops
|
||||||
|
print("DayDeviceUndefined....................");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
print("RETURNING A PREV POINT");
|
||||||
|
print("Prev day: " + days[dayIndex].daydate.getDate());
|
||||||
|
print("Containing: " + prevDayDevice.endPoint);
|
||||||
|
return prevDayDevice.endPoint; // previousDayEndsWithPoint;
|
||||||
|
}
|
||||||
|
if(prevPoint.state == "off"){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
print("RETURNING A POINT");
|
||||||
|
return prevPoint; //.state, only on or dim
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPreviousState(currentPointRect){
|
||||||
|
var pointList = currentPointRect.parent.children
|
||||||
var prevPoint = null;
|
var prevPoint = null;
|
||||||
for(var i=0;i<pointList.length;i++){
|
for(var i=0;i<pointList.length;i++){
|
||||||
if(pointList[i].isPoint != undefined && pointList[i].isPoint == "true" && pointList[i] != currentPointRect){
|
if(pointList[i].isPoint != undefined && pointList[i].isPoint == "true" && pointList[i] != currentPointRect){
|
||||||
|
@ -97,6 +147,28 @@ function getPreviousState(currentPointRect, pointList){
|
||||||
return prevPoint.state;
|
return prevPoint.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: move this to separate js library (pragma?)
|
||||||
|
function getPreviousDayColor(currentDayIndexLocal, daysLocal){
|
||||||
|
var dayIndex = currentDayIndexLocal - 1;
|
||||||
|
if(dayIndex == -1){ //too far, begin from end again
|
||||||
|
dayIndex = daysLocal.length - 1;
|
||||||
|
}
|
||||||
|
/* TODO have too avoid binding loop...
|
||||||
|
if(days[dayIndex].daydate > days[currentDay]){
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//print("Current day index: " + dayIndex);
|
||||||
|
//print("Days count: " + daysLocal.length);
|
||||||
|
var prevDay = daysLocal[dayIndex]; //TODO Kan ju inte vara per dag! Ska vara per device...
|
||||||
|
if(prevDay == undefined || prevDay.endPoint == undefined){
|
||||||
|
//no previous end point exists
|
||||||
|
return "white";
|
||||||
|
}
|
||||||
|
var prevEndPoint = prevDay.endPoint;
|
||||||
|
return prevEndPoint.actionTypeColor;
|
||||||
|
}
|
||||||
|
|
||||||
function isMidnightDark(){
|
function isMidnightDark(){
|
||||||
if(main.sunData == undefined){
|
if(main.sunData == undefined){
|
||||||
main.sunData = getSunData.call();
|
main.sunData = getSunData.call();
|
||||||
|
@ -121,26 +193,126 @@ function pad(number, length) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNextAndPrevBarWidth(currentBar, currentPointRect, pointList){
|
function updateDeviceIndex(){ //TODO, better way, please...
|
||||||
return getBarWidth(currentBar, currentPointRect, pointList);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateDeviceIndex(){
|
|
||||||
deviceIndex = []; //empty list
|
deviceIndex = []; //empty list
|
||||||
for(var i=0;i<deviceModel.length;i++){
|
var startIndex = 0;
|
||||||
deviceIndex[deviceModel.get(i).id] = i;
|
for(var i=0;i<days[0].children[0].children.length;i++){
|
||||||
|
var deviceListItem = days[0].children[0].children[i];
|
||||||
|
//print("** DEVICELISTITEM: ** " + deviceListItem);
|
||||||
|
if(deviceListItem.deviceId != undefined){
|
||||||
|
startIndex = i;
|
||||||
|
//print("** CORRECT DEVICELISTITEM **");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//for(var listproperty in deviceIndex){
|
for(var i=0;i<deviceModel.length;i++){
|
||||||
//}
|
deviceIndex[deviceModel.get(i).id] = i + startIndex;
|
||||||
|
}
|
||||||
|
//TODO !!!!!! are devices reordered sometimes? Check that!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateEndsWith(){
|
||||||
|
updateDeviceIndex(); //TODO needed?
|
||||||
|
print("UPDATEENDSWITH");
|
||||||
|
for(var device in deviceIndex){
|
||||||
|
//for each device, order doesn't matter
|
||||||
|
var previousEndPoint = undefined;
|
||||||
|
print("DeviceIndex: " + deviceIndex[device]);
|
||||||
|
print("DeviceId: " + device);
|
||||||
|
|
||||||
|
//loop through days, beginning with oldest, in search for the first Point
|
||||||
|
var startIndex = 0;
|
||||||
|
for(var dayIndex=0;dayIndex<days.length;dayIndex++){
|
||||||
|
var deviceRow = days[dayIndex].children[0].children[(parseInt(deviceIndex[device]))]; //+1 TODO property somehow? Or function...
|
||||||
|
print("day: " + days[dayIndex]);
|
||||||
|
print("child zero: " + days[dayIndex].children[0]);
|
||||||
|
print("deviceRow: " + deviceRow);
|
||||||
|
print("index: " + (parseInt(deviceIndex[device])));
|
||||||
|
print("Length: " + days[dayIndex].children[0].children.length);
|
||||||
|
//print("deviceRow, id: " + deviceRow.deviceId);
|
||||||
|
//print("deviceRow: " + deviceRow.children.length);
|
||||||
|
|
||||||
|
/*
|
||||||
|
for (var myKey in days[dayIndex].children[0]) {
|
||||||
|
print(myKey + " == (" + days[dayIndex].children[0][myKey] + ")");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
var TEST = getDeviceRow(dayIndex, device);
|
||||||
|
|
||||||
|
if(deviceRow.hasPoints()){
|
||||||
|
print("HAS POINTS ..........");
|
||||||
|
startIndex = dayIndex;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Second loop, start from first point
|
||||||
|
for(var i=0;i<days.length;i++){
|
||||||
|
var dayIndex = i + startIndex;
|
||||||
|
if(dayIndex > days.length-1){
|
||||||
|
dayIndex = dayIndex - days.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
var deviceRow = days[dayIndex].children[0].children[parseInt(deviceIndex[device])]; //+1 TODO property somehow?
|
||||||
|
if(deviceRow.hasPoints()){
|
||||||
|
deviceRow.endPoint = getEndsWith(deviceRow.children, days[dayIndex].daydate.getDay(), deviceRow.deviceId);
|
||||||
|
previousEndPoint = deviceRow.endPoint;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
deviceRow.endPoint = previousEndPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
for(var i=0;i<days.length;i++){
|
||||||
|
var dayindex = i;
|
||||||
|
/*
|
||||||
|
print(currentDayIndex);
|
||||||
|
dayindex = dayindex + currentDayIndex + 1; //make sure to start on the day one week ago
|
||||||
|
if(dayindex > days.length-1){
|
||||||
|
dayindex = dayindex - days.length;
|
||||||
|
}
|
||||||
|
print("Day: " + dayindex);
|
||||||
|
|
||||||
|
|
||||||
|
var day = days[dayindex];
|
||||||
|
print("Day length: " + day.children[0].children.length);
|
||||||
|
for(var j=1;j<day.children[0].children.length-1;j++){ //TODO property?
|
||||||
|
var device = day.children[0].children[j]; //TODO property?
|
||||||
|
print("id: " + device.deviceId);
|
||||||
|
print("day: " + day.daydate.getDay());
|
||||||
|
print("children length: " + device.children.length);
|
||||||
|
if(device.deviceId == undefined){
|
||||||
|
//TODO which controls? More than these? device.endPoint = null;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//TODO remove check above
|
||||||
|
device.endPoint = getEndsWith(device.children, day.daydate.getDay(), device.deviceId);
|
||||||
|
}
|
||||||
|
print("DeviceEndPoint: " + device.endPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//för varje device på denna dag...
|
||||||
|
//kör getEndsWith och spara undan värdet..
|
||||||
|
//fast... hm... om man är på onsdag, sätter en on, inget annat finns under veckan, och så går du bakåt till tisdag...
|
||||||
|
//då måste det ha slagit igenom hela vägen...
|
||||||
|
//inte för varje device, spara (och nollställ här) en deviceChanged-property
|
||||||
|
}
|
||||||
|
|
||||||
|
//Upstart:
|
||||||
function initiatePointsInGUI(){ //weekPointList){
|
function initiatePointsInGUI(){ //weekPointList){
|
||||||
//för varje point, addPointToGUI, men ju även lägga till schemajobb... alltså i __init__.js... men därifrån kan inte denna anropas...
|
//för varje point, addPointToGUI, men ju även lägga till schemajobb... alltså i __init__.js... men därifrån kan inte denna anropas...
|
||||||
//så det får väl bli varsin iteration då...
|
//så det får väl bli varsin iteration då...
|
||||||
//weekPointList -> från __init__.js
|
//weekPointList -> från __init__.js
|
||||||
var weekPointList = new Array();
|
var weekPointList = new Array();
|
||||||
var dummypoint = []
|
var dummypoint = []
|
||||||
dummypoint["day"] = 3;
|
dummypoint["day"] = 5;
|
||||||
dummypoint["deviceId"] = 1;
|
dummypoint["deviceId"] = 1;
|
||||||
weekPointList.push(dummypoint);
|
weekPointList.push(dummypoint);
|
||||||
for(var i=0;i<weekPointList.length;i++){
|
for(var i=0;i<weekPointList.length;i++){
|
||||||
|
@ -149,17 +321,28 @@ function initiatePointsInGUI(){ //weekPointList){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDeviceRow(dayOfWeek, deviceId){
|
||||||
|
var dayListViewComp = days[dayOfWeek];
|
||||||
|
if(dayListViewComp == undefined){
|
||||||
|
print("DayListViewComp undefined");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
print("Children Length: " + dayListViewComp.children[0].children.length); //TODO export this as property instead?
|
||||||
|
print("Deviceid: " + deviceId);
|
||||||
|
var currentDeviceIndex = deviceIndex[deviceId];
|
||||||
|
print("CurrentDeviceIndex: " + currentDeviceIndex);
|
||||||
|
print("Deviceid (should be the same as before, is it always?): " + dayListViewComp.children[0].children[currentDeviceIndex].deviceId); //TEST was +1
|
||||||
|
var pointParent = dayListViewComp.children[0].children[currentDeviceIndex]; //TEST was +1
|
||||||
|
print("Pointparent: " + pointParent);
|
||||||
|
return pointParent;
|
||||||
|
}
|
||||||
|
|
||||||
function addWeekPointToGUI(point){
|
function addWeekPointToGUI(point){
|
||||||
//lägg till point till GUI
|
//lägg till point till GUI
|
||||||
var deviceId = point.deviceId;
|
var deviceId = point.deviceId;
|
||||||
var dayOfWeek = point.day;
|
var dayOfWeek = point.day;
|
||||||
print("Dayofweek: " + dayOfWeek);
|
print("Dayofweek: " + dayOfWeek);
|
||||||
var dayListViewComp = days[dayOfWeek];
|
var pointParent = getDeviceRow(dayOfWeek, deviceId);
|
||||||
print("Length: " + dayListViewComp.children[0].children.length); //TODO export this as property instead?
|
|
||||||
var currentDeviceIndex = deviceIndex[deviceId];
|
|
||||||
var pointParent = dayListViewComp.children[0].children[currentDeviceIndex + 2];
|
|
||||||
print("Pointparent: " + pointParent);
|
|
||||||
|
|
||||||
|
|
||||||
var component = Qt.createComponent("ActionPoint.qml")
|
var component = Qt.createComponent("ActionPoint.qml")
|
||||||
var dynamicPoint = component.createObject(pointParent)
|
var dynamicPoint = component.createObject(pointParent)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue