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.
24 #include <QApplication>
27 #include <QStringList>
29 Settings *Settings::instance()
31 static Settings *settings = 0;
34 settings = new Settings();
38 Settings::Settings(QObject *parent) :
41 qDebug() << "Settings constructor called";
46 qDebug() << "Settings destructor called";
54 qDebug() << "Saving Settings to" << settings.fileName();
58 QString Settings::queryBaseUrl()
61 return settings.value("QueryURL",
62 "http://mobile.viaggiatreno.it/vt_pax_internet/mobile/").toString();
65 void Settings::setQueryBaseUrl(const QString &url)
69 settings.setValue("QueryURL", url);
70 emit queryBaseUrlChanged();
73 QStringList Settings::recentStations()
77 return settings.value("RecentStations").toString().split(",");
80 void Settings::setRecentStations(const QStringList &stations)
84 settings.setValue("RecentStations", stations.join(","));
85 emit recentStationsChanged();
88 int Settings::checkingInterval()
92 return settings.value("CheckInterval", 0).toInt();
95 void Settings::setCheckingInterval(int interval)
99 settings.setValue("CheckInterval", interval);
100 emit checkingIntervalChanged();
103 bool Settings::autoUpdate()
107 bool current = settings.value("AutoUpdate", false).toBool();
108 qDebug() << "AutoUpdate is" << current;
112 void Settings::setAutoUpdate(bool preference)
116 settings.setValue("AutoUpdate", preference);
117 qDebug() << "AutoUpdate set to" << preference;
118 emit autoUpdateChanged();
121 bool Settings::stationViewPreferred()
125 return settings.value("StationViewPreferred", false).toBool();
128 void Settings::setStationViewPreferred(bool preference)
132 settings.setValue("StationViewPreferred", preference);
133 emit stationViewPreferredChanged();
136 bool Settings::showArrivalsPreferred()
140 return settings.value("StationView/ShowArrivals", false).toBool();
143 void Settings::setShowArrivalsPreferred(bool preference)
147 settings.setValue("StationView/ShowArrivals", preference);
148 emit showArrivalsPreferredChanged();
151 StationListProxyModel::SortingMode Settings::stationListSortingMode()
155 int mode = settings.value("StationListView/SortingMode").toInt();
156 qDebug() << "StationListSortingMode is" << mode;
157 return (StationListProxyModel::SortingMode)mode;
160 void Settings::setStationListSortingMode(StationListProxyModel::SortingMode mode)
164 settings.setValue("StationListView/SortingMode", mode);
165 qDebug() << "StationListSortingMode set to" << mode;
166 emit stationListSortingModeChanged();
169 QString Settings::versionString()
171 return qApp->applicationVersion();