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.cpp101
1 files changed, 49 insertions, 52 deletions
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index f72fa8e..e1110e2 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -1,16 +1,16 @@
#include <stdio.h>
#include <qpe/qpeapplication.h>
-#include <qiconset.h>
+#include <qlistbox.h>
#include <qgroupbox.h>
#include <qtimer.h>
#include <qlistbox.h>
#include <qmessagebox.h>
#include <qlabel.h>
#include <qiconview.h>
#include <qtimer.h>
#include <qpe/qpeapplication.h>
#include <qtoolbutton.h>
#include <asdevice.h>
#include "networksettings.h"
@@ -26,42 +26,39 @@ NetworkSettings::NetworkSettings( QWidget *parent,
// set pixmaps
Add_TB->setPixmap( NSResources->getPixmap( "add" ) );
Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) );
CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) );
Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) );
GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) );
Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) );
On_TB->setPixmap( NSResources->getPixmap( "off" ) );
// populate main Listbox
- Profiles_IV->clear();
+ Profiles_LB->clear();
{ Name2Connection_t & M = NSResources->connections();
NodeCollection * NC;
- QIconViewItem * IVI;
-
// for all connections
for( QDictIterator<NodeCollection> it(M);
it.current();
++it ) {
NC = it.current();
- IVI = new QIconViewItem( Profiles_IV,
- NC->name(),
- NC->devicePixmap() );
+ Profiles_LB->insertItem( NC->devicePixmap(),
+ NC->name() );
}
}
- if( Profiles_IV->count() ) {
- Profiles_IV->setSelected( Profiles_IV->firstItem(), TRUE );
+ if( Profiles_LB->count() ) {
+ Profiles_LB->setSelected( 0, TRUE );
}
// if no profiles -> auto popup editing
if( NSResources->connections().count() == 0 ) {
QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) );
}
UpdateTimer->start( 5000 );
connect( UpdateTimer, SIGNAL( timeout() ),
this, SLOT( SLOT_RefreshStates() ) );
/* Add QCopChannel */
@@ -82,36 +79,36 @@ NetworkSettings::~NetworkSettings() {
}
S = NSD.saveSettings();
if( ! S.isEmpty() ) {
// problem saving
QMessageBox::warning(
0,
tr( "Saving setup" ), S );
}
}
void NetworkSettings::SLOT_RefreshStates( void ) {
- QIconViewItem * IVI = Profiles_IV->currentItem(); // remeber
+ QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember
- if( IVI ) {
+ if( LBI ) {
NodeCollection * NC;
NSResources->system().probeInterfaces();
// update current selection only
- NC = NSResources->findConnection( IVI->text() );
+ NC = NSResources->findConnection( LBI->text() );
if( NC ) {
State_t OldS = NC->state();
State_t NewS = NC->state(1);
if( OldS != NewS ) {
- updateProfileState( IVI );
+ updateProfileState( LBI );
}
}
}
/* -> LATER !!
bool is;
NodeCollection * NC;
for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) {
NC = NSResources->findConnection( Profiles_LB->text(i) );
if( NC ) {
@@ -129,97 +126,97 @@ void NetworkSettings::SLOT_RefreshStates( void ) {
}
}
if( ci >= 0 )
Profiles_LB->setCurrentItem( ci );
*/
}
void NetworkSettings::SLOT_AddNode( void ) {
SLOT_EditNode( 0 );
}
void NetworkSettings::SLOT_DeleteNode( void ) {
- QIconViewItem * IVI = Profiles_IV->currentItem();
+ QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
- if ( ! IVI )
+ if ( ! LBI )
return;
if( QMessageBox::warning(
0,
tr( "Removing profile" ),
tr( "Remove selected profile ?" ),
1, 0 ) == 1 ) {
- NSResources->removeConnection( IVI->text() );
- delete IVI;
+ NSResources->removeConnection( LBI->text() );
+ delete LBI;
setModified( 1 );
NSD.forceGeneration(1);
}
}
-void NetworkSettings::SLOT_EditNode( QIconViewItem * IVI ) {
+void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
QString OldName = "";
EditConnection EC( this );
- if( IVI ) {
- NodeCollection * NC = NSResources->findConnection( IVI->text() );
+ if( LBI ) {
+ NodeCollection * NC = NSResources->findConnection( LBI->text() );
if( ! NC ) {
return;
}
OldName = NC->name();
EC.setConnection( NC );
}
EC.showMaximized();
// disable refresh timer
UpdateTimer->stop();
if( EC.exec() == QDialog::Accepted ) {
// toplevel item -> store
NodeCollection * NC = EC.connection();
if( NC->isModified() ) {
setModified( 1 );
- if( IVI ) {
+ if( LBI ) {
// new name -> remove item
NSResources->removeConnection( OldName );
// must add it here since change will trigger event
NSResources->addConnection( NC );
- IVI->setText( NC->name() );
- IVI->setPixmap( NC->devicePixmap() );
+ Profiles_LB->changeItem( NC->devicePixmap(),
+ NC->name(),
+ Profiles_LB->index( LBI )
+ );
} else {
// new item
+ int ci = Profiles_LB->count();
NSResources->addConnection( NC );
NC->setNumber( NC->maxConnectionNumber()+1 );
- IVI = new QIconViewItem( Profiles_IV,
- NC->name(),
- NC->devicePixmap()
- );
- Profiles_IV->setSelected( IVI, TRUE );
+ Profiles_LB->insertItem( NC->devicePixmap(), NC->name() );
+ Profiles_LB->setSelected( ci, TRUE );
}
- updateProfileState( IVI );
+ updateProfileState( LBI );
}
} else {
// cancelled : reset connection
- if( IVI ) {
- NodeCollection * NC = NSResources->findConnection( IVI->text() );
+ if( LBI ) {
+ NodeCollection * NC = NSResources->findConnection( LBI->text() );
NC->reassign();
}
}
// reenable
UpdateTimer->start( 5000 );
}
-void NetworkSettings::SLOT_ShowNode( QIconViewItem * IVI ) {
- if( IVI == 0 )
+void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
+ if( LBI == 0 )
return;
- NodeCollection * NC = NSResources->findConnection( IVI->text() );
+ NodeCollection * NC = NSResources->findConnection( LBI->text() );
// is button possible
bool EnabledPossible, OnPossible, ConnectPossible;
// is button On or Off
bool DisabledOn, OnOn, ConnectOn;
EnabledPossible = OnPossible = ConnectPossible = 1;
DisabledOn = 1;
OnOn = ConnectOn = 0;
switch( NC->state() ) {
case Unknown :
@@ -252,92 +249,92 @@ void NetworkSettings::SLOT_ShowNode( QIconViewItem * IVI ) {
Connect_TB->setEnabled( ConnectPossible );
Enable_TB->setOn( DisabledOn );
On_TB->setOn( OnOn );
Connect_TB->setOn( ConnectOn );
if( NC->description().isEmpty() ) {
Description_LBL->setText( tr( "No description" ) );
} else {
Description_LBL->setText( NC->description() );
}
- CurProfile_GB->setTitle( IVI->text() );
+ CurProfile_GB->setTitle( LBI->text() );
State_LBL->setText( NC->stateName() );
}
void NetworkSettings::SLOT_CheckState( void ) {
- QIconViewItem * IVI = Profiles_IV->currentItem();
- if ( ! IVI )
+ QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
+ if ( ! LBI )
return;
- updateProfileState( IVI );
+ updateProfileState( LBI );
}
-void NetworkSettings::updateProfileState( QIconViewItem * IVI ) {
- if( IVI == Profiles_IV->currentItem() ) {
- SLOT_ShowNode( IVI );
+void NetworkSettings::updateProfileState( QListBoxItem * LBI ) {
+ if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) {
+ SLOT_ShowNode( LBI );
}
}
void NetworkSettings::SLOT_GenerateConfig( void ) {
QString S = NSD.generateSettings( TRUE );
if( ! S.isEmpty() ) {
QMessageBox::warning(
0,
tr( "Generating system configuration" ),
S
);
}
}
void NetworkSettings::SLOT_Enable( void ) {
- QIconViewItem * IVI = Profiles_IV->currentItem();
+ QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
QString Msg;
- if ( ! IVI )
+ if ( ! LBI )
return;
NodeCollection * NC =
- NSResources->findConnection( IVI->text() );
+ NSResources->findConnection( LBI->text() );
bool rv;
switch( NC->state() ) {
case Disabled :
Msg = tr( "Cannot enable profile" );
rv = NC->setState( Enable );
break;
default :
Msg = tr( "Cannot disable profile" );
rv = NC->setState( Disable );
break;
}
if( ! rv ) {
QMessageBox::warning(
0,
tr( "Activating profile" ),
Msg );
return;
}
- updateProfileState( IVI );
+ updateProfileState( LBI );
}
void NetworkSettings::SLOT_On( void ) {
- QIconViewItem * IVI = Profiles_IV->currentItem();
+ QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
- if ( ! IVI )
+ if ( ! LBI )
return;
NodeCollection * NC =
- NSResources->findConnection( IVI->text() );
+ NSResources->findConnection( LBI->text() );
bool rv;
switch( NC->state() ) {
case Off :
// activate interface
rv = NC->setState( Activate );
break;
case Available :
// deactivate
rv = NC->setState( Deactivate );
break;
case IsUp :
@@ -348,35 +345,35 @@ void NetworkSettings::SLOT_On( void ) {
default :
// others no change
return;
}
if( ! rv ) {
QMessageBox::warning(
0,
tr( "Activating profile" ),
tr( "Cannot enable profile" ) );
return;
}
- updateProfileState( IVI );
+ updateProfileState( LBI );
}
void NetworkSettings::SLOT_Connect( void ) {
- QIconViewItem * IVI = Profiles_IV->currentItem();
+ QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
- if ( ! IVI )
+ if ( ! LBI )
return;
NodeCollection * NC =
- NSResources->findConnection( IVI->text() );
+ NSResources->findConnection( LBI->text() );
bool rv;
switch( NC->state() ) {
case IsUp :
// down interface
rv = NC->setState( Down );
break;
case Available :
// up interface
rv = NC->setState( Up );
break;
case Off :