summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp52
1 files changed, 23 insertions, 29 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,20 +1,22 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <unistd.h> 2#include <unistd.h>
3#include <errno.h>
3 4
4#include <qpe/qpeapplication.h> 5#include <qpe/qpeapplication.h>
5#include <qlistbox.h> 6#include <qlistbox.h>
6#include <qgroupbox.h> 7#include <qgroupbox.h>
7#include <qtimer.h> 8#include <qtimer.h>
8#include <qlistbox.h> 9#include <qlistbox.h>
9#include <qmessagebox.h> 10#include <qmessagebox.h>
10#include <qlabel.h> 11#include <qlabel.h>
11#include <qiconview.h> 12#include <qiconview.h>
12#include <qtimer.h> 13#include <qtimer.h>
13#include <qpe/qpeapplication.h> 14#include <qpe/qpeapplication.h>
14#include <qtoolbutton.h> 15#include <qtoolbutton.h>
16#include <qevent.h>
15 17
16#include <asdevice.h> 18#include <asdevice.h>
17#include "networksettings.h" 19#include "networksettings.h"
18#include "netnode.h" 20#include "netnode.h"
19#include "editconnection.h" 21#include "editconnection.h"
20 22
@@ -38,12 +40,19 @@ NetworkSettings::NetworkSettings( QWidget *parent,
38 On_TB->setPixmap( NSResources->getPixmap( "off" ) ); 40 On_TB->setPixmap( NSResources->getPixmap( "off" ) );
39 41
40 SLOT_ToProfile(); 42 SLOT_ToProfile();
41 43
42 // populate main Listbox 44 // populate main Listbox
43 Profiles_LB->clear(); 45 Profiles_LB->clear();
46 QPEApplication::setStylusOperation(
47 Profiles_LB->viewport(), QPEApplication::RightOnHold );
48
49 connect( Profiles_LB,
50 SIGNAL(rightButtonPressed(QListBoxItem*,const QPoint&)),
51 this, SLOT(SLOT_EditNode(QListBoxItem*)) );
52
44 { Name2Connection_t & M = NSResources->connections(); 53 { Name2Connection_t & M = NSResources->connections();
45 NodeCollection * NC; 54 NodeCollection * NC;
46 // for all connections 55 // for all connections
47 for( QDictIterator<NodeCollection> it(M); 56 for( QDictIterator<NodeCollection> it(M);
48 it.current(); 57 it.current();
49 ++it ) { 58 ++it ) {
@@ -75,28 +84,24 @@ NetworkSettings::NetworkSettings( QWidget *parent,
75 this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) ); 84 this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) );
76} 85}
77 86
78NetworkSettings::~NetworkSettings() { 87NetworkSettings::~NetworkSettings() {
79 QString S; 88 QString S;
80 89
81 S = NSD.generateSettings(); 90 if( isModified() ) {
82 if( ! S.isEmpty() ) { 91 S = NSD.saveSettings();
83 QMessageBox::warning( 92 if( ! S.isEmpty() ) {
84 0, 93 // problem saving
85 tr( "In System Config" ), 94 QMessageBox::warning(
86 S 95 0,
87 ); 96 tr( "Saving setup" ), S );
88 } 97 }
89 98
90 S = NSD.saveSettings(); 99 SLOT_GenerateConfig();
91 if( ! S.isEmpty() ) {
92 // problem saving
93 QMessageBox::warning(
94 0,
95 tr( "Saving setup" ), S );
96 } 100 }
101
97} 102}
98 103
99void NetworkSettings::SLOT_CmdMessage( const QString & S ) { 104void NetworkSettings::SLOT_CmdMessage( const QString & S ) {
100 Messages_LB->insertItem( S ); 105 Messages_LB->insertItem( S );
101 Messages_LB->setCurrentItem( Messages_LB->count()-1 ); 106 Messages_LB->setCurrentItem( Messages_LB->count()-1 );
102 Messages_LB->ensureCurrentVisible(); 107 Messages_LB->ensureCurrentVisible();
@@ -142,15 +147,12 @@ void NetworkSettings::SLOT_RefreshStates( void ) {
142 } 147 }
143 if( ci >= 0 ) 148 if( ci >= 0 )
144 Profiles_LB->setCurrentItem( ci ); 149 Profiles_LB->setCurrentItem( ci );
145 */ 150 */
146} 151}
147 152
148void NetworkSettings::SLOT_NoLongerBusy( void ) {
149 NSResources->busy( FALSE );
150}
151void NetworkSettings::SLOT_AddNode( void ) { 153void NetworkSettings::SLOT_AddNode( void ) {
152 SLOT_EditNode( 0 ); 154 SLOT_EditNode( 0 );
153} 155}
154 156
155void NetworkSettings::SLOT_DeleteNode( void ) { 157void NetworkSettings::SLOT_DeleteNode( void ) {
156 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 158 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
@@ -163,18 +165,19 @@ void NetworkSettings::SLOT_DeleteNode( void ) {
163 tr( "Removing profile" ), 165 tr( "Removing profile" ),
164 tr( "Remove selected profile ?" ), 166 tr( "Remove selected profile ?" ),
165 1, 0 ) == 1 ) { 167 1, 0 ) == 1 ) {
166 NSResources->removeConnection( LBI->text() ); 168 NSResources->removeConnection( LBI->text() );
167 delete LBI; 169 delete LBI;
168 setModified( 1 ); 170 setModified( 1 );
169 NSD.forceGeneration(1);
170 } 171 }
171} 172}
172 173
173void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { 174void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
174 QString OldName = ""; 175 QString OldName = "";
176
177 printf( "------------------ Edit NOde\n" );
175 EditConnection EC( this ); 178 EditConnection EC( this );
176 179
177 if( LBI ) { 180 if( LBI ) {
178 NodeCollection * NC = NSResources->findConnection( LBI->text() ); 181 NodeCollection * NC = NSResources->findConnection( LBI->text() );
179 if( ! NC ) { 182 if( ! NC ) {
180 return; 183 return;
@@ -183,14 +186,13 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
183 EC.setConnection( NC ); 186 EC.setConnection( NC );
184 } 187 }
185 188
186 EC.showMaximized(); 189 EC.showMaximized();
187 // disable refresh timer 190 // disable refresh timer
188 UpdateTimer->stop(); 191 UpdateTimer->stop();
189 NSResources->busy( TRUE ); 192
190 QTimer::singleShot( 1000, this, SLOT( SLOT_NoLongerBusy() ));
191 // we need to retry 193 // we need to retry
192 while( 1 ) { 194 while( 1 ) {
193 if( EC.exec() == QDialog::Accepted ) { 195 if( EC.exec() == QDialog::Accepted ) {
194 // toplevel item -> store 196 // toplevel item -> store
195 NodeCollection * NC = EC.connection(); 197 NodeCollection * NC = EC.connection();
196 if( NC->isModified() ) { 198 if( NC->isModified() ) {
@@ -316,21 +318,13 @@ void NetworkSettings::updateProfileState( QListBoxItem * LBI ) {
316 if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) { 318 if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) {
317 SLOT_ShowNode( LBI ); 319 SLOT_ShowNode( LBI );
318 } 320 }
319} 321}
320 322
321void NetworkSettings::SLOT_GenerateConfig( void ) { 323void NetworkSettings::SLOT_GenerateConfig( void ) {
322 QString S = NSD.generateSettings( TRUE ); 324 NSD.regenerate();
323
324 if( ! S.isEmpty() ) {
325 QMessageBox::warning(
326 0,
327 tr( "Generating system configuration" ),
328 S
329 );
330 }
331} 325}
332 326
333void NetworkSettings::SLOT_Enable( void ) { 327void NetworkSettings::SLOT_Enable( void ) {
334 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 328 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
335 QString Msg; 329 QString Msg;
336 if ( ! LBI ) 330 if ( ! LBI )