Use the canonical file name also for the "already open" check
[GPXSee.git] / src / GUI / gui.h
blobba182acea83531fdc2aa3e0e6865caa1ebf1b141
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, int &showError);
49 void show();
50 void writeSettings();
52 private slots:
53 void about();
54 #ifndef Q_OS_ANDROID
55 void keys();
56 #endif // Q_OS_ANDROID
57 void paths();
58 void printFile();
59 void exportPDFFile();
60 void exportPNGFile();
61 void openFile();
62 void openDir();
63 void closeAll();
64 void reloadFiles();
65 void statistics();
66 void openPOIFile();
67 void showGraphs(bool show);
68 void showGraphGrids(bool show);
69 void showGraphSliderInfo(bool show);
70 void showPathMarkerInfo(QAction *action);
71 #ifdef Q_OS_ANDROID
72 void showGraphTabs(bool show);
73 #else // Q_OS_ANDROID
74 void showToolbars(bool show);
75 void showFullscreen(bool show);
76 #endif // Q_OS_ANDROID
77 void showTracks(bool show);
78 void showRoutes(bool show);
79 void showAreas(bool show);
80 void showWaypoints(bool show);
81 void loadMap();
82 void loadMapDir();
83 void nextMap();
84 void prevMap();
85 void openOptions();
86 void clearMapCache();
87 void downloadDEM();
88 void showDEMTiles();
90 void mapChanged(QAction *action);
91 void graphChanged(int);
92 void poiFileChecked(QAction *action);
93 void selectAllPOIs();
94 void unselectAllPOIs();
95 #ifndef Q_OS_ANDROID
96 void recentFileSelected(QAction *action);
97 void clearRecentFiles();
98 #endif // Q_OS_ANDROID
100 void next();
101 void prev();
102 void last();
103 void first();
104 void updateNavigationActions();
106 void setTotalTime() {setTimeType(Total);}
107 void setMovingTime() {setTimeType(Moving);}
108 void setMetricUnits() {setUnits(Metric);}
109 void setImperialUnits() {setUnits(Imperial);}
110 void setNauticalUnits() {setUnits(Nautical);}
111 void setDistanceGraph() {setGraphType(Distance);}
112 void setTimeGraph() {setGraphType(Time);}
113 void setDecimalDegrees() {setCoordinatesFormat(DecimalDegrees);}
114 void setDegreesMinutes() {setCoordinatesFormat(DegreesMinutes);}
115 void setDMS() {setCoordinatesFormat(DMS);}
117 void screenChanged(QScreen *screen);
118 void logicalDotsPerInchChanged(qreal dpi);
120 void mapLoaded();
121 void mapLoadedDir();
122 void mapInitialized();
124 void demLoaded();
126 private:
127 typedef QPair<QDateTime, QDateTime> DateTimeRange;
129 void closeFiles();
130 void plot(QPrinter *printer);
131 void plotMainPage(QPainter *painter, const QRectF &rect, qreal ratio,
132 bool expand = false);
133 void plotGraphsPage(QPainter *painter, const QRectF &rect, qreal ratio);
134 qreal graphPlotHeight(const QRectF &rect, qreal ratio);
136 TreeNode<POIAction*> createPOIActionsNode(const TreeNode<QString> &node);
137 TreeNode<MapAction*> createMapActionsNode(const TreeNode<Map*> &node);
138 void createMapNodeMenu(const TreeNode<MapAction*> &node, QMenu *menu,
139 QAction *action = 0);
140 void createPOINodeMenu(const TreeNode<POIAction*> &node, QMenu *menu,
141 QAction *action = 0);
142 void createActions();
143 void createMenus();
144 #ifdef Q_OS_ANDROID
145 void createNavigation();
146 #else // Q_OS_ANDROID
147 void createToolBars();
148 #endif // Q_OS_ANDROID
149 void createStatusBar();
150 void createMapView();
151 void createGraphTabs();
152 void createBrowser();
154 #ifndef Q_OS_ANDROID
155 void openDir(const QString &path, int &showError);
156 #endif // Q_OS_ANDROID
157 bool openPOIFile(const QString &fileName);
158 bool loadFile(const QString &fileName, bool tryUnknown, int &showError);
159 void loadData(const Data &data);
160 bool loadMapNode(const TreeNode<Map*> &node, MapAction *&action,
161 const QList<QAction*> &existingActions, int &showError);
162 void loadMapDirNode(const TreeNode<Map*> &node, QList<MapAction*> &actions,
163 QMenu *menu, const QList<QAction*> &existingActions, int &showError);
164 void updateStatusBarInfo();
165 void updateWindowTitle();
166 bool updateGraphTabs();
167 void updateDEMDownloadAction();
168 #ifndef Q_OS_ANDROID
169 void updateRecentFiles(const QString &fileName);
170 #endif // Q_OS_ANDROID
172 TimeType timeType() const;
173 Units units() const;
174 void setTimeType(TimeType type);
175 void setUnits(Units units);
176 void setCoordinatesFormat(CoordinatesFormat format);
177 void setGraphType(GraphType type);
179 qreal distance() const;
180 qreal time() const;
181 qreal movingTime() const;
182 QAction *mapAction(const QString &name);
183 QGeoPositionInfoSource *positionSource(const Options &options);
184 void readSettings(QString &activeMap, QStringList &disabledPOIs,
185 QStringList &recentFiles);
187 void loadInitialMaps(const QString &selected);
188 void loadInitialPOIs(const QStringList &disabled);
189 #ifndef Q_OS_ANDROID
190 void loadRecentFiles(const QStringList &files);
191 #endif // Q_OS_ANDROID
193 void loadOptions();
194 void updateOptions(const Options &options);
196 #ifndef Q_OS_ANDROID
197 void keyPressEvent(QKeyEvent *event);
198 #endif // Q_OS_ANDROID
199 void closeEvent(QCloseEvent *event);
200 void dragEnterEvent(QDragEnterEvent *event);
201 void dropEvent(QDropEvent *event);
203 #ifdef Q_OS_ANDROID
204 NavigationWidget *_navigation;
205 #else // Q_OS_ANDROID
206 QToolBar *_fileToolBar;
207 QToolBar *_showToolBar;
208 QToolBar *_navigationToolBar;
209 #endif // Q_OS_ANDROID
210 QMenu *_poiMenu;
211 QMenu *_mapMenu;
212 #ifndef Q_OS_ANDROID
213 QMenu *_recentFilesMenu;
214 #endif // Q_OS_ANDROID
216 QActionGroup *_fileActionGroup;
217 QActionGroup *_navigationActionGroup;
218 QActionGroup *_mapsActionGroup;
219 QActionGroup *_poisActionGroup;
220 #ifndef Q_OS_ANDROID
221 QActionGroup *_recentFilesActionGroup;
222 #endif // Q_OS_ANDROID
223 #if !defined(Q_OS_MAC) && !defined(Q_OS_ANDROID)
224 QAction *_exitAction;
225 #endif // Q_OS_MAC + Q_OS_ANDROID
226 QAction *_pathsAction;
227 QAction *_aboutAction;
228 QAction *_printFileAction;
229 QAction *_exportPDFFileAction;
230 QAction *_exportPNGFileAction;
231 QAction *_openFileAction;
232 QAction *_openDirAction;
233 QAction *_closeFileAction;
234 QAction *_reloadFileAction;
235 QAction *_statisticsAction;
236 QAction *_openPOIAction;
237 QAction *_selectAllPOIAction;
238 QAction *_unselectAllPOIAction;
239 QAction *_showPOIAction;
240 QAction *_overlapPOIAction;
241 QAction *_showPOILabelsAction;
242 QAction *_showPOIIconsAction;
243 QAction *_showMapAction;
244 QAction *_showPositionAction;
245 QAction *_followPositionAction;
246 QAction *_showPositionCoordinatesAction;
247 QAction *_showMotionInfoAction;
248 QAction *_loadMapAction;
249 QAction *_loadMapDirAction;
250 QAction *_clearMapCacheAction;
251 QAction *_showGraphsAction;
252 QAction *_showGraphGridAction;
253 QAction *_showGraphSliderInfoAction;
254 QAction *_distanceGraphAction;
255 QAction *_timeGraphAction;
256 #ifdef Q_OS_ANDROID
257 QAction *_showGraphTabsAction;
258 #else // Q_OS_ANDROID
259 QAction *_keysAction;
260 QAction *_fullscreenAction;
261 QAction *_showToolbarsAction;
262 QAction *_nextAction;
263 QAction *_prevAction;
264 QAction *_lastAction;
265 QAction *_firstAction;
266 #endif // Q_OS_ANDROID
267 QAction *_metricUnitsAction;
268 QAction *_imperialUnitsAction;
269 QAction *_nauticalUnitsAction;
270 QAction *_decimalDegreesAction;
271 QAction *_degreesMinutesAction;
272 QAction *_dmsAction;
273 QAction *_totalTimeAction;
274 QAction *_movingTimeAction;
275 QAction *_nextMapAction;
276 QAction *_prevMapAction;
277 QAction *_showTracksAction;
278 QAction *_showRoutesAction;
279 QAction *_showWaypointsAction;
280 QAction *_showWaypointLabelsAction;
281 QAction *_showWaypointIconsAction;
282 QAction *_showAreasAction;
283 QAction *_showRouteWaypointsAction;
284 QAction *_hideMarkersAction;
285 QAction *_showMarkersAction;
286 QAction *_showMarkerDateAction;
287 QAction *_showMarkerCoordinatesAction;
288 QAction *_showTicksAction;
289 QAction *_useStylesAction;
290 QAction *_showCoordinatesAction;
291 QAction *_openOptionsAction;
292 QAction *_downloadDEMAction;
293 QAction *_showDEMTilesAction;
294 QAction *_mapsEnd;
295 QAction *_poisEnd;
296 #ifndef Q_OS_ANDROID
297 QAction *_clearRecentFilesAction;
298 QAction *_recentFilesEnd;
299 #endif // Q_OS_ANDROID
301 QLabel *_fileNameLabel;
302 QLabel *_distanceLabel;
303 QLabel *_timeLabel;
305 QSplitter *_splitter;
306 MapView *_mapView;
307 QTabWidget *_graphTabWidget;
308 QList<GraphTab*> _tabs;
309 GraphTab *_lastTab;
311 POI *_poi;
312 Map *_map;
313 QGeoPositionInfoSource *_positionSource;
314 DEMLoader *_dem;
316 FileBrowser *_browser;
317 QList<QString> _files;
319 int _trackCount, _routeCount, _areaCount, _waypointCount;
320 qreal _trackDistance, _routeDistance;
321 qreal _time, _movingTime;
322 DateTimeRange _dateRange;
323 QString _pathName;
325 #ifndef Q_OS_ANDROID
326 QList<QByteArray> _windowStates;
327 QList<QByteArray> _windowGeometries;
328 int _frameStyle;
329 #endif // Q_OS_ANDROID
331 PDFExport _pdfExport;
332 PNGExport _pngExport;
333 Options _options;
335 QString _dataDir, _mapDir, _poiDir;
337 Units _units;
339 QList<RectC> _demRects;
342 #endif // GUI_H