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 {
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 {

View file

@ -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

View file

@ -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