89307071709b9e4cb91690f63019f37740500994
[gpsdata] / src / mainwindow.h
1 /*
2  *  GPSData for Maemo.
3  *  Copyright (C) 2011 Roman Moravcik
4  *
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.
9  *
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
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #ifndef MAINWINDOW_H
21 #define MAINWINDOW_H
22
23 #include <QMainWindow>
24 #include <QWidget>
25 #include <QDialog>
26 #include <QLabel>
27
28 #include <QGeoPositionInfo>
29 #include <QGeoPositionInfoSource>
30 #include <QGeoSatelliteInfo>
31 #include <QGeoSatelliteInfoSource>
32
33 #ifdef Q_WS_MAEMO_5
34 #include "satellitesignalstrength.h"
35 #endif
36
37 QTM_USE_NAMESPACE
38
39 class MainWindow : public QMainWindow
40 {
41     Q_OBJECT
42
43 public:
44     enum CoordinateType
45     {
46         LatitudeCoordinate = 0,
47         LongitudeCoordinate = 1
48     };
49
50     MainWindow(QWidget *parent = 0);
51     ~MainWindow();
52
53 signals:
54     void screenLocked(bool locked);
55
56 private slots:
57     void onPositionUpdated(const QGeoPositionInfo &position);
58
59     void onSatellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
60     void onSatellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
61
62 #ifdef Q_OS_SYMBIAN
63     void onSatelliteSignalStrengthMenuClicked();
64 #endif
65     void onSatelliteViewMenuClicked();
66     void onGpsCompassMenuClicked();
67
68 #ifdef Q_WS_MAEMO_5
69     void onScreenLocked(QString state);
70 #endif
71
72 private:
73     void createUi();
74     void updateUi();
75
76     void createMenu();
77
78 #ifdef Q_WS_MAEMO_5
79     void registerScreenLockMonitor();
80 #endif
81
82     QString convertCoordinate(double speed, CoordinateType type) const;
83     QString convertSpeed(double speed) const;
84     QString formatLength(double length) const;
85     QString formatDirection(double length) const;
86
87 private:
88     QGeoPositionInfoSource *m_position;
89     QGeoSatelliteInfoSource *m_satellite;
90
91     QGeoPositionInfo m_positionInfo;
92     int m_satellitesInView;
93     int m_satellitesInUse;
94
95     QLabel *m_latitude;
96     QLabel *m_longitude;
97     QLabel *m_accuracy;
98     QLabel *m_altitude;
99     QLabel *m_altitudeAccuracy;
100     QLabel *m_direction;
101     QLabel *m_magneticDeclination;
102     QLabel *m_groundSpeed;
103     QLabel *m_verticalSpeed;
104     QLabel *m_mode;
105     QLabel *m_time;
106     QLabel *m_satUsedView;
107
108 #ifdef Q_WS_MAEMO_5
109     SatelliteSignalStrength *m_satelliteSignalStrength;
110
111     bool m_screenLocked;
112 #endif
113 };
114
115 #endif // MAINWINDOW_H