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

+50 -10
View File
@@ -4,6 +4,7 @@
#include <QCoreApplication>
#include <QStringList>
#include <QVariantMap>
#include <QVector>
#include <QTimer>
#include <QDebug>
@@ -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<Entry> 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;
+2 -2
View File
@@ -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"),