[PATCH]: Use QCombobox::addItem to append items to combo box lists.

Kel Modderman kel
Tue Jan 1 17:51:35 PST 2008


The QT4 port of wpa_gui uses QCombobox::insertItem() to add items to combo
boxes. In QT3, QCombobox::insertItem() would append items to list when no
index is given as first argument or if index is negative [0]. Qt4 requires an
index to be supplied as first argument to insertItem(), but in contrast to QT3
a negative index prepends items to list [1]. This causes preselection of
various combo boxes in wpa_gui-qt4 to be wrong, as the indices of the items
are the inverse of what is expected and the wrong item index gets chosen by the
setCurrentIndex() function of each combo box object.

QCombobox::addItem() preserves the correct behavior for the QT4 port of
wpa_gui for all instances where the insertItem() function was used for combo
box objects.

[0] http://doc.trolltech.com/3.3/qcombobox.html#insertItem
[1] http://doc.trolltech.com/4.3/qcombobox.html#insertItem

Signed-off-by: Kel Modderman <kel at otaku42.de>
---
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
@@ -273,7 +273,7 @@
 #endif
 
 	adapterSelect->clear();
-	adapterSelect->insertItem(-1, ctrl_iface);
+	adapterSelect->addItem(ctrl_iface);
 	adapterSelect->setCurrentIndex(0);
 
 	len = sizeof(buf) - 1;
@@ -286,7 +286,7 @@
 			if (pos2)
 				*pos2 = '\0';
 			if (strcmp(pos, ctrl_iface) != 0)
-				adapterSelect->insertItem(-1, pos);
+				adapterSelect->addItem(pos);
 			if (pos2)
 				pos = pos2 + 1;
 			else
@@ -475,7 +475,7 @@
 		QString network(id);
 		network.append(": ");
 		network.append(ssid);
-		networkSelect->insertItem(-1, network);
+		networkSelect->addItem(network);
 
 		if (strstr(flags, "[CURRENT]")) {
 			networkSelect->setCurrentIndex(networkSelect->count() -
--- a/wpa_supplicant/wpa_gui-qt4/networkconfig.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/networkconfig.cpp
@@ -110,12 +110,12 @@
 		encrSelect->removeItem(0);
 
 	if (sel == AUTH_NONE || sel == AUTH_IEEE8021X) {
-		encrSelect->insertItem(-1, "None");
-		encrSelect->insertItem(-1, "WEP");
+		encrSelect->addItem("None");
+		encrSelect->addItem("WEP");
 		encrSelect->setCurrentIndex(sel == AUTH_NONE ? 0 : 1);
 	} else {
-		encrSelect->insertItem(-1, "TKIP");
-		encrSelect->insertItem(-1, "CCMP");
+		encrSelect->addItem("TKIP");
+		encrSelect->addItem("CCMP");
 		encrSelect->setCurrentIndex((sel == AUTH_WPA2_PSK ||
 					     sel == AUTH_WPA2_EAP) ? 1 : 0);
 	}
---




More information about the Hostap mailing list