Local si mostra solo se ha messaggi (0.3.2)

Nell'originale Local e la posta senza server (importazioni, cartelle create a
mano): su un telefono che scarica da IMAP e solo rumore. Si nasconde finche
tutte le sue cartelle sono vuote, poi ricompare.
This commit is contained in:
Carlo Baratto committed 2026-11-11 12:40:50 +01:00
1 parent 0670d22f5f
commit 0f24e9f131
3 files changed
+56 -13

No files matched your search

+4 -1
View File
@@ -1,6 +1,6 @@
Name: harbour-grumpydove Name: harbour-grumpydove
Summary: Eudora-style mail interface, mobile prototype Summary: Eudora-style mail interface, mobile prototype
Version: 0.3.1 Version: 0.3.2
Release: 1 Release: 1
Group: Qt/Qt Group: Qt/Qt
# Codice EUPL-1.2; le icone vengono dagli sprite di Eudora, BSD 3-Clause # 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). Computer History Museum).
%changelog %changelog
* Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 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 <carlo@carlobaratto.it> - 0.3.1-1 * Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.3.1-1
- Fix: la pagina del messaggio non si apriva ("Impossibile caricare la - Fix: la pagina del messaggio non si apriva ("Impossibile caricare la
pagina") perche' la proprieta' data sovrascriveva quella finale di Item; pagina") perche' la proprieta' data sovrascriveva quella finale di Item;
+50 -10
View File
@@ -4,6 +4,7 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QStringList> #include <QStringList>
#include <QVariantMap> #include <QVariantMap>
#include <QVector>
#include <QTimer> #include <QTimer>
#include <QDebug> #include <QDebug>
@@ -161,32 +162,71 @@ QString EngineBridge::cell(int folder, int row, int column)
return QString::fromUtf8(buf, n); 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 EngineBridge::folders()
{ {
QVariantList out; QVariantList out;
if (!s_folder) return out; if (!s_folder) return out;
struct Entry { int index; QString nome; int depth; };
QVector<Entry> all;
char buf[512]; char buf[512];
int depth = 0; int depth = 0;
for (int i = 0; i < 200; i++) { for (int i = 0; i < 200; i++) {
int n = s_folder(i, &depth, buf, int(sizeof buf) - 1); int n = s_folder(i, &depth, buf, int(sizeof buf) - 1);
if (n < 0) break; if (n < 0) break;
if (n > int(sizeof buf) - 1) n = int(sizeof buf) - 1; 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. // Il tipo serve solo a scegliere l'icona: il motore non lo dice.
QString tipo = "cartella"; QString tipo = "cartella";
if (depth == 0) tipo = "account"; if (e.depth == 0) tipo = "account";
else if (nome == QLatin1String("In")) tipo = "in"; else if (e.nome == QLatin1String("In")) tipo = "in";
else if (nome == QLatin1String("Out")) tipo = "out"; else if (e.nome == QLatin1String("Out")) tipo = "out";
else if (nome == QLatin1String("Junk")) tipo = "junk"; else if (e.nome == QLatin1String("Junk")) tipo = "junk";
else if (nome == QLatin1String("Trash")) tipo = "trash"; else if (e.nome == QLatin1String("Trash")) tipo = "trash";
QVariantMap m; QVariantMap m;
m["folder"] = i; m["folder"] = e.index;
m["nome"] = nome; m["nome"] = e.nome;
m["livello"] = depth; m["livello"] = e.depth;
m["tipo"] = tipo; m["tipo"] = tipo;
m["nonLetti"] = s_unread ? s_unread(i) : 0; m["nonLetti"] = s_unread ? s_unread(e.index) : 0;
out.append(m); out.append(m);
} }
return out; return out;
+2 -2
View File
@@ -21,9 +21,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
app->setOrganizationName(QStringLiteral("harbour")); app->setOrganizationName(QStringLiteral("harbour"));
app->setApplicationName(QStringLiteral("grumpydove")); 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; QTranslator translator;
if (translator.load(QLocale(), QStringLiteral("harbour-grumpydove"), if (translator.load(QLocale(), QStringLiteral("harbour-grumpydove"),