summaryrefslogtreecommitdiff
path: root/noncore/net/networksetup/mainwindowimp.cpp
authorbenmeyer <benmeyer>2002-10-18 14:28:42 (UTC)
committer benmeyer <benmeyer>2002-10-18 14:28:42 (UTC)
commit88b3a159060ed7057bfee4cc1ccfcf81a63a4780 (patch) (side-by-side diff)
tree3dd78d403f337c73bb3ca9d75ef0a29f2adae9b6 /noncore/net/networksetup/mainwindowimp.cpp
parent461113126af82cd6343eedab36ecabb4253780ee (diff)
downloadopie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.zip
opie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.tar.gz
opie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.tar.bz2
More profile stuff works
Diffstat (limited to 'noncore/net/networksetup/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp89
1 files changed, 76 insertions, 13 deletions
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index a446d29..3c0af6a 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -34,2 +34,3 @@
+#define SCHEME "/var/lib/pcmcia/scheme"
MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
@@ -55,3 +56,18 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
profilesList->insertItem((*it));
+ currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
+
+ QFile file(SCHEME);
+ if ( file.open(IO_ReadOnly) ) { // file opened successfully
+ QTextStream stream( &file ); // use a text stream
+ while ( !stream.eof() ) { // until end of file...
+ QString line = stream.readLine(); // line of text excluding '\n'
+ if(line.contains("SCHEME")){
+ line = line.mid(7, line.length());
+ currentProfileLabel->setText(line);
+ break;
+ }
+ }
+ file.close();
+ }
}
@@ -63,7 +79,6 @@ MainWindowImp::~MainWindowImp(){
// Save profiles.
- if(profiles.count() > 1){
- Config cfg("NetworkSetup");
- cfg.setGroup("General");
- cfg.writeEntry("Profiles", profiles.join(" "));
- }
+ Config cfg("NetworkSetup");
+ cfg.setGroup("General");
+ cfg.writeEntry("Profiles", profiles.join(" "));
+
// Delete Modules and Libraries
@@ -207,5 +222,11 @@ void MainWindowImp::configureClicked(){
}
-
+
+ QString currentProfile = currentProfileLabel->text();
+ if(profilesList->count() <= 1 || currentProfile == "All"){
+ currentProfile = "";
+ }
+
Interface *i = interfaceItems[item];
if(i->getModuleOwner()){
+ i->getModuleOwner()->setProfile(currentProfileLabel->text());
QTabWidget *tabWidget = NULL;
@@ -215,3 +236,5 @@ void MainWindowImp::configureClicked(){
InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
- tabWidget->insertTab(configure, "TCP/IP");
+ configure->setProfile(currentProfileLabel->text());
+ tabWidget->insertTab(configure, "TCP/IP");
+
}
@@ -224,2 +247,3 @@ void MainWindowImp::configureClicked(){
InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
+ configure->setProfile(currentProfileLabel->text());
configure->showMaximized();
@@ -246,2 +270,8 @@ void MainWindowImp::informationClicked(){
}
+
+ QStringList list;
+ for(uint i = 0; i < profilesList->count(); i++){
+ list.append(profilesList->text(i));
+ }
+
if(i->getModuleOwner()){
@@ -322,3 +352,3 @@ void MainWindowImp::jobDone(KProcess *process){
if(hardwareName != -1)
- i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
+ i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) );
@@ -351,3 +381,3 @@ void MainWindowImp::jobDone(KProcess *process){
i->setAttached(false);
- i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
+ i->setHardwareName("Disconnected");
interfaceNames.insert(i->getInterfaceName(), i);
@@ -408,3 +438,4 @@ void MainWindowImp::updateInterface(Interface *i){
item->setText(2, i->getHardwareName());
- item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
+ item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
+ item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
}
@@ -439,3 +470,3 @@ void MainWindowImp::removeProfile(){
if(profilesList->count() <= 1){
- QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
+ QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok");
return;
@@ -443,2 +474,13 @@ void MainWindowImp::removeProfile(){
QString profileToRemove = profilesList->currentText();
+ if(profileToRemove == "All"){
+ QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok");
+ return;
+ }
+ // Can't remove the curent profile
+ if(profileToRemove == currentProfileLabel->text()){
+ QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok");
+ return;
+
+ }
+
if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
@@ -449,3 +491,2 @@ void MainWindowImp::removeProfile(){
}
-
}
@@ -457,3 +498,25 @@ void MainWindowImp::removeProfile(){
void MainWindowImp::changeProfile(){
- currentProfileLabel->setText(profilesList->text(profilesList->currentItem()));
+ if(profilesList->currentItem() == -1){
+ QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok");
+ return;
+ }
+ QString newProfile = profilesList->text(profilesList->currentItem());
+ if(newProfile != currentProfileLabel->text()){
+ currentProfileLabel->setText(newProfile);
+ QFile file(SCHEME);
+ if ( file.open(IO_ReadWrite) ) {
+ QTextStream stream( &file );
+ stream << QString("SCHEME=%1").arg(newProfile);
+ file.close();
+ }
+ // restart all up devices?
+ if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
+ // Go through them one by one
+ QMap<Interface*, QListViewItem*>::Iterator it;
+ for( it = items.begin(); it != items.end(); ++it ){
+ if(it.key()->getStatus() == true)
+ it.key()->restart();
+ }
+ }
+ }
}