2018-10-16 18:50:58 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
|
|
|
|
Page {
|
|
|
|
id: page
|
|
|
|
|
2018-11-18 00:28:25 +03:00
|
|
|
onStatusChanged: {
|
|
|
|
if (status === PageStatus.Active) {
|
|
|
|
if (nextcloudAccounts.count > 0) {
|
|
|
|
nextcloudAccounts.itemAt(appSettings.currentAccount).getNotes()
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
addAccountHint.restart()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-16 18:50:58 +03:00
|
|
|
SilicaListView {
|
|
|
|
id: notesList
|
|
|
|
anchors.fill: parent
|
2018-10-21 02:44:23 +03:00
|
|
|
spacing: Theme.paddingLarge
|
2018-10-16 18:50:58 +03:00
|
|
|
|
|
|
|
PullDownMenu {
|
2018-11-18 00:28:25 +03:00
|
|
|
busy: nextcloudAccounts.itemAt(appSettings.currentAccount) ? nextcloudAccounts.itemAt(appSettings.currentAccount).busy : false
|
2018-10-22 23:53:14 +03:00
|
|
|
|
2018-10-16 18:50:58 +03:00
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Settings")
|
2018-10-22 23:53:14 +03:00
|
|
|
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Add note")
|
2018-11-18 00:28:25 +03:00
|
|
|
enabled: nextcloudAccounts.itemAt(appSettings.currentAccount) ? !nextcloudAccounts.itemAt(appSettings.currentAccount).busy : false
|
|
|
|
visible: appSettings.currentAccount >= 0
|
2018-11-18 15:11:22 +03:00
|
|
|
onClicked: nextcloudAccounts.itemAt(appSettings.currentAccount).createNote()
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
2018-11-15 00:13:47 +03:00
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Reload")
|
2018-11-18 00:28:25 +03:00
|
|
|
enabled: nextcloudAccounts.itemAt(appSettings.currentAccount) ? !nextcloudAccounts.itemAt(appSettings.currentAccount).busy : false
|
|
|
|
visible: appSettings.currentAccount >= 0
|
|
|
|
onClicked: nextcloudAccounts.itemAt(appSettings.currentAccount).getNotes()
|
2018-11-15 00:13:47 +03:00
|
|
|
}
|
|
|
|
MenuLabel {
|
2018-11-18 00:28:25 +03:00
|
|
|
visible: appSettings.currentAccount >= 0
|
|
|
|
text: nextcloudAccounts.itemAt(appSettings.currentAccount) ? (
|
|
|
|
qsTr("Last update") + ": " + (
|
|
|
|
new Date(nextcloudAccounts.itemAt(appSettings.currentAccount).update).valueOf() !== 0 ?
|
|
|
|
new Date(nextcloudAccounts.itemAt(appSettings.currentAccount).update).toLocaleString(Qt.locale(), Locale.ShortFormat) :
|
|
|
|
qsTr("never"))) : ""
|
2018-11-15 00:13:47 +03:00
|
|
|
}
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
2018-11-18 13:25:28 +03:00
|
|
|
header: PageHeader {
|
2018-11-18 15:11:22 +03:00
|
|
|
title: nextcloudAccounts.itemAt(appSettings.currentAccount).name //qsTr("Nextclound Notes")
|
2018-11-18 13:25:28 +03:00
|
|
|
description: nextcloudAccounts.itemAt(appSettings.currentAccount).username + "@" + nextcloudAccounts.itemAt(appSettings.currentAccount).server
|
|
|
|
/*SearchField {
|
2018-10-16 18:50:58 +03:00
|
|
|
width: parent.width
|
|
|
|
placeholderText: qsTr("Nextcloud Notes")
|
2018-10-17 00:52:28 +03:00
|
|
|
onTextChanged: notes.search(text.toLowerCase())
|
2018-10-16 18:50:58 +03:00
|
|
|
|
|
|
|
EnterKey.iconSource: "image://theme/icon-m-enter-close"
|
|
|
|
EnterKey.onClicked: focus = false
|
2018-11-18 13:25:28 +03:00
|
|
|
enabled: notesList.count > 0*/
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
currentIndex: -1
|
|
|
|
|
2018-11-18 00:28:25 +03:00
|
|
|
model: nextcloudAccounts.itemAt(appSettings.currentAccount)? nextcloudAccounts.itemAt(appSettings.currentAccount).model : 0
|
|
|
|
Connections {
|
|
|
|
target: appSettings
|
|
|
|
onCurrentAccountChanged: notesList.model = nextcloudAccounts.itemAt(appSettings.currentAccount)? nextcloudAccounts.itemAt(appSettings.currentAccount).model : 0
|
|
|
|
}
|
2018-10-16 18:50:58 +03:00
|
|
|
|
|
|
|
delegate: ListItem {
|
|
|
|
id: note
|
2018-10-17 13:58:55 +03:00
|
|
|
contentHeight: titleLabel.height + previewLabel.height + 2*Theme.paddingSmall
|
2018-10-16 18:50:58 +03:00
|
|
|
|
|
|
|
IconButton {
|
|
|
|
id: isFavoriteIcon
|
2018-10-17 13:58:55 +03:00
|
|
|
anchors.left: parent.left
|
2018-10-21 02:44:23 +03:00
|
|
|
anchors.leftMargin: Theme.paddingSmall
|
|
|
|
anchors.top: parent.top
|
2018-10-16 18:50:58 +03:00
|
|
|
width: Theme.iconSizeMedium
|
|
|
|
icon.source: (favorite ? "image://theme/icon-m-favorite-selected?" : "image://theme/icon-m-favorite?") +
|
|
|
|
(note.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor)
|
|
|
|
onClicked: {
|
|
|
|
console.log("Toggle favorite")
|
2018-11-18 15:20:17 +03:00
|
|
|
nextcloudAccounts.itemAt(appSettings.currentAccount).updateNote(id, {'favorite': !favorite} )
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: titleLabel
|
|
|
|
anchors.left: isFavoriteIcon.right
|
|
|
|
anchors.leftMargin: Theme.paddingSmall
|
|
|
|
anchors.right: parent.right
|
2018-10-17 13:58:55 +03:00
|
|
|
anchors.rightMargin: Theme.horizontalPageMargin
|
|
|
|
anchors.top: parent.top
|
2018-10-16 18:50:58 +03:00
|
|
|
text: title
|
|
|
|
truncationMode: TruncationMode.Fade
|
|
|
|
color: note.highlighted ? Theme.highlightColor : Theme.primaryColor
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
2018-10-17 13:58:55 +03:00
|
|
|
id: previewLabel
|
2018-10-16 18:50:58 +03:00
|
|
|
anchors.left: isFavoriteIcon.right
|
|
|
|
anchors.leftMargin: Theme.paddingSmall
|
|
|
|
anchors.right: parent.right
|
2018-10-17 13:58:55 +03:00
|
|
|
anchors.rightMargin: Theme.horizontalPageMargin
|
|
|
|
anchors.top: titleLabel.bottom
|
2018-10-21 02:44:23 +03:00
|
|
|
anchors.topMargin: Theme.paddingMedium
|
|
|
|
height: Theme.itemSizeExtraLarge
|
2018-10-17 13:58:55 +03:00
|
|
|
text: content
|
2018-10-16 18:50:58 +03:00
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
2018-10-21 02:44:23 +03:00
|
|
|
textFormat: Text.PlainText
|
2018-10-17 13:58:55 +03:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
elide: Text.ElideRight
|
|
|
|
color: note.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
2018-11-18 13:25:28 +03:00
|
|
|
onClicked: pageStack.push(Qt.resolvedUrl("NotePage.qml"), { account: nextcloudAccounts.itemAt(appSettings.currentAccount), noteIndex: index } )
|
2018-10-17 00:52:28 +03:00
|
|
|
|
2018-10-16 18:50:58 +03:00
|
|
|
menu: ContextMenu {
|
2018-10-17 13:58:55 +03:00
|
|
|
Label {
|
|
|
|
id: modifiedLabel
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: qsTr("Modified") + ": " + new Date(modified * 1000).toLocaleString(Qt.locale(), Locale.ShortFormat)
|
2018-10-16 18:50:58 +03:00
|
|
|
font.pixelSize: Theme.fontSizeSmall
|
2018-10-17 13:58:55 +03:00
|
|
|
color: Theme.highlightColor
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Delete")
|
2018-11-18 15:11:22 +03:00
|
|
|
onClicked: {
|
|
|
|
note.remorseAction(qsTr("Deleting note"), function() {
|
|
|
|
nextcloudAccounts.itemAt(appSettings.currentAccount).deleteNote(id)
|
|
|
|
})
|
|
|
|
}
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
section.property: "category"
|
|
|
|
section.criteria: ViewSection.FullString
|
|
|
|
section.labelPositioning: ViewSection.InlineLabels
|
|
|
|
section.delegate: SectionHeader {
|
2018-10-17 00:52:28 +03:00
|
|
|
text: section
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
BusyIndicator {
|
|
|
|
id: busyIndicator
|
|
|
|
anchors.centerIn: parent
|
|
|
|
size: BusyIndicatorSize.Large
|
2018-11-18 00:28:25 +03:00
|
|
|
visible: nextcloudAccounts.itemAt(appSettings.currentAccount) ? nextcloudAccounts.itemAt(appSettings.currentAccount).busy && notesList.count === 0 : false
|
2018-10-16 18:50:58 +03:00
|
|
|
running: visible
|
|
|
|
}
|
|
|
|
|
2018-10-21 02:44:23 +03:00
|
|
|
ViewPlaceholder {
|
2018-11-18 00:28:25 +03:00
|
|
|
enabled: notesList.count === 0 && !busyIndicator.running && !noLoginPlaceholder.enabled
|
2018-10-22 23:53:14 +03:00
|
|
|
text: qsTr("No notes yet")
|
|
|
|
hintText: qsTr("Pull down to add a note")
|
2018-10-21 02:44:23 +03:00
|
|
|
}
|
|
|
|
|
2018-11-15 00:13:47 +03:00
|
|
|
ViewPlaceholder {
|
|
|
|
id: noLoginPlaceholder
|
2018-11-18 00:28:25 +03:00
|
|
|
enabled: nextcloudUUIDs.value.length <= 0
|
2018-11-15 00:13:47 +03:00
|
|
|
text: qsTr("No account yet")
|
|
|
|
hintText: qsTr("Got to the settings to add an account")
|
|
|
|
}
|
2018-10-22 23:53:14 +03:00
|
|
|
|
2018-11-15 00:13:47 +03:00
|
|
|
TouchInteractionHint {
|
|
|
|
id: addAccountHint
|
|
|
|
interactionMode: TouchInteraction.Pull
|
|
|
|
direction: TouchInteraction.Down
|
|
|
|
}
|
|
|
|
InteractionHintLabel {
|
|
|
|
anchors.fill: parent
|
|
|
|
text: qsTr("Open the settings to configure your Nextcloud accounts")
|
|
|
|
opacity: addAccountHint.running ? 1.0 : 0.0
|
|
|
|
Behavior on opacity { FadeAnimation {} }
|
|
|
|
width: parent.width
|
|
|
|
}
|
2018-10-22 23:53:14 +03:00
|
|
|
|
2018-11-15 00:13:47 +03:00
|
|
|
VerticalScrollDecorator { flickable: notesList }
|
|
|
|
}
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|