Quick GUI: Fix handling last row of FieldModel

This commit is contained in:
Marius Kittler 2018-11-22 22:03:42 +01:00
parent e197b8d8e5
commit a69a91d47e
1 changed files with 8 additions and 8 deletions

View File

@ -79,7 +79,7 @@ Kirigami.ScrollablePage {
id: fieldsListItem id: fieldsListItem
contentItem: RowLayout { contentItem: RowLayout {
id: fieldRow id: fieldRow
property bool isLastRow: model.isPassword === undefined readonly property bool isLast: model.isLastRow
Kirigami.ListItemDragHandle { Kirigami.ListItemDragHandle {
listItem: fieldsListItem listItem: fieldsListItem
@ -89,7 +89,7 @@ Kirigami.ScrollablePage {
oldIndex, 1, oldIndex, 1,
fieldsListView.model.index(-1, 0), fieldsListView.model.index(-1, 0),
newIndex) newIndex)
opacity: fieldRow.isLastRow ? 0 : 100 opacity: fieldRow.isLast ? 0 : 100
} }
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
@ -100,7 +100,7 @@ Kirigami.ScrollablePage {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
text: { text: {
if (fieldRow.isLastRow) { if (fieldRow.isLast) {
return qsTr("click to append new field") return qsTr("click to append new field")
} }
@ -113,7 +113,7 @@ Kirigami.ScrollablePage {
} }
return pieces.join(": ") return pieces.join(": ")
} }
color: fieldRow.isLastRow ? "gray" : palette.text color: fieldRow.isLast ? "gray" : palette.text
} }
} }
MouseArea { MouseArea {
@ -172,7 +172,7 @@ Kirigami.ScrollablePage {
onTriggered: fieldsListView.model.setData( onTriggered: fieldsListView.model.setData(
fieldsListView.model.index(index, 0), fieldsListView.model.index(index, 0),
model.isPassword ? 0 : 1, 0x0100 + 1) model.isPassword ? 0 : 1, 0x0100 + 1)
visible: !fieldRow.isLastRow visible: !fieldRow.isLast
}, },
Kirigami.Action { Kirigami.Action {
iconName: "edit-copy" iconName: "edit-copy"
@ -183,21 +183,21 @@ Kirigami.ScrollablePage {
model.actualValue) ? qsTr("Copied") : qsTr( model.actualValue) ? qsTr("Copied") : qsTr(
"Unable to access clipboard")) "Unable to access clipboard"))
shortcut: StandardKey.Cut shortcut: StandardKey.Cut
visible: !fieldRow.isLastRow visible: !fieldRow.isLast
}, },
Kirigami.Action { Kirigami.Action {
iconName: "edit-delete" iconName: "edit-delete"
text: qsTr("Delete field") text: qsTr("Delete field")
onTriggered: fieldsListView.model.removeRows(index, 1) onTriggered: fieldsListView.model.removeRows(index, 1)
shortcut: StandardKey.Delete shortcut: StandardKey.Delete
visible: !fieldRow.isLastRow visible: !fieldRow.isLast
}, },
Kirigami.Action { Kirigami.Action {
iconName: "list-add" iconName: "list-add"
text: qsTr("Insert empty field after this") text: qsTr("Insert empty field after this")
enabled: !nativeInterface.hasEntryFilter enabled: !nativeInterface.hasEntryFilter
onTriggered: fieldsListView.model.insertRows(index + 1, 1) onTriggered: fieldsListView.model.insertRows(index + 1, 1)
visible: !fieldRow.isLastRow visible: !fieldRow.isLast
} }
] ]
} }