From d2449f75919146891ef13c90c49715baa611a46a Mon Sep 17 00:00:00 2001 From: Scharel Clemens Date: Tue, 4 Dec 2018 00:46:04 +0100 Subject: [PATCH] Implemented auto prepend for list elements. --- qml/pages/EditPage.qml | 28 ++++++++++++++++++++-------- rpm/harbour-nextcloudnotes.changes | 3 +++ rpm/harbour-nextcloudnotes.spec | 2 +- rpm/harbour-nextcloudnotes.yaml | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/qml/pages/EditPage.qml b/qml/pages/EditPage.qml index dcccac4..30c28e2 100644 --- a/qml/pages/EditPage.qml +++ b/qml/pages/EditPage.qml @@ -15,6 +15,7 @@ Dialog { onStatusChanged: { if (status === PageStatus.Active) { note = account.getNote(note.id, false) + favoriteButton.selected = note.favorite } } @@ -29,9 +30,6 @@ Dialog { onClicked: { note = account.getNote(note.id, false) favoriteButton.selected = note.favorite - //categoryField.text = note.category - //contentArea.text = note.content - //favoriteButton.selected = note.favorite } } MenuItem { @@ -53,12 +51,26 @@ Dialog { width: parent.width focus: true text: note.content + property int preTextLength: 0 + property var listPrefixes: ["- ", "* ", "+ ", "- [ ] ", "- [x] ", "- [X] "] onTextChanged: { - // TODO Autocomplete list symbols - /*var preText = text.substring(0, cursorPosition) - preText = preText.substring(preText.lastIndexOf('\n')) - console.log(preText) - console.log(text.substring(cursorPosition))*/ + if (page.status === PageStatus.Active && + text.length > preTextLength && + text.charAt(cursorPosition-1) === "\n") { + var clipboard = "" + var preLine = text.substring(text.lastIndexOf("\n", cursorPosition-2), text.indexOf("\n", cursorPosition-1)) + listPrefixes.forEach(function(currentValue) { + if (preLine.indexOf(currentValue) === 1) + clipboard = currentValue + }) + if (clipboard !== "") { + var tmpClipboard = Clipboard.text + Clipboard.text = clipboard + contentArea.paste() + Clipboard.text = tmpClipboard + } + } + preTextLength = text.length } } diff --git a/rpm/harbour-nextcloudnotes.changes b/rpm/harbour-nextcloudnotes.changes index 5bdda7e..69b235a 100644 --- a/rpm/harbour-nextcloudnotes.changes +++ b/rpm/harbour-nextcloudnotes.changes @@ -12,6 +12,9 @@ # * date Author's Name version-release # - Summary of changes +* Tue Dec 04 2018 Scharel Clemens 0.1-5 +- Implemented auto prepend for list elements + * Mon Dec 03 2018 Scharel Clemens 0.1-4 - Implemented searching - Larger checkboxes diff --git a/rpm/harbour-nextcloudnotes.spec b/rpm/harbour-nextcloudnotes.spec index 69fb423..fe80831 100644 --- a/rpm/harbour-nextcloudnotes.spec +++ b/rpm/harbour-nextcloudnotes.spec @@ -14,7 +14,7 @@ Name: harbour-nextcloudnotes %{?qtc_builddir:%define _builddir %qtc_builddir} Summary: Nextcloud Notes Version: 0.1 -Release: 4 +Release: 5 Group: Qt/Qt License: LICENSE URL: http://example.org/ diff --git a/rpm/harbour-nextcloudnotes.yaml b/rpm/harbour-nextcloudnotes.yaml index ab01abe..0b9be1d 100644 --- a/rpm/harbour-nextcloudnotes.yaml +++ b/rpm/harbour-nextcloudnotes.yaml @@ -1,7 +1,7 @@ Name: harbour-nextcloudnotes Summary: Nextcloud Notes Version: 0.1 -Release: 4 +Release: 5 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt