Index: sources/device/DeviceView.h =================================================================== diff -u -r6e18f1d24b8cc3d84d26f46f36f73deb34e54371 -r0ec66896d0a55a98915dda17f2acf3ff290398a7 --- sources/device/DeviceView.h (.../DeviceView.h) (revision 6e18f1d24b8cc3d84d26f46f36f73deb34e54371) +++ sources/device/DeviceView.h (.../DeviceView.h) (revision 0ec66896d0a55a98915dda17f2acf3ff290398a7) @@ -23,6 +23,7 @@ #include "VView.h" #include "DeviceGlobals.h" #include "DeviceModels.h" +#include "MListModel.h" // define @@ -34,7 +35,7 @@ * \details The device view to interact with the UI. * */ -class VDevice : public QAbstractListModel { +class VDevice : public QObject { Q_OBJECT @@ -52,45 +53,6 @@ eRole_BLE_UNUSED , }; - QHash dataRoles { - // ----- WiFi - { eRole_WifiMacAddress , "wifiMacAddress" }, - { eRole_WifiSsid , "wifiSsid" }, - { eRole_WifiSecurityTypes , "wifiSecurityTypes" }, - { eRole_WifiSignalLevel , "wifiSignalLevel" }, - { eRole_WifiSupported , "wifiSupported" }, - { eRole_WifiConnected , "wifiConnected" }, - // ----- Bluetooth - }; - - struct DataModel { - // ----- WiFi - QString mWifiMacAddress ; - QString mWifiSSID ; - QString mWifiSecurityTypes ; - qint16 mWifiSignalLevel ; - bool mWifiSupported = false ; - bool mWifiConnected = false ; - QString mWifiIpAddress ; - QString mWifiGateway ; - QString mWifiSubnetMask ; - QString mWifiDns ; - - // ----- Bluetooth - QString mBle_Unused ; - }; - typedef QList TDataList; - TDataList _dataList; - - typedef QHash TDataRoles; - TDataRoles roleNames ( ) const override { return dataRoles; } - int rowCount (const QModelIndex & = QModelIndex() ) const override { return _dataList.count(); } - QVariant data (const QModelIndex &vIndex , int vRole = Qt::DisplayRole ) const override ; - void dataAppend (const DataModel &vData , bool vFirst , bool vSecond); - void dataClear ( ); - bool setData (const QModelIndex &vIndex, const QVariant& vValue, int vRole = Qt::EditRole) override; - QModelIndex index (int vRow, int vColumn, const QModelIndex &vParent = QModelIndex()) const override; - private: TRIGGER ( bool , response , true) @@ -123,15 +85,18 @@ ATTRIBUTE ( QStringList , wifiList , {}, WifiList ) ATTRIBUTE ( QStringList , wifiInfo , {}, WifiInfo ) ATTRIBUTE ( bool , wifiConnect , false, WifiConnect ) - READONLY ( bool , wifiListEnabled , true ) + READONLY ( bool , isWifiScanning , false ) READONLY ( QString , ssid , "" ) READONLY ( QString , ipAddress , "" ) READONLY ( QString , gateway , "" ) READONLY ( QString , subnetMask , "" ) READONLY ( QString , dns , "" ) + READONLY ( bool , wifiError , false ) - VIEW_DEC_CLASS_EX(VDevice, QAbstractListModel) + Q_PROPERTY(MListModel* wifiModel READ wifiModel NOTIFY didWifiModelChange ) + VIEW_DEC_CLASS(VDevice) + public slots: void doWifiConnect(bool vConnect, const QString &vSsid, const QString &vPassword); void doDateTime ( const QString &vYear, const QString &vMonth, const QString &vDay, @@ -145,12 +110,17 @@ void parseWifiListResult(const QString &vResult); void parseWifiInfoResult(const QString &vResult); void updateWifiList(); + MListModel* wifiModel () { return &_wifiModel; } + MListModel _wifiModel; bool isCompleteResponse(Model::MDeviceResponseBase::Data vData) { // Either the script exited successfully or the script failed and the reason is provided // There are situations that the script is using the attribute response to update the UI // but it is not the final/completed response return vData.mAccepted || (!vData.mAccepted && vData.mReason != 0 ); } + +signals: + void didWifiModelChange(); }; }