Index: sources/device/DeviceView.h =================================================================== diff -u -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 -r3c547f89553d3aabe59423b82ecb7f8c28f9d32a --- sources/device/DeviceView.h (.../DeviceView.h) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) +++ sources/device/DeviceView.h (.../DeviceView.h) (revision 3c547f89553d3aabe59423b82ecb7f8c28f9d32a) @@ -16,6 +16,7 @@ // Qt #include +#include // Project #include "main.h" // Doxygen : do not remove @@ -33,39 +34,92 @@ * \details The device view to interact with the UI. * */ -class VDevice : public QObject { +class VDevice : public QAbstractListModel { + Q_OBJECT + enum DataRole { + eRole_Start = Qt::UserRole , + // ----- WiFi + eRole_WifiMacAddress , + eRole_WifiSsid , + eRole_WifiSecurityTypes , + eRole_WifiSignalLevel , + eRole_WifiSupported , + eRole_WifiConnected , + // ----- Bluetooth + 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 ; + // ----- 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 ( ); + +private: + TRIGGER ( bool , response , true) - PROPERTY ( bool , accepted , 0) - TRIGGER ( quint32 , reason , 0) PROPERTY ( QString , status , "") - PROPERTY ( QString , osVersion , "") + READONLY ( bool , accepted , 0) + TRIGGER ( quint32 , reason , 0) + READONLY ( QString , osVersion , "") + ATTRIBUTE ( quint8 , brightness , 0, Brightness ) ATTRIBUTE ( quint8 , bluetoothPairedReset, 0, BluetoothPairedReset ) ATTRIBUTE ( QStringList , bluetoothPairedQuery, {}, BluetoothPairedQuery ) ATTRIBUTE ( QString , cryptSetup , "", CryptSetup ) - PROPERTY ( bool , cryptSetupEnabled , true ) + READONLY ( bool , cryptSetupEnabled , true ) ATTRIBUTE ( Qt::CheckState, rootSSHAccess , Qt::Unchecked , RootSSHAccess ) ATTRIBUTE ( QString , factoryReset , "", FactoryReset ) - PROPERTY ( bool , factoryResetEnabled , true ) + READONLY ( bool , factoryResetEnabled , true ) ATTRIBUTE ( QString , decommission , "", Decommission ) - PROPERTY ( bool , decommissionEnabled , true ) + READONLY ( bool , decommissionEnabled , true ) - VIEW_DEC_CLASS(VDevice) + ATTRIBUTE ( QStringList , wifiList , {}, WifiList ) + READONLY ( bool , wifiListEnabled , true ) + VIEW_DEC_CLASS_EX(VDevice, QAbstractListModel) + private slots: void onPOSTOSVersionData (const QString &vOSVersion); private: + void parseWifiListResult(const QString &vResult); 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