[PC-BSD Commits] r16416 - pcbsd/current/src-qt4/pc-netmanager/src/wificonfig

svn at pcbsd.org svn at pcbsd.org
Sun Apr 15 10:17:23 PDT 2012


Author: kenmoore
Date: 2012-04-15 17:17:23 +0000 (Sun, 15 Apr 2012)
New Revision: 16416

Modified:
   pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp
   pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wifiscanssid.cpp
Log:
Fix the wifi scan functions to only display an SSID once, just in case there are multiple routers with the same SSID.



Modified: pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp	2012-04-15 17:11:41 UTC (rev 16415)
+++ pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp	2012-04-15 17:17:23 UTC (rev 16416)
@@ -329,9 +329,32 @@
       }else{
 	FileLoad = ":object-locked.png";
       }
-      //Add the wifi access point to the list
-      listNewWifi->addItem(new QListWidgetItem(QIcon(FileLoad), ssid + " (signal: " +strength + ")") );
-      foundItem = 1; //set the flag for wifi signals found  
+      // qDebug()<<"Checking for duplicate SSID's";
+      bool duplicateSSID = FALSE;
+      int dupRow;
+      for ( int z = 0 ; z < listNewWifi->count() ; z++){
+        //qDebug() << listNewWifi->item(z)->text() << ssid;
+	if ( listNewWifi->item(z)->text().contains(ssid+" (") ){
+          dupRow = z;
+          duplicateSSID = TRUE;
+          break;
+	}
+      }
+      if( !duplicateSSID ){
+        //Add the wifi access point to the list
+        listNewWifi->addItem(new QListWidgetItem(QIcon(FileLoad), ssid + " (signal: " +strength + ")") );
+        foundItem = 1; //set the flag for wifi signals found 
+      }else{
+        //Check if the new signal strength is greater, replace if it is
+        QString oldStrength = listNewWifi->item(dupRow)->text();
+        oldStrength = oldStrength.section("(signal:",1,1).section("%)",0,0).simplified();
+        if( strength.section("%",0,0).toInt() > oldStrength.toInt() ){
+          //New signal strength is greater - replace the string
+          qDebug() << "Changing signal strength for "+ssid+" to reflect a stronger signal found";
+          //qDebug() << strength << oldStrength;
+          listNewWifi->item(dupRow)->setText( ssid+" (signal: "+strength+")" );
+	}
+      } 
     }
     
     if ( foundItem == 1 ){

Modified: pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wifiscanssid.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wifiscanssid.cpp	2012-04-15 17:11:41 UTC (rev 16415)
+++ pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wifiscanssid.cpp	2012-04-15 17:17:23 UTC (rev 16416)
@@ -4,6 +4,7 @@
 #include <qtimer.h>
 #include <pcbsd-utils.h>
 #include <pcbsd-netif.h>
+#include <QDebug>
 
 
 void wifiscanssid::init(QString device)
@@ -40,22 +41,36 @@
       strength = ifline[4];
       //determine the icon based on the signal strength
       tmp = strength.section("%",0,0,QString::SectionSkipEmpty); //remove the % from the end
-      newStrength = tmp.toInt(); //integer strength value      
-      if ( newStrength < 25 ){	
-	FileLoad= PROGPATH + "/pics/tray_wifi.png";
-      } else if ( newStrength < 50 ) {
-	FileLoad= PROGPATH + "/pics/tray_wifi30.png";
-      }  else if ( newStrength < 75 ) {
-	FileLoad= PROGPATH + "/pics/tray_wifi60.png";
-      } else {
-	FileLoad= PROGPATH + "/pics/tray_wifi85.png";
+      newStrength = tmp.toInt(); //integer strength value 
+      bool duplicateSSID = FALSE;
+      for ( int z = 0 ; z < listWifi->count() ; z++){
+        qDebug() << listWifi->item(z)->text() << ssid;
+	if ( listWifi->item(z)->text().contains(ssid+" (") ){
+          duplicateSSID = TRUE;
+          break;
+	}
       }
-      QImage *Icon = new QImage(FileLoad);
-      QPixmap PixmapIcon;
-      PixmapIcon.fromImage(Icon->scaled(22,22));
-      //Add the wifi access point to the list
-      listWifi->addItem(new QListWidgetItem(PixmapIcon, ssid + " (signal strength: " +strength + ")") );
-      foundItem = 1; //set the flag for wifi signals found  
+
+      if( !duplicateSSID ){
+        if ( newStrength < 25 ){	
+	  FileLoad= PROGPATH + "/pics/tray_wifi.png";
+        } else if ( newStrength < 50 ) {
+	  FileLoad= PROGPATH + "/pics/tray_wifi30.png";
+        }  else if ( newStrength < 75 ) {
+	  FileLoad= PROGPATH + "/pics/tray_wifi60.png";
+        } else {
+  	  FileLoad= PROGPATH + "/pics/tray_wifi85.png";
+        }
+        QImage *Icon = new QImage(FileLoad);
+        QPixmap PixmapIcon;
+        PixmapIcon.fromImage(Icon->scaled(22,22));
+        //Add the wifi access point to the list
+        listWifi->addItem(new QListWidgetItem(PixmapIcon, ssid + " (signal strength: " +strength + ")") );
+        foundItem = 1; //set the flag for wifi signals found 
+      }else{
+        //if the new signal is stronger, change the current label to reflect it
+
+      } 
     }
     
     if ( foundItem == 1 ){



More information about the Commits mailing list