1 // -*- C++ -*-
2 // $Id: babeldata.h,v 1.8 2010-06-19 23:59:06 robertl Exp $
3 //------------------------------------------------------------------------
4 //
5 //  Copyright (C) 2009  S. Khai Mong <khai@mangrai.com>.
6 //
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License as
9 //  published by the Free Software Foundation; either version 2 of the
10 //  License, or (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 //  General Public License for more details.
16 //
17 //  You should have received a copy of the GNU General Public License
18 //  along with this program; if not, write to the Free Software
19 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20 //  USA.
21 //
22 //------------------------------------------------------------------------
23 #ifndef BABELDATA_H
24 #define BABELDATA_H
25 
26 #include <QSettings>
27 #include <QStringList>
28 #include <QUuid>
29 #include "setting.h"
30 
31 
32 class BabelData
33 {
34 public:
BabelData()35   BabelData():
36     inputType_(fileType_),
37     inputFileFormat_(QString()),
38     inputDeviceFormat_(QString()),
39     inputFileNames_(QStringList()),
40     inputDeviceName_(QString()),
41     inputCharSet_(QString()),
42     xlateWayPts_(true),
43     xlateRoutes_(true),
44     xlateTracks_(true),
45     outputType_(fileType_),
46     outputFileFormat_(QString()),
47     outputDeviceFormat_(QString()),
48     outputFileName_(QString()),
49     outputDeviceName_(QString()),
50     outputCharSet_(QString()),
51     synthShortNames_(false),
52     forceGPSTypes_(false),
53     enableCharSetXform_(false),
54     debugLevel_(-1),
55     inputBrowse_(QString()),
56     outputBrowse_(QString()),
57     previewGmap_(false),
58     upgradeCheckMethod_(0),
59     upgradeCheckTime_(QDateTime(QDate(2001, 1, 1), QTime(0, 0))),
60     installationUuid_(QUuid::createUuid().toString()),
61     upgradeCallbacks_(0),
62     upgradeAccept_(0),
63     upgradeDeclines_(0),
64     upgradeErrors_(0),
65     upgradeOffers_(0),
66     runCount_(0),
67     startupVersionCheck_(true),
68     reportStatistics_(true),
69     allowBetaUpgrades_(false),
70     ignoreVersionMismatch_(false),
71     disableDonateDialog_(false),
72     donateSplashed_(QDateTime(QDate(2010, 1, 1), QTime(0, 0, 0)))
73   {
74   }
75 
saveSettings(QSettings & st)76   void saveSettings(QSettings& st)
77   {
78     SettingGroup sg;
79     makeSettingGroup(sg);
80     sg.saveSettings(st);
81   }
restoreSettings(QSettings & st)82   void restoreSettings(QSettings& st)
83   {
84     SettingGroup sg;
85     makeSettingGroup(sg);
86     sg.restoreSettings(st);
87   }
88 
makeSettingGroup(SettingGroup & sg)89   void makeSettingGroup(SettingGroup& sg)
90   {
91     sg.addVarSetting(new IntSetting("app.inputType", inputType_));
92     sg.addVarSetting(new StringSetting("app.inputFileFormat", inputFileFormat_));
93     sg.addVarSetting(new StringSetting("app.inputDeviceFormat", inputDeviceFormat_));
94     sg.addVarSetting(new StringSetting("app.inputCharSet", inputCharSet_));
95     sg.addVarSetting(new StringSetting("app.inputDeviceName", inputDeviceName_));
96 
97     sg.addVarSetting(new BoolSetting("app.xlateWayPts", xlateWayPts_));
98     sg.addVarSetting(new BoolSetting("app.xlateRoutes", xlateRoutes_));
99     sg.addVarSetting(new BoolSetting("app.xlateTracks", xlateTracks_));
100 
101     sg.addVarSetting(new IntSetting("app.outputType", outputType_));
102     sg.addVarSetting(new StringSetting("app.outputFileFormat", outputFileFormat_));
103     sg.addVarSetting(new StringSetting("app.outputDeviceFormat", outputDeviceFormat_));
104     sg.addVarSetting(new StringSetting("app.outputCharSet", outputCharSet_));
105     sg.addVarSetting(new StringSetting("app.outputDeviceName", outputDeviceName_));
106 
107     sg.addVarSetting(new BoolSetting("app.synthShortNames", synthShortNames_));
108     sg.addVarSetting(new BoolSetting("app.forceGPSTypes", forceGPSTypes_));
109     sg.addVarSetting(new BoolSetting("app.enableCharSetXform", enableCharSetXform_));
110 
111     sg.addVarSetting(new StringSetting("app.inputBrowse", inputBrowse_));
112     sg.addVarSetting(new StringSetting("app.outputBrowse", outputBrowse_));
113 
114     sg.addVarSetting(new BoolSetting("app.previewGmap", previewGmap_));
115     sg.addVarSetting(new IntSetting("app.upgradeCheckMethod", upgradeCheckMethod_));
116     sg.addVarSetting(new DateTimeSetting("app.upgradeCheckTime", upgradeCheckTime_));
117     sg.addVarSetting(new DateTimeSetting("app.donateSplashed", donateSplashed_));
118     sg.addVarSetting(new StringSetting("app.installationUuid", installationUuid_));
119     sg.addVarSetting(new IntSetting("app.upgradeCallbacks", upgradeCallbacks_));
120     sg.addVarSetting(new IntSetting("app.upgradeAccept", upgradeAccept_));
121     sg.addVarSetting(new IntSetting("app.upgradeDeclines", upgradeDeclines_));
122     sg.addVarSetting(new IntSetting("app.upgradeErrors", upgradeErrors_));
123     sg.addVarSetting(new IntSetting("app.upgradeOffers", upgradeOffers_));
124     sg.addVarSetting(new IntSetting("app.runCount", runCount_));
125 
126     // Global preferences.
127     sg.addVarSetting(new BoolSetting("app.startupVersionCheck", startupVersionCheck_));
128     sg.addVarSetting(new BoolSetting("app.reportStatistics", reportStatistics_));
129     sg.addVarSetting(new BoolSetting("app.allowBetaUpgrades", allowBetaUpgrades_));
130     sg.addVarSetting(new BoolSetting("app.ignoreVersionMismatch", ignoreVersionMismatch_));
131     sg.addVarSetting(new BoolSetting("app.disableDonateDialog", disableDonateDialog_));
132 
133   }
134 
135   static const int noType_;
136   static const int fileType_;
137   static const int deviceType_;
138 
139   int inputType_;
140   QString inputFileFormat_;
141   QString inputDeviceFormat_;
142   QStringList inputFileNames_;
143   QString inputDeviceName_;
144   QString inputCharSet_;
145 
146   bool xlateWayPts_;
147   bool xlateRoutes_;
148   bool xlateTracks_;
149 
150   int outputType_;
151   QString outputFileFormat_;
152   QString outputDeviceFormat_;
153   QString outputFileName_;
154   QString outputDeviceName_;
155   QString outputCharSet_;
156 
157   bool synthShortNames_;
158   bool forceGPSTypes_;
159   bool enableCharSetXform_;
160   int  debugLevel_;
161 
162   QString inputBrowse_, outputBrowse_;
163 
164   bool  previewGmap_;
165   int   upgradeCheckMethod_;
166   QDateTime upgradeCheckTime_;
167   QString installationUuid_;
168   int upgradeCallbacks_;
169   int upgradeAccept_;
170   int upgradeDeclines_;
171   int upgradeErrors_;
172   int upgradeOffers_;
173   int runCount_;
174 
175   // Global preferences.
176   bool startupVersionCheck_;
177   bool reportStatistics_;
178   bool allowBetaUpgrades_;
179   bool ignoreVersionMismatch_;
180   bool disableDonateDialog_;
181   QDateTime donateSplashed_;
182 
183 };
184 
185 #endif
186