Diffstat (limited to 'noncore/settings/aqpkg/settingsimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index c5a55d2..7541f0b 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp | |||
@@ -209,230 +209,232 @@ QWidget *SettingsImpl :: initProxyTab() | |||
209 | 209 | ||
210 | QWidget *container = new QWidget( sv->viewport() ); | 210 | QWidget *container = new QWidget( sv->viewport() ); |
211 | sv->addChild( container ); | 211 | sv->addChild( container ); |
212 | 212 | ||
213 | QGridLayout *layout = new QGridLayout( container ); | 213 | QGridLayout *layout = new QGridLayout( container ); |
214 | layout->setSpacing( 2 ); | 214 | layout->setSpacing( 2 ); |
215 | layout->setMargin( 4 ); | 215 | layout->setMargin( 4 ); |
216 | 216 | ||
217 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); | 217 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); |
218 | grpbox->layout()->setSpacing( 2 ); | 218 | grpbox->layout()->setSpacing( 2 ); |
219 | grpbox->layout()->setMargin( 4 ); | 219 | grpbox->layout()->setMargin( 4 ); |
220 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); | 220 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); |
221 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 221 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
222 | txtHttpProxy = new QLineEdit( grpbox ); | 222 | txtHttpProxy = new QLineEdit( grpbox ); |
223 | grplayout->addWidget( txtHttpProxy ); | 223 | grplayout->addWidget( txtHttpProxy ); |
224 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 224 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
225 | grplayout->addWidget( chkHttpProxyEnabled ); | 225 | grplayout->addWidget( chkHttpProxyEnabled ); |
226 | 226 | ||
227 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); | 227 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); |
228 | grpbox->layout()->setSpacing( 2 ); | 228 | grpbox->layout()->setSpacing( 2 ); |
229 | grpbox->layout()->setMargin( 4 ); | 229 | grpbox->layout()->setMargin( 4 ); |
230 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); | 230 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); |
231 | grplayout = new QVBoxLayout( grpbox->layout() ); | 231 | grplayout = new QVBoxLayout( grpbox->layout() ); |
232 | txtFtpProxy = new QLineEdit( grpbox ); | 232 | txtFtpProxy = new QLineEdit( grpbox ); |
233 | grplayout->addWidget( txtFtpProxy ); | 233 | grplayout->addWidget( txtFtpProxy ); |
234 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 234 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
235 | grplayout->addWidget( chkFtpProxyEnabled ); | 235 | grplayout->addWidget( chkFtpProxyEnabled ); |
236 | 236 | ||
237 | QLabel *label = new QLabel( tr( "Username:" ), container ); | 237 | QLabel *label = new QLabel( tr( "Username:" ), container ); |
238 | layout->addWidget( label, 2, 0 ); | 238 | layout->addWidget( label, 2, 0 ); |
239 | txtUsername = new QLineEdit( container ); | 239 | txtUsername = new QLineEdit( container ); |
240 | layout->addWidget( txtUsername, 2, 1 ); | 240 | layout->addWidget( txtUsername, 2, 1 ); |
241 | 241 | ||
242 | label = new QLabel( tr( "Password:" ), container ); | 242 | label = new QLabel( tr( "Password:" ), container ); |
243 | layout->addWidget( label, 3, 0 ); | 243 | layout->addWidget( label, 3, 0 ); |
244 | txtPassword = new QLineEdit( container ); | 244 | txtPassword = new QLineEdit( container ); |
245 | layout->addWidget( txtPassword, 3, 1 ); | 245 | layout->addWidget( txtPassword, 3, 1 ); |
246 | 246 | ||
247 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); | 247 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); |
248 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); | 248 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); |
249 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); | 249 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); |
250 | 250 | ||
251 | return control; | 251 | return control; |
252 | } | 252 | } |
253 | 253 | ||
254 | void SettingsImpl :: setupData() | 254 | void SettingsImpl :: setupData() |
255 | { | 255 | { |
256 | // add servers | 256 | // add servers |
257 | vector<Server>::iterator it; | 257 | QString serverName; |
258 | for ( it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it ) | 258 | QListIterator<Server> it( dataMgr->getServerList() ); |
259 | for ( ; it.current(); ++it ) | ||
259 | { | 260 | { |
260 | if ( it->getServerName() == LOCAL_SERVER || it->getServerName() == LOCAL_IPKGS ) | 261 | serverName = it.current()->getServerName(); |
262 | if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) | ||
261 | continue; | 263 | continue; |
262 | 264 | ||
263 | servers->insertItem( it->getServerName() ); | 265 | servers->insertItem( serverName ); |
264 | } | 266 | } |
265 | 267 | ||
266 | 268 | ||
267 | // add destinations | 269 | // add destinations |
268 | vector<Destination>::iterator it2; | 270 | QListIterator<Destination> it2( dataMgr->getDestinationList() ); |
269 | for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 ) | 271 | for ( ; it2.current(); ++it2 ) |
270 | destinations->insertItem( it2->getDestinationName() ); | 272 | destinations->insertItem( it2.current()->getDestinationName() ); |
271 | 273 | ||
272 | // setup proxy tab | 274 | // setup proxy tab |
273 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); | 275 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); |
274 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); | 276 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); |
275 | txtUsername->setText( dataMgr->getProxyUsername() ); | 277 | txtUsername->setText( dataMgr->getProxyUsername() ); |
276 | txtPassword->setText( dataMgr->getProxyPassword() ); | 278 | txtPassword->setText( dataMgr->getProxyPassword() ); |
277 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); | 279 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); |
278 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); | 280 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); |
279 | } | 281 | } |
280 | 282 | ||
281 | //------------------ Servers tab ---------------------- | 283 | //------------------ Servers tab ---------------------- |
282 | 284 | ||
283 | void SettingsImpl :: editServer( int sel ) | 285 | void SettingsImpl :: editServer( int sel ) |
284 | { | 286 | { |
285 | currentSelectedServer = sel; | 287 | currentSelectedServer = sel; |
286 | vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); | 288 | Server *s = dataMgr->getServer( servers->currentText() ); |
287 | serverName = s->getServerName(); | 289 | serverName = s->getServerName(); |
288 | servername->setText( s->getServerName() ); | 290 | servername->setText( s->getServerName() ); |
289 | serverurl->setText( s->getServerUrl() ); | 291 | serverurl->setText( s->getServerUrl() ); |
290 | active->setChecked( s->isServerActive() ); | 292 | active->setChecked( s->isServerActive() ); |
291 | } | 293 | } |
292 | 294 | ||
293 | void SettingsImpl :: newServer() | 295 | void SettingsImpl :: newServer() |
294 | { | 296 | { |
295 | newserver = true; | 297 | newserver = true; |
296 | servername->setText( "" ); | 298 | servername->setText( "" ); |
297 | serverurl->setText( "" ); | 299 | serverurl->setText( "" ); |
298 | servername->setFocus(); | 300 | servername->setFocus(); |
299 | active->setChecked( true ); | 301 | active->setChecked( true ); |
300 | } | 302 | } |
301 | 303 | ||
302 | void SettingsImpl :: removeServer() | 304 | void SettingsImpl :: removeServer() |
303 | { | 305 | { |
304 | changed = true; | 306 | changed = true; |
305 | vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); | 307 | Server *s = dataMgr->getServer( servers->currentText() ); |
306 | dataMgr->getServerList().erase( s ); | 308 | dataMgr->getServerList().removeRef( s ); |
307 | servers->removeItem( currentSelectedServer ); | 309 | servers->removeItem( currentSelectedServer ); |
308 | } | 310 | } |
309 | 311 | ||
310 | void SettingsImpl :: changeServerDetails() | 312 | void SettingsImpl :: changeServerDetails() |
311 | { | 313 | { |
312 | changed = true; | 314 | changed = true; |
313 | 315 | ||
314 | QString newName = servername->text(); | 316 | QString newName = servername->text(); |
315 | if ( !newserver ) | 317 | if ( !newserver ) |
316 | { | 318 | { |
317 | vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); | 319 | Server *s = dataMgr->getServer( servers->currentText() ); |
318 | 320 | ||
319 | // Update url | 321 | // Update url |
320 | s->setServerUrl( serverurl->text() ); | 322 | s->setServerUrl( serverurl->text() ); |
321 | s->setActive( active->isChecked() ); | 323 | s->setActive( active->isChecked() ); |
322 | 324 | ||
323 | 325 | ||
324 | // Check if server name has changed, if it has then we need to replace the key in the map | 326 | // Check if server name has changed, if it has then we need to replace the key in the map |
325 | if ( serverName != newName ) | 327 | if ( serverName != newName ) |
326 | { | 328 | { |
327 | // Update server name | 329 | // Update server name |
328 | s->setServerName( newName ); | 330 | s->setServerName( newName ); |
329 | 331 | ||
330 | // See if this server is the active server | 332 | // See if this server is the active server |
331 | // if ( dataMgr->getActiveServer() == serverName ) | 333 | // if ( dataMgr->getActiveServer() == serverName ) |
332 | // dataMgr->setActiveServer( newName ); | 334 | // dataMgr->setActiveServer( newName ); |
333 | 335 | ||
334 | // Update list box | 336 | // Update list box |
335 | servers->changeItem( newName, currentSelectedServer ); | 337 | servers->changeItem( newName, currentSelectedServer ); |
336 | } | 338 | } |
337 | } | 339 | } |
338 | else | 340 | else |
339 | { | 341 | { |
340 | Server s( newName, serverurl->text() ); | 342 | Server s( newName, serverurl->text() ); |
341 | dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) ); | 343 | dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); |
342 | dataMgr->getServerList().end()->setActive( active->isChecked() ); | 344 | dataMgr->getServerList().last()->setActive( active->isChecked() ); |
343 | servers->insertItem( newName ); | 345 | servers->insertItem( newName ); |
344 | servers->setCurrentItem( servers->count() ); | 346 | servers->setCurrentItem( servers->count() ); |
345 | newserver = false; | 347 | newserver = false; |
346 | } | 348 | } |
347 | } | 349 | } |
348 | 350 | ||
349 | //------------------ Destinations tab ---------------------- | 351 | //------------------ Destinations tab ---------------------- |
350 | 352 | ||
351 | void SettingsImpl :: editDestination( int sel ) | 353 | void SettingsImpl :: editDestination( int sel ) |
352 | { | 354 | { |
353 | currentSelectedDestination = sel; | 355 | currentSelectedDestination = sel; |
354 | vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); | 356 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
355 | destinationName = d->getDestinationName(); | 357 | destinationName = d->getDestinationName(); |
356 | destinationname->setText( d->getDestinationName() ); | 358 | destinationname->setText( d->getDestinationName() ); |
357 | destinationurl->setText( d->getDestinationPath() ); | 359 | destinationurl->setText( d->getDestinationPath() ); |
358 | linkToRoot->setChecked( d->linkToRoot() ); | 360 | linkToRoot->setChecked( d->linkToRoot() ); |
359 | } | 361 | } |
360 | 362 | ||
361 | void SettingsImpl :: newDestination() | 363 | void SettingsImpl :: newDestination() |
362 | { | 364 | { |
363 | newdestination = true; | 365 | newdestination = true; |
364 | destinationname->setText( "" ); | 366 | destinationname->setText( "" ); |
365 | destinationurl->setText( "" ); | 367 | destinationurl->setText( "" ); |
366 | destinationname->setFocus(); | 368 | destinationname->setFocus(); |
367 | linkToRoot->setChecked( true ); | 369 | linkToRoot->setChecked( true ); |
368 | } | 370 | } |
369 | 371 | ||
370 | void SettingsImpl :: removeDestination() | 372 | void SettingsImpl :: removeDestination() |
371 | { | 373 | { |
372 | changed = true; | 374 | changed = true; |
373 | vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); | 375 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
374 | dataMgr->getDestinationList().erase( d ); | 376 | dataMgr->getDestinationList().removeRef( d ); |
375 | destinations->removeItem( currentSelectedDestination ); | 377 | destinations->removeItem( currentSelectedDestination ); |
376 | } | 378 | } |
377 | 379 | ||
378 | void SettingsImpl :: changeDestinationDetails() | 380 | void SettingsImpl :: changeDestinationDetails() |
379 | { | 381 | { |
380 | changed = true; | 382 | changed = true; |
381 | 383 | ||
382 | #ifdef QWS | 384 | #ifdef QWS |
383 | Config cfg( "aqpkg" ); | 385 | Config cfg( "aqpkg" ); |
384 | cfg.setGroup( "destinations" ); | 386 | cfg.setGroup( "destinations" ); |
385 | #endif | 387 | #endif |
386 | 388 | ||
387 | QString newName = destinationname->text(); | 389 | QString newName = destinationname->text(); |
388 | if ( !newdestination ) | 390 | if ( !newdestination ) |
389 | { | 391 | { |
390 | vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); | 392 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
391 | 393 | ||
392 | // Update url | 394 | // Update url |
393 | d->setDestinationPath( destinationurl->text() ); | 395 | d->setDestinationPath( destinationurl->text() ); |
394 | d->linkToRoot( linkToRoot->isChecked() ); | 396 | d->linkToRoot( linkToRoot->isChecked() ); |
395 | 397 | ||
396 | // Check if server name has changed, if it has then we need to replace the key in the map | 398 | // Check if server name has changed, if it has then we need to replace the key in the map |
397 | if ( destinationName != newName ) | 399 | if ( destinationName != newName ) |
398 | { | 400 | { |
399 | // Update server name | 401 | // Update server name |
400 | d->setDestinationName( newName ); | 402 | d->setDestinationName( newName ); |
401 | 403 | ||
402 | // Update list box | 404 | // Update list box |
403 | destinations->changeItem( newName, currentSelectedDestination ); | 405 | destinations->changeItem( newName, currentSelectedDestination ); |
404 | } | 406 | } |
405 | #ifdef QWS | 407 | #ifdef QWS |
406 | QString key = newName; | 408 | QString key = newName; |
407 | key += "_linkToRoot"; | 409 | key += "_linkToRoot"; |
408 | int val = d->linkToRoot(); | 410 | int val = d->linkToRoot(); |
409 | cfg.writeEntry( key, val ); | 411 | cfg.writeEntry( key, val ); |
410 | #endif | 412 | #endif |
411 | } | 413 | } |
412 | else | 414 | else |
413 | { | 415 | { |
414 | dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) ); | 416 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); |
415 | destinations->insertItem( newName ); | 417 | destinations->insertItem( newName ); |
416 | destinations->setCurrentItem( destinations->count() ); | 418 | destinations->setCurrentItem( destinations->count() ); |
417 | newdestination = false; | 419 | newdestination = false; |
418 | 420 | ||
419 | #ifdef QWS | 421 | #ifdef QWS |
420 | QString key = newName; | 422 | QString key = newName; |
421 | key += "_linkToRoot"; | 423 | key += "_linkToRoot"; |
422 | cfg.writeEntry( key, true ); | 424 | cfg.writeEntry( key, true ); |
423 | #endif | 425 | #endif |
424 | } | 426 | } |
425 | } | 427 | } |
426 | 428 | ||
427 | //------------------ Proxy tab ---------------------- | 429 | //------------------ Proxy tab ---------------------- |
428 | void SettingsImpl :: proxyApplyChanges() | 430 | void SettingsImpl :: proxyApplyChanges() |
429 | { | 431 | { |
430 | changed = true; | 432 | changed = true; |
431 | dataMgr->setHttpProxy( txtHttpProxy->text() ); | 433 | dataMgr->setHttpProxy( txtHttpProxy->text() ); |
432 | dataMgr->setFtpProxy( txtFtpProxy->text() ); | 434 | dataMgr->setFtpProxy( txtFtpProxy->text() ); |
433 | dataMgr->setProxyUsername( txtUsername->text() ); | 435 | dataMgr->setProxyUsername( txtUsername->text() ); |
434 | dataMgr->setProxyPassword( txtPassword->text() ); | 436 | dataMgr->setProxyPassword( txtPassword->text() ); |
435 | 437 | ||
436 | dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); | 438 | dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); |
437 | dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); | 439 | dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); |
438 | } | 440 | } |