- 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)
147 lines
5.3 KiB
QML
147 lines
5.3 KiB
QML
import QtQuick 2.0
|
|
import Sailfish.Silica 1.0
|
|
|
|
// Ricerca nei messaggi. La ricerca la fa il motore in background (indice suo);
|
|
// qui c'e' il campo, lo stato e i risultati. Il risultato nomina il file, la
|
|
// posizione nella cartella la risolve il ponte.
|
|
Page {
|
|
id: page
|
|
|
|
property string cercato: ""
|
|
property bool cercando: false
|
|
property string errore: ""
|
|
|
|
SilicaFlickable {
|
|
anchors.fill: parent
|
|
contentHeight: colonna.height + Theme.paddingLarge
|
|
|
|
PageHeader {
|
|
id: intestazione
|
|
title: qsTr("Cerca")
|
|
description: page.cercando ? qsTr("Ricerca in corso…")
|
|
: risultati.count > 0 ? qsTr("%1 risultati").arg(risultati.count)
|
|
: ""
|
|
}
|
|
|
|
Column {
|
|
id: colonna
|
|
anchors.top: intestazione.bottom
|
|
width: parent.width
|
|
spacing: Theme.paddingMedium
|
|
|
|
SearchField {
|
|
id: campo
|
|
width: parent.width
|
|
placeholderText: qsTr("parola o indirizzo")
|
|
EnterKey.enabled: true
|
|
EnterKey.iconSource: "image://theme/icon-m-search"
|
|
EnterKey.onClicked: page.cerca(text)
|
|
onTextChanged: if (text.length === 0) { risultati.clear(); page.errore = "" }
|
|
}
|
|
|
|
Label {
|
|
x: Theme.horizontalPageMargin
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
visible: page.errore.length > 0
|
|
text: page.errore
|
|
color: Theme.highlightColor
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
wrapMode: Text.Wrap
|
|
}
|
|
|
|
Repeater {
|
|
model: risultati
|
|
|
|
BackgroundItem {
|
|
width: colonna.width
|
|
height: Math.max(Theme.itemSizeMedium, testo.height + Theme.paddingLarge)
|
|
onClicked: page.apri(model.cartella, model.riga)
|
|
|
|
Column {
|
|
id: testo
|
|
x: Theme.horizontalPageMargin
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
spacing: Theme.paddingSmall / 2
|
|
|
|
Row {
|
|
width: parent.width
|
|
Label {
|
|
width: parent.width * 0.6
|
|
text: model.mittente
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
color: Theme.secondaryColor
|
|
truncationMode: TruncationMode.Fade
|
|
}
|
|
Label {
|
|
width: parent.width * 0.4
|
|
horizontalAlignment: Text.AlignRight
|
|
text: model.dove
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
color: Theme.secondaryColor
|
|
truncationMode: TruncationMode.Fade
|
|
}
|
|
}
|
|
Label {
|
|
width: parent.width
|
|
text: model.oggetto
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
color: Theme.primaryColor
|
|
truncationMode: TruncationMode.Fade
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Label {
|
|
x: Theme.horizontalPageMargin
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
visible: !page.cercando && risultati.count === 0 && page.errore.length === 0
|
|
&& page.cercato.length > 0
|
|
text: qsTr("Nessun messaggio trovato")
|
|
color: Theme.secondaryColor
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
}
|
|
}
|
|
}
|
|
|
|
ListModel { id: risultati }
|
|
|
|
Connections {
|
|
target: engine
|
|
onSearchFinished: {
|
|
page.cercando = false;
|
|
page.errore = errore;
|
|
risultati.clear();
|
|
var elenco = engine.risultatiRicerca();
|
|
for (var i = 0; i < elenco.length; i++) {
|
|
var r = elenco[i];
|
|
if (r.riga < 0) continue; // il messaggio non e' piu' la'
|
|
risultati.append({ cartella: r.cartella, riga: r.riga,
|
|
mittente: r.mittente, oggetto: r.oggetto,
|
|
dove: r.dove, data: r.data });
|
|
}
|
|
}
|
|
}
|
|
|
|
function cerca(testo) {
|
|
if (testo.trim().length === 0) return;
|
|
page.cercato = testo.trim();
|
|
page.errore = "";
|
|
risultati.clear();
|
|
var motivo = engine.avviaRicerca(page.cercato);
|
|
if (motivo.length > 0) {
|
|
page.errore = motivo;
|
|
page.cercando = false;
|
|
return;
|
|
}
|
|
page.cercando = true;
|
|
}
|
|
|
|
function apri(cartella, riga) {
|
|
if (riga < 0) return;
|
|
pageStack.push(Qt.resolvedUrl("MessagePage.qml"),
|
|
{ cartella: cartella, riga: riga });
|
|
}
|
|
}
|