Reload content when opening EditPage.

This commit is contained in:
Scharel Clemens 2018-12-03 23:08:41 +01:00
parent db7b27101d
commit a8d1b64251
3 changed files with 38 additions and 30 deletions

View file

@ -5,12 +5,18 @@ import Nemo.Notifications 1.0
Dialog { Dialog {
id: page id: page
property var account
property var note
onAccepted: { onAccepted: {
account.updateNote(note.id, { 'category': categoryField.text, 'content': contentArea.text, 'favorite': favoriteButton.selected } ) account.updateNote(note.id, { 'category': categoryField.text, 'content': contentArea.text, 'favorite': favoriteButton.selected } )
} }
property var account onStatusChanged: {
property var note if (status === PageStatus.Active) {
note = account.getNote(note.id, false)
}
}
SilicaFlickable { SilicaFlickable {
id: flickable id: flickable
@ -21,9 +27,11 @@ Dialog {
MenuItem { MenuItem {
text: qsTr("Reset") text: qsTr("Reset")
onClicked: { onClicked: {
categoryField.text = note.category note = account.getNote(note.id, false)
contentArea.text = note.content
favoriteButton.selected = note.favorite favoriteButton.selected = note.favorite
//categoryField.text = note.category
//contentArea.text = note.content
//favoriteButton.selected = note.favorite
} }
} }
MenuItem { MenuItem {

View file

@ -17,6 +17,22 @@ Dialog {
simpleLineBreaks: true, simpleLineBreaks: true,
emoji: 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() { function parseContent() {
note = account.getNote(note.id, false) note = account.getNote(note.id, false)
//modifiedDetail.value = new Date(note.modified * 1000).toLocaleString(Qt.locale(), Locale.ShortFormat) //modifiedDetail.value = new Date(note.modified * 1000).toLocaleString(Qt.locale(), Locale.ShortFormat)
@ -39,22 +55,6 @@ Dialog {
//console.log(contentLabel.text) //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 { SilicaFlickable {
anchors.fill: parent anchors.fill: parent
contentHeight: mainColumn.height contentHeight: mainColumn.height

View file

@ -4,16 +4,6 @@ import Sailfish.Silica 1.0
Page { Page {
id: 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: { onStatusChanged: {
if (status === PageStatus.Active) { if (status === PageStatus.Active) {
if (nextcloudAccounts.count > 0) { 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 { SilicaListView {
id: notesList id: notesList
anchors.fill: parent anchors.fill: parent