author | benmeyer <benmeyer> | 2002-10-02 18:52:50 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-02 18:52:50 (UTC) |
commit | 56a0a990842a5b57b961c064809aae27f087562d (patch) (unidiff) | |
tree | e16ec644bff60c88c710ef6beedc5b033b39624c /noncore/net/networksetup/mainwindowimp.cpp | |
parent | 527e77d8244fb25d0bab39857eebbdfbcbfb807a (diff) | |
download | opie-56a0a990842a5b57b961c064809aae27f087562d.zip opie-56a0a990842a5b57b961c064809aae27f087562d.tar.gz opie-56a0a990842a5b57b961c064809aae27f087562d.tar.bz2 |
DHCP works, addProfile works
Diffstat (limited to 'noncore/net/networksetup/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index 66ec8b5..e9429e3 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp | |||
@@ -6,4 +6,5 @@ | |||
6 | 6 | ||
7 | #include "kprocess.h" | 7 | #include "kprocess.h" |
8 | #include "namedialog.h" | ||
8 | 9 | ||
9 | #include <qpushbutton.h> | 10 | #include <qpushbutton.h> |
@@ -129,9 +130,11 @@ void MainWindowImp::addClicked(){ | |||
129 | QMap<Module*, QLibrary*>::Iterator it; | 130 | QMap<Module*, QLibrary*>::Iterator it; |
130 | QMap<QString, QString> list; | 131 | QMap<QString, QString> list; |
132 | QMap<QString, Module*> newInterfaceOwners; | ||
131 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 133 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
132 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 134 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
133 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 135 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
134 | if(it.key()) | 136 | if(it.key()){ |
135 | (it.key())->possibleNewInterfaces(list); | 137 | (it.key())->possibleNewInterfaces(list); |
138 | } | ||
136 | } | 139 | } |
137 | // See if the list has anything that we can add. | 140 | // See if the list has anything that we can add. |
@@ -144,5 +147,17 @@ void MainWindowImp::addClicked(){ | |||
144 | addNewConnection.showMaximized(); | 147 | addNewConnection.showMaximized(); |
145 | if(QDialog::Accepted == addNewConnection.exec()){ | 148 | if(QDialog::Accepted == addNewConnection.exec()){ |
146 | 149 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | |
150 | if(!item) | ||
151 | return; | ||
152 | |||
153 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | ||
154 | if(it.key()){ | ||
155 | Interface *i = (it.key())->addNewInterface(item->text(0)); | ||
156 | if(i){ | ||
157 | interfaceNames.insert(i->getInterfaceName(), i); | ||
158 | updateInterface(i); | ||
159 | } | ||
160 | } | ||
161 | } | ||
147 | } | 162 | } |
148 | } | 163 | } |
@@ -154,16 +169,22 @@ void MainWindowImp::addClicked(){ | |||
154 | void MainWindowImp::removeClicked(){ | 169 | void MainWindowImp::removeClicked(){ |
155 | QListViewItem *item = connectionList->currentItem(); | 170 | QListViewItem *item = connectionList->currentItem(); |
156 | if(item == NULL) { | 171 | if(!item) { |
157 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); | 172 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); |
158 | return; | 173 | return; |
159 | } | 174 | } |
160 | 175 | ||
161 | if((interfaceItems[item])->getModuleOwner() == NULL){ | 176 | Interface *i = interfaceItems[item]; |
177 | if(i->getModuleOwner() == NULL){ | ||
162 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); | 178 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); |
163 | } | 179 | } |
164 | else{ | 180 | else{ |
165 | // Try to remove. | 181 | if(!i->getModuleOwner()->remove(i)) |
182 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); | ||
183 | else{ | ||
184 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); | ||
185 | // TODO memory managment.... | ||
186 | // who deletes the interface? | ||
187 | } | ||
166 | } | 188 | } |
167 | |||
168 | } | 189 | } |
169 | 190 | ||
@@ -312,10 +333,11 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
312 | 333 | ||
313 | /** | 334 | /** |
314 | * | 335 | * Update this interface. If no QListViewItem exists create one. |
336 | * @param Interface* pointer to the interface that needs to be updated. | ||
315 | */ | 337 | */ |
316 | void MainWindowImp::updateInterface(Interface *i){ | 338 | void MainWindowImp::updateInterface(Interface *i){ |
317 | QListViewItem *item = NULL; | 339 | QListViewItem *item = NULL; |
318 | 340 | ||
319 | // See if we already have it | 341 | // Find the interface, making it if needed. |
320 | if(items.find(i) == items.end()){ | 342 | if(items.find(i) == items.end()){ |
321 | item = new QListViewItem(connectionList, "", "", ""); | 343 | item = new QListViewItem(connectionList, "", "", ""); |
@@ -326,5 +348,4 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
326 | i->setModuleOwner(it.key()); | 348 | i->setModuleOwner(it.key()); |
327 | } | 349 | } |
328 | |||
329 | items.insert(i, item); | 350 | items.insert(i, item); |
330 | interfaceItems.insert(item, i); | 351 | interfaceItems.insert(item, i); |
@@ -332,10 +353,7 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
332 | else | 353 | else |
333 | item = items[i]; | 354 | item = items[i]; |
334 | 355 | ||
335 | QString statusImage = "down"; | 356 | // Update the icons and information |
336 | if(i->getStatus()) | 357 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
337 | statusImage = "up"; | ||
338 | QPixmap status = (Resource::loadPixmap(statusImage)); | ||
339 | item->setPixmap(0, status); | ||
340 | 358 | ||
341 | QString typeName = "lan"; | 359 | QString typeName = "lan"; |
@@ -347,12 +365,10 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
347 | typeName = "wlan"; | 365 | typeName = "wlan"; |
348 | // Actually try to use the Module | 366 | // Actually try to use the Module |
349 | if(i->getModuleOwner() != NULL){ | 367 | if(i->getModuleOwner() != NULL) |
350 | typeName = i->getModuleOwner()->getPixmapName(i); | 368 | typeName = i->getModuleOwner()->getPixmapName(i); |
351 | } | ||
352 | QPixmap type = (Resource::loadPixmap(typeName)); | ||
353 | item->setPixmap(1, type); | ||
354 | |||
355 | item->setText(2, i->getHardwareName()); | ||
356 | 369 | ||
370 | item->setPixmap(1, (Resource::loadPixmap(typeName))); | ||
371 | item->setText(2, i->getHardwareName()); | ||
372 | item->setText(3, (i->getStatus()) ? i->getIp() : QString("")); | ||
357 | } | 373 | } |
358 | 374 | ||
@@ -360,15 +376,18 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
360 | * Adds a new profile to the list of profiles. | 376 | * Adds a new profile to the list of profiles. |
361 | * Don't add profiles that already exists. | 377 | * Don't add profiles that already exists. |
362 | * Appends to the combo and QStringList | 378 | * Appends to the list and QStringList |
363 | */ | 379 | */ |
364 | void MainWindowImp::addProfile(){ | 380 | void MainWindowImp::addProfile(){ |
365 | QString newProfileName = "New"; | 381 | NameDialog foo(this, "namedialog", true); |
382 | QString newProfileName = foo.go(); | ||
383 | if(newProfileName.length() == 0) | ||
384 | return; | ||
385 | |||
366 | if(profiles.grep(newProfileName).count() > 0){ | 386 | if(profiles.grep(newProfileName).count() > 0){ |
367 | QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok"); | 387 | QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); |
368 | return; | 388 | return; |
369 | } | 389 | } |
370 | profiles.append(newProfileName); | 390 | profiles.append(newProfileName); |
371 | profilesList->insertItem(newProfileName); | 391 | profilesList->insertItem(newProfileName); |
372 | |||
373 | } | 392 | } |
374 | 393 | ||