From df5e08ff9c47c199049f2337edc41480f90d3bff Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Thu, 12 Jan 2012 17:30:23 +0100 Subject: [PATCH] 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