3 Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
26 #include <QStringList>
28 Settings::Settings(QObject *parent) :
41 m_queryBaseUrl = settings.value("QueryURL",
42 "http://mobile.viaggiatreno.it/viaggiatreno/mobile/stazione").toString();
44 m_recentStations = settings.value("RecentStations").toString().split(",");
45 qDebug() << "RecentStations:" << m_recentStations;
47 m_stationViewPreferred = settings.value("StationViewPreferred", false).toBool();
48 qDebug() << "StationsViewPreferred:" << m_stationViewPreferred;
50 m_checkingInterval = settings.value("CheckInterval", 0).toInt();
51 qDebug() << "CheckInterval:" << m_checkingInterval;
58 qDebug() << "Saving Settings to" << settings.fileName();
60 settings.setValue("QueryURL", m_queryBaseUrl);
61 settings.setValue("RecentStations", m_recentStations.join(","));
62 settings.setValue("CheckInterval", m_checkingInterval);
63 settings.setValue("StationViewPreferred", m_stationViewPreferred);
66 QString Settings::queryBaseUrl()
68 return m_queryBaseUrl;
71 void Settings::setQueryBaseUrl(const QString &url)
74 emit queryBaseUrlChanged(m_queryBaseUrl);
77 QStringList Settings::recentStations()
79 return m_recentStations;
82 void Settings::setRecentStations(const QStringList &stations)
84 m_recentStations = stations;
85 emit recentStationsChanged(m_recentStations);
88 int Settings::checkingInterval()
90 return m_checkingInterval;
93 void Settings::setCheckingInterval(int interval)
95 m_checkingInterval = interval;
97 emit checkingIntervalChanged(m_checkingInterval);
100 bool Settings::stationViewPreferred()
102 return m_stationViewPreferred;
105 void Settings::setStationViewPreferred(bool preference)
107 m_stationViewPreferred = preference;
108 emit stationViewPreferredChanged(m_stationViewPreferred);
111 Settings *Settings::instance()
113 static Settings *settings = 0;
116 settings = new Settings();