qviaggiatreno-2013.7.3/ 0000775 0001750 0001750 00000000000 12215772725 014601 5 ustar locutus locutus qviaggiatreno-2013.7.3/qviaggiatreno.pro 0000664 0001750 0001750 00000000122 12215773056 020154 0 ustar locutus locutus SUBDIRS += src
TEMPLATE = subdirs
CONFIG += ordered warn_on qt debug_and_release
qviaggiatreno-2013.7.3/qviaggiatreno.desktop 0000664 0001750 0001750 00000000364 12215773056 021035 0 ustar locutus locutus [Desktop Entry]
Name=QViaggiaTreno
Comment=Interfaccia grafica per ViaggiaTreno
Exec=qviaggiatreno
Terminal=false
Type=Application
GenericName=Informazioni in tempo reale sulla circolazione ferroviaria
Categories=Qt;Network;
StartupNotify=true
qviaggiatreno-2013.7.3/src/ 0000775 0001750 0001750 00000000000 12215773217 015365 5 ustar locutus locutus qviaggiatreno-2013.7.3/src/application.qrc 0000664 0001750 0001750 00000001454 12215773217 020403 0 ustar locutus locutus
doc/GPL-2.txt
img/avvia.png
img/chiudi.png
img/interrompi.png
traduzioni/qt_it.qm
img/stazione.png
img/listatreni.png
img/treno.png
img/aggiungi.png
img/rimuovi.png
img/cancella-tutti.png
img/apri.png
img/salva.png
img/salva-come.png
img/cronometro.png
img/configura.png
img/aggiorna.png
img/stampa.png
img/esporta.png
img/trenord.png
qviaggiatreno-2013.7.3/src/download_viaggiatreno.h 0000664 0001750 0001750 00000013652 12215773056 022114 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2010-2011 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef DOWNLOAD_VIAGGIATRENO_H
#define DOWNLOAD_VIAGGIATRENO_H
#include
class QViaggiaTreno;
class DownloadViaggiaTreno;
class DownloadViaggiaTrenoItem;
class SchedaQViaggiaTreno;
//questa classe è la classe in cui viene centralizzato il download delle schede
//da viaggiatreno
class DownloadViaggiaTreno : public QObject
{
Q_OBJECT
public:
DownloadViaggiaTreno(QViaggiaTreno* qvt, QNetworkAccessManager* nam);
signals:
void statoViaggiaTreno(bool);
public slots:
//mette in coda la richiesta di scaricare da Viaggiatreno la scheda di una stazione, fornendo il nome della stazione
void downloadStazione(quint32 idScheda, const QString& nomeStazione);
//mette in coda la richiesta di scaricare da ViaggiaTreno la scheda di una stazione, fornendone il codice
void downloadStazioneCodice(quint32 idScheda, const QString& codiceStazione);
//mette in coda la richiesta di scaricare da ViaggiaTreno la scheda di riepilogo di un treno, fornendone il numero
void downloadRiepilogoTreno(quint32 idScheda, const QString& numero);
//mette in coda la richiesta di scaricare da ViaggiaTreno la scheda di riepilogo di un treno, fornendo il numero
//e il codice della stazione di origine
void downloadRiepilogoTreno(quint32 idScheda, const QString &numero, const QString& codiceStazOrigine);
//mette in coda la richiesta di scaricare da ViaggiaTreno la scheda con i dettagli di un treno, fornendone il numero
void downloadDettagliTreno(quint32 idScheda, const QString& numero);
//mette in coda la richiesta di scaricare da ViaggiaTreno la scheda con i dettagli di un treno
//fornendo il numero e il codice della stazione di origine
void downloadDettagliTreno(quint32 idScheda, const QString &numero, const QString& codiceStazOrigine);
//avvia il download
void avvia();
private:
//corregge alcuni errori nel codice XHTML generato da viaggiatreno che ne impediscono
//il corretto parsing da parte della classe QDom
QString correggiOutputVT(QString testoVT);
void richiestaHTTPStazioneConNome(DownloadViaggiaTrenoItem *item);
void richiestaHTTPStazioneConCodice(DownloadViaggiaTrenoItem *item);
void richiestaHTTPRiepilogoTreno(DownloadViaggiaTrenoItem* item);
void richiestaHTTPRiepilogoTrenoConOrigine(DownloadViaggiaTrenoItem *item);
void richiestaHTTPDettagliTreno(DownloadViaggiaTrenoItem *item);
void richiestaHTTPDettagliTrenoConOrigine(DownloadViaggiaTrenoItem * item);
private slots:
void download();
void downloadEffettuato();
bool controllaViaggiaTreno();
private:
QViaggiaTreno* m_qvt;
QNetworkAccessManager* m_nam;
//intervallo tra due download successivi dal server di viaggiatreno
int m_intervalloDownload;
//intervallo di aggiornamento delle cache
int m_intervalloAggiornamentoCache;
//tempo in cui una scheda rimane in cache
int m_tempoCache;
QQueue m_codaDownload;
QTimer *m_timerDownload, *m_timerControlloVT;
//costanti
//valore di default dell'intervallo di download (in ms)
static const int s_intervalloDownload;
//valore di default dell'intervallo di aggiornamento della cache (in ms)
static const int s_intervalloAggiornamentoCache;
//valore di default del tempo di permanenza in cache (in s)
static const int s_tempoCache;
//valore di default dell'intervallo di controllo del corretto funzionamento di Viaggiatreno (in m)
static const int s_itervalloCheckViaggiaTreno;
};
//l'enum elenca i tipi diversi di dati possibili scaricabili da viaggiatreno
enum TipoSchedaViaggiaTreno {StazioneConNome, StazioneConCodice, RiepilogoTreno, RiepilogoTrenoConOrigine,
DettagliTreno, DettagliTrenoConOrigine};
//questa classe memorizza i dati di ogni singolo download
class DownloadViaggiaTrenoItem : public QObject
{
Q_OBJECT
public:
DownloadViaggiaTrenoItem(quint32 idScheda, TipoSchedaViaggiaTreno tipoScheda);
//restituisce il tipo di scheda
TipoSchedaViaggiaTreno tipoScheda() const {return m_tipoSchedaVT;}
//restituisce data e ora della richiesta di download
QDateTime dataEOra() const {return m_dataEOra;}
//restituisce puntatore alla scheda che ha effettuato la richiesta di download
quint32 idScheda() const {return m_scheda;}
//restituisce uno dei dati impostati
QString dato(const QString& nome) const {return m_dati[nome];}
//imposta un dato
void impostaDato(const QString& nome, const QString& valore)
{
m_dati[nome] = valore;
}
private:
quint32 m_scheda;
TipoSchedaViaggiaTreno m_tipoSchedaVT;
QMap m_dati;
QDateTime m_dataEOra;
};
#endif // DOWNLOAD_VIAGGIATRENO_H
qviaggiatreno-2013.7.3/src/schedaavvisitrenord.cpp 0000664 0001750 0001750 00000005705 12215771022 022137 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2008-2012 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "download_trenord.h"
#include "schedaavvisitrenord.h"
#include "qviaggiatreno.h"
#include "parser_trenord.h"
SchedaAvvisiTrenord::SchedaAvvisiTrenord(QViaggiaTreno *parent, const unsigned int intervalloStandard) :
SchedaQViaggiaTreno(parent, tsAvvisiTrenord, intervalloStandard)
{
m_stato = statoNuovaScheda;
//crea il widget con le tabelle contenti gli avvisi
m_parser = new ParserTrenord(this);
m_avvisi = new ModelloAvvisiTrenord(this);
m_widgetAvvisi = new WidgetAvvisiTrenord(this, m_avvisi);
addWidget(m_widgetAvvisi);
//connessioni
connect(this, SIGNAL(statoCambiato(quint32)), parent, SLOT(aggiornaStatoScheda(quint32)));
//TODO: una volta terminato codice scheda verificare se questa connessione sia realmente necessaria
connect(this, SIGNAL(messaggioStatus(const QString&)), parent, SLOT(mostraMessaggioStatusBar(const QString&)));
connect(this, SIGNAL(aggiornaListaDirettrici()), qViaggiaTreno()->downloadTrenord(), SLOT(aggiornaListaDirettrici()));
}
SchedaAvvisiTrenord::~SchedaAvvisiTrenord()
{
if (m_parser)
delete m_parser;
if (m_avvisi)
delete m_avvisi;
}
void SchedaAvvisiTrenord::avvia()
{
SchedaQViaggiaTreno::avvia();
}
void SchedaAvvisiTrenord::ferma()
{
SchedaQViaggiaTreno::ferma();
}
void SchedaAvvisiTrenord::aggiorna()
{
cambiaStato(statoInAggiornamento);
emit aggiornaListaDirettrici();
}
void SchedaAvvisiTrenord::downloadFinito(const QString &rispostaTN)
{
if (m_parser->analizzaListaDirettrici(rispostaTN))
qViaggiaTreno()->downloadTrenord()->scaricaAvvisi(m_parser);
}
qviaggiatreno-2013.7.3/src/dialogo_configurazione.cpp 0000664 0001750 0001750 00000022167 12215773056 022622 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2010-2011 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "dialogo_configurazione.h"
#include "qviaggiatreno.h"
DialogoConfigurazione::DialogoConfigurazione(QViaggiaTreno* qvt) : QDialog(qvt)
{
m_qvt = qvt;
setupUi(this);
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(pulsantePremuto(QAbstractButton*)));
connect(checkBoxUsareProxy, SIGNAL(clicked(bool)), this, SLOT(checkBoxUsareProxyCliccato(bool)));
connect(checkBoxAutenticazione, SIGNAL(clicked(bool)), this, SLOT(checkBoxAutenticazioneCliccato(bool)));
connect(checkBoxUsareProxySistema, SIGNAL(clicked(bool)), this, SLOT(checkBoxUsareProxySistemaCliccato(bool)));
}
//questo metodo legge i valori di configurazione ed imposta i corrispondenti controlli
//nella finestra di dialogo
void DialogoConfigurazione::impostaConfigurazione()
{
//scheda ViaggiaTreno
spinBoxControlloVT->setValue(m_qvt->configurazione().intervalloControlloVT());
spinBoxTimeoutControlloVT->setValue(m_qvt->configurazione().timeoutControlloVT());
doubleSpinBoxQueryVT->setValue(m_qvt->configurazione().intervalloQueryVT());
//scheda Proxy
lineEditHost->setText(m_qvt->configurazione().hostProxy());
spinBoxPorta->setValue(m_qvt->configurazione().portaProxy());
lineEditNomeUtente->setText(m_qvt->configurazione().nomeUtenteProxy());
lineEditPassword->setText(m_qvt->configurazione().passwordProxy());
checkBoxUsareProxy->setChecked(m_qvt->configurazione().proxyUtilizzato());
checkBoxAutenticazione->setChecked(m_qvt->configurazione().proxyRichiedeAutenticazione());
checkBoxUsareProxySistema->setChecked(m_qvt->configurazione().proxyDiSistemaUtilizzato());
// simula la selezione delle due checkbox nella scheda Proxy
checkBoxUsareProxySistemaCliccato(m_qvt->configurazione().proxyDiSistemaUtilizzato());
checkBoxUsareProxyCliccato(m_qvt->configurazione().proxyUtilizzato());
checkBoxAutenticazioneCliccato(m_qvt->configurazione().proxyRichiedeAutenticazione());
}
//questo metodo, richiamato se il dialogo è stato chiuso premendo il pulsante Ok imposta i
//parametri di configurazione leggendo i valodi dei controli della finestra di dialogo
void DialogoConfigurazione::applicaConfigurazione()
{
//scheda ViaggiaTreno
m_qvt->configurazione().impostaIntervalloControlloVT(spinBoxControlloVT->value());
m_qvt->configurazione().impostaTimeoutControllVT(spinBoxTimeoutControlloVT->value());
m_qvt->configurazione().impostaIntervalloQueryVT(doubleSpinBoxQueryVT->value());
//scheda proxy
m_qvt->configurazione().impostaUtilizzoProxy(checkBoxUsareProxy->isChecked());
m_qvt->configurazione().impostaRichiestaAutenticazioneProxy(checkBoxAutenticazione->isChecked());
m_qvt->configurazione().impostaHostProxy(lineEditHost->text());
m_qvt->configurazione().impostaPortaProxy(spinBoxPorta->value());
m_qvt->configurazione().impostaNomeUtenteProxy(lineEditNomeUtente->text());
m_qvt->configurazione().impostaPasswordProxy(lineEditPassword->text());
m_qvt->configurazione().impostaUtilizzoProxyDiSistema(checkBoxUsareProxySistema->isChecked());
}
void DialogoConfigurazione::pulsantePremuto(QAbstractButton *pulsante)
{
//controlla che sia stato premuto il pulsante per reimpostare i valori predefiniti
//a questo scopo è sufficiente controllare il corrispondente ButtonRole
if (buttonBox->buttonRole(pulsante) == QDialogButtonBox::ResetRole)
ripristinaValoriPredefiniti();
}
//ripristina i valori predefiniti leggendoli dalla coppia privata della classe che memorizza la configurazione
void DialogoConfigurazione::ripristinaValoriPredefiniti()
{
//scheda ViaggiaTreno
spinBoxControlloVT->setValue(m_qvt->configurazione().intervalloControlloVTDefault());
spinBoxTimeoutControlloVT->setValue(m_qvt->configurazione().timeoutControlloVTDefault());
doubleSpinBoxQueryVT->setValue(m_qvt->configurazione().intervalloQueryVTDefault());
//scheda Proxy
lineEditHost->setText(m_qvt->configurazione().hostProxyDefault());
spinBoxPorta->setValue(m_qvt->configurazione().portaProxyDefault());
lineEditNomeUtente->setText(m_qvt->configurazione().nomeUtenteProxyDefault());
lineEditPassword->setText(m_qvt->configurazione().passwordProxyDefault());
checkBoxUsareProxy->setChecked(m_qvt->configurazione().proxyUtilizzatoDefault());
checkBoxAutenticazione->setChecked(m_qvt->configurazione().proxyRichiedeAutenticazioneDefault());
checkBoxUsareProxySistema->setChecked(m_qvt->configurazione().proxyDiSistemaUtilizzatoDefault());
// simula la selezione delle due checkbox nella scheda Proxy
checkBoxAutenticazioneCliccato(m_qvt->configurazione().proxyRichiedeAutenticazioneDefault());
checkBoxUsareProxyCliccato(m_qvt->configurazione().proxyUtilizzatoDefault());
}
//abilita/disabilita i controlli a seconda dello stato del check box checkBoxUsareProxy
void DialogoConfigurazione::checkBoxUsareProxyCliccato(bool selezionato)
{
if (selezionato)
{
checkBoxUsareProxySistema->setEnabled(true);
if (!checkBoxUsareProxySistema->isChecked())
{
lineEditHost->setEnabled(true);
spinBoxPorta->setEnabled(true);
labelHost->setEnabled(true);
labelPorta->setEnabled(true);
checkBoxAutenticazione->setEnabled(true);
checkBoxAutenticazioneCliccato(checkBoxAutenticazione->isChecked());
}
}
else //disattiva tutto
{
checkBoxUsareProxySistema->setDisabled(true);
lineEditHost->setDisabled(true);
spinBoxPorta->setDisabled(true);
checkBoxAutenticazione->setDisabled(true);
lineEditNomeUtente->setDisabled(true);
lineEditPassword->setDisabled(true);
labelHost->setDisabled(true);
labelPorta->setDisabled(true);
labelNomeUtente->setDisabled(true);
labelPassword->setDisabled(true);
}
}
//abilita/disabilita i controlli a seconda dello stato del check box checkBoxAutenticazione
void DialogoConfigurazione::checkBoxAutenticazioneCliccato(bool selezionato)
{
if (selezionato)
{
lineEditNomeUtente->setEnabled(true);
lineEditPassword->setEnabled(true);
labelNomeUtente->setEnabled(true);
labelPassword->setEnabled(true);
}
else
{
lineEditNomeUtente->setDisabled(true);
lineEditPassword->setDisabled(true);
labelNomeUtente->setDisabled(true);
labelPassword->setDisabled(true);
}
}
//abilita/disabilita i controlli a seconda dello stato del check box checkBoxUsareProxySistema
void DialogoConfigurazione::checkBoxUsareProxySistemaCliccato(bool selezionato)
{
//il checkbox è stato selezionato, disattivare tutti i controlli per la configurazione
//manuale del proxy
if (selezionato)
{
lineEditHost->setDisabled(true);
spinBoxPorta->setDisabled(true);
checkBoxAutenticazione->setDisabled(true);
lineEditNomeUtente->setDisabled(true);
lineEditPassword->setDisabled(true);
labelHost->setDisabled(true);
labelPorta->setDisabled(true);
labelNomeUtente->setDisabled(true);
labelPassword->setDisabled(true);
}
else
//il checkBox non è stato selezionato, attivare i controlli
{
lineEditHost->setEnabled(true);
spinBoxPorta->setEnabled(true);
labelHost->setEnabled(true);
labelPorta->setEnabled(true);
checkBoxAutenticazione->setEnabled(true);
//abilita i controlli per l'autenticazione solo se il checkbox corrispondente è selezionato
if (checkBoxAutenticazione->isChecked())
{
labelNomeUtente->setEnabled(true);
labelPassword->setEnabled(true);
lineEditNomeUtente->setEnabled(true);
lineEditPassword->setEnabled(true);
}
}
}
qviaggiatreno-2013.7.3/src/schedalistatreni_widget.cpp 0000664 0001750 0001750 00000036663 12215773217 023000 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2009-2011 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "schedalistatreni.h"
#include "items.h"
WidgetListaTreni::WidgetListaTreni(SchedaListaTreni* parent): QWidget(parent)
{
//imposta il layout del widget;
QVBoxLayout * layout = new QVBoxLayout;
setLayout(layout);
//costruisce l'etichetta per il titolo
m_labelTitolo = new QLabel(this);
//l'etichetta sarà centrata
m_labelTitolo->setAlignment(Qt::AlignCenter);
//imposta font con dimensioni del 50% maggiori di quella standard e in grassetto
QFont font = m_labelTitolo->font();
font.setBold(true);
font.setPointSize(font.pointSize()*1.5);
m_labelTitolo->setFont(font);
//aggiunge l'etichetta al layout
layout->addWidget(m_labelTitolo, 0);
//costruisce l'etichetta con ora/data di aggiornamento
m_labelAggiornamento = new QLabel(this);
//l'etichetta sarà centrata
m_labelAggiornamento->setAlignment(Qt::AlignCenter);
layout->addWidget(m_labelAggiornamento, 0);
m_tabella = new TabellaLista(this);
//imposta le colonne della tabella
QStringList righe;
righe<setRowCount(righe.count());
m_tabella->setVerticalHeaderLabels(righe);
layout->addWidget(m_tabella, 1 );
//connessioni
// connect(m_tabella, SIGNAL(cellEntered(int, int)), this, SLOT(ingressoCella(int, int)));
//connect(m_tabella, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(itemAttivato(QTableWidgetItem*)));
connect(m_tabella, SIGNAL(itemClicked(QTableWidgetItem *)), this, SLOT(itemAttivato(QTableWidgetItem*)));
connect(this, SIGNAL(apriSchedaStazione(const QString&, bool)), parent, SIGNAL(apriSchedaStazione(const QString&, bool)));
connect(this, SIGNAL(apriSchedaTreno(const QString&)), parent, SIGNAL(apriSchedaTreno(const QString&)));
}
void WidgetListaTreni::itemAttivato(QTableWidgetItem* item)
{
int riga = item->row();
if (riga == ListaVT::rigaNumero)
if (item->text() != "")
emit(apriSchedaTreno(item->text()));
if ((riga == ListaVT::rigaOrigine) || (riga == ListaVT::rigaDestinazione) || (riga == ListaVT::rigaUltimaFermata))
if (item->text() != "")
emit(apriSchedaStazione(ParserViaggiaTrenoBase::sostituisciNomeStazione(item->text()), true));
}
//aggiunge un treno al widget
void WidgetListaTreni::aggiungiTreno(ListaVT::DatiTreno *treno)
{
int col;
for (col = 0; col < m_tabella->columnCount(); col++)
{
QTableWidgetItem *item = m_tabella->item(ListaVT::rigaNumero, col);
if (!item)
break;
else
if (treno->numero().toInt() < item->text().toInt())
break;
}
//aggiungi una nuova riga in fondo alla tabella
m_tabella->insertColumn(col);
//imposta le celle
impostaCella(ListaVT::rigaNumero, col, treno->numero());
impostaCella(ListaVT::rigaStato, col, treno->stringaStatoTreno());
}
//rimuove un treno dal widget
void WidgetListaTreni::rimuoviTreno(const QString& treno)
{
for (int col = 0; col < m_tabella->columnCount(); col++)
{
QTableWidgetItem *item = m_tabella->item(ListaVT::rigaNumero, col);
if (item)
if (item->text() == treno)
{
m_tabella->removeColumn(col);
return;
}
}
}
//imposta il testo della cella impostando contemporaneamente ogni eventuale formattazione necessaria
void WidgetListaTreni::impostaCella(int riga, int colonna, const QString& testo)
{
QTableWidgetItem *item = new QTableWidgetItem;
item->setText(testo.simplified());
QFont font = item->font();
//sottolinea il testo nelle colonne in cui è necessario ed usa il colore dei link
if (riga == ListaVT::rigaNumero || riga == ListaVT::rigaOrigine || riga == ListaVT::rigaDestinazione || riga == ListaVT::rigaUltimaFermata)
{
font.setUnderline(true);
item->setForeground(QApplication::palette().link());
}
item->setFont(font);
m_tabella->setItem(riga, colonna, item);
}
int WidgetListaTreni::larghezzaItem(const QTableWidgetItem* item)
{
if (!item)
return -1;
QFontMetrics fm(item->font());
int larghezza = fm.width(item->text());
return larghezza;
}
//aggiusta la dimensione delle colonne della tabella in modo che il contenuto delle celle sia visibile
//non usa resizeColumnsToContents perché funziona solo sulla parte visibile delle colonne
void WidgetListaTreni::ridimensionaColonne()
{
int larghezza;
//calcola la larghezza massima
for (int col = 0; col <= m_tabella->columnCount(); col++)
{
larghezza = m_tabella->horizontalHeader()->sectionSizeHint(col);
for (int riga = 0; riga < m_tabella->rowCount(); riga++)
larghezza = qMax(larghezza, larghezzaItem(m_tabella->item(riga, col)));
m_tabella->setColumnWidth(col, larghezza+10);
}
}
void WidgetListaTreni::impostaTitolo(const QString& titolo)
{
m_labelTitolo->setText(titolo);
}
void WidgetListaTreni::aggiornaTreno(const ListaVT::DatiTreno* treno)
{
int colonna = -1;
//ricerca la riga relativa al treno da aggiornare
for (int i=0; icolumnCount();i++)
{
QTableWidgetItem* item = m_tabella->item(ListaVT::rigaNumero, i);
if (!(item->text().compare(treno->numero())))
colonna = i;
}
//aggiorna tutte le colonne (tranne quella del numero)
impostaCella(ListaVT::rigaCategoria, colonna, treno->dato(ListaVT::dtCategoria));
impostaCella(ListaVT::rigaStato, colonna, treno->stringaStatoTreno());
impostaCella(ListaVT::rigaOrigine, colonna, treno->dato(ListaVT::dtOrigine));
impostaCella(ListaVT::rigaPartenzaProgrammata, colonna, treno->dato(ListaVT::dtPartenzaProgrammata));
impostaCella(ListaVT::rigaPartenzaEffettiva, colonna, treno->dato(ListaVT::dtPartenzaEffettiva));
impostaCella(ListaVT::rigaDestinazione, colonna, treno->dato(ListaVT::dtDestinazione));
impostaCella(ListaVT::rigaArrivoProgrammato, colonna, treno->dato(ListaVT::dtArrivoProgrammato));
impostaCella(ListaVT::rigaArrivoEffettivo, colonna, treno->dato(ListaVT::dtArrivoEffettivo));
impostaCella(ListaVT::rigaUltimaFermata, colonna, treno->dato(ListaVT::dtUltimaFermata));
impostaCella(ListaVT::rigaOrarioFermataProgrammato, colonna, treno->dato(ListaVT::dtOrarioFermataProgrammato));
impostaCella(ListaVT::rigaOrarioFermataEffettivo, colonna, treno->dato(ListaVT::dtOrarioFermataEffettivo));
impostaCella(ListaVT::rigaUltimoRilevamento, colonna, treno->dato(ListaVT::dtUltimoRilevamento));
impostaCella(ListaVT::rigaOrarioTransito, colonna, treno->dato(ListaVT::dtOrarioTransito));
impostaCella(ListaVT::rigaRitardoTransito, colonna, treno->dato(ListaVT::dtRitardoTransito));
ridimensionaColonne();
}
//imposta l'etichetta con ora e data del completamento dell'ultimo treno
void WidgetListaTreni::impostaAggiornamento(const QString& testo, bool errore)
{
//se errore è true allora il parsing non è andato a buon fine, imposta il messaggio in rosso
//e grassetto per evidenziarlo
if (errore)
m_labelAggiornamento->setText(QString("%1").arg(testo));
else
m_labelAggiornamento->setText(testo);
}
//Questo dialogo viene visualizzato quando si è scelto da menu o toolbar la voce per
//aggiungere uno o più treni alla lista dei treni da monitorare
DialogoAggiuntaTreni::DialogoAggiuntaTreni(QWidget *parent) : QDialog(parent)
{
//imposta il titolo
setWindowTitle(QString::fromUtf8("Aggiunta treni alla lista"));
//layout principale del dialogo
QVBoxLayout *layout = new QVBoxLayout;
setLayout(layout);
//layout orizzontale
QHBoxLayout *hlayout = new QHBoxLayout;
layout->addLayout(hlayout, 0);
//casella di testo per l'inserimento del numero del treno
QLabel *labelLineEdit = new QLabel(QString::fromUtf8("Numero treno:"), this);
hlayout->addWidget(labelLineEdit, 0);
m_lineedit = new QLineEdit(this);
//la casella accetta solo numeri interi tra 1 e 99999
QIntValidator *validator = new QIntValidator(1, 99999, this);
m_lineedit->setValidator(validator);
QPushButton *aggiungi = new QPushButton(QString::fromUtf8("Aggiungi treno"), this);
aggiungi->setDefault(true);
hlayout->addWidget(m_lineedit, 1);
hlayout->addWidget(aggiungi, 0);
QLabel *labelListWidget = new QLabel(QString::fromUtf8("Elenco treni da aggiungere:"));
layout->addWidget(labelListWidget, 0);
m_listwidget = new QListWidget(this);
layout->addWidget(m_listwidget, 1);
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
buttonBox->addButton(QString::fromUtf8("&Aggiungi treni"), QDialogButtonBox::AcceptRole);
buttonBox->addButton(QDialogButtonBox::Cancel);
qobject_cast(buttonBox->buttons().at(0))->setAutoDefault(true);
layout->addWidget(buttonBox, 0);
//abilita l'ordinamento
m_listwidget->setSortingEnabled(true);
//connessioni
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(aggiungi, SIGNAL(clicked()), this, SLOT(aggiungiTreno()));
}
//elimina tutti i treni dalla tabella
void WidgetListaTreni::rimuoviTuttiITreni()
{
m_tabella->clearContents();
m_tabella->setColumnCount(0);
}
//slot
void DialogoAggiuntaTreni::aggiungiTreno()
{
//richiesto da QIntValidator ma non utilizzato
int pos;
QString treno = m_lineedit->text();
if (m_lineedit->validator()->validate(treno, pos) == QValidator::Acceptable)
{
//verifica che il numero non sia già nell'elenco dei numeri da aggiungere
for (int i = 0; i < m_listwidget->count(); i++)
{// i numeri sono uguali, esci dalla funzione senza far niente
if (treno.compare(m_listwidget->item(i)->text()) == 0)
return;
}
SortedAsIntListWidgetItem * item = new SortedAsIntListWidgetItem(treno);
m_listwidget->addItem(item);
m_lineedit->clear();
}
m_listwidget->sortItems();
}
//restituisce una lista di stringa contentente tutti i numeri dei treni
//di cui è stata richiesta l'aggiunta
QStringList DialogoAggiuntaTreni::listaTreni() const
{
QStringList lista;
for (int i = 0; i < m_listwidget->count(); i++ )
lista.append(m_listwidget->item(i)->text());
return lista;
}
//restituisce true se non ci sono treni da aggiungere, false in caso contrario
bool DialogoAggiuntaTreni::listaVuota() const
{
return (m_listwidget->count() == 0);
}
//Questo dialogo viene visualizzato quando si è scelto da menu o toolbar la voce per
//rimuovere uno o più treni dalla lista dei treni da monitorare
DialogoRimozioneTreni::DialogoRimozioneTreni(const QStringList& lista, QWidget * parent) : QDialog(parent)
{
setWindowTitle(QString::fromUtf8("Rimozione treni dalla lista"));
//layout principale del dialogo
QVBoxLayout *layout = new QVBoxLayout;
setLayout(layout);
QLabel *labelLista = new QLabel(QString::fromUtf8("Elenco treni:"));
layout->addWidget(labelLista, 0);
m_listwidget = new QListWidget(this);
layout->addWidget(m_listwidget, 1);
m_listwidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
m_listwidget->setSortingEnabled(true);
m_buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
m_buttonBox->addButton(QString::fromUtf8("&Rimuovi treni"), QDialogButtonBox::AcceptRole);
m_buttonBox->addButton(QDialogButtonBox::Cancel);
layout->addWidget(m_buttonBox, 0);
//riempie il listwidget
QStringListIterator it(lista);
while (it.hasNext())
m_listwidget->addItem(new SortedAsIntListWidgetItem(it.next()));
//disabilita il pulsante "rimuovi treni"
m_buttonBox->buttons().at(0)->setEnabled(false);
//connessioni
connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(m_listwidget, SIGNAL(itemSelectionChanged()), this, SLOT(selezioneModificata()));
}
//slot
//questo slot attiva il pulsante "rimuovi treni" solo nel caso che ci sia almeno
//un item selezionato nel listwidget, altrimenti lo disattiva
void DialogoRimozioneTreni::selezioneModificata()
{
m_buttonBox->buttons().at(0)->setEnabled(m_listwidget->selectedItems().count());
}
//restituisce la lista dei treni attualmente selezionati per la rimozione
QStringList DialogoRimozioneTreni::listaTreni() const
{
QStringList lista;
QListIterator it(m_listwidget->selectedItems());
while (it.hasNext())
{
lista.append(it.next()->text());
}
return lista;
}
TabellaLista::TabellaLista(QWidget *parent) : QTableWidget(parent)
{
//imposta le caratteristiche della tabella
//righe a colori alternati
setAlternatingRowColors(true);
//disattiva selezione
setSelectionMode(QAbstractItemView::NoSelection);
//disattiva modifiche delle celle
setEditTriggers(QAbstractItemView::NoEditTriggers);
//attiva il tracking del mouse
setMouseTracking(true);
verticalHeader()->setMouseTracking(true);
horizontalHeader()->setVisible(false);
}
void TabellaLista::mouseMoveEvent(QMouseEvent *event)
{
//cambia cursore solo se c'è almeno un treno in lista
if (columnCount() != 0)
{
int riga = rowAt(event->y());
if (riga == ListaVT::rigaNumero || riga == ListaVT::rigaOrigine || riga == ListaVT::rigaDestinazione || riga == ListaVT::rigaUltimaFermata )
setCursor(Qt::PointingHandCursor);
else
setCursor(Qt::ArrowCursor);
}
event->accept();
}
qviaggiatreno-2013.7.3/src/qviaggiatreno.cpp 0000664 0001750 0001750 00000054574 12215773217 020750 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2008-2011 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include
#include "schedastazione.h"
#include "schedalistatreni.h"
#include "qviaggiatreno.h"
#include "download_viaggiatreno.h"
#include "download_trenord.h"
#include "qledindicator.h"
//numero versione
QString QViaggiaTreno::s_versione = QString("2013.7");
QViaggiaTreno::QViaggiaTreno()
{
m_licenseDialog = 0L;
m_nam = new QNetworkAccessManager(this);
//crea una istanza delle varie classi per il download
m_downloadViaggiaTreno = new DownloadViaggiaTreno(this, m_nam);
m_downloadTrenord = new DownloadTrenord(this, m_nam);
creaAzioni();
creaMenu();
creaToolBar();
creaStatusBar();
creaWidgetCentrale();
setWindowTitle(QString::fromUtf8("QViaggiaTreno"));
leggiImpostazioniFinestra();
impostaProxy();
//avvia le varie classi per il download
//per il momento esiste solo la classe per il download da viaggiatreno in futuro è conveniente
//incapsulare l'avvio in un metodo
connect(m_downloadViaggiaTreno, SIGNAL(statoViaggiaTreno(bool)), this, SLOT(statoViaggiaTrenoCambiato(bool)));
m_downloadViaggiaTreno->avvia();
ripristinaSchede();
}
void QViaggiaTreno::creaAzioni()
{
m_exitAct = new QAction(QString::fromUtf8("E&sci"), this);
m_exitAct->setShortcut(QString("Ctrl+Q"));
m_exitAct->setStatusTip(QString::fromUtf8("Chiude l'applicazione"));
connect(m_exitAct, SIGNAL(triggered()), this, SLOT(close()));
m_licenseAct = new QAction(QString::fromUtf8("Licen&za"), this);
m_licenseAct->setStatusTip(QString::fromUtf8("Mostra la licenza di QViaggiaTreno"));
connect(m_licenseAct, SIGNAL(triggered()), this, SLOT(visualizzaLicenza()));
m_aboutAct = new QAction(QString::fromUtf8("Informazioni &su QViaggiaTreno"), this);
m_aboutAct->setStatusTip(QString::fromUtf8("Mostra la finestra di informazione sull'applicazione"));
connect(m_aboutAct, SIGNAL(triggered()), this, SLOT(about()));
m_aboutQtAct = new QAction(QString::fromUtf8("Informazioni su &Qt"), this);
m_aboutQtAct->setStatusTip(QString::fromUtf8("Mostra la finestra di informazioni sulla libreria Qt"));
connect(m_aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
m_nuovaStazioneAct = new QAction(QString::fromUtf8("Stazione..."), this);
m_nuovaStazioneAct->setStatusTip(QString::fromUtf8("Controlla una stazione con ViaggiaTreno"));
m_nuovaStazioneAct->setIcon(QIcon(":/img/stazione.png"));
connect(m_nuovaStazioneAct, SIGNAL(triggered()), this ,SLOT(nuovaStazione()));
m_nuovoTrenoAct = new QAction(QString::fromUtf8("Treno..."), this);
m_nuovoTrenoAct->setStatusTip(QString::fromUtf8("Controlla un treno con ViaggiaTreno"));
m_nuovoTrenoAct->setIcon(QIcon(":/img/treno.png"));
connect(m_nuovoTrenoAct, SIGNAL(triggered()), this, SLOT(nuovoTreno()));
m_nuovaListaTreniAct = new QAction(QString::fromUtf8("Lista di treni"), this);
m_nuovaListaTreniAct->setStatusTip(QString::fromUtf8("Controlla una lista di treni con ViaggiaTreno"));
m_nuovaListaTreniAct->setIcon(QIcon(":/img/listatreni.png"));
connect(m_nuovaListaTreniAct, SIGNAL(triggered()), this, SLOT(nuovaListaTreni()));
m_avvisiTrenordAct = new QAction(QString::fromUtf8("Avvisi Trenord"), this);
m_avvisiTrenordAct->setStatusTip(QString::fromUtf8("Controlla gli avvisi di Trenord"));
m_avvisiTrenordAct->setIcon(QIcon(":/img/trenord.png"));
connect(m_avvisiTrenordAct, SIGNAL(triggered()), this, SLOT(nuovaSchedaAvvisiTrenord()));
m_intervalloAct = new QAction(QString::fromUtf8("Cambia intervallo aggiornamento..."), this);
m_intervalloAct->setStatusTip(QString::fromUtf8("Cambia l'intervallo di aggiornamento della scheda corrente"));
m_intervalloAct->setIcon(QIcon(":/img/cronometro.png"));
connect(m_intervalloAct, SIGNAL(triggered()), this, SLOT(modificaIntervallo()));
m_intervalloAct->setDisabled(true);
m_avviaAct = new QAction(QString::fromUtf8("Avvia"), this);
m_avviaAct->setStatusTip(QString::fromUtf8("Avvia/riprendi il monitoraggio con Viaggiatreno"));
m_avviaAct->setIcon(QIcon(":/img/avvia.png"));
connect(m_avviaAct, SIGNAL(triggered()), this, SLOT(avvia()));
m_avviaAct->setDisabled(true);
m_fermaAct = new QAction(QString::fromUtf8("Ferma"), this);
m_fermaAct->setStatusTip(QString::fromUtf8("Interrompi il monitoraggio con ViaggiaTreno"));
m_fermaAct->setIcon(QIcon(":/img/interrompi.png"));
connect(m_fermaAct, SIGNAL(triggered()), this, SLOT(ferma()));
m_fermaAct->setDisabled(true);
m_fermaTutteAct = new QAction(QString::fromUtf8("Ferma tutte le schede"), this);
m_fermaTutteAct->setStatusTip(QString::fromUtf8("Interrompi il monitoraggio con ViaggiaTreno per tutte le schede"));
connect(m_fermaTutteAct, SIGNAL(triggered()), this, SLOT(fermaTutte()));
m_avviaTutteAct = new QAction(QString::fromUtf8("Avvia tutte le schede"), this);
m_avviaTutteAct->setStatusTip(QString::fromUtf8("Avvia/riprendi il monitoraggio con ViaggiaTreno per tutte le schede"));
connect(m_avviaTutteAct, SIGNAL(triggered()), this, SLOT(avviaTutte()));
m_riprovaComunicazioneConVTAct = new QAction(QString::fromUtf8("Ritenta comunicazione con &ViaggiaTreno"), this);
m_riprovaComunicazioneConVTAct->setStatusTip(QString::fromUtf8("prova a verificare se la comunicazione con"
"ViaggiaTreno ha ripreso a funzionare normalmente"));
connect(m_riprovaComunicazioneConVTAct, SIGNAL(triggered()), m_downloadViaggiaTreno, SLOT(avvia()));
m_riprovaComunicazioneConVTAct->setDisabled(true);
m_aggiornaAct = new QAction(QString::fromUtf8("Aggiorna"), this);
m_aggiornaAct-> setStatusTip(QString::fromUtf8("Aggiorna la scheda corrente"));
m_aggiornaAct->setIcon(QIcon(":/img/aggiorna.png"));
connect(m_aggiornaAct, SIGNAL(triggered()), this, SLOT(aggiorna()));
m_aggiornaAct->setDisabled(true);
m_configuraAct = new QAction(QString::fromUtf8("Configura QViaggiaTreno..."), this);
m_configuraAct->setStatusTip(QString::fromUtf8("Mostra la finestra di configurazione di QViaggiaTreno"));
m_configuraAct->setIcon(QIcon(":/img/configura.png"));
connect(m_configuraAct, SIGNAL(triggered()), this, SLOT(configura()));
m_stampaSchedaAct = new QAction(QString::fromUtf8("Stam&pa scheda corrente..."), this);
m_stampaSchedaAct->setStatusTip(QString::fromUtf8("Stampa la scheda corrente"));
m_stampaSchedaAct->setIcon(QIcon(":img/stampa.png"));
connect(m_stampaSchedaAct, SIGNAL(triggered()), this, SLOT(stampaSchedaCorrente()));
m_stampaSchedaAct->setDisabled(true);
m_esportaSchedaAct = new QAction(QString::fromUtf8("Esporta sche&da corrente..."), this);
m_esportaSchedaAct->setStatusTip(QString::fromUtf8("Esporta la scheda corrente in formato HTML o PDF"));
m_esportaSchedaAct->setIcon(QIcon(":img/esporta.png"));
connect(m_esportaSchedaAct, SIGNAL(triggered()), this, SLOT(esportaSchedaCorrente()));
m_esportaSchedaAct->setDisabled(true);
//crea azioni per i vari menu specifici per tipo di scheda
m_cambiaNomeStazioneAct = new QAction(QString::fromUtf8("Cambia nome sta&zione..."), this);
connect(m_cambiaNomeStazioneAct, SIGNAL(triggered()), this, SLOT(modificaNomeStazione()));
m_apriAct = new QAction(QString::fromUtf8("Apri..."), this);
m_apriAct->setStatusTip(QString::fromUtf8("Apre una lista di treni"));
m_apriAct->setIcon(QIcon(":/img/apri.png"));
connect(m_apriAct, SIGNAL(triggered()), this, SLOT(apri()));
m_salvaAct = new QAction(QString::fromUtf8("Salva"), this);
m_salvaAct->setStatusTip(QString::fromUtf8("Salva una lista di treni"));
m_salvaAct->setIcon(QIcon(":/img/salva.png"));
connect(m_salvaAct, SIGNAL(triggered()), this, SLOT(salva()));
m_salvaConNomeAct = new QAction(QString::fromUtf8("Salva con nome..."), this);
m_salvaConNomeAct->setStatusTip(QString::fromUtf8("Salva una lista di treni con un nuovo nome"));
m_salvaConNomeAct->setIcon(QIcon(":/img/salva-come.png"));
connect(m_salvaConNomeAct, SIGNAL(triggered()), this, SLOT(salvaConNome()));
m_aggiungiTrenoAct = new QAction(QString::fromUtf8("Aggiungi treni alla lista..."), this);
m_aggiungiTrenoAct->setStatusTip(QString::fromUtf8("Aggiungi uno o più treni alla lista dei treni da controllare"));
m_aggiungiTrenoAct->setIcon(QIcon(":/img/aggiungi.png"));
connect(m_aggiungiTrenoAct, SIGNAL(triggered()), this, SLOT(aggiungiTreni()));
m_rimuoviTrenoAct = new QAction(QString::fromUtf8("Rimuovi treni dalla lista..."), this);
m_rimuoviTrenoAct->setStatusTip(QString::fromUtf8("Rimuovi uno o più treni dalla lista dei treni da controllare"));
m_rimuoviTrenoAct->setIcon(QIcon(":/img/rimuovi.png"));
connect(m_rimuoviTrenoAct, SIGNAL(triggered()), this, SLOT(rimuoviTreni()));
m_rimuoviTuttiAct = new QAction(QString::fromUtf8("Rimuovi tutti i treni dalla lista"), this);
m_rimuoviTuttiAct->setStatusTip(QString::fromUtf8("Rimuovi tutti i treni dalla lista dei treni da controllare"));
m_rimuoviTuttiAct->setIcon(QIcon(":/img/cancella-tutti.png"));
connect(m_rimuoviTuttiAct, SIGNAL(triggered()), this, SLOT(rimuoviTuttiITreni()));
m_impostaTitoloAct = new QAction(QString::fromUtf8("Imposta il titolo..."), this);
m_impostaTitoloAct->setStatusTip(QString::fromUtf8("Imposta il titolo della lista di treni"));
connect(m_impostaTitoloAct, SIGNAL(triggered()), this, SLOT(impostaTitolo()));
}
void QViaggiaTreno::creaMenu()
{
m_viaggiatrenoMenu = menuBar()->addMenu("&QViaggiaTreno");
m_viaggiatrenoMenu->addAction(m_nuovaStazioneAct);
m_viaggiatrenoMenu->addAction(m_nuovoTrenoAct);
m_viaggiatrenoMenu->addAction(m_nuovaListaTreniAct);
m_viaggiatrenoMenu->addSeparator();
//TODO rimossa temporaneamente voce scheda trenord ripristinare
// m_viaggiatrenoMenu->addAction(m_avvisiTrenordAct);
m_viaggiatrenoMenu->addSeparator();
//TODO: rimuovere commenti quando sarà pronto il codice per l'esportazione/stampa
// m_viaggiatrenoMenu->addAction(m_esportaSchedaAct);
// m_viaggiatrenoMenu->addAction(m_stampaSchedaAct);
// m_viaggiatrenoMenu->addSeparator();
m_viaggiatrenoMenu->addAction(m_avviaAct);
m_viaggiatrenoMenu->addAction(m_fermaAct);
m_viaggiatrenoMenu->addAction(m_aggiornaAct);
m_viaggiatrenoMenu->addAction(m_intervalloAct);
m_viaggiatrenoMenu->addSeparator();
m_viaggiatrenoMenu->addAction(m_avviaTutteAct);
m_viaggiatrenoMenu->addAction(m_fermaTutteAct);
m_viaggiatrenoMenu->addAction(m_riprovaComunicazioneConVTAct);
m_viaggiatrenoMenu->addSeparator();
m_viaggiatrenoMenu->addAction(m_exitAct);
//crea menu specifici per ogni tipo di scheda
// scheda stazione
m_stazioneMenu = menuBar()->addMenu("Sta&zione");
m_stazioneMenu->addAction(m_cambiaNomeStazioneAct);
//scheda treno
m_trenoMenu = menuBar()->addMenu("Tre&no");
//scheda lista treni
m_listaTreniMenu = menuBar()->addMenu("Lis&ta treni");
m_listaTreniMenu->addAction(m_apriAct);
m_listaTreniMenu->addAction(m_salvaAct);
m_listaTreniMenu->addAction(m_salvaConNomeAct);
m_listaTreniMenu->addSeparator();
m_listaTreniMenu->addAction(m_aggiungiTrenoAct);
m_listaTreniMenu->addAction(m_rimuoviTrenoAct);
m_listaTreniMenu->addAction(m_rimuoviTuttiAct);
m_listaTreniMenu->addSeparator();
m_listaTreniMenu->addAction(m_impostaTitoloAct);
//nascondi i menu specifici per ogni scheda
m_stazioneMenu->menuAction()->setVisible(false);
m_trenoMenu->menuAction()->setVisible(false);
m_listaTreniMenu->menuAction()->setVisible(false);
m_opzioniMenu = menuBar()->addMenu(QString::fromUtf8("&Strumenti"));
m_opzioniMenu->addAction(m_configuraAct);
m_helpMenu = menuBar()->addMenu("&Aiuto");
m_helpMenu->addAction(m_licenseAct);
m_helpMenu->addSeparator();
m_helpMenu->addAction(m_aboutAct);
m_helpMenu->addAction(m_aboutQtAct);
}
void QViaggiaTreno::creaToolBar()
{
m_mainToolBar = addToolBar("Barra strumenti principale");
m_mainToolBar->addAction(m_nuovaStazioneAct);
m_mainToolBar->addAction(m_nuovoTrenoAct);
m_mainToolBar->addAction(m_nuovaListaTreniAct);
//TODO rimossaa icona scheda trenod da toolbar ripristinare
// m_mainToolBar->addAction(m_avvisiTrenordAct);
m_mainToolBar->addSeparator();
//TODO: rimuovere commenti quando sarà pronto il codice per l'esportazione/stampa
// m_mainToolBar->addAction(m_stampaSchedaAct);
// m_mainToolBar->addAction(m_esportaSchedaAct);
// m_mainToolBar->addSeparator();
m_mainToolBar->addAction(m_aggiornaAct);
m_mainToolBar->addAction(m_avviaAct);
m_mainToolBar->addAction(m_fermaAct);
m_spinIntervallo = new QSpinBox(this);
m_spinIntervallo->setRange(1, 1440);
m_spinIntervallo->setSuffix(" min");
m_spinIntervalloAct = m_mainToolBar->addWidget(m_spinIntervallo);
m_spinIntervalloAct->setDisabled(true);
//connessioni
connect(m_spinIntervallo, SIGNAL(valueChanged(int)), this, SLOT(modificaIntervalloConSpinBox(int)));
m_listaToolbar = addToolBar("Barra strumenti lista treni");
m_listaToolbar->addAction(m_apriAct);
m_listaToolbar->addAction(m_salvaAct);
m_listaToolbar->addAction(m_salvaConNomeAct);
m_listaToolbar->addSeparator();
m_listaToolbar->addAction(m_aggiungiTrenoAct);
m_listaToolbar->addAction(m_rimuoviTrenoAct);
m_listaToolbar->addAction(m_rimuoviTuttiAct);
m_listaToolbar->setVisible(false);
}
void QViaggiaTreno::creaWidgetCentrale()
{
m_schede = new QTabWidget(this);
//rende le schede muovibili
m_schede->setMovable(true);
//aggiunge pulsante di chiusura della scheda corrente
m_schede->setTabsClosable(true);
setCentralWidget(m_schede);
//connessioni
connect(m_schede, SIGNAL(currentChanged(int)), this, SLOT(schedaCambiata(int)));
connect(m_schede, SIGNAL(tabCloseRequested(int)), this, SLOT(chiudiScheda(int)));
}
void QViaggiaTreno::creaStatusBar()
{
//crea un indicatore a LED per visualizzare lo stato della connessione a viaggiatreno
m_ledStatoViaggiaTreno = new QLedIndicator(this);
statusBar()->addPermanentWidget(m_ledStatoViaggiaTreno);
statusBar()->showMessage("Pronto");
}
void QViaggiaTreno::leggiImpostazioniFinestra()
{
QSettings settings(QSettings::IniFormat, QSettings::UserScope, "fra74", "QViaggiaTreno");
//legge impostazioni su posizione e dimensione finestra
settings.beginGroup("Finestra principale");
resize(settings.value("dimensione", QSize(400, 400)).toSize());
move(settings.value("posizione", QPoint(200, 200)).toPoint());
settings.endGroup();
//legge lista delle ultime stazioni monitorate
settings.beginGroup("Stazioni monitorate");
maxStazioni = settings.value("max", 20).toInt();
m_listaStazioniMonitorate = settings.value("Lista").toStringList();
settings.endGroup();
}
//ripristina le schede aperte nella sessione precedente di QviaggiaTreno
void QViaggiaTreno::ripristinaSchede()
{
QSettings settings(QSettings::IniFormat, QSettings::UserScope, "fra74", "QViaggiaTreno");
//recupera il numero di schede da ripristinare
settings.beginGroup("Schede aperte");
int numero = settings.value("numero", 0).toInt();
//recupera l'indice della scheda corrente al momento della chiusura
int schedaCorrente = settings.value("scheda corrente", -1).toInt();
settings.endGroup();
for (int i = 1; i <= numero; i++)
{
settings.beginGroup(QString("Scheda %1").arg(i));
//recupera il tipo di scheda
QString tipo = settings.value("tipo scheda").toString();
if (tipo == "treno")
{
//recupera numero treno e intervallo di aggiornamento
QString numero = settings.value("numero treno").toString();
int intervallo = settings.value("intervallo").toInt();
QString codice = settings.value("codice stazione origine").toString();
//crea la scheda
nuovoTreno(numero, codice, intervallo);
}
if (tipo == "stazione")
{
//recupera intervallo di aggiornamento e nome stazione
int intervallo = settings.value("intervallo").toInt();
QString stazione = settings.value("nome stazione").toString();
QString codice = settings.value("codice stazione").toString();
//crea la scheda ma NON la avvia
SchedaStazione *scheda = nuovaStazione(stazione, false, intervallo, true);
if (codice != "")
scheda->cambiaCodiceStazione(codice);
else
{
scheda->aggiorna();
scheda->avvia();
scheda->ripristinaFiltri(settings);
}
}
if (tipo == "lista treni")
{
//recupera nome file
QString nomefile = settings.value("nome file").toString();
SchedaListaTreni * scheda = nuovaListaTreni();
if (nomefile != "")
scheda->apriFile(nomefile);
}
settings.endGroup();
}
//seleziona come scheda corrente la scheda che era selezionata al momento della chiusura
m_schede->setCurrentIndex(schedaCorrente);
}
void QViaggiaTreno::salvaSchede()
{
QSettings settings(QSettings::IniFormat, QSettings::UserScope, "fra74", "QViaggiaTreno");
//rimuove i gruppi relativi alle singole schede aperte in sessioni precedenti
settings.beginGroup("Schede aperte");
int schede = settings.value("numero", 0).toInt();
settings.endGroup();
for (int i = 1; i <= schede; i++)
{
settings.beginGroup(QString("Scheda %1").arg(i));
settings.remove("");
settings.endGroup();
}
//scrive numero di schede aperte
settings.beginGroup("Schede aperte");
schede = m_listaSchede.count();
settings.setValue("numero", schede);
//scrive il numero della scheda attualmente selezionata
settings.setValue("scheda corrente", m_schede->currentIndex());
settings.endGroup();
//scrive informazioni sulle schede aperte
for (int i = 0; i < m_schede->count(); i++)
{
settings.beginGroup(QString("Scheda %1").arg(i+1));
SchedaQViaggiaTreno* scheda = qobject_cast
(m_schede->widget(i));
scheda->salvaScheda(settings);
settings.endGroup();
}
}
void QViaggiaTreno::scriviImpostazioniFinestra()
{
QSettings settings(QSettings::IniFormat, QSettings::UserScope, "fra74", "QViaggiaTreno");
//scrive impostazioni su posizione e dimensione finestra
settings.beginGroup("Finestra principale");
settings.setValue("dimensione", size());
settings.setValue("posizione", pos());
settings.endGroup();
//scrive lista delle ultime stazioni monitorate
settings.beginGroup("Stazioni monitorate");
settings.setValue("max", maxStazioni);
settings.setValue("Lista", m_listaStazioniMonitorate);
settings.endGroup();
}
//questo metodo imposta il proxy utilizzato per tutte le connessioni alla rete. viene chiamato all'avvio del programma ed ogni volkta che si modifica la configurazione
void QViaggiaTreno::impostaProxy()
{
//se è stato selezionato utilizza il proxy di sistema
if (configurazione().proxyDiSistemaUtilizzato())
QNetworkProxyFactory::setUseSystemConfiguration(true);
else
{
QNetworkProxy networkProxy;
if (configurazione().proxyUtilizzato())
{
networkProxy.setType(QNetworkProxy::HttpProxy);
networkProxy.setHostName(configurazione().hostProxy());
networkProxy.setPort(configurazione().portaProxy());
if (configurazione().proxyRichiedeAutenticazione())
{
networkProxy.setUser(configurazione().nomeUtenteProxy());
networkProxy.setPassword(configurazione().passwordProxy());
}
}
else
networkProxy.setType(QNetworkProxy::NoProxy);
QNetworkProxy::setApplicationProxy(networkProxy);
}
}
QViaggiaTreno::~QViaggiaTreno()
{
}
//restituisce un puntatore alla scheda corrente (se esiste)
SchedaQViaggiaTreno * QViaggiaTreno::schedaCorrente()
{
//non ci sono schede restituisce un puntatore nullo
if (!m_schede->count())
return 0L;
else
return m_listaSchede.value(qobject_cast(m_schede->currentWidget())->idScheda());
}
SchedaQViaggiaTreno* QViaggiaTreno::scheda(quint32 id)
{
//non ci sono schede aperte, restituisci un puntatore nullo
if (!m_schede->count())
return 0L;
//non esiste una scheda con questo id
if (!m_listaSchede.contains(id))
return 0L;
else
return m_listaSchede[id];
}
//eventi
void QViaggiaTreno::closeEvent(QCloseEvent *event)
{
salvaSchede();
scriviImpostazioniFinestra();
//per il momento accettare senza condizioni l'evento di chiusura,
//lo scopo è solo quello di richiamare le funzioni di salvataggio delle impostazioni
event->accept();
}
//restituisce true se la scheda è ancora aperta
bool QViaggiaTreno::schedaAperta(SchedaQViaggiaTreno *scheda)
{
//cerca l'indice della scheda nel tab widget
//se è diverso da -1 allora la scheda esiste
return (m_schede->indexOf(scheda) != -1);
}
qviaggiatreno-2013.7.3/src/schedaavvisitrenord_widget.cpp 0000664 0001750 0001750 00000003303 12214355774 023505 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2008-2012 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "schedaavvisitrenord.h"
WidgetAvvisiTrenord::WidgetAvvisiTrenord(QWidget *parent, ModelloAvvisiTrenord* avvisi) : QWidget(parent)
{
setupUi(this);
QFont font = labelTitolo->font();
font.setBold(true);
font.setPointSize(font.pointSize()*1.5);
labelTitolo->setFont(font);
tabellaAvvisi->setModel(avvisi);
}
qviaggiatreno-2013.7.3/src/qledindicator.h 0000664 0001750 0001750 00000005771 12215773056 020373 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2010 by Tn *
* thenobody@poczta.fm *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef QLEDINDICATOR_H
#define QLEDINDICATOR_H
#include
#include
#include
#include
class QLedIndicator : public QAbstractButton
{
Q_PROPERTY(QColor onColor1 WRITE setOnColor1 READ getOnColor1 );
Q_PROPERTY(QColor onColor2 WRITE setOnColor2 READ getOnColor2 );
Q_PROPERTY(QColor offColor1 WRITE setOffColor1 READ getOffColor1 );
Q_PROPERTY(QColor offColor2 WRITE setOffColor2 READ getOffColor2 );
Q_OBJECT
public:
QLedIndicator(QWidget *parent);
void setOnColor1(QColor c) { onColor1 = c; }
void setOffColor1(QColor c) { offColor1 = c; }
void setOnColor2(QColor c) { onColor2 = c; }
void setOffColor2(QColor c) { offColor2 = c; }
QColor getOnColor1(void) { return onColor1; }
QColor getOffColor1(void) { return offColor1; }
QColor getOnColor2(void) { return onColor2; }
QColor getOffColor2(void) { return offColor2; }
protected:
virtual void paintEvent (QPaintEvent *event);
virtual void resizeEvent(QResizeEvent *event);
//trucchetto: il pulsante deve essere checkable altrimenti non è possibile cambiare stato
//ma non voglio che un utente possa cambiare stato con un click
virtual void nextCheckState() {setChecked(isChecked());};
private:
static const qreal scaledSize; /* init in cpp */
QColor onColor1, offColor1;
QColor onColor2, offColor2;
QPixmap ledBuffer;
};
#endif // QLEDINDICATOR_H
qviaggiatreno-2013.7.3/src/qledindicator.cpp 0000664 0001750 0001750 00000006520 12215773217 020716 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2010 by Tn *
* thenobody@poczta.fm *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include
#include "qledindicator.h"
const qreal QLedIndicator::scaledSize = 1000; /* Visual Studio static const mess */
QLedIndicator::QLedIndicator(QWidget *parent) : QAbstractButton(parent)
{
setMinimumSize(24,24);
setCheckable(true);
onColor1 = QColor(0,255,0);
onColor2 = QColor(0, 192, 0);
offColor1 = QColor(255,0,0);
offColor2 = QColor(192,0,0);
}
void QLedIndicator::resizeEvent(QResizeEvent *event) {
Q_UNUSED(event)
update();
}
void QLedIndicator::paintEvent(QPaintEvent *event) {
Q_UNUSED(event)
qreal realSize = qMin(width(), height());
QRadialGradient gradient;
QPainter painter(this);
QPen pen(Qt::black);
pen.setWidth(1);
painter.setRenderHint(QPainter::Antialiasing);
painter.translate(width()/2, height()/2);
painter.scale(realSize/scaledSize, realSize/scaledSize);
gradient = QRadialGradient (QPointF(-500,-500), 1500, QPointF(-500,-500));
gradient.setColorAt(0, QColor(224,224,224));
gradient.setColorAt(1, QColor(28,28,28));
painter.setPen(pen);
painter.setBrush(QBrush(gradient));
painter.drawEllipse(QPointF(0,0), 500, 500);
gradient = QRadialGradient (QPointF(500,500), 1500, QPointF(500,500));
gradient.setColorAt(0, QColor(224,224,224));
gradient.setColorAt(1, QColor(28,28,28));
painter.setPen(pen);
painter.setBrush(QBrush(gradient));
painter.drawEllipse(QPointF(0,0), 450, 450);
painter.setPen(pen);
if( isChecked() ) {
gradient = QRadialGradient (QPointF(-500,-500), 1500, QPointF(-500,-500));
gradient.setColorAt(0, onColor1);
gradient.setColorAt(1, onColor2);
} else {
gradient = QRadialGradient (QPointF(500,500), 1500, QPointF(500,500));
gradient.setColorAt(0, offColor1);
gradient.setColorAt(1, offColor2);
}
painter.setBrush(gradient);
painter.drawEllipse(QPointF(0,0), 400, 400);
}
qviaggiatreno-2013.7.3/src/dialogo_nomestazione.h 0000664 0001750 0001750 00000003673 12215773056 021761 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2010 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef DIALOGO_NOMESTAZIONE_H
#define DIALOGO_NOMESTAZIONE_H
#include "ui_dlgnomestazione.h"
class DialogoNomeStazione: public QDialog, private Ui::dlgNomeStazione
{
public:
DialogoNomeStazione(QWidget *parent, const QStringList& listaStazioni);
//restituisce true se il checkBox per cercare tutte le stazioni che iniziano con il testo inserito è marcato
bool cercaTutteStazioni();
//restituisce il nome della stazione scelto
QString nomeStazione();
};
#endif // DIALOGO_NOMESTAZIONE_H
qviaggiatreno-2013.7.3/src/dlgconfigurazione.ui 0000664 0001750 0001750 00000017507 12215773056 021450 0 ustar locutus locutus
dlgConfigurazione
0
0
556
260
Configurazione di QViaggiaTreno
-
0
Proxy
-
Usare un &proxy HTTP per l'accesso alla rete
-
-
Nome &host:
lineEditHost
-
-
Por&ta:
spinBoxPorta
-
65535
-
Il proxy richiede &autenticazione
-
-
Nome &utente:
lineEditNomeUtente
-
-
Pass&word:
lineEditPassword
-
QLineEdit::Password
-
Utilizzare il pro&xy di sistema
ViaggiaTreno
-
-
&Frequenza controllo corretto funzionamento di ViaggiaTreno (in minuti):
spinBoxControlloVT
-
1
120
-
&Timeout del controllo corretto funzionamento di ViaggiaTreno (in secondi)
spinBoxTimeoutControlloVT
-
15
90
-
Frequenza &richieste schede a ViaggiaTreno (in secondi):
doubleSpinBoxQueryVT
-
1
0.100000000000000
600.000000000000000
0.100000000000000
-
Qt::Vertical
20
43
-
Qt::Horizontal
QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults
spinBoxControlloVT
spinBoxTimeoutControlloVT
doubleSpinBoxQueryVT
buttonBox
tabWidget
buttonBox
accepted()
dlgConfigurazione
accept()
171
279
157
207
buttonBox
rejected()
dlgConfigurazione
reject()
171
279
286
207
pulsantePremuto(QAbstractButton*)
qviaggiatreno-2013.7.3/src/parser_trenord.h 0000664 0001750 0001750 00000005437 12215771022 020570 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2012 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef PARSER_TRENORD_H
#define PARSER_TRENORD_H
#include
class SchedaQViaggiaTreno;
class AvvisoTrenord
{
public:
void impostaOrario(QDateTime orario) {m_orario = orario;}
QDateTime orario() const {return m_orario;}
void impostaDirettrice(const QString& direttrice) {m_direttrice = direttrice;}
QString direttrice() const {return m_direttrice;}
void impostaTesto(const QString& testo) {m_testo = testo;}
QString testo() const {return m_testo;}
private:
QDateTime m_orario;
QString m_direttrice, m_testo;
};
class ParserTrenord : public QObject
{
Q_OBJECT
public:
ParserTrenord(SchedaQViaggiaTreno* scheda);
bool analizzaListaDirettrici(const QString& rispostaTN);
QQueue listaDirettrici() const {return m_direttrici;}
private:
QQueue m_direttrici;
SchedaQViaggiaTreno* m_scheda;
};
class ModelloAvvisiTrenord : public QAbstractTableModel
{
Q_OBJECT
public:
ModelloAvvisiTrenord(QWidget* parent);
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
virtual QVariant data(const QModelIndex &index, int role) const;
virtual int rowCount(const QModelIndex &parent) const;
virtual int columnCount(const QModelIndex &parent) const;
private:
QList m_avvisi;
};
#endif // PARSER_TRENORD_H
qviaggiatreno-2013.7.3/src/wgtstazione.ui 0000664 0001750 0001750 00000016373 12215773056 020315 0 ustar locutus locutus
wgtStazione
0
0
485
576
Form
-
15
75
true
Qt::AlignCenter
-
Ultimo aggiornamento: aggiornamento in corso
Qt::AlignCenter
-
0
0
Qt::Vertical
-
75
true
Arrivi
Qt::AlignCenter
-
QAbstractItemView::NoEditTriggers
true
QAbstractItemView::NoSelection
false
false
false
-
-
Filtra treni in arrivo in base a
-
false
-
Non filtrare
-
Categoria treno
-
Stazione di origine
-
QComboBox::AdjustToContents
-
Qt::Horizontal
40
20
-
75
true
Partenze
Qt::AlignCenter
-
QAbstractItemView::NoEditTriggers
true
QAbstractItemView::NoSelection
QAbstractItemView::SelectItems
false
false
false
-
-
Filtra treni in partenza in base a
-
false
-
Non filtrare
-
Categoria treno
-
Stazione di destinazione
-
QComboBox::AdjustToContents
-
Qt::Horizontal
40
20
qviaggiatreno-2013.7.3/src/items.h 0000664 0001750 0001750 00000003352 12215773217 016662 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2009-2010 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef ITEMS_H
#define ITEMS_H
#include
class SortedAsIntListWidgetItem : public QListWidgetItem
{
public:
SortedAsIntListWidgetItem(const QString& string) : QListWidgetItem(string)
{}
virtual bool operator < (const QListWidgetItem& other) const;
};
#endif // ITEMS_H
qviaggiatreno-2013.7.3/src/parser_viaggiatreno_treno.cpp 0000664 0001750 0001750 00000056107 12215773217 023344 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2011 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "parser_viaggiatreno_treno.h"
#include "utils.h"
#include
#include
ParserTrenoViaggiaTreno::ParserTrenoViaggiaTreno(SchedaQViaggiaTreno* scheda)
{
m_scheda = scheda;
m_err = "";
m_riga = m_col = -1;
m_rispostaVTAnalizzata = "";
m_rispostaVTDettagli = "";
m_rispostaVTRiepilogo = "";
}
void ParserTrenoViaggiaTreno::inizializza()
{
m_err = "";
m_riga = m_col = -1;
}
//cerca nel testo la stringa "non valido" perché VT quando trova un numero non valido visualizza il messaggio
//"numero treno non valido"
bool ParserTrenoViaggiaTreno::trenoNonPrevisto() const
{
return m_rispostaVTRiepilogo.contains("non valido", Qt::CaseInsensitive);
}
//cerca nel testo la stringa "option". Essa è presente quando il numero del treno è ambiguo
//e ViaggiaTreno presenta una lista di alternative
bool ParserTrenoViaggiaTreno::numeroTrenoAmbiguo() const
{
return m_rispostaVTRiepilogo.contains("option", Qt::CaseInsensitive);
}
QMap ParserTrenoViaggiaTreno::listaCodiciTreno(const QString& rispostaVT)
{
QDomDocument docDom;
QString msg;
int riga, col;
QMap lista;
//ottiene la lista di tutti gli elementi figli del tag "select"
//ogni nodo è un elemento "option" che contiene il numero del treno seguito dall'origine
//ad esempio "518 - NAPOLI CENTRALE" e nell'attributo "value" un codice ottenuto combinando
//il numero del treno con il codice di origine della stazione, ad esempio "518;S09218";
docDom.setContent(rispostaVT, &msg, &riga, &col);
QDomElement body = docDom.documentElement().firstChildElement("body");
QDomElement corpocentrale = body.firstChildElement("div").nextSiblingElement("div");
QDomElement form = corpocentrale.firstChildElement("form");
QDomElement select = form.firstChildElement("p").firstChildElement("select");
QDomNodeList nodi = select.childNodes();
//scorre la lista dei nodi
//per ogni elemento "option" crea un elemento della lista, la cui chiave è il nome della stazioone
//mentre il codice è memorizzato nella voce corrispondente alla chiame
for (int j = 0; j < nodi.count(); j++)
lista[nodi.at(j).toElement().text()] = nodi.at(j).toElement().attribute("value");
return lista;
}
//cerca nel testo la stringa "cancellato" e anche ""
//entrambe le stringhe sono presenti nella pagina che viene generata quando si introduce il
//numero di un treno cancellato
bool ParserTrenoViaggiaTreno::trenoSoppressoTotalmente() const
{
return (m_rispostaVTRiepilogo.contains("cancellato") && m_rispostaVTRiepilogo.
contains(""));
}
//analizza il testo della scheda con il riepilogo del treno
bool ParserTrenoViaggiaTreno::analizzaRiepilogo(TrenoVT::DatiTreno& orarioTreno)
{
QString temp;
QList listaNodi;
QDomDocument documentoDOM;
int idx;
m_rispostaVTAnalizzata = m_rispostaVTRiepilogo;
if (!documentoDOM.setContent(m_rispostaVTAnalizzata, &m_err, &m_riga, &m_col))
return false;
//inizia l'analisi dell'albero DOM
//rintraccia il tag body
QDomElement body = documentoDOM.documentElement().firstChildElement("body");
//rintraccia il tag H1 che contiene categoria e numero treno
temp = body.firstChildElement("h1").text();
orarioTreno.impostaNumeroTreno(temp);
orarioTreno.impostaCategoriaTreno(temp.section(" ", 0, 0));
//ottiene una lista di tutti gli elementi div
QDomNodeList elementiDiv = body.elementsByTagName("div");
QDomElement div;
if (m_rispostaVTAnalizzata.contains("arrivato"))
{
orarioTreno.impostaStatoTreno(TrenoVT::TrenoArrivato);
}
if (m_rispostaVTAnalizzata.contains("ancora partito"))
{
orarioTreno.impostaStatoTreno(TrenoVT::TrenoNonPartito);
}
if (m_rispostaVTAnalizzata.contains("viaggia "))
{
orarioTreno.impostaStatoTreno(TrenoVT::TrenoInViaggio);
}
//rintraccia l'elemento DIV con gli eventuali provvedimenti di limitazione/soppressione
for (int i = 0; i < elementiDiv.count(); i++)
if (elementiDiv.at(i).toElement().attribute("style").contains("B02D2D"))
orarioTreno.impostaDato(TrenoVT::dtProvvedimenti, elementiDiv.at(i).toElement().text());
//rintraccia l'elemento DIV con i dati della stazione di partenza
for (int i = 0; i < elementiDiv.count(); i++)
if (elementiDiv.at(i).toElement().text().contains("Partenza"))
div = elementiDiv.at(i).toElement();
//estrai i dati sulla stazione di partenza dall'elemento appena ottenuto
orarioTreno.impostaDato(TrenoVT::dtPartenza, div.firstChildElement("h2").text());
orarioTreno.impostaDato(TrenoVT::dtOrarioPartenzaProgrammato, div.firstChildElement("p").firstChildElement("strong").text());
orarioTreno.impostaDato(TrenoVT::dtOrarioPartenzaReale, div.firstChildElement("p").nextSiblingElement("p")
.firstChildElement("strong").text());
//ottiene la lista di tutti i nodi di tipo testo
for(QDomNode n = div.firstChild(); !n.isNull(); n = n.nextSibling())
{
QDomText t = n.toText();
if (!t.isNull())
listaNodi.append(n);
}
//se la lista dei nodi è vuota allora la pagina non è completa, per evitare
//crash ritorna false segnalando che c'è stato un errore inaspettato
if (listaNodi.isEmpty())
return false;
orarioTreno.impostaDato(TrenoVT::dtBinarioPartenzaProgrammato, listaNodi.at(1).toText().data());
if (listaNodi.count() == 4)
orarioTreno.impostaDato(TrenoVT::dtBinarioPartenzaReale, listaNodi.at(3).toText().data());
else
orarioTreno.impostaDato(TrenoVT::dtBinarioPartenzaReale, div.firstChildElement("strong").text());
//rintraccia l'elemento DIV con i dati della stazione di arrivo
for (int i = 0; i < elementiDiv.count(); i++)
if (elementiDiv.at(i).toElement().text().contains("Arrivo"))
div = elementiDiv.at(i).toElement();
//estrai i dati sulla stazione di arrivo dall'elemento appena ottenuto
orarioTreno.impostaDato(TrenoVT::dtArrivo, div.firstChildElement("h2").text());
orarioTreno.impostaDato(TrenoVT::dtOrarioArrivoProgrammato, div.firstChildElement("p").firstChildElement("strong").text());
orarioTreno.impostaDato(TrenoVT::dtOrarioArrivo, div.firstChildElement("p").nextSiblingElement("p")
.firstChildElement("strong").text());
//ottiene la lista di tutti i nodi di tipo testo
listaNodi.clear();
for(QDomNode n = div.firstChild(); !n.isNull(); n = n.nextSibling())
{
QDomText t = n.toText();
if (!t.isNull())
listaNodi.append(n);
}
orarioTreno.impostaDato(TrenoVT::dtBinarioArrivoProgrammato, listaNodi.at(1).toText().data());
if (listaNodi.count() == 4)
orarioTreno.impostaDato(TrenoVT::dtBinarioArrivoReale, listaNodi.at(3).toText().data());
else
orarioTreno.impostaDato(TrenoVT::dtBinarioArrivoReale, div.firstChildElement("strong").text());
//estra il ritardo attuale per un treno in viaggio
if (m_rispostaVTAnalizzata.contains("viaggia "))
{
//rintraccia l'elemento DIV con il ritardo attuale
idx = -1;
for (int i = 0; i < elementiDiv.count(); i++)
if (elementiDiv.at(i).toElement().text().contains("Il treno viaggia"))
idx = i;
if (idx != -1)
{
QString ritardo, transito;
div = elementiDiv.at(idx).toElement();
temp = div.firstChildElement("strong").text();
idx = temp.indexOf("Ultimo");
if (idx == -1)
{
ritardo = temp;
transito = "";
}
else
{
ritardo = temp.left(idx);
transito = temp.mid(idx);
}
//esistono i dati sull'ora e la località dell'ultimo transito
//TODO qui dovrà essere aggiunto il codice per l'aggiunta di questo transito alla lista di tutti i transiti
if (transito != "")
{
orarioTreno.impostaDato(TrenoVT::dtOrarioTransito, transito.section(' ', -2, -2));
orarioTreno.impostaDato(TrenoVT::dtUltimoRilevamento, transito.section(' ', 3, -5));
}
if (ritardo.contains("orario"))
orarioTreno.impostaDato(TrenoVT::dtRitardoTransito, QString::fromUtf8("in orario"));
else
{
temp = ritardo.section(' ', 5, 5);
if (temp == "1")
orarioTreno.impostaDato(TrenoVT::dtRitardoTransito, QString::fromUtf8("1 minuto in %1").arg(ritardo.section(' ', 8, 8)));
else
orarioTreno.impostaDato(TrenoVT::dtRitardoTransito, QString::fromUtf8("%1 minuti in %2").arg(temp).arg(ritardo.section(' ', 8, 8)));
}
}
}
return true;
}
//analizza il testo della scheda con i dettagli del treno
bool ParserTrenoViaggiaTreno::analizzaDettagli(TrenoVT::DatiTreno& orarioTreno)
{
QList listaNodi;
QDomDocument documentoDOM;
m_rispostaVTAnalizzata = m_rispostaVTDettagli;
if (!documentoDOM.setContent(m_rispostaVTAnalizzata, &m_err, &m_riga, &m_col))
return false;
QDomElement body = documentoDOM.documentElement().firstChildElement("body");
//ottiene la lista degli elementi div
QDomNodeList elementiDiv = body.elementsByTagName("div");
//i dati delle fermate si trovano dal secondo al penultimo elemento div
//ma siccome abbiamo già scritto i dati per la stazione di partenza e di arrivo
//ci interessano solo gli elementi dal terzo al terz'ultimo
for (int i = 2; i < elementiDiv.count()-2; i++)
{
TrenoVT::Fermata *fermata = new TrenoVT::Fermata();
QDomElement div = elementiDiv.at(i).toElement();
//verifica se la fermata è già stata effettuata o no, sfruttando l'attributo class
if (div.attribute("class") == "corpocentrale")
fermata->impostaEffetuata(false);
else
fermata->impostaEffetuata(true);
//verifica se per caso la fermata non sia stata soppressa
if (div.text().contains("soppressa"))
fermata->impostaSoppressa(true);
//imposta il nome della fermata
fermata->impostaNomeFermata(div.firstChildElement("h2").text());
//imposta l'ora di arriva programmata ed effettiva
fermata->impostaOraArrivoProgrammata(div.firstChildElement("p").firstChildElement("strong").text());
if (fermata->effettuata())
fermata->impostaOraArrivoReale(div.firstChildElement("p").nextSiblingElement("p").firstChildElement("strong").text());
else
fermata->impostaOraArrivoStimata(div.firstChildElement("p").nextSiblingElement("p").firstChildElement("strong").text());
listaNodi.clear();
for(QDomNode n = div.firstChild(); !n.isNull(); n = n.nextSibling())
{
QDomText t = n.toText();
if (!t.isNull())
listaNodi.append(n);
}
//se ci sono 4 elementi nella lista allora né binario previsto né reale sono scritti in grassetto
if ( listaNodi.count() == 4)
{
fermata->impostaBinarioProgrammato(listaNodi.at(1).toText().data().simplified());
fermata->impostaBinarioReale(listaNodi.at(3).toText().data().simplified());
}
//ce ne sono 3 allora le possibilità sono varie
//se la fermata è stata effettuata allora il binario reale è in grassetto
else
if (fermata->effettuata())
{
fermata->impostaBinarioProgrammato(listaNodi.at(1).toText().data().simplified());
fermata->impostaBinarioReale(div.firstChildElement("strong").text().simplified());
}
//oppure la fermata non è stata effettuata
else
//è indicato in grassetto il binario reale (evento raro ma succede)
if (listaNodi.at(2).toText().data().contains("Binario"))
{
fermata->impostaBinarioProgrammato(listaNodi.at(1).toText().data().simplified());
fermata->impostaBinarioReale(div.firstChildElement("strong").text().simplified());
}
//è indicato in grassetto il binario programmato
else
{
fermata->impostaBinarioProgrammato(div.firstChildElement("strong").text().simplified());
fermata->impostaBinarioReale(listaNodi.at(2).toText().data().simplified());
}
orarioTreno.aggiungiFermata(fermata);
}
return true;
}
void TrenoVT::DatiTreno::inizializza()
{
m_statoTreno = DatiSconosciuti;
m_dati.clear();
m_fermate.clear();
}
TrenoVT::Fermata::Fermata()
{
m_effettuata = false;
m_soppressa = false;
m_fermata = "";
m_binProgrammato = "";
m_binReale = "";
m_oraArrivoProgrammata = "";
m_oraArrivoReale = "";
m_oraArrivoStimata = "";
}
TrenoVT::Transito::Transito()
{
m_ritardo = 0;
m_localita = "";
m_orarioTransito = "";
}
ListaVT::DatiTreno::DatiTreno(const QString& numero)
{
m_numero = numero;
m_codice = "";
m_stato = TrenoVT::DatiSconosciuti;
}
//cancella tutti i dati del treno tranne numero
void ListaVT::DatiTreno::cancella()
{
m_dati.clear();
m_stato = TrenoVT::DatiSconosciuti;
}
//restituisce una stringa con lo stato del treno
QString ListaVT::DatiTreno::stringaStatoTreno() const
{
QString stringa;
switch(m_stato)
{
case TrenoVT::DatiSconosciuti: stringa = QString::fromUtf8("Stato sconosciuto"); break;
case TrenoVT::TrenoNonPrevisto: stringa = QString::fromUtf8("Non previsto oggi"); break;
case TrenoVT::TrenoNonPartito: stringa = QString::fromUtf8("Non ancora partito"); break;
case TrenoVT::TrenoInViaggio: stringa = QString::fromUtf8("In viaggio"); break;
case TrenoVT::TrenoArrivato: stringa = QString::fromUtf8("Arrivato"); break;
case TrenoVT::TrenoCancellato: stringa = QString::fromUtf8("Soppresso"); break;
}
return stringa;
}
bool ParserTrenoViaggiaTreno::analizzaRiepilogoPerLista(ListaVT::DatiTreno &treno)
{
QDomDocument documentoDOM;
int idx;
QString temp;
treno.cancella();
//analizza il testo della risposta di viaggiatreno
m_rispostaVTAnalizzata = m_rispostaVTRiepilogo;
if (!documentoDOM.setContent(m_rispostaVTAnalizzata, &m_err, &m_riga, &m_col ))
return false;
//inizia l'analisi dell'albero DOM
//rintraccia il tag body
QDomElement body = documentoDOM.documentElement().firstChildElement("body");
//rintraccia il tag H1 che contiene categoria e numero treno
temp = body.firstChildElement("h1").text();
treno.impostaDato(ListaVT::dtCategoria, temp.section(' ', 0, 0));
//ottiene una lista di tutti gli elementi div
QDomNodeList elementiDiv = body.elementsByTagName("div");
QDomElement div;
//imposta lo stato del treno
if (m_rispostaVTAnalizzata.contains("ancora partito"))
treno.impostaStatoTreno(TrenoVT::TrenoNonPartito);
if (m_rispostaVTAnalizzata.contains("viaggia "))
treno.impostaStatoTreno(TrenoVT::TrenoInViaggio);
if (m_rispostaVTAnalizzata.contains("arrivato"))
treno.impostaStatoTreno(TrenoVT::TrenoArrivato);
//rintraccia l'elemento DIV con i dati della stazione di partenza
for (int i = 0; i < elementiDiv.count(); i++)
if (elementiDiv.at(i).toElement().text().contains("Partenza"))
div = elementiDiv.at(i).toElement();
//estrai i dati sulla stazione di partenza dall'elemento appena ottenuto
treno.impostaDato(ListaVT::dtOrigine, div.firstChildElement("h2").text());
treno.impostaDato(ListaVT::dtPartenzaProgrammata, div.firstChildElement("p").firstChildElement("strong").text());
//non cercare l'orario di partenza effettivo se il treno risulta non ancora partito
if (!m_rispostaVTAnalizzata.contains("ancora partito"))
treno.impostaDato(ListaVT::dtPartenzaEffettiva, div.firstChildElement("p").nextSiblingElement("p")
.firstChildElement("strong").text());
//rintraccia l'elemento DIV con i dati della stazione di arrivo
for (int i = 0; i < elementiDiv.count(); i++)
if (elementiDiv.at(i).toElement().text().contains("Arrivo"))
div = elementiDiv.at(i).toElement();
//estrai i dati sulla stazione di arrivo dall'elemento appena ottenuto
treno.impostaDato(ListaVT::dtDestinazione, div.firstChildElement("h2").text());
treno.impostaDato(ListaVT::dtArrivoProgrammato, div.firstChildElement("p").firstChildElement("strong").text());
//cerca l'orario di arrivo effettivo solo se il treno risulta già arrivato
if (m_rispostaVTAnalizzata.contains("arrivato"))
treno.impostaDato(ListaVT::dtArrivoEffettivo, div.firstChildElement("p").nextSiblingElement("p")
.firstChildElement("strong").text());
//cerca solo per i treni ancora in viaggio il dato sull'ultima fermata effettuata
if (m_rispostaVTAnalizzata.contains("viaggia "))
{
idx = -1;
for (int i = 0; i < elementiDiv.count(); i++)
if (elementiDiv.at(i).toElement().text().contains("Ultima fermata effettuata"))
idx = i+1;
//è stata trovato? allora estrai i dati
if (idx != -1)
{
div = elementiDiv.at(idx).toElement();
treno.impostaDato(ListaVT::dtUltimaFermata, div.firstChildElement("h2").text());
treno.impostaDato(ListaVT::dtOrarioFermataProgrammato, div.firstChildElement("p").firstChildElement("strong").text());
treno.impostaDato(ListaVT::dtOrarioFermataEffettivo, div.firstChildElement("p").nextSiblingElement("p")
.firstChildElement("strong").text());
}
}
//cerca il ritardo in arrivo per un treno già arrivato
if (m_rispostaVTAnalizzata.contains("arrivato"))
{
idx = -1;
for (int i = 0; i < elementiDiv.count(); i++)
if (elementiDiv.at(i).toElement().text().contains("Il treno e' arrivato"))
idx = i;
if (idx != -1)
{
div = elementiDiv.at(idx).toElement();
//il treno è arrivato in orario, non c'è ragione di estrarre il ritardo
if (div.text().contains("orario"))
treno.impostaDato(ListaVT::dtRitardoTransito, QString::fromUtf8("In orario"));
else
{
QString minuti = div.text().section(' ', 6, 6);
QString ritOAnticipo = div.text().section(' ', 9, 9);
if (minuti == "1")
temp = QString::fromUtf8("1 minuto in %1").arg(ritOAnticipo);
else
temp = QString::fromUtf8("%1 minuti in %2").arg(minuti).arg(ritOAnticipo);
treno.impostaDato(ListaVT::dtRitardoTransito, temp);
}
}
}
//cerca il ritardo per i treni ancora in viaggio
if (m_rispostaVTAnalizzata.contains("viaggia "))
{
idx = -1;
for (int i = 0; i < elementiDiv.count(); i++)
if (elementiDiv.at(i).toElement().text().contains("Il treno viaggia"))
idx = i;
if (idx != -1)
{
QString ritardo, transito;
div = elementiDiv.at(idx).toElement();
temp = div.firstChildElement("strong").text();
idx = temp.indexOf("Ultimo");
if (idx == -1)
{
ritardo = temp;
transito = "";
}
else
{
ritardo = temp.left(idx);
transito = temp.mid(idx);
}
//esistono i dati sull'ora e la località dell'ultimo transito
if (transito != "")
{
treno.impostaDato(ListaVT::dtOrarioTransito, transito.section(' ', -2, -2));
treno.impostaDato(ListaVT::dtUltimoRilevamento, transito.section(' ', 3, -5));
}
if (ritardo.contains("orario"))
treno.impostaDato(ListaVT::dtRitardoTransito, QString::fromUtf8("in orario"));
else
{
temp = ritardo.section(' ', 5, 5);
if (temp == "1")
treno.impostaDato(ListaVT::dtRitardoTransito, QString::fromUtf8("1 minuto in %1").arg(ritardo.section(' ', 8, 8)));
else
treno.impostaDato(ListaVT::dtRitardoTransito, QString::fromUtf8("%1 minuti in %2").arg(temp).arg(ritardo.section(' ', 8, 8)));
}
}
}
return true;
}
qviaggiatreno-2013.7.3/src/parser_viaggiatreno_treno.h 0000664 0001750 0001750 00000022412 12215773217 023001 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2010-2011 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef PARSER_VIAGGIATRENO_TRENO_H
#define PARSER_VIAGGIATRENO_TRENO_H
#include
#include
#include "parser_viaggiatreno_base.h"
class SchedaQViaggiaTreno;
namespace TrenoVT
{
enum StatoTreno {DatiSconosciuti, TrenoCancellato, TrenoNonPrevisto, TrenoNonPartito, TrenoInViaggio, TrenoArrivato};
enum Dati {dtPartenza, dtOrarioPartenzaProgrammato, dtOrarioPartenzaReale, dtBinarioPartenzaProgrammato, dtBinarioPartenzaReale,
dtArrivo, dtOrarioArrivoProgrammato, dtOrarioArrivo, dtBinarioArrivoProgrammato, dtBinarioArrivoReale,
dtOrarioTransito, dtRitardoTransito, dtUltimoRilevamento, dtProvvedimenti };
enum {colFermata = 0, colEffettuata, colBinarioProgrammato, colBinarioReale,
colArrivoProgrammato, colArrivoStimato, colArrivoReale, colUltima=colArrivoReale};
enum {colLocalita = 0, colOrarioTransito, colRitardo};
class Fermata
{
public:
Fermata();
QString nomeFermata() const {return m_fermata;}
QString binarioProgrammato() const {return m_binProgrammato;}
QString binarioReale() const {return m_binReale;}
QString oraArrivoProgrammata() const {return m_oraArrivoProgrammata;}
QString oraArrivoStimata() const {return m_oraArrivoStimata;}
QString oraArrivoReale() const {return m_oraArrivoReale;}
bool effettuata() const {return m_effettuata;}
bool soppressa() const {return m_soppressa;}
void impostaNomeFermata(const QString& fermata) {m_fermata = fermata;}
void impostaBinarioProgrammato(const QString& binarioProgrammato) {m_binProgrammato = binarioProgrammato;}
void impostaBinarioReale(const QString& binarioReale) {m_binReale = binarioReale;}
void impostaOraArrivoProgrammata(const QString& oraArrivoProgrammata) {m_oraArrivoProgrammata = oraArrivoProgrammata;}
void impostaOraArrivoStimata(const QString& oraArrivoStimata) {m_oraArrivoStimata = oraArrivoStimata;}
void impostaOraArrivoReale(const QString& oraArrivoReale) {m_oraArrivoReale = oraArrivoReale;}
void impostaEffetuata(bool eff) {m_effettuata = eff;}
void impostaSoppressa(bool sopp) {m_soppressa = sopp; m_effettuata = false;}
private:
QString m_fermata;
QString m_binProgrammato, m_binReale;
QString m_oraArrivoProgrammata, m_oraArrivoStimata, m_oraArrivoReale;
bool m_effettuata, m_soppressa;
};
class Transito
{
public:
Transito();
QString nomeLocalita() const {return m_localita;}
QString orarioTransito() const {return m_orarioTransito;}
int ritardo() const {return m_ritardo;}
void impostaLocalita(const QString& localita) {m_localita = localita;}
void impostaOrarioTransito(const QString& orarioTransito) {m_orarioTransito = orarioTransito;}
void impostaRitardo(int ritardo) {m_ritardo = ritardo;}
private:
QString m_localita;
QString m_orarioTransito;
int m_ritardo;
};
class DatiTreno
{
public:
DatiTreno() {m_statoTreno = DatiSconosciuti;}
void impostaStatoTreno(StatoTreno stato) {m_statoTreno = stato;}
StatoTreno statoTreno() const {return m_statoTreno;}
void inizializza();
QString categoriaTreno() const {return m_categoria;}
void impostaCategoriaTreno(const QString& cat) {m_categoria = cat;}
QString numeroTreno() const {return m_numero; }
void impostaNumeroTreno(const QString& numero) {m_numero = numero; }
void impostaDato(Dati tipoDato, const QString& valore) {m_dati[tipoDato] = valore; }
QString dato(Dati tipoDato) const {return m_dati[tipoDato]; }
QList fermate() const {return m_fermate;}
void aggiungiFermata(Fermata* f) {m_fermate.append(f);}
private:
StatoTreno m_statoTreno;
//il numero treno contiene *anche* la categoria
QString m_numero;
QString m_categoria;
QMap m_dati;
QList m_fermate;
};
};
namespace ListaVT
{
enum Dati {dtCategoria, dtOrigine, dtDestinazione, dtUltimaFermata, dtOrarioFermataProgrammato, dtOrarioFermataEffettivo,
dtUltimoRilevamento, dtOrarioTransito, dtRitardoTransito, dtPartenzaProgrammata, dtPartenzaEffettiva,
dtArrivoProgrammato, dtArrivoEffettivo};
enum {rigaNumero = 0, rigaCategoria, rigaStato, rigaOrigine, rigaPartenzaProgrammata, rigaPartenzaEffettiva,
rigaDestinazione, rigaArrivoProgrammato, rigaArrivoEffettivo, rigaUltimaFermata, rigaOrarioFermataProgrammato,
rigaOrarioFermataEffettivo, rigaUltimoRilevamento, rigaOrarioTransito, rigaRitardoTransito, rigaUltima = rigaRitardoTransito};
//questa classe memorizza i dati di ogni singolo treno della lista di treni
class DatiTreno
{
public:
DatiTreno(const QString& numero);
void cancella();
void impostaDato(Dati tipoDato, const QString& valore) {m_dati[tipoDato] = valore; }
QString dato(Dati tipoDato) const {return m_dati[tipoDato]; }
TrenoVT::StatoTreno statoTreno() const {return m_stato;}
void impostaStatoTreno(TrenoVT::StatoTreno stato) {m_stato = stato;}
QString stringaStatoTreno() const;
QString numero() const {return m_numero;}
void impostaNumero(const QString& numero) {m_numero = numero;}
QString codiceOrigine() const {return m_codice;}
void impostaCodiceOrigine(const QString& codice) {m_codice = codice;}
private:
QString m_numero, m_codice;
QMap m_dati;
TrenoVT::StatoTreno m_stato;
};
};
class ParserTrenoViaggiaTreno: public ParserViaggiaTrenoBase
{
Q_OBJECT
public:
ParserTrenoViaggiaTreno(SchedaQViaggiaTreno *scheda);
void inizializza();
//imposta il testo della risposta di viaggiatreno contenente il riepilogo del treno
//che dovrà essere analizzata dal parser
void impostaRispostaVTRiepilogo(const QString& rispostaVT) {m_rispostaVTRiepilogo = rispostaVT;}
//imposta il testo della risposta di viaggiatreno contenente i dettagli del treno
//che dovrà essere analizzata dal parser
void impostaRispostaVTDettagli(const QString& rispostaVT) {m_rispostaVTDettagli = rispostaVT;}
//analizza il testo della risposta di viaggiatreno e restituisce true se non sono incontrati errori sintattici
bool analizzaRiepilogo(TrenoVT::DatiTreno& orarioTreno);
bool analizzaDettagli(TrenoVT::DatiTreno& orarioTreno);
//analizza il riepilogo ma estrai dati necessari alla scheda Lista Treni
bool analizzaRiepilogoPerLista(ListaVT::DatiTreno &treno);
//restituisce true se il numero treno non è stato trovato
bool trenoNonPrevisto() const;
//restituisce true se il treno è stato soppresso totalmente
bool trenoSoppressoTotalmente() const;
//restituisce true se il numero del treno è ambiguo
//cioè se esistono più treni con lo stesso numero
bool numeroTrenoAmbiguo() const;
//restituisce una QMap con una corrispodenza Numero/origine treno<->Codice treno
//utile quando ViaggiaTreno segnala che il numero del treno è ambiguo e produce una lista con numero treno
//seguito da origine del treno
//esempio se si cerca "518" ViaggiaTreno restituirà
//"518 - NAPOLI CENTRALE"
//"518 - SARONNO"
QMap listaCodiciTreno(const QString& rispostaVT );
//restituisce riga dove è stato incontrato errore
int rigaErrore() const {return m_riga;}
//restituisce colonna dove è stato incontrato errore
int colErrore() const {return m_col;}
//restituisce il messaggio di errore
QString errore() const {return m_err;}
//restituisce il testo della risposta di viaggiatreno con il riepilogo
QString rispostaVTRiepilogo() const {return m_rispostaVTRiepilogo;}
// restituisce il testo della risposta di viaggiatreno con i dettagli
QString rispostaVTDettagli() const {return m_rispostaVTDettagli;}
//restituisce il testo dell'ultima risposta di viaggiatreno analizzata
QString rispostaVTAnalizzata() const {return m_rispostaVTAnalizzata;}
private:
SchedaQViaggiaTreno *m_scheda;
QString m_rispostaVTDettagli, m_rispostaVTRiepilogo, m_rispostaVTAnalizzata;
int m_riga, m_col;
QString m_err;
};
#endif
qviaggiatreno-2013.7.3/src/dialogoconfigurazione.h 0000664 0001750 0001750 00000000143 12215773056 022116 0 ustar locutus locutus #ifndef DIALOGOCONFIGURAZIONE_H
#define DIALOGOCONFIGURAZIONE_H
#endif // DIALOGOCONFIGURAZIONE_H
qviaggiatreno-2013.7.3/src/utils.cpp 0000664 0001750 0001750 00000003657 12215773217 017244 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2008-2011 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "utils.h"
//funzioni varie per il debug dei nodi DOM
QString dumpNodo(QDomNode nodo)
{
QString temp;
QTextStream stream(&temp, QIODevice::WriteOnly);
nodo.save(stream, 3);
return temp;
}
void debugNodo(QDomNode nodo)
{
QMessageBox msg;
msg.setTextFormat(Qt::PlainText);
msg.setText(dumpNodo(nodo));
msg.exec();
}
void debugStringa(QString stringa)
{
QMessageBox msg;
msg.setTextFormat(Qt::PlainText);
msg.setText(stringa);
msg.exec();
}
qviaggiatreno-2013.7.3/src/qviaggiatrenoslots.cpp 0000664 0001750 0001750 00000052200 12215773217 022015 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2008-2012 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include
#include "dialogo_nomestazione.h"
#include "dialogo_configurazione.h"
#include "schedalistatreni.h"
#include "schedastazione.h"
#include "schedatreno.h"
#include "schedaavvisitrenord.h"
#include "qviaggiatreno.h"
#include "utils.h"
#include "qledindicator.h"
// slot
void QViaggiaTreno::about()
{
QMessageBox::about(this, QString::fromUtf8("Informazioni su QViaggiaTreno"),
QString::fromUtf8("QViaggiaTreno versione %1\n\n(C) 2008-2012 fra74\n\n%2").arg(s_versione)
.arg(QString::fromUtf8("QViaggiaTreno è un'interfaccia a ViaggiaTreno, il servizio web di Trenitalia per monitorare la marcia dei treni passeggeri\n\n"
"Questo programma è distribuito secondo i termini della licenza GNU GPL v.2"
"\n\nQViaggiaTreno utilizza il widget 'QLedIndicator' scritto da 'Tn'")));
}
void QViaggiaTreno::visualizzaLicenza()
{
if (!m_licenseDialog)
{
//costruzione della finestra di dialogo solo se non è già stata costruita precedentemente
m_licenseDialog = new QDialog(this);
m_licenseDialog->setWindowTitle(QString::fromUtf8("Testo licenza GNU GPL v.2"));
QVBoxLayout *vbox = new QVBoxLayout;
QTextEdit *textEdit = new QTextEdit(m_licenseDialog);
//imposta una larghezza minima per leggere decentemente il testo della licenza
//senza eccessivo a capo
textEdit->setMinimumWidth(500);
vbox->addWidget(textEdit);
QPushButton *button = new QPushButton(QString::fromUtf8("Ok"), this);
vbox->addWidget(button, 0, Qt::AlignCenter);
m_licenseDialog->setLayout(vbox);
connect(button, SIGNAL(clicked()), m_licenseDialog, SLOT(accept()));
//lettura del file di testo contenente il testo della licenza GPL
textEdit->setReadOnly(true);
textEdit->setCursorWidth(0); //cursore non visibile
QString linea;
QFile testoLicenza(":/doc/GPL-2.txt");
testoLicenza.open(QFile::ReadOnly);
QString txt = testoLicenza.readAll();
textEdit->insertPlainText(txt);
//riporta il cursore all'inizio del documento
textEdit->moveCursor(QTextCursor::Start);
}
m_licenseDialog->show();
}
//avvia il monitoraggio nella scheda corrente
void QViaggiaTreno::avvia()
{
schedaCorrente()->avvia();
//attiva/disattiva le azioni coerentemente con il fatto che nella scheda corrente ora il monitoraggio è attivo
m_avviaAct->setDisabled(true);
m_fermaAct->setEnabled(true);
statusBar()->showMessage(QString::fromUtf8("Monitoraggio avviato nella scheda '%1'").arg(schedaCorrente()->titolo()), 3000);
}
void QViaggiaTreno::ferma()
{
schedaCorrente()->ferma();
//attiva/disattiva le azioni coerentemente con il fatto che nella scheda corrente ora il monitoraggio è attivo
m_avviaAct->setEnabled(true);
m_fermaAct->setDisabled(true);
statusBar()->showMessage(QString::fromUtf8("Monitoraggio fermato nella scheda '%1'").arg(schedaCorrente()->titolo()), 3000);
}
//slot
//crea una nuova scheda per il monitoraggio di un treno
void QViaggiaTreno::nuovoTreno()
{
bool ok;
int num = QInputDialog::getInt(this, QString::fromUtf8("Monitoraggio treno"), QString::fromUtf8("Inserire il numero del treno da monitorare con ViaggiaTreno"), 0, 1, 99999, 1, &ok);
if (ok)
{
//converte il numero del treno in una stringa
QString numero;
numero.setNum(num);
nuovoTreno(numero);
}
}
void QViaggiaTreno::nuovaStazione()
{
//ordina la lista delle stazioni già monitorate
QStringList listaOrdinata = m_listaStazioniMonitorate;
listaOrdinata.sort();
DialogoNomeStazione *dialogo = new DialogoNomeStazione(this, listaOrdinata);
// QString stazione = QInputDialog::getItem(this, QString::fromUtf8("Monitoraggio stazione"), QString::fromUtf8("Inserire il nome della stazione da monitorare con ViaggiaTreno:"), listaOrdinata, -1, true, &ok);
if (dialogo->exec())
{
QString stazione = dialogo->nomeStazione();
//verifica che non ci sia già una scheda aperta per questa stazione
//se esiste allora la relativa scheda diventerà la scheda corrente
QMapIterator it(m_listaSchede);
while (it.hasNext())
{
it.next();
//la scheda è una scheda di stazione?
if (it.value()->tipoScheda() == SchedaQViaggiaTreno::tsStazione)
{
SchedaStazione *scheda = qobject_cast(it.value());
if (!QString::compare(stazione, scheda->nomeStazione(), Qt::CaseInsensitive))
{
m_schede->setCurrentWidget(scheda);
return;
}
}
}
//non ci sono schede già aperte, aprine una nuova
nuovaStazione(stazione, !(dialogo->cercaTutteStazioni()));
}
delete dialogo;
}
SchedaTreno* QViaggiaTreno::nuovoTreno(const QString& treno, int intervallo)
{
//verifica che non esista già una scheda aperta per questo treno
QMapIterator it(m_listaSchede);
while (it.hasNext())
{
it.next();
if (it.value()->tipoScheda() == SchedaQViaggiaTreno::tsTreno)
{
SchedaTreno* scheda = qobject_cast(it.value());
// c'è un problema
//supponiamo di avere un treno con numero ambiguo (esempio 518)
//apro la scheda per il 518 su rete RFI
//ma se poi controllo solo il numero treno allora non potrò mai aprire una scheda
//per quello su rete FNM
//workaround: controllo che il codice origine sia nullo, in tal caso impedisco
//l'apertura di una nuova scheda
if (!QString::compare(treno, scheda->numero()) && (scheda->codiceOrigine().isEmpty()))
{
//esiste già una scheda con questo nome, selezionala ed esci
m_schede->setCurrentWidget(scheda);
return 0L;
}
}
}
//crea la scheda della stazione
SchedaTreno *scheda = new SchedaTreno(this, treno);
//aggiorna la lista delle schede e degli item
m_listaSchede.insert(scheda->idScheda(), scheda);
//cambia intervallo di aggiornamento se intervallo != 0
if (intervallo)
scheda->impostaIntervallo(intervallo);
//aggiorna la scheda e avvia il timer
scheda->aggiorna();
scheda->avvia();
//aggiunge la scheda al tabwidget assicurandosi che diventi la scheda corrente
m_schede->addTab(scheda, QIcon(":/img/treno.png"), scheda->titolo());
m_schede->setCurrentWidget(scheda);
return scheda;
}
//crea una nuova scheda Treno specificando anche il codice di origine
SchedaTreno* QViaggiaTreno::nuovoTreno(const QString& treno, const QString &codiceOrigine, int intervallo)
{
//verifica che non esista già una scheda aperta per questo treno
QMapIterator it(m_listaSchede);
while (it.hasNext())
{
it.next();
if (it.value()->tipoScheda() == SchedaQViaggiaTreno::tsTreno)
{
SchedaTreno* scheda = qobject_cast(it.value());
if (!QString::compare(treno, scheda->numero()) && !QString::compare(codiceOrigine, scheda->codiceOrigine()))
{
//esiste già una scheda con questo nome, selezionala ed esci
m_schede->setCurrentWidget(scheda);
return 0L;
}
}
}
//crea la scheda della stazione
SchedaTreno *scheda = new SchedaTreno(this, treno);
//aggiorna la lista delle schede
m_listaSchede.insert(scheda->idScheda(), scheda);
//cambia intervallo di aggiornamento se intervallo != 0
if (intervallo)
scheda->impostaIntervallo(intervallo);
// il metodo cambiaCodiceOrigine automaticamente avvia la scheda
scheda->cambiaCodiceOrigine(codiceOrigine);
//aggiorna la scheda e avvia il timer
//scheda->aggiorna();
//scheda->avvia();
//aggiunge la scheda al tabwidget assicurandosi che diventi la scheda corrente
m_schede->addTab(scheda, QIcon(":/img/treno.png"), scheda->titolo());
m_schede->setCurrentWidget(scheda);
return scheda;
}
SchedaStazione* QViaggiaTreno::nuovaStazione(const QString& stazione, bool nomeEsatto, int intervallo, bool nonAvviare)
{
//verifica che non esista già una scheda aperta per questa stazione
QMapIterator it(m_listaSchede);
while (it.hasNext())
{
it.next();
if (it.value()->tipoScheda() == SchedaQViaggiaTreno::tsStazione)
{
SchedaStazione* scheda = qobject_cast(it.value());
if (!QString::compare(stazione, scheda->nomeStazione()))
{
//esiste già una scheda con questo nome, selezionala ed esci
m_schede->setCurrentWidget(scheda);
return 0L;
}
}
}
//verifica che la stazione non sia già nella lista delle stazioni monitorate
if (!m_listaStazioniMonitorate.contains(stazione, Qt::CaseInsensitive))
{
//aggiunge la stazione alla lista delle stazioni monitorate, assicurandosi di non superare
//il massimo numero di stazioni previste
if (m_listaStazioniMonitorate.size() < maxStazioni)
m_listaStazioniMonitorate.append(stazione);
else
{
m_listaStazioniMonitorate.removeFirst();
m_listaStazioniMonitorate.append(stazione);
}
}
//se nel nome è presente un accento, sostituiscilo con l'entità
QString temp = stazione;
temp.replace("'", "'");
//crea la scheda della stazione
SchedaStazione *scheda = new SchedaStazione(this, temp, nomeEsatto);
//aggiorna la lista delle schede e degli item
m_listaSchede.insert(scheda->idScheda(), scheda);
//cambia intervallo di aggiornamento se intervallo != 0
if (intervallo)
scheda->impostaIntervallo(intervallo);
//aggiorna la scheda e avvia il timer
if (!nonAvviare)
{
scheda->aggiorna();
scheda->avvia();
}
//aggiunge la scheda al tabwidget assicurandosi che diventi la scheda corrente
m_schede->addTab(scheda, QIcon(":/img/stazione.png"), scheda->titolo());
m_schede->setCurrentWidget(scheda);
return scheda;
}
SchedaListaTreni* QViaggiaTreno::nuovaListaTreni()
{
//crea la scheda per la nuova lista dei treni
SchedaListaTreni* scheda = new SchedaListaTreni(this);
//aggiorna la lista delle schede
m_listaSchede.insert(scheda->idScheda(), scheda);
//aggiorna la scheda e avvia il timer
scheda->aggiorna();
scheda->avvia();
//aggiunge la scheda al tabwidget assicurandosi che diventi la scheda corrente
m_schede->addTab(scheda, QIcon(":/img/listatreni.png"), scheda->titolo());
m_schede->setCurrentWidget(scheda);
//sincronizza la GUI con la scheda
sincronizzaGUI(scheda->idScheda());
return scheda;
}
SchedaAvvisiTrenord* QViaggiaTreno::nuovaSchedaAvvisiTrenord()
{
//crea la scheda
SchedaAvvisiTrenord* scheda = new SchedaAvvisiTrenord(this);
//aggiorna la lista delle schede e aggiunge la scheda al tabwidget,
//assicurandosi che diventi la scheda corrente
m_listaSchede.insert(scheda->idScheda(), scheda);
m_schede->addTab(scheda, QIcon(":img/trenord.png"), scheda->titolo());
m_schede->setCurrentWidget(scheda);
//avvia la scheda ed aggiorna il timer
scheda->aggiorna();
scheda->avvia();
sincronizzaGUI(scheda->idScheda());
//disattiva la voce di menu per creare scheda avvisi trenord visto che non ha senso averne più di una
m_avvisiTrenordAct->setDisabled(true);
return scheda;
}
void QViaggiaTreno::chiudiScheda(int id)
{
//ottiene un puntatore alla scheda corrente
SchedaQViaggiaTreno *scheda = qobject_cast(m_schede->widget(id));
if (scheda)
{
//rimuove la scheda dal tab widget
m_schede->removeTab(id);
//elimina scheda dalle rispettiva lista
m_listaSchede.remove(scheda->idScheda());
//verifica se la scheda era la scheda con gli avvisi Trenord
//ed in caso positivo riabilita la corrispondente voce di menu
if (scheda->tipoScheda() == SchedaQViaggiaTreno::tsAvvisiTrenord)
m_avvisiTrenordAct->setEnabled(true);
//infine cancella scheda e item
delete scheda;
}
}
//questo slot viene richiamato quando cambia la scheda selezionata
//questo può succedere quando viene chiusa la scheda corrente,
//o quando ne viene selezionata un'altra cliccando sulla rispettiva linguetta
void QViaggiaTreno::schedaCambiata(int indice)
{
//nasconde menu specifico per schede
m_trenoMenu->menuAction()->setVisible(false);
m_stazioneMenu->menuAction()->setVisible(false);
m_listaTreniMenu->menuAction()->setVisible(false);
//nascondi anche la Toolbar
m_listaToolbar->setVisible(false);
if (indice == -1)
//non ci sono più schede, disattiva tutti i controlli
{
m_avviaAct->setDisabled(true);
m_avviaTutteAct->setDisabled(true);
m_fermaAct->setDisabled(true);
m_fermaTutteAct->setDisabled(true);
m_aggiornaAct->setDisabled(true);
m_intervalloAct->setDisabled(true);
m_spinIntervalloAct->setDisabled(true);
m_esportaSchedaAct->setDisabled(true);
m_stampaSchedaAct->setDisabled(true);
setWindowTitle(QString::fromUtf8("QViaggiaTreno"));
return;
}
//ottiene un puntatore alla scheda corrente
SchedaQViaggiaTreno *scheda = qobject_cast(m_schede->currentWidget());
//cambia titolo della finestra di QViaggiaTreno
setWindowTitle(QString::fromUtf8("QViaggiaTreno - %1").arg(scheda->titolo()));
//attiva/disattiva le azioni che non dipendono dallo stato della scheda
m_avviaTutteAct->setEnabled(true);
m_fermaTutteAct->setEnabled(true);
m_aggiornaAct->setEnabled(true);
m_intervalloAct->setEnabled(true);
m_spinIntervalloAct->setEnabled(true);
m_spinIntervallo->setValue(scheda->intervallo());
//attiva/disattiva le azioni che dipendono dallo stato della scheda
if (scheda->fermata())
{
m_avviaAct->setEnabled(true);
m_fermaAct->setEnabled(false);
}
else
{
m_avviaAct->setEnabled(false);
m_fermaAct->setEnabled(true);
}
m_esportaSchedaAct->setEnabled(scheda->esportabile());
m_stampaSchedaAct->setEnabled(scheda->stampabile());
//attiva/disattiva azioni o menu a seconda del tipo di scheda e dello stato della scheda
switch(scheda->tipoScheda())
{
//non visualizzare il menu a tendina treno perché attualmente è senza voci
case SchedaQViaggiaTreno::tsTreno: m_trenoMenu->menuAction()->setVisible(false); break;
case SchedaQViaggiaTreno::tsStazione: m_stazioneMenu->menuAction()->setVisible(true); break;
case SchedaQViaggiaTreno::tsListaTreni:
{
m_listaTreniMenu->menuAction()->setVisible(true);
m_listaToolbar->setVisible(true);
}; break;
case SchedaQViaggiaTreno::tsAvvisiTrenord: break;
}
}
//Questo slot viene chiamato se l'utente ha scelto di modificare l'intervallo di aggiornamento
//attraverso la corrispondente voce di menu
void QViaggiaTreno::modificaIntervallo()
{
bool Ok;
SchedaQViaggiaTreno *scheda = schedaCorrente();
int intervallo = QInputDialog::getInt(this, QString::fromUtf8("Modifica intervallo di aggiornamento"), QString::fromUtf8("Inserire il nuovo intervallo di aggiornamento in minuti:"), scheda->intervallo(), 1, 1440, 1, &Ok);
if (Ok)
{
scheda->impostaIntervallo(intervallo);
m_spinIntervallo->setValue(intervallo);
}
}
//Questo slot viene richiamato quando si modifica l'intervallo di aggiornamento attraverso la spin box
void QViaggiaTreno::modificaIntervalloConSpinBox(int valore)
{
schedaCorrente()->impostaIntervallo(valore);
}
//questo slot viene richiamato quando lo stato di una scheda cambia
void QViaggiaTreno::aggiornaStatoScheda(quint32 idScheda)
{
SchedaQViaggiaTreno *scheda = m_listaSchede.value(idScheda);
//attiva/disattiva pulsanti per fermare/riavviare il timer a seconda dello stato della scheda...
m_avviaAct->setEnabled(scheda->fermata());
m_fermaAct->setDisabled(scheda->fermata());
}
//la scheda ha emesso un segnale per avvisare che la GUI potrebbe non essere più sincronizzata
//con lo stato della scheda. Questo slot si occupa di risincronizzare lo stato della
//GUI con quello della scheda
void QViaggiaTreno::sincronizzaGUI(quint32 idScheda)
{
//ottieni puntatore alla scheda
SchedaQViaggiaTreno *scheda = m_listaSchede.value(idScheda);
switch(scheda->tipoScheda())
{
case SchedaQViaggiaTreno::tsListaTreni:
{
SchedaListaTreni* listaTreni = qobject_cast(scheda);
//se la lista non è modificata disattiva l'azione per salvare
if (!listaTreni->modificata())
m_salvaAct->setDisabled(true);
else
m_salvaAct->setEnabled(true);
//disattiva le azioni per rimuovere uno o più treni se la lista dei treni è vuota
if (listaTreni->numeroTreni()== 0)
{
m_rimuoviTrenoAct->setDisabled(true);
m_rimuoviTuttiAct->setDisabled(true);
}
else
{
m_rimuoviTrenoAct->setEnabled(true);
m_rimuoviTuttiAct->setEnabled(true);
}
}; break;
default: ; //per le altre tipologie di schede non c'è bisogno di far niente
}
}
//slot
//mostra un messaggio nella status bar
void QViaggiaTreno::mostraMessaggioStatusBar(const QString& msg)
{
statusBar()->showMessage(msg);
}
//slot
//mostra la finestra di dialogo di configurazione
void QViaggiaTreno::configura()
{
DialogoConfigurazione *dlg = new DialogoConfigurazione(this);
dlg->impostaConfigurazione();
if (dlg->exec())
{
dlg->applicaConfigurazione();
//reimposta il proxy
impostaProxy();
}
delete dlg;
}
//aggiorna la scheda corrente
void QViaggiaTreno::aggiorna()
{
schedaCorrente()->aggiorna();
}
//ferma tutte le schede
void QViaggiaTreno::fermaTutte()
{
SchedaQViaggiaTreno* scheda;
foreach(scheda, m_listaSchede)
scheda->ferma();
}
void QViaggiaTreno::avviaTutte()
{
SchedaQViaggiaTreno* scheda;
foreach(scheda, m_listaSchede)
scheda->avvia();
}
//Questo slot viene richiamato durante il controllo periodico del corretto funzionamento di viaggiatreno
void QViaggiaTreno::statoViaggiaTrenoCambiato(bool stato)
{
//attiva/disattiva la voce del menu a seconda dello stato della comunicazione con VT
m_riprovaComunicazioneConVTAct->setDisabled(stato);
//cambia lo stato del LED
m_ledStatoViaggiaTreno->setChecked(stato);
//cambia il tooltip
if (stato)
m_ledStatoViaggiaTreno->setToolTip(QString::fromUtf8("ViaggiaTreno funziona normalmente"));
else
m_ledStatoViaggiaTreno->setToolTip(QString::fromUtf8("ViaggiaTreno al momento non sembra funzionare"));
}
//stampa la scheda corrente richiamandone il rispettivo metodo
void QViaggiaTreno::stampaSchedaCorrente()
{
schedaCorrente()->stampa();
}
//esporta la scheda corrente chiamandone il rispettivo metodo
void QViaggiaTreno::esportaSchedaCorrente()
{
schedaCorrente()->esporta();
}
qviaggiatreno-2013.7.3/src/download_trenord.cpp 0000664 0001750 0001750 00000010064 12215771022 021426 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2010-2012 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "download_trenord.h"
#include "schedaviaggiatreno.h"
#include "qviaggiatreno.h"
//TODO Rimuvovere l'include seguente quando non è più necessario fare debug
#include "utils.h"
#include "parser_trenord.h"
DownloadTrenord::DownloadTrenord(QViaggiaTreno *qvt, QNetworkAccessManager *nam)
{
m_qvt = qvt;
m_nam = nam;
m_parser = 0L;
m_timerAvvisi = new QTimer(this);
}
//richiede al sito webTrenord la pagina con la lista delle direttrici
void DownloadTrenord::aggiornaListaDirettrici()
{
QNetworkRequest request;
//invia una richiesta HTTP GET per scaricare la pagina con la lista delle direttrici
request.setUrl(QUrl("http://www.trenord.it/mobile/it/breaking-news.aspx"));
request.setOriginatingObject(sender());
QNetworkReply* reply = m_nam->get(request);
connect(reply, SIGNAL(finished()), this, SLOT(downloadFinito()));
}
void DownloadTrenord::downloadFinito()
{
QNetworkReply* reply = qobject_cast(sender());
QString risposta = QString::fromUtf8(reply->readAll());
//recupera il puntatore della scheda che ha inviato la richiesta di download
SchedaQViaggiaTreno *scheda = qobject_cast(reply->request().originatingObject());
//controlla se la scheda è aperta, se lo è richiama il metodo downloadFinito della scheda
if (m_qvt->schedaAperta(scheda))
scheda->downloadFinito(risposta);
reply->deleteLater();
}
void DownloadTrenord::scaricaAvvisi(ParserTrenord *parser)
{
m_parser = parser;
m_coda = parser->listaDirettrici();
if (!m_coda.count())
//non ci sono nuovi avvisi da scaricare, inutile continuare
return;
//imposta il timer
//TODO: per il momento scarica gli avvisi con un intervallo fisso di 1 s, successivamente da configurare
m_timerAvvisi->setInterval(1000);
connect(m_timerAvvisi, SIGNAL(timeout()), this, SLOT(scaricaNuovaDirettrice()));
m_timerAvvisi->start();
}
//questo slot viene richiamato dal timer. Ad ogni esecuzione preleva l'indirizzo della pagina di una direttrice
//corregge l'url aggiungendo http://www.trenord.it
//e avvia il download della pagina
//se non ci sono più direttrici allora semplicemente interrompe il timeout ed esce
void DownloadTrenord::scaricaNuovaDirettrice()
{
//controlla che ci siano ancora direttrici da scaricare ed in caso negativo
//arresta il timer ed esce
if (!m_coda.count())
{
//TODO: questo e' il punto in cui si può aggiornare il modello!
disconnect(m_timerAvvisi);
m_timerAvvisi->stop();
return;
}
QString url = QString("http://www.trenord.it%1").arg(m_coda.dequeue());
}
qviaggiatreno-2013.7.3/src/qviaggiatrenoslots_schede.cpp 0000664 0001750 0001750 00000007176 12215773056 023345 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2009-2010 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include
#include "schedalistatreni.h"
#include "schedastazione.h"
#include "schedatreno.h"
#include "qviaggiatreno.h"
//questo file sorgente raggruppa tutti gli slot richiamati da azioni specifiche per ogni scheda
//questo slot viene richiamato quando cambia il nome di una scheda
//(per esempio perché si è cambiato nome della stazione
void QViaggiaTreno::aggiornaNomeScheda(quint32 idScheda)
{
SchedaQViaggiaTreno *scheda = m_listaSchede.value(idScheda);
m_schede->setTabText(m_schede->indexOf(scheda), scheda->titolo());
}
//questo slot viene richiato quando si sceglie la voce per cambiare il nome della stazione
//nel menu stazione. La funzione richiama semplicemente la funzione omonima nella scheda corrente
void QViaggiaTreno::modificaNomeStazione()
{
SchedaStazione *scheda = qobject_cast(schedaCorrente());
scheda->modificaNomeStazione();
}
//questo slot viene richiamato quando si sceglie la voce "apri" nel menu specifico di una scheda
//lo slot richiama semplicemente la funzione corrispondente della scheda
void QViaggiaTreno::apri()
{
//per il momento solo la scheda lista treni ha una funzione apri, non c'è bisogno di
//"indovinare" il tipo della scheda
SchedaListaTreni *scheda = qobject_cast(schedaCorrente());
scheda->apri();
}
void QViaggiaTreno::salva()
{
SchedaListaTreni *scheda = qobject_cast(schedaCorrente());
scheda->salva();
}
void QViaggiaTreno::salvaConNome()
{
SchedaListaTreni *scheda = qobject_cast(schedaCorrente());
scheda->salvaConNome();
}
void QViaggiaTreno::aggiungiTreni()
{
SchedaListaTreni *scheda = qobject_cast(schedaCorrente());
scheda->aggiungiTreni();
}
void QViaggiaTreno::rimuoviTreni()
{
SchedaListaTreni *scheda = qobject_cast(schedaCorrente());
scheda->rimuoviTreni();
}
void QViaggiaTreno::rimuoviTuttiITreni()
{
SchedaListaTreni *scheda = qobject_cast(schedaCorrente());
scheda->rimuoviTuttiITreni();
}
void QViaggiaTreno::impostaTitolo()
{
SchedaListaTreni *scheda = qobject_cast(schedaCorrente());
scheda->impostaTitolo();
}
qviaggiatreno-2013.7.3/src/items.cpp 0000664 0001750 0001750 00000003401 12215773056 017211 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2009-2010 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "items.h"
//confronta il testo di due listwidgetitem, convertendolo in int
//in modo da ordinarli numericamente e non alfabeticamente
bool SortedAsIntListWidgetItem::operator < (const QListWidgetItem& item) const
{
//assume che text() si possa convertire in int
return (text().toInt() < item.text().toInt());
}
qviaggiatreno-2013.7.3/src/dialogo_configurazione.h 0000664 0001750 0001750 00000004207 12215773056 022262 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2010 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef DIALOGO_CONFIGURAZIONE_H
#define DIALOGO_CONFIGURAZIONE_H
#include "ui_dlgconfigurazione.h"
#include "config.h"
class QViaggiaTreno;
class DialogoConfigurazione: public QDialog, private Ui::dlgConfigurazione
{
Q_OBJECT
public:
DialogoConfigurazione(QViaggiaTreno *qvt);
void impostaConfigurazione();
void applicaConfigurazione();
private slots:
void pulsantePremuto(QAbstractButton* pulsante);
void checkBoxAutenticazioneCliccato(bool selezionato);
void checkBoxUsareProxyCliccato(bool selezionato);
void checkBoxUsareProxySistemaCliccato(bool selezionato);
private:
void ripristinaValoriPredefiniti();
QViaggiaTreno* m_qvt;
};
#endif // DIALOGO_CONFIGURAZIONE_H
qviaggiatreno-2013.7.3/src/download_viaggiatreno.cpp 0000664 0001750 0001750 00000034042 12215773217 022442 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2010-2011 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "qviaggiatreno.h"
#include "download_viaggiatreno.h"
#include "schedaviaggiatreno.h"
DownloadViaggiaTreno::DownloadViaggiaTreno(QViaggiaTreno* qvt, QNetworkAccessManager *nam)
{
m_nam = nam;
m_qvt = qvt;
//crea e connette i timer
m_timerDownload = new QTimer(this);
m_timerControlloVT = new QTimer(this);
connect(m_timerControlloVT, SIGNAL(timeout()), this, SLOT(controllaViaggiaTreno()));
connect(m_timerDownload, SIGNAL(timeout()), this, SLOT(download()));
}
QString DownloadViaggiaTreno::correggiOutputVT(QString testoVT)
{
//effettua alcune sostituzione nel codice XHTML generato da ViaggiaTreno, che NON è valido
//sostituisci
con
QString temp = testoVT.simplified();
//sostutuisce l'entità per gli accenti....
temp.replace("'", "'");
//sostituisce gli ampersend negli URL con &
temp.replace("&", "&");
// sostituisce
con
temp.replace("
", "
");
temp.replace("
", "
");
return temp;
}
//slot
// questo slot viene richiamato ad intervalli prefissati
//lo slot controlla se ci sono altre richieste di schede da caricare in coda, in caso positivo scarica la prima e richiama la funzione
//privata più opportuna per impostare la richiesta HTTP
//in futuro in questo slot si verificherà anche se la scheda è già nella cache
void DownloadViaggiaTreno::download()
{
// se non ci sono richieste in coda esce immediatamente
if (!m_codaDownload.count())
return;
//altrimenti prende il primo elemento in coda
DownloadViaggiaTrenoItem * item = m_codaDownload.dequeue();
//individua il tipo di scheda richiesta a viaggiaTreno e richiama la funzione privata giusta
//per generare la richiesta HTTP
switch(item->tipoScheda())
{
case StazioneConNome: richiestaHTTPStazioneConNome(item); break;
case StazioneConCodice: richiestaHTTPStazioneConCodice(item); break;
case RiepilogoTreno: richiestaHTTPRiepilogoTreno(item); break;
case RiepilogoTrenoConOrigine: richiestaHTTPRiepilogoTrenoConOrigine(item); break;
case DettagliTreno: richiestaHTTPDettagliTreno(item); break;
case DettagliTrenoConOrigine: richiestaHTTPDettagliTrenoConOrigine(item);
}
}
// slot richiamati dalle schede per mettere in coda un download
void DownloadViaggiaTreno::downloadStazione(quint32 idScheda, const QString &nomeStazione)
{
DownloadViaggiaTrenoItem *item = new DownloadViaggiaTrenoItem(idScheda, StazioneConNome);
item->impostaDato("NomeStazione", nomeStazione);
m_codaDownload.enqueue(item);
}
void DownloadViaggiaTreno::downloadStazioneCodice(quint32 idScheda, const QString &codiceStazione)
{
DownloadViaggiaTrenoItem *item = new DownloadViaggiaTrenoItem(idScheda, StazioneConCodice);
item->impostaDato("CodiceStazione", codiceStazione);
m_codaDownload.enqueue(item);
}
void DownloadViaggiaTreno::downloadRiepilogoTreno(quint32 idScheda, const QString &numero)
{
DownloadViaggiaTrenoItem *item = new DownloadViaggiaTrenoItem(idScheda, RiepilogoTreno);
item->impostaDato("Numero", numero);
m_codaDownload.enqueue(item);
}
void DownloadViaggiaTreno::downloadRiepilogoTreno(quint32 idScheda, const QString &numero, const QString &codiceStazOrigine)
{
DownloadViaggiaTrenoItem *item = new DownloadViaggiaTrenoItem(idScheda, RiepilogoTrenoConOrigine);
item->impostaDato("Numero", numero);
item->impostaDato("CodiceStazione", codiceStazOrigine );
m_codaDownload.enqueue(item);
}
void DownloadViaggiaTreno::downloadDettagliTreno(quint32 idScheda, const QString &numero)
{
DownloadViaggiaTrenoItem * item = new DownloadViaggiaTrenoItem(idScheda, DettagliTreno);
item->impostaDato("Numero", numero);
m_codaDownload.enqueue(item);
}
void DownloadViaggiaTreno::downloadDettagliTreno(quint32 idScheda, const QString &numero, const QString &codiceStazOrigine)
{
DownloadViaggiaTrenoItem * item = new DownloadViaggiaTrenoItem(idScheda, DettagliTrenoConOrigine);
item->impostaDato("Numero", numero);
item->impostaDato("CodiceStazione", codiceStazOrigine );
m_codaDownload.enqueue(item);
}
//costruisce un'istanza della classe DownloadViaggiaTrenoItem
DownloadViaggiaTrenoItem::DownloadViaggiaTrenoItem(quint32 idScheda, TipoSchedaViaggiaTreno tipoScheda)
{
m_scheda = idScheda;
m_tipoSchedaVT = tipoScheda;
//imposta data/ora richiesta
m_dataEOra = QDateTime::currentDateTime();
}
//invia richiesta HTTP al server di ViaggiaTreno per ottenere la scheda della stazione, fornendo come parametro il nome della stazione
void DownloadViaggiaTreno::richiestaHTTPStazioneConNome(DownloadViaggiaTrenoItem *item)
{
QNetworkRequest request;
QString dati;
dati = QString("stazione=%1").arg(item->dato("NomeStazione"));
dati.replace(" ", "+");
// request.setUrl(QUrl("http://mobile.viaggiatreno.it/viaggiatreno/mobile/stazione?lang=IT"));
request.setUrl(QUrl("http://mobile.viaggiatreno.it/vt_pax_internet/mobile/stazione?lang=IT"));
request.setRawHeader("Content-type", "application/x-www-form-urlencoded");
request.setOriginatingObject(item);
QNetworkReply *reply = m_nam->post(request, dati.toUtf8());
connect(reply, SIGNAL(finished()), this, SLOT(downloadEffettuato()));
}
//invia richiesta HTTP al server di ViaggiaTreno per ottenere la scheda della stazione, fornendo come parametro il codice della stazione
void DownloadViaggiaTreno::richiestaHTTPStazioneConCodice(DownloadViaggiaTrenoItem *item)
{
QNetworkRequest request;
QString dati;
dati = QString("codiceStazione=%1").arg(item->dato("CodiceStazione"));
dati.replace(" ", "+");
//request.setUrl(QUrl("http://mobile.viaggiatreno.it/viaggiatreno/mobile/stazione?lang=IT"));
request.setUrl(QUrl("http://mobile.viaggiatreno.it/vt_pax_internet/mobile/stazione?lang=IT"));
request.setRawHeader("Content-type", "application/x-www-form-urlencoded");
request.setOriginatingObject(item);
QNetworkReply *reply = m_nam->post(request, dati.toUtf8());
connect(reply, SIGNAL(finished()), this, SLOT(downloadEffettuato()));
}
//invia richiesta HTTP a ViaggiaTreno per ottenere la scheda di un treno dato il suo numero
void DownloadViaggiaTreno::richiestaHTTPRiepilogoTreno(DownloadViaggiaTrenoItem *item)
{
QNetworkRequest request;
QString str;
str = QString("numeroTreno=%1&tipoRicerca=numero&lang=IT").arg(item->dato("Numero"));
// request.setUrl(QUrl("http://mobile.viaggiatreno.it/viaggiatreno/mobile/numero"));
request.setUrl(QUrl("http://mobile.viaggiatreno.it/vt_pax_internet/mobile/numero"));
request.setRawHeader("Content-type", "application/x-www-form-urlencoded");
request.setOriginatingObject(item);
QNetworkReply *reply = m_nam->post(request, str.toUtf8());
connect(reply, SIGNAL(finished()), this, SLOT(downloadEffettuato()));
}
//invia richiesta HTTP a ViaggiaTreno per ottenere la scheda di un treno dato il suo numero
//ed il codice della stazione di origine
void DownloadViaggiaTreno::richiestaHTTPRiepilogoTrenoConOrigine(DownloadViaggiaTrenoItem *item)
{
QNetworkRequest request;
QString str;
str = QString("cbxTreno=%1;").arg(item->dato("Numero"));
str += QString("%1&tipoRicerca=numero&lang=IT").arg(item->dato("CodiceStazione"));
//request.setUrl(QUrl("http://mobile.viaggiatreno.it/viaggiatreno/mobile/numero"));
request.setUrl(QUrl("http://mobile.viaggiatreno.it/vt_pax_internet/mobile/numero"));
request.setRawHeader("Content-type", "application/x-www-form-urlencoded");
request.setOriginatingObject(item);
QNetworkReply *reply = m_nam->post(request, str.toUtf8());
connect(reply, SIGNAL(finished()), this, SLOT(downloadEffettuato()));
}
//invia richiesta HTTP a ViaggiaTreno per ottenere la scheda con i dettagli di un treno dato il suo numero
void DownloadViaggiaTreno::richiestaHTTPDettagliTreno(DownloadViaggiaTrenoItem *item)
{
QNetworkRequest request;
// request.setUrl(QUrl(QString("http://mobile.viaggiatreno.it/viaggiatreno/mobile/scheda?dettaglio=visualizza&numeroTreno=%1&tipoRicerca=numero&lang=IT").arg(item->dato("Numero"))));
request.setUrl(QUrl(QString("http://mobile.viaggiatreno.it/vt_pax_internet/mobile/scheda?dettaglio=visualizza&numeroTreno=%1&tipoRicerca=numero&lang=IT").arg(item->dato("Numero"))));
request.setOriginatingObject(item);
QNetworkReply *reply = m_nam->get(request);
connect(reply, SIGNAL(finished()), this, SLOT(downloadEffettuato()));
}
//invia richiesta HTTP a ViaggiaTreno per ottenere la scheda con i dettagli di un treno
//dati il suo numero ed il codice della stazione di origine
void DownloadViaggiaTreno::richiestaHTTPDettagliTrenoConOrigine(DownloadViaggiaTrenoItem *item)
{
QNetworkRequest request;
// request.setUrl(QUrl(QString("http://mobile.viaggiatreno.it/viaggiatreno/mobile/scheda?dettaglio=visualizza&numeroTreno=%1&&codLocOrig=%2&tipoRicerca=numero&lang=IT").
request.setUrl(QUrl(QString("http://mobile.viaggiatreno.it/vt_pax_internet/mobile/scheda?dettaglio=visualizza&numeroTreno=%1&&codLocOrig=%2&tipoRicerca=numero&lang=IT").
arg(item->dato("Numero")).arg(item->dato("CodiceStazione"))));
request.setOriginatingObject(item);
QNetworkReply *reply = m_nam->get(request);
connect(reply, SIGNAL(finished()), this, SLOT(downloadEffettuato()));
}
//slot
//questo slot viene chiamato quando un download da ViaggiaTreno è terminato
void DownloadViaggiaTreno::downloadEffettuato()
{
QNetworkReply *reply = qobject_cast(sender());
QString risposta = QString::fromUtf8(reply->readAll());
//il file XHTML generato da viaggiatreno non è sintatticamente corretto, vanno corretti alcuni errori
risposta = correggiOutputVT(risposta);
// debugStringa(risposta);
//ricava l'item corrispondente a questo downloadQNetworkReply
DownloadViaggiaTrenoItem * item = qobject_cast(reply->request().originatingObject());
//recupera puntatore alla scheda
SchedaQViaggiaTreno* scheda = m_qvt->scheda(item->idScheda());
//se la scheda è ancora aperta richiama la funzione downloadFinito della scheda, altrimenti non fare nulla
if (scheda)
scheda->downloadFinito(risposta);
//in questa sezione andrà aggiunta il testo della scheda alla cache se necessario
//l'item non serve più, liberare memoria
delete item;
//la risposta non serve più, liberare memoria
reply->deleteLater();
}
//slot
//effettua un controllo periodico sul corretto funzionamento del servizio web di viaggiatreno
bool DownloadViaggiaTreno::controllaViaggiaTreno()
{
//prova a scaricare la pagina di query di un treno di ViaggiaTreno
QNetworkRequest request;
//request.setUrl(QUrl("http://mobile.viaggiatreno.it/viaggiatreno/mobile/"));
request.setUrl(QUrl("http://mobile.viaggiatreno.it/vt_pax_internet/mobile"));
QNetworkReply *reply = m_nam->get(request);
// usa un event loop per effettuare una richiesta sincrona
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
//ed usa un timer singleshot per il timeout
QTimer::singleShot(m_qvt->configurazione().intervalloControlloVT()*1000, &loop, SLOT(quit()));
//esegui l'event loop
loop.exec();
//si è usciti dal loop o perché c'è stato un timeout o perché il download si è concluso positivamente
//verifica se non si è concluso positivamente
if (reply->error()!= QNetworkReply::NoError)
{
emit statoViaggiaTreno(false);
//ferma i donwload da ViaggiaTreno
m_timerDownload->stop();
return false;
}
else
{
//il download sembra essersi concluso positivamente, estraiamo il codice HTML
QString paginaVT = QString::fromUtf8(reply->readAll());
//e cerchiamo se la pagina contiene il testo "Numero treno"
if (paginaVT.contains("Numero treno"))
{
emit statoViaggiaTreno(true);
return true;
}
else
{
emit statoViaggiaTreno(false);
//ferma i donwload da ViaggiaTreno
m_timerDownload->stop();
return false;
}
}
}
//avvia il downloader
void DownloadViaggiaTreno::avvia()
{
//inizializza i timer
m_timerDownload->setInterval(m_qvt->configurazione().intervalloQueryVT()*1000);
m_timerControlloVT->setInterval(m_qvt->configurazione().intervalloControlloVT()*60*1000);
//avvia il timer per il controllo periodico del funzionamento di ViaggiaTreno
m_timerControlloVT->start();
//esegue un controllo preliminare sul funzionamento di Viaggiatreno
if (!controllaViaggiaTreno())
// viaggiatreno non funziona
return;
else
m_timerDownload->start();
}
qviaggiatreno-2013.7.3/src/parser_viaggiatreno_lista.h 0000664 0001750 0001750 00000003134 12215773056 022767 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2010-2011 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef PARSER_VIAGGIATRENO_LISTA_H
#define PARSER_VIAGGIATRENO_LISTA_H
#include
class SchedaQViaggiaTreno;
#endif // PARSER_VIAGGIATRENO_LISTA_H
qviaggiatreno-2013.7.3/src/parser_viaggiatreno_base.cpp 0000664 0001750 0001750 00000004242 12214355774 023123 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2010-2013 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "parser_viaggiatreno_base.h"
//sostituisce il nome della stazione per ovviare ad alcuni bug di ViaggiaTreno che fanno si che in
//alcuni casi i nomi delle stazioni siano incoerenti
//per esempio sulla rete FNM i treni vengono riportati con origine destinazione "M N Cadorna" ma poi
// non esiste tale stazione in ViaggiaTreno, bensì "Milano Nord Cadorna"
QString ParserViaggiaTrenoBase::sostituisciNomeStazione(const QString &nome)
{
if (nome.contains("M N CADORNA"))
return QString(nome).replace("M N CADORNA", "MILANO NORD CADORNA", Qt::CaseInsensitive);
if (nome.contains("CAMNAGO LENTATE"))
return QString(nome).replace("CAMNAGO LENTATE", "CAMNAGO-LENTATE", Qt::CaseInsensitive);
return nome;
}
qviaggiatreno-2013.7.3/src/qviaggiatreno.h 0000664 0001750 0001750 00000013044 12215773217 020400 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2008-2010 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef QVIAGGIATRENO_H
#define QVIAGGIATRENO_H
#include
#include
#include "config.h"
class SchedaStazione;
class SchedaTreno;
class SchedaListaTreni;
class SchedaAvvisiTrenord;
class SchedaQViaggiaTreno;
class DownloadViaggiaTreno;
class DownloadTrenord;
class QLedIndicator;
class QViaggiaTreno:public QMainWindow
{
Q_OBJECT
public:
QViaggiaTreno();
~QViaggiaTreno();
//restituisce un puntatore al QNetworkAccessManager che è globale per l'applicazione
QNetworkAccessManager* networkAccessManager() {return m_nam;}
//restituisce un puntatore alla classe per il download da viaggiatreno
DownloadViaggiaTreno * downloadViaggiaTreno() {return m_downloadViaggiaTreno;}
//restituisce un puntatore alla classe per il download dal sito Trenord
DownloadTrenord* downloadTrenord() {return m_downloadTrenord;}
//restituisce un puntatore ad una scheda dato il suo id
SchedaQViaggiaTreno* scheda(quint32 id);
//restituisce true se il puntatore punta ad una scheda ancora aperta
bool schedaAperta(SchedaQViaggiaTreno* scheda);
Configurazione& configurazione() {return m_configurazione;}
protected:
private slots:
void about();
void visualizzaLicenza();
void nuovaStazione();
SchedaStazione* nuovaStazione(const QString& stazione, bool nomeEsatto = false, int intervallo = 0, bool nonAvviare = false);
SchedaListaTreni* nuovaListaTreni();
SchedaAvvisiTrenord* nuovaSchedaAvvisiTrenord();
void nuovoTreno();
SchedaTreno* nuovoTreno(const QString& numeroTreno, int intervallo = 0);
SchedaTreno* nuovoTreno(const QString& numeroTreno, const QString& codiceOrigine, int intervallo = 0);
void chiudiScheda(int id);
void avvia();
void avviaTutte();
void ferma();
void fermaTutte();
void aggiorna();
void configura();
void schedaCambiata(int indice);
void modificaIntervallo();
void modificaIntervalloConSpinBox(int intervallo);
void aggiornaStatoScheda(quint32 idScheda);
void aggiornaNomeScheda(quint32 idScheda);
void sincronizzaGUI(quint32 idScheda);
void mostraMessaggioStatusBar(const QString& msg);
void stampaSchedaCorrente();
void esportaSchedaCorrente();
//azioni per menu/toolbar specifici per tipo di scheda
//implementazione in qviaggiatrenoslots_schede.cpp
void modificaNomeStazione();
void apri();
void salva();
void salvaConNome();
void aggiungiTreni();
void rimuoviTreni();
void rimuoviTuttiITreni();
void impostaTitolo();
void statoViaggiaTrenoCambiato(bool);
private:
void creaWidgetCentrale();
void creaAzioni();
void creaMenu();
void creaToolBar();
void creaStatusBar();
void leggiImpostazioniFinestra();
void ripristinaSchede();
void salvaSchede();
void scriviImpostazioniFinestra();
SchedaQViaggiaTreno * schedaCorrente();
void impostaProxy();
void closeEvent(QCloseEvent *event);
QMenu *m_viaggiatrenoMenu, *m_opzioniMenu, *m_helpMenu;
QMenu *m_stazioneMenu, *m_trenoMenu, *m_listaTreniMenu;
QToolBar *m_mainToolBar, *m_listaToolbar;
QAction *m_exitAct, *m_nuovaStazioneAct, *m_nuovoTrenoAct, *m_nuovaListaTreniAct;
QAction *m_avvisiTrenordAct;
QAction *m_configuraAct;
QAction *m_aboutAct, *m_aboutQtAct, *m_licenseAct;
QAction *m_fermaAct, *m_avviaAct, *m_fermaTutteAct, *m_avviaTutteAct;
QAction *m_aggiornaAct, *m_intervalloAct, *m_aggiungiTrenoAct;
QAction *m_riprovaComunicazioneConVTAct;
QAction *m_rimuoviTrenoAct, *m_rimuoviTuttiAct, *m_impostaTitoloAct;
QAction *m_spinIntervalloAct;
QAction *m_cambiaNomeStazioneAct, *m_apriAct, *m_salvaAct, *m_salvaConNomeAct;
QAction *m_stampaSchedaAct, *m_esportaSchedaAct;
QTabWidget *m_schede;
QSpinBox *m_spinIntervallo;
QDialog *m_licenseDialog;
QLedIndicator *m_ledStatoViaggiaTreno;
int maxStazioni;
QStringList m_listaStazioniMonitorate;
QMap m_listaSchede;
DownloadViaggiaTreno* m_downloadViaggiaTreno;
DownloadTrenord* m_downloadTrenord;
QNetworkAccessManager* m_nam;
//impostazioni
Configurazione m_configurazione;
//numero di versione
static QString s_versione;
};
#endif
qviaggiatreno-2013.7.3/src/schedalistatreni.cpp 0000664 0001750 0001750 00000043125 12215773217 021424 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2009-2011 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "schedalistatreni.h"
#include "download_viaggiatreno.h"
#include "qviaggiatreno.h"
#include "schedatreno.h"
#include "utils.h"
int SchedaListaTreni::s_count = 0;
SchedaListaTreni::SchedaListaTreni(QViaggiaTreno* parent, const unsigned int intervalloStandard):
SchedaQViaggiaTreno(parent, tsListaTreni, intervalloStandard)
{
s_count++;
m_stato = statoNuovaScheda;
m_modificata = false;
m_titoloLista = "";
m_idTabella = m_idNumeroAmbiguo = -1;
//imposta il widget
m_widget = new WidgetListaTreni(this);
m_idTabella = addWidget(m_widget);
setCurrentIndex(m_idTabella);
m_widget->impostaTitolo(titolo(true));
m_widget->ridimensionaColonne();
//imposta il parser
m_parser = new ParserTrenoViaggiaTreno(this);
//imposta connessioni
connect(this, SIGNAL(statoCambiato(quint32)), parent, SLOT(aggiornaStatoScheda(quint32)));
connect(this, SIGNAL(nomeSchedaCambiato(quint32)), parent, SLOT(aggiornaNomeScheda(quint32)));
connect(this, SIGNAL(apriSchedaStazione(const QString&, bool)), parent, SLOT(nuovaStazione(const QString&, bool)));
connect(this, SIGNAL(apriSchedaTreno(const QString&)), parent, SLOT(nuovoTreno(const QString&)));
connect(this, SIGNAL(GuiNonSincronizzata(quint32)), parent, SLOT(sincronizzaGUI(quint32)));
connect(this, SIGNAL(messaggioStatus(const QString&)), parent, SLOT(mostraMessaggioStatusBar(const QString&)));
connect(this, SIGNAL(downloadRiepilogoTreno(quint32, QString)), qViaggiaTreno()->downloadViaggiaTreno(), SLOT(downloadRiepilogoTreno(quint32, QString)));
connect(this, SIGNAL(downloadRiepilogoTreno(quint32,QString,QString)), qViaggiaTreno()->downloadViaggiaTreno(), SLOT(downloadRiepilogoTreno(quint32, QString, QString)));
}
//restituisce una stringa con il "titolo" di questa scheda, che viene ad esempio usato come etichetta della TabBar
// se titoloItem == true restituisce un titolo per l'item dell'albero
QString SchedaListaTreni::titolo(bool titoloBreve) const
{
if (m_titoloLista.isEmpty())
{
if (titoloBreve)
return(QString::fromUtf8("Lista di treni senza titolo #%1").arg(s_count));
else
return(QString::fromUtf8("Lista di treni: senza titolo #%1").arg(s_count));
}
else
{
if (titoloBreve)
return m_titoloLista;
else
return(QString::fromUtf8("Lista di treni: %1").arg(m_titoloLista));
}
}
void SchedaListaTreni::impostaTitolo()
{
bool ok;
QString titolo = QInputDialog::getText(this, QString::fromUtf8("Impostare titolo della lista"),
QString::fromUtf8("Inserire il nuovo titolo della lista di treni"),
QLineEdit::Normal, m_titoloLista, &ok);
if (ok)
{
m_titoloLista = titolo;
m_widget->impostaTitolo(titolo);
m_modificata = true;
emit GuiNonSincronizzata(idScheda());
emit nomeSchedaCambiato(idScheda());
}
}
void SchedaListaTreni::avvia()
{
SchedaQViaggiaTreno::avvia();
}
void SchedaListaTreni::ferma()
{
SchedaQViaggiaTreno::ferma();
m_codatreni.clear();
m_trenoAttuale = "";
}
void SchedaListaTreni::aggiorna()
{
//cancella dallo StackedWidget i widget creati per gestire gli errori
if (m_idNumeroAmbiguo != -1)
{
QWidget *widgetDaRimuovere = widget(m_idNumeroAmbiguo);
widgetDaRimuovere->deleteLater();
m_idNumeroAmbiguo = -1;
}
//ottiene una lista di tutti i numeri dei treni che si stanno attualmente controllando
QStringList listaNumeri = m_listatreni.keys();
//e li aggiunge alla coda
QStringListIterator it(listaNumeri);
while (it.hasNext())
m_codatreni.enqueue(it.next());
//preleva il primo elemento dalla coda e procedi...
prossimoTreno();
}
void SchedaListaTreni::downloadFinito(const QString &rispostaVT)
{
ListaVT::DatiTreno* treno;
//procedi solo se nel frattempo non è stato cancellato il numero del treno attuale
//questo succede ad esempio se nel frattempo il treno è stato rimosso dalla lista dei treni
if (m_trenoAttuale != "")
{
treno = m_listatreni.value(m_trenoAttuale);
m_parser->impostaRispostaVTRiepilogo(rispostaVT);
//sono possibili 6 risposte
//1) il numero del treno non è valido
//2) il treno non è partito ancora
//3) il treno è in viaggio
//4) il treno è già arrivato
//5) il treno è stato soppresso totalmente
//6) il numero treno è ambiguo
//nei casi 1) 5) e 6) non è necessario fare il parsing della risposta...
//verifichiamo quindi se siamo in questa situazione e nel caso aggiorniamo immediatamente il treno
//o lasciamo risolvere all'utente l'ambiguità sul numero treno
if (m_parser->trenoNonPrevisto())
{
treno->cancella();
treno->impostaStatoTreno(TrenoVT::TrenoNonPrevisto);
}
else if (m_parser->trenoSoppressoTotalmente())
{
treno->cancella();
treno->impostaStatoTreno(TrenoVT::TrenoCancellato);
}
else if (m_parser->numeroTrenoAmbiguo())
{
m_trenoAmbiguo = m_trenoAttuale;
ferma();
m_idNumeroAmbiguo = addWidget(new WidgetDisambiguaNumeroTreno(this, treno->numero(), m_parser->listaCodiciTreno(rispostaVT)));
setCurrentIndex(m_idNumeroAmbiguo);
cambiaStato(statoErrore);
return;
}
else
{
if (!m_parser->analizzaRiepilogoPerLista(*treno))
{
cambiaStato(statoErrore);
treno->impostaStatoTreno(TrenoVT::DatiSconosciuti);
return;
}
}
//aggiorna la riga del treno attuale nel widget
m_widget->aggiornaTreno(treno);
emit messaggioStatus(QString::fromUtf8("Aggiornati dati treno %1 della lista '%2' Rimangono %3 su %4 treni da analizzare")
.arg(treno->numero()).arg(titolo(true)).arg(m_codatreni.count()).arg(m_listatreni.count()));
//non ci sono altri treni in coda?
if (m_codatreni.isEmpty())
//no, cambia stato e memorizza l'ora di fine aggiornamento
{
m_trenoAttuale = "";
m_ultimoAgg = QDateTime::currentDateTime();
m_widget->impostaAggiornamento(m_ultimoAgg.toString("dd/MM/yyyy hh:mm"));
cambiaStato(statoMonitoraggioAttivo);
}
else
//si, preleva il treno successivo
prossimoTreno();
}
}
//slot
//questo metodo risponde all'attivazione dell'azione per l'apertura di un file
void SchedaListaTreni::apri()
{
QString filename = QFileDialog::getOpenFileName(this, QString::fromUtf8("Apri lista treni"),
QDir::homePath(), QString::fromUtf8("File QViaggiaTreno (*.qvt);;Tutti i file (*.*)"));
if (filename != "")
apriFile(filename);
}
void SchedaListaTreni::apriFile(const QString& filename)
{
QFile fileaperto(filename);
if (!fileaperto.open(QIODevice::ReadOnly))
{
//errore durante l'apertura del file
QMessageBox::critical(this, QString::fromUtf8("Errore apertura file"),
QString::fromUtf8("Impossibile aprire il file '%1'").arg(filename));
return;
}
QString errore;
int riga, col;
if (!m_dom.setContent(&fileaperto, &errore, &riga, &col))
{
//errore nel parsing
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(QString::fromUtf8("Errore durante la lettura della lista di treni."));
msgBox.setDetailedText(QString::fromUtf8("Ricevuto messaggio di errore %1 alla riga %2, colonna %3.").arg(errore).arg(riga).arg(col));
msgBox.exec();
return;
}
//legge il file xml
QDomElement radice = m_dom.documentElement();
//verifica che il tag dell'elemento radice sia "qviaggiatreno"
if (radice.tagName() != "qviaggiatreno")
{
QMessageBox::warning(this, QString::fromUtf8("Errore nel file"),
QString::fromUtf8("Il file non sembra essere un file dati di QViaggiaTreno"));
return;
}
//in futuro si dovrà verificare la versione del file, ora non è necessario
if (radice.attribute("tipo") != "lista_treni")
{
QMessageBox::warning(this, QString::fromUtf8("Errore nel file"),
QString::fromUtf8("Il file è un file di dati di QViaggiaTreno,"
" ma non sembra contenere una lista treni"));
return;
}
// il file contiene una lista di treni...
//recupera il titolo
m_titoloLista = radice.firstChildElement("titolo").text();
m_widget->impostaTitolo(titolo(true));
emit nomeSchedaCambiato(idScheda());
//ottiene una lista di tutti gli elementi con tag name "treno"
QDomNodeList listaTreni = m_dom.elementsByTagName("treno");
//scorre la lista ed aggiunge i singoli treni
for (int i = 0; i < listaTreni.count(); i++)
{
aggiungiTreno(listaTreni.at(i).toElement().attribute("numero"),
listaTreni.at(i).toElement().attribute("codice", ""));
}
fileaperto.close();
//forza l'aggiornamento
aggiorna();
m_modificata = false;
m_nomefile = filename;
//sincronizza la GUI
emit GuiNonSincronizzata(idScheda());
}
//slot
//viene richiamato quando viene scelto da menu o toolbar l'azione epr salvare il file
void SchedaListaTreni::salva()
{
if (m_nomefile != "")
salvaFile(m_nomefile);
else
salvaConNome();
}
void SchedaListaTreni::salvaConNome()
{
QString filename = QFileDialog::getSaveFileName(this, QString::fromUtf8("Salva file con nome"),
QDir::homePath(), QString::fromUtf8("File QViaggiaTreno (*.qvt)"));
if (filename != "")
{
// se il file non ha una estensione, aggiungi l'estensione .qvt
if (QFileInfo(filename).suffix() == "")
filename.append(".qvt");
salvaFile(filename);
}
}
void SchedaListaTreni::salvaFile(const QString& filename)
{
//prova ad aprire il file
QFile fileDaSalvare(filename);
//l'apertura non è andata a buon fine
if (!fileDaSalvare.open(QIODevice::WriteOnly))
{
QMessageBox::critical(this, QString::fromUtf8("Errore salvataggio file"),
QString::fromUtf8("Errore nell'apertura in scrittura del file %1").arg(filename));
return;
}
//cancella il documento dom
m_dom = QDomDocument("qviaggiatreno");
//crea l'elemento radice
QDomElement radice = m_dom.createElement("qviaggiatreno");
m_dom.appendChild(radice);
//imposta versione e tipo file
radice.setAttribute("versione", "2");
radice.setAttribute("tipo", "lista_treni");
//aggiunge la radice al documento
//crea l'elemento per il titolo
QDomElement titolo = m_dom.createElement("titolo");
QDomText testo = m_dom.createTextNode(m_titoloLista);
titolo.appendChild(testo);
radice.appendChild(titolo);
//scorre la lista dei treni monitorati
QDomElement lista = m_dom.createElement("listatreni");
radice.appendChild(lista);
QStringListIterator it(m_listatreni.keys());
while (it.hasNext())
{
QString numero = it.next();
QDomElement elementoTreno = m_dom.createElement("treno");
elementoTreno.setAttribute("numero", numero);
if (!m_listatreni[numero]->codiceOrigine().isEmpty())
elementoTreno.setAttribute("codice", m_listatreni[numero]->codiceOrigine());
lista.appendChild(elementoTreno);
}
//salva l'albero DOM
QTextStream stream(&fileDaSalvare);
m_dom.save(stream, 4);
fileDaSalvare.close();
//cambia nome file
m_nomefile = filename;
m_modificata = false;
emit GuiNonSincronizzata(idScheda());
}
//aggiunge un singolo treno alla lista dei treni da monitorare
void SchedaListaTreni::aggiungiTreno(const QString& numero, const QString& codice)
{
//verifica se si sta già controllando questo treno,
//in caso positivo esci dalla funzione senza fare niente
if (m_listatreni.contains(numero))
return;
//crea una nuova istanza di ListaVT::DatiTreno per memorizzare i dati del treno
ListaVT::DatiTreno *treno = new ListaVT::DatiTreno(numero);
//imposta, se esiste, il codice della stazione di origine
if (!codice.isEmpty())
treno->impostaCodiceOrigine(codice);
//aggiunge il treno alla mappa dei treni
m_listatreni.insert(numero, treno);
//e lo aggiunge al widget
m_widget->aggiungiTreno(treno);
}
//rimuove un singolo treno alla lista dei treni da monitorare
void SchedaListaTreni::rimuoviTreno(const QString& numero)
{
//rimuove il treno dalla lista dei treni
m_listatreni.remove(numero);
//verifica che non sia nella coda dei treni, se c'è rimuovilo
m_codatreni.removeAll(numero);
if (m_trenoAttuale == numero)
m_trenoAttuale = "";
m_widget->rimuoviTreno(numero);
}
//slot
//questo slot è connesso all'azione per aggiungere treni
void SchedaListaTreni::aggiungiTreni()
{
DialogoAggiuntaTreni dialogo(this);
if (dialogo.exec() == QDialog::Accepted)
{
if (!dialogo.listaVuota())
{
QStringListIterator it(dialogo.listaTreni());
while (it.hasNext())
aggiungiTreno(it.next());
}
}
//sono stati aggiunti tutti i treni, aggiornare la larghezza delle colonne
m_widget->ridimensionaColonne();
m_modificata = true;
//c'è stato un cambiamento nella scheda che ha influenza sull'aspetto della GUI
//va quindi emesso il segnale per sincronizzare la gui
emit(GuiNonSincronizzata(idScheda()));
//forza un aggiornamento immediato dei treni
aggiorna();
}
void SchedaListaTreni::rimuoviTreni()
{
DialogoRimozioneTreni dialogo(m_listatreni.keys(), this);
if (dialogo.exec() == QDialog::Accepted)
{
QStringListIterator it(dialogo.listaTreni());
while (it.hasNext())
rimuoviTreno(it.next());
}
m_modificata = true;
//c'è stato un cambiamento nella scheda che ha influenza sull'aspetto della GUI
//va quindi emesso il segnale per sincronizzare la gui
emit(GuiNonSincronizzata(idScheda()));
}
//slot
//questo slot è connesso all'azione per rimuovere tutti i treni dalla lista
void SchedaListaTreni::rimuoviTuttiITreni()
{
//rimuovi tutti i treni dalla tabella
m_widget->rimuoviTuttiITreni();
//rimuovi tutti i treni dalla coda
m_codatreni.clear();
m_trenoAttuale = "";
//elimina la lista di treni
m_listatreni.clear();
m_modificata = true;
//sincronizza la gui
emit(GuiNonSincronizzata(idScheda()));
}
//questa funziona preleva il prossimo treno dalla coda dei treni
//e richiede i dati a viaggiatreno
void SchedaListaTreni::prossimoTreno()
{
//verifica che ci siano elementi nella coda, altrimenti esci
if (m_codatreni.isEmpty())
return;
m_trenoAttuale = m_codatreni.dequeue();
QString temp = m_listatreni[m_trenoAttuale]->codiceOrigine();
if (m_listatreni[m_trenoAttuale]->codiceOrigine().isEmpty())
emit (downloadRiepilogoTreno(idScheda(), m_trenoAttuale));
else
emit (downloadRiepilogoTreno(idScheda(), m_trenoAttuale, m_listatreni[m_trenoAttuale]->codiceOrigine()));
}
void SchedaListaTreni::salvaScheda(QSettings& settings)
{
//la scheda è modificata, proponi di salvare il contenuto
if (modificata())
{
int risposta = QMessageBox::warning(this, QString::fromUtf8("La scheda è modificata"),
QString::fromUtf8("La scheda '%1' è stata modificata, ma la lista di treni non è ancora stata salvata e non ne sarà possibile il ripristino.
"
"Si desidera salvare la lista?").arg(titolo(true)), QMessageBox::Yes, QMessageBox::No);
if (risposta == QMessageBox::Yes)
salva();
}
//salva semplicemente il nome del file
settings.setValue("tipo scheda", "lista treni");
settings.setValue("nome file", m_nomefile);
}
void SchedaListaTreni::cambiaCodiceOrigine(const QString &nuovoCodice)
{
m_listatreni[m_trenoAmbiguo]->impostaCodiceOrigine(nuovoCodice);
aggiorna();
avvia();
}
qviaggiatreno-2013.7.3/src/doc/ 0000775 0001750 0001750 00000000000 12214333074 016122 5 ustar locutus locutus qviaggiatreno-2013.7.3/src/doc/GPL-2.txt 0000664 0001750 0001750 00000043103 12215773056 017456 0 ustar locutus locutus GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
qviaggiatreno-2013.7.3/src/schedaavvisitrenord.h 0000664 0001750 0001750 00000004472 12214355774 021617 0 ustar locutus locutus /***************************************************************************
* Copyright (C) 2008-2012 by fra74 *
* francesco.b74@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef SCHEDAAVVISITRENORD_H
#define SCHEDAAVVISITRENORD_H
#include "parser_trenord.h"
#include "schedaviaggiatreno.h"
#include "ui_wgtavvisitrenord.h"
class QViaggiaTreno;
class WidgetAvvisiTrenord: public QWidget, private Ui::wgtAvvisiTrenord
{
Q_OBJECT
public:
WidgetAvvisiTrenord(QWidget *parent, ModelloAvvisiTrenord* modello);
};
class SchedaAvvisiTrenord: public SchedaQViaggiaTreno
{
Q_OBJECT
public:
SchedaAvvisiTrenord(QViaggiaTreno* parent, const unsigned int intervalloStandard = 5);
QString titolo(bool = false) const {return QString::fromUtf8("Avvisi Trenord");}
virtual void avvia();
virtual void ferma();
virtual void aggiorna();
virtual void downloadFinito(const QString &);
virtual ~SchedaAvvisiTrenord();
private:
WidgetAvvisiTrenord* m_widgetAvvisi;
ParserTrenord* m_parser;
ModelloAvvisiTrenord *m_avvisi;
signals:
void aggiornaListaDirettrici();
};
#endif // SCHEDAAVVISITRENORD_H
qviaggiatreno-2013.7.3/src/img/ 0000775 0001750 0001750 00000000000 12214335105 016126 5 ustar locutus locutus qviaggiatreno-2013.7.3/src/img/esporta.png 0000664 0001750 0001750 00000002413 12215773056 020325 0 ustar locutus locutus PNG
IHDR D sBITO pHYs v v}Ղ tEXtSoftware www.inkscape.org<
PLTE ~~~~~~~~~TYY\`^X]]Z^_[``\a`agfbggrrr~~~֦zDه PtRNS
!"$%&')+,-13569<>BDFIJNRYj{{|^ IDATxmMkQsMTD)BW]_.nT-P|
TmkjI!M2s3w&Y$Cys,1`D`
"
PUH"\\D=3Eu[vp&+~s|B UbhҺQyRVyX)Z ָVyUS"0(Un.sxrbM"R\x:w遧,\sͬ3#evڠc"@ʻi;\
Af^g|ြQfhC"dY{g`ND9ȯqY)ruyhAPC=&94 r^8
M"?%mqȭ9tn2Y.y;^IDdeg_LE3hև$b9v٠|čt!FV:8
!ش]q(Rr/er;3tc6 49c/kR+,=Sdd3|l IENDB` qviaggiatreno-2013.7.3/src/img/avvia.png 0000664 0001750 0001750 00000002231 12215773056 017754 0 ustar locutus locutus PNG
IHDR s sBITUF pHYs v v}Ղ tEXtSoftware www.inkscape.org< IDATx}kU}3IMkL[
BF+fU4-~P\JHi6(KM[EjkBDDE63Nׇ0C$/$k?$"fÅф5kX)p@+E&pe|M_hBBdɱQq76R_c}0RgYetM<1n>>`pїTel"ogBJCv~[en_:la%3 &q;l,v76x':.2 xBgJݾ~ l<9mw-6O*2í.E^e{K<+Ѵ,j,pZL=|A:,ԩ3HYlAd˫Kf!N[Yc~d_
@]qnק"?-6bujTcG#+O5ZC) $@)>bmY
c1sT2(e|ɓcw·?I[xbkk,r#h%[v`1ʼn`dB%