Allow to delete accounts that are not last in the list
This commit is contained in:
parent
bdc75e1cea
commit
b29e3867e8
3 changed files with 30 additions and 12 deletions
|
@ -27,12 +27,6 @@ ApplicationWindow
|
|||
defaultValue: []
|
||||
onValueChanged: {
|
||||
nextcloudAccounts.model = value
|
||||
console.log("IDs changed: " + value)
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
console.log("Account " + i + i === appSettings.currentAccount ? " (current)" : "")
|
||||
console.log(" - " + nextcloudAccounts.itemAt(i).name)
|
||||
console.log(" - " + nextcloudAccounts.itemAt(i).username + "@" + nextcloudAccounts.itemAt(i).server)
|
||||
}
|
||||
}
|
||||
Component.onCompleted: nextcloudAccounts.model = value
|
||||
}
|
||||
|
@ -46,6 +40,20 @@ ApplicationWindow
|
|||
function add() {
|
||||
push(uuidv4())
|
||||
}
|
||||
function remove(uuid) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
if (itemAt(i).uuid === uuid) {
|
||||
itemAt(i).clear()
|
||||
}
|
||||
}
|
||||
var newIds = [ ]
|
||||
nextcloudUUIDs.value.forEach(function(currentValue) {
|
||||
if (currentValue !== uuid) {
|
||||
newIds.push(currentValue)
|
||||
}
|
||||
})
|
||||
nextcloudUUIDs.value = newIds
|
||||
}
|
||||
function push(uuid) {
|
||||
var accountIDs = nextcloudUUIDs.value
|
||||
accountIDs.push(uuid)
|
||||
|
|
|
@ -59,6 +59,7 @@ Page {
|
|||
}
|
||||
|
||||
header: PageHeader {
|
||||
height: searchField.height + description.height
|
||||
SearchField {
|
||||
id: searchField
|
||||
width: parent.width
|
||||
|
@ -67,10 +68,18 @@ Page {
|
|||
EnterKey.onClicked: focus = false
|
||||
onTextChanged: nextcloudAccounts.itemAt(appSettings.currentAccount).search(text.toLowerCase())
|
||||
}
|
||||
//title: nextcloudAccounts.itemAt(appSettings.currentAccount).name //qsTr("Nextclound Notes")
|
||||
description: searchField.text === "" ? nextcloudAccounts.itemAt(appSettings.currentAccount).username + "@" + nextcloudAccounts.itemAt(appSettings.currentAccount).server :
|
||||
Label {
|
||||
id: description
|
||||
x: Theme.horizontalPageMargin
|
||||
width: parent.width - 2*x
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: Theme.paddingMedium
|
||||
color: Theme.secondaryHighlightColor
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
text: searchField.text === "" ? nextcloudAccounts.itemAt(appSettings.currentAccount).username + "@" + nextcloudAccounts.itemAt(appSettings.currentAccount).server :
|
||||
searchField.placeholderText
|
||||
}
|
||||
}
|
||||
|
||||
currentIndex: -1
|
||||
|
||||
|
|
|
@ -65,12 +65,13 @@ Page {
|
|||
}
|
||||
}
|
||||
MenuItem {
|
||||
visible: index === nextcloudAccounts.count-1
|
||||
text: qsTr("Delete")
|
||||
onClicked: {
|
||||
accountListItem.remorseAction(qsTr("Deleting account"), function() {
|
||||
nextcloudAccounts.itemAt(index).clear()
|
||||
nextcloudAccounts.pop()
|
||||
console.log("Deleting " + nextcloudAccounts.itemAt(index).uuid)
|
||||
nextcloudAccounts.remove(nextcloudAccounts.itemAt(index).uuid)
|
||||
//nextcloudAccounts.itemAt(index).clear()
|
||||
//nextcloudAccounts.pop()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue