def loadNetworksTable(self): self.n, self.network = 0, to_unicode('') if self.num_networks: beginWaitCursor() try: if self.show_extended: for n in range(self.num_networks): bssid = self.networks['bssid-%d' % n] ss = self.networks['signalstrength-%d' % n] try: self.location_cache[bssid] except KeyError: location = wifi.getLocation(bssid, ss) lat = self.networks['latitude-%d' % n] = location.get('latitude', 'Unknown') lng = self.networks['longitude-%d' % n] = location.get('longitude', 'Unknown') address = self.networks['address-%d' % n] = location.get('address', 'Unknown') self.location_cache[bssid] = (lat, lng, address) else: self.networks['latitude-%d' % n], self.networks['longitude-%d' % n], self.networks['address-%d' % n] = \ self.location_cache[bssid] self.NetworksTableWidget.setSortingEnabled(False) self.NetworksTableWidget.setRowCount(self.num_networks) headers = [self.__tr('Network Name (SSID)'), self.__tr('Signal Strength'), self.__tr("Security"), self.__tr("Mode")] if self.show_extended: headers.extend([self.__tr('Channel'), self.__tr("Address (BSSID)"), self.__tr("Location"), self.__tr("Lat/Long")]) self.NetworksTableWidget.setColumnCount(len(headers)) self.NetworksTableWidget.setHorizontalHeaderLabels(headers) enabled_flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled for n in range(self.num_networks): name = self.networks['ssid-%d' % n] if name == '(unknown)': flags = None else: flags = enabled_flags ss = self.networks['signalstrength-%d' % n] sec = self.networks['encryptiontype-%d' % n] mode = self.networks['communicationmode-%d' % n] log.debug("%d: Name=%s, strength=%s, security=%s, mode=%s" % #, channel=%d bssid=%s" % (n, name, ss, sec, mode)) if self.show_extended: chn = self.networks['channel-%d' % n] dbm = self.networks['dbm-%d' % n] bssid = self.networks['bssid-%d' % n] address = self.networks['address-%d' % n] lat = self.networks['latitude-%d' % n] lng = self.networks['longitude-%d' % n] log.debug("%d: channel=%d bssid=%s dbm=%s lat=%s long=%s address=%s" % (n, chn, bssid, dbm, lat, lng, address)) i = QTableWidgetItem(str(name)) if flags is not None: i.setFlags(flags) i.setData(Qt.UserRole, n) self.NetworksTableWidget.setItem(n, 0, i) pixmap = load_pixmap('signal%d' % ss, 'other') if self.show_extended: i = QTableWidgetItem(QIcon(pixmap), self.__tr("%s/5 (%s dBm)" %(ss, dbm))) else: i = QTableWidgetItem(QIcon(pixmap), self.__tr("%s/5" % ss)) if flags is not None: i.setFlags(flags) self.NetworksTableWidget.setItem(n, 1, i) i = QTableWidgetItem(str(sec)) if flags is not None: i.setFlags(flags) self.NetworksTableWidget.setItem(n, 2, i) i = QTableWidgetItem(str(mode)) if flags is not None: i.setFlags(flags) self.NetworksTableWidget.setItem(n, 3, i) if self.show_extended: i = QTableWidgetItem(str(str(chn))) if flags is not None: i.setFlags(flags) self.NetworksTableWidget.setItem(n, 4, i) i = QTableWidgetItem(str(bssid)) if flags is not None: i.setFlags(flags) self.NetworksTableWidget.setItem(n, 5, i) i = QTableWidgetItem(str(address)) if flags is not None: i.setFlags(flags) self.NetworksTableWidget.setItem(n, 6, i) i = QTableWidgetItem(str("%s/%s" % (lat, lng))) if flags is not None: i.setFlags(flags) self.NetworksTableWidget.setItem(n, 7, i) self.NetworksTableWidget.resizeColumnsToContents() self.NetworksTableWidget.setSortingEnabled(True) self.NetworksTableWidget.sortItems(1, Qt.DescendingOrder) self.NetworksTableWidget.selectRow(0) # itemSelectionChanged = pyqtSignal() # self.NetworksTableWidget.emit(SIGNAL("itemSelectionChanged()")) self.NetworksTableWidget.itemSelectionChanged.emit() finally: endWaitCursor() self.NextButton.setEnabled(True) else: self.NextButton.setEnabled(False)