-rw-r--r-- | libkdepim/ksyncprefsdialog.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp index 8d610d8..3df2a3b 100644 --- a/libkdepim/ksyncprefsdialog.cpp +++ b/libkdepim/ksyncprefsdialog.cpp | |||
@@ -309,160 +309,163 @@ void KSyncPrefsDialog::profileChanged( int item ) | |||
309 | remoteFileWidget->setEnabled(false); | 309 | remoteFileWidget->setEnabled(false); |
310 | 310 | ||
311 | } else | 311 | } else |
312 | kindChanged( prof->getIsLocalFileSync() ); | 312 | kindChanged( prof->getIsLocalFileSync() ); |
313 | } | 313 | } |
314 | 314 | ||
315 | void KSyncPrefsDialog::fillSSH() | 315 | void KSyncPrefsDialog::fillSSH() |
316 | { | 316 | { |
317 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | 317 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); |
318 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | 318 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); |
319 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); | 319 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); |
320 | } | 320 | } |
321 | void KSyncPrefsDialog::fillFTP() | 321 | void KSyncPrefsDialog::fillFTP() |
322 | { | 322 | { |
323 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); | 323 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); |
324 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | 324 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); |
325 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | 325 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); |
326 | 326 | ||
327 | } | 327 | } |
328 | void KSyncPrefsDialog::kindChanged( bool b ) | 328 | void KSyncPrefsDialog::kindChanged( bool b ) |
329 | { | 329 | { |
330 | 330 | ||
331 | localFileWidget->setEnabled(b); | 331 | localFileWidget->setEnabled(b); |
332 | remoteFileWidget->setEnabled(!b); | 332 | remoteFileWidget->setEnabled(!b); |
333 | 333 | ||
334 | } | 334 | } |
335 | void KSyncPrefsDialog::deleteProfile() | 335 | void KSyncPrefsDialog::deleteProfile() |
336 | { | 336 | { |
337 | //qDebug("KSyncPrefsDialog::deleteProfile() "); | 337 | //qDebug("KSyncPrefsDialog::deleteProfile() "); |
338 | if ( currentSelection >= 0 ) { | 338 | if ( currentSelection >= 0 ) { |
339 | if ( currentSelection < 3 ) { | 339 | if ( currentSelection < 3 ) { |
340 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); | 340 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); |
341 | return; | 341 | return; |
342 | } | 342 | } |
343 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); | 343 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); |
344 | mSyncProfiles.remove( temp ); | 344 | mSyncProfiles.remove( temp ); |
345 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); | 345 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); |
346 | insertProfiles(); | 346 | insertProfiles(); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | void KSyncPrefsDialog::saveProfile() | 350 | void KSyncPrefsDialog::saveProfile() |
351 | { | 351 | { |
352 | KSyncProfile* prof; | 352 | KSyncProfile* prof; |
353 | if ( currentSelection >= 0 ) { | 353 | if ( currentSelection >= 0 ) { |
354 | prof = mSyncProfiles.at(currentSelection) ; | 354 | prof = mSyncProfiles.at(currentSelection) ; |
355 | prof->setPreSyncCommand( mRemotePrecommand->text()); | 355 | prof->setPreSyncCommand( mRemotePrecommand->text()); |
356 | prof->setPostSyncCommand( mRemotePostcommand->text() ); | 356 | prof->setPostSyncCommand( mRemotePostcommand->text() ); |
357 | prof->setLocalTempFile( mLocalTempFile->text()); | 357 | prof->setLocalTempFile( mLocalTempFile->text()); |
358 | prof->setRemoteFileName( mRemoteFile->text() ); | 358 | prof->setRemoteFileName( mRemoteFile->text() ); |
359 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); | 359 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); |
360 | prof->setAskForPreferences( mAskForPreferences->isChecked()); | 360 | prof->setAskForPreferences( mAskForPreferences->isChecked()); |
361 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); | 361 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); |
362 | prof->setWriteBackFile( mWriteBackFile->isChecked()); | 362 | prof->setWriteBackFile( mWriteBackFile->isChecked()); |
363 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); | 363 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); |
364 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; | 364 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; |
365 | prof->setSyncPrefs( syncprefs); | 365 | prof->setSyncPrefs( syncprefs); |
366 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); | 366 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); |
367 | } | 367 | } |
368 | 368 | ||
369 | } | 369 | } |
370 | 370 | ||
371 | void KSyncPrefsDialog::insertProfiles() | 371 | void KSyncPrefsDialog::insertProfiles() |
372 | { | 372 | { |
373 | int curItem = mProfileBox->currentItem(); | 373 | int curItem = mProfileBox->currentItem(); |
374 | mProfileBox->blockSignals( true ); | 374 | mProfileBox->blockSignals( true ); |
375 | mProfileBox->clear(); | 375 | mProfileBox->clear(); |
376 | mProfileBox->insertStringList (mSyncProfileNames ); | 376 | mProfileBox->insertStringList (mSyncProfileNames ); |
377 | int item = mSyncProfileNames.count() -1; | 377 | int item = mSyncProfileNames.count() -1; |
378 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) | 378 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) |
379 | mProfileBox->setCurrentItem( curItem ); | 379 | mProfileBox->setCurrentItem( curItem ); |
380 | else if ( item >= 0 ) { | 380 | else if ( item >= 0 ) { |
381 | mProfileBox->setCurrentItem( item ); | 381 | mProfileBox->setCurrentItem( item ); |
382 | } | 382 | } |
383 | currentSelection = -1; | 383 | currentSelection = -1; |
384 | if ( mSyncProfileNames.count() > 0 ) { | 384 | if ( mSyncProfileNames.count() > 0 ) { |
385 | //qDebug(" profileChanged( mProfileBox->currentItem() "); | 385 | //qDebug(" profileChanged( mProfileBox->currentItem() "); |
386 | profileChanged( mProfileBox->currentItem() ); | 386 | profileChanged( mProfileBox->currentItem() ); |
387 | currentSelection = mProfileBox->currentItem(); | 387 | currentSelection = mProfileBox->currentItem(); |
388 | } | 388 | } |
389 | mProfileBox->blockSignals( false ); | 389 | mProfileBox->blockSignals( false ); |
390 | } | 390 | } |
391 | 391 | ||
392 | void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) | 392 | void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) |
393 | { | 393 | { |
394 | saveProfile(); | 394 | saveProfile(); |
395 | mSyncProfiles.append( temp ); | 395 | mSyncProfiles.append( temp ); |
396 | mSyncProfileNames << temp->getName(); | 396 | mSyncProfileNames << temp->getName(); |
397 | insertProfiles(); | 397 | insertProfiles(); |
398 | int last = mProfileBox->count() -1; | 398 | int last = mProfileBox->count() -1; |
399 | mProfileBox->blockSignals( true ); | 399 | mProfileBox->blockSignals( true ); |
400 | mProfileBox->setCurrentItem( last ); | 400 | mProfileBox->setCurrentItem( last ); |
401 | mProfileBox->blockSignals( false ); | 401 | mProfileBox->blockSignals( false ); |
402 | profileChanged(last); | 402 | profileChanged(last); |
403 | } | 403 | } |
404 | void KSyncPrefsDialog::newProfile() | 404 | void KSyncPrefsDialog::newProfile() |
405 | { | 405 | { |
406 | addProfile ( new KSyncProfile () ); | 406 | addProfile ( new KSyncProfile () ); |
407 | } | 407 | } |
408 | 408 | ||
409 | void KSyncPrefsDialog::cloneProfile() | 409 | void KSyncPrefsDialog::cloneProfile() |
410 | { | 410 | { |
411 | if ( currentSelection >= 0 ) | 411 | if ( currentSelection >= 0 ) |
412 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; | 412 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; |
413 | else | 413 | else |
414 | newProfile(); | 414 | newProfile(); |
415 | } | 415 | } |
416 | 416 | ||
417 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) | 417 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) |
418 | { | 418 | { |
419 | mMyMachineName->setText( name ); | 419 | mMyMachineName->setText( name ); |
420 | 420 | ||
421 | } | 421 | } |
422 | QString KSyncPrefsDialog::getLocalMachineName ( ) | 422 | QString KSyncPrefsDialog::getLocalMachineName ( ) |
423 | { | 423 | { |
424 | return mMyMachineName->text(); | 424 | return mMyMachineName->text(); |
425 | } | 425 | } |
426 | 426 | ||
427 | QStringList KSyncPrefsDialog::getSyncProfileNames() | 427 | QStringList KSyncPrefsDialog::getSyncProfileNames() |
428 | { | 428 | { |
429 | return mSyncProfileNames; | 429 | return mSyncProfileNames; |
430 | } | 430 | } |
431 | void KSyncPrefsDialog::usrReadConfig() | 431 | void KSyncPrefsDialog::usrReadConfig() |
432 | { | 432 | { |
433 | //KConfig *config = KOGlobals::config(); | 433 | //KConfig *config = KOGlobals::config(); |
434 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); | 434 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); |
435 | config.setGroup("SyncProfiles"); | 435 | config.setGroup("SyncProfiles"); |
436 | mSyncProfileNames =config.readListEntry("SyncProfileNames"); | 436 | mSyncProfileNames =config.readListEntry("SyncProfileNames"); |
437 | mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); | ||
437 | int i; | 438 | int i; |
438 | KSyncProfile* temp ; | 439 | KSyncProfile* temp ; |
439 | mSyncProfiles.clear(); | 440 | mSyncProfiles.clear(); |
440 | for ( i = 0; i < mSyncProfileNames.count();++i ) { | 441 | for ( i = 0; i < mSyncProfileNames.count();++i ) { |
441 | temp = new KSyncProfile (); | 442 | temp = new KSyncProfile (); |
442 | temp->setName( mSyncProfileNames[i] ); | 443 | temp->setName( mSyncProfileNames[i] ); |
443 | temp->readConfig( &config ); | 444 | temp->readConfig( &config ); |
444 | mSyncProfiles.append( temp ); | 445 | mSyncProfiles.append( temp ); |
445 | } | 446 | } |
446 | insertProfiles(); | 447 | insertProfiles(); |
447 | //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); | 448 | //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); |
448 | } | 449 | } |
449 | 450 | ||
450 | 451 | ||
451 | void KSyncPrefsDialog::usrWriteConfig() | 452 | void KSyncPrefsDialog::usrWriteConfig() |
452 | { | 453 | { |
453 | saveProfile(); | 454 | saveProfile(); |
454 | if ( currentSelection >= 0 ) | 455 | if ( currentSelection >= 0 ) |
455 | profileChanged(currentSelection); | 456 | profileChanged(currentSelection); |
456 | //KConfig *config = KOGlobals::config(); | 457 | //KConfig *config = KOGlobals::config(); |
457 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); | 458 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); |
458 | config.setGroup("SyncProfiles"); | 459 | config.setGroup("SyncProfiles"); |
459 | KSyncProfile* prof = mSyncProfiles.first(); | 460 | KSyncProfile* prof = mSyncProfiles.first(); |
460 | while ( prof ) { | 461 | while ( prof ) { |
461 | prof->writeConfig(&config); | 462 | prof->writeConfig(&config); |
462 | prof = mSyncProfiles.next(); | 463 | prof = mSyncProfiles.next(); |
463 | } | 464 | } |
464 | //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; | 465 | //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; |
465 | //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); | 466 | //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); |
466 | config.writeEntry("SyncProfileNames",&mSyncProfileNames); | 467 | config.writeEntry("SyncProfileNames",mSyncProfileNames); |
468 | QString name = mMyMachineName->text(); | ||
469 | config.writeEntry("LocalMachineName",name); | ||
467 | } | 470 | } |
468 | 471 | ||