123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #ifndef MAINWINDOW_H
- #define MAINWINDOW_H
- #include <QMainWindow>
- #include <qmobilityglobal.h>
- #include <qgeopositioninfosource.h>
- #include <qgeosatelliteinfosource.h>
- #include <qnmeapositioninfosource.h>
- #include <qgeopositioninfo.h>
- #include <qnetworkconfigmanager.h>
- #include <qnetworksession.h>
- #include <QGeoPositionInfoSource>
- using namespace QtMobility;
- class QNetworkReply;
- namespace Ui {
- class MainWindow;
- }
- class Station : public QObject {
- Q_OBJECT
- Q_PROPERTY(double latitude READ latitude)
- Q_PROPERTY(double longitude READ longitude)
- Q_PROPERTY(QString name READ name)
- Q_PROPERTY(int slotCount READ slotCount)
- Q_PROPERTY(int bikeCount READ bikeCount)
- public:
- Station(const QString& name, double longitude, double latitude, int slotCount, int bikeCount, QObject* parent = 0) : QObject(parent),
- m_name(name),
- m_latitude(latitude),
- m_longitude(longitude),
- m_slotCount(slotCount),
- m_bikeCount(bikeCount)
- {}
- Station() :
- m_name(""),
- m_latitude(0.0),
- m_longitude(0.0),
- m_slotCount(0),
- m_bikeCount(0)
- {}
- double latitude() const {return m_latitude;}
- double longitude() const {return m_longitude;}
- QString name() const {return m_name;}
- int slotCount() const {return m_slotCount;}
- int bikeCount() const {return m_bikeCount;}
- private:
- QString m_name;
- double m_latitude;
- double m_longitude;
- int m_slotCount;
- int m_bikeCount;
- };
- //Q_DECLARE_METATYPE(Station)
- Q_DECLARE_METATYPE(QObjectList)
- //qRegisterMetaType("QObjectList");
- class MainWindow : public QMainWindow
- {
- Q_OBJECT
- //Q_PROPERTY( QList<Station> m_stations READ stations )
- //Q_PROPERTY(QVariantList stations READ stations)
- Q_PROPERTY(QObjectList stations READ stations)
- public:
- explicit MainWindow(QWidget *parent = 0);
- ~MainWindow();
- QObjectList stations() const;
- private:
- Ui::MainWindow *ui;
- double m_latitude;
- double m_longitude;
- bool once;
- int m_currentZoom;
- void grabZoomKeys(bool grab);
- QList<Station*> m_stations;
- public slots:
- void debug(const QString& value);
- protected:
- void keyPressEvent(QKeyEvent* event);
- private slots:
- void dataReceived(QNetworkReply* reply);
- void loadFinished(bool ok);
- void positionUpdated(const QGeoPositionInfo &info);
- void injectJavascriptIntoWindowObject();
- signals:
- void displayUser(double, double);
- void addStations(QObjectList stations);
- };
- #endif // MAINWINDOW_H
|