0.3.1: la nota nasce nella cartella aperta, navigazione senza voci fantasma

- NewNoteDialog riceve la cartella corrente: il file va dove sei, non nella
  radice del caveau. Un nome gia' presente viene rifiutato (la PUT avrebbe
  sovrascritto la nota senza chiedere) e il nome non puo' contenere "/".
- PropfindParser.listing(): scarta la collezione stessa (il PROPFIND Depth:1 la
  include, e dentro una cartella sembrava di non essere entrati) e le voci
  nascoste (.obsidian/, .trash/), anche nella scansione di ricerca e tag: le
  note nel cestino non finiscono piu' nei risultati.
- MainPage: se il client e' occupato la navigazione va in coda invece di essere
  persa, e l'elenco precedente viene svuotato subito (non resta sotto
  l'intestazione nuova).
- Test del filtro con la risposta reale di Libro/; verificatore aggiornato per i
  segnali di cambio proprieta' (onBusyChanged).
This commit is contained in:
kaneda committed 2026-11-08 21:04:31 +01:00
1 parent 8259297a27
commit 82d85ab30b
9 files changed
+179 -25

No files matched your search

+5 -2
View File
@@ -113,7 +113,10 @@ Item {
request("PROPFIND", fullUrl(relPath || ""), "", function (xhr) { request("PROPFIND", fullUrl(relPath || ""), "", function (xhr) {
if (xhr.status >= 200 && xhr.status < 300) { if (xhr.status >= 200 && xhr.status < 300) {
var entries = Prop.parse(xhr.responseText, appSettings.serverUrl) 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 { } else {
failed(statusMessage(xhr.status)) failed(statusMessage(xhr.status))
} }
@@ -206,7 +209,7 @@ Item {
request("PROPFIND", fullUrl(folder), "", function (xhr) { request("PROPFIND", fullUrl(folder), "", function (xhr) {
if (!dav.scanning) return if (!dav.scanning) return
if (xhr.status >= 200 && xhr.status < 300) { 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++) { for (var i = 0; i < entries.length; i++) {
var e = entries[i] var e = entries[i]
if (e.isDir) { if (e.isDir) {
+22 -2
View File
@@ -73,6 +73,26 @@ function parse(xml, baseUrl) {
return entries; return entries;
} }
if (typeof module !== "undefined" && module.exports) { // Entries to show in a folder listing, given the folder being listed:
module.exports = { parse: parse }; // - 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 };
} }
+28 -10
View File
@@ -12,6 +12,9 @@ Page {
property var pendingEditor: null property var pendingEditor: null
property var allEntries: [] property var allEntries: []
property string filterText: "" 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() onFilterTextChanged: page.applyFilter()
@@ -37,11 +40,26 @@ Page {
Component.onCompleted: reload() Component.onCompleted: reload()
function reload() { function reload() {
if (!dav || dav.busy) return if (!dav) return
if (dav.busy || dav.scanning) {
pendingReload = true
return
}
pendingReload = false
loading = true loading = true
dav.listDir(currentPath) 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() { function applyFilter() {
notesModel.clear() notesModel.clear()
var f = page.filterText.trim().toLowerCase() var f = page.filterText.trim().toLowerCase()
@@ -59,6 +77,9 @@ Page {
Connections { Connections {
target: dav target: dav
onBusyChanged: {
if (!dav.busy && !dav.scanning && page.pendingReload) page.reload()
}
onListReady: { onListReady: {
loading = false loading = false
allEntries = entries allEntries = entries
@@ -97,11 +118,7 @@ Page {
ListItem { ListItem {
visible: page.currentPath !== "" visible: page.currentPath !== ""
contentHeight: Theme.itemSizeSmall contentHeight: Theme.itemSizeSmall
onClicked: { onClicked: page.enterFolder("")
page.filterText = ""
page.currentPath = ""
page.reload()
}
Label { Label {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
x: Theme.paddingLarge x: Theme.paddingLarge
@@ -124,9 +141,7 @@ Page {
contentHeight: Theme.itemSizeMedium contentHeight: Theme.itemSizeMedium
onClicked: { onClicked: {
if (model.isDir) { if (model.isDir) {
page.filterText = "" page.enterFolder(model.path)
page.currentPath = model.path
page.reload()
} else { } else {
pageStack.push(Qt.resolvedUrl("EditorPage.qml"), pageStack.push(Qt.resolvedUrl("EditorPage.qml"),
{ dav: page.dav, notePath: model.path, noteName: model.name }) { dav: page.dav, notePath: model.path, noteName: model.name })
@@ -162,7 +177,10 @@ Page {
MenuItem { MenuItem {
text: qsTr("New note") text: qsTr("New note")
onClicked: { 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 () { dlg.accepted.connect(function () {
if (dlg.resultPath) { if (dlg.resultPath) {
page.pendingEditor = { path: dlg.resultPath, name: dlg.resultName } page.pendingEditor = { path: dlg.resultPath, name: dlg.resultName }
+65 -9
View File
@@ -5,19 +5,43 @@ Dialog {
id: dialog id: dialog
property var dav 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 resultPath: ""
property string resultName: "" 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: { onAccepted: {
var name = nameField.text.trim() var name = fileName()
if (!name) return if (!name) return
var lower = name.toLowerCase() resultName = name
var hasExt = lower.indexOf(".md") === lower.length - 3 resultPath = folder ? folder + name : name
resultName = hasExt ? name : name + ".md" dav.writeFile(resultPath, "# " + name.replace(/\.md$/, "") + "\n\n")
resultPath = resultName
dav.writeFile(resultPath, "# " + resultName.replace(/\.md$/, "") + "\n\n")
} }
Column { Column {
@@ -30,8 +54,40 @@ Dialog {
width: parent.width width: parent.width
label: qsTr("Name") label: qsTr("Name")
placeholderText: qsTr("e.g. Idea") placeholderText: qsTr("e.g. Idea")
EnterKey.enabled: text.length > 0 EnterKey.enabled: dialog.canAccept
EnterKey.onClicked: dialog.accept() 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
} }
} }
} }
+15 -1
View File
@@ -1,6 +1,6 @@
Name: harbour-quill Name: harbour-quill
Summary: Markdown notes client (Obsidian-like) for Sailfish OS Summary: Markdown notes client (Obsidian-like) for Sailfish OS
Version: 0.3.0 Version: 0.3.1
Release: 1 Release: 1
Group: Applications/Office Group: Applications/Office
License: GPLv3 License: GPLv3
@@ -75,6 +75,20 @@ fi
%{_datadir}/%{name}/translations/%{name}*.qm %{_datadir}/%{name}/translations/%{name}*.qm
%changelog %changelog
* Sun Nov 08 2026 Carlo Baratto <carlo@carlobaratto.it> - 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 <carlo@carlobaratto.it> - 0.3.0-1 * Sun Nov 08 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.3.0-1
- Ricerca nel testo: il caveau viene percorso ricorsivamente e le note .md - Ricerca nel testo: il caveau viene percorso ricorsivamente e le note .md
scaricate una alla volta (il WebDAV non cerca nel contenuto), con avanzamento scaricate una alla volta (il WebDAV non cerca nel contenuto), con avanzamento
+1 -1
View File
@@ -12,7 +12,7 @@
int main(int argc, char *argv[]) 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); QGuiApplication *app = SailfishApp::application(argc, argv);
+3
View File
@@ -91,6 +91,9 @@ def controlla_segnali():
segnali = {} segnali = {}
for nome, params in re.findall(r"signal\s+(\w+)\s*\(([^)]*)\)", dav): 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()] 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(): for f in qml_files():
testo = f.read_text() testo = f.read_text()
for blocco in re.findall(r"Connections\s*\{(.*?)\n \}", testo, re.S): for blocco in re.findall(r"Connections\s*\{(.*?)\n \}", testo, re.S):
+28
View File
@@ -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[1].size, 1234, "size");
assert.strictEqual(entries[2].name, "readme.txt", "non-md kept (filtered by caller)"); 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"); console.log("PropfindParser tests: OK");
+12
View File
@@ -128,6 +128,18 @@
<source>e.g. Idea</source> <source>e.g. Idea</source>
<translation>es. Idea</translation> <translation>es. Idea</translation>
</message> </message>
<message>
<source>A note with this name already exists here</source>
<translation>Esiste già una nota con questo nome</translation>
</message>
<message>
<source>The name cannot contain /</source>
<translation>Il nome non può contenere /</translation>
</message>
<message>
<source>In %1</source>
<translation>In %1</translation>
</message>
</context> </context>
<context> <context>
<name>PreviewPage</name> <name>PreviewPage</name>