From 1ed782f91c1af59e31c117809ca5d9150b8b6654 Mon Sep 17 00:00:00 2001 From: benmeyer Date: Tue, 01 Oct 2002 21:21:48 +0000 Subject: Getting modules to work --- diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp index f6eed00..5b21364 100644 --- a/noncore/net/networksetup/interface.cpp +++ b/noncore/net/networksetup/interface.cpp @@ -10,7 +10,7 @@ #include #include -Interface::Interface(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner("Default"), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ +Interface::Interface(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ refresh(); } diff --git a/noncore/net/networksetup/interface.h b/noncore/net/networksetup/interface.h index 1ad71eb..5dc95a4 100644 --- a/noncore/net/networksetup/interface.h +++ b/noncore/net/networksetup/interface.h @@ -3,6 +3,7 @@ #include +class Module; class Interface { public: @@ -21,8 +22,8 @@ public: virtual QString getHardwareName(){ return hardareName; }; virtual void setHardwareName(QString name="Unknown"){ hardareName = name; }; - virtual QString getModuleOwner(){ return moduleOwner; }; - virtual void setModuleOwner(QString owner="Default"){ moduleOwner = owner; }; + virtual Module* getModuleOwner(){ return moduleOwner; }; + virtual void setModuleOwner(Module *owner=NULL){ moduleOwner = owner; }; // inet information. QString getMacAddress(){ return macAddress; }; @@ -45,7 +46,7 @@ private: bool attached; QString interfaceName; QString hardareName; - QString moduleOwner; + Module *moduleOwner; // Network information QString macAddress; diff --git a/noncore/net/networksetup/interfacesetup.ui b/noncore/net/networksetup/interfacesetup.ui index ff9810e..d367608 100644 --- a/noncore/net/networksetup/interfacesetup.ui +++ b/noncore/net/networksetup/interfacesetup.ui @@ -11,15 +11,15 @@ 0 0 - 177 - 320 + 271 + 280 caption Interface Configuration - + margin 11 @@ -28,18 +28,7 @@ spacing 6 - - Line - - name - Line1 - - - orientation - Horizontal - - - + QCheckBox name @@ -50,101 +39,135 @@ Automaticly bring up - - QComboBox - - - text - All - - + + QLayoutWidget name - profileCombo - - - - QLabel - - name - leaseHoursLabel - - - text - Requested Lease - - - - QCheckBox - - name - dhcpCheckBox - - - text - DHCP - - - checked - true - - - - QLabel - - name - TextLabel1 - - - text - Profile: + Layout8 + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel1 + + + text + Profile + + + + QComboBox + + + text + All + + + + name + profileCombo + + + + + name + Spacer20 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + - - QSpinBox + + QLayoutWidget name - leaseTime - - - suffix - hours - - - maxValue - 336 - - - minValue - 1 - - - value - 24 + Layout9 + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + dhcpCheckBox + + + text + DHCP + + + checked + true + + + + QLabel + + name + leaseHoursLabel + + + text + Requested Lease + + + + QSpinBox + + name + leaseTime + + + suffix + hours + + + maxValue + 336 + + + minValue + 1 + + + value + 24 + + + - - - name - Spacer9 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - + QGroupBox name @@ -155,6 +178,14 @@ false + frameShape + Box + + + frameShadow + Sunken + + title Static Ip Configuration @@ -259,7 +290,28 @@ - + + + name + Spacer9 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + diff --git a/noncore/net/networksetup/mainwindow.ui b/noncore/net/networksetup/mainwindow.ui index c1fa101..a3f7bb1 100644 --- a/noncore/net/networksetup/mainwindow.ui +++ b/noncore/net/networksetup/mainwindow.ui @@ -11,7 +11,7 @@ 0 0 - 218 + 217 289 @@ -194,7 +194,18 @@ spacing 6 - + + Line + + name + Line1 + + + orientation + Horizontal + + + QLabel name @@ -205,7 +216,7 @@ Current Profile - + QLabel name @@ -224,18 +235,28 @@ All - - QLabel - + + name - TextLabel1_2 + Spacer2 - text - Profiles + orientation + Horizontal + + + sizeType + Expanding - - + + sizeHint + + 20 + 20 + + + + name Spacer16 @@ -256,14 +277,7 @@ - - QListBox - - name - profilesList - - - + QPushButton name @@ -274,7 +288,7 @@ &Set Current - + QPushButton name @@ -285,7 +299,7 @@ &Remove - + QPushButton name @@ -296,6 +310,24 @@ &New + + QLabel + + name + TextLabel1_2 + + + text + Profiles + + + + QListBox + + name + profilesList + + diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index 0f48a4b..89dac6f 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp @@ -151,7 +151,7 @@ void MainWindowImp::removeClicked(){ return; } - if(modules.find(interfaceItems[item]) == modules.end()){ + if((interfaceItems[item])->getModuleOwner() == NULL){ QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); } else{ @@ -171,14 +171,29 @@ void MainWindowImp::configureClicked(){ return; } - if(modules.find(interfaceItems[item]) == modules.end()){ + if((interfaceItems[item])->getModuleOwner() == NULL){ InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]); conf->showMaximized(); conf->show(); } else{ - InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration"); - conf->show(); + QTabWidget *t = NULL; + QWidget *conf = (interfaceItems[item])->getModuleOwner()->configure(&t); + if(conf != NULL){ + qDebug("Conf found"); + if(t != NULL){ + qDebug("Adding Interface"); + InterfaceSetupImp *i = new InterfaceSetupImp(t, "TCPIPInformation", interfaceItems[item], true); + t->insertTab(i, "TCP/IP"); + } + conf->showMaximized(); + conf->show(); + } + else{ + InterfaceSetupImp *i = new InterfaceSetupImp(0, "TCPIPInformation", interfaceItems[item], true); + i->showMaximized(); + i->show(); + } } } @@ -193,16 +208,28 @@ void MainWindowImp::informationClicked(){ return; } - if(modules.find(interfaceItems[item]) == modules.end()){ + if( (interfaceItems[item])->getModuleOwner() == NULL){ InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]); i->showMaximized(); i->show(); } else{ - QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB"); - InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true); - t->insertTab(i, "TCP/IP"); - t->show(); + QTabWidget *t = NULL; + QWidget *conf = (interfaceItems[item])->getModuleOwner()->information(&t); + if(conf != NULL){ + if(t){ + qDebug("Adding Interface"); + InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true); + t->insertTab(i, "TCP/IP"); + } + conf->showMaximized(); + conf->show(); + } + else{ + InterfaceInformationImp *i = new InterfaceInformationImp(0, "TCPIPInformation", interfaceItems[item], true); + i->showMaximized(); + i->show(); + } } } @@ -286,10 +313,12 @@ void MainWindowImp::updateInterface(Interface *i){ if(items.find(i) == items.end()){ item = new QListViewItem(serviceList, "", "", ""); // See if you can't find a module owner for this interface - //EmployeeMap::Iterator it; - //for( it = map.begin(); it != map.end(); ++it ) - // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() ); - + QMap::Iterator it; + for( it = libraries.begin(); it != libraries.end(); ++it ){ + if(it.key()->isOwner(i)) + i->setModuleOwner(it.key()); + } + items.insert(i, item); interfaceItems.insert(item, i); } @@ -309,6 +338,10 @@ void MainWindowImp::updateInterface(Interface *i){ typeName = "irda"; if(i->getInterfaceName().contains("wlan")) typeName = "wlan"; + // Actually try to use the Module + if(i->getModuleOwner() != NULL){ + typeName = i->getModuleOwner()->getPixmapName(i); + } QPixmap type = (Resource::loadPixmap(typeName)); item->setPixmap(1, type); diff --git a/noncore/net/networksetup/mainwindowimp.h b/noncore/net/networksetup/mainwindowimp.h index 8e300bf..19ebaf2 100644 --- a/noncore/net/networksetup/mainwindowimp.h +++ b/noncore/net/networksetup/mainwindowimp.h @@ -42,7 +42,6 @@ private: QMap interfaceNames; QMap libraries; - QMap modules; QMap items; QMap interfaceItems; diff --git a/noncore/net/networksetup/module.h b/noncore/net/networksetup/module.h index 13fd523..c1e9488 100644 --- a/noncore/net/networksetup/module.h +++ b/noncore/net/networksetup/module.h @@ -7,6 +7,7 @@ #include "interface.h" class QWidget; +class QTabWidget; class Module : QObject{ @@ -17,13 +18,13 @@ public: Module(){}; virtual bool isOwner(Interface *){ return false; }; - virtual QWidget *configure(){ return NULL; } ; - virtual QWidget *information(){ return NULL; }; + virtual QWidget *configure(QTabWidget **tabWidget){ return NULL; } ; + virtual QWidget *information(QTabWidget **tabWidget){ return NULL; }; virtual QList getInterfaces() = 0; virtual QMap possibleNewInterfaces() = 0; virtual Interface *addNewInterface(QString name) = 0; virtual bool remove(Interface* i) = 0; - + virtual QString getPixmapName(Interface* i) = 0; }; diff --git a/noncore/net/networksetup/networksetup.pro b/noncore/net/networksetup/networksetup.pro index a01b050..0d48790 100644 --- a/noncore/net/networksetup/networksetup.pro +++ b/noncore/net/networksetup/networksetup.pro @@ -1,6 +1,6 @@ TEMPLATE = app -CONFIG = qt warn_on debug -#CONFIG = qt warn_on release +#CONFIG = qt warn_on debug +CONFIG = qt warn_on release HEADERS = mainwindowimp.h addserviceimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h SOURCES = main.cpp mainwindowimp.cpp addserviceimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp #INCLUDEPATH += $(QPEDIR)/include diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp index f6eed00..5b21364 100644 --- a/noncore/settings/networksettings/interface.cpp +++ b/noncore/settings/networksettings/interface.cpp @@ -10,7 +10,7 @@ #include #include -Interface::Interface(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner("Default"), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ +Interface::Interface(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ refresh(); } diff --git a/noncore/settings/networksettings/interface.h b/noncore/settings/networksettings/interface.h index 1ad71eb..5dc95a4 100644 --- a/noncore/settings/networksettings/interface.h +++ b/noncore/settings/networksettings/interface.h @@ -3,6 +3,7 @@ #include +class Module; class Interface { public: @@ -21,8 +22,8 @@ public: virtual QString getHardwareName(){ return hardareName; }; virtual void setHardwareName(QString name="Unknown"){ hardareName = name; }; - virtual QString getModuleOwner(){ return moduleOwner; }; - virtual void setModuleOwner(QString owner="Default"){ moduleOwner = owner; }; + virtual Module* getModuleOwner(){ return moduleOwner; }; + virtual void setModuleOwner(Module *owner=NULL){ moduleOwner = owner; }; // inet information. QString getMacAddress(){ return macAddress; }; @@ -45,7 +46,7 @@ private: bool attached; QString interfaceName; QString hardareName; - QString moduleOwner; + Module *moduleOwner; // Network information QString macAddress; diff --git a/noncore/settings/networksettings/interfacesetup.ui b/noncore/settings/networksettings/interfacesetup.ui index ff9810e..d367608 100644 --- a/noncore/settings/networksettings/interfacesetup.ui +++ b/noncore/settings/networksettings/interfacesetup.ui @@ -11,15 +11,15 @@ 0 0 - 177 - 320 + 271 + 280 caption Interface Configuration - + margin 11 @@ -28,18 +28,7 @@ spacing 6 - - Line - - name - Line1 - - - orientation - Horizontal - - - + QCheckBox name @@ -50,101 +39,135 @@ Automaticly bring up - - QComboBox - - - text - All - - + + QLayoutWidget name - profileCombo - - - - QLabel - - name - leaseHoursLabel - - - text - Requested Lease - - - - QCheckBox - - name - dhcpCheckBox - - - text - DHCP - - - checked - true - - - - QLabel - - name - TextLabel1 - - - text - Profile: + Layout8 + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel1 + + + text + Profile + + + + QComboBox + + + text + All + + + + name + profileCombo + + + + + name + Spacer20 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + - - QSpinBox + + QLayoutWidget name - leaseTime - - - suffix - hours - - - maxValue - 336 - - - minValue - 1 - - - value - 24 + Layout9 + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + dhcpCheckBox + + + text + DHCP + + + checked + true + + + + QLabel + + name + leaseHoursLabel + + + text + Requested Lease + + + + QSpinBox + + name + leaseTime + + + suffix + hours + + + maxValue + 336 + + + minValue + 1 + + + value + 24 + + + - - - name - Spacer9 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - + QGroupBox name @@ -155,6 +178,14 @@ false + frameShape + Box + + + frameShadow + Sunken + + title Static Ip Configuration @@ -259,7 +290,28 @@ - + + + name + Spacer9 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + diff --git a/noncore/settings/networksettings/mainwindow.ui b/noncore/settings/networksettings/mainwindow.ui index c1fa101..a3f7bb1 100644 --- a/noncore/settings/networksettings/mainwindow.ui +++ b/noncore/settings/networksettings/mainwindow.ui @@ -11,7 +11,7 @@ 0 0 - 218 + 217 289 @@ -194,7 +194,18 @@ spacing 6 - + + Line + + name + Line1 + + + orientation + Horizontal + + + QLabel name @@ -205,7 +216,7 @@ Current Profile - + QLabel name @@ -224,18 +235,28 @@ All - - QLabel - + + name - TextLabel1_2 + Spacer2 - text - Profiles + orientation + Horizontal + + + sizeType + Expanding - - + + sizeHint + + 20 + 20 + + + + name Spacer16 @@ -256,14 +277,7 @@ - - QListBox - - name - profilesList - - - + QPushButton name @@ -274,7 +288,7 @@ &Set Current - + QPushButton name @@ -285,7 +299,7 @@ &Remove - + QPushButton name @@ -296,6 +310,24 @@ &New + + QLabel + + name + TextLabel1_2 + + + text + Profiles + + + + QListBox + + name + profilesList + + diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 0f48a4b..89dac6f 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp @@ -151,7 +151,7 @@ void MainWindowImp::removeClicked(){ return; } - if(modules.find(interfaceItems[item]) == modules.end()){ + if((interfaceItems[item])->getModuleOwner() == NULL){ QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); } else{ @@ -171,14 +171,29 @@ void MainWindowImp::configureClicked(){ return; } - if(modules.find(interfaceItems[item]) == modules.end()){ + if((interfaceItems[item])->getModuleOwner() == NULL){ InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]); conf->showMaximized(); conf->show(); } else{ - InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration"); - conf->show(); + QTabWidget *t = NULL; + QWidget *conf = (interfaceItems[item])->getModuleOwner()->configure(&t); + if(conf != NULL){ + qDebug("Conf found"); + if(t != NULL){ + qDebug("Adding Interface"); + InterfaceSetupImp *i = new InterfaceSetupImp(t, "TCPIPInformation", interfaceItems[item], true); + t->insertTab(i, "TCP/IP"); + } + conf->showMaximized(); + conf->show(); + } + else{ + InterfaceSetupImp *i = new InterfaceSetupImp(0, "TCPIPInformation", interfaceItems[item], true); + i->showMaximized(); + i->show(); + } } } @@ -193,16 +208,28 @@ void MainWindowImp::informationClicked(){ return; } - if(modules.find(interfaceItems[item]) == modules.end()){ + if( (interfaceItems[item])->getModuleOwner() == NULL){ InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]); i->showMaximized(); i->show(); } else{ - QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB"); - InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true); - t->insertTab(i, "TCP/IP"); - t->show(); + QTabWidget *t = NULL; + QWidget *conf = (interfaceItems[item])->getModuleOwner()->information(&t); + if(conf != NULL){ + if(t){ + qDebug("Adding Interface"); + InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true); + t->insertTab(i, "TCP/IP"); + } + conf->showMaximized(); + conf->show(); + } + else{ + InterfaceInformationImp *i = new InterfaceInformationImp(0, "TCPIPInformation", interfaceItems[item], true); + i->showMaximized(); + i->show(); + } } } @@ -286,10 +313,12 @@ void MainWindowImp::updateInterface(Interface *i){ if(items.find(i) == items.end()){ item = new QListViewItem(serviceList, "", "", ""); // See if you can't find a module owner for this interface - //EmployeeMap::Iterator it; - //for( it = map.begin(); it != map.end(); ++it ) - // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() ); - + QMap::Iterator it; + for( it = libraries.begin(); it != libraries.end(); ++it ){ + if(it.key()->isOwner(i)) + i->setModuleOwner(it.key()); + } + items.insert(i, item); interfaceItems.insert(item, i); } @@ -309,6 +338,10 @@ void MainWindowImp::updateInterface(Interface *i){ typeName = "irda"; if(i->getInterfaceName().contains("wlan")) typeName = "wlan"; + // Actually try to use the Module + if(i->getModuleOwner() != NULL){ + typeName = i->getModuleOwner()->getPixmapName(i); + } QPixmap type = (Resource::loadPixmap(typeName)); item->setPixmap(1, type); diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h index 8e300bf..19ebaf2 100644 --- a/noncore/settings/networksettings/mainwindowimp.h +++ b/noncore/settings/networksettings/mainwindowimp.h @@ -42,7 +42,6 @@ private: QMap interfaceNames; QMap libraries; - QMap modules; QMap items; QMap interfaceItems; diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h index 13fd523..c1e9488 100644 --- a/noncore/settings/networksettings/module.h +++ b/noncore/settings/networksettings/module.h @@ -7,6 +7,7 @@ #include "interface.h" class QWidget; +class QTabWidget; class Module : QObject{ @@ -17,13 +18,13 @@ public: Module(){}; virtual bool isOwner(Interface *){ return false; }; - virtual QWidget *configure(){ return NULL; } ; - virtual QWidget *information(){ return NULL; }; + virtual QWidget *configure(QTabWidget **tabWidget){ return NULL; } ; + virtual QWidget *information(QTabWidget **tabWidget){ return NULL; }; virtual QList getInterfaces() = 0; virtual QMap possibleNewInterfaces() = 0; virtual Interface *addNewInterface(QString name) = 0; virtual bool remove(Interface* i) = 0; - + virtual QString getPixmapName(Interface* i) = 0; }; diff --git a/noncore/settings/networksettings/networksetup.pro b/noncore/settings/networksettings/networksetup.pro index a01b050..0d48790 100644 --- a/noncore/settings/networksettings/networksetup.pro +++ b/noncore/settings/networksettings/networksetup.pro @@ -1,6 +1,6 @@ TEMPLATE = app -CONFIG = qt warn_on debug -#CONFIG = qt warn_on release +#CONFIG = qt warn_on debug +CONFIG = qt warn_on release HEADERS = mainwindowimp.h addserviceimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h SOURCES = main.cpp mainwindowimp.cpp addserviceimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp #INCLUDEPATH += $(QPEDIR)/include -- cgit v0.9.0.2