Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index d6b708b..581b7e3 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -5,30 +5,30 @@ | |||
5 | #include "interfaces.h" | 5 | #include "interfaces.h" |
6 | #include "module.h" | 6 | #include "module.h" |
7 | 7 | ||
8 | #include <qpushbutton.h> | 8 | #include <qpushbutton.h> |
9 | #include <qlistbox.h> | 9 | #include <qlistbox.h> |
10 | #include <qlineedit.h> | 10 | #include <qlineedit.h> |
11 | #include <qlistview.h> | 11 | #include <qlistview.h> |
12 | #include <qheader.h> | 12 | #include <qheader.h> |
13 | #include <qlabel.h> | 13 | #include <qlabel.h> |
14 | 14 | ||
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | 16 | ||
17 | #ifdef QTE_VERSION | 17 | #ifdef QWS |
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/qlibrary.h> | 19 | #include <qpe/qlibrary.h> |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #define QLibrary | 22 | // #define QLibrary Library |
23 | #else | 23 | #else |
24 | #include <klibloader.h> | 24 | #include <klibloader.h> |
25 | #define QLibrary KLibrary | 25 | #define QLibrary KLibrary |
26 | #include <kconfig.h> | 26 | #include <kconfig.h> |
27 | #define Config KConfig | 27 | #define Config KConfig |
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <kstandarddirs.h> | 29 | #include <kstandarddirs.h> |
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #define showMaximized show | 31 | #define showMaximized show |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #if QT_VERSION < 300 | 34 | #if QT_VERSION < 300 |
@@ -50,26 +50,26 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par | |||
50 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 50 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
51 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 51 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
52 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 52 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
53 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 53 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
54 | 54 | ||
55 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 55 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
56 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 56 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
57 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 57 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
58 | 58 | ||
59 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 59 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
60 | // Load connections. | 60 | // Load connections. |
61 | // /usr/local/kde/lib/libinterfaces.la | 61 | // /usr/local/kde/lib/libinterfaces.la |
62 | #ifdef QTE_VERSION | 62 | #ifdef QWS |
63 | loadModules(QPEApplication::kdeDir() + "/plugins/networksettings"); | 63 | loadModules(QPEApplication::qpeDir() + "/plugins/networksettings"); |
64 | #else | 64 | #else |
65 | loader = KLibLoader::self(); | 65 | loader = KLibLoader::self(); |
66 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); | 66 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); |
67 | #endif | 67 | #endif |
68 | getAllInterfaces(); | 68 | getAllInterfaces(); |
69 | 69 | ||
70 | Interfaces i; | 70 | Interfaces i; |
71 | QStringList list = i.getInterfaceList(); | 71 | QStringList list = i.getInterfaceList(); |
72 | QMap<QString, Interface*>::Iterator it; | 72 | QMap<QString, Interface*>::Iterator it; |
73 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 73 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
74 | bool found = false; | 74 | bool found = false; |
75 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 75 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
@@ -121,25 +121,25 @@ MainWindowImp::~MainWindowImp(){ | |||
121 | // Save profiles. | 121 | // Save profiles. |
122 | Config cfg("NetworkSetup"); | 122 | Config cfg("NetworkSetup"); |
123 | cfg.setGroup("General"); | 123 | cfg.setGroup("General"); |
124 | cfg.writeEntry("Profiles", profiles.join(" ")); | 124 | cfg.writeEntry("Profiles", profiles.join(" ")); |
125 | 125 | ||
126 | // Delete all interfaces that don't have owners. | 126 | // Delete all interfaces that don't have owners. |
127 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 127 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
128 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 128 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
129 | if(iIt.key()->getModuleOwner() == NULL) | 129 | if(iIt.key()->getModuleOwner() == NULL) |
130 | delete iIt.key(); | 130 | delete iIt.key(); |
131 | } | 131 | } |
132 | 132 | ||
133 | #ifdef QTE_VERSION | 133 | #ifdef QWS |
134 | // Delete Modules and Libraries | 134 | // Delete Modules and Libraries |
135 | QMap<Module*, QLibrary*>::Iterator it; | 135 | QMap<Module*, QLibrary*>::Iterator it; |
136 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 136 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
137 | delete it.key(); | 137 | delete it.key(); |
138 | // I wonder why I can't delete the libraries | 138 | // I wonder why I can't delete the libraries |
139 | // What fucking shit this is. | 139 | // What fucking shit this is. |
140 | //delete it.data(); | 140 | //delete it.data(); |
141 | } | 141 | } |
142 | #else | 142 | #else |
143 | // klibloader automaticly deletes the libraries for us... | 143 | // klibloader automaticly deletes the libraries for us... |
144 | #endif | 144 | #endif |
145 | } | 145 | } |
@@ -237,25 +237,25 @@ void MainWindowImp::loadModules(const QString &path){ | |||
237 | } | 237 | } |
238 | 238 | ||
239 | /** | 239 | /** |
240 | * Attempt to load a function and resolve a function. | 240 | * Attempt to load a function and resolve a function. |
241 | * @param pluginFileName - the name of the file in which to attempt to load | 241 | * @param pluginFileName - the name of the file in which to attempt to load |
242 | * @param resolveString - function pointer to resolve | 242 | * @param resolveString - function pointer to resolve |
243 | * @return pointer to the function with name resolveString or NULL | 243 | * @return pointer to the function with name resolveString or NULL |
244 | */ | 244 | */ |
245 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ | 245 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ |
246 | #ifdef DEBUG | 246 | #ifdef DEBUG |
247 | qDebug("MainWindowImp::loadPlugin: %s", pluginFileName.latin1()); | 247 | qDebug("MainWindowImp::loadPlugin: %s", pluginFileName.latin1()); |
248 | #endif | 248 | #endif |
249 | #ifdef QTE_VERSION | 249 | #ifdef QWS |
250 | QLibrary *lib = new QLibrary(pluginFileName); | 250 | QLibrary *lib = new QLibrary(pluginFileName); |
251 | void *functionPointer = lib->resolve(resolveString); | 251 | void *functionPointer = lib->resolve(resolveString); |
252 | if( !functionPointer ){ | 252 | if( !functionPointer ){ |
253 | #ifdef DEBUG | 253 | #ifdef DEBUG |
254 | qDebug("MainWindowImp::loadPlugin: File: %s is not a plugin, but though was.", pluginFileName.latin1()); | 254 | qDebug("MainWindowImp::loadPlugin: File: %s is not a plugin, but though was.", pluginFileName.latin1()); |
255 | #endif | 255 | #endif |
256 | delete lib; | 256 | delete lib; |
257 | return NULL; | 257 | return NULL; |
258 | } | 258 | } |
259 | // Try to get an object. | 259 | // Try to get an object. |
260 | Module *object = ((Module* (*)()) functionPointer)(); | 260 | Module *object = ((Module* (*)()) functionPointer)(); |
261 | if(object == NULL){ | 261 | if(object == NULL){ |
@@ -373,25 +373,25 @@ void MainWindowImp::configureClicked(){ | |||
373 | return; | 373 | return; |
374 | } | 374 | } |
375 | 375 | ||
376 | Interface *i = interfaceItems[item]; | 376 | Interface *i = interfaceItems[item]; |
377 | if(i->getModuleOwner()){ | 377 | if(i->getModuleOwner()){ |
378 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 378 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
379 | if(moduleConfigure != NULL){ | 379 | if(moduleConfigure != NULL){ |
380 | moduleConfigure->showMaximized(); | 380 | moduleConfigure->showMaximized(); |
381 | return; | 381 | return; |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WShowModal | Qt::WDestructiveClose | Qt::WType_Dialog); | 385 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); |
386 | QString currentProfileText = currentProfileLabel->text(); | 386 | QString currentProfileText = currentProfileLabel->text(); |
387 | if(currentProfileText.upper() == "ALL"); | 387 | if(currentProfileText.upper() == "ALL"); |
388 | currentProfileText = ""; | 388 | currentProfileText = ""; |
389 | configure->setProfile(currentProfileText); | 389 | configure->setProfile(currentProfileText); |
390 | configure->showMaximized(); | 390 | configure->showMaximized(); |
391 | } | 391 | } |
392 | 392 | ||
393 | /** | 393 | /** |
394 | * Pull up the information about the currently selected interface. | 394 | * Pull up the information about the currently selected interface. |
395 | * Report an error if no interface is selected. | 395 | * Report an error if no interface is selected. |
396 | * If the interface has a module owner then request its configure. | 396 | * If the interface has a module owner then request its configure. |
397 | */ | 397 | */ |
@@ -409,25 +409,25 @@ void MainWindowImp::informationClicked(){ | |||
409 | } | 409 | } |
410 | 410 | ||
411 | if(i->getModuleOwner()){ | 411 | if(i->getModuleOwner()){ |
412 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 412 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
413 | if(moduleInformation != NULL){ | 413 | if(moduleInformation != NULL){ |
414 | moduleInformation->showMaximized(); | 414 | moduleInformation->showMaximized(); |
415 | #ifdef DEBUG | 415 | #ifdef DEBUG |
416 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); | 416 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); |
417 | #endif | 417 | #endif |
418 | return; | 418 | return; |
419 | } | 419 | } |
420 | } | 420 | } |
421 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WShowModal | Qt::WDestructiveClose | Qt::WType_Dialog); | 421 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); |
422 | information->showMaximized(); | 422 | information->showMaximized(); |
423 | } | 423 | } |
424 | 424 | ||
425 | /** | 425 | /** |
426 | * Update this interface. If no QListViewItem exists create one. | 426 | * Update this interface. If no QListViewItem exists create one. |
427 | * @param Interface* pointer to the interface that needs to be updated. | 427 | * @param Interface* pointer to the interface that needs to be updated. |
428 | */ | 428 | */ |
429 | void MainWindowImp::updateInterface(Interface *i){ | 429 | void MainWindowImp::updateInterface(Interface *i){ |
430 | if(!advancedUserMode){ | 430 | if(!advancedUserMode){ |
431 | if(i->getInterfaceName() == "lo") | 431 | if(i->getInterfaceName() == "lo") |
432 | return; | 432 | return; |
433 | } | 433 | } |
@@ -441,47 +441,47 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
441 | QMap<Module*, QLibrary*>::Iterator it; | 441 | QMap<Module*, QLibrary*>::Iterator it; |
442 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 442 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
443 | if(it.key()->isOwner(i)) | 443 | if(it.key()->isOwner(i)) |
444 | i->setModuleOwner(it.key()); | 444 | i->setModuleOwner(it.key()); |
445 | } | 445 | } |
446 | items.insert(i, item); | 446 | items.insert(i, item); |
447 | interfaceItems.insert(item, i); | 447 | interfaceItems.insert(item, i); |
448 | } | 448 | } |
449 | else | 449 | else |
450 | item = items[i]; | 450 | item = items[i]; |
451 | 451 | ||
452 | // Update the icons and information | 452 | // Update the icons and information |
453 | #ifdef QTE_VERSION | 453 | #ifdef QWS |
454 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 454 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
455 | #else | 455 | #else |
456 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); | 456 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); |
457 | #endif | 457 | #endif |
458 | 458 | ||
459 | QString typeName = "lan"; | 459 | QString typeName = "lan"; |
460 | if(i->getHardwareName().contains("Local Loopback")) | 460 | if(i->getHardwareName().contains("Local Loopback")) |
461 | typeName = "lo"; | 461 | typeName = "lo"; |
462 | if(i->getInterfaceName().contains("irda")) | 462 | if(i->getInterfaceName().contains("irda")) |
463 | typeName = "irda"; | 463 | typeName = "irda"; |
464 | if(i->getInterfaceName().contains("wlan")) | 464 | if(i->getInterfaceName().contains("wlan")) |
465 | typeName = "wlan"; | 465 | typeName = "wlan"; |
466 | if(i->getInterfaceName().contains("usb")) | 466 | if(i->getInterfaceName().contains("usb")) |
467 | typeName = "usb"; | 467 | typeName = "usb"; |
468 | 468 | ||
469 | if(!i->isAttached()) | 469 | if(!i->isAttached()) |
470 | typeName = "connect_no"; | 470 | typeName = "connect_no"; |
471 | // Actually try to use the Module | 471 | // Actually try to use the Module |
472 | if(i->getModuleOwner() != NULL) | 472 | if(i->getModuleOwner() != NULL) |
473 | typeName = i->getModuleOwner()->getPixmapName(i); | 473 | typeName = i->getModuleOwner()->getPixmapName(i); |
474 | 474 | ||
475 | #ifdef QTE_VERSION | 475 | #ifdef QWS |
476 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); | 476 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); |
477 | #else | 477 | #else |
478 | item->setPixmap(1, (SmallIcon(typeName))); | 478 | item->setPixmap(1, (SmallIcon(typeName))); |
479 | #endif | 479 | #endif |
480 | item->setText(2, i->getHardwareName()); | 480 | item->setText(2, i->getHardwareName()); |
481 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 481 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
482 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 482 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
483 | } | 483 | } |
484 | 484 | ||
485 | void MainWindowImp::newProfileChanged(const QString& newText){ | 485 | void MainWindowImp::newProfileChanged(const QString& newText){ |
486 | if(newText.length() > 0) | 486 | if(newText.length() > 0) |
487 | newProfileButton->setEnabled(true); | 487 | newProfileButton->setEnabled(true); |