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::instance()
30 static Settings *settings = 0;
33 settings = new Settings();
37 Settings::Settings(QObject *parent) :
40 qDebug() << "Settings constructor called";
45 qDebug() << "Settings destructor called";
53 qDebug() << "Saving Settings to" << settings.fileName();
57 QString Settings::queryBaseUrl()
60 return settings.value("QueryURL",
61 "http://mobile.viaggiatreno.it/viaggiatreno/mobile/stazione").toString();
64 void Settings::setQueryBaseUrl(const QString &url)
68 settings.setValue("QueryURL", url);
69 emit queryBaseUrlChanged();
72 QStringList Settings::recentStations()
76 return settings.value("RecentStations").toString().split(",");
79 void Settings::setRecentStations(const QStringList &stations)
83 settings.setValue("RecentStations", stations.join(","));
84 emit recentStationsChanged();
87 int Settings::checkingInterval()
91 return settings.value("CheckInterval", 0).toInt();
94 void Settings::setCheckingInterval(int interval)
98 settings.setValue("CheckInterval", interval);
99 emit checkingIntervalChanged();
102 bool Settings::stationViewPreferred()
106 return settings.value("StationViewPreferred", false).toBool();
109 void Settings::setStationViewPreferred(bool preference)
113 settings.setValue("StationViewPreferred", preference);
114 emit stationViewPreferredChanged();
117 bool Settings::showArrivalsPreferred()
121 return settings.value("StationView/ShowArrivals", false).toBool();
124 void Settings::setShowArrivalsPreferred(bool preference)
128 settings.setValue("StationView/ShowArrivals", preference);
129 emit showArrivalsPreferredChanged();
132 StationListProxyModel::SortingMode Settings::stationListSortingMode()
136 int mode = settings.value("StationListView/SortingMode").toInt();
137 qDebug() << "StationListSortingMode is" << mode;
138 return (StationListProxyModel::SortingMode)mode;
141 void Settings::setStationListSortingMode(StationListProxyModel::SortingMode mode)
145 settings.setValue("StationListView/SortingMode", mode);
146 qDebug() << "StationListSortingMode set to" << mode;
147 emit stationListSortingModeChanged();