Diffstat (limited to 'noncore/settings/aqpkg/settingsimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 243 |
1 files changed, 122 insertions, 121 deletions
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index 4887ceb..9fdf31e 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp | |||
@@ -26,9 +26,17 @@ | |||
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <fstream> | 30 | #include "settingsimpl.h" |
31 | #include <algorithm> | 31 | #include "global.h" |
32 | using namespace std; | ||
33 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <opie/otabwidget.h> | ||
35 | #ifdef QWS | ||
36 | #include <qpe/config.h> | ||
37 | #include <qpe/resource.h> | ||
38 | #endif | ||
39 | #include <qpe/qpeapplication.h> | ||
40 | |||
41 | /* QT */ | ||
34 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
@@ -41,18 +49,12 @@ using namespace std; | |||
41 | 49 | ||
42 | #include <opie/otabwidget.h> | 50 | /* STD */ |
43 | 51 | #include <fstream> | |
44 | #ifdef QWS | 52 | #include <algorithm> |
45 | #include <qpe/config.h> | 53 | using namespace std; |
46 | #include <qpe/resource.h> | ||
47 | #endif | ||
48 | |||
49 | #include "settingsimpl.h" | ||
50 | |||
51 | #include "global.h" | ||
52 | 54 | ||
53 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 55 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) |
54 | : QDialog( parent, name, modal, fl ) | 56 | : QDialog( parent, name, modal, fl ) |
55 | { | 57 | { |
56 | setCaption( tr( "Configuration" ) ); | 58 | setCaption( tr( "Configuration" ) ); |
57 | 59 | ||
58 | // Setup layout to make everything pretty | 60 | // Setup layout to make everything pretty |
@@ -70,3 +72,3 @@ SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const | |||
70 | tabwidget->setCurrentTab( tr( "Servers" ) ); | 72 | tabwidget->setCurrentTab( tr( "Servers" ) ); |
71 | 73 | ||
72 | dataMgr = dataManager; | 74 | dataMgr = dataManager; |
@@ -80,3 +82,2 @@ SettingsImpl :: ~SettingsImpl() | |||
80 | { | 82 | { |
81 | |||
82 | } | 83 | } |
@@ -85,9 +86,7 @@ bool SettingsImpl :: showDlg() | |||
85 | { | 86 | { |
86 | showMaximized(); | 87 | QPEApplication::execDialog( this ); |
87 | exec(); | 88 | if ( changed ) |
88 | 89 | dataMgr->writeOutIpkgConf(); | |
89 | if ( changed ) | ||
90 | dataMgr->writeOutIpkgConf(); | ||
91 | 90 | ||
92 | return changed; | 91 | return changed; |
93 | } | 92 | } |
@@ -120,3 +119,3 @@ QWidget *SettingsImpl :: initServerTab() | |||
120 | layout->addWidget( btn, 1, 0 ); | 119 | layout->addWidget( btn, 1, 0 ); |
121 | 120 | ||
122 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 121 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
@@ -124,3 +123,3 @@ QWidget *SettingsImpl :: initServerTab() | |||
124 | layout->addWidget( btn, 1, 1 ); | 123 | layout->addWidget( btn, 1, 1 ); |
125 | 124 | ||
126 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); | 125 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); |
@@ -131,3 +130,3 @@ QWidget *SettingsImpl :: initServerTab() | |||
131 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 130 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
132 | 131 | ||
133 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 132 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
@@ -144,3 +143,3 @@ QWidget *SettingsImpl :: initServerTab() | |||
144 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); | 143 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); |
145 | 144 | ||
146 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 145 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
@@ -148,3 +147,3 @@ QWidget *SettingsImpl :: initServerTab() | |||
148 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 147 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
149 | 148 | ||
150 | return control; | 149 | return control; |
@@ -178,3 +177,3 @@ QWidget *SettingsImpl :: initDestinationTab() | |||
178 | layout->addWidget( btn, 1, 0 ); | 177 | layout->addWidget( btn, 1, 0 ); |
179 | 178 | ||
180 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 179 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
@@ -182,3 +181,3 @@ QWidget *SettingsImpl :: initDestinationTab() | |||
182 | layout->addWidget( btn, 1, 1 ); | 181 | layout->addWidget( btn, 1, 1 ); |
183 | 182 | ||
184 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); | 183 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); |
@@ -189,3 +188,3 @@ QWidget *SettingsImpl :: initDestinationTab() | |||
189 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 188 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
190 | 189 | ||
191 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 190 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
@@ -202,3 +201,3 @@ QWidget *SettingsImpl :: initDestinationTab() | |||
202 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); | 201 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); |
203 | 202 | ||
204 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 203 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
@@ -206,3 +205,3 @@ QWidget *SettingsImpl :: initDestinationTab() | |||
206 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 205 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
207 | 206 | ||
208 | return control; | 207 | return control; |
@@ -237,3 +236,3 @@ QWidget *SettingsImpl :: initProxyTab() | |||
237 | grplayout->addWidget( chkHttpProxyEnabled ); | 236 | grplayout->addWidget( chkHttpProxyEnabled ); |
238 | 237 | ||
239 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); | 238 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); |
@@ -247,3 +246,3 @@ QWidget *SettingsImpl :: initProxyTab() | |||
247 | grplayout->addWidget( chkFtpProxyEnabled ); | 246 | grplayout->addWidget( chkFtpProxyEnabled ); |
248 | 247 | ||
249 | QLabel *label = new QLabel( tr( "Username:" ), container ); | 248 | QLabel *label = new QLabel( tr( "Username:" ), container ); |
@@ -261,3 +260,3 @@ QWidget *SettingsImpl :: initProxyTab() | |||
261 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); | 260 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); |
262 | 261 | ||
263 | return control; | 262 | return control; |
@@ -271,3 +270,3 @@ void SettingsImpl :: setupData() | |||
271 | for ( ; it.current(); ++it ) | 270 | for ( ; it.current(); ++it ) |
272 | { | 271 | { |
273 | serverName = it.current()->getServerName(); | 272 | serverName = it.current()->getServerName(); |
@@ -277,3 +276,3 @@ void SettingsImpl :: setupData() | |||
277 | servers->insertItem( serverName ); | 276 | servers->insertItem( serverName ); |
278 | } | 277 | } |
279 | 278 | ||
@@ -284,3 +283,3 @@ void SettingsImpl :: setupData() | |||
284 | destinations->insertItem( it2.current()->getDestinationName() ); | 283 | destinations->insertItem( it2.current()->getDestinationName() ); |
285 | 284 | ||
286 | // setup proxy tab | 285 | // setup proxy tab |
@@ -338,42 +337,42 @@ void SettingsImpl :: changeServerDetails() | |||
338 | { | 337 | { |
339 | changed = true; | 338 | changed = true; |
340 | 339 | ||
341 | QString newName = servername->text(); | 340 | QString newName = servername->text(); |
342 | 341 | ||
343 | // Convert any spaces to underscores | 342 | // Convert any spaces to underscores |
344 | char *tmpStr = new char[newName.length() + 1]; | 343 | char *tmpStr = new char[newName.length() + 1]; |
345 | for ( unsigned int i = 0 ; i < newName.length() ; ++i ) | 344 | for ( unsigned int i = 0 ; i < newName.length() ; ++i ) |
346 | { | 345 | { |
347 | if ( newName[i] == ' ' ) | 346 | if ( newName[i] == ' ' ) |
348 | tmpStr[i] = '_'; | 347 | tmpStr[i] = '_'; |
349 | else | 348 | else |
350 | tmpStr[i] = newName[i].latin1(); | 349 | tmpStr[i] = newName[i].latin1(); |
351 | } | 350 | } |
352 | tmpStr[newName.length()] = '\0'; | 351 | tmpStr[newName.length()] = '\0'; |
353 | 352 | ||
354 | newName = tmpStr; | 353 | newName = tmpStr; |
355 | delete tmpStr; | 354 | delete tmpStr; |
356 | 355 | ||
357 | if ( !newserver ) | 356 | if ( !newserver ) |
358 | { | 357 | { |
359 | Server *s = dataMgr->getServer( servers->currentText() ); | 358 | Server *s = dataMgr->getServer( servers->currentText() ); |
360 | if ( s ) | 359 | if ( s ) |
361 | { | 360 | { |
362 | // Update url | 361 | // Update url |
363 | s->setServerUrl( serverurl->text() ); | 362 | s->setServerUrl( serverurl->text() ); |
364 | s->setActive( active->isChecked() ); | 363 | s->setActive( active->isChecked() ); |
365 | 364 | ||
366 | // Check if server name has changed, if it has then we need to replace the key in the map | 365 | // Check if server name has changed, if it has then we need to replace the key in the map |
367 | if ( serverName != newName ) | 366 | if ( serverName != newName ) |
368 | { | 367 | { |
369 | // Update server name | 368 | // Update server name |
370 | s->setServerName( newName ); | 369 | s->setServerName( newName ); |
371 | } | 370 | } |
372 | 371 | ||
373 | // Update list box | 372 | // Update list box |
374 | servers->changeItem( newName, currentSelectedServer ); | 373 | servers->changeItem( newName, currentSelectedServer ); |
375 | } | 374 | } |
376 | } | 375 | } |
377 | else | 376 | else |
378 | { | 377 | { |
379 | Server s( newName, serverurl->text() ); | 378 | Server s( newName, serverurl->text() ); |
@@ -381,6 +380,6 @@ void SettingsImpl :: changeServerDetails() | |||
381 | dataMgr->getServerList().last()->setActive( active->isChecked() ); | 380 | dataMgr->getServerList().last()->setActive( active->isChecked() ); |
382 | servers->insertItem( newName ); | 381 | servers->insertItem( newName ); |
383 | servers->setCurrentItem( servers->count() ); | 382 | servers->setCurrentItem( servers->count() ); |
384 | newserver = false; | 383 | newserver = false; |
385 | } | 384 | } |
386 | } | 385 | } |
@@ -411,6 +410,6 @@ void SettingsImpl :: newDestination() | |||
411 | { | 410 | { |
412 | newdestination = true; | 411 | newdestination = true; |
413 | destinationname->setText( "" ); | 412 | destinationname->setText( "" ); |
414 | destinationurl->setText( "" ); | 413 | destinationurl->setText( "" ); |
415 | destinationname->setFocus(); | 414 | destinationname->setFocus(); |
416 | linkToRoot->setChecked( true ); | 415 | linkToRoot->setChecked( true ); |
@@ -431,3 +430,3 @@ void SettingsImpl :: changeDestinationDetails() | |||
431 | { | 430 | { |
432 | changed = true; | 431 | changed = true; |
433 | 432 | ||
@@ -439,35 +438,36 @@ void SettingsImpl :: changeDestinationDetails() | |||
439 | QString newName = destinationname->text(); | 438 | QString newName = destinationname->text(); |
440 | if ( !newdestination ) | 439 | if ( !newdestination ) |
441 | { | 440 | { |
442 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 441 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
443 | if ( d ) | 442 | if ( d ) |
444 | { | 443 | { |
445 | // Update url | 444 | // Update url |
446 | d->setDestinationPath( destinationurl->text() ); | 445 | d->setDestinationPath( destinationurl->text() ); |
447 | d->linkToRoot( linkToRoot->isChecked() ); | 446 | d->linkToRoot( linkToRoot->isChecked() ); |
448 | 447 | ||
449 | // Check if server name has changed, if it has then we need to replace the key in the map | 448 | // Check if server name has changed, if it has then we need to replace the key in the map |
450 | if ( destinationName != newName ) | 449 | if ( destinationName != newName ) |
451 | { | 450 | { |
452 | // Update server name | 451 | // Update server name |
453 | d->setDestinationName( newName ); | 452 | d->setDestinationName( newName ); |
454 | 453 | ||
455 | // Update list box | 454 | // Update list box |
456 | destinations->changeItem( newName, currentSelectedDestination ); | 455 | destinations->changeItem( newName, currentSelectedDestination ); |
457 | } | 456 | } |
458 | 457 | ||
459 | #ifdef QWS | 458 | #ifdef QWS |
460 | QString key = newName; | 459 | QString key = newName; |
461 | key += "_linkToRoot"; | 460 | key += "_linkToRoot"; |
462 | int val = d->linkToRoot(); | 461 | int val = d->linkToRoot(); |
463 | cfg.writeEntry( key, val ); | 462 | cfg.writeEntry( key, val ); |
464 | #endif | 463 | #endif |
465 | } | 464 | |
466 | } | 465 | } |
467 | else | 466 | } |
468 | { | 467 | else |
469 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); | 468 | { |
470 | destinations->insertItem( newName ); | 469 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); |
471 | destinations->setCurrentItem( destinations->count() ); | 470 | destinations->insertItem( newName ); |
472 | newdestination = false; | 471 | destinations->setCurrentItem( destinations->count() ); |
472 | newdestination = false; | ||
473 | 473 | ||
@@ -478,3 +478,4 @@ void SettingsImpl :: changeDestinationDetails() | |||
478 | #endif | 478 | #endif |
479 | } | 479 | |
480 | } | ||
480 | } | 481 | } |