Preparing for storage and connection to scheduling, but have to turn pointList into model now
This commit is contained in:
parent
ec7d5db109
commit
ead8016cdd
3 changed files with 163 additions and 34 deletions
|
@ -32,7 +32,7 @@ Rectangle{
|
||||||
border.color: "black"
|
border.color: "black"
|
||||||
opacity: 1 //0.8
|
opacity: 1 //0.8
|
||||||
z: 100
|
z: 100
|
||||||
state: "on"
|
//state: "on"
|
||||||
focus: true
|
focus: true
|
||||||
//actionTypeColor: getColor()
|
//actionTypeColor: getColor()
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ Rectangle{
|
||||||
anchors.left: pointRect.horizontalCenter
|
anchors.left: pointRect.horizontalCenter
|
||||||
color: pointRect.actionTypeColor
|
color: pointRect.actionTypeColor
|
||||||
opacity: pointRect.actionTypeOpacity
|
opacity: pointRect.actionTypeOpacity
|
||||||
width: Scripts.getNextAndPrevBarWidth(actionBar, pointRect, pointRect.parent.children);
|
width: Scripts.getBarWidth(actionBar, pointRect, pointRect.parent.children, weekModel.get(mainListView.currentIndex)); //getNextAndPrevBarWidth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,54 @@ import "schedulerscripts.js" as Scripts
|
||||||
width: parent.width
|
width: parent.width
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
Rectangle{
|
||||||
|
anchors.right: weekDayText.left
|
||||||
|
anchors.verticalCenter: weekDayText.verticalCenter
|
||||||
|
height: 20
|
||||||
|
width: 20
|
||||||
|
border.color: "red"
|
||||||
|
Text{
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "<-"
|
||||||
|
}
|
||||||
|
MouseArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
//step to prev weekday
|
||||||
|
//Scripts.updateEndsWith()
|
||||||
|
mainListView.decrementCurrentIndex()
|
||||||
|
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
|
||||||
|
//mainListView.currentIndex = mainListView.currentIndex - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Text{
|
Text{
|
||||||
|
id: weekDayText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: "TESTAR"
|
text: mainListView.cacheBuffer + " - " + weekModel.get(mainListView.currentIndex).name + " " + weekModel.get(mainListView.currentIndex).endsWith + " " + mainListView.currentIndex //TODO, do nicer... mainListView.currentItem.test.get(0) // test //.name //mainListView.model[mainListView.currentIndex] //currentItem.name
|
||||||
|
//TODO test with http://doc.qt.nokia.com/4.7-snapshot/declarative-ui-components-spinner-content-spinner-qml.html alias instead
|
||||||
|
|
||||||
|
}
|
||||||
|
Rectangle{
|
||||||
|
anchors.left: weekDayText.right
|
||||||
|
anchors.verticalCenter: weekDayText.verticalCenter
|
||||||
|
height: 20
|
||||||
|
width: 20
|
||||||
|
border.color: "red"
|
||||||
|
Text{
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "->"
|
||||||
|
}
|
||||||
|
MouseArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
//step to next weekday
|
||||||
|
//Scripts.updateEndsWith(mainListView)
|
||||||
|
mainListView.incrementCurrentIndex()
|
||||||
|
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
|
||||||
|
//mainListView.currentIndex = mainListView.currentIndex + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,24 +72,54 @@ import "schedulerscripts.js" as Scripts
|
||||||
anchors.topMargin: 10
|
anchors.topMargin: 10
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
height: parent.height //TODO
|
height: parent.height //TODO
|
||||||
width: parent.width
|
width: constDeviceRowWidth
|
||||||
//anchors.left: dayListView.left
|
//header: mainListViewHeader
|
||||||
header: mainListViewHeader
|
model: weekModel
|
||||||
model: 1
|
|
||||||
orientation: ListView.Horizontal
|
orientation: ListView.Horizontal
|
||||||
delegate: listDayRow //Text { text: "TEST - per modell" }
|
//delegate: Rectangle{ width: 600; height: 500; border.color: "black"; Text{text: "koll" + model.name} } //listDayRow
|
||||||
interactive: false //no scroll between days in this way
|
delegate: listDayRow
|
||||||
|
interactive: false //false //TODO //no scroll between days in this way
|
||||||
|
clip: true
|
||||||
|
currentIndex: count-1
|
||||||
|
//cacheBuffer: 100000 //TODO remove
|
||||||
|
|
||||||
|
onCurrentIndexChanged: {
|
||||||
|
|
||||||
|
myScript(currentIndex)
|
||||||
|
}
|
||||||
|
//highlight: Rectangle { color: "yellow" }
|
||||||
|
//currentIndex: root.current
|
||||||
|
//preferredHighlightBegin: 80; preferredHighlightEnd: 220
|
||||||
|
//highlightRangeMode: ListView.ApplyRange
|
||||||
|
|
||||||
|
|
||||||
//TODO transitions:
|
//TODO transitions:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListModel{
|
||||||
|
id: weekModel
|
||||||
|
ListElement{
|
||||||
|
name: "Monday"
|
||||||
|
endsWith: ""
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
name: "Tuesday"
|
||||||
|
endsWith: ""
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
name: "Wednesday"
|
||||||
|
endsWith: ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component{
|
Component{
|
||||||
id: listDayRow
|
id: listDayRow
|
||||||
ListView {
|
ListView {
|
||||||
id: dayListView
|
id: dayListView
|
||||||
|
//property variant test: model
|
||||||
//anchors.top: mainListView.bottom
|
//anchors.top: mainListView.bottom
|
||||||
//anchors.left: parent.left
|
//anchors.left: parent.left
|
||||||
width: parent.width
|
width: constDeviceRowWidth //TODO//parent.width
|
||||||
height: 700 //TODO
|
height: 700 //TODO
|
||||||
|
|
||||||
//anchors.fill: parent
|
//anchors.fill: parent
|
||||||
|
@ -55,33 +130,44 @@ import "schedulerscripts.js" as Scripts
|
||||||
header: timeline
|
header: timeline
|
||||||
snapMode: ListView.SnapToItem
|
snapMode: ListView.SnapToItem
|
||||||
interactive: false //no scroll between devices at the moment
|
interactive: false //no scroll between devices at the moment
|
||||||
|
|
||||||
|
//keyNavigationWraps: true
|
||||||
|
|
||||||
|
/*
|
||||||
|
states: State {
|
||||||
|
name: "currentItem"; when: ListView.isCurrentItem
|
||||||
|
PropertyChanges { target: dayListView; height: myScript(ListView.) } //TODO better way...
|
||||||
|
//ScriptAction { scriptName: "myScript" }
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component{
|
//Component{
|
||||||
id: mainListViewHeader
|
// id: mainListViewHeader
|
||||||
Column{
|
Column{
|
||||||
id: mainListViewHeaderColumn
|
id: mainListViewHeaderColumn
|
||||||
anchors.left: parent.left
|
anchors.right: mainListView.left
|
||||||
anchors.top: parent.top
|
anchors.top: mainListView.top
|
||||||
anchors.topMargin: dayListHeaderHeight
|
anchors.topMargin: dayListHeaderHeight
|
||||||
width: main.width - constDeviceRowWidth
|
|
||||||
|
width: main.width - constDeviceRowWidth
|
||||||
spacing: 0
|
|
||||||
|
spacing: 0
|
||||||
Repeater{
|
|
||||||
model: deviceModel
|
Repeater{
|
||||||
Rectangle{
|
model: deviceModel
|
||||||
width: parent.width
|
Rectangle{
|
||||||
height: constDeviceRowHeight
|
width: parent.width
|
||||||
border.color: "green"
|
height: constDeviceRowHeight
|
||||||
Text{
|
border.color: "green"
|
||||||
anchors.centerIn: parent
|
Text{
|
||||||
text: modelData.name
|
anchors.centerIn: parent
|
||||||
}
|
text: modelData.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component{
|
Component{
|
||||||
|
@ -105,6 +191,7 @@ import "schedulerscripts.js" as Scripts
|
||||||
*/
|
*/
|
||||||
Rectangle { id: "deviceRow"; border.color: "blue"; width: parent.width; height: parent.height;
|
Rectangle { id: "deviceRow"; border.color: "blue"; width: parent.width; height: parent.height;
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: deviceMouseArea
|
id: deviceMouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -299,6 +386,21 @@ import "schedulerscripts.js" as Scripts
|
||||||
var hourSize = constDeviceRowWidth/24; //(main.width - 100)/24; //TODO constant or something?
|
var hourSize = constDeviceRowWidth/24; //(main.width - 100)/24; //TODO constant or something?
|
||||||
return hourSize * suntime[0] + hourSize * suntime[1]/60;
|
return hourSize * suntime[0] + hourSize * suntime[1]/60;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO SPARA POINTLISTAN OCKSÅ! Kanske inte här, utan att man addar points till modellen och inte den fysiska listan?
|
||||||
|
function myScript(index){
|
||||||
|
|
||||||
|
if(index == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
index = index - 1; //prev index
|
||||||
|
var pointList = "TODO" //TODO !!!! förra dagens pointlist...
|
||||||
|
weekModel.setProperty(index, "endsWith", Scripts.getEndsWith(pointList, "on")) //TODO previousDayEndsWith, vad förra dagen endade med...
|
||||||
|
|
||||||
|
//return 700;
|
||||||
|
print(index);
|
||||||
|
print("LYCKATS!!!");
|
||||||
|
}
|
||||||
//opacity vid dimning?
|
//opacity vid dimning?
|
||||||
//linjens färg etc (state) beror ju på närmaste punkt föres sort... Punkten kan finnas osynlig (tidigare dag) också...
|
//linjens färg etc (state) beror ju på närmaste punkt föres sort... Punkten kan finnas osynlig (tidigare dag) också...
|
||||||
//kan man liksom göra hela linjen (från en vecka tillbaka) men inte visa den? Om det är vettigt... Då hade man tom kunnat zooma en vacker dag
|
//kan man liksom göra hela linjen (från en vecka tillbaka) men inte visa den? Om det är vettigt... Då hade man tom kunnat zooma en vacker dag
|
||||||
|
|
|
@ -8,10 +8,11 @@ function getActiveStates(){
|
||||||
return activeStates;
|
return activeStates;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBarWidth(currentBar, currentPointRect, pointList){
|
function getBarWidth(currentBar, currentPointRect, pointList, currentDay){
|
||||||
|
|
||||||
|
//TODO REMOVE currentDay too, currentDay.endsWith = ""; //reset
|
||||||
var maxWidth = currentPointRect.parent.width;
|
var maxWidth = currentPointRect.parent.width;
|
||||||
var nextX = maxWidth - currentPointRect.width / 2
|
var nextX = maxWidth - currentPointRect.width / 2;
|
||||||
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") {
|
if (pointList[i].isPoint != undefined && pointList[i].isPoint == "true") {
|
||||||
if(pointList[i].x < nextX && pointList[i].x > currentPointRect.x){
|
if(pointList[i].x < nextX && pointList[i].x > currentPointRect.x){
|
||||||
|
@ -19,6 +20,12 @@ function getBarWidth(currentBar, currentPointRect, pointList){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* TODO
|
||||||
|
if(nextX == maxWidth - currentPointRect.width/2 && currentPointRect.state != "" && currentPointRect.state != "off"){
|
||||||
|
currentDay.endsWith = currentPointRect.state;
|
||||||
|
print("Ends with: " + currentDay.endsWith);
|
||||||
|
}
|
||||||
|
*/
|
||||||
return (nextX - currentPointRect.x);
|
return (nextX - currentPointRect.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +47,25 @@ function getPreviousState(currentPointRect, pointList){
|
||||||
return prevPoint.state;
|
return prevPoint.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getEndsWith(pointList, previousDayEndsWith){
|
||||||
|
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){
|
||||||
|
return previousDayEndsWith;
|
||||||
|
}
|
||||||
|
if(prevPoint.state == "off"){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return prevPoint.state; //only on or dim
|
||||||
|
}
|
||||||
|
|
||||||
function isMidnightDark(){
|
function isMidnightDark(){
|
||||||
if(main.sunData == undefined){
|
if(main.sunData == undefined){
|
||||||
main.sunData = getSunData.call();
|
main.sunData = getSunData.call();
|
||||||
|
@ -63,7 +89,8 @@ function pad(number, length) {
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
function getNextAndPrevBarWidth(currentBar, currentPointRect, pointList){
|
function getNextAndPrevBarWidth(currentBar, currentPointRect, pointList){
|
||||||
return getBarWidth(currentBar, currentPointRect, pointList);
|
return getBarWidth(currentBar, currentPointRect, pointList);
|
||||||
}
|
}
|
||||||
|
*/
|
Loading…
Add table
Add a link
Reference in a new issue