Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ed2bd614e | ||
|
|
e6f3786aef | ||
|
|
fc4b06a756 | ||
|
|
77ad15b72f | ||
|
|
4dadc7f6ca |
No files matched your search
@@ -32,6 +32,15 @@ doveva succedere (è un difetto anche questo).
|
||||
| B8 | Firma in Account, poi nuovo messaggio | La firma è in fondo, preceduta da `-- `. In una risposta non c'è | | |
|
||||
| B9 | Salva bozza con marcatori, riaprila | I marcatori sono ancora lì (le bozze sono testo semplice) | | |
|
||||
|
||||
## Nota sulle cartelle degli account
|
||||
|
||||
Il motore lascia creare cartelle **solo sotto Local** (`Can_Hold` vale 1 lì, 2 per
|
||||
le cartelle di un account) e la creazione sul server — `IMAP CREATE` — nel
|
||||
motore è un segnaposto: `Mail_Imap.Create` è dichiarato `renames Start`.
|
||||
Rinominare o eliminare una cartella di un account tocca per ora **solo la copia
|
||||
locale**: al controllo successivo il server la riporta. Per questo D1–D3 si
|
||||
provano su Local.
|
||||
|
||||
## C. Azioni sui messaggi
|
||||
|
||||
| # | Prova | Cosa deve succedere | Esito | Note |
|
||||
|
||||
+2
-1
@@ -41,7 +41,8 @@ mkdir -p "$WORK/src"
|
||||
cp "$SRC"/src/*.adb "$SRC"/src/*.ads "$SRC"/src/*.c "$SRC"/src/*.cpp \
|
||||
"$SRC"/src/*.h "$WORK/src/"
|
||||
cp "$HERE"/engine_entry.ads "$HERE"/engine_entry.adb \
|
||||
"$HERE"/filing_keep.ads "$HERE"/filing_keep.adb "$WORK/src/"
|
||||
"$HERE"/filing_keep.ads "$HERE"/filing_keep.adb \
|
||||
"$HERE"/make_remote.ads "$HERE"/make_remote.adb "$WORK/src/"
|
||||
|
||||
# Le modifiche al motore (log redirigibile, cancellazione sul server) stanno
|
||||
# in uno script: si applicano ai sorgenti originali a ogni build, e se un
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
-- Corpo dell'entry point: quello di src/grumpydove.adb, con la sola
|
||||
-- differenza del nome e nessun uso di Ada.Command_Line.
|
||||
with System;
|
||||
|
||||
with GNAT.Exception_Traces;
|
||||
with GNAT.Traceback.Symbolic;
|
||||
with Interfaces.C; use Interfaces.C;
|
||||
@@ -7,6 +9,7 @@ with Interfaces.C; use Interfaces.C;
|
||||
with Mail_Boxes;
|
||||
with Mail_Find;
|
||||
with Filing_Keep;
|
||||
with Make_Remote;
|
||||
with Mail_Folders;
|
||||
with Mail_Carddav;
|
||||
with Mail_Imap;
|
||||
@@ -28,6 +31,14 @@ begin
|
||||
Mail_Log.Start;
|
||||
-- Nomina i filtri che imparano, così entrano nella libreria.
|
||||
Filing_Keep;
|
||||
-- E la creazione di cartelle sul server: la funzione e' esportata, ma se
|
||||
-- nessuno la nomina gnatmake non la compila e gd_make_remote manca.
|
||||
declare
|
||||
Ignored : constant int := Make_Remote.Make (-1, System.Null_Address, 0);
|
||||
pragma Unreferenced (Ignored);
|
||||
begin
|
||||
null;
|
||||
end;
|
||||
if Single_Instance = 0 then
|
||||
Mail_Log.Write ("another GrumpyDove is open: this one leaves");
|
||||
Already_Open;
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Creare una cartella sul server: accoda la nota, la esegue il controllo
|
||||
successivo (IMAP CREATE). Restituisce 1 se accodata, -1 se non si puo'. */
|
||||
int gd_make_remote(int folder, const char *name, int length);
|
||||
|
||||
/* Folders, rows and columns count from 0. A text callback writes at most cap
|
||||
bytes of UTF-8 into buf, with no terminator, and returns how many. */
|
||||
typedef int (*gd_folder_fn)(int index, int *depth, char *buf, int cap);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
with Ada.Exceptions;
|
||||
|
||||
with Mail_Folders;
|
||||
with Mail_Log;
|
||||
with Mail_Pending;
|
||||
|
||||
package body Make_Remote is
|
||||
|
||||
function Make (Folder : int; Name : System.Address; Length : int) return int is
|
||||
Path : constant String := Mail_Folders.Path_Of (Folder);
|
||||
Text : String (1 .. Natural (Length)) with Import, Address => Name;
|
||||
begin
|
||||
-- Senza nome non c'è niente da creare; senza percorso la cartella non
|
||||
-- esiste (indice vecchio, di un albero ricaricato).
|
||||
if Length <= 0 or else Path = "" then
|
||||
return -1;
|
||||
end if;
|
||||
|
||||
-- Solo le cartelle di un account: sotto Local ci pensa Make_Folder.
|
||||
if Mail_Folders.Can_Hold (Folder) /= 2 then
|
||||
return -1;
|
||||
end if;
|
||||
|
||||
Mail_Pending.Note_Make (Path, Text);
|
||||
return 1;
|
||||
exception
|
||||
when Error : others =>
|
||||
Mail_Log.Write
|
||||
("ERR make remote: " & Ada.Exceptions.Exception_Message (Error));
|
||||
return -1;
|
||||
end Make;
|
||||
|
||||
end Make_Remote;
|
||||
@@ -0,0 +1,19 @@
|
||||
-- Creare una cartella sul server, per un account.
|
||||
--
|
||||
-- Mail_Folders.Make_Folder sa creare solo sotto Local (Can_Hold vale 1 lì, 2
|
||||
-- per le cartelle di un account) e Mail_Imap.Create — la funzione che fa IMAP
|
||||
-- CREATE — non è accodata da nessuno. Questa funzione scrive la nota nel
|
||||
-- pending dell'account; il controllo successivo la esegue.
|
||||
--
|
||||
-- Il nome è quello che l'utente ha scritto: la cartella nasce nella radice
|
||||
-- dell'account, non dentro una sua sottocartella.
|
||||
|
||||
with Interfaces.C; use Interfaces.C;
|
||||
with System;
|
||||
|
||||
package Make_Remote is
|
||||
|
||||
function Make (Folder : int; Name : System.Address; Length : int) return int
|
||||
with Export, Convention => C, External_Name => "gd_make_remote";
|
||||
|
||||
end Make_Remote;
|
||||
@@ -184,6 +184,66 @@ with Mail_Log;''',
|
||||
Mail_Pending.Note_Delete (To_String (M.Path));
|
||||
GNAT.OS_Lib.Delete_File (To_String (M.Path), Done);''',
|
||||
"Empty propaga la cancellazione"),
|
||||
|
||||
# Creare una cartella sul server. Make_Folder sa creare solo sotto Local
|
||||
# (Can_Hold = 1); per le cartelle di un account la via e' IMAP CREATE, che
|
||||
# nel motore esiste (Mail_Imap.I_Create) ma non e' mai accodata da nessuno.
|
||||
# La nota sta nel pending della INBOX dell'account e la esegue il Flush.
|
||||
("mail_pending.ads",
|
||||
''' -- File was written in Goal by us: the server gets it at the next check.
|
||||
procedure Note_Copy (Goal, File : String);''',
|
||||
''' -- File was written in Goal by us: the server gets it at the next check.
|
||||
procedure Note_Copy (Goal, File : String);
|
||||
|
||||
-- A mailbox to make on the server. Box is the account's INBOX, Name what
|
||||
-- the user called it: the next check runs IMAP CREATE.
|
||||
procedure Note_Make (Box, Name : String);''',
|
||||
"Note_Make in Mail_Pending (specifica)"),
|
||||
|
||||
("mail_pending.adb",
|
||||
''' procedure Note_Copy (Goal, File : String) is
|
||||
begin''',
|
||||
''' procedure Note_Make (Box, Name : String) is
|
||||
begin
|
||||
if In_Account (Box) and then Name /= "" then
|
||||
Write (Box, Name & ".mkdir", Name);
|
||||
Mail_Log.Write ("pending: mkdir " & Name & " in " & Box);
|
||||
end if;
|
||||
exception
|
||||
when Error : others =>
|
||||
Mail_Log.Write ("ERR pending: " & Ada.Exceptions.Exception_Message (Error));
|
||||
end Note_Make;
|
||||
|
||||
procedure Note_Copy (Goal, File : String) is
|
||||
begin''',
|
||||
"Note_Make in Mail_Pending (corpo)"),
|
||||
|
||||
# Il Flush esegue la creazione. "Esiste gia'" non e' un guasto: la
|
||||
# cartella c'e', che e' quello che l'utente voleva.
|
||||
("mail_imap.adb",
|
||||
''' elsif Kind = "delete" then''',
|
||||
''' elsif Kind = "mkdir" then
|
||||
declare
|
||||
Wanted : constant String := Read_File (Path);
|
||||
New_Box : chars_ptr := New_String (Wanted);
|
||||
begin
|
||||
Ok := C_Create (S, New_Box, Why\'Address, Why_Size) /= 0;
|
||||
if not Ok then
|
||||
declare
|
||||
Said : constant String := To_Ada (Why);
|
||||
begin
|
||||
Ok := Ada.Strings.Fixed.Index (Said, "ALREADYEXISTS") > 0
|
||||
or else Ada.Strings.Fixed.Index (Said, "already exists") > 0;
|
||||
end;
|
||||
end if;
|
||||
if not Ok then
|
||||
Channel.Put ("!" & Tab & Clean (Name) & ": create "
|
||||
& Clean (Wanted) & ": " & To_Ada (Why));
|
||||
end if;
|
||||
Free (New_Box);
|
||||
end;
|
||||
elsif Kind = "delete" then''',
|
||||
"ramo mkdir nel Flush"),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -79,13 +79,35 @@ Page {
|
||||
{ "rinomina": folder, "nomeIniziale": nome });
|
||||
}
|
||||
|
||||
// La cartella si crea sotto l'account: il primo che compare nell'albero.
|
||||
// Le cartelle si creano solo sotto Local: il motore (Can_Hold) non lascia
|
||||
// creare figli dentro una cartella di un account, e la creazione sul
|
||||
// server (IMAP CREATE) nel motore è un segnaposto. Meglio dirlo che
|
||||
// mostrare una pagina che poi si rifiuta.
|
||||
function nuovaCartella() {
|
||||
var account = 0;
|
||||
for (var i = 0; i < cartelle.count; i++) {
|
||||
if (cartelle.get(i).livello === 0) { account = cartelle.get(i).folder; break; }
|
||||
var locale = engine.indiceLocale();
|
||||
if (locale < 0) {
|
||||
avviso.text = qsTr("Non trovo la cartella Local");
|
||||
avvisoTimer.restart();
|
||||
return;
|
||||
}
|
||||
pageStack.push(Qt.resolvedUrl("NewFolderPage.qml"), { "parent": account });
|
||||
pageStack.push(Qt.resolvedUrl("NewFolderPage.qml"),
|
||||
{ "cartellaPadre": locale });
|
||||
}
|
||||
|
||||
// Creare una cartella dentro l'account: sul server, al controllo dopo.
|
||||
function nuovaCartellaAccount() {
|
||||
var account = -1;
|
||||
for (var i = 0; i < cartelle.count; i++) {
|
||||
var m = cartelle.get(i);
|
||||
if (m.livello === 0 && m.nome !== "Local") { account = m.folder; break; }
|
||||
}
|
||||
if (account < 0) {
|
||||
avviso.text = qsTr("Non trovo un account di posta");
|
||||
avvisoTimer.restart();
|
||||
return;
|
||||
}
|
||||
pageStack.push(Qt.resolvedUrl("NewFolderPage.qml"),
|
||||
{ "cartellaPadre": account, "remota": true });
|
||||
}
|
||||
|
||||
function carica() {
|
||||
@@ -142,9 +164,13 @@ Page {
|
||||
onClicked: { page.nonLettiPrima = engine.totalUnread(); engine.checkMail() }
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Nuova cartella")
|
||||
text: qsTr("Nuova cartella (in Local)")
|
||||
onClicked: page.nuovaCartella()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Nuova cartella nell'account")
|
||||
onClicked: page.nuovaCartellaAccount()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Rileggi le cartelle")
|
||||
onClicked: page.carica()
|
||||
|
||||
@@ -8,7 +8,12 @@ import Sailfish.Silica 1.0
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property int parent: 0
|
||||
// Non chiamarla `parent`: in QML è già la proprietà dell'Item, e
|
||||
// ridichiararla impedisce il caricamento della pagina.
|
||||
property int cartellaPadre: 0
|
||||
// In un account la cartella va creata sul server: il motore la
|
||||
// accoda e la crea al controllo successivo.
|
||||
property bool remota: false
|
||||
property int rinomina: -1 // >= 0: si sta rinominando quella cartella
|
||||
property string nomeIniziale: ""
|
||||
property string errore: ""
|
||||
@@ -25,7 +30,9 @@ Page {
|
||||
PageHeader {
|
||||
title: page.rinomina >= 0 ? qsTr("Rinomina la cartella")
|
||||
: qsTr("Nuova cartella")
|
||||
description: qsTr("Dentro l'account")
|
||||
description: page.rinomina >= 0 ? qsTr("Nell'albero delle cartelle")
|
||||
: page.remota ? qsTr("Sul server, al prossimo controllo")
|
||||
: qsTr("Dentro Local")
|
||||
}
|
||||
|
||||
TextField {
|
||||
@@ -76,9 +83,12 @@ Page {
|
||||
}
|
||||
|
||||
function conferma() {
|
||||
page.errore = page.rinomina >= 0
|
||||
? engine.rinominaCartella(page.rinomina, nome.text)
|
||||
: engine.creaCartella(page.parent, nome.text);
|
||||
if (page.rinomina >= 0)
|
||||
page.errore = engine.rinominaCartella(page.rinomina, nome.text);
|
||||
else if (page.remota)
|
||||
page.errore = engine.creaCartellaSulServer(page.cartellaPadre, nome.text);
|
||||
else
|
||||
page.errore = engine.creaCartella(page.cartellaPadre, nome.text);
|
||||
if (page.errore.length === 0)
|
||||
pageStack.pop();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: harbour-grumpydove
|
||||
Summary: Eudora-style mail interface, mobile prototype
|
||||
Version: 0.21.2
|
||||
Version: 0.22.0
|
||||
Release: 1
|
||||
Group: Qt/Qt
|
||||
# Codice EUPL-1.2; le icone vengono dagli sprite di Eudora, BSD 3-Clause
|
||||
@@ -27,6 +27,28 @@ Icons come from the original project's Eudora bitmaps (BSD 3-Clause,
|
||||
Computer History Museum).
|
||||
|
||||
%changelog
|
||||
* Tue Nov 17 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.22.0-1
|
||||
- Creare cartelle sul server (IMAP CREATE). Il motore aveva la funzione
|
||||
(Mail_Imap.I_Create) ma nessuno la accodava: nuova nota .mkdir nel pending,
|
||||
eseguita dal Flush al controllo successivo, e gd_make_remote per accodarla.
|
||||
Voce "Nuova cartella nell'account" nel menu delle cartelle
|
||||
* Tue Nov 17 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.21.5-1
|
||||
- Creare cartelle: il motore (Can_Hold) accetta solo un genitore sotto Local;
|
||||
le cartelle di un account andrebbero create con IMAP CREATE, che nel motore
|
||||
e' un segnaposto (Mail_Imap.Create rinomina Start). La voce ora crea in Local
|
||||
e si chiama cosi', e il rifiuto spiega il perche' invece di dire "non puo'"
|
||||
* Tue Nov 17 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.21.4-1
|
||||
- Corretto: la pressione lunga su una cartella apriva "impossibile caricare la
|
||||
pagina". La pagina dichiarava "property int parent", nome che ogni Item di
|
||||
QtQuick ha gia': il componente non si caricava. Rinominata in cartellaPadre
|
||||
- Aggiunto tests/nomi-riservati.py: controlla che nessuna pagina ridichiari un
|
||||
nome di Item (qmllint non lo segnala e il guasto si vede solo sul telefono)
|
||||
* Tue Nov 17 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.21.3-1
|
||||
- Corretto davvero il limite delle righe: s_open ha due uscite e il valore di
|
||||
ritorno sono le righe valide (Order'Length), mentre il parametro out e'
|
||||
Boxes.Total. Usando quello si chiedeva la riga 495 di una cartella da 495
|
||||
messaggi, e il motore sollevava CONSTRAINT_ERROR a ogni apertura (log del
|
||||
telefono: 234 occorrenze, ancora presenti nella 0.21.2)
|
||||
* Tue Nov 17 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.21.2-1
|
||||
- Corretto: i nomi delle cartelle letti dal motore erano sporchi dei residui
|
||||
della chiamata precedente ("In" diventava "Incal", "Out" diventava "Outal",
|
||||
|
||||
+53
-4
@@ -294,6 +294,40 @@ bool EngineBridge::spostaIn(int da, int riga, int a)
|
||||
|
||||
// Creare una cartella vera (Maildir: tmp, new, cur) sotto l'account. Il
|
||||
// motore dice 1 se l'ha creata, 0 se c'era già, negativo se non può.
|
||||
// La cartella "Local": è l'unica sotto cui il motore sa creare cartelle.
|
||||
int EngineBridge::indiceLocale()
|
||||
{
|
||||
if (!s_folder) return -1;
|
||||
char buf[512];
|
||||
int depth = 0;
|
||||
for (int i = 0; i < 500; i++) {
|
||||
memset(buf, 0, sizeof buf);
|
||||
const int n = s_folder(i, &depth, buf, int(sizeof buf) - 1);
|
||||
if (n < 0) break;
|
||||
if (depth == 0 && testoMotore(buf, n) == QLatin1String("Local"))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Creare una cartella di un account: il motore non la crea in locale, la
|
||||
// accoda (Make_Remote scrive una nota .mkdir nel pending) e il controllo
|
||||
// successivo esegue IMAP CREATE.
|
||||
QString EngineBridge::creaCartellaSulServer(int parent, const QString &nome)
|
||||
{
|
||||
const QString n = nome.trimmed();
|
||||
if (n.isEmpty()) return tr("Scrivi il nome della cartella");
|
||||
const QByteArray b = n.toUtf8();
|
||||
const int r = gd_make_remote(parent, b.constData(), b.size());
|
||||
if (r != 1) {
|
||||
return tr("Non riesco ad accodare la creazione: la cartella deve stare "
|
||||
"dentro un account di posta");
|
||||
}
|
||||
logInvio(QString("cartella «%1» da creare sul server (sotto %2)")
|
||||
.arg(n).arg(parent));
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString EngineBridge::creaCartella(int parent, const QString &nome)
|
||||
{
|
||||
if (!s_make_folder) return tr("Il motore non sa creare cartelle");
|
||||
@@ -301,7 +335,17 @@ QString EngineBridge::creaCartella(int parent, const QString &nome)
|
||||
if (n.isEmpty()) return tr("Scrivi il nome della cartella");
|
||||
const QByteArray b = n.toUtf8();
|
||||
const int r = s_make_folder(parent, b.constData(), b.size(), 1);
|
||||
if (r < 0) return tr("Il motore non può creare una cartella lì");
|
||||
if (r < 0) {
|
||||
// Il motore (Can_Hold) lascia creare cartelle solo sotto Local: quelle
|
||||
// di un account andrebbero create sul server con IMAP CREATE, che nel
|
||||
// motore è un segnaposto (Mail_Imap.Create rinomina Start).
|
||||
const QString m = tr("Qui il motore non crea cartelle: le cartelle di un "
|
||||
"account vanno create sul server, e questa versione "
|
||||
"non lo fa ancora. Per ora si possono creare in Local.");
|
||||
logInvio("ERR crea cartella: rifiutata dal motore (parent " +
|
||||
QString::number(parent) + ")");
|
||||
return m;
|
||||
}
|
||||
if (r == 0) return tr("Esiste già una cartella con questo nome");
|
||||
if (s_rescan) s_rescan();
|
||||
logInvio(QString("cartella creata: %1 sotto %2").arg(n).arg(parent));
|
||||
@@ -1666,12 +1710,17 @@ void EngineBridge::buildRows(int folder)
|
||||
if (!s_open || !s_cell) return;
|
||||
|
||||
long total_k = 0;
|
||||
if (s_open(folder, &total_k) == 0) return;
|
||||
// s_open ha due uscite: il valore di ritorno sono le righe valide
|
||||
// (Order'Length), total_k è Boxes.Total — un altro numero. Usare
|
||||
// total_k come limite fa chiedere la riga oltre l'ultima e il motore
|
||||
// solleva CONSTRAINT_ERROR dentro Cell.
|
||||
const int righeValide = s_open(folder, &total_k);
|
||||
if (righeValide <= 0) return;
|
||||
|
||||
// Il numero di messaggi lo dice s_open: senza questo limite si chiede la
|
||||
// Il numero di righe lo dice s_open: senza questo limite si chiede la
|
||||
// riga successiva all'ultima, che nel motore non esiste, e Ada solleva
|
||||
// un CONSTRAINT_ERROR (mail_boxes.adb, B.Order (Row + 1)) a ogni lettura.
|
||||
const int quante = int(qBound<long>(0, total_k, 2000));
|
||||
const int quante = qMin(righeValide, 2000);
|
||||
if (quante == 0) return;
|
||||
|
||||
// Dal più nuovo al più vecchio, salvo che l'utente abbia scelto un'altra
|
||||
|
||||
@@ -104,6 +104,11 @@ public:
|
||||
Q_INVOKABLE QVariantList cartellePer(int esclusa);
|
||||
// Creare una cartella: sotto l'account indicato (0 = la prima).
|
||||
Q_INVOKABLE QString creaCartella(int parent, const QString &nome);
|
||||
// La cartella "Local": l'unica sotto cui il motore sa creare cartelle.
|
||||
Q_INVOKABLE int indiceLocale();
|
||||
// Creare una cartella di un account: va sul server, quindi in coda fino
|
||||
// al prossimo controllo. Stringa vuota se accodata.
|
||||
Q_INVOKABLE QString creaCartellaSulServer(int parent, const QString &nome);
|
||||
// Controllo automatico della posta: ogni quanti minuti (0 = spento).
|
||||
Q_INVOKABLE int minutiControllo() const;
|
||||
Q_INVOKABLE void setMinutiControllo(int minuti);
|
||||
|
||||
+2
-2
@@ -32,9 +32,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
|
||||
app->setOrganizationName(QStringLiteral("harbour"));
|
||||
app->setApplicationName(QStringLiteral("grumpydove"));
|
||||
app->setApplicationVersion(QStringLiteral("0.21.2"));
|
||||
app->setApplicationVersion(QStringLiteral("0.22.0"));
|
||||
|
||||
qDebug() << "harbour-grumpydove v0.21.2 build" << __DATE__ << __TIME__;
|
||||
qDebug() << "harbour-grumpydove v0.22.0 build" << __DATE__ << __TIME__;
|
||||
|
||||
// Maildir, log, rubrica e liste dei filtri nella cartella dati dell'app:
|
||||
// la sandbox non lascia vedere ~/Mail né scrivere sotto HOME, e cambiare
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Cerca proprietà QML che usano un nome già esistente in Item.
|
||||
|
||||
`property int parent` non è un errore di sintassi: qmllint lo lascia passare,
|
||||
il file si installa, e poi pageStack.push mostra "impossibile caricare la
|
||||
pagina" senza dire perché. Questo controllo lo intercetta prima della build.
|
||||
|
||||
Uso: python3 tests/nomi-riservati.py
|
||||
"""
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
|
||||
# Nomi che ogni Item di QtQuick ha già: ridichiararli rompe il componente.
|
||||
RISERVATI = {
|
||||
"parent", "anchors", "width", "height", "x", "y", "z",
|
||||
"visible", "opacity", "enabled", "clip", "focus", "activeFocus",
|
||||
"children", "data", "resources", "state", "states", "transitions",
|
||||
"transform", "scale", "rotation", "layer", "smooth", "antialiasing",
|
||||
"implicitWidth", "implicitHeight", "baselineOffset", "mirror",
|
||||
}
|
||||
|
||||
DICHIARAZIONE = re.compile(r"^\s*(?:readonly\s+)?property\s+[\w<>.]+\s+(\w+)\s*(?::|$)")
|
||||
|
||||
radice = pathlib.Path(__file__).resolve().parent.parent
|
||||
guasti = 0
|
||||
controllati = 0
|
||||
|
||||
for qml in sorted(radice.glob("qml/**/*.qml")):
|
||||
for numero, riga in enumerate(qml.read_text(encoding="utf-8").splitlines(), 1):
|
||||
trovato = DICHIARAZIONE.match(riga)
|
||||
if not trovato:
|
||||
continue
|
||||
controllati += 1
|
||||
nome = trovato.group(1)
|
||||
if nome in RISERVATI:
|
||||
guasti += 1
|
||||
relativo = qml.relative_to(radice)
|
||||
print("%s:%d proprietà «%s»: nome già usato da Item"
|
||||
% (relativo, numero, nome))
|
||||
|
||||
print(("OK: nomi riservati (%d proprietà controllate)" if guasti == 0
|
||||
else "FALLITO: nomi riservati (%d guasti)") % (controllati if guasti == 0 else guasti))
|
||||
sys.exit(0 if guasti == 0 else 1)
|
||||
Reference in new issue
Block a user