From ef9a201f9052aef710ebaa70b3e4458e014564f0 Mon Sep 17 00:00:00 2001 From: Stefan Persson Date: Tue, 1 Nov 2011 14:14:14 +0100 Subject: [PATCH 01/20] Possibility to add/remove sensors from list, and change their names. Not yet persistent. --- telldus-gui/Plugins/Sensors/SensorValue.qml | 1 + telldus-gui/Plugins/Sensors/__init__.js | 1 + telldus-gui/Plugins/Sensors/main.qml | 193 +++++++++++++++++--- telldus-gui/Plugins/Sensors/sensor.cpp | 18 +- telldus-gui/Plugins/Sensors/sensor.h | 8 +- 5 files changed, 191 insertions(+), 30 deletions(-) diff --git a/telldus-gui/Plugins/Sensors/SensorValue.qml b/telldus-gui/Plugins/Sensors/SensorValue.qml index 7198c9ff..083830a1 100644 --- a/telldus-gui/Plugins/Sensors/SensorValue.qml +++ b/telldus-gui/Plugins/Sensors/SensorValue.qml @@ -14,6 +14,7 @@ Item { } Text { id: text + font.weight: Font.Bold anchors.left: icon.right anchors.leftMargin: 10 anchors.verticalCenter: parent.verticalCenter diff --git a/telldus-gui/Plugins/Sensors/__init__.js b/telldus-gui/Plugins/Sensors/__init__.js index c20bfb67..70283e2b 100644 --- a/telldus-gui/Plugins/Sensors/__init__.js +++ b/telldus-gui/Plugins/Sensors/__init__.js @@ -56,6 +56,7 @@ com.telldus.sensors = function() { sensor.protocol = protocol; sensor.model = model; sensor.id = id; + sensor.showInList = false; sensorList.push(sensor); print("Create new"); } else { diff --git a/telldus-gui/Plugins/Sensors/main.qml b/telldus-gui/Plugins/Sensors/main.qml index 8be6755d..5d240c29 100644 --- a/telldus-gui/Plugins/Sensors/main.qml +++ b/telldus-gui/Plugins/Sensors/main.qml @@ -2,39 +2,116 @@ import Qt 4.7 Item { id: main + state: "VIEW" Component { id: sensorView - BorderImage { - source: "row_bg.png" - border.left: 5; border.top: 5 - border.right: 5; border.bottom: 5 - height: sensorInfo.height + Item{ + id: sensorViewItem + visible: main.state == "EDIT" || modelData.showInList + height: childrenRect.height width: parent.width - Text { - anchors.left: parent.left - anchors.leftMargin: 15 - height: 40 - verticalAlignment: Text.AlignVCenter - text: modelData.name; - color: "#004275" - } - Column { - id: sensorInfo - anchors.right: parent.right - width: 250 - SensorValue { - visible: modelData.hasTemperature - text: visible ? modelData.sensorValue(1).value + '°C' : '' - icon: "icon_temp.png" - lastUpdated: visible ? modelData.sensorValue(1).lastUpdated : new Date() + BorderImage { + source: "row_bg.png" + border.left: 5; border.top: 5 + border.right: 5; border.bottom: 5 + height: sensorInfo.height + width: parent.width + + Text { + visible: main.state == "VIEW" + anchors.left: parent.left + anchors.leftMargin: 15 + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.name; + color: "#004275" } - SensorValue { - visible: modelData.hasHumidity - text: visible ? modelData.sensorValue(2).value + '%' : '' - icon: "icon_humidity.png" - lastUpdated: visible ? modelData.sensorValue(2).lastUpdated : new Date() + Rectangle{ + color: "white" + visible: main.state == "EDIT" + anchors.left: parent.left + anchors.leftMargin: 15 + width: nameEdit.width + 4 + height: 22 + TextInput{ + id: nameEdit + anchors.centerIn: parent + text: modelData.name; + color: "#004275" + + onActiveFocusChanged: { + if(!activeFocus){ + //todo other way? + modelData.setName(nameEdit.text); + } + } + onAccepted: { + modelData.setName(nameEdit.text); + } + } + } + Text{ + anchors.right: model.left + visible: main.state == "EDIT" + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.id + color: "#004275" + width: 50 + } + Text{ + id: model + anchors.right: visibleinlistcheckbox.left + visible: main.state == "EDIT" + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.model + color: "#004275" + width: 100 + } + Item{ + id: visibleinlistcheckbox + anchors.right: sensorInfo.left + visible: main.state == "EDIT" + height: 40 + Rectangle{ + anchors.centerIn: parent + height: 10 + width: 10 + color: "white" + Text{ + anchors.centerIn: parent + color: "#004275" + text: modelData.showInList ? "X" : "" + } + MouseArea{ + anchors.fill: parent + onClicked: { + modelData.setShowInList(!modelData.showInList); + } + } + } + width: 100 + } + + Column { + id: sensorInfo + anchors.right: parent.right + width: 250 + SensorValue { + visible: modelData.hasTemperature + text: visible ? modelData.sensorValue(1).value + '°C' : '' + icon: "icon_temp.png" + lastUpdated: visible ? modelData.sensorValue(1).lastUpdated : new Date() + } + SensorValue { + visible: modelData.hasHumidity + text: visible ? modelData.sensorValue(2).value + '%' : '' + icon: "icon_humidity.png" + lastUpdated: visible ? modelData.sensorValue(2).lastUpdated : new Date() + } } } } @@ -55,6 +132,27 @@ Item { anchors.leftMargin: 15 } HeaderTitle { + text: "ID" + anchors.right: modelTitle.left + visible: main.state == "EDIT" + width: 50 + } + HeaderTitle { + id: modelTitle + text: "Model" + anchors.right: visibleinlistTitle.left + visible: main.state == "EDIT" + width: 100 + } + HeaderTitle { + id: visibleinlistTitle + text: "Visible in list" + anchors.right: sensorinformationTitle.left + visible: main.state == "EDIT" + width: 100 + } + HeaderTitle { + id: sensorinformationTitle text: "Sensor information" width: 150 anchors.right: timestampTitle.left @@ -64,12 +162,53 @@ Item { text: "Last updated" width: 100 anchors.right: parent.right + //horizontalAlignment: Text.AlignRight } } Repeater { model: sensorModel delegate: sensorView } + Row{ + spacing: 20 + Rectangle { + width: 50 + height: 20 + Text{ + anchors.centerIn: parent + text: main.state == "VIEW" ? "Edit" : "View" + } + MouseArea{ + anchors.fill: parent + onClicked: { + if(main.state == "VIEW"){ + main.state = "EDIT" + } + else{ + main.state ="VIEW" + } + } + } + } + /* + Rectangle { + //TODO should this button exist at all, or always save? + width: 50 + height: 20 + visible: main.state == "EDIT" + Text{ + anchors.centerIn: parent + text: "Cancel" + } + MouseArea{ + anchors.fill: parent + onClicked: { + main.state ="VIEW" + } + } + } + */ + } anchors.fill: parent } } diff --git a/telldus-gui/Plugins/Sensors/sensor.cpp b/telldus-gui/Plugins/Sensors/sensor.cpp index cb04f2fc..7a56f46f 100644 --- a/telldus-gui/Plugins/Sensors/sensor.cpp +++ b/telldus-gui/Plugins/Sensors/sensor.cpp @@ -1,10 +1,11 @@ #include "sensor.h" #include "sensorvalue.h" #include +#include class Sensor::PrivateData { public: - bool hasTemperature, hasHumidity; + bool hasTemperature, hasHumidity, showInList; int id; QString model, name, protocol; QDateTime lastUpdated; @@ -45,7 +46,10 @@ void Sensor::setModel(const QString &model) { } QString Sensor::name() const { - return QString("%1 %2").arg(this->protocol()).arg(this->id()); //TODO: Remove when name is fully implemented + //return QString("%1 %2").arg(this->protocol()).arg(this->id()); //TODO: Remove when name is fully implemented + if(d->name == ""){ + return ""; + } return d->name; } @@ -88,3 +92,13 @@ void Sensor::setValue(int type, const QString &value, const QDateTime ×tamp emit hasHumidityChanged(); } } + +bool Sensor::showInList() const{ + //TODO showInList and name must be persistent... + return d->showInList; +} + +void Sensor::setShowInList(bool show){ + d->showInList = show; + emit showInListChanged(); +} diff --git a/telldus-gui/Plugins/Sensors/sensor.h b/telldus-gui/Plugins/Sensors/sensor.h index fc70468d..85164246 100644 --- a/telldus-gui/Plugins/Sensors/sensor.h +++ b/telldus-gui/Plugins/Sensors/sensor.h @@ -17,6 +17,8 @@ class Sensor : public QObject Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString protocol READ protocol WRITE setProtocol NOTIFY protocolChanged) + Q_PROPERTY(bool showInList READ showInList NOTIFY showInListChanged) + public: explicit Sensor(QObject *parent = 0); ~Sensor(); @@ -30,15 +32,18 @@ public: void setModel(const QString &model); QString name() const; - void setName(const QString &name); + //void setName(const QString &name); QString protocol() const; void setProtocol(const QString &protocol); bool hasTemperature() const; + bool showInList() const; Q_INVOKABLE SensorValue *sensorValue(int type); Q_INVOKABLE void setValue(int type, const QString &value, const QDateTime ×tamp); + Q_INVOKABLE void setName(const QString &name); + Q_INVOKABLE void setShowInList(bool show); signals: void idChanged(); @@ -47,6 +52,7 @@ signals: void modelChanged(); void nameChanged(); void protocolChanged(); + void showInListChanged(); private: class PrivateData; From df5e08ff9c47c199049f2337edc41480f90d3bff Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Thu, 12 Jan 2012 17:30:23 +0100 Subject: [PATCH 02/20] Move SensorView to its own file --- telldus-gui/Plugins/Sensors/CMakeLists.txt | 1 + telldus-gui/Plugins/Sensors/SensorView.qml | 114 +++++++++++++++++++++ telldus-gui/Plugins/Sensors/main.qml | 111 +------------------- telldus-gui/Plugins/Sensors/qmldir | 1 + 4 files changed, 117 insertions(+), 110 deletions(-) create mode 100644 telldus-gui/Plugins/Sensors/SensorView.qml diff --git a/telldus-gui/Plugins/Sensors/CMakeLists.txt b/telldus-gui/Plugins/Sensors/CMakeLists.txt index cf97f98c..bb3a4157 100644 --- a/telldus-gui/Plugins/Sensors/CMakeLists.txt +++ b/telldus-gui/Plugins/Sensors/CMakeLists.txt @@ -33,6 +33,7 @@ SET( Plugin_EXTRA row_bg.png qmldir SensorValue.qml + SensorView.qml ) FIND_PACKAGE(TelldusCore REQUIRED) diff --git a/telldus-gui/Plugins/Sensors/SensorView.qml b/telldus-gui/Plugins/Sensors/SensorView.qml new file mode 100644 index 00000000..108c58c4 --- /dev/null +++ b/telldus-gui/Plugins/Sensors/SensorView.qml @@ -0,0 +1,114 @@ +import Qt 4.7 + +Component { + id: sensorView + Item{ + id: sensorViewItem + visible: main.state == "EDIT" || modelData.showInList + height: childrenRect.height + width: parent.width + + BorderImage { + source: "row_bg.png" + border.left: 5; border.top: 5 + border.right: 5; border.bottom: 5 + height: sensorInfo.height + width: parent.width + + Text { + visible: main.state == "VIEW" + anchors.left: parent.left + anchors.leftMargin: 15 + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.name; + color: "#004275" + } + Rectangle{ + color: "white" + visible: main.state == "EDIT" + anchors.left: parent.left + anchors.leftMargin: 15 + width: nameEdit.width + 4 + height: 22 + TextInput{ + id: nameEdit + anchors.centerIn: parent + text: modelData.name; + color: "#004275" + + onActiveFocusChanged: { + if(!activeFocus){ + //todo other way? + modelData.setName(nameEdit.text); + } + } + onAccepted: { + modelData.setName(nameEdit.text); + } + } + } + Text{ + anchors.right: model.left + visible: main.state == "EDIT" + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.id + color: "#004275" + width: 50 + } + Text{ + id: model + anchors.right: visibleinlistcheckbox.left + visible: main.state == "EDIT" + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.model + color: "#004275" + width: 100 + } + Item{ + id: visibleinlistcheckbox + anchors.right: sensorInfo.left + visible: main.state == "EDIT" + height: 40 + Rectangle{ + anchors.centerIn: parent + height: 10 + width: 10 + color: "white" + Text{ + anchors.centerIn: parent + color: "#004275" + text: modelData.showInList ? "X" : "" + } + MouseArea{ + anchors.fill: parent + onClicked: { + modelData.setShowInList(!modelData.showInList); + } + } + } + width: 100 + } + + Column { + id: sensorInfo + anchors.right: parent.right + width: 250 + SensorValue { + visible: modelData.hasTemperature + text: visible ? modelData.sensorValue(1).value + '°C' : '' + icon: "icon_temp.png" + lastUpdated: visible ? modelData.sensorValue(1).lastUpdated : new Date() + } + SensorValue { + visible: modelData.hasHumidity + text: visible ? modelData.sensorValue(2).value + '%' : '' + icon: "icon_humidity.png" + lastUpdated: visible ? modelData.sensorValue(2).lastUpdated : new Date() + } + } + } + } +} diff --git a/telldus-gui/Plugins/Sensors/main.qml b/telldus-gui/Plugins/Sensors/main.qml index 5d240c29..c68d3f06 100644 --- a/telldus-gui/Plugins/Sensors/main.qml +++ b/telldus-gui/Plugins/Sensors/main.qml @@ -4,117 +4,8 @@ Item { id: main state: "VIEW" - Component { + SensorView { id: sensorView - Item{ - id: sensorViewItem - visible: main.state == "EDIT" || modelData.showInList - height: childrenRect.height - width: parent.width - - BorderImage { - source: "row_bg.png" - border.left: 5; border.top: 5 - border.right: 5; border.bottom: 5 - height: sensorInfo.height - width: parent.width - - Text { - visible: main.state == "VIEW" - anchors.left: parent.left - anchors.leftMargin: 15 - height: 40 - verticalAlignment: Text.AlignVCenter - text: modelData.name; - color: "#004275" - } - Rectangle{ - color: "white" - visible: main.state == "EDIT" - anchors.left: parent.left - anchors.leftMargin: 15 - width: nameEdit.width + 4 - height: 22 - TextInput{ - id: nameEdit - anchors.centerIn: parent - text: modelData.name; - color: "#004275" - - onActiveFocusChanged: { - if(!activeFocus){ - //todo other way? - modelData.setName(nameEdit.text); - } - } - onAccepted: { - modelData.setName(nameEdit.text); - } - } - } - Text{ - anchors.right: model.left - visible: main.state == "EDIT" - height: 40 - verticalAlignment: Text.AlignVCenter - text: modelData.id - color: "#004275" - width: 50 - } - Text{ - id: model - anchors.right: visibleinlistcheckbox.left - visible: main.state == "EDIT" - height: 40 - verticalAlignment: Text.AlignVCenter - text: modelData.model - color: "#004275" - width: 100 - } - Item{ - id: visibleinlistcheckbox - anchors.right: sensorInfo.left - visible: main.state == "EDIT" - height: 40 - Rectangle{ - anchors.centerIn: parent - height: 10 - width: 10 - color: "white" - Text{ - anchors.centerIn: parent - color: "#004275" - text: modelData.showInList ? "X" : "" - } - MouseArea{ - anchors.fill: parent - onClicked: { - modelData.setShowInList(!modelData.showInList); - } - } - } - width: 100 - } - - Column { - id: sensorInfo - anchors.right: parent.right - width: 250 - SensorValue { - visible: modelData.hasTemperature - text: visible ? modelData.sensorValue(1).value + '°C' : '' - icon: "icon_temp.png" - lastUpdated: visible ? modelData.sensorValue(1).lastUpdated : new Date() - } - SensorValue { - visible: modelData.hasHumidity - text: visible ? modelData.sensorValue(2).value + '%' : '' - icon: "icon_humidity.png" - lastUpdated: visible ? modelData.sensorValue(2).lastUpdated : new Date() - } - } - } - } } Column { diff --git a/telldus-gui/Plugins/Sensors/qmldir b/telldus-gui/Plugins/Sensors/qmldir index 19c8cb6f..8c98fd76 100644 --- a/telldus-gui/Plugins/Sensors/qmldir +++ b/telldus-gui/Plugins/Sensors/qmldir @@ -1,2 +1,3 @@ HeaderTitle 1.0 HeaderTitle.qml SensorValue 1.0 SensorValue.qml +SensorView 1.0 SensorView.qml From 332bf966f52568b7ac890e860f686d984c765309 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Thu, 12 Jan 2012 17:32:41 +0100 Subject: [PATCH 03/20] Change plugin name to have capital first letter --- telldus-gui/Plugins/Sensors/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telldus-gui/Plugins/Sensors/CMakeLists.txt b/telldus-gui/Plugins/Sensors/CMakeLists.txt index bb3a4157..74e2750a 100644 --- a/telldus-gui/Plugins/Sensors/CMakeLists.txt +++ b/telldus-gui/Plugins/Sensors/CMakeLists.txt @@ -3,7 +3,7 @@ SET(REQUIRE_PLUGIN_SETTINGS TRUE PARENT_SCOPE) SET(QT_USE_QTDECLARATIVE TRUE) -SET( Plugin_NAME "sensors" ) +SET( Plugin_NAME "Sensors" ) SET( Plugin_SRCS From 3942702881a48f92e0417fe6a63a7d3b3c7e8237 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Thu, 12 Jan 2012 17:33:08 +0100 Subject: [PATCH 04/20] Move SensorList to its own file --- telldus-gui/Plugins/Sensors/CMakeLists.txt | 1 + telldus-gui/Plugins/Sensors/SensorList.qml | 102 +++++++++++++++++++++ telldus-gui/Plugins/Sensors/main.qml | 99 +------------------- telldus-gui/Plugins/Sensors/qmldir | 1 + 4 files changed, 106 insertions(+), 97 deletions(-) create mode 100644 telldus-gui/Plugins/Sensors/SensorList.qml diff --git a/telldus-gui/Plugins/Sensors/CMakeLists.txt b/telldus-gui/Plugins/Sensors/CMakeLists.txt index 74e2750a..45371412 100644 --- a/telldus-gui/Plugins/Sensors/CMakeLists.txt +++ b/telldus-gui/Plugins/Sensors/CMakeLists.txt @@ -34,6 +34,7 @@ SET( Plugin_EXTRA qmldir SensorValue.qml SensorView.qml + SensorList.qml ) FIND_PACKAGE(TelldusCore REQUIRED) diff --git a/telldus-gui/Plugins/Sensors/SensorList.qml b/telldus-gui/Plugins/Sensors/SensorList.qml new file mode 100644 index 00000000..a43a0b93 --- /dev/null +++ b/telldus-gui/Plugins/Sensors/SensorList.qml @@ -0,0 +1,102 @@ +import Qt 4.7 + +Column { + id: sensorList + spacing: 1 + + SensorView { + id: sensorView + } + + BorderImage { + id: header + source: "header_bg.png" + width: parent.width; height: 40 + border.left: 5; border.top: 5 + border.right: 5; border.bottom: 5 + + HeaderTitle { + text: "Name" + anchors.left: parent.left + anchors.leftMargin: 15 + } + HeaderTitle { + text: "ID" + anchors.right: modelTitle.left + visible: main.state == "EDIT" + width: 50 + } + HeaderTitle { + id: modelTitle + text: "Model" + anchors.right: visibleinlistTitle.left + visible: main.state == "EDIT" + width: 100 + } + HeaderTitle { + id: visibleinlistTitle + text: "Visible in list" + anchors.right: sensorinformationTitle.left + visible: main.state == "EDIT" + width: 100 + } + HeaderTitle { + id: sensorinformationTitle + text: "Sensor information" + width: 150 + anchors.right: timestampTitle.left + } + HeaderTitle { + id: timestampTitle + text: "Last updated" + width: 100 + anchors.right: parent.right + //horizontalAlignment: Text.AlignRight + } + } + Repeater { + model: sensorModel + delegate: sensorView + } + Row{ + spacing: 20 + Rectangle { + width: 50 + height: 20 + Text{ + anchors.centerIn: parent + text: main.state == "VIEW" ? "Edit" : "View" + } + MouseArea{ + anchors.fill: parent + onClicked: { + if(main.state == "VIEW"){ + main.state = "EDIT" + } + else{ + main.state ="VIEW" + } + } + } + } + /* + Rectangle { + //TODO should this button exist at all, or always save? + width: 50 + height: 20 + visible: main.state == "EDIT" + Text{ + anchors.centerIn: parent + text: "Cancel" + } + MouseArea{ + anchors.fill: parent + onClicked: { + main.state ="VIEW" + } + } + } + */ + } + anchors.fill: parent +} diff --git a/telldus-gui/Plugins/Sensors/main.qml b/telldus-gui/Plugins/Sensors/main.qml index c68d3f06..523480d6 100644 --- a/telldus-gui/Plugins/Sensors/main.qml +++ b/telldus-gui/Plugins/Sensors/main.qml @@ -4,102 +4,7 @@ Item { id: main state: "VIEW" - SensorView { - id: sensorView - } - - Column { - spacing: 1 - BorderImage { - id: header - source: "header_bg.png" - width: parent.width; height: 40 - border.left: 5; border.top: 5 - border.right: 5; border.bottom: 5 - - HeaderTitle { - text: "Name" - anchors.left: parent.left - anchors.leftMargin: 15 - } - HeaderTitle { - text: "ID" - anchors.right: modelTitle.left - visible: main.state == "EDIT" - width: 50 - } - HeaderTitle { - id: modelTitle - text: "Model" - anchors.right: visibleinlistTitle.left - visible: main.state == "EDIT" - width: 100 - } - HeaderTitle { - id: visibleinlistTitle - text: "Visible in list" - anchors.right: sensorinformationTitle.left - visible: main.state == "EDIT" - width: 100 - } - HeaderTitle { - id: sensorinformationTitle - text: "Sensor information" - width: 150 - anchors.right: timestampTitle.left - } - HeaderTitle { - id: timestampTitle - text: "Last updated" - width: 100 - anchors.right: parent.right - //horizontalAlignment: Text.AlignRight - } - } - Repeater { - model: sensorModel - delegate: sensorView - } - Row{ - spacing: 20 - Rectangle { - width: 50 - height: 20 - Text{ - anchors.centerIn: parent - text: main.state == "VIEW" ? "Edit" : "View" - } - MouseArea{ - anchors.fill: parent - onClicked: { - if(main.state == "VIEW"){ - main.state = "EDIT" - } - else{ - main.state ="VIEW" - } - } - } - } - /* - Rectangle { - //TODO should this button exist at all, or always save? - width: 50 - height: 20 - visible: main.state == "EDIT" - Text{ - anchors.centerIn: parent - text: "Cancel" - } - MouseArea{ - anchors.fill: parent - onClicked: { - main.state ="VIEW" - } - } - } - */ - } - anchors.fill: parent + SensorList { + id: sensorList } } diff --git a/telldus-gui/Plugins/Sensors/qmldir b/telldus-gui/Plugins/Sensors/qmldir index 8c98fd76..050f9f5b 100644 --- a/telldus-gui/Plugins/Sensors/qmldir +++ b/telldus-gui/Plugins/Sensors/qmldir @@ -1,3 +1,4 @@ HeaderTitle 1.0 HeaderTitle.qml SensorValue 1.0 SensorValue.qml SensorView 1.0 SensorView.qml +SensorList 1.0 SensorList.qml From 1dfacddf1af00dee7813b006dcb4ed554de2b5ac Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Thu, 12 Jan 2012 17:39:11 +0100 Subject: [PATCH 05/20] Make the list flickable --- telldus-gui/Plugins/Sensors/SensorList.qml | 1 - telldus-gui/Plugins/Sensors/main.qml | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/telldus-gui/Plugins/Sensors/SensorList.qml b/telldus-gui/Plugins/Sensors/SensorList.qml index a43a0b93..b6be1003 100644 --- a/telldus-gui/Plugins/Sensors/SensorList.qml +++ b/telldus-gui/Plugins/Sensors/SensorList.qml @@ -98,5 +98,4 @@ Column { } */ } - anchors.fill: parent } diff --git a/telldus-gui/Plugins/Sensors/main.qml b/telldus-gui/Plugins/Sensors/main.qml index 523480d6..599a1ae1 100644 --- a/telldus-gui/Plugins/Sensors/main.qml +++ b/telldus-gui/Plugins/Sensors/main.qml @@ -4,7 +4,14 @@ Item { id: main state: "VIEW" - SensorList { - id: sensorList + Flickable { + anchors.fill: parent + + contentHeight: sensorList.height + + SensorList { + width: parent.width + id: sensorList + } } } From 5db7658a477ef4b3615d7ea90d325404121b7d17 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Fri, 13 Jan 2012 12:05:22 +0100 Subject: [PATCH 06/20] Add Qt Components for desktop as submodule --- .gitmodules | 3 +++ telldus-gui/3rdparty/qt-components-desktop | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 telldus-gui/3rdparty/qt-components-desktop diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..1512eb7b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "telldus-gui/3rdparty/qt-components-desktop"] + path = telldus-gui/3rdparty/qt-components-desktop + url = git://gitorious.org/qt-components/desktop.git diff --git a/telldus-gui/3rdparty/qt-components-desktop b/telldus-gui/3rdparty/qt-components-desktop new file mode 160000 index 00000000..563fdbc4 --- /dev/null +++ b/telldus-gui/3rdparty/qt-components-desktop @@ -0,0 +1 @@ +Subproject commit 563fdbc4d7805c9d9c1d2abde1d52b39e58b4329 From ab436a212fb4158c66b118c557ab4b4f8275033d Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Fri, 13 Jan 2012 14:34:53 +0100 Subject: [PATCH 07/20] Add cmake build file for QtComponents --- .../3rdparty/qt-components-desktop.cmake | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 telldus-gui/3rdparty/qt-components-desktop.cmake diff --git a/telldus-gui/3rdparty/qt-components-desktop.cmake b/telldus-gui/3rdparty/qt-components-desktop.cmake new file mode 100644 index 00000000..7af264c7 --- /dev/null +++ b/telldus-gui/3rdparty/qt-components-desktop.cmake @@ -0,0 +1,42 @@ +FIND_PACKAGE( Qt4 REQUIRED ) + +SET(BASE_PATH "${CMAKE_SOURCE_DIR}/3rdparty/qt-components-desktop") +FILE(GLOB SRCS ${BASE_PATH}/src/*.cpp) +FILE(GLOB HDRS ${BASE_PATH}/src/*.h) + +FILE(GLOB_RECURSE QML ${BASE_PATH}/components/*.qml) +FILE(GLOB_RECURSE JS ${BASE_PATH}/components/*.js) +FILE(GLOB_RECURSE PNG ${BASE_PATH}/components/*.png) +FILE(GLOB_RECURSE QMLDIR ${BASE_PATH}/components/qmldir) +SET(EXTRA_FILES ${QML} ${JS} ${PNG} ${QMLDIR}) + +QT4_WRAP_CPP( MOC_SRCS ${HDRS} ) +QT4_AUTOMOC ( ${SRCS} ) + +ADD_LIBRARY(styleplugin SHARED + ${SRCS} + ${MOC_SRCS} + ${QMLS} +) +TARGET_LINK_LIBRARIES( styleplugin ${QT_LIBRARIES} ) + + +IF (QT_COMPONENTS_OUTPUT_DIR) + SET(QT_COMPONENTS_OUTPUT_DIR "${QT_COMPONENTS_OUTPUT_DIR}/QtDesktop") +ELSE() + SET(QT_COMPONENTS_OUTPUT_DIR "QtDesktop") +ENDIF() + +SET_TARGET_PROPERTIES(styleplugin PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${QT_COMPONENTS_OUTPUT_DIR}/plugin +) + +STRING(LENGTH "${BASE_PATH}/components" BASE_LENGTH) +FOREACH(_FILE ${EXTRA_FILES}) + STRING(SUBSTRING ${_FILE} ${BASE_LENGTH} -1 _OUT_FILE) + GET_FILENAME_COMPONENT(_FILENAME ${_FILE} NAME) + ADD_CUSTOM_COMMAND( TARGET ${Plugin_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${_FILE} ${QT_COMPONENTS_OUTPUT_DIR}${_OUT_FILE} + ) +ENDFOREACH(_FILE) From 5531d6b3132be7754e7354244a669ac03a22719f Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Fri, 13 Jan 2012 14:36:38 +0100 Subject: [PATCH 08/20] Add QtComponents to the QML plugin --- telldus-gui/Plugins/QML/CMakeLists.txt | 3 +++ telldus-gui/Plugins/QML/qmlview.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/telldus-gui/Plugins/QML/CMakeLists.txt b/telldus-gui/Plugins/QML/CMakeLists.txt index 5d0830d8..e2fe6a94 100644 --- a/telldus-gui/Plugins/QML/CMakeLists.txt +++ b/telldus-gui/Plugins/QML/CMakeLists.txt @@ -23,3 +23,6 @@ SET( Plugin_MOC_HDRS SET( Plugin_PATH "com.telldus.qml" ) INCLUDE( ../TelldusCenterPlugin.cmake NO_POLICY_SCOPE ) + +SET(QT_COMPONENTS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/TelldusCenter/Plugins/declarative") +INCLUDE( ${CMAKE_SOURCE_DIR}/3rdparty/qt-components-desktop.cmake NO_POLICY_SCOPE ) diff --git a/telldus-gui/Plugins/QML/qmlview.cpp b/telldus-gui/Plugins/QML/qmlview.cpp index dea06628..6d12cc0f 100644 --- a/telldus-gui/Plugins/QML/qmlview.cpp +++ b/telldus-gui/Plugins/QML/qmlview.cpp @@ -2,7 +2,9 @@ #include "scriptfunctionwrapper.h" #include #include +#include #include +#include class QMLView::PrivateData { public: @@ -16,6 +18,22 @@ QMLView::QMLView(const QDir &dir, const QScriptValue &object) : setAttribute(Qt::WA_TranslucentBackground); setStyleSheet("background:transparent;"); + QDeclarativeEngine *eng = this->engine(); + QStringList paths(eng->importPathList()); + QDir pluginsDir = QDir(qApp->applicationDirPath()); + +#if defined(Q_OS_MAC) + if (pluginsDir.dirName() == "MacOS") { + pluginsDir.cdUp(); + } +#endif + + if (pluginsDir.cd("Plugins/declarative")) { + paths << pluginsDir.absolutePath(); + } + + eng->setImportPathList(paths); + d = new PrivateData; d->baseDir = dir; d->object = object; From aadc4554fc97f0caac4d591e1b9f8197e02d94f0 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Fri, 13 Jan 2012 14:37:07 +0100 Subject: [PATCH 09/20] Convert the edit button to a qt-component button --- telldus-gui/Plugins/Sensors/SensorList.qml | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/telldus-gui/Plugins/Sensors/SensorList.qml b/telldus-gui/Plugins/Sensors/SensorList.qml index b6be1003..a26cdd4d 100644 --- a/telldus-gui/Plugins/Sensors/SensorList.qml +++ b/telldus-gui/Plugins/Sensors/SensorList.qml @@ -1,4 +1,5 @@ import Qt 4.7 +import QtDesktop 0.1 Column { id: sensorList @@ -60,22 +61,16 @@ Column { } Row{ spacing: 20 - Rectangle { + Button { width: 50 height: 20 - Text{ - anchors.centerIn: parent - text: main.state == "VIEW" ? "Edit" : "View" - } - MouseArea{ - anchors.fill: parent - onClicked: { - if(main.state == "VIEW"){ - main.state = "EDIT" - } - else{ - main.state ="VIEW" - } + text: main.state == "VIEW" ? "Edit" : "View" + onClicked: { + if(main.state == "VIEW"){ + main.state = "EDIT" + } + else{ + main.state ="VIEW" } } } From cc0b37e179d94a87d627d031dd4d857bfeeee297 Mon Sep 17 00:00:00 2001 From: Stefan Persson Date: Fri, 13 Jan 2012 15:05:22 +0100 Subject: [PATCH 10/20] Fix for building if cmake doesn't understand -1 length in STRING(SUBSTRING) --- telldus-gui/3rdparty/qt-components-desktop.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/telldus-gui/3rdparty/qt-components-desktop.cmake b/telldus-gui/3rdparty/qt-components-desktop.cmake index 7af264c7..3a1d5bd2 100644 --- a/telldus-gui/3rdparty/qt-components-desktop.cmake +++ b/telldus-gui/3rdparty/qt-components-desktop.cmake @@ -33,10 +33,13 @@ SET_TARGET_PROPERTIES(styleplugin PROPERTIES STRING(LENGTH "${BASE_PATH}/components" BASE_LENGTH) FOREACH(_FILE ${EXTRA_FILES}) - STRING(SUBSTRING ${_FILE} ${BASE_LENGTH} -1 _OUT_FILE) + STRING(LENGTH ${_FILE} _FILE_LENGTH) + MATH(EXPR _TOP_LENGTH "${_FILE_LENGTH}-${BASE_LENGTH}") + STRING(SUBSTRING ${_FILE} ${BASE_LENGTH} ${_TOP_LENGTH} _OUT_FILE) GET_FILENAME_COMPONENT(_FILENAME ${_FILE} NAME) - ADD_CUSTOM_COMMAND( TARGET ${Plugin_NAME} + ADD_CUSTOM_COMMAND( TARGET styleplugin POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${_FILE} ${QT_COMPONENTS_OUTPUT_DIR}${_OUT_FILE} + COMMENT "Copy ${_FILENAME} to destination" ) ENDFOREACH(_FILE) From 69b16f0bafc540369d457341523f49302540f21a Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Fri, 13 Jan 2012 15:29:55 +0100 Subject: [PATCH 11/20] Plugin extra files should be a custom command and not built after linking. This fixes the issue that the plugin needed to be relinked for new files to be copied to destination --- telldus-gui/Plugins/TelldusCenterPlugin.cmake | 45 +++++++++---------- telldus-gui/Plugins/telldus/__init__.js | 2 +- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/telldus-gui/Plugins/TelldusCenterPlugin.cmake b/telldus-gui/Plugins/TelldusCenterPlugin.cmake index 20ab8c6a..daae9f1a 100644 --- a/telldus-gui/Plugins/TelldusCenterPlugin.cmake +++ b/telldus-gui/Plugins/TelldusCenterPlugin.cmake @@ -63,6 +63,21 @@ ELSE (UPDATE_TRANSLATIONS) LIST(APPEND Plugin_FILES ${Plugin_QM}) ENDIF (UPDATE_TRANSLATIONS) +IF(Plugin_PATH) + FOREACH(_FILE ${Plugin_FILES}) + GET_FILENAME_COMPONENT(_FILENAME ${_FILE} NAME) + ADD_CUSTOM_COMMAND( OUTPUT ${Plugin_PATH}/${_FILENAME} + COMMAND ${CMAKE_COMMAND} -E copy ${_FILE} ${Plugin_PATH}/${_FILENAME} + DEPENDS ${_FILE} + COMMENT "Copy ${_FILENAME} for plugin ${Plugin_NAME}" + ) + LIST(APPEND Plugin_TARGET_FILES "${Plugin_PATH}/${_FILENAME}") + IF (NOT APPLE) + INSTALL(FILES ${_FILE} DESTINATION "${PLUGIN_LIB_FULL_PATH}/script/${Plugin_PATH_relative}") + ENDIF () + ENDFOREACH(_FILE) +ENDIF(Plugin_PATH) + IF(Plugin_SRCS) ADD_LIBRARY(${Plugin_NAME} SHARED ${Plugin_SRCS} @@ -74,6 +89,7 @@ IF(Plugin_SRCS) ${Plugin_FILES} ${Plugin_TS} ${Plugin_QM} + ${Plugin_TARGET_FILES} ) TARGET_LINK_LIBRARIES( ${Plugin_NAME} ${Plugin_LIBRARIES} ) @@ -87,13 +103,13 @@ IF(Plugin_SRCS) SET(app \"\${DESTDIR}/Applications/TelldusCenter.app\") GET_BUNDLE_AND_EXECUTABLE(\"\${app}\" bundle exe valid) SET(plugin \"\${bundle}/Contents/Plugins/script/${Plugin_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}\") - + GET_ITEM_KEY(\"\${plugin}\" pkey) SET(prereqs \"\") GET_PREREQUISITES(\${plugin} prereqs 1 0 \"\${exe}\" \"\${bundle}/Contents/Frameworks/\") FOREACH(pr \${prereqs}) GET_ITEM_KEY(\"\${pr}\" rkey) - + #Don't change the path to TelldusCore IF (NOT \"\${rkey}\" STREQUAL \"TelldusCore\") #Check to see if this is ourself @@ -117,33 +133,12 @@ IF(Plugin_SRCS) LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/TelldusCenter/Plugins/script ) INSTALL(TARGETS ${Plugin_NAME} - LIBRARY DESTINATION "${PLUGIN_LIB_FULL_PATH}/script" + LIBRARY DESTINATION "${PLUGIN_LIB_FULL_PATH}/script" ) ENDIF (APPLE) SIGN(${Plugin_NAME}) ELSE(Plugin_SRCS) ADD_CUSTOM_TARGET(${Plugin_NAME} ALL - SOURCES ${Plugin_FILES} + SOURCES ${Plugin_FILES} ${Plugin_TARGET_FILES} ) ENDIF(Plugin_SRCS) - -IF(Plugin_PATH) - ADD_CUSTOM_COMMAND( TARGET ${Plugin_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${Plugin_PATH} - COMMENT "Creating plugin directory ${Plugin_NAME}" - ) - FOREACH(_FILE ${Plugin_FILES}) - GET_FILENAME_COMPONENT(_FILENAME ${_FILE} NAME) - ADD_CUSTOM_COMMAND( TARGET ${Plugin_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${_FILE} ${Plugin_PATH} - COMMENT "Copy ${_FILENAME} for plugin ${Plugin_NAME}" - ) - IF (NOT APPLE) - INSTALL(FILES ${_FILE} DESTINATION "${PLUGIN_LIB_FULL_PATH}/script/${Plugin_PATH_relative}") - ENDIF () - ENDFOREACH(_FILE) -ENDIF(Plugin_PATH) - - diff --git a/telldus-gui/Plugins/telldus/__init__.js b/telldus-gui/Plugins/telldus/__init__.js index 64493195..a9c88dfb 100644 --- a/telldus-gui/Plugins/telldus/__init__.js +++ b/telldus-gui/Plugins/telldus/__init__.js @@ -1 +1 @@ -__setupPackage__( __extension__ ); \ No newline at end of file +__setupPackage__( __extension__ ); From c90a4c1f1228464d23cf043d910d9c128d5e717f Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Fri, 13 Jan 2012 15:50:21 +0100 Subject: [PATCH 12/20] Change the flickable area to a ScrollArea. Better for the desktop --- telldus-gui/Plugins/Sensors/main.qml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/telldus-gui/Plugins/Sensors/main.qml b/telldus-gui/Plugins/Sensors/main.qml index 599a1ae1..41ecb0ac 100644 --- a/telldus-gui/Plugins/Sensors/main.qml +++ b/telldus-gui/Plugins/Sensors/main.qml @@ -1,17 +1,21 @@ import Qt 4.7 +import QtDesktop 0.1 Item { id: main state: "VIEW" - Flickable { + ScrollArea { + id: scrollArea anchors.fill: parent + frame: false contentHeight: sensorList.height + contentWidth: sensorList.width SensorList { - width: parent.width id: sensorList + width: main.width-scrollArea.verticalScrollBar.width } } } From 64e2b354af0c1166afff3ea763e1c12b6b1be779 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Fri, 13 Jan 2012 16:12:13 +0100 Subject: [PATCH 13/20] Convert our checkbox to a qt-component checkbox --- telldus-gui/Plugins/Sensors/SensorList.qml | 1 + telldus-gui/Plugins/Sensors/SensorView.qml | 31 ++++++++-------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/telldus-gui/Plugins/Sensors/SensorList.qml b/telldus-gui/Plugins/Sensors/SensorList.qml index a26cdd4d..bd6f03c7 100644 --- a/telldus-gui/Plugins/Sensors/SensorList.qml +++ b/telldus-gui/Plugins/Sensors/SensorList.qml @@ -38,6 +38,7 @@ Column { id: visibleinlistTitle text: "Visible in list" anchors.right: sensorinformationTitle.left + horizontalAlignment: Text.AlignHCenter visible: main.state == "EDIT" width: 100 } diff --git a/telldus-gui/Plugins/Sensors/SensorView.qml b/telldus-gui/Plugins/Sensors/SensorView.qml index 108c58c4..752cbc0f 100644 --- a/telldus-gui/Plugins/Sensors/SensorView.qml +++ b/telldus-gui/Plugins/Sensors/SensorView.qml @@ -1,4 +1,5 @@ import Qt 4.7 +import QtDesktop 0.1 Component { id: sensorView @@ -67,29 +68,19 @@ Component { color: "#004275" width: 100 } - Item{ + Item { id: visibleinlistcheckbox - anchors.right: sensorInfo.left - visible: main.state == "EDIT" height: 40 - Rectangle{ - anchors.centerIn: parent - height: 10 - width: 10 - color: "white" - Text{ - anchors.centerIn: parent - color: "#004275" - text: modelData.showInList ? "X" : "" - } - MouseArea{ - anchors.fill: parent - onClicked: { - modelData.setShowInList(!modelData.showInList); - } - } - } width: 100 + anchors.right: sensorInfo.left + CheckBox { + id: checkBox + anchors.centerIn: parent + width: checkBox.height + visible: main.state == "EDIT" + checked: modelData.showInList + onClicked: modelData.setShowInList(!modelData.showInList) + } } Column { From 99c2b0e158d7a587a0b2cba693c0c15a54818171 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Fri, 13 Jan 2012 16:47:20 +0100 Subject: [PATCH 14/20] Convert the textbox to qt-components as well --- telldus-gui/Plugins/Sensors/SensorView.qml | 35 +++++++++------------- telldus-gui/Plugins/Sensors/sensor.cpp | 4 --- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/telldus-gui/Plugins/Sensors/SensorView.qml b/telldus-gui/Plugins/Sensors/SensorView.qml index 752cbc0f..c0492840 100644 --- a/telldus-gui/Plugins/Sensors/SensorView.qml +++ b/telldus-gui/Plugins/Sensors/SensorView.qml @@ -9,6 +9,13 @@ Component { height: childrenRect.height width: parent.width + property string state: main.state + onStateChanged: { + if (state != "EDIT") { + modelData.setName(nameEdit.text) + } + } + BorderImage { source: "row_bg.png" border.left: 5; border.top: 5 @@ -22,32 +29,18 @@ Component { anchors.leftMargin: 15 height: 40 verticalAlignment: Text.AlignVCenter - text: modelData.name; + text: modelData.name == '' ? '' : modelData.name; color: "#004275" } - Rectangle{ - color: "white" + TextField { + id: nameEdit visible: main.state == "EDIT" anchors.left: parent.left anchors.leftMargin: 15 - width: nameEdit.width + 4 - height: 22 - TextInput{ - id: nameEdit - anchors.centerIn: parent - text: modelData.name; - color: "#004275" - - onActiveFocusChanged: { - if(!activeFocus){ - //todo other way? - modelData.setName(nameEdit.text); - } - } - onAccepted: { - modelData.setName(nameEdit.text); - } - } + anchors.top: parent.top + anchors.topMargin: (40-nameEdit.height)/2 + text: modelData.name; + placeholderText: 'Enter a name' } Text{ anchors.right: model.left diff --git a/telldus-gui/Plugins/Sensors/sensor.cpp b/telldus-gui/Plugins/Sensors/sensor.cpp index 7a56f46f..d800032a 100644 --- a/telldus-gui/Plugins/Sensors/sensor.cpp +++ b/telldus-gui/Plugins/Sensors/sensor.cpp @@ -46,10 +46,6 @@ void Sensor::setModel(const QString &model) { } QString Sensor::name() const { - //return QString("%1 %2").arg(this->protocol()).arg(this->id()); //TODO: Remove when name is fully implemented - if(d->name == ""){ - return ""; - } return d->name; } From 1e650c7142f7844537be880bdfa4b4229880b6ad Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Fri, 13 Jan 2012 18:22:31 +0100 Subject: [PATCH 15/20] Fix compiling issues for qt-components-desktop on Windows --- .../3rdparty/qt-components-desktop.cmake | 45 +++++++++++-------- telldus-gui/Plugins/QML/CMakeLists.txt | 6 ++- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/telldus-gui/3rdparty/qt-components-desktop.cmake b/telldus-gui/3rdparty/qt-components-desktop.cmake index 3a1d5bd2..5018f34f 100644 --- a/telldus-gui/3rdparty/qt-components-desktop.cmake +++ b/telldus-gui/3rdparty/qt-components-desktop.cmake @@ -10,36 +10,45 @@ FILE(GLOB_RECURSE PNG ${BASE_PATH}/components/*.png) FILE(GLOB_RECURSE QMLDIR ${BASE_PATH}/components/qmldir) SET(EXTRA_FILES ${QML} ${JS} ${PNG} ${QMLDIR}) -QT4_WRAP_CPP( MOC_SRCS ${HDRS} ) -QT4_AUTOMOC ( ${SRCS} ) - -ADD_LIBRARY(styleplugin SHARED - ${SRCS} - ${MOC_SRCS} - ${QMLS} -) -TARGET_LINK_LIBRARIES( styleplugin ${QT_LIBRARIES} ) - - IF (QT_COMPONENTS_OUTPUT_DIR) SET(QT_COMPONENTS_OUTPUT_DIR "${QT_COMPONENTS_OUTPUT_DIR}/QtDesktop") ELSE() SET(QT_COMPONENTS_OUTPUT_DIR "QtDesktop") ENDIF() -SET_TARGET_PROPERTIES(styleplugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${QT_COMPONENTS_OUTPUT_DIR}/plugin -) - STRING(LENGTH "${BASE_PATH}/components" BASE_LENGTH) FOREACH(_FILE ${EXTRA_FILES}) STRING(LENGTH ${_FILE} _FILE_LENGTH) MATH(EXPR _TOP_LENGTH "${_FILE_LENGTH}-${BASE_LENGTH}") STRING(SUBSTRING ${_FILE} ${BASE_LENGTH} ${_TOP_LENGTH} _OUT_FILE) GET_FILENAME_COMPONENT(_FILENAME ${_FILE} NAME) - ADD_CUSTOM_COMMAND( TARGET styleplugin - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${_FILE} ${QT_COMPONENTS_OUTPUT_DIR}${_OUT_FILE} + SET(_OUTFILEPATH ${QT_COMPONENTS_OUTPUT_DIR}${_OUT_FILE}) + LIST(APPEND SRCS ${_OUTFILEPATH}) + ADD_CUSTOM_COMMAND( + OUTPUT ${_OUTFILEPATH} + DEPENDS ${_FILE} + COMMAND ${CMAKE_COMMAND} -E copy ${_FILE} ${_OUTFILEPATH} COMMENT "Copy ${_FILENAME} to destination" ) ENDFOREACH(_FILE) + +QT4_WRAP_CPP( MOC_SRCS ${HDRS} ) +QT4_AUTOMOC ( ${SRCS} ) + +ADD_LIBRARY(styleplugin SHARED + ${SRCS} + ${MOC_SRCS} +) +TARGET_LINK_LIBRARIES( styleplugin ${QT_LIBRARIES} ) + + + +IF (WIN32) + SET_TARGET_PROPERTIES(styleplugin PROPERTIES + PREFIX "Plugins/declarative/QtDesktop/plugin/" + ) +ELSE() + SET_TARGET_PROPERTIES(styleplugin PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${QT_COMPONENTS_OUTPUT_DIR}/plugin + ) +ENDIF() diff --git a/telldus-gui/Plugins/QML/CMakeLists.txt b/telldus-gui/Plugins/QML/CMakeLists.txt index e2fe6a94..719ec69e 100644 --- a/telldus-gui/Plugins/QML/CMakeLists.txt +++ b/telldus-gui/Plugins/QML/CMakeLists.txt @@ -24,5 +24,9 @@ SET( Plugin_PATH "com.telldus.qml" ) INCLUDE( ../TelldusCenterPlugin.cmake NO_POLICY_SCOPE ) -SET(QT_COMPONENTS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/TelldusCenter/Plugins/declarative") +IF (WIN32) + SET(QT_COMPONENTS_OUTPUT_DIR "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/Plugins/declarative") +ELSE() + SET(QT_COMPONENTS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/TelldusCenter/Plugins/declarative") +ENDIF() INCLUDE( ${CMAKE_SOURCE_DIR}/3rdparty/qt-components-desktop.cmake NO_POLICY_SCOPE ) From 9afb2cbbacbc788de8372e6c0a2dd60585f0e947 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Mon, 16 Jan 2012 16:53:29 +0100 Subject: [PATCH 16/20] Fix for building qt-components on Mac OS X. Master branch. --- telldus-gui/3rdparty/qt-components-desktop.cmake | 11 ++++++++--- telldus-gui/Plugins/QML/CMakeLists.txt | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/telldus-gui/3rdparty/qt-components-desktop.cmake b/telldus-gui/3rdparty/qt-components-desktop.cmake index 5018f34f..ff7deaba 100644 --- a/telldus-gui/3rdparty/qt-components-desktop.cmake +++ b/telldus-gui/3rdparty/qt-components-desktop.cmake @@ -35,13 +35,18 @@ ENDFOREACH(_FILE) QT4_WRAP_CPP( MOC_SRCS ${HDRS} ) QT4_AUTOMOC ( ${SRCS} ) +SET(LIBRARIES ${QT_LIBRARIES}) + +IF (APPLE) + FIND_LIBRARY(CARBON_LIBRARY Carbon) + LIST(APPEND LIBRARIES ${CARBON_LIBRARY}) +ENDIF () + ADD_LIBRARY(styleplugin SHARED ${SRCS} ${MOC_SRCS} ) -TARGET_LINK_LIBRARIES( styleplugin ${QT_LIBRARIES} ) - - +TARGET_LINK_LIBRARIES( styleplugin ${LIBRARIES} ) IF (WIN32) SET_TARGET_PROPERTIES(styleplugin PROPERTIES diff --git a/telldus-gui/Plugins/QML/CMakeLists.txt b/telldus-gui/Plugins/QML/CMakeLists.txt index 719ec69e..d008a815 100644 --- a/telldus-gui/Plugins/QML/CMakeLists.txt +++ b/telldus-gui/Plugins/QML/CMakeLists.txt @@ -26,6 +26,8 @@ INCLUDE( ../TelldusCenterPlugin.cmake NO_POLICY_SCOPE ) IF (WIN32) SET(QT_COMPONENTS_OUTPUT_DIR "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/Plugins/declarative") +ELSEIF (APPLE) + SET(QT_COMPONENTS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/TelldusCenter.app/Contents/Plugins/declarative") ELSE() SET(QT_COMPONENTS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/TelldusCenter/Plugins/declarative") ENDIF() From a182ba2111f3fa020edcce1f5e9192dd0ce25c56 Mon Sep 17 00:00:00 2001 From: Stefan Persson Date: Tue, 17 Jan 2012 13:16:10 +0100 Subject: [PATCH 17/20] Delete sensors from model and storage --- telldus-gui/Plugins/QML/qmlarray.cpp | 8 ++++++++ telldus-gui/Plugins/QML/qmlarray.h | 1 + 2 files changed, 9 insertions(+) diff --git a/telldus-gui/Plugins/QML/qmlarray.cpp b/telldus-gui/Plugins/QML/qmlarray.cpp index b36bfac8..8c46d294 100644 --- a/telldus-gui/Plugins/QML/qmlarray.cpp +++ b/telldus-gui/Plugins/QML/qmlarray.cpp @@ -35,6 +35,14 @@ void QMLArray::push(const QScriptValue &v) { endInsertRows(); } +void QMLArray::remove(int index) { + qDebug() << "Count first: " << d->list.count(); + beginRemoveRows( QModelIndex(), index, index ); + d->list.takeAt(index); + endRemoveRows(); + qDebug() << "Count after: " << d->list.size(); +} + int QMLArray::rowCount(const QModelIndex &parent) const { return d->list.size(); } diff --git a/telldus-gui/Plugins/QML/qmlarray.h b/telldus-gui/Plugins/QML/qmlarray.h index 8c29b798..25eb51f8 100644 --- a/telldus-gui/Plugins/QML/qmlarray.h +++ b/telldus-gui/Plugins/QML/qmlarray.h @@ -19,6 +19,7 @@ signals: public slots: void push(const QScriptValue &v); + void remove(int index); QVariant get(int index) const; From 5b3b6699970beabbd1af5f4a45002244dfa42de5 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Tue, 17 Jan 2012 13:20:19 +0100 Subject: [PATCH 18/20] Remove Stefans debug code --- telldus-gui/Plugins/QML/qmlarray.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/telldus-gui/Plugins/QML/qmlarray.cpp b/telldus-gui/Plugins/QML/qmlarray.cpp index 8c46d294..634e7949 100644 --- a/telldus-gui/Plugins/QML/qmlarray.cpp +++ b/telldus-gui/Plugins/QML/qmlarray.cpp @@ -1,7 +1,5 @@ #include "qmlarray.h" -#include - class QMLArray::PrivateData { public: QList list; @@ -36,11 +34,9 @@ void QMLArray::push(const QScriptValue &v) { } void QMLArray::remove(int index) { - qDebug() << "Count first: " << d->list.count(); beginRemoveRows( QModelIndex(), index, index ); d->list.takeAt(index); endRemoveRows(); - qDebug() << "Count after: " << d->list.size(); } int QMLArray::rowCount(const QModelIndex &parent) const { From 5ce0b81e39f7ef7fca38b915ed42b6d3bef1ce91 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Tue, 17 Jan 2012 13:31:01 +0100 Subject: [PATCH 19/20] Add function QMLArray::removeLater() --- telldus-gui/Plugins/QML/qmlarray.cpp | 7 +++++++ telldus-gui/Plugins/QML/qmlarray.h | 1 + 2 files changed, 8 insertions(+) diff --git a/telldus-gui/Plugins/QML/qmlarray.cpp b/telldus-gui/Plugins/QML/qmlarray.cpp index 634e7949..fa306fea 100644 --- a/telldus-gui/Plugins/QML/qmlarray.cpp +++ b/telldus-gui/Plugins/QML/qmlarray.cpp @@ -1,4 +1,5 @@ #include "qmlarray.h" +#include class QMLArray::PrivateData { public: @@ -39,6 +40,12 @@ void QMLArray::remove(int index) { endRemoveRows(); } +void QMLArray::removeLater(int index) { + int methodIndex = this->metaObject()->indexOfMethod(QMetaObject::normalizedSignature("remove(int)")); + QMetaMethod method = this->metaObject()->method(methodIndex); + method.invoke(this, Qt::QueuedConnection, Q_ARG(int, index)); +} + int QMLArray::rowCount(const QModelIndex &parent) const { return d->list.size(); } diff --git a/telldus-gui/Plugins/QML/qmlarray.h b/telldus-gui/Plugins/QML/qmlarray.h index 25eb51f8..d9da42e1 100644 --- a/telldus-gui/Plugins/QML/qmlarray.h +++ b/telldus-gui/Plugins/QML/qmlarray.h @@ -20,6 +20,7 @@ signals: public slots: void push(const QScriptValue &v); void remove(int index); + void removeLater(int index); QVariant get(int index) const; From 645ef2098e00e54a96cbcc13ecd9b504fe64768b Mon Sep 17 00:00:00 2001 From: Stefan Persson Date: Tue, 17 Jan 2012 15:10:46 +0100 Subject: [PATCH 20/20] Sensor save and load from storage, and deletion. Closes #96 --- telldus-gui/Plugins/Sensors/SensorList.qml | 33 +--- telldus-gui/Plugins/Sensors/SensorView.qml | 210 ++++++++++++--------- telldus-gui/Plugins/Sensors/__init__.js | 107 +++++++++-- telldus-gui/Plugins/Sensors/sensor.cpp | 7 +- telldus-gui/Plugins/Sensors/sensor.h | 5 +- telldus-gui/Plugins/Settings/settings.cpp | 4 +- 6 files changed, 237 insertions(+), 129 deletions(-) diff --git a/telldus-gui/Plugins/Sensors/SensorList.qml b/telldus-gui/Plugins/Sensors/SensorList.qml index bd6f03c7..8f6635bd 100644 --- a/telldus-gui/Plugins/Sensors/SensorList.qml +++ b/telldus-gui/Plugins/Sensors/SensorList.qml @@ -5,10 +5,6 @@ Column { id: sensorList spacing: 1 - SensorView { - id: sensorView - } - BorderImage { id: header source: "header_bg.png" @@ -22,6 +18,13 @@ Column { anchors.leftMargin: 15 } HeaderTitle { + text: "" + anchors.right: sensorid.left + visible: main.state == "EDIT" + width: 50 + } + HeaderTitle { + id: sensorid text: "ID" anchors.right: modelTitle.left visible: main.state == "EDIT" @@ -58,7 +61,7 @@ Column { } Repeater { model: sensorModel - delegate: sensorView + delegate: SensorView{ state: main.state == "EDIT" ? 'EDIT' : ''} } Row{ spacing: 20 @@ -71,27 +74,9 @@ Column { main.state = "EDIT" } else{ - main.state ="VIEW" + main.state = "VIEW" } } } - /* - Rectangle { - //TODO should this button exist at all, or always save? - width: 50 - height: 20 - visible: main.state == "EDIT" - Text{ - anchors.centerIn: parent - text: "Cancel" - } - MouseArea{ - anchors.fill: parent - onClicked: { - main.state ="VIEW" - } - } - } - */ } } diff --git a/telldus-gui/Plugins/Sensors/SensorView.qml b/telldus-gui/Plugins/Sensors/SensorView.qml index c0492840..e383c8b3 100644 --- a/telldus-gui/Plugins/Sensors/SensorView.qml +++ b/telldus-gui/Plugins/Sensors/SensorView.qml @@ -1,98 +1,138 @@ import Qt 4.7 import QtDesktop 0.1 -Component { - id: sensorView - Item{ - id: sensorViewItem - visible: main.state == "EDIT" || modelData.showInList - height: childrenRect.height +Item{ + id: sensorViewItem + visible: state == "EDIT" || modelData.showInList + height: childrenRect.height + width: parent ? parent.width : 0 + + states:[ + State { + name: "EDIT" + } + ] + + BorderImage { + source: "row_bg.png" + border.left: 5; border.top: 5 + border.right: 5; border.bottom: 5 + height: sensorInfo.height width: parent.width - property string state: main.state - onStateChanged: { - if (state != "EDIT") { - modelData.setName(nameEdit.text) + Text { + visible: sensorViewItem.state != "EDIT" + anchors.left: parent.left + anchors.leftMargin: 15 + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.name == '' ? '' : modelData.name; + color: "#004275" + } + TextField { + id: nameEdit + visible: sensorViewItem.state == "EDIT" + anchors.left: parent.left + anchors.leftMargin: 15 + anchors.top: parent.top + anchors.topMargin: (40-nameEdit.height)/2 + text: modelData.name; + placeholderText: 'Enter a name' + onTextChanged: modelData.name = text + } + + Text{ + anchors.right: sensorid.left + visible: sensorViewItem.state == "EDIT" + height: 40 + verticalAlignment: Text.AlignVCenter + text: "Delete" + font.underline: true + color: "#004275" + width: 50 + MouseArea{ + anchors.fill: parent + onClicked: { + confirmDeletion.visible = true; + } + } + } + Text{ + id: sensorid + anchors.right: model.left + visible: sensorViewItem.state == "EDIT" + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.id + color: "#004275" + width: 50 + } + Text{ + id: model + anchors.right: visibleinlistcheckbox.left + visible: sensorViewItem.state == "EDIT" + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.model + color: "#004275" + width: 100 + } + Item { + id: visibleinlistcheckbox + height: 40 + width: 100 + anchors.right: sensorInfo.left + CheckBox { + id: checkBox + anchors.centerIn: parent + width: checkBox.height + visible: sensorViewItem.state == "EDIT" + checked: modelData.showInList + onClicked: modelData.setShowInList(!modelData.showInList) } } - BorderImage { - source: "row_bg.png" - border.left: 5; border.top: 5 - border.right: 5; border.bottom: 5 - height: sensorInfo.height - width: parent.width - - Text { - visible: main.state == "VIEW" - anchors.left: parent.left - anchors.leftMargin: 15 - height: 40 - verticalAlignment: Text.AlignVCenter - text: modelData.name == '' ? '' : modelData.name; - color: "#004275" + Column { + id: sensorInfo + anchors.right: parent.right + width: 250 + SensorValue { + visible: modelData.hasTemperature + text: visible ? modelData.sensorValue(1).value + '°C' : '' + icon: "icon_temp.png" + lastUpdated: visible ? modelData.sensorValue(1).lastUpdated : new Date() } - TextField { - id: nameEdit - visible: main.state == "EDIT" - anchors.left: parent.left - anchors.leftMargin: 15 - anchors.top: parent.top - anchors.topMargin: (40-nameEdit.height)/2 - text: modelData.name; - placeholderText: 'Enter a name' - } - Text{ - anchors.right: model.left - visible: main.state == "EDIT" - height: 40 - verticalAlignment: Text.AlignVCenter - text: modelData.id - color: "#004275" - width: 50 - } - Text{ - id: model - anchors.right: visibleinlistcheckbox.left - visible: main.state == "EDIT" - height: 40 - verticalAlignment: Text.AlignVCenter - text: modelData.model - color: "#004275" - width: 100 - } - Item { - id: visibleinlistcheckbox - height: 40 - width: 100 - anchors.right: sensorInfo.left - CheckBox { - id: checkBox - anchors.centerIn: parent - width: checkBox.height - visible: main.state == "EDIT" - checked: modelData.showInList - onClicked: modelData.setShowInList(!modelData.showInList) - } - } - - Column { - id: sensorInfo - anchors.right: parent.right - width: 250 - SensorValue { - visible: modelData.hasTemperature - text: visible ? modelData.sensorValue(1).value + '°C' : '' - icon: "icon_temp.png" - lastUpdated: visible ? modelData.sensorValue(1).lastUpdated : new Date() - } - SensorValue { - visible: modelData.hasHumidity - text: visible ? modelData.sensorValue(2).value + '%' : '' - icon: "icon_humidity.png" - lastUpdated: visible ? modelData.sensorValue(2).lastUpdated : new Date() - } + SensorValue { + visible: modelData.hasHumidity + text: visible ? modelData.sensorValue(2).value + '%' : '' + icon: "icon_humidity.png" + lastUpdated: visible ? modelData.sensorValue(2).lastUpdated : new Date() } } } + + Dialog{ + id: confirmDeletion + modal: true + title: "Confirm deletion" + Text{ + id: descriptionHeadline + text:"Delete this sensor?" + font.bold: true + } + Text{ + id: descriptionText + anchors.top: descriptionHeadline.bottom + anchors.topMargin: 10 + width: parent.width - 20 + anchors.left: parent.left + anchors.leftMargin: 10 + text: "Please note that a sensor that is still transmitting will reappear here again, but it will be hidden in the list by default." + wrapMode: Text.Wrap + } + + onAccepted: { + deleteSensor.callWith(modelData.protocol, modelData.model, modelData.id); + } + } } diff --git a/telldus-gui/Plugins/Sensors/__init__.js b/telldus-gui/Plugins/Sensors/__init__.js index 70283e2b..b2a36c73 100644 --- a/telldus-gui/Plugins/Sensors/__init__.js +++ b/telldus-gui/Plugins/Sensors/__init__.js @@ -6,10 +6,13 @@ __postInit__ = function() { } com.telldus.sensors = function() { - var sensorList = new com.telldus.qml.array(); - + var sensorList; function init() { var sensorData = 0; + sensorList = loadSensorModel(); + sensorList.rowsRemoved.connect(function(){saveSensorModel();}); + sensorList.rowsInserted.connect(function(){saveSensorModel();}); + while(sensorData = com.telldus.core.sensor()) { var p = sensorData["protocol"]; var m = sensorData["model"]; @@ -19,7 +22,7 @@ com.telldus.sensors = function() { var tryFetchValue = function(p, m, id, types, type) { if (types & type) { sensorValue = com.telldus.core.sensorValue(p, m, id, type); - sensorEvent(p, m, id, type, sensorValue["value"], sensorValue["timestamp"]); + sensorEvent(p, m, id, type, sensorValue["value"], sensorValue["timestamp"], true); } } tryFetchValue(p, m, id, types, com.telldus.core.TELLSTICK_TEMPERATURE); @@ -28,14 +31,94 @@ com.telldus.sensors = function() { } com.telldus.core.sensorEvent.connect(sensorEvent); - view = new com.telldus.qml.view({}); + view = new com.telldus.qml.view({ + deleteSensor: deleteSensor + }); view.setProperty('sensorModel', sensorList); + saveSensorModel(); view.load("main.qml"); application.addWidget("sensors.gui", "icon.png", view); } - function sensorEvent(protocol, model, id, dataType, value, timestamp) { + function createSensor(protocol, model, id, name, showInList){ + var sensor = new com.telldus.sensors.sensor(); + sensor.protocol = protocol; + sensor.model = model; + sensor.id = id; + sensor.name = name; + sensor.nameChanged.connect(function() { saveSensorModel(); }); + sensor.showInList = showInList; + sensor.showInListChanged.connect(function() { saveSensorModel(); }); + return sensor; + } + + function deleteSensor(protocol, model, id){ + var i = 0; + var found = false; + for (; i < sensorList.length; ++i) { + if (sensorList.get(i).protocol != protocol) { + continue; + } + if (sensorList.get(i).model != model) { + continue; + } + if (sensorList.get(i).id != id) { + continue; + } + found = true; + break; + } + if(found){ + sensorList.removeLater(i); + } + } + + function loadSensorModel(){ + var settings = new com.telldus.settings(); + var sensors = new com.telldus.qml.array(); + + var sensorProperties = settings.value("sensors", ""); + if(sensorProperties){ + for (var i = 0; i < sensorProperties.length; i++) { + var sensor = createSensor(sensorProperties[i].protocol, sensorProperties[i].model, sensorProperties[i].id, sensorProperties[i].name, sensorProperties[i].showInList=="true"); + for (var j = 0; j < sensorProperties[i].values.length; j++) { + sensor.setValue(sensorProperties[i].values[j].type, sensorProperties[i].values[j].value, sensorProperties[i].values[j].lastUpdated) + } + sensors.push(sensor); + } + } + return sensors; + } + + function saveSensorModel(){ + var settings = new com.telldus.settings(); + var sensorProperties = new Array(); + + for (var i = 0; i < sensorList.length; ++i) { + var sensor = sensorList.get(i); + + var allValues = new Array(); + if(sensor.hasHumidity){ + var sensorValue = sensor.sensorValue(com.telldus.core.TELLSTICK_HUMIDITY); + var value = {type: com.telldus.core.TELLSTICK_HUMIDITY, lastUpdated: sensorValue.lastUpdated, value: sensorValue.value}; + allValues.push(value); + } + if(sensor.hasTemperature){ + var sensorValue = sensor.sensorValue(com.telldus.core.TELLSTICK_TEMPERATURE); + var value = {type: com.telldus.core.TELLSTICK_TEMPERATURE, lastUpdated: sensorValue.lastUpdated, value: sensorValue.value}; + allValues.push(value); + } + + var sensorProp = {protocol:sensor.protocol, model:sensor.model, id:sensor.id, values:allValues, name:sensor.name, showInList:sensor.showInList}; + sensorProperties.push(sensorProp); + } + + settings.setValue("sensors", sensorProperties); + } + + function sensorEvent(protocol, model, id, dataType, value, timestamp, avoidSave) { + var sensor = 0; for (var i = 0; i < sensorList.length; ++i) { if (sensorList.get(i).protocol != protocol) { @@ -52,19 +135,15 @@ com.telldus.sensors = function() { } if (!sensor) { - sensor = new com.telldus.sensors.sensor(); - sensor.protocol = protocol; - sensor.model = model; - sensor.id = id; - sensor.showInList = false; + sensor = createSensor(protocol, model, id, "", false); sensorList.push(sensor); - print("Create new"); - } else { - print("Update"); } - print("Sensor event", protocol, model, id, dataType, value, timestamp); sensor.setValue(dataType, value, timestamp); + + if(!avoidSave){ + saveSensorModel(); + } } return { //Public functions diff --git a/telldus-gui/Plugins/Sensors/sensor.cpp b/telldus-gui/Plugins/Sensors/sensor.cpp index d800032a..1ba7d76f 100644 --- a/telldus-gui/Plugins/Sensors/sensor.cpp +++ b/telldus-gui/Plugins/Sensors/sensor.cpp @@ -17,6 +17,7 @@ Sensor::Sensor(QObject *parent) : { d = new PrivateData; d->id = 0; + d->showInList = false; } Sensor::~Sensor() { @@ -50,6 +51,9 @@ QString Sensor::name() const { } void Sensor::setName(const QString &name) { + if (name == d->name) { + return; + } d->name = name; emit nameChanged(); } @@ -67,7 +71,7 @@ bool Sensor::hasTemperature() const { return d->values.contains(TELLSTICK_TEMPERATURE); } -SensorValue * Sensor::sensorValue(int type) { +QObject * Sensor::sensorValue(int type) { return (d->values.contains(type) ? d->values[type] : 0); } @@ -90,7 +94,6 @@ void Sensor::setValue(int type, const QString &value, const QDateTime ×tamp } bool Sensor::showInList() const{ - //TODO showInList and name must be persistent... return d->showInList; } diff --git a/telldus-gui/Plugins/Sensors/sensor.h b/telldus-gui/Plugins/Sensors/sensor.h index 85164246..6683e305 100644 --- a/telldus-gui/Plugins/Sensors/sensor.h +++ b/telldus-gui/Plugins/Sensors/sensor.h @@ -17,7 +17,7 @@ class Sensor : public QObject Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString protocol READ protocol WRITE setProtocol NOTIFY protocolChanged) - Q_PROPERTY(bool showInList READ showInList NOTIFY showInListChanged) + Q_PROPERTY(bool showInList READ showInList WRITE setShowInList NOTIFY showInListChanged) public: explicit Sensor(QObject *parent = 0); @@ -32,7 +32,6 @@ public: void setModel(const QString &model); QString name() const; - //void setName(const QString &name); QString protocol() const; void setProtocol(const QString &protocol); @@ -40,7 +39,7 @@ public: bool hasTemperature() const; bool showInList() const; - Q_INVOKABLE SensorValue *sensorValue(int type); + Q_INVOKABLE QObject *sensorValue(int type); Q_INVOKABLE void setValue(int type, const QString &value, const QDateTime ×tamp); Q_INVOKABLE void setName(const QString &name); Q_INVOKABLE void setShowInList(bool show); diff --git a/telldus-gui/Plugins/Settings/settings.cpp b/telldus-gui/Plugins/Settings/settings.cpp index d0f7097b..85ae12ff 100644 --- a/telldus-gui/Plugins/Settings/settings.cpp +++ b/telldus-gui/Plugins/Settings/settings.cpp @@ -26,10 +26,12 @@ void Settings::setValue( const QString & key, const QVariant & value ) { d->s.beginGroup(key); d->s.setValue("size", list.size()); d->s.setValue("type", "array"); + //d->s.beginWriteArray("list"); //TODO write or read? What prefix? for (int i = 0; i < list.size(); ++i) { - d->s.setArrayIndex(i); + //d->s.setArrayIndex(i); this->setValue(QString::number(i), list.at(i)); } + //d->s.endArray(); d->s.endGroup(); } else if (value.type() == QVariant::Map) {