Ricerca e rubrica CardDAV (0.9.0)
- 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)
This commit is contained in:
1 parent
651592e076
commit
35ea49a992
11 files changed
+623
-7
No files matched your search
@@ -0,0 +1,113 @@
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
// Rubrica CardDAV. Il motore sincronizza il libro e tiene i contatti in
|
||||
// locale; qui si leggono e, con un tocco, si scrive subito a qualcuno.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property bool sincronizzando: false
|
||||
property string errore: ""
|
||||
|
||||
SilicaListView {
|
||||
id: lista
|
||||
anchors.fill: parent
|
||||
model: contatti
|
||||
currentIndex: -1
|
||||
|
||||
header: PageHeader {
|
||||
title: qsTr("Rubrica")
|
||||
description: page.sincronizzando ? qsTr("Sincronizzazione…")
|
||||
: contatti.count > 0 ? qsTr("%1 contatti").arg(contatti.count)
|
||||
: qsTr("Nessun contatto")
|
||||
}
|
||||
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: page.sincronizzando ? qsTr("Sincronizzazione…")
|
||||
: qsTr("Sincronizza")
|
||||
enabled: !page.sincronizzando
|
||||
onClicked: page.sincronizza()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Account")
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
|
||||
}
|
||||
}
|
||||
|
||||
delegate: BackgroundItem {
|
||||
id: riga
|
||||
width: lista.width
|
||||
height: Math.max(Theme.itemSizeMedium, testo.height + Theme.paddingLarge)
|
||||
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("ComposePage.qml"),
|
||||
{ destinatario: model.indirizzo })
|
||||
|
||||
Column {
|
||||
id: testo
|
||||
x: Theme.horizontalPageMargin
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.paddingSmall / 2
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
text: model.nome.length > 0 ? model.nome : model.indirizzo
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.primaryColor
|
||||
truncationMode: TruncationMode.Fade
|
||||
}
|
||||
Label {
|
||||
width: parent.width
|
||||
text: model.indirizzo
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
color: Theme.secondaryColor
|
||||
truncationMode: TruncationMode.Fade
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ViewPlaceholder {
|
||||
enabled: contatti.count === 0 && !page.sincronizzando
|
||||
text: page.errore.length > 0 ? page.errore
|
||||
: qsTr("Sincronizza la rubrica dal menù")
|
||||
hintText: page.errore.length > 0 ? qsTr("Controlla l'indirizzo del libro in Account")
|
||||
: qsTr("I contatti del tuo libro CardDAV")
|
||||
}
|
||||
|
||||
VerticalScrollDecorator { }
|
||||
}
|
||||
|
||||
ListModel { id: contatti }
|
||||
|
||||
Connections {
|
||||
target: engine
|
||||
onRubricaPronta: {
|
||||
page.sincronizzando = false;
|
||||
page.errore = errore;
|
||||
page.riempi();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: page.riempi()
|
||||
|
||||
function riempi() {
|
||||
contatti.clear();
|
||||
var elenco = engine.contatti();
|
||||
for (var i = 0; i < elenco.length; i++) {
|
||||
var c = elenco[i];
|
||||
contatti.append({ nome: c.nome, indirizzo: c.indirizzo, libro: c.libro });
|
||||
}
|
||||
}
|
||||
|
||||
function sincronizza() {
|
||||
page.errore = "";
|
||||
var motivo = engine.sincronizzaRubrica();
|
||||
if (motivo.length > 0) {
|
||||
page.errore = motivo;
|
||||
page.sincronizzando = false;
|
||||
return;
|
||||
}
|
||||
page.sincronizzando = true;
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,14 @@ Page {
|
||||
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"))
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
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 });
|
||||
}
|
||||
}
|
||||
@@ -147,6 +147,37 @@ Page {
|
||||
}
|
||||
}
|
||||
|
||||
SectionHeader { text: qsTr("Rubrica (CardDAV)") }
|
||||
|
||||
TextField {
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
label: qsTr("Indirizzo del libro")
|
||||
placeholderText: qsTr("https://…/addressbooks/user/contacts/")
|
||||
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase
|
||||
text: account.bookUrl
|
||||
onTextChanged: account.bookUrl = text.trim()
|
||||
}
|
||||
|
||||
TextField {
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
label: qsTr("Utente del libro")
|
||||
placeholderText: qsTr("vuoto = utente della posta")
|
||||
text: account.bookUser
|
||||
onTextChanged: account.bookUser = text.trim()
|
||||
}
|
||||
|
||||
TextField {
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
label: qsTr("Password del libro")
|
||||
placeholderText: qsTr("vuota = password della posta")
|
||||
echoMode: TextInput.Password
|
||||
text: account.bookPassword
|
||||
onTextChanged: account.bookPassword = text
|
||||
}
|
||||
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("Salva")
|
||||
|
||||
Reference in new issue
Block a user