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.cpp42
1 files changed, 18 insertions, 24 deletions
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index 6ee4106..ce0eabc 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -1,26 +1,28 @@
#include <stdio.h>
#include <unistd.h>
+#include <errno.h>
#include <qpe/qpeapplication.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 <qevent.h>
#include <asdevice.h>
#include "networksettings.h"
#include "netnode.h"
#include "editconnection.h"
NetworkSettings::NetworkSettings( QWidget *parent,
const char *name,
WFlags fl ) : NetworkSettingsGUI(parent,name,fl),
NSD() {
UpdateTimer = new QTimer( this );
@@ -32,24 +34,31 @@ NetworkSettings::NetworkSettings( QWidget *parent,
Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) );
GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) );
Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) );
Disconnect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) );
On_TB->setPixmap( NSResources->getPixmap( "off" ) );
SLOT_ToProfile();
// populate main Listbox
Profiles_LB->clear();
+ QPEApplication::setStylusOperation(
+ Profiles_LB->viewport(), QPEApplication::RightOnHold );
+
+ connect( Profiles_LB,
+ SIGNAL(rightButtonPressed(QListBoxItem*,const QPoint&)),
+ this, SLOT(SLOT_EditNode(QListBoxItem*)) );
+
{ Name2Connection_t & M = NSResources->connections();
NodeCollection * NC;
// for all connections
for( QDictIterator<NodeCollection> it(M);
it.current();
++it ) {
NC = it.current();
Profiles_LB->insertItem( NC->devicePixmap(),
NC->name() );
}
}
@@ -69,40 +78,36 @@ NetworkSettings::NetworkSettings( QWidget *parent,
UpdateTimer->start( 5000 );
connect( UpdateTimer, SIGNAL( timeout() ),
this, SLOT( SLOT_RefreshStates() ) );
/* Add QCopChannel */
connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) );
}
NetworkSettings::~NetworkSettings() {
QString S;
- S = NSD.generateSettings();
- if( ! S.isEmpty() ) {
- QMessageBox::warning(
- 0,
- tr( "In System Config" ),
- S
- );
- }
-
+ if( isModified() ) {
S = NSD.saveSettings();
if( ! S.isEmpty() ) {
// problem saving
QMessageBox::warning(
0,
tr( "Saving setup" ), S );
}
+
+ SLOT_GenerateConfig();
+ }
+
}
void NetworkSettings::SLOT_CmdMessage( const QString & S ) {
Messages_LB->insertItem( S );
Messages_LB->setCurrentItem( Messages_LB->count()-1 );
Messages_LB->ensureCurrentVisible();
}
void NetworkSettings::SLOT_RefreshStates( void ) {
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember
if( LBI ) {
@@ -136,67 +141,64 @@ void NetworkSettings::SLOT_RefreshStates( void ) {
i );
if( is ) {
Profiles_LB->setSelected( i, TRUE );
}
}
}
}
if( ci >= 0 )
Profiles_LB->setCurrentItem( ci );
*/
}
-void NetworkSettings::SLOT_NoLongerBusy( void ) {
- NSResources->busy( FALSE );
-}
void NetworkSettings::SLOT_AddNode( void ) {
SLOT_EditNode( 0 );
}
void NetworkSettings::SLOT_DeleteNode( void ) {
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
if ( ! LBI )
return;
if( QMessageBox::warning(
0,
tr( "Removing profile" ),
tr( "Remove selected profile ?" ),
1, 0 ) == 1 ) {
NSResources->removeConnection( LBI->text() );
delete LBI;
setModified( 1 );
- NSD.forceGeneration(1);
}
}
void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
QString OldName = "";
+
+ printf( "------------------ Edit NOde\n" );
EditConnection EC( this );
if( LBI ) {
NodeCollection * NC = NSResources->findConnection( LBI->text() );
if( ! NC ) {
return;
}
OldName = NC->name();
EC.setConnection( NC );
}
EC.showMaximized();
// disable refresh timer
UpdateTimer->stop();
- NSResources->busy( TRUE );
- QTimer::singleShot( 1000, this, SLOT( SLOT_NoLongerBusy() ));
+
// 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() );
@@ -310,33 +312,25 @@ void NetworkSettings::SLOT_CheckState( void ) {
if ( ! LBI )
return;
updateProfileState( LBI );
}
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
- );
- }
+ NSD.regenerate();
}
void NetworkSettings::SLOT_Enable( void ) {
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
QString Msg;
if ( ! LBI )
return;
NodeCollection * NC =
NSResources->findConnection( LBI->text() );
bool rv;