author | zautrix <zautrix> | 2004-08-01 13:59:52 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-01 13:59:52 (UTC) |
commit | 43d6cf3619675856333d82ae2fcad6ce81d824b8 (patch) (unidiff) | |
tree | 40629720fce9e0840fc4ab50ab1ef746a7c07375 /libkdepim | |
parent | 47a3a79ddde4ab63d34ddb0ffaa92d65f04de8ad (diff) | |
download | kdepimpi-43d6cf3619675856333d82ae2fcad6ce81d824b8.zip kdepimpi-43d6cf3619675856333d82ae2fcad6ce81d824b8.tar.gz kdepimpi-43d6cf3619675856333d82ae2fcad6ce81d824b8.tar.bz2 |
fixed sync config
-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 | |||
@@ -245,224 +245,227 @@ void KSyncPrefsDialog::chooseFile() | |||
245 | void KSyncPrefsDialog::textChanged( const QString & s ) | 245 | void KSyncPrefsDialog::textChanged( const QString & s ) |
246 | { | 246 | { |
247 | if ( mProfileBox->count() == 0 ) | 247 | if ( mProfileBox->count() == 0 ) |
248 | return; | 248 | return; |
249 | if ( currentSelection < 3 ) { | 249 | if ( currentSelection < 3 ) { |
250 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); | 250 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); |
251 | mProfileBox->blockSignals( true ); | 251 | mProfileBox->blockSignals( true ); |
252 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); | 252 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); |
253 | mProfileBox->blockSignals( false ); | 253 | mProfileBox->blockSignals( false ); |
254 | return; | 254 | return; |
255 | } | 255 | } |
256 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); | 256 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); |
257 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; | 257 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; |
258 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; | 258 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; |
259 | prof->setName( s ); | 259 | prof->setName( s ); |
260 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; | 260 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; |
261 | } | 261 | } |
262 | void KSyncPrefsDialog::profileChanged( int item ) | 262 | void KSyncPrefsDialog::profileChanged( int item ) |
263 | { | 263 | { |
264 | //qDebug("KSyncPrefsDialog::profileChanged %d ", item ); | 264 | //qDebug("KSyncPrefsDialog::profileChanged %d ", item ); |
265 | KSyncProfile* prof; | 265 | KSyncProfile* prof; |
266 | saveProfile(); | 266 | saveProfile(); |
267 | currentSelection = item; | 267 | currentSelection = item; |
268 | prof = mSyncProfiles.at(item) ; | 268 | prof = mSyncProfiles.at(item) ; |
269 | mRemotePrecommand->setText(prof->getPreSyncCommand()); | 269 | mRemotePrecommand->setText(prof->getPreSyncCommand()); |
270 | mRemotePostcommand->setText(prof->getPostSyncCommand()); | 270 | mRemotePostcommand->setText(prof->getPostSyncCommand()); |
271 | mLocalTempFile->setText(prof->getLocalTempFile()); | 271 | mLocalTempFile->setText(prof->getLocalTempFile()); |
272 | mRemoteFile->setText(prof->getRemoteFileName()) ; | 272 | mRemoteFile->setText(prof->getRemoteFileName()) ; |
273 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); | 273 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); |
274 | mAskForPreferences->setChecked( prof->getAskForPreferences()); | 274 | mAskForPreferences->setChecked( prof->getAskForPreferences()); |
275 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); | 275 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); |
276 | mWriteBackFile->setChecked( prof->getWriteBackFile()); | 276 | mWriteBackFile->setChecked( prof->getWriteBackFile()); |
277 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); | 277 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); |
278 | 278 | ||
279 | switch ( prof->getSyncPrefs() ) { | 279 | switch ( prof->getSyncPrefs() ) { |
280 | case 0: | 280 | case 0: |
281 | loc->setChecked( true); | 281 | loc->setChecked( true); |
282 | break; | 282 | break; |
283 | case 1: | 283 | case 1: |
284 | rem->setChecked( true ); | 284 | rem->setChecked( true ); |
285 | break; | 285 | break; |
286 | case 2: | 286 | case 2: |
287 | newest->setChecked( true); | 287 | newest->setChecked( true); |
288 | break; | 288 | break; |
289 | case 3: | 289 | case 3: |
290 | ask->setChecked( true); | 290 | ask->setChecked( true); |
291 | break; | 291 | break; |
292 | case 4: | 292 | case 4: |
293 | f_loc->setChecked( true); | 293 | f_loc->setChecked( true); |
294 | break; | 294 | break; |
295 | case 5: | 295 | case 5: |
296 | f_rem->setChecked( true); | 296 | f_rem->setChecked( true); |
297 | break; | 297 | break; |
298 | case 6: | 298 | case 6: |
299 | //both->setChecked( true); | 299 | //both->setChecked( true); |
300 | break; | 300 | break; |
301 | default: | 301 | default: |
302 | break; | 302 | break; |
303 | } | 303 | } |
304 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; | 304 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; |
305 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync()); | 305 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync()); |
306 | proGr->setEnabled( item > 2 ); | 306 | proGr->setEnabled( item > 2 ); |
307 | if ( item < 3 ) { | 307 | if ( item < 3 ) { |
308 | localFileWidget->setEnabled(false); | 308 | localFileWidget->setEnabled(false); |
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 | ||