From a8d1b6425160deec4fc770d7f37efafe32667cdb Mon Sep 17 00:00:00 2001 From: Scharel Clemens Date: Mon, 3 Dec 2018 23:08:41 +0100 Subject: [PATCH] Reload content when opening EditPage. --- qml/pages/EditPage.qml | 16 ++++++++++++---- qml/pages/NotePage.qml | 32 ++++++++++++++++---------------- qml/pages/NotesPage.qml | 20 ++++++++++---------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/qml/pages/EditPage.qml b/qml/pages/EditPage.qml index d9bde19..dcccac4 100644 --- a/qml/pages/EditPage.qml +++ b/qml/pages/EditPage.qml @@ -5,12 +5,18 @@ import Nemo.Notifications 1.0 Dialog { id: page + property var account + property var note + onAccepted: { account.updateNote(note.id, { 'category': categoryField.text, 'content': contentArea.text, 'favorite': favoriteButton.selected } ) } - property var account - property var note + onStatusChanged: { + if (status === PageStatus.Active) { + note = account.getNote(note.id, false) + } + } SilicaFlickable { id: flickable @@ -21,9 +27,11 @@ Dialog { MenuItem { text: qsTr("Reset") onClicked: { - categoryField.text = note.category - contentArea.text = note.content + note = account.getNote(note.id, false) favoriteButton.selected = note.favorite + //categoryField.text = note.category + //contentArea.text = note.content + //favoriteButton.selected = note.favorite } } MenuItem { diff --git a/qml/pages/NotePage.qml b/qml/pages/NotePage.qml index f63f9ba..b7cdad9 100644 --- a/qml/pages/NotePage.qml +++ b/qml/pages/NotePage.qml @@ -17,6 +17,22 @@ Dialog { simpleLineBreaks: true, emoji: true } ) + acceptDestination: Qt.resolvedUrl("EditPage.qml") + acceptDestinationProperties: { account: account; note: note } + Component.onCompleted: { + parseContent() + acceptDestinationProperties = { account: account, note: note } + } + Connections { + target: account + onBusyChanged: { + if (account.busy === false) { + note = account.getNote(note.id, false) + parseContent() + } + } + } + function parseContent() { note = account.getNote(note.id, false) //modifiedDetail.value = new Date(note.modified * 1000).toLocaleString(Qt.locale(), Locale.ShortFormat) @@ -39,22 +55,6 @@ Dialog { //console.log(contentLabel.text) } - acceptDestination: Qt.resolvedUrl("EditPage.qml") - acceptDestinationProperties: { account: account; note: note } - Component.onCompleted: { - parseContent() - acceptDestinationProperties = { account: account, note: note } - } - Connections { - target: account - onBusyChanged: { - if (account.busy === false) { - note = account.getNote(note.id, false) - parseContent() - } - } - } - SilicaFlickable { anchors.fill: parent contentHeight: mainColumn.height diff --git a/qml/pages/NotesPage.qml b/qml/pages/NotesPage.qml index 5359685..d02b213 100644 --- a/qml/pages/NotesPage.qml +++ b/qml/pages/NotesPage.qml @@ -4,16 +4,6 @@ import Sailfish.Silica 1.0 Page { id: page - Timer { - id: autoSyncTimer - interval: appSettings.autoSyncInterval * 1000 - repeat: true - running: interval > 0 && appWindow.visible - triggeredOnStart: true - onTriggered: nextcloudAccounts.itemAt(appSettings.currentAccount).getNotes() - onIntervalChanged: console.log("Auto-Sync every " + interval / 1000 + " seconds") - } - onStatusChanged: { if (status === PageStatus.Active) { if (nextcloudAccounts.count > 0) { @@ -25,6 +15,16 @@ Page { } } + Timer { + id: autoSyncTimer + interval: appSettings.autoSyncInterval * 1000 + repeat: true + running: interval > 0 && appWindow.visible + triggeredOnStart: true + onTriggered: nextcloudAccounts.itemAt(appSettings.currentAccount).getNotes() + onIntervalChanged: console.log("Auto-Sync every " + interval / 1000 + " seconds") + } + SilicaListView { id: notesList anchors.fill: parent