diff --git a/qml/harbour-nextcloudnotes.qml b/qml/harbour-nextcloudnotes.qml index 28d0b4d..ba31e16 100644 --- a/qml/harbour-nextcloudnotes.qml +++ b/qml/harbour-nextcloudnotes.qml @@ -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) diff --git a/qml/pages/NotesPage.qml b/qml/pages/NotesPage.qml index 9220592..a01ae80 100644 --- a/qml/pages/NotesPage.qml +++ b/qml/pages/NotesPage.qml @@ -59,6 +59,7 @@ Page { } header: PageHeader { + height: searchField.height + description.height SearchField { id: searchField width: parent.width @@ -67,9 +68,17 @@ 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 : - searchField.placeholderText + 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 diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index 7fbfbe9..3019ad8 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -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() }) } }