- SearchPage: find_start/find_poll, risultati con mittente, oggetto e cartella; la riga nella cartella si ricava da id_named + row_of - ContactsPage: sincronizzazione del libro CardDAV e contatti che aprono la composizione; campi del libro in Account (indirizzo, utente, password)
183 lines
6.5 KiB
QML
183 lines
6.5 KiB
QML
import QtQuick 2.0
|
|
import Sailfish.Silica 1.0
|
|
|
|
// Cartelle: l'albero di Eudora (account -> cartelle -> sottocartelle)
|
|
// appiattito in una lista, con i non letti che risalgono fino all'account.
|
|
// I dati arrivano dal motore (libgrumpydove.so) attraverso il bridge.
|
|
Page {
|
|
id: page
|
|
|
|
ListModel { id: cartelle }
|
|
|
|
Component.onCompleted: carica()
|
|
|
|
// Le callback del motore arrivano quando il bridge le riceve: se la pagina
|
|
// e' gia' aperta, si ricarica qui.
|
|
Connections {
|
|
target: engine
|
|
onReady: page.carica()
|
|
}
|
|
|
|
function carica() {
|
|
cartelle.clear();
|
|
var elenco = engine.folders();
|
|
for (var i = 0; i < elenco.length; i++) {
|
|
var m = elenco[i];
|
|
cartelle.append({
|
|
folder: m.folder,
|
|
nome: m.nome,
|
|
livello: m.livello,
|
|
nonLetti: m.nonLetti,
|
|
tipo: m.tipo
|
|
});
|
|
}
|
|
}
|
|
|
|
function apriCartella(folder, nome) {
|
|
pageStack.push(Qt.resolvedUrl("MessagesPage.qml"),
|
|
{ cartella: folder, titolo: nome });
|
|
}
|
|
|
|
// Le icone vengono dagli sprite dell'originale (icons/ di GrumpyDove,
|
|
// BSD 3-Clause, © Computer History Museum): cartella, In, Out, Trash,
|
|
// Junk, account.
|
|
// Sono compilate nel binario come risorse (images.qrc): nessun percorso
|
|
// da risolvere, nessuna dipendenza dalla cartella qml installata.
|
|
function iconaDi(tipo) {
|
|
var radice = "qrc:/images/";
|
|
if (tipo === "account") return radice + "icona-account.png";
|
|
if (tipo === "in") return radice + "icona-in.png";
|
|
if (tipo === "out") return radice + "icona-out.png";
|
|
if (tipo === "trash") return radice + "icona-trash.png";
|
|
if (tipo === "junk") return radice + "icona-junk.png";
|
|
return radice + "icona-cartella.png";
|
|
}
|
|
|
|
SilicaListView {
|
|
id: lista
|
|
anchors.fill: parent
|
|
model: cartelle
|
|
|
|
header: PageHeader {
|
|
title: qsTr("Cartelle")
|
|
description: !account.configured() ? qsTr("Account non configurato: menù qui sopra")
|
|
: cartelle.count === 0 ? qsTr("Nessuna cartella — %1").arg(appVersion)
|
|
: qsTr("%1 non letti — %2").arg(engine.totalUnread()).arg(appVersion)
|
|
}
|
|
|
|
PullDownMenu {
|
|
MenuItem {
|
|
text: engine.checking ? qsTr("Controllo in corso…") : qsTr("Scarica la posta")
|
|
enabled: !engine.checking
|
|
onClicked: engine.checkMail()
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Rileggi le cartelle")
|
|
onClicked: page.carica()
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Cerca")
|
|
onClicked: pageStack.push(Qt.resolvedUrl("SearchPage.qml"))
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Rubrica")
|
|
onClicked: pageStack.push(Qt.resolvedUrl("ContactsPage.qml"))
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Account")
|
|
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Nuovo messaggio")
|
|
onClicked: pageStack.push(Qt.resolvedUrl("ComposePage.qml"))
|
|
}
|
|
}
|
|
|
|
delegate: BackgroundItem {
|
|
id: riga
|
|
|
|
height: Math.max(Theme.itemSizeMedium, etichetta.implicitHeight + Theme.paddingLarge)
|
|
onClicked: page.apriCartella(model.folder, model.nome)
|
|
|
|
// Rientro per profondita': la gerarchia si vede dall'icona.
|
|
Image {
|
|
id: icona
|
|
x: Theme.horizontalPageMargin + model.livello * Theme.paddingLarge
|
|
width: Theme.iconSizeSmall
|
|
height: width
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
source: page.iconaDi(model.tipo)
|
|
// pixel art dell'originale: niente sfumature inventate
|
|
smooth: false
|
|
}
|
|
|
|
Column {
|
|
id: etichetta
|
|
anchors.left: icona.right
|
|
anchors.leftMargin: Theme.paddingMedium
|
|
anchors.right: conteggio.left
|
|
anchors.rightMargin: Theme.paddingMedium
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
Label {
|
|
width: parent.width
|
|
text: model.nome
|
|
font.bold: model.nonLetti > 0 || model.tipo === "account"
|
|
truncationMode: TruncationMode.Fade
|
|
color: riga.highlighted ? Theme.highlightColor : Theme.primaryColor
|
|
}
|
|
Label {
|
|
width: parent.width
|
|
visible: model.tipo === "account"
|
|
text: qsTr("account")
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
color: Theme.secondaryColor
|
|
}
|
|
}
|
|
|
|
Label {
|
|
id: conteggio
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: Theme.horizontalPageMargin
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
// Out e Trash non si marcano mai: e' la regola di Eudora.
|
|
text: (model.nonLetti > 0 && model.tipo !== "out" && model.tipo !== "trash")
|
|
? model.nonLetti : ""
|
|
font.bold: true
|
|
color: model.tipo === "junk" ? Theme.secondaryHighlightColor
|
|
: Theme.highlightColor
|
|
}
|
|
}
|
|
|
|
VerticalScrollDecorator { }
|
|
|
|
// Esito del controllo della posta, dalle righe che il motore manda a
|
|
// Poll ("! problema", "+ copiati", "* cartella creata").
|
|
Connections {
|
|
target: engine
|
|
onLastResultChanged: avviso.text = engine.lastResult
|
|
onMailChecked: {
|
|
avviso.text = engine.lastResult;
|
|
avvisoTimer.restart();
|
|
}
|
|
}
|
|
}
|
|
|
|
Label {
|
|
id: avviso
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
anchors.bottom: parent.bottom
|
|
anchors.bottomMargin: Theme.paddingLarge
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
horizontalAlignment: Text.AlignHCenter
|
|
wrapMode: Text.Wrap
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
color: Theme.highlightColor
|
|
}
|
|
Timer {
|
|
id: avvisoTimer
|
|
interval: 4000
|
|
onTriggered: avviso.text = ""
|
|
}
|
|
}
|