Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index a0b3113..4119490 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -402,193 +402,193 @@ void MainWindowImp::removeClicked(){ | |||
402 | * If the interface has a module owner then request its configure. | 402 | * If the interface has a module owner then request its configure. |
403 | */ | 403 | */ |
404 | void MainWindowImp::configureClicked(){ | 404 | void MainWindowImp::configureClicked(){ |
405 | QListViewItem *item = connectionList->currentItem(); | 405 | QListViewItem *item = connectionList->currentItem(); |
406 | if(!item){ | 406 | if(!item){ |
407 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); | 407 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | 410 | ||
411 | QString currentProfileText = currentProfileLabel->text(); | 411 | QString currentProfileText = currentProfileLabel->text(); |
412 | if(currentProfileText.upper() == "ALL"); | 412 | if(currentProfileText.upper() == "ALL"); |
413 | currentProfileText = ""; | 413 | currentProfileText = ""; |
414 | 414 | ||
415 | Interface *i = interfaceItems[item]; | 415 | Interface *i = interfaceItems[item]; |
416 | 416 | ||
417 | if(i->getModuleOwner()){ | 417 | if(i->getModuleOwner()){ |
418 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 418 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
419 | if(moduleConfigure != NULL){ | 419 | if(moduleConfigure != NULL){ |
420 | i->getModuleOwner()->setProfile(currentProfileText); | 420 | i->getModuleOwner()->setProfile(currentProfileText); |
421 | moduleConfigure->showMaximized(); | 421 | moduleConfigure->showMaximized(); |
422 | return; | 422 | return; |
423 | } | 423 | } |
424 | } | 424 | } |
425 | 425 | ||
426 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); | 426 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); |
427 | configure->setProfile(currentProfileText); | 427 | configure->setProfile(currentProfileText); |
428 | configure->showMaximized(); | 428 | configure->showMaximized(); |
429 | } | 429 | } |
430 | 430 | ||
431 | /** | 431 | /** |
432 | * Pull up the information about the currently selected interface. | 432 | * Pull up the information about the currently selected interface. |
433 | * Report an error if no interface is selected. | 433 | * Report an error if no interface is selected. |
434 | * If the interface has a module owner then request its configure. | 434 | * If the interface has a module owner then request its configure. |
435 | */ | 435 | */ |
436 | void MainWindowImp::informationClicked(){ | 436 | void MainWindowImp::informationClicked(){ |
437 | QListViewItem *item = connectionList->currentItem(); | 437 | QListViewItem *item = connectionList->currentItem(); |
438 | if(!item){ | 438 | if(!item){ |
439 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 439 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
440 | return; | 440 | return; |
441 | } | 441 | } |
442 | 442 | ||
443 | Interface *i = interfaceItems[item]; | 443 | Interface *i = interfaceItems[item]; |
444 | // if(!i->isAttached()){ | 444 | // if(!i->isAttached()){ |
445 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 445 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
446 | // return; | 446 | // return; |
447 | // } | 447 | // } |
448 | 448 | ||
449 | if(i->getModuleOwner()){ | 449 | if(i->getModuleOwner()){ |
450 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 450 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
451 | if(moduleInformation != NULL){ | 451 | if(moduleInformation != NULL){ |
452 | moduleInformation->showMaximized(); | 452 | moduleInformation->showMaximized(); |
453 | #ifdef DEBUG | 453 | #ifdef DEBUG |
454 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); | 454 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); |
455 | #endif | 455 | #endif |
456 | return; | 456 | return; |
457 | } | 457 | } |
458 | } | 458 | } |
459 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); | 459 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); |
460 | information->showMaximized(); | 460 | information->showMaximized(); |
461 | } | 461 | } |
462 | 462 | ||
463 | /** | 463 | /** |
464 | * Update this interface. If no QListViewItem exists create one. | 464 | * Update this interface. If no QListViewItem exists create one. |
465 | * @param Interface* pointer to the interface that needs to be updated. | 465 | * @param Interface* pointer to the interface that needs to be updated. |
466 | */ | 466 | */ |
467 | void MainWindowImp::updateInterface(Interface *i){ | 467 | void MainWindowImp::updateInterface(Interface *i){ |
468 | if(!advancedUserMode){ | 468 | if(!advancedUserMode){ |
469 | if(i->getInterfaceName() == "lo") | 469 | if(i->getInterfaceName() == "lo") |
470 | return; | 470 | return; |
471 | } | 471 | } |
472 | 472 | ||
473 | QListViewItem *item = NULL; | 473 | QListViewItem *item = NULL; |
474 | 474 | ||
475 | // Find the interface, making it if needed. | 475 | // Find the interface, making it if needed. |
476 | if(items.find(i) == items.end()){ | 476 | if(items.find(i) == items.end()){ |
477 | item = new QListViewItem(connectionList, "", "", ""); | 477 | item = new QListViewItem(connectionList, "", "", ""); |
478 | // See if you can't find a module owner for this interface | 478 | // See if you can't find a module owner for this interface |
479 | QMap<Module*, QLibrary*>::Iterator it; | 479 | QMap<Module*, QLibrary*>::Iterator it; |
480 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 480 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
481 | if(it.key()->isOwner(i)) | 481 | if(it.key()->isOwner(i)) |
482 | i->setModuleOwner(it.key()); | 482 | i->setModuleOwner(it.key()); |
483 | } | 483 | } |
484 | items.insert(i, item); | 484 | items.insert(i, item); |
485 | interfaceItems.insert(item, i); | 485 | interfaceItems.insert(item, i); |
486 | } | 486 | } |
487 | else | 487 | else |
488 | item = items[i]; | 488 | item = items[i]; |
489 | 489 | ||
490 | // Update the icons and information | 490 | // Update the icons and information |
491 | #ifdef QWS | 491 | #ifdef QWS |
492 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 492 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
493 | #else | 493 | #else |
494 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); | 494 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); |
495 | #endif | 495 | #endif |
496 | 496 | ||
497 | QString typeName = "lan"; | 497 | QString typeName = "lan"; |
498 | if(i->getHardwareName().contains("Local Loopback")) | 498 | if(i->getInterfaceName() == "lo") |
499 | typeName = "lo"; | 499 | typeName = "lo"; |
500 | if(i->getInterfaceName().contains("irda")) | 500 | if(i->getInterfaceName().contains("irda")) |
501 | typeName = "irda"; | 501 | typeName = "irda"; |
502 | if(i->getInterfaceName().contains("wlan")) | 502 | if(i->getInterfaceName().contains("wlan")) |
503 | typeName = "wlan"; | 503 | typeName = "wlan"; |
504 | if(i->getInterfaceName().contains("usb")) | 504 | if(i->getInterfaceName().contains("usb")) |
505 | typeName = "usb"; | 505 | typeName = "usb"; |
506 | 506 | ||
507 | if(!i->isAttached()) | 507 | if(!i->isAttached()) |
508 | typeName = "connect_no"; | 508 | typeName = "connect_no"; |
509 | // Actually try to use the Module | 509 | // Actually try to use the Module |
510 | if(i->getModuleOwner() != NULL) | 510 | if(i->getModuleOwner() != NULL) |
511 | typeName = i->getModuleOwner()->getPixmapName(i); | 511 | typeName = i->getModuleOwner()->getPixmapName(i); |
512 | 512 | ||
513 | #ifdef QWS | 513 | #ifdef QWS |
514 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); | 514 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); |
515 | #else | 515 | #else |
516 | item->setPixmap(1, (SmallIcon(typeName))); | 516 | item->setPixmap(1, (SmallIcon(typeName))); |
517 | #endif | 517 | #endif |
518 | item->setText(2, i->getHardwareName()); | 518 | item->setText(2, i->getHardwareName()); |
519 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 519 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
520 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 520 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
521 | } | 521 | } |
522 | 522 | ||
523 | void MainWindowImp::newProfileChanged(const QString& newText){ | 523 | void MainWindowImp::newProfileChanged(const QString& newText){ |
524 | if(newText.length() > 0) | 524 | if(newText.length() > 0) |
525 | newProfileButton->setEnabled(true); | 525 | newProfileButton->setEnabled(true); |
526 | else | 526 | else |
527 | newProfileButton->setEnabled(false); | 527 | newProfileButton->setEnabled(false); |
528 | } | 528 | } |
529 | 529 | ||
530 | /** | 530 | /** |
531 | * Adds a new profile to the list of profiles. | 531 | * Adds a new profile to the list of profiles. |
532 | * Don't add profiles that already exists. | 532 | * Don't add profiles that already exists. |
533 | * Appends to the list and QStringList | 533 | * Appends to the list and QStringList |
534 | */ | 534 | */ |
535 | void MainWindowImp::addProfile(){ | 535 | void MainWindowImp::addProfile(){ |
536 | QString newProfileName = newProfile->text(); | 536 | QString newProfileName = newProfile->text(); |
537 | if(profiles.grep(newProfileName).count() > 0){ | 537 | if(profiles.grep(newProfileName).count() > 0){ |
538 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); | 538 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); |
539 | return; | 539 | return; |
540 | } | 540 | } |
541 | profiles.append(newProfileName); | 541 | profiles.append(newProfileName); |
542 | profilesList->insertItem(newProfileName); | 542 | profilesList->insertItem(newProfileName); |
543 | } | 543 | } |
544 | 544 | ||
545 | /** | 545 | /** |
546 | * Removes the currently selected profile in the combo. | 546 | * Removes the currently selected profile in the combo. |
547 | * Doesn't delete if there are less then 2 profiles. | 547 | * Doesn't delete if there are less then 2 profiles. |
548 | */ | 548 | */ |
549 | void MainWindowImp::removeProfile(){ | 549 | void MainWindowImp::removeProfile(){ |
550 | if(profilesList->count() <= 1){ | 550 | if(profilesList->count() <= 1){ |
551 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); | 551 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); |
552 | return; | 552 | return; |
553 | } | 553 | } |
554 | QString profileToRemove = profilesList->currentText(); | 554 | QString profileToRemove = profilesList->currentText(); |
555 | if(profileToRemove == "All"){ | 555 | if(profileToRemove == "All"){ |
556 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); | 556 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); |
557 | return; | 557 | return; |
558 | } | 558 | } |
559 | // Can't remove the curent profile | 559 | // Can't remove the curent profile |
560 | if(profileToRemove == currentProfileLabel->text()){ | 560 | if(profileToRemove == currentProfileLabel->text()){ |
561 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); | 561 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); |
562 | return; | 562 | return; |
563 | 563 | ||
564 | } | 564 | } |
565 | 565 | ||
566 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 566 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ |
567 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 567 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
568 | profilesList->clear(); | 568 | profilesList->clear(); |
569 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 569 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
570 | profilesList->insertItem((*it)); | 570 | profilesList->insertItem((*it)); |
571 | 571 | ||
572 | // Remove any interface settings and mappings. | 572 | // Remove any interface settings and mappings. |
573 | Interfaces interfaces; | 573 | Interfaces interfaces; |
574 | // Go through them one by one | 574 | // Go through them one by one |
575 | QMap<Interface*, QListViewItem*>::Iterator it; | 575 | QMap<Interface*, QListViewItem*>::Iterator it; |
576 | for( it = items.begin(); it != items.end(); ++it ){ | 576 | for( it = items.begin(); it != items.end(); ++it ){ |
577 | QString interfaceName = it.key()->getInterfaceName(); | 577 | QString interfaceName = it.key()->getInterfaceName(); |
578 | qDebug(interfaceName.latin1()); | 578 | qDebug(interfaceName.latin1()); |
579 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ | 579 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ |
580 | interfaces.removeInterface(); | 580 | interfaces.removeInterface(); |
581 | if(interfaces.setMapping(interfaceName)){ | 581 | if(interfaces.setMapping(interfaceName)){ |
582 | if(profilesList->count() == 1) | 582 | if(profilesList->count() == 1) |
583 | interfaces.removeMapping(); | 583 | interfaces.removeMapping(); |
584 | else{ | 584 | else{ |
585 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 585 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | interfaces.write(); | 588 | interfaces.write(); |
589 | break; | 589 | break; |
590 | } | 590 | } |
591 | } | 591 | } |
592 | } | 592 | } |
593 | } | 593 | } |
594 | 594 | ||