[PATCH 5/14]: wpa_gui-qt4: connect new Edit pushbutton to signal/slot pair
Kel Modderman
kel
Mon Jan 28 23:13:51 PST 2008
Connect new Edit pushbutton on Manage Networks tab to a signal/slot pair
to spawn networkconfig form to edit configuration of network currently
selected in listbox.
Modify existing editNetwork() function to accept a QString as argument and
provide editSelectedNetwork() and editListedNetwork() as public slot
functions connected with the signals from the Edit entry in network menu
and new Edit pushbutton respectively.
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
@@ -41,7 +41,7 @@
connect(networkAddAction, SIGNAL(triggered()), this,
SLOT(addNetwork()));
connect(networkEditAction, SIGNAL(triggered()), this,
- SLOT(editNetwork()));
+ SLOT(editSelectedNetwork()));
connect(networkEnableAllAction, SIGNAL(triggered()), this,
SLOT(enableAllNetworks()));
connect(networkDisableAllAction, SIGNAL(triggered()), this,
@@ -58,6 +58,8 @@
connect(networkSelect, SIGNAL(activated(const QString&)), this,
SLOT(selectNetwork(const QString&)));
connect(addNetworkButton, SIGNAL(clicked()), this, SLOT(addNetwork()));
+ connect(editNetworkButton, SIGNAL(clicked()), this,
+ SLOT(editListedNetwork()));
eh = NULL;
scanres = NULL;
@@ -745,20 +747,20 @@
}
-void WpaGui::editNetwork()
+void WpaGui::editNetwork(const QString &sel)
{
- QString sel(networkSelect->currentText());
+ QString cmd(sel);
int id = -1;
- if (!sel.startsWith("Select any")) {
+ if (!cmd.startsWith("Select any")) {
int pos = sel.indexOf(':');
if (pos < 0) {
- printf("Invalid selectNetwork '%s'\n",
- sel.toAscii().constData());
+ printf("Invalid editNetwork '%s'\n",
+ cmd.toAscii().constData());
return;
}
- sel.truncate(pos);
- id = sel.toInt();
+ cmd.truncate(pos);
+ id = cmd.toInt();
}
NetworkConfig *nc = new NetworkConfig();
@@ -776,6 +778,26 @@
}
+void WpaGui::editSelectedNetwork()
+{
+ QString sel(networkSelect->currentText());
+ editNetwork(sel);
+}
+
+
+void WpaGui::editListedNetwork()
+{
+ if (networkList->currentRow() < 0) {
+ QMessageBox::information(this, "Select A Network",
+ "Select a network from the list to"
+ " edit it.\n");
+ return;
+ }
+ QString sel(networkList->currentItem()->text());
+ editNetwork(sel);
+}
+
+
void WpaGui::triggerUpdate()
{
updateStatus();
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.h
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.h
@@ -32,6 +32,7 @@
virtual int ctrlRequest(const char *cmd, char *buf, size_t *buflen);
virtual void triggerUpdate();
+ virtual void editNetwork(const QString &sel);
public slots:
virtual void parse_argv();
@@ -49,7 +50,8 @@
virtual void receiveMsgs();
virtual void connectB();
virtual void selectNetwork(const QString &sel);
- virtual void editNetwork();
+ virtual void editSelectedNetwork();
+ virtual void editListedNetwork();
virtual void addNetwork();
virtual void enableAllNetworks();
virtual void disableAllNetworks();
---
More information about the Hostap
mailing list