QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FactBitmask.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3
4import QGroundControl
5import QGroundControl.Controls
6
7Flow {
8 spacing: ScreenTools.defaultFontPixelWidth
9
10 /// true: Checking the first entry will clear and disable all other entries
11 property bool firstEntryIsAll: false
12
13 property Fact fact: Fact { }
14
15 Component.onCompleted: {
16 if (firstEntryIsAll && repeater.itemAt(0).checked) {
17 for (var i=1; i<repeater.count; i++) {
18 var otherCheckbox = repeater.itemAt(i)
19 otherCheckbox.enabled = false
20 }
21 }
22 }
23
24 Repeater {
25 id: repeater
26 model: fact ? fact.bitmaskStrings : []
27
28 QGCCheckBox {
29 id: checkbox
30 text: modelData
31 checked: fact.value & fact.bitmaskValues[index]
32
33 onClicked: {
34 var i;
35 var otherCheckbox;
36 if (checked) {
37 if (firstEntryIsAll && index == 0) {
38 for (i = 1; i < repeater.count; i++) {
39 otherCheckbox = repeater.itemAt(i)
40 fact.value &= ~fact.bitmaskValues[i]
41 otherCheckbox.checked = false
42 otherCheckbox.enabled = false
43 }
44 }
45 fact.value |= fact.bitmaskValues[index]
46 } else {
47 if (firstEntryIsAll && index == 0) {
48 for (i = 1; i < repeater.count; i++) {
49 otherCheckbox = repeater.itemAt(i)
50 otherCheckbox.enabled = true
51 }
52 }
53 fact.value &= ~fact.bitmaskValues[index]
54 }
55 }
56 }
57 }
58}