Prototipo interfaccia Sailfish per GrumpyDove: cartelle, lista, lettura con paginazione a tap, compose, copertina; dati finti e piano di porting
This commit is contained in:
commit
696b61319c
20 files changed
+1146
No files matched your search
@@ -0,0 +1,165 @@
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
import "../js/dati.js" as Dati
|
||||
|
||||
// Lista messaggi della cartella. La riga non letta e' in grassetto con la
|
||||
// barra a sinistra; data a destra; nessuna colonna, che su un telefono non
|
||||
// ci sta: mittente sopra, oggetto sotto.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property string cartella: "in"
|
||||
property string titolo: "In"
|
||||
property bool soloNonLetti: false
|
||||
property string ordine: "data"
|
||||
|
||||
ListModel { id: messaggi }
|
||||
|
||||
Component.onCompleted: carica()
|
||||
|
||||
function carica() {
|
||||
messaggi.clear();
|
||||
var lista = Dati.messagesOf(page.cartella).slice();
|
||||
if (page.ordine === "mittente") {
|
||||
lista.sort(function (a, b) {
|
||||
return a.sender.toLowerCase() < b.sender.toLowerCase() ? -1 : 1;
|
||||
});
|
||||
}
|
||||
for (var i = 0; i < lista.length; i++) {
|
||||
var m = lista[i];
|
||||
if (page.soloNonLetti && !m.unread) continue;
|
||||
messaggi.append({
|
||||
mittente: m.sender,
|
||||
oggetto: m.subject,
|
||||
data: m.date,
|
||||
nonLetto: m.unread,
|
||||
junk: m.junk,
|
||||
allegato: m.attachment,
|
||||
indice: i
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// La navigazione sta qui, non nel delegate: nei delegate pageStack non
|
||||
// si risolve su Qt 5.6.
|
||||
function apri(indice) {
|
||||
pageStack.push(Qt.resolvedUrl("MessagePage.qml"), {
|
||||
cartella: page.cartella,
|
||||
indice: indice,
|
||||
titolo: page.titolo
|
||||
});
|
||||
}
|
||||
|
||||
SilicaListView {
|
||||
id: lista
|
||||
anchors.fill: parent
|
||||
model: messaggi
|
||||
|
||||
header: PageHeader {
|
||||
title: page.titolo
|
||||
description: messaggi.count === 1 ? qsTr("1 messaggio")
|
||||
: qsTr("%1 messaggi").arg(messaggi.count)
|
||||
}
|
||||
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Scarica la posta")
|
||||
onClicked: { page.carica(); avviso.text = qsTr("Aggiornato") ; avvisoTimer.restart() }
|
||||
}
|
||||
MenuItem {
|
||||
text: page.soloNonLetti ? qsTr("Mostra tutti") : qsTr("Solo non letti")
|
||||
onClicked: { page.soloNonLetti = !page.soloNonLetti; page.carica() }
|
||||
}
|
||||
}
|
||||
|
||||
PushUpMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Ordina per data")
|
||||
onClicked: { page.ordine = "data"; page.carica() }
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Ordina per mittente")
|
||||
onClicked: { page.ordine = "mittente"; page.carica() }
|
||||
}
|
||||
}
|
||||
|
||||
delegate: BackgroundItem {
|
||||
id: riga
|
||||
|
||||
height: Math.max(Theme.itemSizeLarge, colonna.implicitHeight + Theme.paddingLarge)
|
||||
onClicked: page.apri(model.indice)
|
||||
|
||||
Rectangle {
|
||||
width: Theme.paddingSmall / 3
|
||||
height: parent.height - Theme.paddingMedium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
color: Theme.highlightColor
|
||||
visible: model.nonLetto
|
||||
}
|
||||
|
||||
Column {
|
||||
id: colonna
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Theme.horizontalPageMargin
|
||||
anchors.right: dataLabel.left
|
||||
anchors.rightMargin: Theme.paddingMedium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
text: model.mittente
|
||||
font.bold: model.nonLetto
|
||||
truncationMode: TruncationMode.Fade
|
||||
color: riga.highlighted ? Theme.highlightColor : Theme.primaryColor
|
||||
}
|
||||
Label {
|
||||
width: parent.width
|
||||
text: model.allegato ? model.oggetto + " \u2022" : model.oggetto
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
truncationMode: TruncationMode.Fade
|
||||
color: Theme.secondaryColor
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
id: dataLabel
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.horizontalPageMargin
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: Theme.paddingMedium
|
||||
text: model.data
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
color: Theme.secondaryColor
|
||||
}
|
||||
}
|
||||
|
||||
VerticalScrollDecorator { }
|
||||
|
||||
// Messaggio di lista vuota: fratello della lista, non ancorato
|
||||
// all'headerItem (trappola nota).
|
||||
Label {
|
||||
anchors.centerIn: parent
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
visible: messaggi.count === 0
|
||||
text: page.soloNonLetti ? qsTr("Nessun messaggio non letto")
|
||||
: qsTr("Cartella vuota")
|
||||
color: Theme.secondaryColor
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
id: avviso
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: Theme.paddingLarge
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.highlightColor
|
||||
}
|
||||
Timer {
|
||||
id: avvisoTimer
|
||||
interval: 1200
|
||||
onTriggered: avviso.text = ""
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user