1 #ifndef MAPVIEW_HH 2 #define MAPVIEW_HH 3 4 #include <QWebView> 5 #include <QTimer> 6 #include "receiver.hh" 7 8 9 /** A trivial bridge to the JS environment, exposing two signals to update the map view. */ 10 class MapViewJSBridge: public QObject 11 { 12 Q_OBJECT 13 14 public: 15 /** Constructor. */ 16 explicit MapViewJSBridge(QObject *parent=0); 17 18 /** Emmits the setQTH signal. */ 19 void emitSetQTH(double lon, double lat); 20 /** Emmits the addConnection signal. */ 21 void emitAddConnection(const QString &callsign, double lon, double lat, double snr); 22 23 signals: 24 void setQTH(double lon, double lat); 25 void addConnection(QString callsign, double lon, double lat, double snr); 26 }; 27 28 29 /** A simple MapView using Google Maps displaying the locations of the received spots. */ 30 class MapView : public QWebView 31 { 32 Q_OBJECT 33 34 public: 35 /** Constructs a map view. */ 36 explicit MapView(Receiver &rx, QWidget *parent = 0); 37 38 signals: 39 /** Gets emitted once the map was loaded completely. */ 40 void mapReady(); 41 42 public slots: 43 /** Centers the map at the given location. */ 44 void setQTH(double lon, double lat); 45 /** Adds a connection (transmitter) to the map. */ 46 void addConnection(const QString &callsign, const QString &loc, double snr); 47 48 protected slots: 49 /** Gets called, once the map is loaded. */ 50 void onLoadFinished(bool success); 51 /** Gets called, once some new spots are added to Receiver.messages(). */ 52 void onMessagesReceived(QModelIndex parent, int from, int to); 53 54 protected: 55 Receiver &_rx; 56 /** The bridge to the JS environment of the MapView. */ 57 MapViewJSBridge _bridge; 58 }; 59 60 #endif // MAPVIEW_HH 61