- Ricerca nel testo: la cartella viene percorsa ricorsivamente e le note .md scaricate una alla volta (il WebDAV non cerca nel contenuto), con avanzamento, possibilità di fermare e il passaggio che contiene la parola. La ricerca per titolo nella lista resta istantanea. - Caselle di spunta: "- [ ]" e "- [x]" diventano caselle toccabili nell'anteprima; il tocco riscrive quella sola riga e salva subito, e l'editor segue (senza, uscendo riscriverebbe la versione vecchia sul server). - Tag: front-matter (tags: [a, b], lista a trattini o separata da virgole) e #tag nel testo; pastiglie in cima all'anteprima, #tag toccabili, nuova schermata Tag con il conteggio per tag. Il blocco front-matter non viene più stampato come testo. - tests/qml_contract_check.py: confronta i nomi JS e le proprietà usati dalla QML con i sorgenti, le pagine raggiungibili e i parametri dei gestori dei segnali — la classe di errori che la compilazione non vede. - Catalogo italiano aggiornato (25 stringhe nuove); repo ripulito dai residui di build e .gitignore esteso.
141 lines
3.9 KiB
QML
141 lines
3.9 KiB
QML
import QtQuick 2.2
|
|
import Sailfish.Silica 1.0
|
|
import "../components"
|
|
|
|
Page {
|
|
id: page
|
|
|
|
property var dav
|
|
property string notePath
|
|
property string noteName
|
|
property string initialContent: ""
|
|
property bool skipLoad: false
|
|
property bool loaded: false
|
|
property bool dirty: false
|
|
property string coverText: noteName
|
|
|
|
onStatusChanged: {
|
|
if (status === PageStatus.Active) {
|
|
if (!loaded) {
|
|
if (skipLoad) {
|
|
// New note: content is already known, no GET needed.
|
|
loaded = true
|
|
editor.text = initialContent
|
|
dirty = false
|
|
} else {
|
|
loadNote()
|
|
}
|
|
}
|
|
} else if (status === PageStatus.Inactive) {
|
|
// Auto-save on exit (Obsidian-like: nothing is ever lost).
|
|
if (loaded && dirty && !dav.busy) saveNow(false)
|
|
}
|
|
}
|
|
|
|
function loadNote() {
|
|
loaded = false
|
|
dav.readFile(notePath)
|
|
}
|
|
|
|
function saveNow(notify) {
|
|
if (!loaded) return
|
|
if (dav.busy) {
|
|
banner.show(qsTr("Save in progress..."), false)
|
|
return
|
|
}
|
|
dav.writeFile(notePath, editor.text)
|
|
if (notify) banner.show(qsTr("Saving..."), false)
|
|
}
|
|
|
|
// Called by the preview when it changes the note (a checked box): the text
|
|
// typed here must follow, or leaving the editor would write the old version
|
|
// back over the server copy. `saved` says whether the change already
|
|
// reached the server, and therefore whether the note is still dirty.
|
|
function externalUpdate(text, saved) {
|
|
if (saved) initialContent = text
|
|
editor.text = text
|
|
dirty = !saved
|
|
}
|
|
|
|
Connections {
|
|
target: dav
|
|
onFileReady: {
|
|
loaded = true
|
|
initialContent = content
|
|
editor.text = content
|
|
dirty = false
|
|
}
|
|
onWriteDone: {
|
|
initialContent = editor.text
|
|
dirty = false
|
|
banner.show(qsTr("Saved"), false)
|
|
}
|
|
onFailed: {
|
|
if (loaded) {
|
|
banner.show(message, true)
|
|
} else {
|
|
loaded = true
|
|
banner.show(qsTr("Cannot open: %1").arg(message), true)
|
|
}
|
|
}
|
|
}
|
|
|
|
SilicaFlickable {
|
|
anchors.fill: parent
|
|
contentHeight: column.height
|
|
|
|
Column {
|
|
id: column
|
|
width: parent.width
|
|
|
|
PageHeader { title: noteName }
|
|
|
|
TextArea {
|
|
id: editor
|
|
width: parent.width
|
|
focus: true
|
|
label: "Markdown"
|
|
onTextChanged: {
|
|
dirty = editor.text !== initialContent
|
|
}
|
|
}
|
|
}
|
|
|
|
PullDownMenu {
|
|
MenuItem {
|
|
text: qsTr("Save")
|
|
enabled: page.dirty && page.loaded
|
|
onClicked: page.saveNow(true)
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Preview")
|
|
onClicked: pageStack.push(Qt.resolvedUrl("PreviewPage.qml"),
|
|
{ dav: page.dav, noteName: page.noteName, notePath: page.notePath,
|
|
markdown: editor.text, owner: page })
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Delete note")
|
|
onClicked: {
|
|
var remorse = remorseComponent.createObject(page)
|
|
remorse.execute(qsTr("Delete the note?"), function () {
|
|
dav.deleteFile(notePath)
|
|
pageStack.pop()
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: remorseComponent
|
|
RemorsePopup { }
|
|
}
|
|
|
|
BusyIndicator {
|
|
anchors.centerIn: parent
|
|
running: !page.loaded
|
|
}
|
|
}
|
|
|
|
Banner { id: banner }
|
|
}
|