appmodel.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #ifndef APPMODEL_H
  2. #define APPMODEL_H
  3. #include "../common/comm.h"
  4. #include "ImageProvider.h"
  5. #include <QObject>
  6. #include <QtCore/QObject>
  7. #include <QtCore/QString>
  8. #include <QtGui>
  9. #include <QtQml/qqml.h>
  10. class CarData : public QObject {
  11. Q_OBJECT
  12. Q_PROPERTY(int32_t uid READ uid WRITE setUid NOTIFY dataChanged)
  13. Q_PROPERTY(QString name READ name WRITE setName NOTIFY dataChanged)
  14. Q_PROPERTY(QString type READ type WRITE setType NOTIFY dataChanged)
  15. Q_PROPERTY(QString state READ state WRITE setState NOTIFY dataChanged)
  16. public:
  17. explicit CarData(QObject *parent = 0);
  18. CarData(const CarData &other);
  19. int32_t uid() const;
  20. QString name() const;
  21. QString type() const;
  22. QString state() const;
  23. int32_t carType() const;
  24. void setUid(const int32_t &value);
  25. void setName(const QString &value);
  26. void setType(const QString &value);
  27. void setState(const QString &value);
  28. void setCarType(const int32_t& value);
  29. signals:
  30. void dataChanged();
  31. private:
  32. int32_t m_uid;
  33. int32_t m_carType;
  34. QString m_name;
  35. QString m_type;
  36. QString m_state;
  37. };
  38. Q_DECLARE_METATYPE(CarData)
  39. class AppModelPrivate;
  40. class CFishEyeWindow;
  41. class AppModel : public QObject {
  42. Q_OBJECT
  43. Q_PROPERTY(bool ready READ ready WRITE setReady NOTIFY readyChanged)
  44. Q_PROPERTY(QQmlListProperty<CarData> car READ car NOTIFY carChanged)
  45. // Q_PROPERTY(int32_t Gear READ Gear WRITE SetGear NOTIFY gearChanged)
  46. Q_PROPERTY(QString Account READ Account WRITE setAccount NOTIFY accountChanged)
  47. Q_PROPERTY(QString Password READ Password WRITE setPassword NOTIFY passwordChanged)
  48. Q_PROPERTY(QString CarName READ CarName WRITE setCarName NOTIFY carNameChanged)
  49. Q_PROPERTY(QString DriveName READ DriveName WRITE setDriveName NOTIFY driveNameChanged)
  50. public:
  51. explicit AppModel(IMonitroNotify *n , IRemoteCtrl *c , QObject* qmlObj, QObject *parent = 0);
  52. ~AppModel();
  53. Q_INVOKABLE void userLogin(QString useName, QString password);
  54. Q_INVOKABLE void connectCar(int id);
  55. Q_INVOKABLE void leaveCar();
  56. Q_INVOKABLE void logout();
  57. // Q_INVOKABLE void switchDriver();
  58. //Q_INVOKABLE void areaChanged(int32_t area);
  59. Q_INVOKABLE void controlCar(int id);
  60. Q_INVOKABLE bool idle(int32_t uid);
  61. //Q_INVOKABLE void showTrackDlg();
  62. // Q_INVOKABLE void track();
  63. //Q_INVOKABLE void unTrack();
  64. //Q_INVOKABLE bool autoClose();
  65. //Q_INVOKABLE QString ReadyText();
  66. //int radar6() const;
  67. //int radar7() const;
  68. QString Account() const;
  69. QString Password() const;
  70. QString CarName() const;
  71. QString DriveName() const;
  72. bool ready() const;
  73. void SetVisible(const bool value);
  74. //void SetGear(const int32_t value);
  75. void SetCold(const int32_t value);
  76. void setReady(const bool value);
  77. //void setRadar6(const int32_t& value);
  78. //void setRadar7(const int32_t& value);
  79. void setAccount(const QString& value);
  80. void setPassword(const QString& password);
  81. void setCarName(const QString& carname);
  82. void setDriveName(const QString& drivename);
  83. //void setModelX(const int32_t value);
  84. //void setModelY(const int32_t value);
  85. //void setModelZ(const int32_t value);
  86. //void setRadar6(const int32_t &value);
  87. QQmlListProperty<CarData> car() const;
  88. public slots:
  89. void onLoginRst(bool rst);
  90. void onCarAppend(const UserDriver&info);
  91. void onNotifyState(int32_t uid, UserState state);
  92. void onNotifyDel(int32_t peer);
  93. void onKickoff();
  94. void onNotifyLeave(int32_t peer);
  95. void onNotifyFail(int32_t peer);
  96. void OnClose();
  97. //void OnPosition(float x, float y, float z);
  98. signals:
  99. void readyChanged();
  100. //void radar6Changed();
  101. //void radar7Changed();
  102. void accountChanged();
  103. void passwordChanged();
  104. void carNameChanged();
  105. void driveNameChanged();
  106. void sectionTextChanged();
  107. void gearChanged();
  108. void playAlertSound();
  109. void carConnected();
  110. void closeWin();
  111. void carChanged();
  112. private:
  113. IMonitroNotify *_notify;
  114. IRemoteCtrl *_control;
  115. // std::unique_ptr<CFishEyeWindow> _window;
  116. AppModelPrivate *d;
  117. std::vector<UserDriver> _users;
  118. QString m_account;
  119. QString m_password;
  120. QString m_carName;
  121. QString m_driveName;
  122. bool m_visible = true;
  123. //int32_t m_gear =0;
  124. //WorkArea m_area= WorkArea::Area_A;
  125. // int32_t m_no;
  126. bool m_ready;
  127. QObject* m_qmlObj = nullptr;
  128. int32_t m_peer = -1;
  129. };
  130. #endif // APPMODEL_H