mainwindow.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QMainWindow>
  4. #include <qmobilityglobal.h>
  5. #include <qgeopositioninfosource.h>
  6. #include <qgeosatelliteinfosource.h>
  7. #include <qnmeapositioninfosource.h>
  8. #include <qgeopositioninfo.h>
  9. #include <qnetworkconfigmanager.h>
  10. #include <qnetworksession.h>
  11. #include <QGeoPositionInfoSource>
  12. using namespace QtMobility;
  13. class QNetworkReply;
  14. namespace Ui {
  15. class MainWindow;
  16. }
  17. class Station : public QObject {
  18. Q_OBJECT
  19. Q_PROPERTY(double latitude READ latitude)
  20. Q_PROPERTY(double longitude READ longitude)
  21. Q_PROPERTY(QString name READ name)
  22. Q_PROPERTY(int slotCount READ slotCount)
  23. Q_PROPERTY(int bikeCount READ bikeCount)
  24. public:
  25. Station(const QString& name, double longitude, double latitude, int slotCount, int bikeCount, QObject* parent = 0) : QObject(parent),
  26. m_name(name),
  27. m_latitude(latitude),
  28. m_longitude(longitude),
  29. m_slotCount(slotCount),
  30. m_bikeCount(bikeCount)
  31. {}
  32. Station() :
  33. m_name(""),
  34. m_latitude(0.0),
  35. m_longitude(0.0),
  36. m_slotCount(0),
  37. m_bikeCount(0)
  38. {}
  39. double latitude() const {return m_latitude;}
  40. double longitude() const {return m_longitude;}
  41. QString name() const {return m_name;}
  42. int slotCount() const {return m_slotCount;}
  43. int bikeCount() const {return m_bikeCount;}
  44. private:
  45. QString m_name;
  46. double m_latitude;
  47. double m_longitude;
  48. int m_slotCount;
  49. int m_bikeCount;
  50. };
  51. //Q_DECLARE_METATYPE(Station)
  52. Q_DECLARE_METATYPE(QObjectList)
  53. //qRegisterMetaType("QObjectList");
  54. class MainWindow : public QMainWindow
  55. {
  56. Q_OBJECT
  57. //Q_PROPERTY( QList<Station> m_stations READ stations )
  58. //Q_PROPERTY(QVariantList stations READ stations)
  59. Q_PROPERTY(QObjectList stations READ stations)
  60. public:
  61. explicit MainWindow(QWidget *parent = 0);
  62. ~MainWindow();
  63. QObjectList stations() const;
  64. private:
  65. Ui::MainWindow *ui;
  66. double m_latitude;
  67. double m_longitude;
  68. bool once;
  69. int m_currentZoom;
  70. void grabZoomKeys(bool grab);
  71. QList<Station*> m_stations;
  72. public slots:
  73. void debug(const QString& value);
  74. protected:
  75. void keyPressEvent(QKeyEvent* event);
  76. private slots:
  77. void dataReceived(QNetworkReply* reply);
  78. void loadFinished(bool ok);
  79. void positionUpdated(const QGeoPositionInfo &info);
  80. void injectJavascriptIntoWindowObject();
  81. signals:
  82. void displayUser(double, double);
  83. void addStations(QObjectList stations);
  84. };
  85. #endif // MAINWINDOW_H