Avevo chiamato data una proprieta della MessagePage: data e finale su Item e QML rifiuta di sovrascriverla, quindi la pagina non si caricava affatto (Impossibile caricare la pagina). Rinominata in quando, anche nel push.
205 lines
6.4 KiB
QML
205 lines
6.4 KiB
QML
import QtQuick 2.0
|
|
import Sailfish.Silica 1.0
|
|
|
|
// Lettura di un messaggio, dal motore. Paginazione a tap: un tocco sul lato
|
|
// destro passa al successivo, sul sinistro al precedente; il corpo resta
|
|
// scorrevole al centro, cosi' i due gesti non si rubano.
|
|
Page {
|
|
id: page
|
|
|
|
property int cartella: -1
|
|
property int riga: 0
|
|
property int totale: 0
|
|
|
|
property string mittente: ""
|
|
property string oggetto: ""
|
|
// non "data": e' una proprieta' finale di Item (la lista dei figli) e
|
|
// sovrascriverla fa rifiutare la pagina ("Impossibile caricare la pagina")
|
|
property string quando: ""
|
|
property string indirizzo: ""
|
|
property string corpo: ""
|
|
|
|
Component.onCompleted: leggi()
|
|
|
|
Connections {
|
|
target: engine
|
|
onReady: page.leggi()
|
|
}
|
|
|
|
// Colonne del motore: 4 mittente, 5 data, 7 oggetto.
|
|
function leggi() {
|
|
if (page.cartella < 0) return;
|
|
page.mittente = engine.cell(page.cartella, page.riga, 4);
|
|
page.quando = engine.cell(page.cartella, page.riga, 5);
|
|
page.oggetto = engine.cell(page.cartella, page.riga, 7);
|
|
page.corpo = engine.body(page.cartella, page.riga);
|
|
page.totale = engine.messages(page.cartella).length;
|
|
}
|
|
|
|
function vai(delta) {
|
|
var nuovo = page.riga + delta;
|
|
if (nuovo < 0 || nuovo >= page.totale) {
|
|
avviso.text = delta < 0 ? qsTr("Primo messaggio")
|
|
: qsTr("Ultimo messaggio");
|
|
avvisoTimer.restart();
|
|
return;
|
|
}
|
|
pageStack.replace(Qt.resolvedUrl("MessagePage.qml"), {
|
|
cartella: page.cartella,
|
|
riga: nuovo
|
|
});
|
|
}
|
|
|
|
SilicaFlickable {
|
|
anchors.fill: parent
|
|
contentHeight: contenuto.height + Theme.paddingLarge
|
|
|
|
PageHeader {
|
|
id: intestazione
|
|
title: page.oggetto
|
|
description: qsTr("%1 di %2").arg(page.riga + 1).arg(page.totale)
|
|
}
|
|
|
|
Column {
|
|
id: contenuto
|
|
anchors.top: intestazione.bottom
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.leftMargin: Theme.horizontalPageMargin
|
|
anchors.rightMargin: Theme.horizontalPageMargin
|
|
spacing: Theme.paddingSmall
|
|
|
|
Label {
|
|
width: parent.width
|
|
text: qsTr("Da: %1").arg(page.mittente)
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
color: Theme.highlightColor
|
|
truncationMode: TruncationMode.Fade
|
|
}
|
|
Label {
|
|
width: parent.width
|
|
visible: page.indirizzo.length > 0
|
|
text: page.indirizzo
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
color: Theme.secondaryColor
|
|
truncationMode: TruncationMode.Fade
|
|
}
|
|
Label {
|
|
width: parent.width
|
|
text: qsTr("A: me — %1").arg(page.quando)
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
color: Theme.secondaryColor
|
|
}
|
|
|
|
Item {
|
|
width: parent.width
|
|
height: Theme.paddingMedium
|
|
}
|
|
|
|
Label {
|
|
width: parent.width
|
|
text: page.corpo.length > 0 ? page.corpo : qsTr("(nessun testo)")
|
|
wrapMode: Text.Wrap
|
|
textFormat: Text.PlainText
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
color: Theme.primaryColor
|
|
bottomPadding: Theme.paddingLarge
|
|
}
|
|
}
|
|
|
|
PullDownMenu {
|
|
MenuItem {
|
|
text: qsTr("Rispondi")
|
|
onClicked: pageStack.push(Qt.resolvedUrl("ComposePage.qml"),
|
|
{ destinatario: page.indirizzo,
|
|
oggetto: "Re: " + page.oggetto })
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Inoltra")
|
|
onClicked: pageStack.push(Qt.resolvedUrl("ComposePage.qml"),
|
|
{ oggetto: "Fwd: " + page.oggetto,
|
|
corpo: page.corpo })
|
|
}
|
|
}
|
|
|
|
PushUpMenu {
|
|
MenuItem {
|
|
text: qsTr("Segna come non letto")
|
|
onClicked: {
|
|
engine.markRead(page.cartella, page.riga, false);
|
|
avviso.text = qsTr("Segnato non letto");
|
|
avvisoTimer.restart();
|
|
}
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Sposta in Trash")
|
|
onClicked: {
|
|
if (engine.moveToTrash(page.cartella, page.riga)) {
|
|
pageStack.pop();
|
|
} else {
|
|
avviso.text = qsTr("Non e' stato possibile spostarlo");
|
|
avvisoTimer.restart();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
VerticalScrollDecorator { }
|
|
}
|
|
|
|
// Zone di tap: destra avanti, sinistra indietro.
|
|
Item {
|
|
anchors.left: parent.left
|
|
anchors.top: parent.top
|
|
anchors.bottom: parent.bottom
|
|
width: Theme.itemSizeMedium
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: page.vai(-1)
|
|
}
|
|
Label {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.left: parent.left
|
|
anchors.leftMargin: Theme.paddingSmall
|
|
text: "\u2039"
|
|
font.pixelSize: Theme.fontSizeHuge
|
|
color: Theme.rgba(Theme.primaryColor, 0.25)
|
|
}
|
|
}
|
|
|
|
Item {
|
|
anchors.right: parent.right
|
|
anchors.top: parent.top
|
|
anchors.bottom: parent.bottom
|
|
width: Theme.itemSizeMedium
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: page.vai(1)
|
|
}
|
|
Label {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: Theme.paddingSmall
|
|
text: "\u203a"
|
|
font.pixelSize: Theme.fontSizeHuge
|
|
color: Theme.rgba(Theme.primaryColor, 0.25)
|
|
}
|
|
}
|
|
|
|
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: 1400
|
|
onTriggered: avviso.text = ""
|
|
}
|
|
}
|