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 <QCoreApplication>
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 QStringList Settings::favoriteStations()
92 return settings.value("FavoriteStations").toString().split(",");
95 void Settings::setFavoriteStations(const QStringList &stations)
99 settings.setValue("FavoriteStations", stations.join(","));
100 emit favoriteStationsChanged();
103 int Settings::checkingInterval()
107 return settings.value("CheckInterval", 0).toInt();
110 void Settings::setCheckingInterval(int interval)
114 settings.setValue("CheckInterval", interval);
115 emit checkingIntervalChanged();
118 bool Settings::autoUpdate()
122 bool current = settings.value("AutoUpdate", false).toBool();
123 qDebug() << "AutoUpdate is" << current;
127 void Settings::setAutoUpdate(bool preference)
131 settings.setValue("AutoUpdate", preference);
132 qDebug() << "AutoUpdate set to" << preference;
133 emit autoUpdateChanged();
136 bool Settings::stationViewPreferred()
140 return settings.value("StationViewPreferred", false).toBool();
143 void Settings::setStationViewPreferred(bool preference)
147 settings.setValue("StationViewPreferred", preference);
148 emit stationViewPreferredChanged();
151 bool Settings::darkThemePreferred()
155 return settings.value("DarkThemePreferred", false).toBool();
158 void Settings::setDarkThemePreferred(bool preference)
162 settings.setValue("DarkThemePreferred", preference);
163 emit stationViewPreferredChanged();
166 bool Settings::showArrivalsPreferred()
170 return settings.value("StationView/ShowArrivals", false).toBool();
173 void Settings::setShowArrivalsPreferred(bool preference)
177 settings.setValue("StationView/ShowArrivals", preference);
178 emit showArrivalsPreferredChanged();
181 StationListProxyModel::SortingMode Settings::stationListSortingMode()
185 int mode = settings.value("StationListView/SortingMode").toInt();
186 qDebug() << "StationListSortingMode is" << mode;
187 return (StationListProxyModel::SortingMode)mode;
190 void Settings::setStationListSortingMode(StationListProxyModel::SortingMode mode)
194 settings.setValue("StationListView/SortingMode", mode);
195 qDebug() << "StationListSortingMode set to" << mode;
196 emit stationListSortingModeChanged();
199 QString Settings::versionString()
201 return qApp->applicationVersion();