Index: sources/device/DeviceView.cpp =================================================================== diff -u -r0932b2beee9cc169291cbf69161f902f805237b1 -r574c7c5fb48b1fcb72337f5fb4c0119a20288815 --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 0932b2beee9cc169291cbf69161f902f805237b1) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 574c7c5fb48b1fcb72337f5fb4c0119a20288815) @@ -24,7 +24,7 @@ #include "encryption.h" #include "MWifiNetwork.h" -VIEW_DEF_CLASS(VDevice) +VIEW_DEF_CLASS_EX(VDevice, QAbstractListModel) void VDevice::initConnections() { @@ -283,13 +283,13 @@ /// which is when we have the mComp;eted as true. static QString result; // DEBUG : - qDebug() << __FUNCTION__ << vData.mMessage << result << vData.mCompleted; + qDebug() << " 2 ---------- " << __FUNCTION__ << vData.mMessage << result << vData.mCompleted; if ( vData.mCompleted ) { if ( vData.mAccepted ) { - wifiList({ "SSID1" , "SSID2" }); + // wifiList(); status(""); wifiListEnabled(true); // TODO - parseWifiListResult(result); + parseWifiListResult(vData.mWifiList/*result*/); status(vData.mMessage); } else { @@ -313,7 +313,7 @@ * \param vResult - (QString) output collected from QProcess execution * \return List of the Found SSIDs in a model. */ -QVariantList VDevice::parseWifiListResult(const QString &vResult) +QVariantList View::VDevice::parseWifiListResult(const QString &vResult) { enum SSIDInfo_Enum { eSSID , @@ -358,6 +358,8 @@ }; QString mResult = vResult; + qDebug() << " ---------- "; + qDebug() << mResult; SSIDInfo data; QHash mSSIDInfoList; @@ -375,6 +377,7 @@ QStringList lines = mResult.split('\n'); for ( int row = 0; row < lines.count(); row++ ) { QStringList fields = lines[row].split(','); + qDebug() << fields.join("-"); if ( fields[eSSID].trimmed().isEmpty() ) continue; // hidden networks, or an incorrect entry QString mWPA_FLAGS; @@ -446,6 +449,55 @@ break; } } + DataModel dataModel; + dataModel.mWifiSSID = mSSID; + qDebug() << mSSID; + addData(dataModel); } + + // qDebug() << _wifiList; return {}; } + +void View::VDevice::addData(const DataModel &vDataModel) { + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + _dataList << vDataModel; + endInsertRows(); +} + +int View::VDevice::rowCount(const QModelIndex &) const +{ + return _wifiList.count(); +} + +QVariant View::VDevice::data(const QModelIndex &vIndex, int vRole) const +{ + if (vIndex.row() < 0 || vIndex.row() >= _dataList.count()) + return QVariant(); + + const DataModel &dataList = _dataList[vIndex.row()]; + + switch (vRole) { + case eRole_WifiMacAddress : return dataList.mWifiMacAddress ; break; + case eRole_WifiSsid : return dataList.mWifiSSID ; break; + case eRole_WifiSecurityTypes : return dataList.mWifiSecurityTypes ; break; + case eRole_WifiSignalLevel : return dataList.mWifiSignalLevel ; break; + case eRole_WifiSupported : return dataList.mWifiSupported ; break; + case eRole_WifiConnected : return dataList.mWifiConnected ; break; + default: break; + } + + + return QString("Wifi %1").arg(vIndex.row()); +} + +QHash View::VDevice::roleNames() const { + QHash roles; + roles[eRole_WifiMacAddress ] = "wifiMacAddress" ; + roles[eRole_WifiSsid ] = "wifiSsid" ; + roles[eRole_WifiSecurityTypes ] = "wifiSecurityTypes" ; + roles[eRole_WifiSignalLevel ] = "wifiSignalLevel" ; + roles[eRole_WifiSupported ] = "wifiSupported" ; + roles[eRole_WifiConnected ] = "wifiConnected" ; + return roles; +}