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
import QtQuick 2.3
import QtQuick.Controls 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
Flow {
spacing: ScreenTools.defaultFontPixelWidth
/// true: Checking the first entry will clear and disable all other entries
property bool firstEntryIsAll: false
property Fact fact: Fact { }
Component.onCompleted: {
if (firstEntryIsAll && repeater.itemAt(0).checked) {
for (var i=1; i<repeater.count; i++) {
var otherCheckbox = repeater.itemAt(i)
otherCheckbox.enabled = false
}
}
}
Repeater {
id: repeater
model: fact ? fact.bitmaskStrings : []
QGCCheckBox {
id: checkbox
text: modelData
checked: fact.value & fact.bitmaskValues[index]
onClicked: {
var i;
var otherCheckbox;
if (checked) {
if (firstEntryIsAll && index == 0) {
for (i = 1; i < repeater.count; i++) {
otherCheckbox = repeater.itemAt(i)
fact.value &= ~fact.bitmaskValues[i]
otherCheckbox.checked = false
otherCheckbox.enabled = false
}
}
fact.value |= fact.bitmaskValues[index]
} else {
if (firstEntryIsAll && index == 0) {
for (i = 1; i < repeater.count; i++) {
otherCheckbox = repeater.itemAt(i)
otherCheckbox.enabled = true
}
}
fact.value &= ~fact.bitmaskValues[index]
}
}
}
}
}