From 829c265234f940fba3e5bbaa7adf9b20fd43741f Mon Sep 17 00:00:00 2001 From: Scharel Clemens Date: Thu, 6 Dec 2018 13:37:29 +0100 Subject: [PATCH] Implemented #20 List of existing categories. --- qml/pages/EditPage.qml | 31 +++++++++++++++++++++++++++++ qml/pages/NotePage.qml | 32 +++++++++++++++++++++++++++++- qml/pages/NotesApi.qml | 5 +++++ qml/pages/NotesPage.qml | 2 +- rpm/harbour-nextcloudnotes.changes | 1 + rpm/harbour-nextcloudnotes.spec | 2 +- 6 files changed, 70 insertions(+), 3 deletions(-) diff --git a/qml/pages/EditPage.qml b/qml/pages/EditPage.qml index 530d70b..2df0b41 100644 --- a/qml/pages/EditPage.qml +++ b/qml/pages/EditPage.qml @@ -16,6 +16,7 @@ Dialog { if (status === PageStatus.Active) { note = account.getNote(note.id, false) favoriteButton.selected = note.favorite + categoryRepeater.model = account.categories } } @@ -83,6 +84,36 @@ Dialog { } } + Flow { + x: Theme.horizontalPageMargin + width: parent.width - 2*x + spacing: Theme.paddingMedium + visible: categoryField.focus + Repeater { + id: categoryRepeater + model: account.categories + BackgroundItem { + width: categoryRectangle.width + height: categoryRectangle.height + Rectangle { + id: categoryRectangle + width: categoryLabel.width + Theme.paddingLarge + height: categoryLabel.height + Theme.paddingSmall + color: "transparent" + border.color: Theme.highlightColor + radius: height / 4 + Label { + id: categoryLabel + anchors.centerIn: parent + text: modelData + color: Theme.primaryColor + font.pixelSize: Theme.fontSizeSmall + } + } + onClicked: categoryField.text = modelData + } + } + } Row { x: Theme.horizontalPageMargin width: parent.width - x diff --git a/qml/pages/NotePage.qml b/qml/pages/NotePage.qml index 56e61e4..d7c0bfc 100644 --- a/qml/pages/NotePage.qml +++ b/qml/pages/NotePage.qml @@ -31,6 +31,7 @@ Dialog { onBusyChanged: { if (account.busy === false) { note = account.getNote(note.id, false) + categoryRepeater.model = account.categories acceptDestinationProperties = { account: account, note: note } parseContent() } @@ -158,6 +159,36 @@ Dialog { Column { width: parent.width + Flow { + x: Theme.horizontalPageMargin + width: parent.width - 2*x + spacing: Theme.paddingMedium + visible: categoryField.focus + Repeater { + id: categoryRepeater + model: account.categories + BackgroundItem { + width: categoryRectangle.width + height: categoryRectangle.height + Rectangle { + id: categoryRectangle + width: categoryLabel.width + Theme.paddingLarge + height: categoryLabel.height + Theme.paddingSmall + color: "transparent" + border.color: Theme.highlightColor + radius: height / 4 + Label { + id: categoryLabel + anchors.centerIn: parent + text: modelData + color: Theme.primaryColor + font.pixelSize: Theme.fontSizeSmall + } + } + onClicked: categoryField.text = modelData + } + } + } Row { x: Theme.horizontalPageMargin width: parent.width - x @@ -188,7 +219,6 @@ Dialog { } } } - DetailItem { id: modifiedDetail label: qsTr("Modified") diff --git a/qml/pages/NotesApi.qml b/qml/pages/NotesApi.qml index 126c560..c418f6b 100644 --- a/qml/pages/NotesApi.qml +++ b/qml/pages/NotesApi.qml @@ -16,6 +16,7 @@ Item { property var modelData: [ ] property var model: ListModel { } + property var categories: [ ] property string file: StandardPaths.data + "/" + uuid + ".json" property bool saveFile: false property bool busy: false @@ -221,7 +222,11 @@ Item { break } if (!searchActive) { + categories = [ ] for (var element in modelData) { + if (categories.indexOf(modelData[element].category) === -1 && modelData[element].category !== "" && typeof(modelData[element].category) !== 'undefined') { + categories.push(modelData[element].category) + } model.set(element, modelData[element]) } element++ diff --git a/qml/pages/NotesPage.qml b/qml/pages/NotesPage.qml index fbc5add..5f7c1a5 100644 --- a/qml/pages/NotesPage.qml +++ b/qml/pages/NotesPage.qml @@ -83,7 +83,7 @@ Page { anchors.right: parent.right anchors.rightMargin: Theme.horizontalPageMargin size: BusyIndicatorSize.Medium - running: nextcloudAccounts.itemAt(appSettings.currentAccount) ? nextcloudAccounts.itemAt(appSettings.currentAccount).busy : false + running: nextcloudAccounts.itemAt(appSettings.currentAccount) ? nextcloudAccounts.itemAt(appSettings.currentAccount).busy && !busyIndicator.running : false } } diff --git a/rpm/harbour-nextcloudnotes.changes b/rpm/harbour-nextcloudnotes.changes index 9b92f12..baad587 100644 --- a/rpm/harbour-nextcloudnotes.changes +++ b/rpm/harbour-nextcloudnotes.changes @@ -14,6 +14,7 @@ * Thu Dec 06 2018 Scharel Clemens 0.1-8 - Fix for #19 "Strikethrough is not shown" +- Added #20 "List of existing categories" * Wed Dec 05 2018 Scharel Clemens 0.1-7 - Fix for #17 "Indents break the tick box bug" diff --git a/rpm/harbour-nextcloudnotes.spec b/rpm/harbour-nextcloudnotes.spec index 3a92881..d66d81e 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: 7 +Release: 8 Group: Qt/Qt License: LICENSE URL: http://example.org/