diff --git a/qml/components/DavClient.qml b/qml/components/DavClient.qml index 826791e..4f678be 100644 --- a/qml/components/DavClient.qml +++ b/qml/components/DavClient.qml @@ -113,7 +113,10 @@ Item { request("PROPFIND", fullUrl(relPath || ""), "", function (xhr) { if (xhr.status >= 200 && xhr.status < 300) { var entries = Prop.parse(xhr.responseText, appSettings.serverUrl) - listReady(entries) + // Senza questo filtro la cartella appena aperta compare come + // prima voce di se stessa (Depth:1 la include) e .obsidian/ + // .trash sporcano la navigazione. + listReady(Prop.listing(entries, relPath || "")) } else { failed(statusMessage(xhr.status)) } @@ -206,7 +209,7 @@ Item { request("PROPFIND", fullUrl(folder), "", function (xhr) { if (!dav.scanning) return if (xhr.status >= 200 && xhr.status < 300) { - var entries = Prop.parse(xhr.responseText, appSettings.serverUrl) + var entries = Prop.listing(Prop.parse(xhr.responseText, appSettings.serverUrl), folder) for (var i = 0; i < entries.length; i++) { var e = entries[i] if (e.isDir) { diff --git a/qml/components/PropfindParser.js b/qml/components/PropfindParser.js index 5f13e37..8aed810 100644 --- a/qml/components/PropfindParser.js +++ b/qml/components/PropfindParser.js @@ -73,6 +73,26 @@ function parse(xml, baseUrl) { return entries; } -if (typeof module !== "undefined" && module.exports) { - module.exports = { parse: parse }; +// Entries to show in a folder listing, given the folder being listed: +// - the collection ITSELF is dropped (a Depth:1 PROPFIND returns it, and in +// the app it looked like the folder had not been entered at all); +// - hidden entries (".obsidian", ".trash", ".git") are dropped: they are +// configuration, not notes, and they only add noise to the navigation. +// Pure ES5 so the node tests cover it. +function listing(entries, currentPath) { + var out = []; + if (!entries) return out; + var self = currentPath || ""; + for (var i = 0; i < entries.length; i++) { + var e = entries[i]; + if (e.path === self) continue; + var name = e.name || ""; + if (!name || name.charAt(0) === ".") continue; + out.push(e); + } + return out; +} + +if (typeof module !== "undefined" && module.exports) { + module.exports = { parse: parse, listing: listing }; } diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index faead4c..8071f53 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -12,6 +12,9 @@ Page { property var pendingEditor: null property var allEntries: [] property string filterText: "" + // Una navigazione chiesta mentre il client è occupato non va persa: senza + // questa coda l'intestazione cambiava e la lista restava quella di prima. + property bool pendingReload: false onFilterTextChanged: page.applyFilter() @@ -37,11 +40,26 @@ Page { Component.onCompleted: reload() function reload() { - if (!dav || dav.busy) return + if (!dav) return + if (dav.busy || dav.scanning) { + pendingReload = true + return + } + pendingReload = false loading = true dav.listDir(currentPath) } + function enterFolder(path) { + filterText = "" + currentPath = path + // L'elenco vecchio non deve restare sotto l'intestazione nuova mentre + // arriva la risposta: si vedrebbe la cartella di prima. + allEntries = [] + notesModel.clear() + reload() + } + function applyFilter() { notesModel.clear() var f = page.filterText.trim().toLowerCase() @@ -59,6 +77,9 @@ Page { Connections { target: dav + onBusyChanged: { + if (!dav.busy && !dav.scanning && page.pendingReload) page.reload() + } onListReady: { loading = false allEntries = entries @@ -97,11 +118,7 @@ Page { ListItem { visible: page.currentPath !== "" contentHeight: Theme.itemSizeSmall - onClicked: { - page.filterText = "" - page.currentPath = "" - page.reload() - } + onClicked: page.enterFolder("") Label { anchors.verticalCenter: parent.verticalCenter x: Theme.paddingLarge @@ -124,9 +141,7 @@ Page { contentHeight: Theme.itemSizeMedium onClicked: { if (model.isDir) { - page.filterText = "" - page.currentPath = model.path - page.reload() + page.enterFolder(model.path) } else { pageStack.push(Qt.resolvedUrl("EditorPage.qml"), { dav: page.dav, notePath: model.path, noteName: model.name }) @@ -162,7 +177,10 @@ Page { MenuItem { text: qsTr("New note") onClicked: { - var dlg = pageStack.push(Qt.resolvedUrl("NewNoteDialog.qml"), { dav: page.dav }) + var names = [] + for (var i = 0; i < page.allEntries.length; i++) names.push(page.allEntries[i].name) + var dlg = pageStack.push(Qt.resolvedUrl("NewNoteDialog.qml"), + { dav: page.dav, folder: page.currentPath, existingNames: names }) dlg.accepted.connect(function () { if (dlg.resultPath) { page.pendingEditor = { path: dlg.resultPath, name: dlg.resultName } diff --git a/qml/pages/NewNoteDialog.qml b/qml/pages/NewNoteDialog.qml index 811c4dc..965dd91 100644 --- a/qml/pages/NewNoteDialog.qml +++ b/qml/pages/NewNoteDialog.qml @@ -5,19 +5,43 @@ Dialog { id: dialog property var dav + // Cartella corrente (finisce sempre con "/", vuota in radice): la nota + // nasce qui, non nella radice del caveau. + property string folder: "" + // Nomi già presenti nella cartella: un nome ripetuto non si accetta, + // perché la PUT sovrascriverebbe la nota esistente senza chiedere. + property var existingNames: [] + property string resultPath: "" property string resultName: "" - canAccept: nameField.text.length > 0 + function fileName() { + var name = nameField.text.trim().replace(/^\/+/, "").replace(/\/+$/, "") + var lower = name.toLowerCase() + if (lower.indexOf(".md") !== lower.length - 3) name = name + ".md" + return name + } + + function alreadyExists() { + var name = fileName().toLowerCase() + for (var i = 0; i < existingNames.length; i++) { + if (String(existingNames[i]).toLowerCase() === name) return true + } + return false + } + + function invalidChars() { + return nameField.text.indexOf("/") >= 0 + } + + canAccept: nameField.text.trim().length > 0 && !alreadyExists() && !invalidChars() onAccepted: { - var name = nameField.text.trim() + var name = fileName() if (!name) return - var lower = name.toLowerCase() - var hasExt = lower.indexOf(".md") === lower.length - 3 - resultName = hasExt ? name : name + ".md" - resultPath = resultName - dav.writeFile(resultPath, "# " + resultName.replace(/\.md$/, "") + "\n\n") + resultName = name + resultPath = folder ? folder + name : name + dav.writeFile(resultPath, "# " + name.replace(/\.md$/, "") + "\n\n") } Column { @@ -30,8 +54,40 @@ Dialog { width: parent.width label: qsTr("Name") placeholderText: qsTr("e.g. Idea") - EnterKey.enabled: text.length > 0 - EnterKey.onClicked: dialog.accept() + EnterKey.enabled: dialog.canAccept + EnterKey.onClicked: { + if (dialog.canAccept) dialog.accept() + } + } + + Label { + visible: dialog.alreadyExists() + x: Theme.paddingLarge + width: parent.width - 2 * Theme.paddingLarge + text: qsTr("A note with this name already exists here") + color: Theme.highlightColor + font.pixelSize: Theme.fontSizeSmall + wrapMode: Text.Wrap + } + + Label { + visible: dialog.invalidChars() + x: Theme.paddingLarge + width: parent.width - 2 * Theme.paddingLarge + text: qsTr("The name cannot contain /") + color: Theme.highlightColor + font.pixelSize: Theme.fontSizeSmall + wrapMode: Text.Wrap + } + + Label { + visible: dialog.folder !== "" + x: Theme.paddingLarge + width: parent.width - 2 * Theme.paddingLarge + text: qsTr("In %1").arg(dialog.folder) + color: Theme.secondaryColor + font.pixelSize: Theme.fontSizeExtraSmall + truncationMode: TruncationMode.Fade } } } diff --git a/rpm/harbour-quill.spec b/rpm/harbour-quill.spec index ee65b31..dcbdc74 100644 --- a/rpm/harbour-quill.spec +++ b/rpm/harbour-quill.spec @@ -1,6 +1,6 @@ Name: harbour-quill Summary: Markdown notes client (Obsidian-like) for Sailfish OS -Version: 0.3.0 +Version: 0.3.1 Release: 1 Group: Applications/Office License: GPLv3 @@ -75,6 +75,20 @@ fi %{_datadir}/%{name}/translations/%{name}*.qm %changelog +* Sun Nov 08 2026 Carlo Baratto - 0.3.1-1 +- La nuova nota nasce nella cartella aperta, non nella radice del caveau: il + dialogo riceve la cartella corrente e mostra dove la sta creando. Un nome gia' + presente non e' accettato (la PUT avrebbe sovrascritto la nota esistente senza + chiedere) e il nome non puo' contenere "/". +- Dentro una cartella non compare piu' la cartella stessa: il PROPFIND Depth:1 + la includeva e sembrava di non essere entrati. +- Le voci nascoste (.obsidian/, .trash/, .git/) non vengono piu' elencate, ne' + visitate dalla ricerca nel testo e dall'indice dei tag (le note nel cestino + finivano nei risultati). +- La navigazione non si perde piu' se il client e' occupato: la richiesta viene + ripresa appena si libera e l'elenco della cartella precedente viene svuotato + subito, invece di restare sotto l'intestazione nuova. + * Sun Nov 08 2026 Carlo Baratto - 0.3.0-1 - Ricerca nel testo: il caveau viene percorso ricorsivamente e le note .md scaricate una alla volta (il WebDAV non cerca nel contenuto), con avanzamento diff --git a/src/main.cpp b/src/main.cpp index 347bec5..f89e939 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,7 +12,7 @@ int main(int argc, char *argv[]) { - qDebug() << "Quill v0.3.0 build" << __DATE__ << __TIME__; + qDebug() << "Quill v0.3.1 build" << __DATE__ << __TIME__; QGuiApplication *app = SailfishApp::application(argc, argv); diff --git a/tests/qml_contract_check.py b/tests/qml_contract_check.py index 5f18cfa..f39c2af 100644 --- a/tests/qml_contract_check.py +++ b/tests/qml_contract_check.py @@ -91,6 +91,9 @@ def controlla_segnali(): segnali = {} for nome, params in re.findall(r"signal\s+(\w+)\s*\(([^)]*)\)", dav): segnali[nome] = [p.strip().split()[-1] for p in params.split(",") if p.strip()] + # Ogni proprietà genera anche il suo segnale di cambiamento (onBusyChanged). + for nome in re.findall(r"^\s*property\s+\w+\s+(\w+)", dav, re.M): + segnali.setdefault(nome + "Changed", []) for f in qml_files(): testo = f.read_text() for blocco in re.findall(r"Connections\s*\{(.*?)\n \}", testo, re.S): diff --git a/tests/test_parsers.js b/tests/test_parsers.js index 326b1a3..4aea9b1 100644 --- a/tests/test_parsers.js +++ b/tests/test_parsers.js @@ -277,4 +277,32 @@ assert.strictEqual(entries[1].mtime, "Fri, 14 Aug 2026 09:30:00 GMT", "mtime"); assert.strictEqual(entries[1].size, 1234, "size"); assert.strictEqual(entries[2].name, "readme.txt", "non-md kept (filtered by caller)"); +// ── listing: cosa si mostra dentro una cartella ────────────────────────── +// Fixture dalla risposta vera di un Nextcloud: dentro Libro/ arrivano anche la +// cartella stessa e le cartelle di configurazione di Obsidian. +var libro = [ + { name: "Libro", path: "Libro/", isDir: true }, + { name: "ambientazioni", path: "Libro/ambientazioni/", isDir: true }, + { name: "capitoli", path: "Libro/capitoli/", isDir: true }, + { name: "nota.md", path: "Libro/nota.md", isDir: false } +]; +var vis = PropfindParser.listing(libro, "Libro/"); +assert.strictEqual(vis.length, 3, "la cartella stessa non compare nel suo elenco: " + vis.length); +assert(vis.every(function (e) { return e.path !== "Libro/"; }), "self entry dropped"); +assert.strictEqual(vis[0].name, "ambientazioni", "ordine conservato"); + +var radice = [ + { name: ".obsidian", path: ".obsidian/", isDir: true }, + { name: ".trash", path: ".trash/", isDir: true }, + { name: "Libro", path: "Libro/", isDir: true }, + { name: "nota.md", path: "nota.md", isDir: false } +]; +var visRadice = PropfindParser.listing(radice, ""); +assert.strictEqual(visRadice.length, 2, "voci nascoste scartate: " + visRadice.length); +assert.strictEqual(PropfindParser.listing(null, "").length, 0, "entries null"); +assert.strictEqual(PropfindParser.listing([], "").length, 0, "entries vuoto"); +// una nota che si chiama come il percorso non va scartata per errore +var omonima = [{ name: "note.md", path: "note.md", isDir: false }]; +assert.strictEqual(PropfindParser.listing(omonima, "Libro/").length, 1, "path diverso dal self"); + console.log("PropfindParser tests: OK"); diff --git a/translations/harbour-quill_it.ts b/translations/harbour-quill_it.ts index 525a5e9..f0ea58a 100644 --- a/translations/harbour-quill_it.ts +++ b/translations/harbour-quill_it.ts @@ -128,6 +128,18 @@ e.g. Idea es. Idea + + A note with this name already exists here + Esiste già una nota con questo nome + + + The name cannot contain / + Il nome non può contenere / + + + In %1 + In %1 + PreviewPage