diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ae27afa3..1c803ca1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1716,9 +1716,8 @@ void MainWindow::getWifiListDone(QStringList slist) // getFinalWifiList(slist); } } - if (current_wifi_list_state == RECONNECT_WIFI) { - QList targetWifiStructList = connectableWifiPriorityList(slist); + QVector targetWifiStructList = connectableWifiPriorityList(slist); if (!targetWifiStructList.isEmpty()) { if (!isReconnectingWifi) { isReconnectingWifi = true; //保证对于连续发出的重连信号,只处理第一个 @@ -1787,6 +1786,66 @@ void MainWindow::getConnListDone(QStringList slist) return; } } +//QStringList MainWindow::priorityList(QStringList slist){ +// QStringList ret; +// ret.append(slist[0]); +// QString headLine = slist.at(0); +// int indexSignal,indexSecu, indexFreq, indexBSsid, indexName,indexPath,indexCate; +// headLine = headLine.trimmed(); +// bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+")); +// if (isChineseExist) { +// indexSignal = headLine.indexOf("SIGNAL"); +// indexSecu = headLine.indexOf("安全性"); +// indexFreq = headLine.indexOf("频率") + 4; +// indexBSsid = headLine.indexOf("BSSID") + 6; +// indexName = indexBSsid + 19; +// indexPath = headLine.indexOf("DBUS-PATH"); +// indexCate = headLine.indexOf("CATEGORY"); +// } else { +// indexSignal = headLine.indexOf("SIGNAL"); +// indexSecu = headLine.indexOf("SECURITY"); +// indexFreq = headLine.indexOf("FREQ"); +// indexBSsid = headLine.indexOf("BSSID"); +// indexName = indexBSsid + 19; +// indexPath = headLine.indexOf("DBUS-PATH"); +// indexCate = headLine.indexOf("CATEGORY"); +// } +// QStringList p1,p2,p3,p4,p5,p6,p7;//按照信号与频段划分为6个列表 +// for(int i=1;i 75 && conFreq >= 5000){ +// p1.append(line); +// continue; +// }else if(conSignal > 55 && conFreq >= 5000){ +// p2.append(line); +// continue; +// }else if(conSignal > 75){ +// p3.append(line); +// continue; +// }else if(conSignal > 55){ +// p4.append(line); +// continue; +// }else if(conSignal > 35){ +// p5.append(line); +// continue; +// }else if(conSignal > 15){ +// p6.append(line); +// continue; +// }else{ +// p7.append(line); +// } +// } +// QVector listVec; +// listVec< 55 && conCate == 2){ + p1.append(line); + continue; + }else if(conSignal > 55 && conCate == 1){ + p2.append(line); + continue; + }else{ + p3.append(line); + continue; + } + } + QVector listVec; + listVec< 75 && conFreq >= 5000){ p1.append(line); continue; @@ -1838,14 +1927,10 @@ QStringList MainWindow::priorityList(QStringList slist){ p7.append(line); } } - QVector listVec; - listVec< MainWindow::repetitionFilter(QVector){ QVector ret; return ret; @@ -1999,8 +2084,8 @@ void MainWindow::getFinalWifiList(QStringList &slist) } //从有配置文件的wifi选出最优wifi进行连接,同时考虑用户手动设置的优先级,这个函数在回连中用到 -QList MainWindow::connectableWifiPriorityList(const QStringList slist){ - QList selectedWifiListStruct; +QVector MainWindow::connectableWifiPriorityList(const QStringList slist){ + QVector selectedWifiListStruct; if(slist.size()<2) return selectedWifiListStruct; OneConnForm *ocf = new OneConnForm(); QString headLine = slist.at(0); @@ -2063,6 +2148,7 @@ QList MainWindow::connectableWifiPriorityList(const QStringL myWifiProStruct.bssid = wifibssid; myWifiProStruct.priority = wifiPriority.toInt(); selectedWifiListStruct.append(myWifiProStruct); + qDebug()<"<"<"< MainWindow::connectableWifiPriorityList(const QStringL } //排序 -void MainWindow::devListSort(QList *list) +void MainWindow::devListSort(QVector *list) { - qSort(list->begin(), list->end(), subDevListSort); +// qSort(list->begin(), list->end(), subDevListSort); + std::sort(list->begin(), list->end(), subDevListSort); } bool MainWindow::subDevListSort(const structWifiProperty &info1, const structWifiProperty &info2) { - return info1.priority > info2.priority; + return info1.priority > info2.priority; } // 加载wifi列表 diff --git a/src/mainwindow.h b/src/mainwindow.h index e8a556df..dccdee1a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -319,9 +319,10 @@ private: QVector repetitionFilter(QVector); QStringList priorityList(QStringList); QStringList sortApByCategory(QStringList,int); + QStringList sortApByFreq(QStringList,int, int); void getFinalWifiList(QStringList& slist); //获取应该显示在wifi列表中的最优列表参数 - QList connectableWifiPriorityList(const QStringList slist); //可连接wifi优先级列表 - void devListSort(QList *list); + QVector connectableWifiPriorityList(const QStringList slist); //可连接wifi优先级列表 + void devListSort(QVector *list); static bool subDevListSort(const structWifiProperty&info1,const structWifiProperty&info2); //循环检测网络连接状态 QTimer *iconTimer = nullptr;