kcms/rules: Some QML clean-ups
- Remove unnecessary bindings to enabled: Properties that are not enabled are not shown in the list anyway, and it fixes QML warnings: RuleItemDelegate.qml:16:5: Unable to assign [undefined] to bool RuleItemDelegate.qml:93:17: Unable to assign [undefined] to bool - Remove unnecessary colorSet - Port away from javascript `var` - Remove outdated comment
This commit is contained in:
parent
0bd722e84b
commit
ac5c175ade
4 changed files with 8 additions and 16 deletions
|
@ -13,10 +13,6 @@ import org.kde.kcmutils as KCM
|
|||
QQC2.ItemDelegate {
|
||||
id: ruleDelegate
|
||||
|
||||
property bool ruleEnabled: model.enabled
|
||||
|
||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||
|
||||
width: ListView.view.width
|
||||
highlighted: false
|
||||
hoverEnabled: false
|
||||
|
@ -76,7 +72,6 @@ QQC2.ItemDelegate {
|
|||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
visible: count > 0
|
||||
enabled: ruleEnabled
|
||||
|
||||
model: policyModel
|
||||
onActivated: {
|
||||
|
@ -90,8 +85,6 @@ QQC2.ItemDelegate {
|
|||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
|
||||
|
||||
enabled: model.enabled
|
||||
|
||||
ruleValue: model.value
|
||||
ruleOptions: model.options
|
||||
controlType: model.type
|
||||
|
|
|
@ -297,7 +297,7 @@ KCM.ScrollViewKCM {
|
|||
case RuleItem.Option:
|
||||
return options.textOfValue(value);
|
||||
case RuleItem.NetTypes:
|
||||
var selectedValue = value.toString(2).length - 1;
|
||||
const selectedValue = value.toString(2).length - 1;
|
||||
return options.textOfValue(selectedValue);
|
||||
case RuleItem.OptionList:
|
||||
return Array.from(value, item => options.textOfValue(item) ).join(", ");
|
||||
|
@ -309,7 +309,7 @@ KCM.ScrollViewKCM {
|
|||
id: enabledRulesModel
|
||||
sourceModel: kcm.rulesModel
|
||||
filterRowCallback: (source_row, source_parent) => {
|
||||
var index = sourceModel.index(source_row, 0, source_parent);
|
||||
const index = sourceModel.index(source_row, 0, source_parent);
|
||||
return sourceModel.data(index, RulesModel.EnabledRole);
|
||||
}
|
||||
}
|
||||
|
@ -325,13 +325,13 @@ KCM.ScrollViewKCM {
|
|||
|
||||
filterString: searchField.text.trim().toLowerCase()
|
||||
filterRowCallback: (source_row, source_parent) => {
|
||||
var index = sourceModel.index(source_row, 0, source_parent);
|
||||
const index = sourceModel.index(source_row, 0, source_parent);
|
||||
|
||||
var hasSuggestion = sourceModel.data(index, RulesModel.SuggestedValueRole) != null;
|
||||
var isOptional = sourceModel.data(index, RulesModel.SelectableRole);
|
||||
var isEnabled = sourceModel.data(index, RulesModel.EnabledRole);
|
||||
const hasSuggestion = sourceModel.data(index, RulesModel.SuggestedValueRole) != null;
|
||||
const isOptional = sourceModel.data(index, RulesModel.SelectableRole);
|
||||
const isEnabled = sourceModel.data(index, RulesModel.EnabledRole);
|
||||
|
||||
var showItem = hasSuggestion || (!onlySuggestions && isOptional && !isEnabled);
|
||||
const showItem = hasSuggestion || (!onlySuggestions && isOptional && !isEnabled);
|
||||
|
||||
if (!showItem) {
|
||||
return false;
|
||||
|
|
|
@ -124,7 +124,7 @@ Loader {
|
|||
multipleChoice: true
|
||||
|
||||
onActivated: {
|
||||
let selectionList = []
|
||||
const selectionList = []
|
||||
for (let i = 0; i < count; i++) {
|
||||
if (selectionMask & (1 << i)) {
|
||||
selectionList.push(model.data(model.index(i,0), Qt.UserRole))
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.kde.kirigami 2.12 as Kirigami
|
|||
KCM.ScrollViewKCM {
|
||||
id: rulesListKCM
|
||||
|
||||
// FIXME: ScrollViewKCM.qml:73:13: QML Control: Binding loop detected for property "implicitHeight"
|
||||
implicitWidth: Kirigami.Units.gridUnit * 35
|
||||
implicitHeight: Kirigami.Units.gridUnit * 35
|
||||
|
||||
|
|
Loading…
Reference in a new issue