This repository has been archived by the owner on Feb 28, 2019. It is now read-only.
forked from zhangh94/MAQSS_GCS
-
Notifications
You must be signed in to change notification settings - Fork 3
/
VehicleStatus.qml
164 lines (137 loc) · 4.7 KB
/
VehicleStatus.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import XbeeInterfaceClass 1.0
Rectangle {
property int vehicleStatusPadding: 10
property string title: "Vehicle Monitor"
property bool titleBold: true
property int titleFontSize: 13
property var labels: ["Vehicle","Status","Role"]
property bool labelBold: true
property int labelFontSize: 12
property int vehicleFontSize: 12
property bool roleCheckable: true
signal updateStatus(bool update)
id: vehicleStatusBox
TextField {
id: vehicleStatusTitle
anchors {
top: vehicleStatusBox.top
left: vehicleStatusBox.left
}
background: Rectangle {
implicitWidth: vehicleStatusBox.width
implicitHeight: vehicleStatusBox.height/6
color: "transparent"
border.color: "transparent"
}
text: title
font {
bold: titleBold
pointSize: titleFontSize
}
readOnly: true
selectByMouse: false
}
onUpdateStatus: {
var i1 = 0
// create new ListElements if they dont exist
while (vehicleModel.count < quadcopters.length) {
vehicleModel.append({name: quadcopters[i1].name, status: quadcopters[i1].status})
}
// update vehicle status display
for (i1 = 0; i1< quadcopters.length; i1++ ) {
vehicleModel.set(i1, {name: quadcopters[i1].name, status: quadcopters[i1].status, role: quadcopters[i1].roles[quadcopters[i1].role]});
vehicleModel.setProperty(i1, "vehicleID", quadcopters[i1].idNumber);
}
}
TextField {
id: vehicleStatusLabels
anchors {
top: vehicleStatusTitle.bottom
left: vehicleStatusBox.left
}
background: Rectangle {
implicitWidth: vehicleStatusBox.width
implicitHeight: vehicleStatusBox.height/8
color: "transparent"
border.color: "transparent"
}
text: labels[0] + " \t" + labels[1] + " \t" + labels[2]
font {
bold: labelBold
pointSize: labelFontSize
}
readOnly: true
selectByMouse: false
}
ListModel {
id: vehicleModel
}
Component {
id: vehicleComponent
Item {
// these arent getting set properly?
property int indexOfThisDelegate: index
property int vehicleID
Text {
id: statusText
text: name + " \t" + status + " \t"
font {
pointSize: vehicleFontSize
}
}
Button {
id: roleToggle
state: "Quick"
anchors {
left: statusText.right
}
text: role
height: statusText.height
highlighted: false
checkable: vehicleStatusBox.roleCheckable
states: [
State {
name: "Detailed"; when: roleToggle.checked
PropertyChanges {target:roleToggle; text: qsTr("Detailed")}
},
State {
name: "Quick"; when: !roleToggle.checked
PropertyChanges {target:roleToggle; text: qsTr("Quick")}
}
]
onClicked: {
if (roleToggle.state === "Detailed") {
console.log(index)
quadcopters[index].role = 1;
console.log("Set Vehicle ID: ", quadcopters[index].idNumber, " at ndx: ", index, ", role: ", quadcopters[index].role)
console.log(roleToggle.state)
}
else {
quadcopters[index].role = 0;
console.log("Set Vehicle ID: ", vehicleID, quadcopters[index].role)
console.log(roleToggle.state)
}
if (vehicleStatusBox.roleCheckable) {
XbeeInterface.writeMsg("NEWMSG,ROLE,Q" + quadcopters[index].idNumber + ",R" + quadcopters[index].role,quadcopters[index].idNumber)
}
}
}
height: roleToggle.height
}
}
ListView {
id: vehicleStatusList
anchors {
top: vehicleStatusLabels.bottom
left: vehicleStatusLabels.left
leftMargin: vehicleStatusPadding
bottom: vehicleStatusBox.bottom
}
model: vehicleModel
delegate: vehicleComponent
spacing: 4
}
}