diff --git a/rpm/harbour-grumpydove.spec b/rpm/harbour-grumpydove.spec index e899520..20177d2 100644 --- a/rpm/harbour-grumpydove.spec +++ b/rpm/harbour-grumpydove.spec @@ -1,6 +1,6 @@ Name: harbour-grumpydove Summary: Eudora-style mail interface, mobile prototype -Version: 0.3.1 +Version: 0.3.2 Release: 1 Group: Qt/Qt # Codice EUPL-1.2; le icone vengono dagli sprite di Eudora, BSD 3-Clause @@ -27,6 +27,9 @@ Icons come from the original project's Eudora bitmaps (BSD 3-Clause, Computer History Museum). %changelog +* Wed Nov 11 2026 Carlo Baratto - 0.3.2-1 +- L'account "Local" (la posta senza server dell'originale) si mostra solo se + contiene messaggi: su un telefono che scarica da IMAP era solo rumore * Wed Nov 11 2026 Carlo Baratto - 0.3.1-1 - Fix: la pagina del messaggio non si apriva ("Impossibile caricare la pagina") perche' la proprieta' data sovrascriveva quella finale di Item; diff --git a/src/enginebridge.cpp b/src/enginebridge.cpp index 2e7f9c1..97d9188 100644 --- a/src/enginebridge.cpp +++ b/src/enginebridge.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -161,32 +162,71 @@ QString EngineBridge::cell(int folder, int row, int column) return QString::fromUtf8(buf, n); } +// Una cartella ha messaggi? Serve solo per decidere se "Local" merita di +// comparire: nell'originale e' la posta senza server (importazioni e cartelle +// create a mano), e su un telefono che scarica da IMAP e' quasi sempre vuota. +static bool hasMessages(int folder) +{ + EngineBridge *b = EngineBridge::instance(); + return b && !b->messages(folder).isEmpty(); +} + QVariantList EngineBridge::folders() { QVariantList out; if (!s_folder) return out; + + struct Entry { int index; QString nome; int depth; }; + QVector all; char buf[512]; int depth = 0; for (int i = 0; i < 200; i++) { int n = s_folder(i, &depth, buf, int(sizeof buf) - 1); if (n < 0) break; if (n > int(sizeof buf) - 1) n = int(sizeof buf) - 1; - const QString nome = QString::fromUtf8(buf, n); + Entry e; + e.index = i; + e.nome = QString::fromUtf8(buf, n); + e.depth = depth; + all.append(e); + } + + // "Local" e le sue cartelle si mostrano solo se qualcuna ha messaggi. + int localAt = -1; + for (int k = 0; k < all.size(); k++) { + if (all.at(k).depth == 0 && all.at(k).nome == QLatin1String("Local")) { + localAt = k; + break; + } + } + int localEnd = localAt; // ultimo indice del sottoalbero di Local + bool localHasMail = false; + if (localAt >= 0) { + for (int k = localAt + 1; k < all.size() && all.at(k).depth > 0; k++) { + localEnd = k; + if (hasMessages(all.at(k).index)) localHasMail = true; + } + } + + for (int k = 0; k < all.size(); k++) { + if (localAt >= 0 && !localHasMail && k >= localAt && k <= localEnd) + continue; + const Entry &e = all.at(k); // Il tipo serve solo a scegliere l'icona: il motore non lo dice. QString tipo = "cartella"; - if (depth == 0) tipo = "account"; - else if (nome == QLatin1String("In")) tipo = "in"; - else if (nome == QLatin1String("Out")) tipo = "out"; - else if (nome == QLatin1String("Junk")) tipo = "junk"; - else if (nome == QLatin1String("Trash")) tipo = "trash"; + if (e.depth == 0) tipo = "account"; + else if (e.nome == QLatin1String("In")) tipo = "in"; + else if (e.nome == QLatin1String("Out")) tipo = "out"; + else if (e.nome == QLatin1String("Junk")) tipo = "junk"; + else if (e.nome == QLatin1String("Trash")) tipo = "trash"; QVariantMap m; - m["folder"] = i; - m["nome"] = nome; - m["livello"] = depth; + m["folder"] = e.index; + m["nome"] = e.nome; + m["livello"] = e.depth; m["tipo"] = tipo; - m["nonLetti"] = s_unread ? s_unread(i) : 0; + m["nonLetti"] = s_unread ? s_unread(e.index) : 0; out.append(m); } return out; diff --git a/src/main.cpp b/src/main.cpp index e10ef62..5fdc300 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,9 +21,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) app->setOrganizationName(QStringLiteral("harbour")); app->setApplicationName(QStringLiteral("grumpydove")); - app->setApplicationVersion(QStringLiteral("0.3.1")); + app->setApplicationVersion(QStringLiteral("0.3.2")); - qDebug() << "harbour-grumpydove v0.3.1 build" << __DATE__ << __TIME__; + qDebug() << "harbour-grumpydove v0.3.2 build" << __DATE__ << __TIME__; QTranslator translator; if (translator.load(QLocale(), QStringLiteral("harbour-grumpydove"),