Convert the textbox to qt-components as well
This commit is contained in:
parent
64e2b354af
commit
99c2b0e158
2 changed files with 14 additions and 25 deletions
|
@ -9,6 +9,13 @@ Component {
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
|
property string state: main.state
|
||||||
|
onStateChanged: {
|
||||||
|
if (state != "EDIT") {
|
||||||
|
modelData.setName(nameEdit.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BorderImage {
|
BorderImage {
|
||||||
source: "row_bg.png"
|
source: "row_bg.png"
|
||||||
border.left: 5; border.top: 5
|
border.left: 5; border.top: 5
|
||||||
|
@ -22,32 +29,18 @@ Component {
|
||||||
anchors.leftMargin: 15
|
anchors.leftMargin: 15
|
||||||
height: 40
|
height: 40
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
text: modelData.name;
|
text: modelData.name == '' ? '<unnamed>' : modelData.name;
|
||||||
color: "#004275"
|
color: "#004275"
|
||||||
}
|
}
|
||||||
Rectangle{
|
TextField {
|
||||||
color: "white"
|
id: nameEdit
|
||||||
visible: main.state == "EDIT"
|
visible: main.state == "EDIT"
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 15
|
anchors.leftMargin: 15
|
||||||
width: nameEdit.width + 4
|
anchors.top: parent.top
|
||||||
height: 22
|
anchors.topMargin: (40-nameEdit.height)/2
|
||||||
TextInput{
|
text: modelData.name;
|
||||||
id: nameEdit
|
placeholderText: 'Enter a name'
|
||||||
anchors.centerIn: parent
|
|
||||||
text: modelData.name;
|
|
||||||
color: "#004275"
|
|
||||||
|
|
||||||
onActiveFocusChanged: {
|
|
||||||
if(!activeFocus){
|
|
||||||
//todo other way?
|
|
||||||
modelData.setName(nameEdit.text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onAccepted: {
|
|
||||||
modelData.setName(nameEdit.text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Text{
|
Text{
|
||||||
anchors.right: model.left
|
anchors.right: model.left
|
||||||
|
|
|
@ -46,10 +46,6 @@ void Sensor::setModel(const QString &model) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Sensor::name() const {
|
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 "<unnamed>";
|
|
||||||
}
|
|
||||||
return d->name;
|
return d->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue