summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index e1110e2..c3e6572 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -165,22 +165,38 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
EC.setConnection( NC );
}
EC.showMaximized();
// disable refresh timer
UpdateTimer->stop();
+ // we need to retry
+ while( 1 ) {
if( EC.exec() == QDialog::Accepted ) {
// toplevel item -> store
NodeCollection * NC = EC.connection();
if( NC->isModified() ) {
setModified( 1 );
if( LBI ) {
+ if( NC->name() != OldName ) {
+ // find if new name is free
+ NodeCollection * LCN = NSResources->findConnection(
+ NC->name() );
+ if( LCN ) {
+ QMessageBox::warning(
+ 0,
+ tr( "Generating system configuration" ),
+ tr( "Name %1 already exists" ).arg(NC->name())
+ );
+ continue; // restart exec
+ } // else new name
// new name -> remove item
NSResources->removeConnection( OldName );
- // must add it here since change will trigger event
NSResources->addConnection( NC );
+ } // else not changed
+
+ // must add it here since change will trigger event
Profiles_LB->changeItem( NC->devicePixmap(),
NC->name(),
Profiles_LB->index( LBI )
);
} else {
// new item
@@ -196,12 +212,14 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
// cancelled : reset connection
if( LBI ) {
NodeCollection * NC = NSResources->findConnection( LBI->text() );
NC->reassign();
}
}
+ break;
+ }
// reenable
UpdateTimer->start( 5000 );
}
void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
if( LBI == 0 )
@@ -330,21 +348,16 @@ void NetworkSettings::SLOT_On( void ) {
bool rv;
switch( NC->state() ) {
case Off :
// activate interface
rv = NC->setState( Activate );
break;
- case Available :
- // deactivate
+ case Available : // deactivate
+ case IsUp : // deactivate (will also bring down if needed)
rv = NC->setState( Deactivate );
break;
- case IsUp :
- // bring down and deactivate
- rv = ( NC->setState( Down ) &&
- NC->setState( Deactivate ) );
- break;
default :
// others no change
return;
}
if( ! rv ) {
@@ -363,13 +376,13 @@ void NetworkSettings::SLOT_Connect( void ) {
if ( ! LBI )
return;
NodeCollection * NC =
NSResources->findConnection( LBI->text() );
- bool rv;
+ bool rv = 1 ;
switch( NC->state() ) {
case IsUp :
// down interface
rv = NC->setState( Down );
break;
case Available :
@@ -380,21 +393,20 @@ void NetworkSettings::SLOT_Connect( void ) {
// activate and bring up
rv = ( NC->setState( Activate ) &&
NC->setState( Up ) );
break;
default :
// others no change
- return;
+ break;
}
if( ! rv ) {
QMessageBox::warning(
0,
tr( "Activating profile" ),
tr( "Cannot enable profile" ) );
- return;
}
// we do not update the GUI but wait for the REAL upping of the device
}
void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) {