Index: sources/device/DeviceView.h =================================================================== diff -u -r6e18f1d24b8cc3d84d26f46f36f73deb34e54371 -rabb959f145f8af64bab3b8f24314bf0ba8f3bb0e --- sources/device/DeviceView.h (.../DeviceView.h) (revision 6e18f1d24b8cc3d84d26f46f36f73deb34e54371) +++ sources/device/DeviceView.h (.../DeviceView.h) (revision abb959f145f8af64bab3b8f24314bf0ba8f3bb0e) @@ -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) @@ -130,8 +92,10 @@ READONLY ( QString , subnetMask , "" ) READONLY ( QString , dns , "" ) - VIEW_DEC_CLASS_EX(VDevice, QAbstractListModel) + Q_PROPERTY(MListModel* model READ model NOTIFY didModelChange ) + 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 +109,17 @@ void parseWifiListResult(const QString &vResult); void parseWifiInfoResult(const QString &vResult); void updateWifiList(); + MListModel* model () { 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 didModelChange(); }; }