2018-10-16 18:50:58 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
2018-12-20 20:53:29 +03:00
|
|
|
import "../components"
|
2018-10-16 18:50:58 +03:00
|
|
|
|
|
|
|
Page {
|
|
|
|
id: page
|
|
|
|
|
2018-12-20 20:53:29 +03:00
|
|
|
property string searchText: ""
|
|
|
|
|
2018-11-18 00:28:25 +03:00
|
|
|
onStatusChanged: {
|
|
|
|
if (status === PageStatus.Active) {
|
2018-12-07 02:30:18 +03:00
|
|
|
if (appSettings.accountIDs.length <= 0) {
|
|
|
|
addAccountHint.restart()
|
2018-11-18 00:28:25 +03:00
|
|
|
}
|
|
|
|
else {
|
2018-12-07 02:30:18 +03:00
|
|
|
autoSyncTimer.restart()
|
2018-11-18 00:28:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-16 18:50:58 +03:00
|
|
|
SilicaListView {
|
|
|
|
id: notesList
|
|
|
|
anchors.fill: parent
|
2018-12-13 01:10:45 +03:00
|
|
|
spacing: Theme.paddingLarge
|
2018-10-16 18:50:58 +03:00
|
|
|
|
|
|
|
PullDownMenu {
|
2018-12-07 02:30:18 +03:00
|
|
|
busy: api.busy
|
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-12-07 02:30:18 +03:00
|
|
|
enabled: appSettings.currentAccount.length > 0
|
2018-12-20 20:53:29 +03:00
|
|
|
onClicked: api.createNote( { 'content': "" } )
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
2018-11-15 00:13:47 +03:00
|
|
|
MenuItem {
|
2018-11-24 21:34:01 +03:00
|
|
|
text: enabled ? qsTr("Reload") : qsTr("Updating...")
|
2018-12-07 02:30:18 +03:00
|
|
|
enabled: appSettings.currentAccount.length > 0 && !api.busy
|
2018-12-20 20:53:29 +03:00
|
|
|
onClicked: api.getNotesFromApi()
|
2018-11-15 00:13:47 +03:00
|
|
|
}
|
|
|
|
MenuLabel {
|
2018-12-07 02:30:18 +03:00
|
|
|
visible: appSettings.currentAccount.length > 0
|
|
|
|
text: qsTr("Last update") + ": " + (
|
|
|
|
new Date(api.update).valueOf() !== 0 ?
|
|
|
|
new Date(api.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-12-04 18:31:28 +03:00
|
|
|
height: searchField.height + description.height
|
2018-12-03 22:33:37 +03:00
|
|
|
SearchField {
|
|
|
|
id: searchField
|
|
|
|
width: parent.width
|
2018-12-23 03:59:01 +03:00
|
|
|
enabled: appSettings.accountIDs.count > 0
|
|
|
|
placeholderText: api.name.length > 0 ? api.name : qsTr("Nextcloud Notes")
|
2018-12-03 22:33:37 +03:00
|
|
|
EnterKey.iconSource: "image://theme/icon-m-enter-close"
|
|
|
|
EnterKey.onClicked: focus = false
|
2018-12-20 20:53:29 +03:00
|
|
|
onTextChanged: noteListModel.searchText = text
|
2018-11-25 16:08:00 +03:00
|
|
|
}
|
2018-12-04 18:31:28 +03:00
|
|
|
Label {
|
|
|
|
id: description
|
|
|
|
x: Theme.horizontalPageMargin
|
|
|
|
width: parent.width - 2*x
|
2018-12-23 03:59:01 +03:00
|
|
|
visible: appSettings.accountIDs.count > 0
|
2018-12-04 18:31:28 +03:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: Theme.paddingMedium
|
|
|
|
color: Theme.secondaryHighlightColor
|
|
|
|
font.pixelSize: Theme.fontSizeSmall
|
2018-12-07 02:30:18 +03:00
|
|
|
text: api.username + "@" + api.server
|
2018-12-05 19:06:06 +03:00
|
|
|
}
|
|
|
|
BusyIndicator {
|
|
|
|
anchors.verticalCenter: searchField.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Theme.horizontalPageMargin
|
|
|
|
size: BusyIndicatorSize.Medium
|
2018-12-07 02:30:18 +03:00
|
|
|
running: api.busy && !busyIndicator.running
|
2018-12-04 18:31:28 +03:00
|
|
|
}
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
currentIndex: -1
|
|
|
|
|
2018-12-20 20:53:29 +03:00
|
|
|
model: NoteDelegateModel {
|
|
|
|
id: noteListModel
|
|
|
|
model: api.model
|
|
|
|
sortBy: appSettings.sortBy
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
2018-11-25 16:08:00 +03:00
|
|
|
section.property: appSettings.sortBy
|
|
|
|
section.criteria: appSettings.sortBy === "title" ? ViewSection.FirstCharacter : ViewSection.FullString
|
2018-12-20 20:53:29 +03:00
|
|
|
section.labelPositioning: appSettings.sortBy === "title" ? ViewSection.CurrentLabelAtStart | ViewSection.NextLabelAtEnd : ViewSection.InlineLabels
|
2018-10-16 18:50:58 +03:00
|
|
|
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-12-07 02:30:18 +03:00
|
|
|
running: notesList.count === 0 && api.busy
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
2018-10-21 02:44:23 +03:00
|
|
|
ViewPlaceholder {
|
2018-11-24 21:34:01 +03:00
|
|
|
id: noLoginPlaceholder
|
2018-12-07 02:30:18 +03:00
|
|
|
enabled: appSettings.accountIDs.length <= 0
|
2018-11-24 21:34:01 +03:00
|
|
|
text: qsTr("No account yet")
|
|
|
|
hintText: qsTr("Got to the settings to add an account")
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewPlaceholder {
|
|
|
|
id: noNotesPlaceholder
|
2018-12-07 02:30:18 +03:00
|
|
|
enabled: api.status === 204 && !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-12-03 22:33:37 +03:00
|
|
|
ViewPlaceholder {
|
|
|
|
id: noSearchPlaceholder
|
2018-12-20 20:53:29 +03:00
|
|
|
enabled: notesList.count === 0 && noteListModel.searchText !== ""
|
2018-12-03 22:33:37 +03:00
|
|
|
text: qsTr("No result")
|
|
|
|
hintText: qsTr("Try another query")
|
|
|
|
}
|
|
|
|
|
2018-11-15 00:13:47 +03:00
|
|
|
ViewPlaceholder {
|
2018-11-24 21:34:01 +03:00
|
|
|
id: errorPlaceholder
|
2018-12-03 22:33:37 +03:00
|
|
|
enabled: notesList.count === 0 && !busyIndicator.running && !noSearchPlaceholder.enabled && !noNotesPlaceholder.enabled && !noLoginPlaceholder.enabled
|
2018-11-24 21:34:01 +03:00
|
|
|
text: qsTr("An error occurred")
|
2018-12-07 02:30:18 +03:00
|
|
|
hintText: api.statusText
|
2018-11-15 00:13:47 +03:00
|
|
|
}
|
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-12-04 19:24:45 +03:00
|
|
|
|
|
|
|
allowedOrientations: defaultAllowedOrientations
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|