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: []
|
defaultValue: []
|
||||||
onValueChanged: {
|
onValueChanged: {
|
||||||
nextcloudAccounts.model = value
|
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
|
Component.onCompleted: nextcloudAccounts.model = value
|
||||||
}
|
}
|
||||||
|
@ -46,6 +40,20 @@ ApplicationWindow
|
||||||
function add() {
|
function add() {
|
||||||
push(uuidv4())
|
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) {
|
function push(uuid) {
|
||||||
var accountIDs = nextcloudUUIDs.value
|
var accountIDs = nextcloudUUIDs.value
|
||||||
accountIDs.push(uuid)
|
accountIDs.push(uuid)
|
||||||
|
|
|
@ -59,6 +59,7 @@ Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
header: PageHeader {
|
header: PageHeader {
|
||||||
|
height: searchField.height + description.height
|
||||||
SearchField {
|
SearchField {
|
||||||
id: searchField
|
id: searchField
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -67,9 +68,17 @@ Page {
|
||||||
EnterKey.onClicked: focus = false
|
EnterKey.onClicked: focus = false
|
||||||
onTextChanged: nextcloudAccounts.itemAt(appSettings.currentAccount).search(text.toLowerCase())
|
onTextChanged: nextcloudAccounts.itemAt(appSettings.currentAccount).search(text.toLowerCase())
|
||||||
}
|
}
|
||||||
//title: nextcloudAccounts.itemAt(appSettings.currentAccount).name //qsTr("Nextclound Notes")
|
Label {
|
||||||
description: searchField.text === "" ? nextcloudAccounts.itemAt(appSettings.currentAccount).username + "@" + nextcloudAccounts.itemAt(appSettings.currentAccount).server :
|
id: description
|
||||||
searchField.placeholderText
|
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
|
currentIndex: -1
|
||||||
|
|
|
@ -65,12 +65,13 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
visible: index === nextcloudAccounts.count-1
|
|
||||||
text: qsTr("Delete")
|
text: qsTr("Delete")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
accountListItem.remorseAction(qsTr("Deleting account"), function() {
|
accountListItem.remorseAction(qsTr("Deleting account"), function() {
|
||||||
nextcloudAccounts.itemAt(index).clear()
|
console.log("Deleting " + nextcloudAccounts.itemAt(index).uuid)
|
||||||
nextcloudAccounts.pop()
|
nextcloudAccounts.remove(nextcloudAccounts.itemAt(index).uuid)
|
||||||
|
//nextcloudAccounts.itemAt(index).clear()
|
||||||
|
//nextcloudAccounts.pop()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue