Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 3c0af6a..9f07f0d 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -207,66 +207,66 @@ void MainWindowImp::removeClicked(){ | |||
207 | } | 207 | } |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | /** | 211 | /** |
212 | * Pull up the configure about the currently selected interface. | 212 | * Pull up the configure about the currently selected interface. |
213 | * Report an error if no interface is selected. | 213 | * Report an error if no interface is selected. |
214 | * If the interface has a module owner then request its configure with a empty | 214 | * If the interface has a module owner then request its configure with a empty |
215 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 215 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
216 | */ | 216 | */ |
217 | void MainWindowImp::configureClicked(){ | 217 | void MainWindowImp::configureClicked(){ |
218 | QListViewItem *item = connectionList->currentItem(); | 218 | QListViewItem *item = connectionList->currentItem(); |
219 | if(!item){ | 219 | if(!item){ |
220 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 220 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); |
221 | return; | 221 | return; |
222 | } | 222 | } |
223 | 223 | ||
224 | QString currentProfile = currentProfileLabel->text(); | 224 | QString currentProfile = currentProfileLabel->text(); |
225 | if(profilesList->count() <= 1 || currentProfile == "All"){ | 225 | if(profilesList->count() <= 1 || currentProfile == "All"){ |
226 | currentProfile = ""; | 226 | currentProfile = ""; |
227 | } | 227 | } |
228 | 228 | ||
229 | Interface *i = interfaceItems[item]; | 229 | Interface *i = interfaceItems[item]; |
230 | if(i->getModuleOwner()){ | 230 | if(i->getModuleOwner()){ |
231 | i->getModuleOwner()->setProfile(currentProfileLabel->text()); | 231 | i->getModuleOwner()->setProfile(currentProfile); |
232 | QTabWidget *tabWidget = NULL; | 232 | QTabWidget *tabWidget = NULL; |
233 | QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); | 233 | QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); |
234 | if(moduleConfigure != NULL){ | 234 | if(moduleConfigure != NULL){ |
235 | if(tabWidget != NULL){ | 235 | if(tabWidget != NULL){ |
236 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); | 236 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); |
237 | configure->setProfile(currentProfileLabel->text()); | 237 | configure->setProfile(currentProfile); |
238 | tabWidget->insertTab(configure, "TCP/IP"); | 238 | tabWidget->insertTab(configure, "TCP/IP"); |
239 | 239 | ||
240 | } | 240 | } |
241 | moduleConfigure->showMaximized(); | 241 | moduleConfigure->showMaximized(); |
242 | moduleConfigure->show(); | 242 | moduleConfigure->show(); |
243 | return; | 243 | return; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); | 247 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); |
248 | configure->setProfile(currentProfileLabel->text()); | 248 | configure->setProfile(currentProfile); |
249 | configure->showMaximized(); | 249 | configure->showMaximized(); |
250 | configure->show(); | 250 | configure->show(); |
251 | } | 251 | } |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * Pull up the information about the currently selected interface. | 254 | * Pull up the information about the currently selected interface. |
255 | * Report an error if no interface is selected. | 255 | * Report an error if no interface is selected. |
256 | * If the interface has a module owner then request its configure with a empty | 256 | * If the interface has a module owner then request its configure with a empty |
257 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 257 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
258 | */ | 258 | */ |
259 | void MainWindowImp::informationClicked(){ | 259 | void MainWindowImp::informationClicked(){ |
260 | QListViewItem *item = connectionList->currentItem(); | 260 | QListViewItem *item = connectionList->currentItem(); |
261 | if(!item){ | 261 | if(!item){ |
262 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 262 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | 265 | ||
266 | Interface *i = interfaceItems[item]; | 266 | Interface *i = interfaceItems[item]; |
267 | if(!i->isAttached()){ | 267 | if(!i->isAttached()){ |
268 | QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); | 268 | QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); |
269 | return; | 269 | return; |
270 | } | 270 | } |
271 | 271 | ||
272 | QStringList list; | 272 | QStringList list; |
@@ -356,54 +356,56 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
356 | updateInterface(i); | 356 | updateInterface(i); |
357 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 357 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
358 | } | 358 | } |
359 | // It was an interface we already had. | 359 | // It was an interface we already had. |
360 | else{ | 360 | else{ |
361 | if(fileName != TEMP_ALL) | 361 | if(fileName != TEMP_ALL) |
362 | (interfaceNames[interfaceName])->setStatus(true); | 362 | (interfaceNames[interfaceName])->setStatus(true); |
363 | } | 363 | } |
364 | } | 364 | } |
365 | } | 365 | } |
366 | file.close(); | 366 | file.close(); |
367 | QFile::remove(fileName); | 367 | QFile::remove(fileName); |
368 | 368 | ||
369 | if(threads.count() == 0){ | 369 | if(threads.count() == 0){ |
370 | Interfaces i; | 370 | Interfaces i; |
371 | QStringList list = i.getInterfaceList(); | 371 | QStringList list = i.getInterfaceList(); |
372 | QMap<QString, Interface*>::Iterator it; | 372 | QMap<QString, Interface*>::Iterator it; |
373 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 373 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
374 | bool found = false; | 374 | bool found = false; |
375 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 375 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
376 | if(it.key() == (*ni)) | 376 | if(it.key() == (*ni)) |
377 | found = true; | 377 | found = true; |
378 | } | 378 | } |
379 | if(!found){ | 379 | if(!found){ |
380 | Interface *i = new Interface(this, *ni, false); | 380 | if(!(*ni).contains("_")){ |
381 | i->setAttached(false); | 381 | Interface *i = new Interface(this, *ni, false); |
382 | i->setHardwareName("Disconnected"); | 382 | i->setAttached(false); |
383 | interfaceNames.insert(i->getInterfaceName(), i); | 383 | i->setHardwareName("Disconnected"); |
384 | updateInterface(i); | 384 | interfaceNames.insert(i->getInterfaceName(), i); |
385 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 385 | updateInterface(i); |
386 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | ||
387 | } | ||
386 | } | 388 | } |
387 | } | 389 | } |
388 | } | 390 | } |
389 | } | 391 | } |
390 | 392 | ||
391 | /** | 393 | /** |
392 | * Update this interface. If no QListViewItem exists create one. | 394 | * Update this interface. If no QListViewItem exists create one. |
393 | * @param Interface* pointer to the interface that needs to be updated. | 395 | * @param Interface* pointer to the interface that needs to be updated. |
394 | */ | 396 | */ |
395 | void MainWindowImp::updateInterface(Interface *i){ | 397 | void MainWindowImp::updateInterface(Interface *i){ |
396 | if(!advancedUserMode){ | 398 | if(!advancedUserMode){ |
397 | if(i->getInterfaceName() == "lo") | 399 | if(i->getInterfaceName() == "lo") |
398 | return; | 400 | return; |
399 | } | 401 | } |
400 | 402 | ||
401 | QListViewItem *item = NULL; | 403 | QListViewItem *item = NULL; |
402 | 404 | ||
403 | // Find the interface, making it if needed. | 405 | // Find the interface, making it if needed. |
404 | if(items.find(i) == items.end()){ | 406 | if(items.find(i) == items.end()){ |
405 | item = new QListViewItem(connectionList, "", "", ""); | 407 | item = new QListViewItem(connectionList, "", "", ""); |
406 | // See if you can't find a module owner for this interface | 408 | // See if you can't find a module owner for this interface |
407 | QMap<Module*, QLibrary*>::Iterator it; | 409 | QMap<Module*, QLibrary*>::Iterator it; |
408 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 410 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
409 | if(it.key()->isOwner(i)) | 411 | if(it.key()->isOwner(i)) |
@@ -468,58 +470,62 @@ void MainWindowImp::addProfile(){ | |||
468 | */ | 470 | */ |
469 | void MainWindowImp::removeProfile(){ | 471 | void MainWindowImp::removeProfile(){ |
470 | if(profilesList->count() <= 1){ | 472 | if(profilesList->count() <= 1){ |
471 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); | 473 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); |
472 | return; | 474 | return; |
473 | } | 475 | } |
474 | QString profileToRemove = profilesList->currentText(); | 476 | QString profileToRemove = profilesList->currentText(); |
475 | if(profileToRemove == "All"){ | 477 | if(profileToRemove == "All"){ |
476 | QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); | 478 | QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); |
477 | return; | 479 | return; |
478 | } | 480 | } |
479 | // Can't remove the curent profile | 481 | // Can't remove the curent profile |
480 | if(profileToRemove == currentProfileLabel->text()){ | 482 | if(profileToRemove == currentProfileLabel->text()){ |
481 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); | 483 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); |
482 | return; | 484 | return; |
483 | 485 | ||
484 | } | 486 | } |
485 | 487 | ||
486 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 488 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ |
487 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 489 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
488 | profilesList->clear(); | 490 | profilesList->clear(); |
489 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 491 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
490 | profilesList->insertItem((*it)); | 492 | profilesList->insertItem((*it)); |
491 | } | 493 | } |
494 | |||
495 | // Remove any interface settings and mappings. | ||
496 | //TODO | ||
492 | } | 497 | } |
493 | 498 | ||
494 | /** | 499 | /** |
495 | * A new profile has been selected, change. | 500 | * A new profile has been selected, change. |
496 | * @param newProfile the new profile. | 501 | * @param newProfile the new profile. |
497 | */ | 502 | */ |
498 | void MainWindowImp::changeProfile(){ | 503 | void MainWindowImp::changeProfile(){ |
499 | if(profilesList->currentItem() == -1){ | 504 | if(profilesList->currentItem() == -1){ |
500 | QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); | 505 | QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); |
501 | return; | 506 | return; |
502 | } | 507 | } |
503 | QString newProfile = profilesList->text(profilesList->currentItem()); | 508 | QString newProfile = profilesList->text(profilesList->currentItem()); |
504 | if(newProfile != currentProfileLabel->text()){ | 509 | if(newProfile != currentProfileLabel->text()){ |
505 | currentProfileLabel->setText(newProfile); | 510 | currentProfileLabel->setText(newProfile); |
511 | QFile::remove(SCHEME); | ||
506 | QFile file(SCHEME); | 512 | QFile file(SCHEME); |
507 | if ( file.open(IO_ReadWrite) ) { | 513 | if ( file.open(IO_ReadWrite) ) { |
508 | QTextStream stream( &file ); | 514 | QTextStream stream( &file ); |
509 | stream << QString("SCHEME=%1").arg(newProfile); | 515 | stream << QString("SCHEME=%1").arg(newProfile); |
510 | file.close(); | 516 | file.close(); |
511 | } | 517 | } |
512 | // restart all up devices? | 518 | // restart all up devices? |
513 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | 519 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ |
514 | // Go through them one by one | 520 | // Go through them one by one |
515 | QMap<Interface*, QListViewItem*>::Iterator it; | 521 | QMap<Interface*, QListViewItem*>::Iterator it; |
516 | for( it = items.begin(); it != items.end(); ++it ){ | 522 | for( it = items.begin(); it != items.end(); ++it ){ |
517 | if(it.key()->getStatus() == true) | 523 | if(it.key()->getStatus() == true) |
518 | it.key()->restart(); | 524 | it.key()->restart(); |
519 | } | 525 | } |
520 | } | 526 | } |
521 | } | 527 | } |
522 | } | 528 | } |
523 | 529 | ||
524 | // mainwindowimp.cpp | 530 | // mainwindowimp.cpp |
525 | 531 | ||