2
// C++ Interface: MerkaartorPreferences
7
// Author: cbro <cbro@semperpax.com>, bvh, (C) 2008
9
// Copyright: See COPYING file that comes with this distribution
12
#ifndef MERKAARTORPREFERENCES_H
13
#define MERKAARTORPREFERENCES_H
16
#include <QtCore/QSettings>
21
#include <QNetworkProxy>
23
#include "Maps/Coord.h"
24
#include "Preferences/WmsServersList.h"
25
#include "Preferences/TmsServersList.h"
26
#include "Preferences/ProjectionsList.h"
27
#include "Preferences/BookmarksList.h"
33
//#define WORLD_COORDBOX CoordBox(Coord(1.3, -1.3), Coord(-1.3, 1.3))
34
#define WORLD_COORDBOX CoordBox(Coord(INT_MAX/4, -INT_MAX/4), Coord(-INT_MAX/4, INT_MAX/4))
35
#define BUILTIN_STYLES_DIR ":/Styles"
36
#define BUILTIN_TEMPLATES_DIR ":/Templates"
37
#define M_PREFS MerkaartorPreferences::instance()
39
#define NONE_ADAPTER_UUID QUuid("{8F5D3625-F987-45c5-A50B-17D88384F97D}")
40
#define SHAPE_ADAPTER_UUID QUuid("{AFB0324E-34D0-4267-BB8A-CF56CD2D7012}")
41
#define WMS_ADAPTER_UUID QUuid("{E238750A-AC27-429e-995C-A60C17B9A1E0}")
42
#define TMS_ADAPTER_UUID QUuid("{CA8A07EC-A466-462b-929F-3805BC9DEC95}")
44
#define HOMEDIR QDir::homePath() + "/.merkaartor"
46
#define M_PARAM_DECLARE_BOOL(Param) \
50
void set##Param(bool theValue); \
52
#define M_PARAM_DECLARE_STRING(Param) \
56
void set##Param(QString theValue); \
58
#define M_PARAM_DECLARE_INT(Param) \
62
void set##Param(int theValue); \
64
#define M_PARAM_DECLARE_DOUBLE(Param) \
68
void set##Param(double theValue); \
71
#define SAFE_DELETE(x) {delete (x); x = NULL;}
72
#define STRINGIFY(x) XSTRINGIFY(x)
73
#define XSTRINGIFY(x) #x
76
@author cbro <cbro@semperpax.com>
80
typedef QString ProjectionType;
89
enum DirectionalArrowsShow {
90
DirectionalArrows_Never,
91
DirectionalArrows_Oneway,
92
DirectionalArrows_Always
95
#define TOOL_FIELD_SIZE 2
100
Tool(QString Name, QString Path);
106
typedef QMap<QString, Tool> ToolList;
107
typedef QMapIterator<QString, Tool> ToolListIterator;
110
// Outside of merkaartorpreferences, because initializing it will need translations
111
// Classic chicken & egg problem.
112
QString getDefaultLanguage();
113
void setDefaultLanguage(const QString& L);
115
class MerkaartorPreferences : public QObject
119
MerkaartorPreferences();
120
~MerkaartorPreferences();
122
static MerkaartorPreferences* instance() {
123
if (!m_prefInstance) {
124
m_prefInstance = new MerkaartorPreferences;
127
return m_prefInstance;
130
void save(bool UserPwdChanged = false);
134
void putOsmPref(const QString& k, const QString& v);
135
void deleteOsmPref(const QString& k);
137
const QVector<qreal> getParentDashes() const;
139
//bool use06Api() const;
140
void setUse06Api(bool b);
141
const QString apiVersion() const;
142
double apiVersionNum() const;
144
void setRightSideDriving(bool theValue);
145
bool getRightSideDriving() const;
147
void setDoubleRoadDistance(double theValue);
148
double getDoubleRoadDistance() const;
150
void setWorkingDir(const QString & theValue);
151
QString getWorkingDir() const;
153
BookmarkList* getBookmarks();
155
WmsServerList* getWmsServers();
156
TmsServerList* getTmsServers();
157
void setSelectedServer(const QString & theValue);
158
QString getSelectedServer() const;
160
void setBgVisible(bool theValue);
161
bool getBgVisible() const;
164
void setCacheDir(const QString & theValue);
165
QString getCacheDir() const;
166
void setCacheSize(int theValue);
167
int getCacheSize() const;
170
void setLastMaxSearchResults(int theValue);
171
int getLastMaxSearchResults() const;
172
void setLastSearchName(const QString & theValue);
173
QString getLastSearchName() const;
174
void setLastSearchKey(const QString & theValue);
175
QString getLastSearchKey() const;
176
void setLastSearchValue(const QString & theValue);
177
QString getLastSearchValue() const;
180
void setZoomInPerc(int theValue);
181
int getZoomInPerc() const;
182
void setZoomOutPerc(int theValue);
183
int getZoomOutPerc() const;
185
QStringList getAlphaList() const;
187
qreal getAlpha(QString lvl);
188
QHash<QString, qreal>* getAlphaPtr();
190
QColor getBgColor() const;
191
void setBgColor(const QColor theValue);
192
QColor getWaterColor() const;
193
void setWaterColor(const QColor theValue);
194
QColor getFocusColor() const;
195
int getFocusWidth() const;
196
void setFocusColor(const QColor theValue, int width);
197
QColor getHoverColor() const;
198
int getHoverWidth() const;
199
void setHoverColor(const QColor theValue, int width);
200
QColor getHighlightColor() const;
201
int getHighlightWidth() const;
202
void setHighlightColor(const QColor theValue, int width);
203
QColor getRelationsColor() const;
204
int getRelationsWidth() const;
205
void setRelationsColor(const QColor theValue, int width);
206
QColor getGpxTrackColor() const;
207
int getGpxTrackWidth() const;
208
void setGpxTrackColor(const QColor theValue, int width);
210
void setDownloadedVisible(bool theValue);
211
bool getDownloadedVisible() const;
213
void setScaleVisible(bool theValue);
214
bool getScaleVisible() const;
216
bool getStyleBackgroundVisible() const;
217
void setStyleBackgroundVisible(bool theValue);
218
bool getStyleForegroundVisible() const;
219
void setStyleForegroundVisible(bool theValue);
220
bool getStyleTouchupVisible() const;
221
void setStyleTouchupVisible(bool theValue);
222
void setNamesVisible(bool theValue);
223
bool getNamesVisible() const;
225
DirectionalArrowsShow getDirectionalArrowsVisible();
226
void setDirectionalArrowsVisible(DirectionalArrowsShow theValue);
228
void setTrackPointsVisible(bool theValue);
229
bool getTrackPointsVisible() const;
231
void setTrackSegmentsVisible(bool theValue);
232
bool getTrackSegmentsVisible() const;
234
void setRelationsVisible(bool theValue);
235
bool getRelationsVisible() const;
237
M_PARAM_DECLARE_INT(TagListFirstColumnWidth)
239
/* MainWindow state */
240
void saveMainWindowState(const class MainWindow * mainWindow);
241
void restoreMainWindowState(class MainWindow * mainWindow) const;
243
void setInitialPosition(MapView* vw);
244
void initialPosition(MapView* vw);
246
bool getDrawTileBoundary();
249
void setOsmWebsite(const QString & theValue);
250
QString getOsmWebsite() const;
252
M_PARAM_DECLARE_STRING(XapiWebSite)
253
M_PARAM_DECLARE_BOOL(AutoHistoryCleanup)
255
void setOsmUser(const QString & theValue);
256
QString getOsmUser() const;
258
void setOsmPassword(const QString & theValue);
259
QString getOsmPassword() const;
261
void setGpsPort(const QString & theValue);
262
QString getGpsPort() const;
264
M_PARAM_DECLARE_DOUBLE(MaxDistNodes)
266
void setAutoSaveDoc(bool theValue);
267
bool getAutoSaveDoc() const;
269
void setAutoExtractTracks(bool theValue);
270
bool getAutoExtractTracks() const;
273
void setExportType(ExportType theValue);
274
ExportType getExportType() const;
277
ToolList* getTools() const;
278
Tool getTool(QString toolName) const;
280
QStringList getShortcuts() const;
281
void setShortcuts(const QStringList & theValue);
284
void setRecentOpen(const QStringList & theValue);
285
QStringList getRecentOpen() const;
286
void addRecentOpen(const QString & theValue);
288
void setRecentImport(const QStringList & theValue);
289
QStringList getRecentImport() const;
290
void addRecentImport(const QString & theValue);
293
M_PARAM_DECLARE_STRING(DefaultStyle)
294
M_PARAM_DECLARE_STRING(CustomStyle)
295
M_PARAM_DECLARE_BOOL(DisableStyleForTracks)
298
M_PARAM_DECLARE_BOOL(BackgroundOverwriteStyle)
299
M_PARAM_DECLARE_INT(AreaOpacity)
300
M_PARAM_DECLARE_BOOL(UseShapefileForBackground)
301
M_PARAM_DECLARE_BOOL(DrawingHack)
302
M_PARAM_DECLARE_BOOL(SimpleGpxTrack)
305
M_PARAM_DECLARE_STRING(DefaultTemplate)
306
M_PARAM_DECLARE_STRING(CustomTemplate)
308
M_PARAM_DECLARE_BOOL(GpsSaveLog)
309
M_PARAM_DECLARE_BOOL(GpsMapCenter)
310
M_PARAM_DECLARE_STRING(GpsLogDir)
311
M_PARAM_DECLARE_BOOL(GpsSyncTime)
313
M_PARAM_DECLARE_BOOL(ResolveRelations)
314
M_PARAM_DECLARE_BOOL(DeleteIncompleteRelations)
316
M_PARAM_DECLARE_BOOL(TranslateTags)
318
M_PARAM_DECLARE_BOOL(MapTooltip)
319
M_PARAM_DECLARE_BOOL(InfoOnHover)
320
M_PARAM_DECLARE_BOOL(ShowParents)
322
/* World OSB manager */
323
M_PARAM_DECLARE_DOUBLE(TileToRegionThreshold)
325
M_PARAM_DECLARE_STRING(WorldOsbUri)
326
M_PARAM_DECLARE_BOOL(WorldOsbAutoload)
327
M_PARAM_DECLARE_BOOL(WorldOsbAutoshow)
329
/* Mouse bevaviour */
330
M_PARAM_DECLARE_BOOL(MouseSingleButton)
331
M_PARAM_DECLARE_BOOL(SeparateMoveMode)
334
M_PARAM_DECLARE_BOOL(MerkaartorStyle)
335
M_PARAM_DECLARE_STRING(MerkaartorStyleString)
338
M_PARAM_DECLARE_BOOL(OfflineMode)
341
QNetworkProxy getProxy(const QUrl & requestUrl);
343
M_PARAM_DECLARE_BOOL(ProxyUse)
344
M_PARAM_DECLARE_STRING(ProxyHost)
345
M_PARAM_DECLARE_INT(ProxyPort)
346
M_PARAM_DECLARE_STRING(ProxyUser)
347
M_PARAM_DECLARE_STRING(ProxyPassword)
350
M_PARAM_DECLARE_BOOL(ReadonlyTracksDefault)
353
M_PARAM_DECLARE_BOOL(FeaturesWithin)
356
void addBackgroundPlugin(IMapAdapter* aPlugin);
357
void setBackgroundPlugin(const QUuid& theValue);
358
QUuid getBackgroundPlugin() const;
359
IMapAdapter* getBackgroundPlugin(const QUuid& anAdapterUid);
360
QMap<QUuid, IMapAdapter *> getBackgroundPlugins();
363
void loadProjection(QString fn);
364
void loadProjections();
365
void saveProjections();
368
void loadWMS(QString fn);
373
void loadTMS(QString fn);
378
void loadBookmark(QString fn);
379
void loadBookmarks();
380
void saveBookmarks();
383
void setProjectionType(ProjectionType theValue);
384
ProjectionType getProjectionType() const;
385
ProjectionsList getProjectionsList();
386
ProjectionItem getProjection(QString aProj);
392
QVector<qreal> parentDashes;
396
bool RightSideDriving;
397
double DoubleRoadDistance;
407
QBuffer OsmPrefContent;
408
QMap<QString, int> OsmPrefListsCount;
410
void setWmsServers();
411
void setTmsServers();
416
QHash<QString, qreal> alpha;
417
ToolList* theToolList;
419
QStringList projTypes;
420
QMap<QUuid, IMapAdapter *> mBackgroundPlugins;
421
ProjectionsList theProjectionsList;
422
WmsServersList theWmsServerList;
423
TmsServersList theTmsServerList;
424
BookmarksList theBookmarkList;
426
static MerkaartorPreferences* m_prefInstance;
429
void on_responseHeaderReceived(const QHttpResponseHeader & hdr);
430
void on_requestFinished ( int id, bool error );
433
void bookmarkChanged();