diff --git a/README.md b/README.md index d3bd974..39b7658 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ You can preview some screenshots [here](https://www.scharel.name/harbour/nextclo - Show the content of the notes - Basic [Markdown](https://en.wikipedia.org/wiki/Markdown) rendering - Edit the notes content +- Create new notes +- Delete notes - Edit favorite property - Edit category property @@ -19,8 +21,6 @@ You can preview some screenshots [here](https://www.scharel.name/harbour/nextclo (The ordering represents the priority for the implementation) - Login screen for the nextcloud account (using the [Login Flow](https://docs.nextcloud.com/server/14/developer_manual/client_apis/LoginFlow/index.html) if possible) -- Create new notes -- Delete notes - Automatically push changes to the server while editing a note - Better [Markdown](https://en.wikipedia.org/wiki/Markdown) rendering - Search in notes diff --git a/qml/pages/EditPage.qml b/qml/pages/EditPage.qml index 3ef12b0..a2daa2a 100644 --- a/qml/pages/EditPage.qml +++ b/qml/pages/EditPage.qml @@ -5,7 +5,7 @@ Dialog { id: page onAccepted: { - account.updateNote(account.model.get(noteIndex).id, { 'category': categoryField.text, 'content': contentArea.text, 'favorite': favoriteButton.down } ) + account.updateNote(account.model.get(noteIndex).id, { 'category': categoryField.text, 'content': contentArea.text, 'favorite': favoriteButton.selected } ) } property var account @@ -17,10 +17,17 @@ Dialog { contentHeight: column.height PullDownMenu { - quickSelect: true - MenuItem { + /*MenuItem { text: qsTr("Markdown Cheatsheet") onClicked: pageStack.push(Qt.resolvedUrl("MarkdownPage.qml")) + }*/ + MenuItem { + text: qsTr("Reset") + onClicked: { + categoryField.text = account.model.get(noteIndex).category + contentArea.text = account.model.get(noteIndex).content + favoriteButton.selected = account.model.get(noteIndex).favorite + } } } @@ -43,10 +50,11 @@ Dialog { width: parent.width - x IconButton { id: favoriteButton + property bool selected: account.model.get(noteIndex).favorite width: Theme.iconSizeMedium - icon.source: (account.model.get(noteIndex).favorite ? "image://theme/icon-m-favorite-selected?" : "image://theme/icon-m-favorite?") + + icon.source: (selected ? "image://theme/icon-m-favorite-selected?" : "image://theme/icon-m-favorite?") + (favoriteButton.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor) - onClicked: account.model.get(noteIndex).favorite = !account.model.get(noteIndex).favorite + onClicked: selected = !selected } TextField { id: categoryField diff --git a/qml/pages/NotePage.qml b/qml/pages/NotePage.qml index 2aefda3..14d4e49 100644 --- a/qml/pages/NotePage.qml +++ b/qml/pages/NotePage.qml @@ -6,11 +6,6 @@ Dialog { acceptDestination: Qt.resolvedUrl("EditPage.qml") acceptDestinationProperties: { account: account; noteIndex: noteIndex } - /*onAcceptPendingChanged: { - if (acceptPending) { - acceptDestinationInstance.note = note - } - }*/ Component.onCompleted: acceptDestinationProperties = { account: account, noteIndex: noteIndex }//acceptDestinationInstance.note = note property var account @@ -31,14 +26,6 @@ Dialog { anchors.fill: parent contentHeight: column.height - /*PullDownMenu { - quickSelect: true - MenuItem { - text: qsTr("Edit") - onClicked: pageStack.push(Qt.resolvedUrl("EditPage.qml"), { note: note } ) - } - }*/ - Column { id: column width: parent.width @@ -60,7 +47,6 @@ Dialog { for (var i=0; i < markdown.length; i++) { text = text.replace(markdown[i].regex, markdown[i].replace) } - console.log(text) } } } diff --git a/qml/pages/NotesApi.qml b/qml/pages/NotesApi.qml index fb40c00..915dc8e 100644 --- a/qml/pages/NotesApi.qml +++ b/qml/pages/NotesApi.qml @@ -105,6 +105,12 @@ Item { break; case "DELETE": console.log("Deleted a note") + for (var i = 0; i < model.count; i++) { + var listItem = model.get(i) + if (listItem.id === data.id){ + model.remove(i) + } + } break; default: console.log("Unsupported method: " + method) diff --git a/qml/pages/NotesPage.qml b/qml/pages/NotesPage.qml index 6c63d05..87386c1 100644 --- a/qml/pages/NotesPage.qml +++ b/qml/pages/NotesPage.qml @@ -31,7 +31,7 @@ Page { text: qsTr("Add note") enabled: nextcloudAccounts.itemAt(appSettings.currentAccount) ? !nextcloudAccounts.itemAt(appSettings.currentAccount).busy : false visible: appSettings.currentAccount >= 0 - onClicked: console.log("Add note") + onClicked: nextcloudAccounts.itemAt(appSettings.currentAccount).createNote() } MenuItem { text: qsTr("Reload") @@ -50,7 +50,7 @@ Page { } header: PageHeader { - title: qsTr("Nextclound Notes") + title: nextcloudAccounts.itemAt(appSettings.currentAccount).name //qsTr("Nextclound Notes") description: nextcloudAccounts.itemAt(appSettings.currentAccount).username + "@" + nextcloudAccounts.itemAt(appSettings.currentAccount).server /*SearchField { width: parent.width @@ -130,7 +130,11 @@ Page { } MenuItem { text: qsTr("Delete") - onClicked: console.log("Delete note") + onClicked: { + note.remorseAction(qsTr("Deleting note"), function() { + nextcloudAccounts.itemAt(appSettings.currentAccount).deleteNote(id) + }) + } } } }