Changes in model use

This commit is contained in:
Scharel Clemens 2020-05-17 17:40:24 +02:00
parent 6d537f5ec1
commit 3ff56872c0

View file

@ -4,8 +4,6 @@ import Sailfish.Silica 1.0
Page { Page {
id: page id: page
property string searchString
onStatusChanged: { onStatusChanged: {
if (status === PageStatus.Activating) { if (status === PageStatus.Activating) {
if (accounts.value.length <= 0) { if (accounts.value.length <= 0) {
@ -35,12 +33,12 @@ Page {
MenuItem { MenuItem {
text: qsTr("Add note") text: qsTr("Add note")
enabled: appSettings.currentAccount.length > 0 && notesApi.networkAccessible enabled: appSettings.currentAccount.length > 0 && notesApi.networkAccessible
onClicked: notesModel.createNote( { 'content': "", 'modified': new Date().valueOf() / 1000 } ) onClicked: notesApi.createNote( { 'content': "", 'modified': new Date().valueOf() / 1000 } )
} }
MenuItem { MenuItem {
text: notesApi.networkAccessible && !notesApi.busy ? qsTr("Reload") : qsTr("Updating...") text: notesApi.networkAccessible && !notesApi.busy ? qsTr("Reload") : qsTr("Updating...")
enabled: appSettings.currentAccount.length > 0 && notesApi.networkAccessible && !notesApi.busy enabled: appSettings.currentAccount.length > 0 && notesApi.networkAccessible && !notesApi.busy
onClicked: notesModel.getAllNotes() onClicked: notes.getAllNotes()
} }
MenuLabel { MenuLabel {
visible: appSettings.currentAccount.length > 0 visible: appSettings.currentAccount.length > 0
@ -61,8 +59,7 @@ Page {
EnterKey.iconSource: "image://theme/icon-m-enter-close" EnterKey.iconSource: "image://theme/icon-m-enter-close"
EnterKey.onClicked: focus = false EnterKey.onClicked: focus = false
onTextChanged: { onTextChanged: {
searchString = text notesProxyModel.searchFilter = text
notesProxyModel.setFilterFixedString(text)
} }
} }
Label { Label {
@ -123,8 +120,7 @@ Page {
icon.source: (favorite ? "image://theme/icon-m-favorite-selected?" : "image://theme/icon-m-favorite?") + icon.source: (favorite ? "image://theme/icon-m-favorite-selected?" : "image://theme/icon-m-favorite?") +
(note.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor) (note.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor)
onClicked: { onClicked: {
var newFavorite = !favorite notesModel.setNote({ 'favorite': !favorite })
notesModel.updateNote(id, {'favorite': newFavorite } )
} }
} }
@ -242,7 +238,7 @@ Page {
ViewPlaceholder { ViewPlaceholder {
id: noSearchPlaceholder id: noSearchPlaceholder
enabled: notesList.count === 0 && searchString !== "" //notesProxyModel.filterRegExp !== "" enabled: notesList.count === 0 && notesProxyModel.searchFilter !== "" //notesProxyModel.filterRegExp !== ""
text: qsTr("No result") text: qsTr("No result")
hintText: qsTr("Try another query") hintText: qsTr("Try another query")
} }