import QtQuick 2.0
import "components"
import Explorer 1.0
ApplicationWindow {
id: mainWnd
SensorExplorer {
id: explorer
}
SensorList {
id: sensorList
anchors.top: parent.top
anchors.topMargin: 20
anchors.left: parent.left
anchors.right: parent.right
height: 170
title: "sensor explorer"
listmodel: explorer.availableSensors
onSelectedItemChanged: {
explorer.selectedSensorItem = sensorList.selectedItem;
startstopButton.text=(explorer.selectedSensorItem !== null ?
(explorer.selectedSensorItem.start === true ? "Stop" : "Start") : "Start")
if (sensorList.selectedItem !== null)
propertyList.listmodel = sensorList.selectedItem.properties;
}
}
Rectangle {
id: listSplitLine
anchors.top: sensorList.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 5
anchors.rightMargin: 5
height: 1
border.width: 1
border.color: "#999999"
}
PropertyList {
id: propertyList
anchors.top: listSplitLine.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: listPropertyEndLine.top
anchors.bottomMargin: 5
onSelectedItemChanged: {
textfield.enabled = (propertyList.selectedItem === null ?
false : propertyList.selectedItem.isWriteable);
}
}
Rectangle {
id: listPropertyEndLine
anchors.bottom: startstopButton.top
anchors.bottomMargin: 5
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 5
anchors.rightMargin: 5
height: 1
border.width: 1
border.color: "#999999"
}
Button {
id: startstopButton
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.margins: 5
text: (explorer.selectedSensorItem !== null ?
(explorer.selectedSensorItem.start === true ? "Stop" : "Start") : "Start")
enabled: true
height: 30
width: 80
onClicked: {
if (explorer.selectedSensorItem !== null) {
if (text === "Start") {
explorer.selectedSensorItem.start = true;
text = "Stop";
}
else {
explorer.selectedSensorItem.start = false;
text = "Start";
}
}
textfield.text = "";
}
}
TextField {
id: textfield
anchors.top: parent.bottom
anchors.topMargin: -35
anchors.left: startstopButton.right
anchors.right: parent.right
anchors.margins: 5
height: 30
enabled: false
onEnabledChanged: {
if (!textfield.enabled) {
textfield.closeSoftwareInputPanel();
textfield.anchors.top= parent.bottom;
textfield.anchors.topMargin= -35;
textfield.text = "";
}
}
onFocusChanged: {
if (textfield.focus) {
textfield.anchors.top= sensorList.bottom
textfield.anchors.topMargin= -15
}
else {
textfield.closeSoftwareInputPanel();
textfield.anchors.top= parent.bottom;
textfield.anchors.topMargin= -35;
}
}
onAccepted: {
if (explorer.selectedSensorItem !== null
&& propertyList.selectedItem !== null) {
explorer.selectedSensorItem.changePropertyValue(propertyList.selectedItem, textfield.text);
propertyList.focus=true;
}
textfield.text = "";
}
}
}