Added option to surpress error messages
[GPXSee.git] / src / GUI / gui.h
blob4b8c00dfb41072b0c4fc4b188dbcad796ec9dc4b
1 #ifndef GUI_H
2 #define GUI_H
4 #include <QMainWindow>
5 #include <QString>
6 #include <QList>
7 #include <QDate>
8 #include <QPrinter>
9 #include "common/treenode.h"
10 #include "common/rectc.h"
11 #include "data/graph.h"
12 #include "units.h"
13 #include "timetype.h"
14 #include "format.h"
15 #include "pdfexportdialog.h"
16 #include "pngexportdialog.h"
17 #include "optionsdialog.h"
19 class QMenu;
20 class QToolBar;
21 class QTabWidget;
22 class QActionGroup;
23 class QAction;
24 class QLabel;
25 class QSplitter;
26 class QPrinter;
27 class QGeoPositionInfoSource;
28 class FileBrowser;
29 class GraphTab;
30 class MapView;
31 class Map;
32 class POI;
33 class QScreen;
34 class MapAction;
35 class POIAction;
36 class Data;
37 class DEMLoader;
38 class NavigationWidget;
40 class GUI : public QMainWindow
42 Q_OBJECT
44 public:
45 GUI();
47 bool openFile(const QString &fileName, bool tryUnknown, int &showError);
48 bool loadMap(const QString &fileName, MapAction *&action,
49 bool silent = false);
50 void show();
51 void writeSettings();
53 private slots:
54 void about();
55 #ifndef Q_OS_ANDROID
56 void keys();
57 #endif // Q_OS_ANDROID
58 void paths();
59 void printFile();
60 void exportPDFFile();
61 void exportPNGFile();
62 void openFile();
63 #ifdef Q_OS_ANDROID
64 void openDir();
65 #endif // Q_OS_ANDROID
66 void closeAll();
67 void reloadFiles();
68 void statistics();
69 void openPOIFile();
70 void showGraphs(bool show);
71 void showGraphGrids(bool show);
72 void showGraphSliderInfo(bool show);
73 void showPathMarkerInfo(QAction *action);
74 #ifdef Q_OS_ANDROID
75 void showGraphTabs(bool show);
76 #else // Q_OS_ANDROID
77 void showToolbars(bool show);
78 void showFullscreen(bool show);
79 #endif // Q_OS_ANDROID
80 void showTracks(bool show);
81 void showRoutes(bool show);
82 void showAreas(bool show);
83 void showWaypoints(bool show);
84 void loadMap();
85 void loadMapDir();
86 void nextMap();
87 void prevMap();
88 void openOptions();
89 void clearMapCache();
90 void downloadDEM();
91 void showDEMTiles();
93 void mapChanged(QAction *action);
94 void graphChanged(int);
95 void poiFileChecked(QAction *action);
96 void selectAllPOIs();
97 void unselectAllPOIs();
99 void next();
100 void prev();
101 void last();
102 void first();
103 void updateNavigationActions();
105 void setTotalTime() {setTimeType(Total);}
106 void setMovingTime() {setTimeType(Moving);}
107 void setMetricUnits() {setUnits(Metric);}
108 void setImperialUnits() {setUnits(Imperial);}
109 void setNauticalUnits() {setUnits(Nautical);}
110 void setDistanceGraph() {setGraphType(Distance);}
111 void setTimeGraph() {setGraphType(Time);}
112 void setDecimalDegrees() {setCoordinatesFormat(DecimalDegrees);}
113 void setDegreesMinutes() {setCoordinatesFormat(DegreesMinutes);}
114 void setDMS() {setCoordinatesFormat(DMS);}
116 void screenChanged(QScreen *screen);
117 void logicalDotsPerInchChanged(qreal dpi);
119 void mapLoaded();
120 void mapLoadedDir();
121 void mapInitialized();
123 void demLoaded();
125 private:
126 typedef QPair<QDateTime, QDateTime> DateTimeRange;
128 void closeFiles();
129 void plot(QPrinter *printer);
130 void plotMainPage(QPainter *painter, const QRectF &rect, qreal ratio,
131 bool expand = false);
132 void plotGraphsPage(QPainter *painter, const QRectF &rect, qreal ratio);
133 qreal graphPlotHeight(const QRectF &rect, qreal ratio);
135 TreeNode<POIAction*> createPOIActionsNode(const TreeNode<QString> &node);
136 TreeNode<MapAction*> createMapActionsNode(const TreeNode<Map*> &node);
137 void createMapNodeMenu(const TreeNode<MapAction*> &node, QMenu *menu,
138 QAction *action = 0);
139 void createPOINodeMenu(const TreeNode<POIAction*> &node, QMenu *menu,
140 QAction *action = 0);
141 void createActions();
142 void createMenus();
143 #ifdef Q_OS_ANDROID
144 void createNavigation();
145 #else // Q_OS_ANDROID
146 void createToolBars();
147 #endif // Q_OS_ANDROID
148 void createStatusBar();
149 void createMapView();
150 void createGraphTabs();
151 void createBrowser();
153 bool openPOIFile(const QString &fileName);
154 bool loadFile(const QString &fileName, bool tryUnknown, int &showError);
155 void loadData(const Data &data);
156 bool loadMapNode(const TreeNode<Map*> &node, MapAction *&action,
157 bool silent, const QList<QAction*> &existingActions);
158 void loadMapDirNode(const TreeNode<Map*> &node, QList<MapAction*> &actions,
159 QMenu *menu, const QList<QAction*> &existingActions);
160 void updateStatusBarInfo();
161 void updateWindowTitle();
162 bool updateGraphTabs();
163 void updateDEMDownloadAction();
165 TimeType timeType() const;
166 Units units() const;
167 void setTimeType(TimeType type);
168 void setUnits(Units units);
169 void setCoordinatesFormat(CoordinatesFormat format);
170 void setGraphType(GraphType type);
172 qreal distance() const;
173 qreal time() const;
174 qreal movingTime() const;
175 QAction *mapAction(const QString &name);
176 QGeoPositionInfoSource *positionSource(const Options &options);
177 void readSettings(QString &activeMap, QStringList &disabledPOIs);
179 void loadInitialMaps(const QString &selected);
180 void loadInitialPOIs(const QStringList &disabled);
182 void loadOptions();
183 void updateOptions(const Options &options);
185 #ifndef Q_OS_ANDROID
186 void keyPressEvent(QKeyEvent *event);
187 #endif // Q_OS_ANDROID
188 void closeEvent(QCloseEvent *event);
189 void dragEnterEvent(QDragEnterEvent *event);
190 void dropEvent(QDropEvent *event);
192 #ifdef Q_OS_ANDROID
193 NavigationWidget *_navigation;
194 #else // Q_OS_ANDROID
195 QToolBar *_fileToolBar;
196 QToolBar *_showToolBar;
197 QToolBar *_navigationToolBar;
198 #endif // Q_OS_ANDROID
199 QMenu *_poiMenu;
200 QMenu *_mapMenu;
202 QActionGroup *_fileActionGroup;
203 QActionGroup *_navigationActionGroup;
204 QActionGroup *_mapsActionGroup;
205 QActionGroup *_poisActionGroup;
206 #if !defined(Q_OS_MAC) && !defined(Q_OS_ANDROID)
207 QAction *_exitAction;
208 #endif // Q_OS_MAC + Q_OS_ANDROID
209 QAction *_pathsAction;
210 QAction *_aboutAction;
211 QAction *_printFileAction;
212 QAction *_exportPDFFileAction;
213 QAction *_exportPNGFileAction;
214 QAction *_openFileAction;
215 QAction *_openDirAction;
216 QAction *_closeFileAction;
217 QAction *_reloadFileAction;
218 QAction *_statisticsAction;
219 QAction *_openPOIAction;
220 QAction *_selectAllPOIAction;
221 QAction *_unselectAllPOIAction;
222 QAction *_showPOIAction;
223 QAction *_overlapPOIAction;
224 QAction *_showPOILabelsAction;
225 QAction *_showPOIIconsAction;
226 QAction *_showMapAction;
227 QAction *_showPositionAction;
228 QAction *_followPositionAction;
229 QAction *_showPositionCoordinatesAction;
230 QAction *_showMotionInfoAction;
231 QAction *_loadMapAction;
232 QAction *_loadMapDirAction;
233 QAction *_clearMapCacheAction;
234 QAction *_showGraphsAction;
235 QAction *_showGraphGridAction;
236 QAction *_showGraphSliderInfoAction;
237 QAction *_distanceGraphAction;
238 QAction *_timeGraphAction;
239 #ifdef Q_OS_ANDROID
240 QAction *_showGraphTabsAction;
241 #else // Q_OS_ANDROID
242 QAction *_keysAction;
243 QAction *_fullscreenAction;
244 QAction *_showToolbarsAction;
245 QAction *_nextAction;
246 QAction *_prevAction;
247 QAction *_lastAction;
248 QAction *_firstAction;
249 #endif // Q_OS_ANDROID
250 QAction *_metricUnitsAction;
251 QAction *_imperialUnitsAction;
252 QAction *_nauticalUnitsAction;
253 QAction *_decimalDegreesAction;
254 QAction *_degreesMinutesAction;
255 QAction *_dmsAction;
256 QAction *_totalTimeAction;
257 QAction *_movingTimeAction;
258 QAction *_nextMapAction;
259 QAction *_prevMapAction;
260 QAction *_showTracksAction;
261 QAction *_showRoutesAction;
262 QAction *_showWaypointsAction;
263 QAction *_showWaypointLabelsAction;
264 QAction *_showWaypointIconsAction;
265 QAction *_showAreasAction;
266 QAction *_showRouteWaypointsAction;
267 QAction *_hideMarkersAction;
268 QAction *_showMarkersAction;
269 QAction *_showMarkerDateAction;
270 QAction *_showMarkerCoordinatesAction;
271 QAction *_showTicksAction;
272 QAction *_useStylesAction;
273 QAction *_showCoordinatesAction;
274 QAction *_openOptionsAction;
275 QAction *_downloadDEMAction;
276 QAction *_showDEMTilesAction;
277 QAction *_mapsEnd;
278 QAction *_poisEnd;
280 QLabel *_fileNameLabel;
281 QLabel *_distanceLabel;
282 QLabel *_timeLabel;
284 QSplitter *_splitter;
285 MapView *_mapView;
286 QTabWidget *_graphTabWidget;
287 QList<GraphTab*> _tabs;
288 GraphTab *_lastTab;
290 POI *_poi;
291 Map *_map;
292 QGeoPositionInfoSource *_positionSource;
293 DEMLoader *_dem;
295 FileBrowser *_browser;
296 QList<QString> _files;
298 int _trackCount, _routeCount, _areaCount, _waypointCount;
299 qreal _trackDistance, _routeDistance;
300 qreal _time, _movingTime;
301 DateTimeRange _dateRange;
302 QString _pathName;
304 #ifndef Q_OS_ANDROID
305 QList<QByteArray> _windowStates;
306 QList<QByteArray> _windowGeometries;
307 int _frameStyle;
308 #endif // Q_OS_ANDROID
310 PDFExport _pdfExport;
311 PNGExport _pngExport;
312 Options _options;
314 QString _dataDir, _mapDir, _poiDir;
316 Units _units;
318 QList<RectC> _demRects;
321 #endif // GUI_H