author | zautrix <zautrix> | 2005-11-25 15:49:13 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-25 15:49:13 (UTC) |
commit | 794a5204686ad9bfc16172b01db35f1f3b7683e5 (patch) (unidiff) | |
tree | 29da2cb35a4d6a0cd6885436087fe0659b58a9f4 | |
parent | 90b62d1158d00f162a258541e24aaed4c967480b (diff) | |
download | kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.zip kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.gz kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.bz2 |
sync
-rw-r--r-- | kaddressbook/kabcore.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 19 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 10 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 51 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 8 | ||||
-rw-r--r-- | libkdepim/ksyncprefsdialog.cpp | 6 |
9 files changed, 80 insertions, 21 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 033e537..2dea619 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2284,1212 +2284,1212 @@ void KABCore::addActionsManually() | |||
2284 | #endif | 2284 | #endif |
2285 | #ifndef DESKTOP_VERSION | 2285 | #ifndef DESKTOP_VERSION |
2286 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2286 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2287 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2287 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2288 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2288 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2289 | #endif | 2289 | #endif |
2290 | fileMenu->insertSeparator(); | 2290 | fileMenu->insertSeparator(); |
2291 | mActionQuit->plug( fileMenu ); | 2291 | mActionQuit->plug( fileMenu ); |
2292 | #ifdef _OL_IMPORT_ | 2292 | #ifdef _OL_IMPORT_ |
2293 | mActionImportOL->plug( ImportMenu ); | 2293 | mActionImportOL->plug( ImportMenu ); |
2294 | #endif | 2294 | #endif |
2295 | // edit menu | 2295 | // edit menu |
2296 | mActionUndo->plug( editMenu ); | 2296 | mActionUndo->plug( editMenu ); |
2297 | mActionRedo->plug( editMenu ); | 2297 | mActionRedo->plug( editMenu ); |
2298 | editMenu->insertSeparator(); | 2298 | editMenu->insertSeparator(); |
2299 | mActionCut->plug( editMenu ); | 2299 | mActionCut->plug( editMenu ); |
2300 | mActionCopy->plug( editMenu ); | 2300 | mActionCopy->plug( editMenu ); |
2301 | mActionPaste->plug( editMenu ); | 2301 | mActionPaste->plug( editMenu ); |
2302 | mActionDelete->plug( editMenu ); | 2302 | mActionDelete->plug( editMenu ); |
2303 | editMenu->insertSeparator(); | 2303 | editMenu->insertSeparator(); |
2304 | mActionSelectAll->plug( editMenu ); | 2304 | mActionSelectAll->plug( editMenu ); |
2305 | 2305 | ||
2306 | mActionSetFormattedName->plug( changeMenu ); | 2306 | mActionSetFormattedName->plug( changeMenu ); |
2307 | mActionRemoveVoice->plug( changeMenu ); | 2307 | mActionRemoveVoice->plug( changeMenu ); |
2308 | // settingsmings menu | 2308 | // settingsmings menu |
2309 | //US special menuentry to configure the addressbook resources. On KDE | 2309 | //US special menuentry to configure the addressbook resources. On KDE |
2310 | // you do that through the control center !!! | 2310 | // you do that through the control center !!! |
2311 | // settingsMenu->insertSeparator(); | 2311 | // settingsMenu->insertSeparator(); |
2312 | 2312 | ||
2313 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); | 2313 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); |
2314 | mActionConfigGlobal->plug( settingsMenu, 1 ); | 2314 | mActionConfigGlobal->plug( settingsMenu, 1 ); |
2315 | mActionConfigResources->plug( settingsMenu,2 ); | 2315 | mActionConfigResources->plug( settingsMenu,2 ); |
2316 | settingsMenu->insertSeparator(3); | 2316 | settingsMenu->insertSeparator(3); |
2317 | 2317 | ||
2318 | if ( mIsPart ) { | 2318 | if ( mIsPart ) { |
2319 | //US not implemented yet | 2319 | //US not implemented yet |
2320 | //mActionConfigShortcuts->plug( settingsMenu ); | 2320 | //mActionConfigShortcuts->plug( settingsMenu ); |
2321 | //mActionConfigureToolbars->plug( settingsMenu ); | 2321 | //mActionConfigureToolbars->plug( settingsMenu ); |
2322 | 2322 | ||
2323 | } else { | 2323 | } else { |
2324 | //US not implemented yet | 2324 | //US not implemented yet |
2325 | //mActionKeyBindings->plug( settingsMenu ); | 2325 | //mActionKeyBindings->plug( settingsMenu ); |
2326 | } | 2326 | } |
2327 | 2327 | ||
2328 | mActionEditCategories->plug( settingsMenu ); | 2328 | mActionEditCategories->plug( settingsMenu ); |
2329 | mActionManageCategories->plug( settingsMenu ); | 2329 | mActionManageCategories->plug( settingsMenu ); |
2330 | mActionJumpBar->plug( viewMenu,0 ); | 2330 | mActionJumpBar->plug( viewMenu,0 ); |
2331 | mActionDetails->plug( viewMenu,0 ); | 2331 | mActionDetails->plug( viewMenu,0 ); |
2332 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2332 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2333 | mActionDetails->plug( tb ); | 2333 | mActionDetails->plug( tb ); |
2334 | settingsMenu->insertSeparator(); | 2334 | settingsMenu->insertSeparator(); |
2335 | #ifndef DESKTOP_VERSION | 2335 | #ifndef DESKTOP_VERSION |
2336 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2336 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2337 | settingsMenu->insertSeparator(); | 2337 | settingsMenu->insertSeparator(); |
2338 | #endif | 2338 | #endif |
2339 | 2339 | ||
2340 | mActionWhoAmI->plug( settingsMenu ); | 2340 | mActionWhoAmI->plug( settingsMenu ); |
2341 | //mActionEditCategories->plug( changeMenu ); | 2341 | //mActionEditCategories->plug( changeMenu ); |
2342 | mActionCategories->plug( changeMenu ); | 2342 | mActionCategories->plug( changeMenu ); |
2343 | //mActionManageCategories->plug( changeMenu ); | 2343 | //mActionManageCategories->plug( changeMenu ); |
2344 | 2344 | ||
2345 | //mActionCategories->plug( settingsMenu ); | 2345 | //mActionCategories->plug( settingsMenu ); |
2346 | 2346 | ||
2347 | 2347 | ||
2348 | mActionWN->plug( helpMenu ); | 2348 | mActionWN->plug( helpMenu ); |
2349 | mActionStorageHowto->plug( helpMenu ); | 2349 | mActionStorageHowto->plug( helpMenu ); |
2350 | mActionSyncHowto->plug( helpMenu ); | 2350 | mActionSyncHowto->plug( helpMenu ); |
2351 | mActionKdeSyncHowto->plug( helpMenu ); | 2351 | mActionKdeSyncHowto->plug( helpMenu ); |
2352 | mActionMultiSyncHowto->plug( helpMenu ); | 2352 | mActionMultiSyncHowto->plug( helpMenu ); |
2353 | mActionFaq->plug( helpMenu ); | 2353 | mActionFaq->plug( helpMenu ); |
2354 | mActionLicence->plug( helpMenu ); | 2354 | mActionLicence->plug( helpMenu ); |
2355 | mActionAboutKAddressbook->plug( helpMenu ); | 2355 | mActionAboutKAddressbook->plug( helpMenu ); |
2356 | 2356 | ||
2357 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2357 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2358 | 2358 | ||
2359 | mActionSave->plug( tb ); | 2359 | mActionSave->plug( tb ); |
2360 | mViewManager->getFilterAction()->plug ( tb); | 2360 | mViewManager->getFilterAction()->plug ( tb); |
2361 | //LR hide filteraction on started in 480x640 | 2361 | //LR hide filteraction on started in 480x640 |
2362 | if (QApplication::desktop()->width() == 480 ) { | 2362 | if (QApplication::desktop()->width() == 480 ) { |
2363 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2363 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2364 | } | 2364 | } |
2365 | mActionUndo->plug( tb ); | 2365 | mActionUndo->plug( tb ); |
2366 | mActionDelete->plug( tb ); | 2366 | mActionDelete->plug( tb ); |
2367 | mActionRedo->plug( tb ); | 2367 | mActionRedo->plug( tb ); |
2368 | } else { | 2368 | } else { |
2369 | mActionSave->plug( tb ); | 2369 | mActionSave->plug( tb ); |
2370 | tb->enableMoving(false); | 2370 | tb->enableMoving(false); |
2371 | } | 2371 | } |
2372 | //mActionQuit->plug ( tb ); | 2372 | //mActionQuit->plug ( tb ); |
2373 | //tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2373 | //tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2374 | 2374 | ||
2375 | //US link the searchwidget first to this. | 2375 | //US link the searchwidget first to this. |
2376 | // The real linkage to the toolbar happens later. | 2376 | // The real linkage to the toolbar happens later. |
2377 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2377 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2378 | //US tb->insertItem( mIncSearchWidget ); | 2378 | //US tb->insertItem( mIncSearchWidget ); |
2379 | /*US | 2379 | /*US |
2380 | mIncSearchWidget = new IncSearchWidget( tb ); | 2380 | mIncSearchWidget = new IncSearchWidget( tb ); |
2381 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2381 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2382 | SLOT( incrementalSearch( const QString& ) ) ); | 2382 | SLOT( incrementalSearch( const QString& ) ) ); |
2383 | 2383 | ||
2384 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2384 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2385 | 2385 | ||
2386 | //US topLayout->addWidget( mJumpButtonBar ); | 2386 | //US topLayout->addWidget( mJumpButtonBar ); |
2387 | this->layout()->add( mJumpButtonBar ); | 2387 | this->layout()->add( mJumpButtonBar ); |
2388 | */ | 2388 | */ |
2389 | 2389 | ||
2390 | #endif //KAB_EMBEDDED | 2390 | #endif //KAB_EMBEDDED |
2391 | 2391 | ||
2392 | mActionExport2phone->plug( ExportMenu ); | 2392 | mActionExport2phone->plug( ExportMenu ); |
2393 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2393 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2394 | syncManager->fillSyncMenu(); | 2394 | syncManager->fillSyncMenu(); |
2395 | 2395 | ||
2396 | } | 2396 | } |
2397 | void KABCore::showLicence() | 2397 | void KABCore::showLicence() |
2398 | { | 2398 | { |
2399 | KApplication::showLicence(); | 2399 | KApplication::showLicence(); |
2400 | } | 2400 | } |
2401 | 2401 | ||
2402 | void KABCore::manageCategories( ) | 2402 | void KABCore::manageCategories( ) |
2403 | { | 2403 | { |
2404 | KABCatPrefs* cp = new KABCatPrefs(); | 2404 | KABCatPrefs* cp = new KABCatPrefs(); |
2405 | cp->show(); | 2405 | cp->show(); |
2406 | int w =cp->sizeHint().width() ; | 2406 | int w =cp->sizeHint().width() ; |
2407 | int h = cp->sizeHint().height() ; | 2407 | int h = cp->sizeHint().height() ; |
2408 | int dw = QApplication::desktop()->width(); | 2408 | int dw = QApplication::desktop()->width(); |
2409 | int dh = QApplication::desktop()->height(); | 2409 | int dh = QApplication::desktop()->height(); |
2410 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2410 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2411 | if ( !cp->exec() ) { | 2411 | if ( !cp->exec() ) { |
2412 | delete cp; | 2412 | delete cp; |
2413 | return; | 2413 | return; |
2414 | } | 2414 | } |
2415 | int count = 0; | 2415 | int count = 0; |
2416 | int cc = 0; | 2416 | int cc = 0; |
2417 | message( i18n("Please wait, processing categories...")); | 2417 | message( i18n("Please wait, processing categories...")); |
2418 | if ( cp->addCat() ) { | 2418 | if ( cp->addCat() ) { |
2419 | KABC::AddressBook::Iterator it; | 2419 | KABC::AddressBook::Iterator it; |
2420 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2420 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2421 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2421 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2422 | ++cc; | 2422 | ++cc; |
2423 | if ( cc %10 == 0) | 2423 | if ( cc %10 == 0) |
2424 | message(i18n("Processing contact #%1").arg(cc)); | 2424 | message(i18n("Processing contact #%1").arg(cc)); |
2425 | QStringList catIncList = (*it).categories(); | 2425 | QStringList catIncList = (*it).categories(); |
2426 | int i; | 2426 | int i; |
2427 | for( i = 0; i< catIncList.count(); ++i ) { | 2427 | for( i = 0; i< catIncList.count(); ++i ) { |
2428 | if ( !catList.contains (catIncList[i])) { | 2428 | if ( !catList.contains (catIncList[i])) { |
2429 | catList.append( catIncList[i] ); | 2429 | catList.append( catIncList[i] ); |
2430 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2430 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2431 | ++count; | 2431 | ++count; |
2432 | } | 2432 | } |
2433 | } | 2433 | } |
2434 | } | 2434 | } |
2435 | catList.sort(); | 2435 | catList.sort(); |
2436 | KABPrefs::instance()->mCustomCategories = catList; | 2436 | KABPrefs::instance()->mCustomCategories = catList; |
2437 | KABPrefs::instance()->writeConfig(); | 2437 | KABPrefs::instance()->writeConfig(); |
2438 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2438 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2439 | } else { | 2439 | } else { |
2440 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2440 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2441 | QStringList catIncList; | 2441 | QStringList catIncList; |
2442 | QStringList newCatList; | 2442 | QStringList newCatList; |
2443 | KABC::AddressBook::Iterator it; | 2443 | KABC::AddressBook::Iterator it; |
2444 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2444 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2445 | ++cc; | 2445 | ++cc; |
2446 | if ( cc %10 == 0) | 2446 | if ( cc %10 == 0) |
2447 | message(i18n("Processing contact #%1").arg(cc)); | 2447 | message(i18n("Processing contact #%1").arg(cc)); |
2448 | QStringList catIncList = (*it).categories(); | 2448 | QStringList catIncList = (*it).categories(); |
2449 | int i; | 2449 | int i; |
2450 | if ( catIncList.count() ) { | 2450 | if ( catIncList.count() ) { |
2451 | newCatList.clear(); | 2451 | newCatList.clear(); |
2452 | for( i = 0; i< catIncList.count(); ++i ) { | 2452 | for( i = 0; i< catIncList.count(); ++i ) { |
2453 | if ( catList.contains (catIncList[i])) { | 2453 | if ( catList.contains (catIncList[i])) { |
2454 | newCatList.append( catIncList[i] ); | 2454 | newCatList.append( catIncList[i] ); |
2455 | } | 2455 | } |
2456 | } | 2456 | } |
2457 | newCatList.sort(); | 2457 | newCatList.sort(); |
2458 | (*it).setCategories( newCatList ); | 2458 | (*it).setCategories( newCatList ); |
2459 | mAddressBook->insertAddressee( (*it) ); | 2459 | mAddressBook->insertAddressee( (*it) ); |
2460 | } | 2460 | } |
2461 | } | 2461 | } |
2462 | setModified( true ); | 2462 | setModified( true ); |
2463 | mViewManager->refreshView(); | 2463 | mViewManager->refreshView(); |
2464 | message( i18n("Removing categories done!")); | 2464 | message( i18n("Removing categories done!")); |
2465 | } | 2465 | } |
2466 | delete cp; | 2466 | delete cp; |
2467 | } | 2467 | } |
2468 | void KABCore::removeVoice() | 2468 | void KABCore::removeVoice() |
2469 | { | 2469 | { |
2470 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2470 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2471 | return; | 2471 | return; |
2472 | XXPortSelectDialog dlg( this, false, this ); | 2472 | XXPortSelectDialog dlg( this, false, this ); |
2473 | if ( !dlg.exec() ) | 2473 | if ( !dlg.exec() ) |
2474 | return; | 2474 | return; |
2475 | mAddressBook->setUntagged(); | 2475 | mAddressBook->setUntagged(); |
2476 | dlg.tagSelected(); | 2476 | dlg.tagSelected(); |
2477 | message(i18n("Removing voice..."), false ); | 2477 | message(i18n("Removing voice..."), false ); |
2478 | KABC::AddressBook::Iterator it; | 2478 | KABC::AddressBook::Iterator it; |
2479 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2479 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2480 | if ( (*it).tagged() ) { | 2480 | if ( (*it).tagged() ) { |
2481 | (*it).removeVoice(); | 2481 | (*it).removeVoice(); |
2482 | } | 2482 | } |
2483 | } | 2483 | } |
2484 | message(i18n("Refreshing view...") ); | 2484 | message(i18n("Refreshing view...") ); |
2485 | mViewManager->refreshView( "" ); | 2485 | mViewManager->refreshView( "" ); |
2486 | Addressee add; | 2486 | Addressee add; |
2487 | mDetails->setAddressee( add ); | 2487 | mDetails->setAddressee( add ); |
2488 | message(i18n("Remove voice completed!") ); | 2488 | message(i18n("Remove voice completed!") ); |
2489 | 2489 | ||
2490 | 2490 | ||
2491 | 2491 | ||
2492 | } | 2492 | } |
2493 | 2493 | ||
2494 | void KABCore::setFormattedName() | 2494 | void KABCore::setFormattedName() |
2495 | { | 2495 | { |
2496 | KABFormatPrefs setpref; | 2496 | KABFormatPrefs setpref; |
2497 | if ( !setpref.exec() ) { | 2497 | if ( !setpref.exec() ) { |
2498 | return; | 2498 | return; |
2499 | } | 2499 | } |
2500 | XXPortSelectDialog dlg( this, false, this ); | 2500 | XXPortSelectDialog dlg( this, false, this ); |
2501 | if ( !dlg.exec() ) | 2501 | if ( !dlg.exec() ) |
2502 | return; | 2502 | return; |
2503 | mAddressBook->setUntagged(); | 2503 | mAddressBook->setUntagged(); |
2504 | dlg.tagSelected(); | 2504 | dlg.tagSelected(); |
2505 | int count = 0; | 2505 | int count = 0; |
2506 | KABC::AddressBook::Iterator it; | 2506 | KABC::AddressBook::Iterator it; |
2507 | bool modified = false; | 2507 | bool modified = false; |
2508 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2508 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2509 | if ( (*it).tagged() ) { | 2509 | if ( (*it).tagged() ) { |
2510 | if ( (*it).uid().left( 2 ) == "la" ) | 2510 | if ( (*it).uid().left( 2 ) == "la" ) |
2511 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) | 2511 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) |
2512 | continue; | 2512 | continue; |
2513 | ++count; | 2513 | ++count; |
2514 | if ( count %10 == 0 ) | 2514 | if ( count %10 == 0 ) |
2515 | message(i18n("Changing contact #%1").arg( count ) ); | 2515 | message(i18n("Changing contact #%1").arg( count ) ); |
2516 | QString fName; | 2516 | QString fName; |
2517 | if ( setpref.simple->isChecked() ) | 2517 | if ( setpref.simple->isChecked() ) |
2518 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2518 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2519 | else if ( setpref.full->isChecked() ) | 2519 | else if ( setpref.full->isChecked() ) |
2520 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2520 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2521 | else if ( setpref.reverse->isChecked() ) | 2521 | else if ( setpref.reverse->isChecked() ) |
2522 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2522 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2523 | else | 2523 | else |
2524 | fName = (*it).organization(); | 2524 | fName = (*it).organization(); |
2525 | if ( setpref.setCompany->isChecked() ) | 2525 | if ( setpref.setCompany->isChecked() ) |
2526 | if ( fName.isEmpty() || fName =="," ) | 2526 | if ( fName.isEmpty() || fName =="," ) |
2527 | fName = (*it).organization(); | 2527 | fName = (*it).organization(); |
2528 | (*it).setFormattedName( fName ); | 2528 | (*it).setFormattedName( fName ); |
2529 | (*it).setChanged( true ); | 2529 | (*it).setChanged( true ); |
2530 | modified = true; | 2530 | modified = true; |
2531 | (*it).setRevision( QDateTime::currentDateTime() ); | 2531 | (*it).setRevision( QDateTime::currentDateTime() ); |
2532 | } | 2532 | } |
2533 | } | 2533 | } |
2534 | message(i18n("Refreshing view...") ); | 2534 | message(i18n("Refreshing view...") ); |
2535 | if ( modified ) | 2535 | if ( modified ) |
2536 | setModified( true ); | 2536 | setModified( true ); |
2537 | Addressee add; | 2537 | Addressee add; |
2538 | mDetails->setAddressee( add ); | 2538 | mDetails->setAddressee( add ); |
2539 | if ( count == 0 ) | 2539 | if ( count == 0 ) |
2540 | message(i18n("No contact changed!") ); | 2540 | message(i18n("No contact changed!") ); |
2541 | else | 2541 | else |
2542 | message(i18n("%1 contacts changed!").arg( count ) ); | 2542 | message(i18n("%1 contacts changed!").arg( count ) ); |
2543 | } | 2543 | } |
2544 | 2544 | ||
2545 | void KABCore::clipboardDataChanged() | 2545 | void KABCore::clipboardDataChanged() |
2546 | { | 2546 | { |
2547 | 2547 | ||
2548 | if ( mReadWrite ) | 2548 | if ( mReadWrite ) |
2549 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2549 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2550 | 2550 | ||
2551 | } | 2551 | } |
2552 | 2552 | ||
2553 | void KABCore::updateActionMenu() | 2553 | void KABCore::updateActionMenu() |
2554 | { | 2554 | { |
2555 | UndoStack *undo = UndoStack::instance(); | 2555 | UndoStack *undo = UndoStack::instance(); |
2556 | RedoStack *redo = RedoStack::instance(); | 2556 | RedoStack *redo = RedoStack::instance(); |
2557 | 2557 | ||
2558 | if ( undo->isEmpty() ) | 2558 | if ( undo->isEmpty() ) |
2559 | mActionUndo->setText( i18n( "Undo" ) ); | 2559 | mActionUndo->setText( i18n( "Undo" ) ); |
2560 | else | 2560 | else |
2561 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2561 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2562 | 2562 | ||
2563 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2563 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2564 | 2564 | ||
2565 | if ( !redo->top() ) | 2565 | if ( !redo->top() ) |
2566 | mActionRedo->setText( i18n( "Redo" ) ); | 2566 | mActionRedo->setText( i18n( "Redo" ) ); |
2567 | else | 2567 | else |
2568 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2568 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2569 | 2569 | ||
2570 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2570 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2571 | } | 2571 | } |
2572 | 2572 | ||
2573 | void KABCore::configureKeyBindings() | 2573 | void KABCore::configureKeyBindings() |
2574 | { | 2574 | { |
2575 | #ifndef KAB_EMBEDDED | 2575 | #ifndef KAB_EMBEDDED |
2576 | KKeyDialog::configure( actionCollection(), true ); | 2576 | KKeyDialog::configure( actionCollection(), true ); |
2577 | #else //KAB_EMBEDDED | 2577 | #else //KAB_EMBEDDED |
2578 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2578 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2579 | #endif //KAB_EMBEDDED | 2579 | #endif //KAB_EMBEDDED |
2580 | } | 2580 | } |
2581 | 2581 | ||
2582 | #ifdef KAB_EMBEDDED | 2582 | #ifdef KAB_EMBEDDED |
2583 | void KABCore::configureResources() | 2583 | void KABCore::configureResources() |
2584 | { | 2584 | { |
2585 | KRES::KCMKResources dlg( this, "" , 0 ); | 2585 | KRES::KCMKResources dlg( this, "" , 0 ); |
2586 | 2586 | ||
2587 | if ( !dlg.exec() ) | 2587 | if ( !dlg.exec() ) |
2588 | return; | 2588 | return; |
2589 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2589 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2590 | } | 2590 | } |
2591 | #endif //KAB_EMBEDDED | 2591 | #endif //KAB_EMBEDDED |
2592 | 2592 | ||
2593 | 2593 | ||
2594 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2594 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2595 | * for the attendees list of an event. | 2595 | * for the attendees list of an event. |
2596 | */ | 2596 | */ |
2597 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2597 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2598 | { | 2598 | { |
2599 | qDebug("KABCore::requestForNameEmailUidList "); | 2599 | qDebug("KABCore::requestForNameEmailUidList "); |
2600 | bool ok = false; | 2600 | bool ok = false; |
2601 | mEmailSourceChannel = sourceChannel; | 2601 | mEmailSourceChannel = sourceChannel; |
2602 | mEmailSourceUID = uid; | 2602 | mEmailSourceUID = uid; |
2603 | QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); | 2603 | QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); |
2604 | //callContactdialog(); | 2604 | //callContactdialog(); |
2605 | #if 0 | 2605 | #if 0 |
2606 | int wid = uid.toInt( &ok ); | 2606 | int wid = uid.toInt( &ok ); |
2607 | qDebug("UID %s ", uid.latin1()); | 2607 | qDebug("UID %s ", uid.latin1()); |
2608 | if ( ok ) { | 2608 | if ( ok ) { |
2609 | if ( wid != QApplication::desktop()->width() ) { | 2609 | if ( wid != QApplication::desktop()->width() ) { |
2610 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); | 2610 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); |
2611 | message( i18n("Resizing, please wait...") ); | 2611 | message( i18n("Resizing, please wait...") ); |
2612 | mMainWindow->showMinimized(); | 2612 | mMainWindow->showMinimized(); |
2613 | /* | 2613 | /* |
2614 | { | 2614 | { |
2615 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2615 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2616 | } | 2616 | } |
2617 | */ | 2617 | */ |
2618 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); | 2618 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); |
2619 | return; | 2619 | return; |
2620 | } | 2620 | } |
2621 | 2621 | ||
2622 | } else { | 2622 | } else { |
2623 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); | 2623 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); |
2624 | } | 2624 | } |
2625 | callContactdialog(); | 2625 | callContactdialog(); |
2626 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2626 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2627 | #endif | 2627 | #endif |
2628 | } | 2628 | } |
2629 | void KABCore::resizeAndCallContactdialog() | 2629 | void KABCore::resizeAndCallContactdialog() |
2630 | { | 2630 | { |
2631 | updateMainWindow(); | 2631 | updateMainWindow(); |
2632 | QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); | 2632 | QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); |
2633 | } | 2633 | } |
2634 | 2634 | ||
2635 | void KABCore::doRingSync() | 2635 | void KABCore::doRingSync() |
2636 | { | 2636 | { |
2637 | topLevelWidget()->raise(); | 2637 | topLevelWidget()->raise(); |
2638 | syncManager->multiSync( false ); | 2638 | syncManager->multiSync( false ); |
2639 | } | 2639 | } |
2640 | void KABCore::callContactdialog() | 2640 | void KABCore::callContactdialog() |
2641 | { | 2641 | { |
2642 | static bool running = false; | 2642 | static bool running = false; |
2643 | if (running) return; | 2643 | if (running) return; |
2644 | running = true; | 2644 | running = true; |
2645 | QStringList nameList; | 2645 | QStringList nameList; |
2646 | QStringList emailList; | 2646 | QStringList emailList; |
2647 | QStringList uidList; | 2647 | QStringList uidList; |
2648 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); | 2648 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); |
2649 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2649 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2650 | uint i=0; | 2650 | uint i=0; |
2651 | for (i=0; i < list.count(); i++) | 2651 | for (i=0; i < list.count(); i++) |
2652 | { | 2652 | { |
2653 | nameList.append(list[i].realName()); | 2653 | nameList.append(list[i].realName()); |
2654 | emailList.append(list[i].preferredEmail()); | 2654 | emailList.append(list[i].preferredEmail()); |
2655 | uidList.append(list[i].uid()); | 2655 | uidList.append(list[i].uid()); |
2656 | } | 2656 | } |
2657 | QString uid = mEmailSourceUID; | 2657 | QString uid = mEmailSourceUID; |
2658 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); | 2658 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); |
2659 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); | 2659 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); |
2660 | running = false; | 2660 | running = false; |
2661 | } | 2661 | } |
2662 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2662 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2663 | * to put them into the calendar. | 2663 | * to put them into the calendar. |
2664 | */ | 2664 | */ |
2665 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2665 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2666 | { | 2666 | { |
2667 | // qDebug("KABCore::requestForBirthdayList"); | 2667 | // qDebug("KABCore::requestForBirthdayList"); |
2668 | QStringList birthdayList; | 2668 | QStringList birthdayList; |
2669 | QStringList anniversaryList; | 2669 | QStringList anniversaryList; |
2670 | QStringList realNameList; | 2670 | QStringList realNameList; |
2671 | QStringList preferredEmailList; | 2671 | QStringList preferredEmailList; |
2672 | QStringList assembledNameList; | 2672 | QStringList assembledNameList; |
2673 | QStringList uidList; | 2673 | QStringList uidList; |
2674 | 2674 | ||
2675 | KABC::AddressBook::Iterator it; | 2675 | KABC::AddressBook::Iterator it; |
2676 | 2676 | ||
2677 | int count = 0; | 2677 | int count = 0; |
2678 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2678 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2679 | ++count; | 2679 | ++count; |
2680 | } | 2680 | } |
2681 | QProgressBar bar(count,0 ); | 2681 | QProgressBar bar(count,0 ); |
2682 | int w = 300; | 2682 | int w = 300; |
2683 | if ( QApplication::desktop()->width() < 320 ) | 2683 | if ( QApplication::desktop()->width() < 320 ) |
2684 | w = 220; | 2684 | w = 220; |
2685 | int h = bar.sizeHint().height() ; | 2685 | int h = bar.sizeHint().height() ; |
2686 | int dw = QApplication::desktop()->width(); | 2686 | int dw = QApplication::desktop()->width(); |
2687 | int dh = QApplication::desktop()->height(); | 2687 | int dh = QApplication::desktop()->height(); |
2688 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2688 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2689 | bar.show(); | 2689 | bar.show(); |
2690 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2690 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2691 | qApp->processEvents(); | 2691 | qApp->processEvents(); |
2692 | 2692 | ||
2693 | QDate bday; | 2693 | QDate bday; |
2694 | QString anni; | 2694 | QString anni; |
2695 | QString formattedbday; | 2695 | QString formattedbday; |
2696 | 2696 | ||
2697 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2697 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2698 | { | 2698 | { |
2699 | if ( ! bar.isVisible() ) | 2699 | if ( ! bar.isVisible() ) |
2700 | return; | 2700 | return; |
2701 | bar.setProgress( count++ ); | 2701 | bar.setProgress( count++ ); |
2702 | qApp->processEvents(); | 2702 | qApp->processEvents(); |
2703 | bday = (*it).birthday().date(); | 2703 | bday = (*it).birthday().date(); |
2704 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2704 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2705 | 2705 | ||
2706 | if ( bday.isValid() || !anni.isEmpty()) | 2706 | if ( bday.isValid() || !anni.isEmpty()) |
2707 | { | 2707 | { |
2708 | if (bday.isValid()) | 2708 | if (bday.isValid()) |
2709 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2709 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2710 | else | 2710 | else |
2711 | formattedbday = "NOTVALID"; | 2711 | formattedbday = "NOTVALID"; |
2712 | if (anni.isEmpty()) | 2712 | if (anni.isEmpty()) |
2713 | anni = "INVALID"; | 2713 | anni = "INVALID"; |
2714 | 2714 | ||
2715 | birthdayList.append(formattedbday); | 2715 | birthdayList.append(formattedbday); |
2716 | anniversaryList.append(anni); //should be ISODate | 2716 | anniversaryList.append(anni); //should be ISODate |
2717 | realNameList.append((*it).realName()); | 2717 | realNameList.append((*it).realName()); |
2718 | preferredEmailList.append((*it).preferredEmail()); | 2718 | preferredEmailList.append((*it).preferredEmail()); |
2719 | assembledNameList.append((*it).realName()); | 2719 | assembledNameList.append((*it).realName()); |
2720 | uidList.append((*it).uid()); | 2720 | uidList.append((*it).uid()); |
2721 | 2721 | ||
2722 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2722 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2723 | } | 2723 | } |
2724 | } | 2724 | } |
2725 | 2725 | ||
2726 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2726 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2727 | 2727 | ||
2728 | } | 2728 | } |
2729 | 2729 | ||
2730 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2730 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2731 | */ | 2731 | */ |
2732 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2732 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2733 | { | 2733 | { |
2734 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2734 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2735 | 2735 | ||
2736 | QString foundUid = QString::null; | 2736 | QString foundUid = QString::null; |
2737 | if ( ! uid.isEmpty() ) { | 2737 | if ( ! uid.isEmpty() ) { |
2738 | Addressee adrr = mAddressBook->findByUid( uid ); | 2738 | Addressee adrr = mAddressBook->findByUid( uid ); |
2739 | if ( !adrr.isEmpty() ) { | 2739 | if ( !adrr.isEmpty() ) { |
2740 | foundUid = uid; | 2740 | foundUid = uid; |
2741 | } | 2741 | } |
2742 | if ( email == "sendbacklist" ) { | 2742 | if ( email == "sendbacklist" ) { |
2743 | //qDebug("ssssssssssssssssssssssend "); | 2743 | //qDebug("ssssssssssssssssssssssend "); |
2744 | QStringList nameList; | 2744 | QStringList nameList; |
2745 | QStringList emailList; | 2745 | QStringList emailList; |
2746 | QStringList uidList; | 2746 | QStringList uidList; |
2747 | nameList.append(adrr.realName()); | 2747 | nameList.append(adrr.realName()); |
2748 | emailList = adrr.emails(); | 2748 | emailList = adrr.emails(); |
2749 | uidList.append( adrr.preferredEmail()); | 2749 | uidList.append( adrr.preferredEmail()); |
2750 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2750 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2751 | return; | 2751 | return; |
2752 | } | 2752 | } |
2753 | 2753 | ||
2754 | } | 2754 | } |
2755 | 2755 | ||
2756 | if ( email == "sendbacklist" ) | 2756 | if ( email == "sendbacklist" ) |
2757 | return; | 2757 | return; |
2758 | if (foundUid.isEmpty()) | 2758 | if (foundUid.isEmpty()) |
2759 | { | 2759 | { |
2760 | //find the uid of the person first | 2760 | //find the uid of the person first |
2761 | Addressee::List namelist; | 2761 | Addressee::List namelist; |
2762 | Addressee::List emaillist; | 2762 | Addressee::List emaillist; |
2763 | 2763 | ||
2764 | if (!name.isEmpty()) | 2764 | if (!name.isEmpty()) |
2765 | namelist = mAddressBook->findByName( name ); | 2765 | namelist = mAddressBook->findByName( name ); |
2766 | 2766 | ||
2767 | if (!email.isEmpty()) | 2767 | if (!email.isEmpty()) |
2768 | emaillist = mAddressBook->findByEmail( email ); | 2768 | emaillist = mAddressBook->findByEmail( email ); |
2769 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2769 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2770 | //check if we have a match in Namelist and Emaillist | 2770 | //check if we have a match in Namelist and Emaillist |
2771 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2771 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2772 | foundUid = emaillist[0].uid(); | 2772 | foundUid = emaillist[0].uid(); |
2773 | } | 2773 | } |
2774 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2774 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2775 | foundUid = namelist[0].uid(); | 2775 | foundUid = namelist[0].uid(); |
2776 | else | 2776 | else |
2777 | { | 2777 | { |
2778 | for (int i = 0; i < namelist.count(); i++) | 2778 | for (int i = 0; i < namelist.count(); i++) |
2779 | { | 2779 | { |
2780 | for (int j = 0; j < emaillist.count(); j++) | 2780 | for (int j = 0; j < emaillist.count(); j++) |
2781 | { | 2781 | { |
2782 | if (namelist[i] == emaillist[j]) | 2782 | if (namelist[i] == emaillist[j]) |
2783 | { | 2783 | { |
2784 | foundUid = namelist[i].uid(); | 2784 | foundUid = namelist[i].uid(); |
2785 | } | 2785 | } |
2786 | } | 2786 | } |
2787 | } | 2787 | } |
2788 | } | 2788 | } |
2789 | } | 2789 | } |
2790 | else | 2790 | else |
2791 | { | 2791 | { |
2792 | foundUid = uid; | 2792 | foundUid = uid; |
2793 | } | 2793 | } |
2794 | 2794 | ||
2795 | if (!foundUid.isEmpty()) | 2795 | if (!foundUid.isEmpty()) |
2796 | { | 2796 | { |
2797 | 2797 | ||
2798 | // raise Ka/Pi if it is in the background | 2798 | // raise Ka/Pi if it is in the background |
2799 | #ifndef DESKTOP_VERSION | 2799 | #ifndef DESKTOP_VERSION |
2800 | #ifndef KORG_NODCOP | 2800 | #ifndef KORG_NODCOP |
2801 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2801 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2802 | #endif | 2802 | #endif |
2803 | #endif | 2803 | #endif |
2804 | 2804 | ||
2805 | mMainWindow->showMaximized(); | 2805 | mMainWindow->showMaximized(); |
2806 | mMainWindow-> raise(); | 2806 | mMainWindow-> raise(); |
2807 | 2807 | ||
2808 | mViewManager->setSelected( "", false); | 2808 | mViewManager->setSelected( "", false); |
2809 | mViewManager->refreshView( "" ); | 2809 | mViewManager->refreshView( "" ); |
2810 | mViewManager->setSelected( foundUid, true ); | 2810 | mViewManager->setSelected( foundUid, true ); |
2811 | mViewManager->refreshView( foundUid ); | 2811 | mViewManager->refreshView( foundUid ); |
2812 | 2812 | ||
2813 | if ( !mMultipleViewsAtOnce ) | 2813 | if ( !mMultipleViewsAtOnce ) |
2814 | { | 2814 | { |
2815 | setDetailsVisible( true ); | 2815 | setDetailsVisible( true ); |
2816 | mActionDetails->setChecked(true); | 2816 | mActionDetails->setChecked(true); |
2817 | } | 2817 | } |
2818 | } | 2818 | } |
2819 | } | 2819 | } |
2820 | void KABCore::storagehowto() | 2820 | void KABCore::storagehowto() |
2821 | { | 2821 | { |
2822 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); | 2822 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); |
2823 | } | 2823 | } |
2824 | void KABCore::whatsnew() | 2824 | void KABCore::whatsnew() |
2825 | { | 2825 | { |
2826 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2826 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2827 | } | 2827 | } |
2828 | void KABCore::synchowto() | 2828 | void KABCore::synchowto() |
2829 | { | 2829 | { |
2830 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2830 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2831 | } | 2831 | } |
2832 | void KABCore::kdesynchowto() | 2832 | void KABCore::kdesynchowto() |
2833 | { | 2833 | { |
2834 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2834 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2835 | } | 2835 | } |
2836 | void KABCore::multisynchowto() | 2836 | void KABCore::multisynchowto() |
2837 | { | 2837 | { |
2838 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2838 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2839 | } | 2839 | } |
2840 | void KABCore::faq() | 2840 | void KABCore::faq() |
2841 | { | 2841 | { |
2842 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2842 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2843 | } | 2843 | } |
2844 | 2844 | ||
2845 | #include <libkcal/syncdefines.h> | 2845 | #include <libkcal/syncdefines.h> |
2846 | 2846 | ||
2847 | KABC::Addressee KABCore::getLastSyncAddressee() | 2847 | KABC::Addressee KABCore::getLastSyncAddressee() |
2848 | { | 2848 | { |
2849 | Addressee lse; | 2849 | Addressee lse; |
2850 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2850 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2851 | 2851 | ||
2852 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2852 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2853 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2853 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2854 | if (lse.isEmpty()) { | 2854 | if (lse.isEmpty()) { |
2855 | qDebug("KA: Creating new last-syncAddressee "); | 2855 | qDebug("KA: Creating new last-syncAddressee "); |
2856 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2856 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2857 | QString sum = ""; | 2857 | QString sum = ""; |
2858 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2858 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2859 | sum = "E: "; | 2859 | sum = "E: "; |
2860 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2860 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2861 | lse.setRevision( mLastAddressbookSync ); | 2861 | lse.setRevision( mLastAddressbookSync ); |
2862 | lse.setCategories( i18n("SyncEvent") ); | 2862 | lse.setCategories( i18n("SyncEvent") ); |
2863 | mAddressBook->insertAddressee( lse ); | 2863 | mAddressBook->insertAddressee( lse ); |
2864 | } | 2864 | } |
2865 | return lse; | 2865 | return lse; |
2866 | } | 2866 | } |
2867 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2867 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2868 | { | 2868 | { |
2869 | 2869 | ||
2870 | //void setZaurusId(int id); | 2870 | //void setZaurusId(int id); |
2871 | // int zaurusId() const; | 2871 | // int zaurusId() const; |
2872 | // void setZaurusUid(int id); | 2872 | // void setZaurusUid(int id); |
2873 | // int zaurusUid() const; | 2873 | // int zaurusUid() const; |
2874 | // void setZaurusStat(int id); | 2874 | // void setZaurusStat(int id); |
2875 | // int zaurusStat() const; | 2875 | // int zaurusStat() const; |
2876 | // 0 equal | 2876 | // 0 equal |
2877 | // 1 take local | 2877 | // 1 take local |
2878 | // 2 take remote | 2878 | // 2 take remote |
2879 | // 3 cancel | 2879 | // 3 cancel |
2880 | QDateTime lastSync = mLastAddressbookSync; | 2880 | QDateTime lastSync = mLastAddressbookSync; |
2881 | QDateTime localMod = local->revision(); | 2881 | QDateTime localMod = local->revision(); |
2882 | QDateTime remoteMod = remote->revision(); | 2882 | QDateTime remoteMod = remote->revision(); |
2883 | 2883 | ||
2884 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2884 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2885 | 2885 | ||
2886 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2886 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2887 | bool remCh, locCh; | 2887 | bool remCh, locCh; |
2888 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2888 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2889 | //if ( remCh ) | 2889 | //if ( remCh ) |
2890 | // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2890 | // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2891 | locCh = ( localMod > mLastAddressbookSync ); | 2891 | locCh = ( localMod > mLastAddressbookSync ); |
2892 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | 2892 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); |
2893 | if ( !remCh && ! locCh ) { | 2893 | if ( !remCh && ! locCh ) { |
2894 | //qDebug("both not changed "); | 2894 | //qDebug("both not changed "); |
2895 | lastSync = localMod.addDays(1); | 2895 | lastSync = localMod.addDays(1); |
2896 | if ( mode <= SYNC_PREF_ASK ) | 2896 | if ( mode <= SYNC_PREF_ASK ) |
2897 | return 0; | 2897 | return 0; |
2898 | } else { | 2898 | } else { |
2899 | if ( locCh ) { | 2899 | if ( locCh ) { |
2900 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2900 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2901 | lastSync = localMod.addDays( -1 ); | 2901 | lastSync = localMod.addDays( -1 ); |
2902 | if ( !remCh ) | 2902 | if ( !remCh ) |
2903 | remoteMod =( lastSync.addDays( -1 ) ); | 2903 | remoteMod =( lastSync.addDays( -1 ) ); |
2904 | } else { | 2904 | } else { |
2905 | //qDebug(" not loc changed "); | 2905 | //qDebug(" not loc changed "); |
2906 | lastSync = localMod.addDays( 1 ); | 2906 | lastSync = localMod.addDays( 1 ); |
2907 | if ( remCh ) { | 2907 | if ( remCh ) { |
2908 | //qDebug("rem changed "); | 2908 | //qDebug("rem changed "); |
2909 | remoteMod =( lastSync.addDays( 1 ) ); | 2909 | remoteMod =( lastSync.addDays( 1 ) ); |
2910 | } | 2910 | } |
2911 | 2911 | ||
2912 | } | 2912 | } |
2913 | } | 2913 | } |
2914 | full = true; | 2914 | full = true; |
2915 | if ( mode < SYNC_PREF_ASK ) | 2915 | if ( mode < SYNC_PREF_ASK ) |
2916 | mode = SYNC_PREF_ASK; | 2916 | mode = SYNC_PREF_ASK; |
2917 | } else { | 2917 | } else { |
2918 | if ( localMod == remoteMod ) | 2918 | if ( localMod == remoteMod ) |
2919 | return 0; | 2919 | return 0; |
2920 | 2920 | ||
2921 | } | 2921 | } |
2922 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2922 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2923 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2923 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2924 | //full = true; //debug only | 2924 | //full = true; //debug only |
2925 | if ( full ) { | 2925 | if ( full ) { |
2926 | bool equ = ( (*local) == (*remote) ); | 2926 | bool equ = ( (*local) == (*remote) ); |
2927 | if ( equ ) { | 2927 | if ( equ ) { |
2928 | //qDebug("equal "); | 2928 | //qDebug("equal "); |
2929 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2929 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2930 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2930 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2931 | } | 2931 | } |
2932 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2932 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2933 | return 0; | 2933 | return 0; |
2934 | 2934 | ||
2935 | }//else //debug only | 2935 | }//else //debug only |
2936 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2936 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2937 | } | 2937 | } |
2938 | int result; | 2938 | int result; |
2939 | bool localIsNew; | 2939 | bool localIsNew; |
2940 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2940 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2941 | 2941 | ||
2942 | if ( full && mode < SYNC_PREF_NEWEST ) | 2942 | if ( full && mode < SYNC_PREF_NEWEST ) |
2943 | mode = SYNC_PREF_ASK; | 2943 | mode = SYNC_PREF_ASK; |
2944 | 2944 | ||
2945 | switch( mode ) { | 2945 | switch( mode ) { |
2946 | case SYNC_PREF_LOCAL: | 2946 | case SYNC_PREF_LOCAL: |
2947 | if ( lastSync > remoteMod ) | 2947 | if ( lastSync > remoteMod ) |
2948 | return 1; | 2948 | return 1; |
2949 | if ( lastSync > localMod ) | 2949 | if ( lastSync > localMod ) |
2950 | return 2; | 2950 | return 2; |
2951 | return 1; | 2951 | return 1; |
2952 | break; | 2952 | break; |
2953 | case SYNC_PREF_REMOTE: | 2953 | case SYNC_PREF_REMOTE: |
2954 | if ( lastSync > localMod ) | 2954 | if ( lastSync > localMod ) |
2955 | return 2; | 2955 | return 2; |
2956 | if ( lastSync > remoteMod ) | 2956 | if ( lastSync > remoteMod ) |
2957 | return 1; | 2957 | return 1; |
2958 | return 2; | 2958 | return 2; |
2959 | break; | 2959 | break; |
2960 | case SYNC_PREF_NEWEST: | 2960 | case SYNC_PREF_NEWEST: |
2961 | if ( localMod > remoteMod ) | 2961 | if ( localMod > remoteMod ) |
2962 | return 1; | 2962 | return 1; |
2963 | else | 2963 | else |
2964 | return 2; | 2964 | return 2; |
2965 | break; | 2965 | break; |
2966 | case SYNC_PREF_ASK: | 2966 | case SYNC_PREF_ASK: |
2967 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2967 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2968 | if ( lastSync > remoteMod && lastSync > localMod) | 2968 | if ( lastSync > remoteMod && lastSync > localMod) |
2969 | return 0; | 2969 | return 0; |
2970 | if ( lastSync > remoteMod ) | 2970 | if ( lastSync > remoteMod ) |
2971 | return 1; | 2971 | return 1; |
2972 | if ( lastSync > localMod ) { | 2972 | if ( lastSync > localMod ) { |
2973 | return 2; | 2973 | return 2; |
2974 | } | 2974 | } |
2975 | localIsNew = localMod >= remoteMod; | 2975 | localIsNew = localMod >= remoteMod; |
2976 | //qDebug("conflict! ************************************** "); | 2976 | //qDebug("conflict! ************************************** "); |
2977 | { | 2977 | { |
2978 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2978 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2979 | result = acd.executeD(localIsNew); | 2979 | result = acd.executeD(localIsNew); |
2980 | return result; | 2980 | return result; |
2981 | } | 2981 | } |
2982 | break; | 2982 | break; |
2983 | case SYNC_PREF_FORCE_LOCAL: | 2983 | case SYNC_PREF_FORCE_LOCAL: |
2984 | return 1; | 2984 | return 1; |
2985 | break; | 2985 | break; |
2986 | case SYNC_PREF_FORCE_REMOTE: | 2986 | case SYNC_PREF_FORCE_REMOTE: |
2987 | return 2; | 2987 | return 2; |
2988 | break; | 2988 | break; |
2989 | 2989 | ||
2990 | default: | 2990 | default: |
2991 | // SYNC_PREF_TAKE_BOTH not implemented | 2991 | // SYNC_PREF_TAKE_BOTH not implemented |
2992 | break; | 2992 | break; |
2993 | } | 2993 | } |
2994 | return 0; | 2994 | return 0; |
2995 | } | 2995 | } |
2996 | 2996 | ||
2997 | 2997 | ||
2998 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2998 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2999 | { | 2999 | { |
3000 | bool syncOK = true; | 3000 | bool syncOK = true; |
3001 | int addedAddressee = 0; | 3001 | int addedAddressee = 0; |
3002 | int addedAddresseeR = 0; | 3002 | int addedAddresseeR = 0; |
3003 | int deletedAddresseeR = 0; | 3003 | int deletedAddresseeR = 0; |
3004 | int deletedAddresseeL = 0; | 3004 | int deletedAddresseeL = 0; |
3005 | int changedLocal = 0; | 3005 | int changedLocal = 0; |
3006 | int changedRemote = 0; | 3006 | int changedRemote = 0; |
3007 | int filteredIN = 0; | 3007 | int filteredIN = 0; |
3008 | int filteredOUT = 0; | 3008 | int filteredOUT = 0; |
3009 | 3009 | ||
3010 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 3010 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
3011 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3011 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3012 | 3012 | ||
3013 | //QPtrList<Addressee> el = local->rawAddressees(); | 3013 | //QPtrList<Addressee> el = local->rawAddressees(); |
3014 | Addressee addresseeR; | 3014 | Addressee addresseeR; |
3015 | QString uid; | 3015 | QString uid; |
3016 | int take; | 3016 | int take; |
3017 | Addressee addresseeL; | 3017 | Addressee addresseeL; |
3018 | Addressee addresseeRSync; | 3018 | Addressee addresseeRSync; |
3019 | Addressee addresseeLSync; | 3019 | Addressee addresseeLSync; |
3020 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 3020 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
3021 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 3021 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
3022 | bool fullDateRange = false; | 3022 | bool fullDateRange = false; |
3023 | local->resetTempSyncStat(); | 3023 | local->resetTempSyncStat(); |
3024 | mLastAddressbookSync = QDateTime::currentDateTime(); | 3024 | mLastAddressbookSync = QDateTime::currentDateTime(); |
3025 | if ( syncManager->syncWithDesktop() ) { | 3025 | if ( syncManager->syncWithDesktop() ) { |
3026 | // remote->removeSyncInfo( QString());//remove all info | 3026 | // remote->removeSyncInfo( QString());//remove all info |
3027 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 3027 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
3028 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 3028 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
3029 | qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 3029 | qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
3030 | } else { | 3030 | } else { |
3031 | qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 3031 | qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); |
3032 | } | 3032 | } |
3033 | } | 3033 | } |
3034 | QDateTime modifiedCalendar = mLastAddressbookSync; | 3034 | QDateTime modifiedCalendar = mLastAddressbookSync; |
3035 | addresseeLSync = getLastSyncAddressee(); | 3035 | addresseeLSync = getLastSyncAddressee(); |
3036 | qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 3036 | qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
3037 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 3037 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
3038 | if ( !addresseeR.isEmpty() ) { | 3038 | if ( !addresseeR.isEmpty() ) { |
3039 | addresseeRSync = addresseeR; | 3039 | addresseeRSync = addresseeR; |
3040 | remote->removeAddressee(addresseeR ); | 3040 | remote->removeAddressee(addresseeR ); |
3041 | 3041 | ||
3042 | } else { | 3042 | } else { |
3043 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3043 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3044 | addresseeRSync = addresseeLSync ; | 3044 | addresseeRSync = addresseeLSync ; |
3045 | } else { | 3045 | } else { |
3046 | //qDebug("FULLDATE 1"); | 3046 | //qDebug("FULLDATE 1"); |
3047 | fullDateRange = true; | 3047 | fullDateRange = true; |
3048 | Addressee newAdd; | 3048 | Addressee newAdd; |
3049 | addresseeRSync = newAdd; | 3049 | addresseeRSync = newAdd; |
3050 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 3050 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
3051 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 3051 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
3052 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3052 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3053 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 3053 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
3054 | } | 3054 | } |
3055 | } | 3055 | } |
3056 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 3056 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
3057 | // qDebug("FULLDATE 2"); | 3057 | // qDebug("FULLDATE 2"); |
3058 | fullDateRange = true; | 3058 | fullDateRange = true; |
3059 | } | 3059 | } |
3060 | if ( ! fullDateRange ) { | 3060 | if ( ! fullDateRange ) { |
3061 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 3061 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
3062 | 3062 | ||
3063 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 3063 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
3064 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 3064 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
3065 | fullDateRange = true; | 3065 | fullDateRange = true; |
3066 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 3066 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
3067 | } | 3067 | } |
3068 | } | 3068 | } |
3069 | // fullDateRange = true; // debug only! | 3069 | // fullDateRange = true; // debug only! |
3070 | if ( fullDateRange ) | 3070 | if ( fullDateRange ) |
3071 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 3071 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
3072 | else | 3072 | else |
3073 | mLastAddressbookSync = addresseeLSync.revision(); | 3073 | mLastAddressbookSync = addresseeLSync.revision(); |
3074 | // for resyncing if own file has changed | 3074 | // for resyncing if own file has changed |
3075 | // PENDING fixme later when implemented | 3075 | // PENDING fixme later when implemented |
3076 | #if 0 | 3076 | #if 0 |
3077 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 3077 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
3078 | mLastAddressbookSync = loadedFileVersion; | 3078 | mLastAddressbookSync = loadedFileVersion; |
3079 | qDebug("setting mLastAddressbookSync "); | 3079 | qDebug("setting mLastAddressbookSync "); |
3080 | } | 3080 | } |
3081 | #endif | 3081 | #endif |
3082 | 3082 | ||
3083 | 3083 | ||
3084 | // ********** setting filters **************** | 3084 | // ********** setting filters **************** |
3085 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); | 3085 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); |
3086 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); | 3086 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); |
3087 | 3087 | ||
3088 | //qDebug("*************************** "); | 3088 | //qDebug("*************************** "); |
3089 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 3089 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
3090 | QStringList er = remote->uidList(); | 3090 | QStringList er = remote->uidList(); |
3091 | Addressee inR ;//= er.first(); | 3091 | Addressee inR ;//= er.first(); |
3092 | Addressee inL; | 3092 | Addressee inL; |
3093 | 3093 | ||
3094 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 3094 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
3095 | 3095 | ||
3096 | int modulo = (er.count()/10)+1; | 3096 | int modulo = (er.count()/10)+1; |
3097 | int incCounter = 0; | 3097 | int incCounter = 0; |
3098 | while ( incCounter < er.count()) { | 3098 | while ( incCounter < er.count()) { |
3099 | if (syncManager->isProgressBarCanceled()) | 3099 | if (syncManager->isProgressBarCanceled()) |
3100 | return false; | 3100 | return false; |
3101 | if ( incCounter % modulo == 0 ) | 3101 | if ( incCounter % modulo == 0 ) |
3102 | syncManager->showProgressBar(incCounter); | 3102 | syncManager->showProgressBar(incCounter); |
3103 | 3103 | ||
3104 | uid = er[ incCounter ]; | 3104 | uid = er[ incCounter ]; |
3105 | bool skipIncidence = false; | 3105 | bool skipIncidence = false; |
3106 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3106 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3107 | skipIncidence = true; | 3107 | skipIncidence = true; |
3108 | QString idS,OidS; | 3108 | QString idS,OidS; |
3109 | qApp->processEvents(); | 3109 | qApp->processEvents(); |
3110 | if ( !skipIncidence ) { | 3110 | if ( !skipIncidence ) { |
3111 | inL = local->findByUid( uid ); | 3111 | inL = local->findByUid( uid ); |
3112 | inR = remote->findByUid( uid ); | 3112 | inR = remote->findByUid( uid ); |
3113 | //inL.setResource( 0 ); | 3113 | //inL.setResource( 0 ); |
3114 | //inR.setResource( 0 ); | 3114 | //inR.setResource( 0 ); |
3115 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 3115 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
3116 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3116 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3117 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 3117 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
3118 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 3118 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
3119 | if ( take == 3 ) | 3119 | if ( take == 3 ) |
3120 | return false; | 3120 | return false; |
3121 | if ( take == 1 ) {// take local ********************** | 3121 | if ( take == 1 ) {// take local ********************** |
3122 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3122 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3123 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3123 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3124 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3124 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3125 | local->insertAddressee( inL, false ); | 3125 | local->insertAddressee( inL, false ); |
3126 | idS = inR.externalUID(); | 3126 | idS = inR.externalUID(); |
3127 | OidS = inR.originalExternalUID(); | 3127 | OidS = inR.originalExternalUID(); |
3128 | } | 3128 | } |
3129 | else | 3129 | else |
3130 | idS = inR.IDStr(); | 3130 | idS = inR.IDStr(); |
3131 | remote->removeAddressee( inR ); | 3131 | remote->removeAddressee( inR ); |
3132 | inR = inL; | 3132 | inR = inL; |
3133 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 3133 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
3134 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3134 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3135 | inR.setOriginalExternalUID( OidS ); | 3135 | inR.setOriginalExternalUID( OidS ); |
3136 | inR.setExternalUID( idS ); | 3136 | inR.setExternalUID( idS ); |
3137 | if ( syncManager->syncWithDesktop() ) { | 3137 | if ( syncManager->syncWithDesktop() ) { |
3138 | inR.setIDStr("changed" ); | 3138 | inR.setIDStr("changed" ); |
3139 | } | 3139 | } |
3140 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 3140 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
3141 | } else { | 3141 | } else { |
3142 | inR.setIDStr( idS ); | 3142 | inR.setIDStr( idS ); |
3143 | } | 3143 | } |
3144 | inR.setResource( 0 ); | 3144 | inR.setResource( 0 ); |
3145 | remote->insertAddressee( inR , false); | 3145 | remote->insertAddressee( inR , false); |
3146 | ++changedRemote; | 3146 | ++changedRemote; |
3147 | } else { // take == 2 take remote ********************** | 3147 | } else { // take == 2 take remote ********************** |
3148 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3148 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3149 | if ( inR.revision().date().year() < 2004 ) | 3149 | if ( inR.revision().date().year() < 2004 ) |
3150 | inR.setRevision( modifiedCalendar ); | 3150 | inR.setRevision( modifiedCalendar ); |
3151 | } | 3151 | } |
3152 | idS = inL.IDStr(); | 3152 | idS = inL.IDStr(); |
3153 | local->removeAddressee( inL ); | 3153 | local->removeAddressee( inL ); |
3154 | inL = inR; | 3154 | inL = inR; |
3155 | inL.setIDStr( idS ); | 3155 | inL.setIDStr( idS ); |
3156 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3156 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3157 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3157 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3158 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3158 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3159 | } | 3159 | } |
3160 | inL.setResource( 0 ); | 3160 | inL.setResource( 0 ); |
3161 | local->insertAddressee( inL , false ); | 3161 | local->insertAddressee( inL , false ); |
3162 | ++changedLocal; | 3162 | ++changedLocal; |
3163 | } | 3163 | } |
3164 | } | 3164 | } |
3165 | } | 3165 | } |
3166 | } else { // no conflict ********** add or delete remote | 3166 | } else { // no conflict ********** add or delete remote |
3167 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { | 3167 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { |
3168 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3168 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3169 | QString des = addresseeLSync.note(); | 3169 | QString des = addresseeLSync.note(); |
3170 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 3170 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
3171 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 3171 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
3172 | remote->insertAddressee( inR, false ); | 3172 | remote->insertAddressee( inR, false ); |
3173 | ++deletedAddresseeR; | 3173 | ++deletedAddresseeR; |
3174 | } else { | 3174 | } else { |
3175 | inR.setRevision( modifiedCalendar ); | 3175 | inR.setRevision( modifiedCalendar ); |
3176 | remote->insertAddressee( inR, false ); | 3176 | remote->insertAddressee( inR, false ); |
3177 | inL = inR; | 3177 | inL = inR; |
3178 | inL.setIDStr( ":" ); | 3178 | inL.setIDStr( ":" ); |
3179 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3179 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3180 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3180 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3181 | inL.setResource( 0 ); | 3181 | inL.setResource( 0 ); |
3182 | local->insertAddressee( inL , false); | 3182 | local->insertAddressee( inL , false); |
3183 | ++addedAddressee; | 3183 | ++addedAddressee; |
3184 | } | 3184 | } |
3185 | } else { | 3185 | } else { |
3186 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 3186 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
3187 | inR.setRevision( modifiedCalendar ); | 3187 | inR.setRevision( modifiedCalendar ); |
3188 | remote->insertAddressee( inR, false ); | 3188 | remote->insertAddressee( inR, false ); |
3189 | inR.setResource( 0 ); | 3189 | inR.setResource( 0 ); |
3190 | local->insertAddressee( inR, false ); | 3190 | local->insertAddressee( inR, false ); |
3191 | ++addedAddressee; | 3191 | ++addedAddressee; |
3192 | } else { | 3192 | } else { |
3193 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3193 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
3194 | remote->removeAddressee( inR ); | 3194 | remote->removeAddressee( inR ); |
3195 | ++deletedAddresseeR; | 3195 | ++deletedAddresseeR; |
3196 | } | 3196 | } |
3197 | } | 3197 | } |
3198 | } else { | 3198 | } else { |
3199 | ++filteredIN; | 3199 | ++filteredIN; |
3200 | } | 3200 | } |
3201 | } | 3201 | } |
3202 | } | 3202 | } |
3203 | ++incCounter; | 3203 | ++incCounter; |
3204 | } | 3204 | } |
3205 | er.clear(); | 3205 | er.clear(); |
3206 | QStringList el = local->uidList(); | 3206 | QStringList el = local->uidList(); |
3207 | modulo = (el.count()/10)+1; | 3207 | modulo = (el.count()/10)+1; |
3208 | 3208 | ||
3209 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3209 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3210 | incCounter = 0; | 3210 | incCounter = 0; |
3211 | while ( incCounter < el.count()) { | 3211 | while ( incCounter < el.count()) { |
3212 | qApp->processEvents(); | 3212 | qApp->processEvents(); |
3213 | if (syncManager->isProgressBarCanceled()) | 3213 | if (syncManager->isProgressBarCanceled()) |
3214 | return false; | 3214 | return false; |
3215 | if ( incCounter % modulo == 0 ) | 3215 | if ( incCounter % modulo == 0 ) |
3216 | syncManager->showProgressBar(incCounter); | 3216 | syncManager->showProgressBar(incCounter); |
3217 | uid = el[ incCounter ]; | 3217 | uid = el[ incCounter ]; |
3218 | bool skipIncidence = false; | 3218 | bool skipIncidence = false; |
3219 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3219 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3220 | skipIncidence = true; | 3220 | skipIncidence = true; |
3221 | if ( !skipIncidence ) { | 3221 | if ( !skipIncidence ) { |
3222 | inL = local->findByUid( uid ); | 3222 | inL = local->findByUid( uid ); |
3223 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3223 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3224 | inR = remote->findByUid( uid ); | 3224 | inR = remote->findByUid( uid ); |
3225 | if ( inR.isEmpty() ){ | 3225 | if ( inR.isEmpty() ){ |
3226 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { | 3226 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { |
3227 | // no conflict ********** add or delete local | 3227 | // no conflict ********** add or delete local |
3228 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3228 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3229 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3229 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3230 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3230 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3231 | local->removeAddressee( inL ); | 3231 | local->removeAddressee( inL ); |
3232 | ++deletedAddresseeL; | 3232 | ++deletedAddresseeL; |
3233 | } else { | 3233 | } else { |
3234 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3234 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3235 | inL.removeID(mCurrentSyncDevice ); | 3235 | inL.removeID(mCurrentSyncDevice ); |
3236 | ++addedAddresseeR; | 3236 | ++addedAddresseeR; |
3237 | inL.setRevision( modifiedCalendar ); | 3237 | inL.setRevision( modifiedCalendar ); |
3238 | local->insertAddressee( inL, false ); | 3238 | local->insertAddressee( inL, false ); |
3239 | inR = inL; | 3239 | inR = inL; |
3240 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3240 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3241 | inR.setResource( 0 ); | 3241 | inR.setResource( 0 ); |
3242 | remote->insertAddressee( inR, false ); | 3242 | remote->insertAddressee( inR, false ); |
3243 | } | 3243 | } |
3244 | } | 3244 | } |
3245 | } else { | 3245 | } else { |
3246 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3246 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3247 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3247 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3248 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3248 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3249 | local->removeAddressee( inL ); | 3249 | local->removeAddressee( inL ); |
3250 | ++deletedAddresseeL; | 3250 | ++deletedAddresseeL; |
3251 | } else { | 3251 | } else { |
3252 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3252 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3253 | ++addedAddresseeR; | 3253 | ++addedAddresseeR; |
3254 | inL.setRevision( modifiedCalendar ); | 3254 | inL.setRevision( modifiedCalendar ); |
3255 | local->insertAddressee( inL, false ); | 3255 | local->insertAddressee( inL, false ); |
3256 | inR = inL; | 3256 | inR = inL; |
3257 | inR.setIDStr( ":" ); | 3257 | inR.setIDStr( ":" ); |
3258 | inR.setResource( 0 ); | 3258 | inR.setResource( 0 ); |
3259 | remote->insertAddressee( inR, false ); | 3259 | remote->insertAddressee( inR, false ); |
3260 | } | 3260 | } |
3261 | } | 3261 | } |
3262 | } | 3262 | } |
3263 | } else { | 3263 | } else { |
3264 | ++filteredOUT; | 3264 | ++filteredOUT; |
3265 | } | 3265 | } |
3266 | } | 3266 | } |
3267 | } | 3267 | } |
3268 | } | 3268 | } |
3269 | ++incCounter; | 3269 | ++incCounter; |
3270 | } | 3270 | } |
3271 | el.clear(); | 3271 | el.clear(); |
3272 | syncManager->hideProgressBar(); | 3272 | syncManager->hideProgressBar(); |
3273 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3273 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3274 | // get rid of micro seconds | 3274 | // get rid of micro seconds |
3275 | QTime t = mLastAddressbookSync.time(); | 3275 | QTime t = mLastAddressbookSync.time(); |
3276 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3276 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3277 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3277 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3278 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3278 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3279 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3279 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3280 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3280 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3281 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3281 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3282 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3282 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3283 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3283 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3284 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3284 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3285 | addresseeRSync.setNote( "" ) ; | 3285 | addresseeRSync.setNote( "" ) ; |
3286 | addresseeLSync.setNote( "" ); | 3286 | addresseeLSync.setNote( "" ); |
3287 | 3287 | ||
3288 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3288 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3289 | remote->insertAddressee( addresseeRSync, false ); | 3289 | remote->insertAddressee( addresseeRSync, false ); |
3290 | local->insertAddressee( addresseeLSync, false ); | 3290 | local->insertAddressee( addresseeLSync, false ); |
3291 | QString mes; | 3291 | QString mes; |
3292 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3292 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3293 | qDebug( mes ); | 3293 | qDebug( mes ); |
3294 | mes = i18n("Local addressbook changed!\n") +mes; | 3294 | mes = i18n("Local addressbook changed!\n") +mes; |
3295 | if ( syncManager->mShowSyncSummary ) { | 3295 | if ( syncManager->mShowSyncSummary ) { |
3296 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3296 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3297 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3297 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3298 | qDebug("KA: WB cancelled "); | 3298 | qDebug("KA: WB cancelled "); |
3299 | syncManager->mWriteBackFile = false; | 3299 | syncManager->mWriteBackFile = false; |
3300 | return syncOK; | 3300 | return syncOK; |
3301 | } | 3301 | } |
3302 | } | 3302 | } |
3303 | return syncOK; | 3303 | return syncOK; |
3304 | } | 3304 | } |
3305 | 3305 | ||
3306 | 3306 | ||
3307 | //this is a overwritten callbackmethods from the syncinterface | 3307 | //this is a overwritten callbackmethods from the syncinterface |
3308 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3308 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
3309 | { | 3309 | { |
3310 | 3310 | ||
3311 | //pending prepare addresseeview for output | 3311 | //pending prepare addresseeview for output |
3312 | //pending detect, if remote file has REV field. if not switch to external sync | 3312 | //pending detect, if remote file has REV field. if not switch to external sync |
3313 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3313 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3314 | if ( manager != syncManager ) | 3314 | if ( manager != syncManager ) |
3315 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3315 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3316 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3316 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3317 | 3317 | ||
3318 | AddressBook abLocal(filename,"syncContact"); | 3318 | AddressBook abLocal(filename,"syncContact"); |
3319 | bool syncOK = false; | 3319 | bool syncOK = false; |
3320 | if ( abLocal.load() ) { | 3320 | if ( abLocal.load() ) { |
3321 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3321 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3322 | bool external = false; | 3322 | bool external = false; |
3323 | bool isXML = false; | 3323 | bool isXML = false; |
3324 | if ( filename.right(4) == ".xml") { | 3324 | if ( filename.right(4) == ".xml") { |
3325 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3325 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3326 | isXML = true; | 3326 | isXML = true; |
3327 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3327 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3328 | } else { | 3328 | } else { |
3329 | external = !manager->mIsKapiFile; | 3329 | external = !manager->mIsKapiFile; |
3330 | if ( external ) { | 3330 | if ( external ) { |
3331 | qDebug("KA: Sync::Setting vcf mode to external "); | 3331 | qDebug("KA: Sync::Setting vcf mode to external "); |
3332 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3332 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3333 | AddressBook::Iterator it; | 3333 | AddressBook::Iterator it; |
3334 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3334 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3335 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3335 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3336 | (*it).computeCsum( mCurrentSyncDevice ); | 3336 | (*it).computeCsum( mCurrentSyncDevice ); |
3337 | } | 3337 | } |
3338 | } | 3338 | } |
3339 | } | 3339 | } |
3340 | //AddressBook::Iterator it; | 3340 | //AddressBook::Iterator it; |
3341 | //QStringList vcards; | 3341 | //QStringList vcards; |
3342 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3342 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3343 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3343 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3344 | //} | 3344 | //} |
3345 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3345 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3346 | syncManager->hideProgressBar(); | 3346 | syncManager->hideProgressBar(); |
3347 | if ( syncOK ) { | 3347 | if ( syncOK ) { |
3348 | if ( syncManager->mWriteBackFile ) | 3348 | if ( syncManager->mWriteBackFile ) |
3349 | { | 3349 | { |
3350 | if ( external ) | 3350 | if ( external ) |
3351 | abLocal.removeSyncAddressees( !isXML); | 3351 | abLocal.removeSyncAddressees( !isXML); |
3352 | qDebug("KA: Sync::Saving remote AB "); | 3352 | qDebug("KA: Sync::Saving remote AB "); |
3353 | if ( ! abLocal.saveAB()) | 3353 | if ( ! abLocal.saveAB()) |
3354 | qDebug("KA: sync::Error writing back AB to file "); | 3354 | qDebug("KA: sync::Error writing back AB to file "); |
3355 | if ( external ) { | 3355 | if ( external ) { |
3356 | // afterwrite processing | 3356 | // afterwrite processing |
3357 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3357 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3358 | } | 3358 | } |
3359 | } | 3359 | } |
3360 | } | 3360 | } |
3361 | setModified(); | 3361 | setModified(); |
3362 | 3362 | ||
3363 | } | 3363 | } |
3364 | abLocal.removeResources(); | 3364 | abLocal.removeResources(); |
3365 | if ( syncOK ) | 3365 | if ( syncOK ) |
3366 | mViewManager->refreshView(); | 3366 | mViewManager->refreshView(); |
3367 | return syncOK; | 3367 | return syncOK; |
3368 | 3368 | ||
3369 | } | 3369 | } |
3370 | void KABCore::removeSyncInfo( QString syncProfile) | 3370 | void KABCore::removeSyncInfo( QString syncProfile) |
3371 | { | 3371 | { |
3372 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3372 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3373 | mAddressBook->removeSyncInfo( syncProfile ); | 3373 | mAddressBook->removeSyncInfo( syncProfile ); |
3374 | setModified(); | 3374 | setModified(); |
3375 | } | 3375 | } |
3376 | 3376 | ||
3377 | 3377 | ||
3378 | //this is a overwritten callbackmethods from the syncinterface | 3378 | //this is a overwritten callbackmethods from the syncinterface |
3379 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3379 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3380 | { | 3380 | { |
3381 | if ( resource == "phone" ) | 3381 | if ( resource == "phone" ) |
3382 | return syncPhone(); | 3382 | return syncPhone(); |
3383 | disableBR( true ); | 3383 | disableBR( true ); |
3384 | if ( manager != syncManager ) | 3384 | if ( manager != syncManager ) |
3385 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3385 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3386 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3386 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3387 | 3387 | ||
3388 | AddressBook abLocal( resource,"syncContact"); | 3388 | AddressBook abLocal( resource,"syncContact"); |
3389 | bool syncOK = false; | 3389 | bool syncOK = false; |
3390 | message(i18n("Loading DTM address data..."), false); | 3390 | message(i18n("Loading DTM address data..."), false); |
3391 | if ( abLocal.load() ) { | 3391 | if ( abLocal.load() ) { |
3392 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3392 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3393 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3393 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3394 | message(i18n("Sync preprocessing..."),false); | 3394 | message(i18n("Sync preprocessing..."),false); |
3395 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3395 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3396 | message(i18n("Synchronizing..."),false); | 3396 | message(i18n("Synchronizing..."),false); |
3397 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3397 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3398 | syncManager->hideProgressBar(); | 3398 | syncManager->hideProgressBar(); |
3399 | if ( syncOK ) { | 3399 | if ( syncOK ) { |
3400 | if ( syncManager->mWriteBackFile ) { | 3400 | if ( syncManager->mWriteBackFile ) { |
3401 | abLocal.removeSyncAddressees( false ); | 3401 | abLocal.removeSyncAddressees( false ); |
3402 | message(i18n("Saving DTM address data..."),false); | 3402 | message(i18n("Saving DTM address data..."),false); |
3403 | abLocal.saveAB(); | 3403 | abLocal.saveAB(); |
3404 | message(i18n("Sync postprocessing..."),false); | 3404 | message(i18n("Sync postprocessing..."),false); |
3405 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3405 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3406 | } | 3406 | } |
3407 | } else | 3407 | } else |
3408 | message( i18n("Sync cancelled or failed.") ); | 3408 | message( i18n("Sync cancelled or failed.") ); |
3409 | setModified(); | 3409 | setModified(); |
3410 | } | 3410 | } |
3411 | abLocal.removeResources(); | 3411 | abLocal.removeResources(); |
3412 | if ( syncOK ) { | 3412 | if ( syncOK ) { |
3413 | mViewManager->refreshView(); | 3413 | mViewManager->refreshView(); |
3414 | message(i18n("DTM syncing finished.")); | 3414 | message(i18n("DTM syncing finished.")); |
3415 | } | 3415 | } |
3416 | disableBR( false ); | 3416 | disableBR( false ); |
3417 | return syncOK; | 3417 | return syncOK; |
3418 | 3418 | ||
3419 | } | 3419 | } |
3420 | void KABCore::message( QString m, bool startTimer) | 3420 | void KABCore::message( QString m, bool startTimer) |
3421 | { | 3421 | { |
3422 | topLevelWidget()->setCaption( m ); | 3422 | topLevelWidget()->setCaption( m ); |
3423 | qApp->processEvents(); | 3423 | qApp->processEvents(); |
3424 | if ( startTimer ) | 3424 | if ( startTimer ) |
3425 | mMessageTimer->start( 15000, true ); | 3425 | mMessageTimer->start( 15000, true ); |
3426 | else | 3426 | else |
3427 | mMessageTimer->stop(); | 3427 | mMessageTimer->stop(); |
3428 | } | 3428 | } |
3429 | bool KABCore::syncPhone() | 3429 | bool KABCore::syncPhone() |
3430 | { | 3430 | { |
3431 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3431 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3432 | QString fileName = getPhoneFile(); | 3432 | QString fileName = getPhoneFile(); |
3433 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3433 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3434 | message(i18n("Phone access failed!")); | 3434 | message(i18n("Phone access failed!")); |
3435 | return false; | 3435 | return false; |
3436 | } | 3436 | } |
3437 | AddressBook abLocal( fileName,"syncContact"); | 3437 | AddressBook abLocal( fileName,"syncContact"); |
3438 | bool syncOK = false; | 3438 | bool syncOK = false; |
3439 | { | 3439 | { |
3440 | abLocal.importFromFile( fileName ); | 3440 | abLocal.importFromFile( fileName ); |
3441 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3441 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3442 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3442 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3443 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3443 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3444 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3444 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3445 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3445 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3446 | syncManager->hideProgressBar(); | 3446 | syncManager->hideProgressBar(); |
3447 | if ( syncOK ) { | 3447 | if ( syncOK ) { |
3448 | if ( syncManager->mWriteBackFile ) { | 3448 | if ( syncManager->mWriteBackFile ) { |
3449 | abLocal.removeSyncAddressees( true ); | 3449 | abLocal.removeSyncAddressees( true ); |
3450 | abLocal.saveABphone( fileName ); | 3450 | abLocal.saveABphone( fileName ); |
3451 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3451 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3452 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3452 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3453 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3453 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3454 | } | 3454 | } |
3455 | } | 3455 | } |
3456 | setModified(); | 3456 | setModified(); |
3457 | } | 3457 | } |
3458 | abLocal.removeResources(); | 3458 | abLocal.removeResources(); |
3459 | if ( syncOK ) | 3459 | if ( syncOK ) |
3460 | mViewManager->refreshView(); | 3460 | mViewManager->refreshView(); |
3461 | return syncOK; | 3461 | return syncOK; |
3462 | } | 3462 | } |
3463 | void KABCore::getFile( bool success ) | 3463 | void KABCore::getFile( bool success ) |
3464 | { | 3464 | { |
3465 | if ( ! success ) { | 3465 | if ( ! success ) { |
3466 | message( i18n("Error receiving file. Nothing changed!") ); | 3466 | message( i18n("Error receiving file. Nothing changed!") ); |
3467 | return; | 3467 | return; |
3468 | } | 3468 | } |
3469 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3469 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3470 | if ( count ) | 3470 | if ( count ) |
3471 | setModified( true ); | 3471 | setModified( true ); |
3472 | message( i18n("Pi-Sync successful!") ); | 3472 | message( i18n("Pi-Sync successful!") ); |
3473 | mViewManager->refreshView(); | 3473 | mViewManager->refreshView(); |
3474 | } | 3474 | } |
3475 | void KABCore::syncFileRequest() | 3475 | void KABCore::syncFileRequest() |
3476 | { | 3476 | { |
3477 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3477 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3478 | syncManager->slotSyncMenu( 999 ); | 3478 | syncManager->slotSyncMenu( 999 ); |
3479 | } | 3479 | } |
3480 | mAddressBook->export2File( sentSyncFile() ); | 3480 | mAddressBook->export2File( sentSyncFile() ); |
3481 | } | 3481 | } |
3482 | QString KABCore::sentSyncFile() | 3482 | QString KABCore::sentSyncFile() |
3483 | { | 3483 | { |
3484 | #ifdef DESKTOP_VERSION | 3484 | #ifdef DESKTOP_VERSION |
3485 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3485 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3486 | #else | 3486 | #else |
3487 | return QString( "/tmp/copysyncab.vcf" ); | 3487 | return QString( "/tmp/copysyncab.vcf" ); |
3488 | #endif | 3488 | #endif |
3489 | } | 3489 | } |
3490 | 3490 | ||
3491 | void KABCore::setCaptionBack() | 3491 | void KABCore::setCaptionBack() |
3492 | { | 3492 | { |
3493 | mMessageTimer->stop(); | 3493 | mMessageTimer->stop(); |
3494 | topLevelWidget()->setCaption( i18n("KA/Pi") ); | 3494 | topLevelWidget()->setCaption( i18n("KA/Pi") ); |
3495 | } | 3495 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 42b7709..c4a0b3b 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,535 +1,535 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <qwidget.h> | 34 | #include <qwidget.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <ksyncmanager.h> | 36 | #include <ksyncmanager.h> |
37 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
38 | #include <qcopchannel_qws.h> | 38 | #include <qcopchannel_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | namespace KABC { | 41 | namespace KABC { |
42 | class AddressBook; | 42 | class AddressBook; |
43 | } | 43 | } |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | class KAboutData; | 46 | class KAboutData; |
47 | class KConfig; | 47 | class KConfig; |
48 | 48 | ||
49 | class KAddressBookService; | 49 | class KAddressBookService; |
50 | class LDAPSearchDialog; | 50 | class LDAPSearchDialog; |
51 | #else //KAB_EMBEDDED | 51 | #else //KAB_EMBEDDED |
52 | class KAddressBookMain; | 52 | class KAddressBookMain; |
53 | //US class QAction; | 53 | //US class QAction; |
54 | #endif //KAB_EMBEDDED | 54 | #endif //KAB_EMBEDDED |
55 | class KCMultiDialog; | 55 | class KCMultiDialog; |
56 | class KXMLGUIClient; | 56 | class KXMLGUIClient; |
57 | class ExtensionManager; | 57 | class ExtensionManager; |
58 | class XXPortManager; | 58 | class XXPortManager; |
59 | class JumpButtonBar; | 59 | class JumpButtonBar; |
60 | class IncSearchWidget; | 60 | class IncSearchWidget; |
61 | class KDGanttMinimizeSplitter; | 61 | class KDGanttMinimizeSplitter; |
62 | class KAction; | 62 | class KAction; |
63 | class KActionCollection; | 63 | class KActionCollection; |
64 | class KToggleAction; | 64 | class KToggleAction; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | 66 | ||
67 | class QAction; | 67 | class QAction; |
68 | class QMenuBar; | 68 | class QMenuBar; |
69 | class QSplitter; | 69 | class QSplitter; |
70 | class ViewContainer; | 70 | class ViewContainer; |
71 | class ViewManager; | 71 | class ViewManager; |
72 | class AddresseeEditorDialog; | 72 | class AddresseeEditorDialog; |
73 | class Ir; | 73 | class Ir; |
74 | 74 | ||
75 | class KABCore : public QWidget, public KSyncInterface | 75 | class KABCore : public QWidget, public KSyncInterface |
76 | { | 76 | { |
77 | Q_OBJECT | 77 | Q_OBJECT |
78 | 78 | ||
79 | public: | 79 | public: |
80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
81 | 81 | ||
82 | 82 | ||
83 | ~KABCore(); | 83 | ~KABCore(); |
84 | 84 | ||
85 | 85 | ||
86 | #ifdef KAB_EMBEDDED | 86 | #ifdef KAB_EMBEDDED |
87 | //US added functionality | 87 | //US added functionality |
88 | QPopupMenu* getViewMenu() {return viewMenu;} | 88 | QPopupMenu* getViewMenu() {return viewMenu;} |
89 | QPopupMenu* getFilterMenu() {return filterMenu;} | 89 | QPopupMenu* getFilterMenu() {return filterMenu;} |
90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
91 | void addActionsManually(); | 91 | void addActionsManually(); |
92 | #endif //KAB_EMBEDDED | 92 | #endif //KAB_EMBEDDED |
93 | /** | 93 | /** |
94 | Restores the global settings. | 94 | Restores the global settings. |
95 | */ | 95 | */ |
96 | void restoreSettings(); | 96 | void restoreSettings(); |
97 | 97 | ||
98 | 98 | ||
99 | 99 | ||
100 | /** | 100 | /** |
101 | Returns a pointer to the StdAddressBook of the application. | 101 | Returns a pointer to the StdAddressBook of the application. |
102 | */ | 102 | */ |
103 | KABC::AddressBook *addressBook() const; | 103 | KABC::AddressBook *addressBook() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Returns a pointer to the KConfig object of the application. | 106 | Returns a pointer to the KConfig object of the application. |
107 | */ | 107 | */ |
108 | static KConfig *config(); | 108 | static KConfig *config(); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | Returns a pointer to the global KActionCollection object. So | 111 | Returns a pointer to the global KActionCollection object. So |
112 | other classes can register their actions easily. | 112 | other classes can register their actions easily. |
113 | */ | 113 | */ |
114 | KActionCollection *actionCollection() const; | 114 | KActionCollection *actionCollection() const; |
115 | 115 | ||
116 | /** | 116 | /** |
117 | Returns the current search field of the Incremental Search Widget. | 117 | Returns the current search field of the Incremental Search Widget. |
118 | */ | 118 | */ |
119 | KABC::Field *currentSearchField() const; | 119 | KABC::Field *currentSearchField() const; |
120 | 120 | ||
121 | /** | 121 | /** |
122 | Returns the uid list of the currently selected contacts. | 122 | Returns the uid list of the currently selected contacts. |
123 | */ | 123 | */ |
124 | QStringList selectedUIDs() const; | 124 | QStringList selectedUIDs() const; |
125 | 125 | ||
126 | /** | 126 | /** |
127 | Displays the ResourceSelectDialog and returns the selected | 127 | Displays the ResourceSelectDialog and returns the selected |
128 | resource or a null pointer if no resource was selected by | 128 | resource or a null pointer if no resource was selected by |
129 | the user. | 129 | the user. |
130 | */ | 130 | */ |
131 | KABC::Resource *requestResource( QWidget *parent ); | 131 | KABC::Resource *requestResource( QWidget *parent ); |
132 | 132 | ||
133 | #ifndef KAB_EMBEDDED | 133 | #ifndef KAB_EMBEDDED |
134 | static KAboutData *createAboutData(); | 134 | static KAboutData *createAboutData(); |
135 | #endif //KAB_EMBEDDED | 135 | #endif //KAB_EMBEDDED |
136 | 136 | ||
137 | #ifdef KAB_EMBEDDED | 137 | #ifdef KAB_EMBEDDED |
138 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 138 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
139 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 139 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
140 | #endif //KAB_EMBEDDED | 140 | #endif //KAB_EMBEDDED |
141 | 141 | ||
142 | public slots: | 142 | public slots: |
143 | #ifdef KAB_EMBEDDED | 143 | #ifdef KAB_EMBEDDED |
144 | void createAboutData(); | 144 | void createAboutData(); |
145 | #endif //KAB_EMBEDDED | 145 | #endif //KAB_EMBEDDED |
146 | void setDetailsToggle(); | 146 | void setDetailsToggle(); |
147 | 147 | ||
148 | void showLicence(); | 148 | void showLicence(); |
149 | void faq(); | 149 | void faq(); |
150 | void whatsnew() ; | 150 | void whatsnew() ; |
151 | void synchowto() ; | 151 | void synchowto() ; |
152 | void storagehowto() ; | 152 | void storagehowto() ; |
153 | void multisynchowto() ; | 153 | void multisynchowto() ; |
154 | void kdesynchowto() ; | 154 | void kdesynchowto() ; |
155 | void writeToPhone(); | 155 | void writeToPhone(); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Is called whenever a contact is selected in the view. | 158 | Is called whenever a contact is selected in the view. |
159 | */ | 159 | */ |
160 | void setContactSelected( const QString &uid ); | 160 | void setContactSelected( const QString &uid ); |
161 | 161 | ||
162 | /** | 162 | /** |
163 | Opens the preferred mail composer with all selected contacts as | 163 | Opens the preferred mail composer with all selected contacts as |
164 | arguments. | 164 | arguments. |
165 | */ | 165 | */ |
166 | void sendMail(); | 166 | void sendMail(); |
167 | 167 | ||
168 | /** | 168 | /** |
169 | Opens the preferred mail composer with the given contacts as | 169 | Opens the preferred mail composer with the given contacts as |
170 | arguments. | 170 | arguments. |
171 | */ | 171 | */ |
172 | void sendMail( const QString& email ); | 172 | void sendMail( const QString& email ); |
173 | 173 | ||
174 | 174 | ||
175 | void mailVCard(); | 175 | void mailVCard(); |
176 | void mailVCard(const QStringList& uids); | 176 | void mailVCard(const QStringList& uids); |
177 | 177 | ||
178 | /** | 178 | /** |
179 | Beams the "WhoAmI contact. | 179 | Beams the "WhoAmI contact. |
180 | */ | 180 | */ |
181 | void beamMySelf(); | 181 | void beamMySelf(); |
182 | 182 | ||
183 | void beamVCard(); | 183 | void beamVCard(); |
184 | void export2phone(); | 184 | void export2phone(); |
185 | void beamVCard(const QStringList& uids); | 185 | void beamVCard(const QStringList& uids); |
186 | void beamDone( Ir *ir ); | 186 | void beamDone( Ir *ir ); |
187 | 187 | ||
188 | 188 | ||
189 | /** | 189 | /** |
190 | Starts the preferred web browser with the given URL as argument. | 190 | Starts the preferred web browser with the given URL as argument. |
191 | */ | 191 | */ |
192 | void browse( const QString& url ); | 192 | void browse( const QString& url ); |
193 | 193 | ||
194 | /** | 194 | /** |
195 | Select all contacts in the view. | 195 | Select all contacts in the view. |
196 | */ | 196 | */ |
197 | void selectAllContacts(); | 197 | void selectAllContacts(); |
198 | 198 | ||
199 | /** | 199 | /** |
200 | Deletes all selected contacts from the address book. | 200 | Deletes all selected contacts from the address book. |
201 | */ | 201 | */ |
202 | void deleteContacts(); | 202 | void deleteContacts(); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | Deletes given contacts from the address book. | 205 | Deletes given contacts from the address book. |
206 | 206 | ||
207 | @param uids The uids of the contacts, which shall be deleted. | 207 | @param uids The uids of the contacts, which shall be deleted. |
208 | */ | 208 | */ |
209 | void deleteContacts( const QStringList &uids ); | 209 | void deleteContacts( const QStringList &uids ); |
210 | 210 | ||
211 | /** | 211 | /** |
212 | Copys the selected contacts into clipboard for later pasting. | 212 | Copys the selected contacts into clipboard for later pasting. |
213 | */ | 213 | */ |
214 | void copyContacts(); | 214 | void copyContacts(); |
215 | 215 | ||
216 | /** | 216 | /** |
217 | Cuts the selected contacts and stores them for later pasting. | 217 | Cuts the selected contacts and stores them for later pasting. |
218 | */ | 218 | */ |
219 | void cutContacts(); | 219 | void cutContacts(); |
220 | 220 | ||
221 | /** | 221 | /** |
222 | Paste contacts from clipboard into the address book. | 222 | Paste contacts from clipboard into the address book. |
223 | */ | 223 | */ |
224 | void pasteContacts(); | 224 | void pasteContacts(); |
225 | 225 | ||
226 | /** | 226 | /** |
227 | Paste given contacts into the address book. | 227 | Paste given contacts into the address book. |
228 | 228 | ||
229 | @param list The list of addressee, which shall be pasted. | 229 | @param list The list of addressee, which shall be pasted. |
230 | */ | 230 | */ |
231 | void pasteContacts( KABC::Addressee::List &list ); | 231 | void pasteContacts( KABC::Addressee::List &list ); |
232 | 232 | ||
233 | /** | 233 | /** |
234 | Sets the whoAmI contact, that is used by many other programs to | 234 | Sets the whoAmI contact, that is used by many other programs to |
235 | get personal information about the current user. | 235 | get personal information about the current user. |
236 | */ | 236 | */ |
237 | void setWhoAmI(); | 237 | void setWhoAmI(); |
238 | 238 | ||
239 | /** | 239 | /** |
240 | Displays the category dialog and applies the result to all | 240 | Displays the category dialog and applies the result to all |
241 | selected contacts. | 241 | selected contacts. |
242 | */ | 242 | */ |
243 | void setCategories(); | 243 | void setCategories(); |
244 | void manageCategories(); | 244 | void manageCategories(); |
245 | void editCategories(); | 245 | void editCategories(); |
246 | 246 | ||
247 | /** | 247 | /** |
248 | Sets the field list of the Incremental Search Widget. | 248 | Sets the field list of the Incremental Search Widget. |
249 | */ | 249 | */ |
250 | void setSearchFields( const KABC::Field::List &fields ); | 250 | void setSearchFields( const KABC::Field::List &fields ); |
251 | 251 | ||
252 | /** | 252 | /** |
253 | Search with the current search field for a contact, that matches | 253 | Search with the current search field for a contact, that matches |
254 | the given text, and selects it in the view. | 254 | the given text, and selects it in the view. |
255 | */ | 255 | */ |
256 | void incrementalSearch( const QString& text ); | 256 | void incrementalSearch( const QString& text ); |
257 | void incrementalSearchJump( const QString& text ); | 257 | void incrementalSearchJump( const QString& text ); |
258 | 258 | ||
259 | /** | 259 | /** |
260 | Marks the address book as modified. | 260 | Marks the address book as modified. |
261 | */ | 261 | */ |
262 | void setModified(); | 262 | void setModified(); |
263 | /** | 263 | /** |
264 | Marks the address book as modified without refreshing the view. | 264 | Marks the address book as modified without refreshing the view. |
265 | */ | 265 | */ |
266 | void setModifiedWOrefresh(); | 266 | void setModifiedWOrefresh(); |
267 | 267 | ||
268 | /** | 268 | /** |
269 | Marks the address book as modified concerning the argument. | 269 | Marks the address book as modified concerning the argument. |
270 | */ | 270 | */ |
271 | void setModified( bool modified ); | 271 | void setModified( bool modified ); |
272 | 272 | ||
273 | /** | 273 | /** |
274 | Returns whether the address book is modified. | 274 | Returns whether the address book is modified. |
275 | */ | 275 | */ |
276 | bool modified() const; | 276 | bool modified() const; |
277 | 277 | ||
278 | /** | 278 | /** |
279 | Called whenever an contact is modified in the contact editor | 279 | Called whenever an contact is modified in the contact editor |
280 | dialog or the quick edit. | 280 | dialog or the quick edit. |
281 | */ | 281 | */ |
282 | void contactModified( const KABC::Addressee &addr ); | 282 | void contactModified( const KABC::Addressee &addr ); |
283 | void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); | 283 | void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); |
284 | 284 | ||
285 | /** | 285 | /** |
286 | DCOP METHODS. | 286 | DCOP METHODS. |
287 | */ | 287 | */ |
288 | void addEmail( QString addr ); | 288 | void addEmail( QString addr ); |
289 | void importVCard( const KURL& url, bool showPreview ); | 289 | void importVCard( const KURL& url, bool showPreview ); |
290 | void importVCard( const QString& vCard, bool showPreview ); | 290 | void importVCard( const QString& vCard, bool showPreview ); |
291 | void newContact(); | 291 | void newContact(); |
292 | QString getNameByPhone( const QString& phone ); | 292 | QString getNameByPhone( const QString& phone ); |
293 | /** | 293 | /** |
294 | END DCOP METHODS | 294 | END DCOP METHODS |
295 | */ | 295 | */ |
296 | 296 | ||
297 | /** | 297 | /** |
298 | Saves the contents of the AddressBook back to disk. | 298 | Saves the contents of the AddressBook back to disk. |
299 | */ | 299 | */ |
300 | void save(); | 300 | void save(); |
301 | 301 | ||
302 | /** | 302 | /** |
303 | Undos the last command using the undo stack. | 303 | Undos the last command using the undo stack. |
304 | */ | 304 | */ |
305 | void undo(); | 305 | void undo(); |
306 | 306 | ||
307 | /** | 307 | /** |
308 | Redos the last command that was undone, using the redo stack. | 308 | Redos the last command that was undone, using the redo stack. |
309 | */ | 309 | */ |
310 | void redo(); | 310 | void redo(); |
311 | 311 | ||
312 | /** | 312 | /** |
313 | Shows the edit dialog for the given uid. If the uid is QString::null, | 313 | Shows the edit dialog for the given uid. If the uid is QString::null, |
314 | the method will try to find a selected addressee in the view. | 314 | the method will try to find a selected addressee in the view. |
315 | */ | 315 | */ |
316 | void editContact( const QString &uid /*US = QString::null*/ ); | 316 | void editContact( const QString &uid /*US = QString::null*/ ); |
317 | //US added a second method without defaultparameter | 317 | //US added a second method without defaultparameter |
318 | void editContact2(); | 318 | void editContact2(); |
319 | 319 | ||
320 | /** | 320 | /** |
321 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 321 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
322 | the method will try to find a selected addressee in the view. | 322 | the method will try to find a selected addressee in the view. |
323 | */ | 323 | */ |
324 | void executeContact( const QString &uid /*US = QString::null*/ ); | 324 | void executeContact( const QString &uid /*US = QString::null*/ ); |
325 | 325 | ||
326 | /** | 326 | /** |
327 | Launches the configuration dialog. | 327 | Launches the configuration dialog. |
328 | */ | 328 | */ |
329 | void openConfigDialog(); | 329 | void openConfigDialog(); |
330 | void openConfigGlobalDialog(); | 330 | void openConfigGlobalDialog(); |
331 | 331 | ||
332 | /** | 332 | /** |
333 | Launches the ldap search dialog. | 333 | Launches the ldap search dialog. |
334 | */ | 334 | */ |
335 | void openLDAPDialog(); | 335 | void openLDAPDialog(); |
336 | 336 | ||
337 | /** | 337 | /** |
338 | Creates a KAddressBookPrinter, which will display the print | 338 | Creates a KAddressBookPrinter, which will display the print |
339 | dialog and do the printing. | 339 | dialog and do the printing. |
340 | */ | 340 | */ |
341 | void print(); | 341 | void print(); |
342 | 342 | ||
343 | /** | 343 | /** |
344 | Registers a new GUI client, so plugins can register its actions. | 344 | Registers a new GUI client, so plugins can register its actions. |
345 | */ | 345 | */ |
346 | void addGUIClient( KXMLGUIClient *client ); | 346 | void addGUIClient( KXMLGUIClient *client ); |
347 | 347 | ||
348 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 348 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
349 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 349 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
350 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 350 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
351 | 351 | ||
352 | 352 | ||
353 | signals: | 353 | signals: |
354 | void contactSelected( const QString &name ); | 354 | void contactSelected( const QString &name ); |
355 | void contactSelected( const QPixmap &pixmap ); | 355 | void contactSelected( const QPixmap &pixmap ); |
356 | public slots: | 356 | public slots: |
357 | void loadDataAfterStart(); | 357 | void loadDataAfterStart(); |
358 | void recieve(QString cmsg ); | 358 | void recieve(QString cmsg ); |
359 | void getFile( bool success ); | 359 | void getFile( bool success ); |
360 | void syncFileRequest(); | 360 | void syncFileRequest(); |
361 | void setDetailsVisible( bool visible ); | 361 | void setDetailsVisible( bool visible ); |
362 | void setDetailsToState(); | 362 | void setDetailsToState(); |
363 | 363 | ||
364 | void saveSettings(); | 364 | void saveSettings(); |
365 | 365 | ||
366 | private slots: | 366 | private slots: |
367 | void updateToolBar(); | 367 | void updateToolBar(); |
368 | void updateMainWindow(); | 368 | void updateMainWindow(); |
369 | void receive( const QCString& cmsg, const QByteArray& data ); | 369 | void receive( const QCString& cmsg, const QByteArray& data ); |
370 | void receiveStart( const QCString& cmsg, const QByteArray& data ); | 370 | void receiveStart( const QCString& cmsg, const QByteArray& data ); |
371 | void toggleBeamReceive( ); | 371 | void toggleBeamReceive( ); |
372 | void disableBR(bool); | 372 | void disableBR(bool); |
373 | void setJumpButtonBarVisible( bool visible ); | 373 | void setJumpButtonBarVisible( bool visible ); |
374 | void setJumpButtonBar( bool visible ); | 374 | void setJumpButtonBar( bool visible ); |
375 | void setCaptionBack(); | 375 | void setCaptionBack(); |
376 | void resizeAndCallContactdialog(); | 376 | void resizeAndCallContactdialog(); |
377 | void callContactdialog(); | 377 | void callContactdialog(); |
378 | void doRingSync(); | 378 | void doRingSync(); |
379 | 379 | ||
380 | void importFromOL(); | 380 | void importFromOL(); |
381 | void extensionModified( const KABC::Addressee::List &list ); | 381 | void extensionModified( const KABC::Addressee::List &list ); |
382 | void extensionChanged( int id ); | 382 | void extensionChanged( int id ); |
383 | void clipboardDataChanged(); | 383 | void clipboardDataChanged(); |
384 | void updateActionMenu(); | 384 | void updateActionMenu(); |
385 | void configureKeyBindings(); | 385 | void configureKeyBindings(); |
386 | void removeVoice(); | 386 | void removeVoice(); |
387 | void setFormattedName(); | 387 | void setFormattedName(); |
388 | #ifdef KAB_EMBEDDED | 388 | #ifdef KAB_EMBEDDED |
389 | void configureResources(); | 389 | void configureResources(); |
390 | #endif //KAB_EMBEDDED | 390 | #endif //KAB_EMBEDDED |
391 | 391 | ||
392 | void slotEditorDestroyed( const QString &uid ); | 392 | void slotEditorDestroyed( const QString &uid ); |
393 | void configurationChanged(); | 393 | void configurationChanged(); |
394 | void addressBookChanged(); | 394 | void addressBookChanged(); |
395 | 395 | ||
396 | private: | 396 | private: |
397 | QCString mCStringMess; | 397 | QCString mCStringMess; |
398 | QByteArray mByteData; | 398 | QByteArray mByteData; |
399 | QString mEmailSourceChannel; | 399 | QString mEmailSourceChannel; |
400 | QString mEmailSourceUID; | 400 | QString mEmailSourceUID; |
401 | void resizeEvent(QResizeEvent* e ); | 401 | void resizeEvent(QResizeEvent* e ); |
402 | bool mBRdisabled; | 402 | bool mBRdisabled; |
403 | #ifndef DESKTOP_VERSION | 403 | #ifndef DESKTOP_VERSION |
404 | QCopChannel* infrared; | 404 | QCopChannel* infrared; |
405 | #endif | 405 | #endif |
406 | QTimer *mMessageTimer; | 406 | QTimer *mMessageTimer; |
407 | void initGUI(); | 407 | void initGUI(); |
408 | void initActions(); | 408 | void initActions(); |
409 | QString getPhoneFile(); | 409 | QString getPhoneFile(); |
410 | 410 | ||
411 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 411 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
412 | const char *name = 0 ); | 412 | const char *name = 0 ); |
413 | 413 | ||
414 | KXMLGUIClient *mGUIClient; | 414 | KXMLGUIClient *mGUIClient; |
415 | 415 | ||
416 | KABC::AddressBook *mAddressBook; | 416 | KABC::AddressBook *mAddressBook; |
417 | 417 | ||
418 | ViewManager *mViewManager; | 418 | ViewManager *mViewManager; |
419 | // QSplitter *mDetailsSplitter; | 419 | // QSplitter *mDetailsSplitter; |
420 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 420 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
421 | ViewContainer *mDetails; | 421 | ViewContainer *mDetails; |
422 | KDGanttMinimizeSplitter* mMiniSplitter; | 422 | KDGanttMinimizeSplitter* mMiniSplitter; |
423 | XXPortManager *mXXPortManager; | 423 | XXPortManager *mXXPortManager; |
424 | JumpButtonBar *mJumpButtonBar; | 424 | JumpButtonBar *mJumpButtonBar; |
425 | IncSearchWidget *mIncSearchWidget; | 425 | IncSearchWidget *mIncSearchWidget; |
426 | ExtensionManager *mExtensionManager; | 426 | ExtensionManager *mExtensionManager; |
427 | 427 | ||
428 | KCMultiDialog *mConfigureDialog; | 428 | KCMultiDialog *mConfigureDialog; |
429 | 429 | ||
430 | #ifndef KAB_EMBEDDED | 430 | #ifndef KAB_EMBEDDED |
431 | LDAPSearchDialog *mLdapSearchDialog; | 431 | LDAPSearchDialog *mLdapSearchDialog; |
432 | #endif //KAB_EMBEDDED | 432 | #endif //KAB_EMBEDDED |
433 | // QDict<AddresseeEditorDialog> mEditorDict; | 433 | // QDict<AddresseeEditorDialog> mEditorDict; |
434 | AddresseeEditorDialog *mEditorDialog; | 434 | AddresseeEditorDialog *mEditorDialog; |
435 | bool mReadWrite; | 435 | bool mReadWrite; |
436 | bool mModified; | 436 | bool mModified; |
437 | bool mIsPart; | 437 | bool mIsPart; |
438 | bool mMultipleViewsAtOnce; | 438 | bool mMultipleViewsAtOnce; |
439 | 439 | ||
440 | 440 | ||
441 | //US file menu | 441 | //US file menu |
442 | KAction *mActionMail; | 442 | KAction *mActionMail; |
443 | KAction *mActionBeam; | 443 | KAction *mActionBeam; |
444 | KToggleAction *mActionBR; | 444 | KToggleAction *mActionBR; |
445 | KAction *mActionExport2phone; | 445 | KAction *mActionExport2phone; |
446 | KAction* mActionPrint; | 446 | KAction* mActionPrint; |
447 | KAction* mActionPrintDetails; | 447 | KAction* mActionPrintDetails; |
448 | KAction* mActionNewContact; | 448 | KAction* mActionNewContact; |
449 | KAction *mActionSave; | 449 | KAction *mActionSave; |
450 | KAction *mActionEditAddressee; | 450 | KAction *mActionEditAddressee; |
451 | KAction *mActionMailVCard; | 451 | KAction *mActionMailVCard; |
452 | KAction *mActionBeamVCard; | 452 | KAction *mActionBeamVCard; |
453 | 453 | ||
454 | KAction *mActionQuit; | 454 | KAction *mActionQuit; |
455 | 455 | ||
456 | //US edit menu | 456 | //US edit menu |
457 | KAction *mActionCopy; | 457 | KAction *mActionCopy; |
458 | KAction *mActionCut; | 458 | KAction *mActionCut; |
459 | KAction *mActionPaste; | 459 | KAction *mActionPaste; |
460 | KAction *mActionSelectAll; | 460 | KAction *mActionSelectAll; |
461 | KAction *mActionUndo; | 461 | KAction *mActionUndo; |
462 | KAction *mActionRedo; | 462 | KAction *mActionRedo; |
463 | KAction *mActionDelete; | 463 | KAction *mActionDelete; |
464 | 464 | ||
465 | //US settings menu | 465 | //US settings menu |
466 | KAction *mActionConfigResources; | 466 | KAction *mActionConfigResources; |
467 | KAction *mActionConfigGlobal; | 467 | KAction *mActionConfigGlobal; |
468 | KAction *mActionConfigKAddressbook; | 468 | KAction *mActionConfigKAddressbook; |
469 | KAction *mActionConfigShortcuts; | 469 | KAction *mActionConfigShortcuts; |
470 | KAction *mActionConfigureToolbars; | 470 | KAction *mActionConfigureToolbars; |
471 | KAction *mActionKeyBindings; | 471 | KAction *mActionKeyBindings; |
472 | KToggleAction *mActionJumpBar; | 472 | KToggleAction *mActionJumpBar; |
473 | KToggleAction *mActionDetails; | 473 | KToggleAction *mActionDetails; |
474 | KAction *mActionWhoAmI; | 474 | KAction *mActionWhoAmI; |
475 | KAction *mActionCategories; | 475 | KAction *mActionCategories; |
476 | KAction *mActionEditCategories; | 476 | KAction *mActionEditCategories; |
477 | KAction *mActionManageCategories; | 477 | KAction *mActionManageCategories; |
478 | KAction *mActionAboutKAddressbook; | 478 | KAction *mActionAboutKAddressbook; |
479 | KAction *mActionLicence; | 479 | KAction *mActionLicence; |
480 | KAction *mActionFaq; | 480 | KAction *mActionFaq; |
481 | KAction *mActionWN; | 481 | KAction *mActionWN; |
482 | KAction *mActionSyncHowto; | 482 | KAction *mActionSyncHowto; |
483 | KAction *mActionStorageHowto; | 483 | KAction *mActionStorageHowto; |
484 | KAction *mActionKdeSyncHowto; | 484 | KAction *mActionKdeSyncHowto; |
485 | KAction *mActionMultiSyncHowto; | 485 | KAction *mActionMultiSyncHowto; |
486 | 486 | ||
487 | KAction *mActionDeleteView; | 487 | KAction *mActionDeleteView; |
488 | 488 | ||
489 | QPopupMenu *viewMenu; | 489 | QPopupMenu *viewMenu; |
490 | QPopupMenu *filterMenu; | 490 | QPopupMenu *filterMenu; |
491 | QPopupMenu *settingsMenu; | 491 | QPopupMenu *settingsMenu; |
492 | QPopupMenu *changeMenu; | 492 | QPopupMenu *changeMenu; |
493 | QPopupMenu *beamMenu; | 493 | QPopupMenu *beamMenu; |
494 | //US QAction *mActionSave; | 494 | //US QAction *mActionSave; |
495 | QPopupMenu *ImportMenu; | 495 | QPopupMenu *ImportMenu; |
496 | QPopupMenu *ExportMenu; | 496 | QPopupMenu *ExportMenu; |
497 | //LR additional methods | 497 | //LR additional methods |
498 | KAction *mActionRemoveVoice; | 498 | KAction *mActionRemoveVoice; |
499 | KAction *mActionSetFormattedName; | 499 | KAction *mActionSetFormattedName; |
500 | KAction * mActionImportOL; | 500 | KAction * mActionImportOL; |
501 | 501 | ||
502 | #ifndef KAB_EMBEDDED | 502 | #ifndef KAB_EMBEDDED |
503 | KAddressBookService *mAddressBookService; | 503 | KAddressBookService *mAddressBookService; |
504 | #endif //KAB_EMBEDDED | 504 | #endif //KAB_EMBEDDED |
505 | 505 | ||
506 | class KABCorePrivate; | 506 | class KABCorePrivate; |
507 | KABCorePrivate *d; | 507 | KABCorePrivate *d; |
508 | //US bool mBlockSaveFlag; | 508 | //US bool mBlockSaveFlag; |
509 | 509 | ||
510 | #ifdef KAB_EMBEDDED | 510 | #ifdef KAB_EMBEDDED |
511 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 511 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
512 | #endif //KAB_EMBEDDED | 512 | #endif //KAB_EMBEDDED |
513 | 513 | ||
514 | //this are the overwritten callbackmethods from the syncinterface | 514 | //this are the overwritten callbackmethods from the syncinterface |
515 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 515 | virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); |
516 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 516 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
517 | virtual void removeSyncInfo( QString syncProfile); | 517 | virtual void removeSyncInfo( QString syncProfile); |
518 | bool syncPhone(); | 518 | bool syncPhone(); |
519 | void message( QString m , bool startTimer = true); | 519 | void message( QString m , bool startTimer = true); |
520 | 520 | ||
521 | // LR ******************************* | 521 | // LR ******************************* |
522 | // sync stuff! | 522 | // sync stuff! |
523 | QString sentSyncFile(); | 523 | QString sentSyncFile(); |
524 | QPopupMenu *syncMenu; | 524 | QPopupMenu *syncMenu; |
525 | KSyncManager* syncManager; | 525 | KSyncManager* syncManager; |
526 | int mGlobalSyncMode; | 526 | int mGlobalSyncMode; |
527 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 527 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
528 | KABC::Addressee getLastSyncAddressee(); | 528 | KABC::Addressee getLastSyncAddressee(); |
529 | QDateTime mLastAddressbookSync; | 529 | QDateTime mLastAddressbookSync; |
530 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 530 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
531 | // ********************* | 531 | // ********************* |
532 | 532 | ||
533 | }; | 533 | }; |
534 | 534 | ||
535 | #endif | 535 | #endif |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 31e103d..8965d3b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -957,2049 +957,2048 @@ void CalendarView::checkAlarms() | |||
957 | mCalendar->addTodo( nt ); | 957 | mCalendar->addTodo( nt ); |
958 | nt->setSummary( "Work on 1"); | 958 | nt->setSummary( "Work on 1"); |
959 | nt->setPriority( 1 ); | 959 | nt->setPriority( 1 ); |
960 | nt->setDescription( "This is a test description of Work Project_1" ); | 960 | nt->setDescription( "This is a test description of Work Project_1" ); |
961 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); | 961 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); |
962 | nt->setPercentComplete( 20 ); | 962 | nt->setPercentComplete( 20 ); |
963 | 963 | ||
964 | Todo * sub2 = nt; | 964 | Todo * sub2 = nt; |
965 | sub2->setRelatedTo( root1 ); | 965 | sub2->setRelatedTo( root1 ); |
966 | 966 | ||
967 | 967 | ||
968 | nt = new Todo; | 968 | nt = new Todo; |
969 | mCalendar->addTodo( nt ); | 969 | mCalendar->addTodo( nt ); |
970 | nt->setSummary( "Work on 1: Lutz"); | 970 | nt->setSummary( "Work on 1: Lutz"); |
971 | nt->setPriority( 1 ); | 971 | nt->setPriority( 1 ); |
972 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 972 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
973 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); | 973 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); |
974 | nt->setPercentComplete( 20 ); | 974 | nt->setPercentComplete( 20 ); |
975 | Todo * workLutz12 = nt; | 975 | Todo * workLutz12 = nt; |
976 | workLutz12->setRelatedTo( sub2 ); | 976 | workLutz12->setRelatedTo( sub2 ); |
977 | 977 | ||
978 | nt = new Todo; | 978 | nt = new Todo; |
979 | mCalendar->addTodo( nt ); | 979 | mCalendar->addTodo( nt ); |
980 | nt->setSummary( "Work on 1: Norbert"); | 980 | nt->setSummary( "Work on 1: Norbert"); |
981 | nt->setPriority( 1 ); | 981 | nt->setPriority( 1 ); |
982 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 982 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
983 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); | 983 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); |
984 | nt->setPercentComplete( 20 ); | 984 | nt->setPercentComplete( 20 ); |
985 | Todo * workNorbert12 = nt; | 985 | Todo * workNorbert12 = nt; |
986 | workNorbert12->setRelatedTo( sub2 ); | 986 | workNorbert12->setRelatedTo( sub2 ); |
987 | 987 | ||
988 | int secLenRunning = 7200; | 988 | int secLenRunning = 7200; |
989 | int secLenPausing = 3600 * 3; | 989 | int secLenPausing = 3600 * 3; |
990 | int dayInterval = 1; | 990 | int dayInterval = 1; |
991 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); | 991 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); |
992 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); | 992 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); |
993 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); | 993 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); |
994 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); | 994 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); |
995 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); | 995 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); |
996 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); | 996 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); |
997 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); | 997 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); |
998 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); | 998 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); |
999 | 999 | ||
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | { | 1002 | { |
1003 | Todo * root1 = new Todo; | 1003 | Todo * root1 = new Todo; |
1004 | mCalendar->addTodo( root1 ); | 1004 | mCalendar->addTodo( root1 ); |
1005 | root1->setSummary( "Project2"); | 1005 | root1->setSummary( "Project2"); |
1006 | root1->setPriority( 1 ); | 1006 | root1->setPriority( 1 ); |
1007 | root1->setDescription( "This is a test description of a root Project 2" ); | 1007 | root1->setDescription( "This is a test description of a root Project 2" ); |
1008 | root1->setPercentComplete( 20 ); | 1008 | root1->setPercentComplete( 20 ); |
1009 | root1->setCategories( QString( "Cat_Pro2") ); | 1009 | root1->setCategories( QString( "Cat_Pro2") ); |
1010 | updateView(); | 1010 | updateView(); |
1011 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 1011 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
1012 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 1012 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
1013 | int secLenRunning = 7200; | 1013 | int secLenRunning = 7200; |
1014 | int secLenPausing = 3600 * 3; | 1014 | int secLenPausing = 3600 * 3; |
1015 | int dayInterval = 1; | 1015 | int dayInterval = 1; |
1016 | 1016 | ||
1017 | nt = new Todo; | 1017 | nt = new Todo; |
1018 | mCalendar->addTodo( nt ); | 1018 | mCalendar->addTodo( nt ); |
1019 | nt->setSummary( "Planning Project2"); | 1019 | nt->setSummary( "Planning Project2"); |
1020 | nt->setPriority( 1 ); | 1020 | nt->setPriority( 1 ); |
1021 | nt->setDescription( "This is a test description of Planning_Project_2" ); | 1021 | nt->setDescription( "This is a test description of Planning_Project_2" ); |
1022 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); | 1022 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); |
1023 | nt->setPercentComplete( 20 ); | 1023 | nt->setPercentComplete( 20 ); |
1024 | 1024 | ||
1025 | 1025 | ||
1026 | Todo * sub1 = nt; | 1026 | Todo * sub1 = nt; |
1027 | sub1->setRelatedTo( root1 ); | 1027 | sub1->setRelatedTo( root1 ); |
1028 | 1028 | ||
1029 | nt = new Todo; | 1029 | nt = new Todo; |
1030 | mCalendar->addTodo( nt ); | 1030 | mCalendar->addTodo( nt ); |
1031 | nt->setSummary( "Planning Project2: Lutz"); | 1031 | nt->setSummary( "Planning Project2: Lutz"); |
1032 | nt->setPriority( 1 ); | 1032 | nt->setPriority( 1 ); |
1033 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1033 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1034 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); | 1034 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); |
1035 | nt->setPercentComplete( 20 ); | 1035 | nt->setPercentComplete( 20 ); |
1036 | Todo * workLutz11 = nt; | 1036 | Todo * workLutz11 = nt; |
1037 | workLutz11->setRelatedTo( sub1 ); | 1037 | workLutz11->setRelatedTo( sub1 ); |
1038 | 1038 | ||
1039 | nt = new Todo; | 1039 | nt = new Todo; |
1040 | mCalendar->addTodo( nt ); | 1040 | mCalendar->addTodo( nt ); |
1041 | nt->setSummary( "Planning Project2: Norbert"); | 1041 | nt->setSummary( "Planning Project2: Norbert"); |
1042 | nt->setPriority( 1 ); | 1042 | nt->setPriority( 1 ); |
1043 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1043 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1044 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); | 1044 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); |
1045 | nt->setPercentComplete( 20 ); | 1045 | nt->setPercentComplete( 20 ); |
1046 | Todo * workNorbert11 = nt; | 1046 | Todo * workNorbert11 = nt; |
1047 | workNorbert11->setRelatedTo( sub1 ); | 1047 | workNorbert11->setRelatedTo( sub1 ); |
1048 | 1048 | ||
1049 | nt = new Todo; | 1049 | nt = new Todo; |
1050 | mCalendar->addTodo( nt ); | 1050 | mCalendar->addTodo( nt ); |
1051 | nt->setSummary( "Work on 2"); | 1051 | nt->setSummary( "Work on 2"); |
1052 | nt->setPriority( 1 ); | 1052 | nt->setPriority( 1 ); |
1053 | nt->setDescription( "This is a test description of Work Project_2" ); | 1053 | nt->setDescription( "This is a test description of Work Project_2" ); |
1054 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); | 1054 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); |
1055 | nt->setPercentComplete( 20 ); | 1055 | nt->setPercentComplete( 20 ); |
1056 | 1056 | ||
1057 | Todo * sub2 = nt; | 1057 | Todo * sub2 = nt; |
1058 | sub2->setRelatedTo( root1 ); | 1058 | sub2->setRelatedTo( root1 ); |
1059 | 1059 | ||
1060 | 1060 | ||
1061 | nt = new Todo; | 1061 | nt = new Todo; |
1062 | mCalendar->addTodo( nt ); | 1062 | mCalendar->addTodo( nt ); |
1063 | nt->setSummary( "Work on 2: Lutz"); | 1063 | nt->setSummary( "Work on 2: Lutz"); |
1064 | nt->setPriority( 1 ); | 1064 | nt->setPriority( 1 ); |
1065 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1065 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1066 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); | 1066 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); |
1067 | nt->setPercentComplete( 20 ); | 1067 | nt->setPercentComplete( 20 ); |
1068 | Todo * workLutz12 = nt; | 1068 | Todo * workLutz12 = nt; |
1069 | workLutz12->setRelatedTo( sub2 ); | 1069 | workLutz12->setRelatedTo( sub2 ); |
1070 | 1070 | ||
1071 | nt = new Todo; | 1071 | nt = new Todo; |
1072 | mCalendar->addTodo( nt ); | 1072 | mCalendar->addTodo( nt ); |
1073 | nt->setSummary( "Work on 2: Norbert"); | 1073 | nt->setSummary( "Work on 2: Norbert"); |
1074 | nt->setPriority( 1 ); | 1074 | nt->setPriority( 1 ); |
1075 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1075 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1076 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); | 1076 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); |
1077 | nt->setPercentComplete( 20 ); | 1077 | nt->setPercentComplete( 20 ); |
1078 | Todo * workNorbert12 = nt; | 1078 | Todo * workNorbert12 = nt; |
1079 | workNorbert12->setRelatedTo( sub2 ); | 1079 | workNorbert12->setRelatedTo( sub2 ); |
1080 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); | 1080 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); |
1081 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); | 1081 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); |
1082 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); | 1082 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); |
1083 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); | 1083 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); |
1084 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); | 1084 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); |
1085 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); | 1085 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); |
1086 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); | 1086 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); |
1087 | } | 1087 | } |
1088 | updateView(); | 1088 | updateView(); |
1089 | #endif | 1089 | #endif |
1090 | 1090 | ||
1091 | } | 1091 | } |
1092 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) | 1092 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) |
1093 | { | 1093 | { |
1094 | static int ccc = 0; | 1094 | static int ccc = 0; |
1095 | ++ccc; | 1095 | ++ccc; |
1096 | QDateTime t_start = start; | 1096 | QDateTime t_start = start; |
1097 | runT->setPriority( 5 ); | 1097 | runT->setPriority( 5 ); |
1098 | runT->setPercentComplete( 0 ); | 1098 | runT->setPercentComplete( 0 ); |
1099 | int count = 0; | 1099 | int count = 0; |
1100 | int prio = 5; | 1100 | int prio = 5; |
1101 | int complete = 0; | 1101 | int complete = 0; |
1102 | while ( t_start < end ) { | 1102 | while ( t_start < end ) { |
1103 | ++count; | 1103 | ++count; |
1104 | if ( count > ccc ) { | 1104 | if ( count > ccc ) { |
1105 | count = 0; | 1105 | count = 0; |
1106 | --prio; | 1106 | --prio; |
1107 | if ( prio == 0 ) prio = 5; | 1107 | if ( prio == 0 ) prio = 5; |
1108 | complete += 20; | 1108 | complete += 20; |
1109 | if ( complete > 100 ) complete = 0; | 1109 | if ( complete > 100 ) complete = 0; |
1110 | runT->setPriority( prio ); | 1110 | runT->setPriority( prio ); |
1111 | runT->setPercentComplete( complete ); | 1111 | runT->setPercentComplete( complete ); |
1112 | } | 1112 | } |
1113 | runT->setRunning( true ); | 1113 | runT->setRunning( true ); |
1114 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); | 1114 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); |
1115 | if ( dayInterval ) | 1115 | if ( dayInterval ) |
1116 | t_start = t_start.addDays( dayInterval ); | 1116 | t_start = t_start.addDays( dayInterval ); |
1117 | else { | 1117 | else { |
1118 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); | 1118 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); |
1119 | } | 1119 | } |
1120 | } | 1120 | } |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | void CalendarView::showDay( QDate d ) | 1123 | void CalendarView::showDay( QDate d ) |
1124 | { | 1124 | { |
1125 | dateNavigator()->blockSignals( true ); | 1125 | dateNavigator()->blockSignals( true ); |
1126 | dateNavigator()->selectDate( d ); | 1126 | dateNavigator()->selectDate( d ); |
1127 | dateNavigator()->blockSignals( false ); | 1127 | dateNavigator()->blockSignals( false ); |
1128 | mViewManager->showDayView(); | 1128 | mViewManager->showDayView(); |
1129 | //dateNavigator()->selectDate( d ); | 1129 | //dateNavigator()->selectDate( d ); |
1130 | } | 1130 | } |
1131 | void CalendarView::timerAlarm() | 1131 | void CalendarView::timerAlarm() |
1132 | { | 1132 | { |
1133 | //qDebug("CalendarView::timerAlarm() "); | 1133 | //qDebug("CalendarView::timerAlarm() "); |
1134 | computeAlarm(mAlarmNotification ); | 1134 | computeAlarm(mAlarmNotification ); |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | void CalendarView::suspendAlarm() | 1137 | void CalendarView::suspendAlarm() |
1138 | { | 1138 | { |
1139 | //qDebug(" CalendarView::suspendAlarm() "); | 1139 | //qDebug(" CalendarView::suspendAlarm() "); |
1140 | computeAlarm(mSuspendAlarmNotification ); | 1140 | computeAlarm(mSuspendAlarmNotification ); |
1141 | 1141 | ||
1142 | } | 1142 | } |
1143 | 1143 | ||
1144 | void CalendarView::startAlarm( QString mess , QString filename) | 1144 | void CalendarView::startAlarm( QString mess , QString filename) |
1145 | { | 1145 | { |
1146 | 1146 | ||
1147 | topLevelWidget()->showNormal(); | 1147 | topLevelWidget()->showNormal(); |
1148 | topLevelWidget()->setActiveWindow(); | 1148 | topLevelWidget()->setActiveWindow(); |
1149 | topLevelWidget()->raise(); | 1149 | topLevelWidget()->raise(); |
1150 | 1150 | ||
1151 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 1151 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
1152 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 1152 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
1153 | 1153 | ||
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | void CalendarView::checkNextTimerAlarm() | 1156 | void CalendarView::checkNextTimerAlarm() |
1157 | { | 1157 | { |
1158 | mCalendar->checkAlarmForIncidence( 0, true ); | 1158 | mCalendar->checkAlarmForIncidence( 0, true ); |
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | void CalendarView::computeAlarm( QString msg ) | 1161 | void CalendarView::computeAlarm( QString msg ) |
1162 | { | 1162 | { |
1163 | 1163 | ||
1164 | QString mess = msg; | 1164 | QString mess = msg; |
1165 | QString mAlarmMessage = mess.mid( 9 ); | 1165 | QString mAlarmMessage = mess.mid( 9 ); |
1166 | QString filename = MainWindow::resourcePath(); | 1166 | QString filename = MainWindow::resourcePath(); |
1167 | filename += "koalarm.wav"; | 1167 | filename += "koalarm.wav"; |
1168 | QString tempfilename; | 1168 | QString tempfilename; |
1169 | if ( mess.left( 13 ) == "suspend_alarm") { | 1169 | if ( mess.left( 13 ) == "suspend_alarm") { |
1170 | bool error = false; | 1170 | bool error = false; |
1171 | int len = mess.mid( 13 ).find("+++"); | 1171 | int len = mess.mid( 13 ).find("+++"); |
1172 | if ( len < 2 ) | 1172 | if ( len < 2 ) |
1173 | error = true; | 1173 | error = true; |
1174 | else { | 1174 | else { |
1175 | tempfilename = mess.mid( 13, len ); | 1175 | tempfilename = mess.mid( 13, len ); |
1176 | if ( !QFile::exists( tempfilename ) ) | 1176 | if ( !QFile::exists( tempfilename ) ) |
1177 | error = true; | 1177 | error = true; |
1178 | } | 1178 | } |
1179 | if ( ! error ) { | 1179 | if ( ! error ) { |
1180 | filename = tempfilename; | 1180 | filename = tempfilename; |
1181 | } | 1181 | } |
1182 | mAlarmMessage = mess.mid( 13+len+3 ); | 1182 | mAlarmMessage = mess.mid( 13+len+3 ); |
1183 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 1183 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
1184 | startAlarm( mAlarmMessage, filename); | 1184 | startAlarm( mAlarmMessage, filename); |
1185 | return; | 1185 | return; |
1186 | } | 1186 | } |
1187 | if ( mess.left( 11 ) == "timer_alarm") { | 1187 | if ( mess.left( 11 ) == "timer_alarm") { |
1188 | //mTimerTime = 0; | 1188 | //mTimerTime = 0; |
1189 | startAlarm( mess.mid( 11 ), filename ); | 1189 | startAlarm( mess.mid( 11 ), filename ); |
1190 | return; | 1190 | return; |
1191 | } | 1191 | } |
1192 | if ( mess.left( 10 ) == "proc_alarm") { | 1192 | if ( mess.left( 10 ) == "proc_alarm") { |
1193 | bool error = false; | 1193 | bool error = false; |
1194 | int len = mess.mid( 10 ).find("+++"); | 1194 | int len = mess.mid( 10 ).find("+++"); |
1195 | if ( len < 2 ) | 1195 | if ( len < 2 ) |
1196 | error = true; | 1196 | error = true; |
1197 | else { | 1197 | else { |
1198 | tempfilename = mess.mid( 10, len ); | 1198 | tempfilename = mess.mid( 10, len ); |
1199 | if ( !QFile::exists( tempfilename ) ) | 1199 | if ( !QFile::exists( tempfilename ) ) |
1200 | error = true; | 1200 | error = true; |
1201 | } | 1201 | } |
1202 | if ( error ) { | 1202 | if ( error ) { |
1203 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1203 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1204 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1204 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1205 | } else { | 1205 | } else { |
1206 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1206 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1207 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1207 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1208 | #ifndef _WIN32_ | 1208 | #ifndef _WIN32_ |
1209 | if ( vfork () == 0 ) { | 1209 | if ( vfork () == 0 ) { |
1210 | execl ( tempfilename.latin1(), 0 ); | 1210 | execl ( tempfilename.latin1(), 0 ); |
1211 | return; | 1211 | return; |
1212 | } | 1212 | } |
1213 | #else | 1213 | #else |
1214 | QProcess* p = new QProcess(); | 1214 | QProcess* p = new QProcess(); |
1215 | p->addArgument( tempfilename.latin1() ); | 1215 | p->addArgument( tempfilename.latin1() ); |
1216 | p->start(); | 1216 | p->start(); |
1217 | return; | 1217 | return; |
1218 | #endif | 1218 | #endif |
1219 | 1219 | ||
1220 | return; | 1220 | return; |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1223 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1224 | } | 1224 | } |
1225 | if ( mess.left( 11 ) == "audio_alarm") { | 1225 | if ( mess.left( 11 ) == "audio_alarm") { |
1226 | bool error = false; | 1226 | bool error = false; |
1227 | int len = mess.mid( 11 ).find("+++"); | 1227 | int len = mess.mid( 11 ).find("+++"); |
1228 | if ( len < 2 ) | 1228 | if ( len < 2 ) |
1229 | error = true; | 1229 | error = true; |
1230 | else { | 1230 | else { |
1231 | tempfilename = mess.mid( 11, len ); | 1231 | tempfilename = mess.mid( 11, len ); |
1232 | if ( !QFile::exists( tempfilename ) ) | 1232 | if ( !QFile::exists( tempfilename ) ) |
1233 | error = true; | 1233 | error = true; |
1234 | } | 1234 | } |
1235 | if ( ! error ) { | 1235 | if ( ! error ) { |
1236 | filename = tempfilename; | 1236 | filename = tempfilename; |
1237 | } | 1237 | } |
1238 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1238 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1239 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1239 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1240 | } | 1240 | } |
1241 | if ( mess.left( 9 ) == "cal_alarm") { | 1241 | if ( mess.left( 9 ) == "cal_alarm") { |
1242 | mAlarmMessage = mess.mid( 9 ) ; | 1242 | mAlarmMessage = mess.mid( 9 ) ; |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | startAlarm( mAlarmMessage, filename ); | 1245 | startAlarm( mAlarmMessage, filename ); |
1246 | 1246 | ||
1247 | 1247 | ||
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1250 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1251 | { | 1251 | { |
1252 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1252 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1253 | 1253 | ||
1254 | mSuspendAlarmNotification = noti; | 1254 | mSuspendAlarmNotification = noti; |
1255 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1255 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1256 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1256 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1257 | mSuspendTimer->start( ms , true ); | 1257 | mSuspendTimer->start( ms , true ); |
1258 | #ifdef DESKTOP_VERSION | 1258 | #ifdef DESKTOP_VERSION |
1259 | if ( QApplication::desktop()->width() < 1024 ) { | 1259 | if ( QApplication::desktop()->width() < 1024 ) { |
1260 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1260 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1261 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); | 1261 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); |
1262 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; | 1262 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; |
1263 | QFile file( fn ); | 1263 | QFile file( fn ); |
1264 | if (!file.open( IO_WriteOnly ) ) { | 1264 | if (!file.open( IO_WriteOnly ) ) { |
1265 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1265 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1266 | } else { | 1266 | } else { |
1267 | QTextStream ts( &file ); | 1267 | QTextStream ts( &file ); |
1268 | ts << mess; | 1268 | ts << mess; |
1269 | file.close(); | 1269 | file.close(); |
1270 | } | 1270 | } |
1271 | } | 1271 | } |
1272 | #endif | 1272 | #endif |
1273 | 1273 | ||
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1276 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1277 | { | 1277 | { |
1278 | mNextAlarmDateTime = qdt; | 1278 | mNextAlarmDateTime = qdt; |
1279 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1279 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1280 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1280 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1281 | #ifndef DESKTOP_VERSION | 1281 | #ifndef DESKTOP_VERSION |
1282 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1282 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1283 | #endif | 1283 | #endif |
1284 | return; | 1284 | return; |
1285 | } | 1285 | } |
1286 | #ifdef DESKTOP_VERSION | 1286 | #ifdef DESKTOP_VERSION |
1287 | if ( QApplication::desktop()->width() < 1024 ) { | 1287 | if ( QApplication::desktop()->width() < 1024 ) { |
1288 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1288 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1289 | //qDebug("nextalarm = \n%s ",mess.latin1() ); | 1289 | //qDebug("nextalarm = \n%s ",mess.latin1() ); |
1290 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; | 1290 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; |
1291 | QFile file( fn ); | 1291 | QFile file( fn ); |
1292 | if (!file.open( IO_WriteOnly ) ) { | 1292 | if (!file.open( IO_WriteOnly ) ) { |
1293 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1293 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1294 | } else { | 1294 | } else { |
1295 | QTextStream ts( &file ); | 1295 | QTextStream ts( &file ); |
1296 | ts << mess; | 1296 | ts << mess; |
1297 | file.close(); | 1297 | file.close(); |
1298 | } | 1298 | } |
1299 | } | 1299 | } |
1300 | #endif | 1300 | #endif |
1301 | int maxSec; | 1301 | int maxSec; |
1302 | //maxSec = 5; //testing only | 1302 | //maxSec = 5; //testing only |
1303 | maxSec = 86400+3600; // one day+1hour | 1303 | maxSec = 86400+3600; // one day+1hour |
1304 | mAlarmNotification = noti; | 1304 | mAlarmNotification = noti; |
1305 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1305 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1306 | if ( sec > maxSec ) { | 1306 | if ( sec > maxSec ) { |
1307 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1307 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1308 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1308 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1309 | return; | 1309 | return; |
1310 | } else { | 1310 | } else { |
1311 | mRecheckAlarmTimer->stop(); | 1311 | mRecheckAlarmTimer->stop(); |
1312 | } | 1312 | } |
1313 | //qDebug("Alarm timer started with secs: %d ", sec); | 1313 | //qDebug("Alarm timer started with secs: %d ", sec); |
1314 | mAlarmTimer->start( sec * 1000 , true ); | 1314 | mAlarmTimer->start( sec * 1000 , true ); |
1315 | 1315 | ||
1316 | } | 1316 | } |
1317 | // called by mRecheckAlarmTimer to get next alarm | 1317 | // called by mRecheckAlarmTimer to get next alarm |
1318 | // we need this, because a QTimer has only a max range of 25 days | 1318 | // we need this, because a QTimer has only a max range of 25 days |
1319 | void CalendarView::recheckTimerAlarm() | 1319 | void CalendarView::recheckTimerAlarm() |
1320 | { | 1320 | { |
1321 | mAlarmTimer->stop(); | 1321 | mAlarmTimer->stop(); |
1322 | mRecheckAlarmTimer->stop(); | 1322 | mRecheckAlarmTimer->stop(); |
1323 | mCalendar->checkAlarmForIncidence( 0, true ); | 1323 | mCalendar->checkAlarmForIncidence( 0, true ); |
1324 | } | 1324 | } |
1325 | #ifndef DESKTOP_VERSION | 1325 | #ifndef DESKTOP_VERSION |
1326 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1326 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1327 | #else | 1327 | #else |
1328 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1328 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1329 | #endif | 1329 | #endif |
1330 | { | 1330 | { |
1331 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1331 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1332 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1332 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1333 | #ifndef DESKTOP_VERSION | 1333 | #ifndef DESKTOP_VERSION |
1334 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1334 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1335 | #endif | 1335 | #endif |
1336 | return; | 1336 | return; |
1337 | } | 1337 | } |
1338 | mAlarmTimer->stop(); | 1338 | mAlarmTimer->stop(); |
1339 | } | 1339 | } |
1340 | void CalendarView::selectWeekNum ( int num ) | 1340 | void CalendarView::selectWeekNum ( int num ) |
1341 | { | 1341 | { |
1342 | dateNavigator()->blockSignals( true ); | 1342 | dateNavigator()->blockSignals( true ); |
1343 | dateNavigator()->selectWeek( num ); | 1343 | dateNavigator()->selectWeek( num ); |
1344 | dateNavigator()->blockSignals( false ); | 1344 | dateNavigator()->blockSignals( false ); |
1345 | mViewManager->showWeekView(); | 1345 | mViewManager->showWeekView(); |
1346 | } | 1346 | } |
1347 | KOViewManager *CalendarView::viewManager() | 1347 | KOViewManager *CalendarView::viewManager() |
1348 | { | 1348 | { |
1349 | return mViewManager; | 1349 | return mViewManager; |
1350 | } | 1350 | } |
1351 | 1351 | ||
1352 | KODialogManager *CalendarView::dialogManager() | 1352 | KODialogManager *CalendarView::dialogManager() |
1353 | { | 1353 | { |
1354 | return mDialogManager; | 1354 | return mDialogManager; |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | QDate CalendarView::startDate() | 1357 | QDate CalendarView::startDate() |
1358 | { | 1358 | { |
1359 | DateList dates = mNavigator->selectedDates(); | 1359 | DateList dates = mNavigator->selectedDates(); |
1360 | 1360 | ||
1361 | return dates.first(); | 1361 | return dates.first(); |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | QDate CalendarView::endDate() | 1364 | QDate CalendarView::endDate() |
1365 | { | 1365 | { |
1366 | DateList dates = mNavigator->selectedDates(); | 1366 | DateList dates = mNavigator->selectedDates(); |
1367 | 1367 | ||
1368 | return dates.last(); | 1368 | return dates.last(); |
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | 1371 | ||
1372 | void CalendarView::createPrinter() | 1372 | void CalendarView::createPrinter() |
1373 | { | 1373 | { |
1374 | #ifndef KORG_NOPRINTER | 1374 | #ifndef KORG_NOPRINTER |
1375 | if (!mCalPrinter) { | 1375 | if (!mCalPrinter) { |
1376 | mCalPrinter = new CalPrinter(this, mCalendar); | 1376 | mCalPrinter = new CalPrinter(this, mCalendar); |
1377 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1377 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1378 | } | 1378 | } |
1379 | #endif | 1379 | #endif |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | 1382 | ||
1383 | //KOPrefs::instance()->mWriteBackFile | 1383 | //KOPrefs::instance()->mWriteBackFile |
1384 | //KOPrefs::instance()->mWriteBackExistingOnly | 1384 | //KOPrefs::instance()->mWriteBackExistingOnly |
1385 | 1385 | ||
1386 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1386 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1387 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1387 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1388 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1388 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1389 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1389 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1390 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1390 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1391 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1391 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1392 | 1392 | ||
1393 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1393 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1394 | { | 1394 | { |
1395 | 1395 | ||
1396 | // 0 equal | 1396 | // 0 equal |
1397 | // 1 take local | 1397 | // 1 take local |
1398 | // 2 take remote | 1398 | // 2 take remote |
1399 | // 3 cancel | 1399 | // 3 cancel |
1400 | QDateTime lastSync = mLastCalendarSync; | 1400 | QDateTime lastSync = mLastCalendarSync; |
1401 | QDateTime localMod = local->lastModified(); | 1401 | QDateTime localMod = local->lastModified(); |
1402 | QDateTime remoteMod = remote->lastModified(); | 1402 | QDateTime remoteMod = remote->lastModified(); |
1403 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1403 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1404 | bool remCh, locCh; | 1404 | bool remCh, locCh; |
1405 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1405 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1406 | //if ( remCh ) | 1406 | //if ( remCh ) |
1407 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1407 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1408 | locCh = ( localMod > mLastCalendarSync ); | 1408 | locCh = ( localMod > mLastCalendarSync ); |
1409 | if ( !remCh && ! locCh ) { | 1409 | if ( !remCh && ! locCh ) { |
1410 | //qDebug("both not changed "); | 1410 | //qDebug("both not changed "); |
1411 | lastSync = localMod.addDays(1); | 1411 | lastSync = localMod.addDays(1); |
1412 | if ( mode <= SYNC_PREF_ASK ) | 1412 | if ( mode <= SYNC_PREF_ASK ) |
1413 | return 0; | 1413 | return 0; |
1414 | } else { | 1414 | } else { |
1415 | if ( locCh ) { | 1415 | if ( locCh ) { |
1416 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1416 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1417 | lastSync = localMod.addDays( -1 ); | 1417 | lastSync = localMod.addDays( -1 ); |
1418 | if ( !remCh ) | 1418 | if ( !remCh ) |
1419 | remoteMod = ( lastSync.addDays( -1 ) ); | 1419 | remoteMod = ( lastSync.addDays( -1 ) ); |
1420 | } else { | 1420 | } else { |
1421 | //qDebug(" not loc changed "); | 1421 | //qDebug(" not loc changed "); |
1422 | lastSync = localMod.addDays( 1 ); | 1422 | lastSync = localMod.addDays( 1 ); |
1423 | if ( remCh ) | 1423 | if ( remCh ) |
1424 | remoteMod =( lastSync.addDays( 1 ) ); | 1424 | remoteMod =( lastSync.addDays( 1 ) ); |
1425 | 1425 | ||
1426 | } | 1426 | } |
1427 | } | 1427 | } |
1428 | full = true; | 1428 | full = true; |
1429 | if ( mode < SYNC_PREF_ASK ) | 1429 | if ( mode < SYNC_PREF_ASK ) |
1430 | mode = SYNC_PREF_ASK; | 1430 | mode = SYNC_PREF_ASK; |
1431 | } else { | 1431 | } else { |
1432 | if ( localMod == remoteMod ) | 1432 | if ( localMod == remoteMod ) |
1433 | // if ( local->revision() == remote->revision() ) | 1433 | // if ( local->revision() == remote->revision() ) |
1434 | return 0; | 1434 | return 0; |
1435 | 1435 | ||
1436 | } | 1436 | } |
1437 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1437 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1438 | 1438 | ||
1439 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1439 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1440 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1440 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1441 | //full = true; //debug only | 1441 | //full = true; //debug only |
1442 | if ( full ) { | 1442 | if ( full ) { |
1443 | bool equ = false; | 1443 | bool equ = false; |
1444 | if ( local->typeID() == eventID ) { | 1444 | if ( local->typeID() == eventID ) { |
1445 | equ = (*((Event*) local) == *((Event*) remote)); | 1445 | equ = (*((Event*) local) == *((Event*) remote)); |
1446 | } | 1446 | } |
1447 | else if ( local->typeID() == todoID ) | 1447 | else if ( local->typeID() == todoID ) |
1448 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1448 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1449 | else if ( local->typeID() == journalID ) | 1449 | else if ( local->typeID() == journalID ) |
1450 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1450 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1451 | if ( equ ) { | 1451 | if ( equ ) { |
1452 | //qDebug("equal "); | 1452 | //qDebug("equal "); |
1453 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1453 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1454 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1454 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1455 | } | 1455 | } |
1456 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1456 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1457 | return 0; | 1457 | return 0; |
1458 | 1458 | ||
1459 | }//else //debug only | 1459 | }//else //debug only |
1460 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1460 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1461 | } | 1461 | } |
1462 | int result; | 1462 | int result; |
1463 | bool localIsNew; | 1463 | bool localIsNew; |
1464 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 1464 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
1465 | 1465 | ||
1466 | 1466 | ||
1467 | // ************************************************ | 1467 | // ************************************************ |
1468 | // ************************************************ | 1468 | // ************************************************ |
1469 | // ************************************************ | 1469 | // ************************************************ |
1470 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1470 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1471 | // BUT remoteMod != localMod | 1471 | // BUT remoteMod != localMod |
1472 | 1472 | ||
1473 | 1473 | ||
1474 | if ( full && mode < SYNC_PREF_NEWEST ) | 1474 | if ( full && mode < SYNC_PREF_NEWEST ) |
1475 | mode = SYNC_PREF_ASK; | 1475 | mode = SYNC_PREF_ASK; |
1476 | 1476 | ||
1477 | switch( mode ) { | 1477 | switch( mode ) { |
1478 | case SYNC_PREF_LOCAL: | 1478 | case SYNC_PREF_LOCAL: |
1479 | if ( lastSync > remoteMod ) | 1479 | if ( lastSync > remoteMod ) |
1480 | return 1; | 1480 | return 1; |
1481 | if ( lastSync > localMod ) | 1481 | if ( lastSync > localMod ) |
1482 | return 2; | 1482 | return 2; |
1483 | return 1; | 1483 | return 1; |
1484 | break; | 1484 | break; |
1485 | case SYNC_PREF_REMOTE: | 1485 | case SYNC_PREF_REMOTE: |
1486 | if ( lastSync > localMod ) | 1486 | if ( lastSync > localMod ) |
1487 | return 2; | 1487 | return 2; |
1488 | if ( lastSync > remoteMod ) | 1488 | if ( lastSync > remoteMod ) |
1489 | return 1; | 1489 | return 1; |
1490 | return 2; | 1490 | return 2; |
1491 | break; | 1491 | break; |
1492 | case SYNC_PREF_NEWEST: | 1492 | case SYNC_PREF_NEWEST: |
1493 | if ( localMod >= remoteMod ) | 1493 | if ( localMod >= remoteMod ) |
1494 | return 1; | 1494 | return 1; |
1495 | else | 1495 | else |
1496 | return 2; | 1496 | return 2; |
1497 | break; | 1497 | break; |
1498 | case SYNC_PREF_ASK: | 1498 | case SYNC_PREF_ASK: |
1499 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1499 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1500 | if ( lastSync > remoteMod && lastSync > localMod) | 1500 | if ( lastSync > remoteMod && lastSync > localMod) |
1501 | return 0; | 1501 | return 0; |
1502 | if ( lastSync > remoteMod ) | 1502 | if ( lastSync > remoteMod ) |
1503 | return 1; | 1503 | return 1; |
1504 | if ( lastSync > localMod ) | 1504 | if ( lastSync > localMod ) |
1505 | return 2; | 1505 | return 2; |
1506 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1506 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1507 | localIsNew = localMod >= remoteMod; | 1507 | localIsNew = localMod >= remoteMod; |
1508 | if ( localIsNew ) | 1508 | if ( localIsNew ) |
1509 | getEventViewerDialog()->setColorMode( 1 ); | 1509 | getEventViewerDialog()->setColorMode( 1 ); |
1510 | else | 1510 | else |
1511 | getEventViewerDialog()->setColorMode( 2 ); | 1511 | getEventViewerDialog()->setColorMode( 2 ); |
1512 | getEventViewerDialog()->setIncidence(local); | 1512 | getEventViewerDialog()->setIncidence(local); |
1513 | if ( localIsNew ) | 1513 | if ( localIsNew ) |
1514 | getEventViewerDialog()->setColorMode( 2 ); | 1514 | getEventViewerDialog()->setColorMode( 2 ); |
1515 | else | 1515 | else |
1516 | getEventViewerDialog()->setColorMode( 1 ); | 1516 | getEventViewerDialog()->setColorMode( 1 ); |
1517 | getEventViewerDialog()->addIncidence(remote); | 1517 | getEventViewerDialog()->addIncidence(remote); |
1518 | getEventViewerDialog()->setColorMode( 0 ); | 1518 | getEventViewerDialog()->setColorMode( 0 ); |
1519 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1519 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1520 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1520 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1521 | getEventViewerDialog()->showMe(); | 1521 | getEventViewerDialog()->showMe(); |
1522 | result = getEventViewerDialog()->executeS( localIsNew ); | 1522 | result = getEventViewerDialog()->executeS( localIsNew ); |
1523 | return result; | 1523 | return result; |
1524 | 1524 | ||
1525 | break; | 1525 | break; |
1526 | case SYNC_PREF_FORCE_LOCAL: | 1526 | case SYNC_PREF_FORCE_LOCAL: |
1527 | return 1; | 1527 | return 1; |
1528 | break; | 1528 | break; |
1529 | case SYNC_PREF_FORCE_REMOTE: | 1529 | case SYNC_PREF_FORCE_REMOTE: |
1530 | return 2; | 1530 | return 2; |
1531 | break; | 1531 | break; |
1532 | 1532 | ||
1533 | default: | 1533 | default: |
1534 | // SYNC_PREF_TAKE_BOTH not implemented | 1534 | // SYNC_PREF_TAKE_BOTH not implemented |
1535 | break; | 1535 | break; |
1536 | } | 1536 | } |
1537 | return 0; | 1537 | return 0; |
1538 | } | 1538 | } |
1539 | Event* CalendarView::getLastSyncEvent() | 1539 | Event* CalendarView::getLastSyncEvent() |
1540 | { | 1540 | { |
1541 | Event* lse; | 1541 | Event* lse; |
1542 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1542 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1543 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1543 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1544 | if (!lse) { | 1544 | if (!lse) { |
1545 | lse = new Event(); | 1545 | lse = new Event(); |
1546 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1546 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1547 | QString sum = ""; | 1547 | QString sum = ""; |
1548 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1548 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1549 | sum = "E: "; | 1549 | sum = "E: "; |
1550 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1550 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1551 | lse->setDtStart( mLastCalendarSync ); | 1551 | lse->setDtStart( mLastCalendarSync ); |
1552 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1552 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1553 | lse->setCategories( i18n("SyncEvent") ); | 1553 | lse->setCategories( i18n("SyncEvent") ); |
1554 | lse->setReadOnly( true ); | 1554 | lse->setReadOnly( true ); |
1555 | mCalendar->addEvent( lse ); | 1555 | mCalendar->addEvent( lse ); |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | return lse; | 1558 | return lse; |
1559 | 1559 | ||
1560 | } | 1560 | } |
1561 | 1561 | ||
1562 | // we check, if the to delete event has a id for a profile | 1562 | // we check, if the to delete event has a id for a profile |
1563 | // if yes, we set this id in the profile to delete | 1563 | // if yes, we set this id in the profile to delete |
1564 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1564 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1565 | { | 1565 | { |
1566 | if ( lastSync.count() == 0 ) { | 1566 | if ( lastSync.count() == 0 ) { |
1567 | //qDebug(" lastSync.count() == 0"); | 1567 | //qDebug(" lastSync.count() == 0"); |
1568 | return; | 1568 | return; |
1569 | } | 1569 | } |
1570 | if ( toDelete->typeID() == journalID ) | 1570 | if ( toDelete->typeID() == journalID ) |
1571 | return; | 1571 | return; |
1572 | 1572 | ||
1573 | Event* eve = lastSync.first(); | 1573 | Event* eve = lastSync.first(); |
1574 | 1574 | ||
1575 | while ( eve ) { | 1575 | while ( eve ) { |
1576 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1576 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1577 | if ( !id.isEmpty() ) { | 1577 | if ( !id.isEmpty() ) { |
1578 | QString des = eve->description(); | 1578 | QString des = eve->description(); |
1579 | QString pref = "e"; | 1579 | QString pref = "e"; |
1580 | if ( toDelete->typeID() == todoID ) | 1580 | if ( toDelete->typeID() == todoID ) |
1581 | pref = "t"; | 1581 | pref = "t"; |
1582 | des += pref+ id + ","; | 1582 | des += pref+ id + ","; |
1583 | eve->setReadOnly( false ); | 1583 | eve->setReadOnly( false ); |
1584 | eve->setDescription( des ); | 1584 | eve->setDescription( des ); |
1585 | //qDebug("setdes %s ", des.latin1()); | 1585 | //qDebug("setdes %s ", des.latin1()); |
1586 | eve->setReadOnly( true ); | 1586 | eve->setReadOnly( true ); |
1587 | } | 1587 | } |
1588 | eve = lastSync.next(); | 1588 | eve = lastSync.next(); |
1589 | } | 1589 | } |
1590 | 1590 | ||
1591 | } | 1591 | } |
1592 | void CalendarView::checkExternalId( Incidence * inc ) | 1592 | void CalendarView::checkExternalId( Incidence * inc ) |
1593 | { | 1593 | { |
1594 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1594 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1595 | checkExternSyncEvent( lastSync, inc ); | 1595 | checkExternSyncEvent( lastSync, inc ); |
1596 | 1596 | ||
1597 | } | 1597 | } |
1598 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1598 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1599 | { | 1599 | { |
1600 | bool syncOK = true; | 1600 | bool syncOK = true; |
1601 | int addedEvent = 0; | 1601 | int addedEvent = 0; |
1602 | int addedEventR = 0; | 1602 | int addedEventR = 0; |
1603 | int deletedEventR = 0; | 1603 | int deletedEventR = 0; |
1604 | int deletedEventL = 0; | 1604 | int deletedEventL = 0; |
1605 | int changedLocal = 0; | 1605 | int changedLocal = 0; |
1606 | int changedRemote = 0; | 1606 | int changedRemote = 0; |
1607 | int filteredIN = 0; | 1607 | int filteredIN = 0; |
1608 | int filteredOUT = 0; | 1608 | int filteredOUT = 0; |
1609 | //QPtrList<Event> el = local->rawEvents(); | 1609 | //QPtrList<Event> el = local->rawEvents(); |
1610 | Event* eventR; | 1610 | Event* eventR; |
1611 | QString uid; | 1611 | QString uid; |
1612 | int take; | 1612 | int take; |
1613 | Event* eventRSync; | 1613 | Event* eventRSync; |
1614 | Event* eventLSync; | 1614 | Event* eventLSync; |
1615 | clearAllViews(); | 1615 | clearAllViews(); |
1616 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1616 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1617 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1617 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1618 | bool fullDateRange = false; | 1618 | bool fullDateRange = false; |
1619 | local->resetTempSyncStat(); | 1619 | local->resetTempSyncStat(); |
1620 | mLastCalendarSync = QDateTime::currentDateTime(); | 1620 | mLastCalendarSync = QDateTime::currentDateTime(); |
1621 | if ( mSyncManager->syncWithDesktop() ) { | 1621 | if ( mSyncManager->syncWithDesktop() ) { |
1622 | remote->resetPilotStat(1); | 1622 | remote->resetPilotStat(1); |
1623 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1623 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1624 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1624 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1625 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1625 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1626 | } else { | 1626 | } else { |
1627 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1627 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1628 | } | 1628 | } |
1629 | } | 1629 | } |
1630 | QDateTime modifiedCalendar = mLastCalendarSync; | 1630 | QDateTime modifiedCalendar = mLastCalendarSync; |
1631 | eventLSync = getLastSyncEvent(); | 1631 | eventLSync = getLastSyncEvent(); |
1632 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1632 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1633 | if ( eventR ) { | 1633 | if ( eventR ) { |
1634 | qDebug("last-syncEvent on remote found "); | 1634 | qDebug("last-syncEvent on remote found "); |
1635 | eventRSync = (Event*) eventR->clone(); | 1635 | eventRSync = (Event*) eventR->clone(); |
1636 | remote->deleteEvent(eventR ); | 1636 | remote->deleteEvent(eventR ); |
1637 | 1637 | ||
1638 | } else { | 1638 | } else { |
1639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1640 | eventRSync = (Event*)eventLSync->clone(); | 1640 | eventRSync = (Event*)eventLSync->clone(); |
1641 | } else { | 1641 | } else { |
1642 | fullDateRange = true; | 1642 | fullDateRange = true; |
1643 | eventRSync = new Event(); | 1643 | eventRSync = new Event(); |
1644 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1644 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1645 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1645 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1646 | eventRSync->setDtStart( mLastCalendarSync ); | 1646 | eventRSync->setDtStart( mLastCalendarSync ); |
1647 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1647 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1648 | eventRSync->setCategories( i18n("SyncEvent") ); | 1648 | eventRSync->setCategories( i18n("SyncEvent") ); |
1649 | } | 1649 | } |
1650 | } | 1650 | } |
1651 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1651 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1652 | fullDateRange = true; | 1652 | fullDateRange = true; |
1653 | 1653 | ||
1654 | if ( ! fullDateRange ) { | 1654 | if ( ! fullDateRange ) { |
1655 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1655 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1656 | 1656 | ||
1657 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1657 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1658 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1658 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1659 | fullDateRange = true; | 1659 | fullDateRange = true; |
1660 | } | 1660 | } |
1661 | } | 1661 | } |
1662 | if ( mSyncManager->syncWithDesktop() ) { | 1662 | if ( mSyncManager->syncWithDesktop() ) { |
1663 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1663 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1664 | } | 1664 | } |
1665 | if ( fullDateRange ) | 1665 | if ( fullDateRange ) |
1666 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1666 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1667 | else | 1667 | else |
1668 | mLastCalendarSync = eventLSync->dtStart(); | 1668 | mLastCalendarSync = eventLSync->dtStart(); |
1669 | // for resyncing if own file has changed | 1669 | // for resyncing if own file has changed |
1670 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1670 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1671 | mLastCalendarSync = loadedFileVersion; | 1671 | mLastCalendarSync = loadedFileVersion; |
1672 | //qDebug("setting mLastCalendarSync "); | 1672 | //qDebug("setting mLastCalendarSync "); |
1673 | } | 1673 | } |
1674 | //qDebug("*************************** "); | 1674 | //qDebug("*************************** "); |
1675 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1675 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1676 | QPtrList<Incidence> er = remote->rawIncidences(); | 1676 | QPtrList<Incidence> er = remote->rawIncidences(); |
1677 | Incidence* inR = er.first(); | 1677 | Incidence* inR = er.first(); |
1678 | Incidence* inL; | 1678 | Incidence* inL; |
1679 | QProgressBar bar( er.count(),0 ); | 1679 | QProgressBar bar( er.count(),0 ); |
1680 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1680 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1681 | 1681 | ||
1682 | // ************** setting up filter ************* | 1682 | // ************** setting up filter ************* |
1683 | CalFilter *filterIN = 0; | 1683 | CalFilter *filterIN = 0; |
1684 | CalFilter *filterOUT = 0; | 1684 | CalFilter *filterOUT = 0; |
1685 | CalFilter *filter = mFilters.first(); | 1685 | CalFilter *filter = mFilters.first(); |
1686 | while(filter) { | 1686 | while(filter) { |
1687 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1687 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1688 | filterIN = filter; | 1688 | filterIN = filter; |
1689 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1689 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1690 | filterOUT = filter; | 1690 | filterOUT = filter; |
1691 | filter = mFilters.next(); | 1691 | filter = mFilters.next(); |
1692 | } | 1692 | } |
1693 | int w = 300; | 1693 | int w = 300; |
1694 | if ( QApplication::desktop()->width() < 320 ) | 1694 | if ( QApplication::desktop()->width() < 320 ) |
1695 | w = 220; | 1695 | w = 220; |
1696 | int h = bar.sizeHint().height() ; | 1696 | int h = bar.sizeHint().height() ; |
1697 | int dw = QApplication::desktop()->width(); | 1697 | int dw = QApplication::desktop()->width(); |
1698 | int dh = QApplication::desktop()->height(); | 1698 | int dh = QApplication::desktop()->height(); |
1699 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1699 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1700 | bar.show(); | 1700 | bar.show(); |
1701 | int modulo = (er.count()/10)+1; | 1701 | int modulo = (er.count()/10)+1; |
1702 | int incCounter = 0; | 1702 | int incCounter = 0; |
1703 | while ( inR ) { | 1703 | while ( inR ) { |
1704 | if ( ! bar.isVisible() ) | 1704 | if ( ! bar.isVisible() ) |
1705 | return false; | 1705 | return false; |
1706 | if ( incCounter % modulo == 0 ) | 1706 | if ( incCounter % modulo == 0 ) |
1707 | bar.setProgress( incCounter ); | 1707 | bar.setProgress( incCounter ); |
1708 | ++incCounter; | 1708 | ++incCounter; |
1709 | uid = inR->uid(); | 1709 | uid = inR->uid(); |
1710 | bool skipIncidence = false; | 1710 | bool skipIncidence = false; |
1711 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1711 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1712 | skipIncidence = true; | 1712 | skipIncidence = true; |
1713 | QString idS; | 1713 | QString idS; |
1714 | qApp->processEvents(); | 1714 | qApp->processEvents(); |
1715 | if ( !skipIncidence ) { | 1715 | if ( !skipIncidence ) { |
1716 | inL = local->incidenceForUid( uid , false ); | 1716 | inL = local->incidenceForUid( uid , false ); |
1717 | if ( inL ) { // maybe conflict - same uid in both calendars | 1717 | if ( inL ) { // maybe conflict - same uid in both calendars |
1718 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1718 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1719 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1719 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1720 | if ( take == 3 ) | 1720 | if ( take == 3 ) |
1721 | return false; | 1721 | return false; |
1722 | if ( take == 1 ) {// take local ********************** | 1722 | if ( take == 1 ) {// take local ********************** |
1723 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1723 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1724 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1724 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1725 | else | 1725 | else |
1726 | idS = inR->IDStr(); | 1726 | idS = inR->IDStr(); |
1727 | int calID = inR->calID(); | 1727 | int calID = inR->calID(); |
1728 | remote->deleteIncidence( inR ); | 1728 | remote->deleteIncidence( inR ); |
1729 | inR = inL->clone(); | 1729 | inR = inL->clone(); |
1730 | inR->setCalID( calID ); | 1730 | inR->setCalID( calID ); |
1731 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1731 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1732 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1732 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1733 | inR->setIDStr( idS ); | 1733 | inR->setIDStr( idS ); |
1734 | remote->addIncidence( inR ); | 1734 | remote->addIncidence( inR ); |
1735 | if ( mSyncManager->syncWithDesktop() ) | 1735 | if ( mSyncManager->syncWithDesktop() ) |
1736 | inR->setPilotId( 2 ); | 1736 | inR->setPilotId( 2 ); |
1737 | ++changedRemote; | 1737 | ++changedRemote; |
1738 | } else {// take remote ********************** | 1738 | } else {// take remote ********************** |
1739 | if ( !inL->isReadOnly() ) { | 1739 | if ( !inL->isReadOnly() ) { |
1740 | idS = inL->IDStr(); | 1740 | idS = inL->IDStr(); |
1741 | int pid = inL->pilotId(); | 1741 | int pid = inL->pilotId(); |
1742 | int calID = inL->calID(); | 1742 | int calID = inL->calID(); |
1743 | local->deleteIncidence( inL ); | 1743 | local->deleteIncidence( inL ); |
1744 | inL = inR->clone(); | 1744 | inL = inR->clone(); |
1745 | inL->setCalID( calID ); | 1745 | inL->setCalID( calID ); |
1746 | if ( mSyncManager->syncWithDesktop() ) | 1746 | if ( mSyncManager->syncWithDesktop() ) |
1747 | inL->setPilotId( pid ); | 1747 | inL->setPilotId( pid ); |
1748 | inL->setIDStr( idS ); | 1748 | inL->setIDStr( idS ); |
1749 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1749 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1750 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1750 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1751 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1751 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1752 | } | 1752 | } |
1753 | local->addIncidence( inL ); | 1753 | local->addIncidence( inL ); |
1754 | ++changedLocal; | 1754 | ++changedLocal; |
1755 | } | 1755 | } |
1756 | } | 1756 | } |
1757 | } | 1757 | } |
1758 | } else { // no conflict ********** add or delete remote | 1758 | } else { // no conflict ********** add or delete remote |
1759 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1759 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1760 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1760 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1761 | QString des = eventLSync->description(); | 1761 | QString des = eventLSync->description(); |
1762 | QString pref = "e"; | 1762 | QString pref = "e"; |
1763 | if ( inR->typeID() == todoID ) | 1763 | if ( inR->typeID() == todoID ) |
1764 | pref = "t"; | 1764 | pref = "t"; |
1765 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1765 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1766 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1766 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1767 | //remote->deleteIncidence( inR ); | 1767 | //remote->deleteIncidence( inR ); |
1768 | ++deletedEventR; | 1768 | ++deletedEventR; |
1769 | } else { | 1769 | } else { |
1770 | inR->setLastModified( modifiedCalendar ); | 1770 | inR->setLastModified( modifiedCalendar ); |
1771 | inL = inR->clone(); | 1771 | inL = inR->clone(); |
1772 | inL->setIDStr( ":" ); | 1772 | inL->setIDStr( ":" ); |
1773 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1773 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1774 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1774 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1775 | 1775 | ||
1776 | inL->setCalID( 0 );// add to default cal | 1776 | inL->setCalID( 0 );// add to default cal |
1777 | local->addIncidence( inL ); | 1777 | local->addIncidence( inL ); |
1778 | ++addedEvent; | 1778 | ++addedEvent; |
1779 | 1779 | ||
1780 | } | 1780 | } |
1781 | } else { | 1781 | } else { |
1782 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1782 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1783 | inR->setLastModified( modifiedCalendar ); | 1783 | inR->setLastModified( modifiedCalendar ); |
1784 | inL = inR->clone(); | 1784 | inL = inR->clone(); |
1785 | inL->setIDStr( ":" ); | 1785 | inL->setIDStr( ":" ); |
1786 | inL->setCalID( 0 );// add to default cal | 1786 | inL->setCalID( 0 );// add to default cal |
1787 | local->addIncidence( inL ); | 1787 | local->addIncidence( inL ); |
1788 | ++addedEvent; | 1788 | ++addedEvent; |
1789 | 1789 | ||
1790 | } else { | 1790 | } else { |
1791 | checkExternSyncEvent(eventRSyncSharp, inR); | 1791 | checkExternSyncEvent(eventRSyncSharp, inR); |
1792 | remote->deleteIncidence( inR ); | 1792 | remote->deleteIncidence( inR ); |
1793 | ++deletedEventR; | 1793 | ++deletedEventR; |
1794 | } | 1794 | } |
1795 | } | 1795 | } |
1796 | } else { | 1796 | } else { |
1797 | ++filteredIN; | 1797 | ++filteredIN; |
1798 | } | 1798 | } |
1799 | } | 1799 | } |
1800 | } | 1800 | } |
1801 | inR = er.next(); | 1801 | inR = er.next(); |
1802 | } | 1802 | } |
1803 | QPtrList<Incidence> el = local->rawIncidences(); | 1803 | QPtrList<Incidence> el = local->rawIncidences(); |
1804 | inL = el.first(); | 1804 | inL = el.first(); |
1805 | modulo = (el.count()/10)+1; | 1805 | modulo = (el.count()/10)+1; |
1806 | bar.setCaption (i18n("Add / remove events") ); | 1806 | bar.setCaption (i18n("Add / remove events") ); |
1807 | bar.setTotalSteps ( el.count() ) ; | 1807 | bar.setTotalSteps ( el.count() ) ; |
1808 | bar.show(); | 1808 | bar.show(); |
1809 | incCounter = 0; | 1809 | incCounter = 0; |
1810 | 1810 | ||
1811 | while ( inL ) { | 1811 | while ( inL ) { |
1812 | 1812 | ||
1813 | qApp->processEvents(); | 1813 | qApp->processEvents(); |
1814 | if ( ! bar.isVisible() ) | 1814 | if ( ! bar.isVisible() ) |
1815 | return false; | 1815 | return false; |
1816 | if ( incCounter % modulo == 0 ) | 1816 | if ( incCounter % modulo == 0 ) |
1817 | bar.setProgress( incCounter ); | 1817 | bar.setProgress( incCounter ); |
1818 | ++incCounter; | 1818 | ++incCounter; |
1819 | uid = inL->uid(); | 1819 | uid = inL->uid(); |
1820 | bool skipIncidence = false; | 1820 | bool skipIncidence = false; |
1821 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1821 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1822 | skipIncidence = true; | 1822 | skipIncidence = true; |
1823 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1823 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1824 | skipIncidence = true; | 1824 | skipIncidence = true; |
1825 | if ( !skipIncidence ) { | 1825 | if ( !skipIncidence ) { |
1826 | inR = remote->incidenceForUid( uid , true ); | 1826 | inR = remote->incidenceForUid( uid , true ); |
1827 | if ( ! inR ) { | 1827 | if ( ! inR ) { |
1828 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1828 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1829 | // no conflict ********** add or delete local | 1829 | // no conflict ********** add or delete local |
1830 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1830 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1831 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1831 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1832 | checkExternSyncEvent(eventLSyncSharp, inL); | 1832 | checkExternSyncEvent(eventLSyncSharp, inL); |
1833 | local->deleteIncidence( inL ); | 1833 | local->deleteIncidence( inL ); |
1834 | ++deletedEventL; | 1834 | ++deletedEventL; |
1835 | } else { | 1835 | } else { |
1836 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1836 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1837 | inL->removeID(mCurrentSyncDevice ); | 1837 | inL->removeID(mCurrentSyncDevice ); |
1838 | ++addedEventR; | 1838 | ++addedEventR; |
1839 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1839 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1840 | inL->setLastModified( modifiedCalendar ); | 1840 | inL->setLastModified( modifiedCalendar ); |
1841 | inR = inL->clone(); | 1841 | inR = inL->clone(); |
1842 | inR->setIDStr( ":" ); | 1842 | inR->setIDStr( ":" ); |
1843 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1843 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1844 | inR->setCalID( 0 );// add to default cal | 1844 | inR->setCalID( 0 );// add to default cal |
1845 | remote->addIncidence( inR ); | 1845 | remote->addIncidence( inR ); |
1846 | } | 1846 | } |
1847 | } | 1847 | } |
1848 | } else { | 1848 | } else { |
1849 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1849 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1850 | checkExternSyncEvent(eventLSyncSharp, inL); | 1850 | checkExternSyncEvent(eventLSyncSharp, inL); |
1851 | local->deleteIncidence( inL ); | 1851 | local->deleteIncidence( inL ); |
1852 | ++deletedEventL; | 1852 | ++deletedEventL; |
1853 | } else { | 1853 | } else { |
1854 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1854 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1855 | ++addedEventR; | 1855 | ++addedEventR; |
1856 | inL->setLastModified( modifiedCalendar ); | 1856 | inL->setLastModified( modifiedCalendar ); |
1857 | inR = inL->clone(); | 1857 | inR = inL->clone(); |
1858 | inR->setIDStr( ":" ); | 1858 | inR->setIDStr( ":" ); |
1859 | inR->setCalID( 0 );// add to default cal | 1859 | inR->setCalID( 0 );// add to default cal |
1860 | remote->addIncidence( inR ); | 1860 | remote->addIncidence( inR ); |
1861 | } | 1861 | } |
1862 | } | 1862 | } |
1863 | } | 1863 | } |
1864 | } else { | 1864 | } else { |
1865 | ++filteredOUT; | 1865 | ++filteredOUT; |
1866 | } | 1866 | } |
1867 | } | 1867 | } |
1868 | } | 1868 | } |
1869 | inL = el.next(); | 1869 | inL = el.next(); |
1870 | } | 1870 | } |
1871 | int delFut = 0; | 1871 | int delFut = 0; |
1872 | int remRem = 0; | 1872 | int remRem = 0; |
1873 | if ( mSyncManager->mWriteBackInFuture ) { | 1873 | if ( mSyncManager->mWriteBackInFuture ) { |
1874 | er = remote->rawIncidences(); | 1874 | er = remote->rawIncidences(); |
1875 | remRem = er.count(); | 1875 | remRem = er.count(); |
1876 | inR = er.first(); | 1876 | inR = er.first(); |
1877 | QDateTime dt; | 1877 | QDateTime dt; |
1878 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1878 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1879 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1879 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1880 | while ( inR ) { | 1880 | while ( inR ) { |
1881 | if ( inR->typeID() == todoID ) { | 1881 | if ( inR->typeID() == todoID ) { |
1882 | Todo * t = (Todo*)inR; | 1882 | Todo * t = (Todo*)inR; |
1883 | if ( t->hasDueDate() ) | 1883 | if ( t->hasDueDate() ) |
1884 | dt = t->dtDue(); | 1884 | dt = t->dtDue(); |
1885 | else | 1885 | else |
1886 | dt = cur.addSecs( 62 ); | 1886 | dt = cur.addSecs( 62 ); |
1887 | } | 1887 | } |
1888 | else if (inR->typeID() == eventID ) { | 1888 | else if (inR->typeID() == eventID ) { |
1889 | bool ok; | 1889 | bool ok; |
1890 | dt = inR->getNextOccurence( cur, &ok ); | 1890 | dt = inR->getNextOccurence( cur, &ok ); |
1891 | if ( !ok ) | 1891 | if ( !ok ) |
1892 | dt = cur.addSecs( -62 ); | 1892 | dt = cur.addSecs( -62 ); |
1893 | } | 1893 | } |
1894 | else | 1894 | else |
1895 | dt = inR->dtStart(); | 1895 | dt = inR->dtStart(); |
1896 | if ( dt < cur || dt > end ) { | 1896 | if ( dt < cur || dt > end ) { |
1897 | remote->deleteIncidence( inR ); | 1897 | remote->deleteIncidence( inR ); |
1898 | ++delFut; | 1898 | ++delFut; |
1899 | } | 1899 | } |
1900 | inR = er.next(); | 1900 | inR = er.next(); |
1901 | } | 1901 | } |
1902 | } | 1902 | } |
1903 | bar.hide(); | 1903 | bar.hide(); |
1904 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1904 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1905 | eventLSync->setReadOnly( false ); | 1905 | eventLSync->setReadOnly( false ); |
1906 | eventLSync->setDtStart( mLastCalendarSync ); | 1906 | eventLSync->setDtStart( mLastCalendarSync ); |
1907 | eventRSync->setDtStart( mLastCalendarSync ); | 1907 | eventRSync->setDtStart( mLastCalendarSync ); |
1908 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1908 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1909 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1909 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1910 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1910 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1911 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1911 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1912 | eventLSync->setReadOnly( true ); | 1912 | eventLSync->setReadOnly( true ); |
1913 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1913 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1914 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1914 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1915 | remote->addEvent( eventRSync ); | 1915 | remote->addEvent( eventRSync ); |
1916 | else | 1916 | else |
1917 | delete eventRSync; | 1917 | delete eventRSync; |
1918 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1918 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1919 | QString mes; | 1919 | QString mes; |
1920 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1920 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1921 | QString delmess; | 1921 | QString delmess; |
1922 | if ( delFut ) { | 1922 | if ( delFut ) { |
1923 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1923 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1924 | mes += delmess; | 1924 | mes += delmess; |
1925 | } | 1925 | } |
1926 | mes = i18n("Local calendar changed!\n") +mes; | 1926 | mes = i18n("Local calendar changed!\n") +mes; |
1927 | mCalendar->checkAlarmForIncidence( 0, true ); | 1927 | mCalendar->checkAlarmForIncidence( 0, true ); |
1928 | qDebug( mes ); | 1928 | qDebug( mes ); |
1929 | if ( mSyncManager->mShowSyncSummary ) { | 1929 | if ( mSyncManager->mShowSyncSummary ) { |
1930 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1930 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1931 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1931 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1932 | qDebug("KO: WB cancelled "); | 1932 | qDebug("KO: WB cancelled "); |
1933 | mSyncManager->mWriteBackFile = false; | 1933 | mSyncManager->mWriteBackFile = false; |
1934 | return syncOK; | 1934 | return syncOK; |
1935 | } | 1935 | } |
1936 | } | 1936 | } |
1937 | return syncOK; | 1937 | return syncOK; |
1938 | } | 1938 | } |
1939 | 1939 | ||
1940 | void CalendarView::setSyncDevice( QString s ) | 1940 | void CalendarView::setSyncDevice( QString s ) |
1941 | { | 1941 | { |
1942 | mCurrentSyncDevice= s; | 1942 | mCurrentSyncDevice= s; |
1943 | } | 1943 | } |
1944 | void CalendarView::setSyncName( QString s ) | 1944 | void CalendarView::setSyncName( QString s ) |
1945 | { | 1945 | { |
1946 | mCurrentSyncName= s; | 1946 | mCurrentSyncName= s; |
1947 | } | 1947 | } |
1948 | bool CalendarView::syncCalendar(QString filename, int mode) | 1948 | bool CalendarView::syncCalendar(QString filename, int mode) |
1949 | { | 1949 | { |
1950 | //qDebug("syncCalendar %s ", filename.latin1()); | 1950 | //qDebug("syncCalendar %s ", filename.latin1()); |
1951 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1951 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1952 | CalendarLocal* calendar = new CalendarLocal(); | 1952 | CalendarLocal* calendar = new CalendarLocal(); |
1953 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1953 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1954 | FileStorage* storage = new FileStorage( calendar ); | 1954 | FileStorage* storage = new FileStorage( calendar ); |
1955 | bool syncOK = false; | 1955 | bool syncOK = false; |
1956 | storage->setFileName( filename ); | 1956 | storage->setFileName( filename ); |
1957 | // qDebug("loading ... "); | 1957 | // qDebug("loading ... "); |
1958 | if ( storage->load() ) { | 1958 | if ( storage->load() ) { |
1959 | getEventViewerDialog()->setSyncMode( true ); | 1959 | getEventViewerDialog()->setSyncMode( true ); |
1960 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1960 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1961 | getEventViewerDialog()->setSyncMode( false ); | 1961 | getEventViewerDialog()->setSyncMode( false ); |
1962 | if ( syncOK ) { | 1962 | if ( syncOK ) { |
1963 | if ( mSyncManager->mWriteBackFile ) | 1963 | if ( mSyncManager->mWriteBackFile ) |
1964 | { | 1964 | { |
1965 | storage->setSaveFormat( new ICalFormat() ); | 1965 | storage->setSaveFormat( new ICalFormat() ); |
1966 | storage->save(); | 1966 | storage->save(); |
1967 | } | 1967 | } |
1968 | } | 1968 | } |
1969 | setModified( true ); | 1969 | setModified( true ); |
1970 | } | 1970 | } |
1971 | delete storage; | 1971 | delete storage; |
1972 | delete calendar; | 1972 | delete calendar; |
1973 | if ( syncOK ) | 1973 | if ( syncOK ) |
1974 | updateView(); | 1974 | updateView(); |
1975 | return syncOK; | 1975 | return syncOK; |
1976 | } | 1976 | } |
1977 | 1977 | ||
1978 | void CalendarView::syncExternal( int mode ) | 1978 | void CalendarView::syncExternal( int mode ) |
1979 | { | 1979 | { |
1980 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1980 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1981 | |||
1982 | qApp->processEvents(); | 1981 | qApp->processEvents(); |
1983 | CalendarLocal* calendar = new CalendarLocal(); | 1982 | CalendarLocal* calendar = new CalendarLocal(); |
1984 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1983 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1985 | bool syncOK = false; | 1984 | bool syncOK = false; |
1986 | bool loadSuccess = false; | 1985 | bool loadSuccess = false; |
1987 | PhoneFormat* phoneFormat = 0; | 1986 | PhoneFormat* phoneFormat = 0; |
1988 | emit tempDisableBR(true); | 1987 | emit tempDisableBR(true); |
1989 | #ifndef DESKTOP_VERSION | 1988 | #ifndef DESKTOP_VERSION |
1990 | SharpFormat* sharpFormat = 0; | 1989 | SharpFormat* sharpFormat = 0; |
1991 | if ( mode == 0 ) { // sharp | 1990 | if ( mode == 0 ) { // sharp |
1992 | sharpFormat = new SharpFormat () ; | 1991 | sharpFormat = new SharpFormat () ; |
1993 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1992 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1994 | 1993 | ||
1995 | } else | 1994 | } else |
1996 | #endif | 1995 | #endif |
1997 | if ( mode == 1 ) { // phone | 1996 | if ( mode == 1 ) { // phone |
1998 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1997 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1999 | mSyncManager->mPhoneDevice, | 1998 | mSyncManager->mPhoneDevice, |
2000 | mSyncManager->mPhoneConnection, | 1999 | mSyncManager->mPhoneConnection, |
2001 | mSyncManager->mPhoneModel); | 2000 | mSyncManager->mPhoneModel); |
2002 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 2001 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
2003 | 2002 | ||
2004 | } else { | 2003 | } else { |
2005 | emit tempDisableBR(false); | 2004 | emit tempDisableBR(false); |
2006 | return; | 2005 | return; |
2007 | } | 2006 | } |
2008 | if ( loadSuccess ) { | 2007 | if ( loadSuccess ) { |
2009 | getEventViewerDialog()->setSyncMode( true ); | 2008 | getEventViewerDialog()->setSyncMode( true ); |
2010 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2009 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2011 | getEventViewerDialog()->setSyncMode( false ); | 2010 | getEventViewerDialog()->setSyncMode( false ); |
2012 | qApp->processEvents(); | 2011 | qApp->processEvents(); |
2013 | if ( syncOK ) { | 2012 | if ( syncOK ) { |
2014 | if ( mSyncManager->mWriteBackFile ) | 2013 | if ( mSyncManager->mWriteBackFile ) |
2015 | { | 2014 | { |
2016 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 2015 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
2017 | Incidence* inc = iL.first(); | 2016 | Incidence* inc = iL.first(); |
2018 | if ( phoneFormat ) { | 2017 | if ( phoneFormat ) { |
2019 | while ( inc ) { | 2018 | while ( inc ) { |
2020 | inc->removeID(mCurrentSyncDevice); | 2019 | inc->removeID(mCurrentSyncDevice); |
2021 | inc = iL.next(); | 2020 | inc = iL.next(); |
2022 | } | 2021 | } |
2023 | } | 2022 | } |
2024 | #ifndef DESKTOP_VERSION | 2023 | #ifndef DESKTOP_VERSION |
2025 | if ( sharpFormat ) | 2024 | if ( sharpFormat ) |
2026 | sharpFormat->save(calendar); | 2025 | sharpFormat->save(calendar); |
2027 | #endif | 2026 | #endif |
2028 | if ( phoneFormat ) | 2027 | if ( phoneFormat ) |
2029 | phoneFormat->save(calendar); | 2028 | phoneFormat->save(calendar); |
2030 | iL = calendar->rawIncidences(); | 2029 | iL = calendar->rawIncidences(); |
2031 | inc = iL.first(); | 2030 | inc = iL.first(); |
2032 | Incidence* loc; | 2031 | Incidence* loc; |
2033 | while ( inc ) { | 2032 | while ( inc ) { |
2034 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 2033 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
2035 | loc = mCalendar->incidence(inc->uid() ); | 2034 | loc = mCalendar->incidence(inc->uid() ); |
2036 | if ( loc ) { | 2035 | if ( loc ) { |
2037 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 2036 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
2038 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 2037 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
2039 | } | 2038 | } |
2040 | } | 2039 | } |
2041 | inc = iL.next(); | 2040 | inc = iL.next(); |
2042 | } | 2041 | } |
2043 | Incidence* lse = getLastSyncEvent(); | 2042 | Incidence* lse = getLastSyncEvent(); |
2044 | if ( lse ) { | 2043 | if ( lse ) { |
2045 | lse->setReadOnly( false ); | 2044 | lse->setReadOnly( false ); |
2046 | lse->setDescription( "" ); | 2045 | lse->setDescription( "" ); |
2047 | lse->setReadOnly( true ); | 2046 | lse->setReadOnly( true ); |
2048 | } | 2047 | } |
2049 | } | 2048 | } |
2050 | } else { | 2049 | } else { |
2051 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 2050 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
2052 | } | 2051 | } |
2053 | setModified( true ); | 2052 | setModified( true ); |
2054 | } else { | 2053 | } else { |
2055 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 2054 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
2056 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 2055 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
2057 | question, i18n("Ok")) ; | 2056 | question, i18n("Ok")) ; |
2058 | 2057 | ||
2059 | } | 2058 | } |
2060 | delete calendar; | 2059 | delete calendar; |
2061 | updateView(); | 2060 | updateView(); |
2062 | emit tempDisableBR(false); | 2061 | emit tempDisableBR(false); |
2063 | return ;//syncOK; | 2062 | return ;//syncOK; |
2064 | 2063 | ||
2065 | } | 2064 | } |
2066 | 2065 | ||
2067 | bool CalendarView::importBday() | 2066 | bool CalendarView::importBday() |
2068 | { | 2067 | { |
2069 | #ifndef KORG_NOKABC | 2068 | #ifndef KORG_NOKABC |
2070 | 2069 | ||
2071 | #ifdef DESKTOP_VERSION | 2070 | #ifdef DESKTOP_VERSION |
2072 | int curCal = mCalendar->defaultCalendar(); | 2071 | int curCal = mCalendar->defaultCalendar(); |
2073 | int bd = mCalEditView->getBirtdayID(); | 2072 | int bd = mCalEditView->getBirtdayID(); |
2074 | if ( bd == 0 ) | 2073 | if ( bd == 0 ) |
2075 | return false; | 2074 | return false; |
2076 | mCalendar->setDefaultCalendar( bd ); | 2075 | mCalendar->setDefaultCalendar( bd ); |
2077 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 2076 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
2078 | KABC::AddressBook::Iterator it; | 2077 | KABC::AddressBook::Iterator it; |
2079 | int count = 0; | 2078 | int count = 0; |
2080 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2079 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2081 | ++count; | 2080 | ++count; |
2082 | } | 2081 | } |
2083 | QProgressBar bar(count,0 ); | 2082 | QProgressBar bar(count,0 ); |
2084 | int w = 300; | 2083 | int w = 300; |
2085 | if ( QApplication::desktop()->width() < 320 ) | 2084 | if ( QApplication::desktop()->width() < 320 ) |
2086 | w = 220; | 2085 | w = 220; |
2087 | int h = bar.sizeHint().height() ; | 2086 | int h = bar.sizeHint().height() ; |
2088 | int dw = QApplication::desktop()->width(); | 2087 | int dw = QApplication::desktop()->width(); |
2089 | int dh = QApplication::desktop()->height(); | 2088 | int dh = QApplication::desktop()->height(); |
2090 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2089 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2091 | bar.show(); | 2090 | bar.show(); |
2092 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 2091 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
2093 | qApp->processEvents(); | 2092 | qApp->processEvents(); |
2094 | count = 0; | 2093 | count = 0; |
2095 | int addCount = 0; | 2094 | int addCount = 0; |
2096 | KCal::Attendee* a = 0; | 2095 | KCal::Attendee* a = 0; |
2097 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2096 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2098 | if ( ! bar.isVisible() ) | 2097 | if ( ! bar.isVisible() ) |
2099 | return false; | 2098 | return false; |
2100 | bar.setProgress( count++ ); | 2099 | bar.setProgress( count++ ); |
2101 | qApp->processEvents(); | 2100 | qApp->processEvents(); |
2102 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 2101 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
2103 | if ( (*it).birthday().date().isValid() ){ | 2102 | if ( (*it).birthday().date().isValid() ){ |
2104 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2103 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2105 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 2104 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
2106 | ++addCount; | 2105 | ++addCount; |
2107 | } | 2106 | } |
2108 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 2107 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
2109 | if ( anni.isValid() ){ | 2108 | if ( anni.isValid() ){ |
2110 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2109 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2111 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 2110 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
2112 | ++addCount; | 2111 | ++addCount; |
2113 | } | 2112 | } |
2114 | } | 2113 | } |
2115 | mCalendar->setDefaultCalendar( curCal ); | 2114 | mCalendar->setDefaultCalendar( curCal ); |
2116 | updateView(); | 2115 | updateView(); |
2117 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2116 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2118 | #else //DESKTOP_VERSION | 2117 | #else //DESKTOP_VERSION |
2119 | 2118 | ||
2120 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 2119 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
2121 | // the result should now arrive through method insertBirthdays | 2120 | // the result should now arrive through method insertBirthdays |
2122 | 2121 | ||
2123 | #endif //DESKTOP_VERSION | 2122 | #endif //DESKTOP_VERSION |
2124 | 2123 | ||
2125 | #endif //KORG_NOKABC | 2124 | #endif //KORG_NOKABC |
2126 | 2125 | ||
2127 | 2126 | ||
2128 | return true; | 2127 | return true; |
2129 | } | 2128 | } |
2130 | 2129 | ||
2131 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 2130 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
2132 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 2131 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
2133 | const QStringList& anniversaryList, const QStringList& realNameList, | 2132 | const QStringList& anniversaryList, const QStringList& realNameList, |
2134 | const QStringList& emailList, const QStringList& assembledNameList, | 2133 | const QStringList& emailList, const QStringList& assembledNameList, |
2135 | const QStringList& uidList) | 2134 | const QStringList& uidList) |
2136 | { | 2135 | { |
2137 | 2136 | ||
2138 | //qDebug("KO::CalendarView::insertBirthdays"); | 2137 | //qDebug("KO::CalendarView::insertBirthdays"); |
2139 | if (uid == this->name()) | 2138 | if (uid == this->name()) |
2140 | { | 2139 | { |
2141 | int curCal = mCalendar->defaultCalendar(); | 2140 | int curCal = mCalendar->defaultCalendar(); |
2142 | int bd = mCalEditView->getBirtdayID(); | 2141 | int bd = mCalEditView->getBirtdayID(); |
2143 | if ( bd == 0 ) | 2142 | if ( bd == 0 ) |
2144 | return; | 2143 | return; |
2145 | mCalendar->setDefaultCalendar( bd ); | 2144 | mCalendar->setDefaultCalendar( bd ); |
2146 | 2145 | ||
2147 | 2146 | ||
2148 | int count = birthdayList.count(); | 2147 | int count = birthdayList.count(); |
2149 | int addCount = 0; | 2148 | int addCount = 0; |
2150 | KCal::Attendee* a = 0; | 2149 | KCal::Attendee* a = 0; |
2151 | 2150 | ||
2152 | //qDebug("CalView 1 %i", count); | 2151 | //qDebug("CalView 1 %i", count); |
2153 | 2152 | ||
2154 | QProgressBar bar(count,0 ); | 2153 | QProgressBar bar(count,0 ); |
2155 | int w = 300; | 2154 | int w = 300; |
2156 | if ( QApplication::desktop()->width() < 320 ) | 2155 | if ( QApplication::desktop()->width() < 320 ) |
2157 | w = 220; | 2156 | w = 220; |
2158 | int h = bar.sizeHint().height() ; | 2157 | int h = bar.sizeHint().height() ; |
2159 | int dw = QApplication::desktop()->width(); | 2158 | int dw = QApplication::desktop()->width(); |
2160 | int dh = QApplication::desktop()->height(); | 2159 | int dh = QApplication::desktop()->height(); |
2161 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2160 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2162 | bar.show(); | 2161 | bar.show(); |
2163 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 2162 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
2164 | qApp->processEvents(); | 2163 | qApp->processEvents(); |
2165 | 2164 | ||
2166 | QDate birthday; | 2165 | QDate birthday; |
2167 | QDate anniversary; | 2166 | QDate anniversary; |
2168 | QString realName; | 2167 | QString realName; |
2169 | QString email; | 2168 | QString email; |
2170 | QString assembledName; | 2169 | QString assembledName; |
2171 | QString uid; | 2170 | QString uid; |
2172 | bool ok = true; | 2171 | bool ok = true; |
2173 | for ( int i = 0; i < count; i++) | 2172 | for ( int i = 0; i < count; i++) |
2174 | { | 2173 | { |
2175 | if ( ! bar.isVisible() ) | 2174 | if ( ! bar.isVisible() ) |
2176 | return; | 2175 | return; |
2177 | bar.setProgress( i ); | 2176 | bar.setProgress( i ); |
2178 | qApp->processEvents(); | 2177 | qApp->processEvents(); |
2179 | 2178 | ||
2180 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 2179 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
2181 | if (!ok) { | 2180 | if (!ok) { |
2182 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 2181 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
2183 | } | 2182 | } |
2184 | 2183 | ||
2185 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 2184 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
2186 | if (!ok) { | 2185 | if (!ok) { |
2187 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 2186 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
2188 | } | 2187 | } |
2189 | realName = realNameList[i]; | 2188 | realName = realNameList[i]; |
2190 | email = emailList[i]; | 2189 | email = emailList[i]; |
2191 | assembledName = assembledNameList[i]; | 2190 | assembledName = assembledNameList[i]; |
2192 | uid = uidList[i]; | 2191 | uid = uidList[i]; |
2193 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 2192 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
2194 | 2193 | ||
2195 | if ( birthday.isValid() ){ | 2194 | if ( birthday.isValid() ){ |
2196 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2195 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2197 | KCal::Attendee::ReqParticipant,uid) ; | 2196 | KCal::Attendee::ReqParticipant,uid) ; |
2198 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 2197 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
2199 | ++addCount; | 2198 | ++addCount; |
2200 | } | 2199 | } |
2201 | 2200 | ||
2202 | if ( anniversary.isValid() ){ | 2201 | if ( anniversary.isValid() ){ |
2203 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2202 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2204 | KCal::Attendee::ReqParticipant,uid) ; | 2203 | KCal::Attendee::ReqParticipant,uid) ; |
2205 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 2204 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
2206 | ++addCount; | 2205 | ++addCount; |
2207 | } | 2206 | } |
2208 | } | 2207 | } |
2209 | 2208 | ||
2210 | mCalendar->setDefaultCalendar( curCal ); | 2209 | mCalendar->setDefaultCalendar( curCal ); |
2211 | updateView(); | 2210 | updateView(); |
2212 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2211 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2213 | 2212 | ||
2214 | } | 2213 | } |
2215 | 2214 | ||
2216 | } | 2215 | } |
2217 | 2216 | ||
2218 | 2217 | ||
2219 | 2218 | ||
2220 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 2219 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
2221 | { | 2220 | { |
2222 | //qDebug("addAnni "); | 2221 | //qDebug("addAnni "); |
2223 | Event * ev = new Event(); | 2222 | Event * ev = new Event(); |
2224 | ev->setOrganizer(KOPrefs::instance()->email()); | 2223 | ev->setOrganizer(KOPrefs::instance()->email()); |
2225 | if ( a ) { | 2224 | if ( a ) { |
2226 | ev->addAttendee( a ); | 2225 | ev->addAttendee( a ); |
2227 | } | 2226 | } |
2228 | QString kind; | 2227 | QString kind; |
2229 | if ( birthday ) { | 2228 | if ( birthday ) { |
2230 | kind = i18n( "Birthday" ); | 2229 | kind = i18n( "Birthday" ); |
2231 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 2230 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
2232 | } | 2231 | } |
2233 | else { | 2232 | else { |
2234 | kind = i18n( "Anniversary" ); | 2233 | kind = i18n( "Anniversary" ); |
2235 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 2234 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
2236 | } | 2235 | } |
2237 | ev->setCategories( kind ); | 2236 | ev->setCategories( kind ); |
2238 | ev->setDtStart( QDateTime(date) ); | 2237 | ev->setDtStart( QDateTime(date) ); |
2239 | ev->setDtEnd( QDateTime(date) ); | 2238 | ev->setDtEnd( QDateTime(date) ); |
2240 | ev->setFloats( true ); | 2239 | ev->setFloats( true ); |
2241 | Recurrence * rec = ev->recurrence(); | 2240 | Recurrence * rec = ev->recurrence(); |
2242 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 2241 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
2243 | rec->addYearlyNum( date.month() ); | 2242 | rec->addYearlyNum( date.month() ); |
2244 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 2243 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
2245 | delete ev; | 2244 | delete ev; |
2246 | return false; | 2245 | return false; |
2247 | } | 2246 | } |
2248 | return true; | 2247 | return true; |
2249 | 2248 | ||
2250 | } | 2249 | } |
2251 | bool CalendarView::importQtopia( const QString &categories, | 2250 | bool CalendarView::importQtopia( const QString &categories, |
2252 | const QString &datebook, | 2251 | const QString &datebook, |
2253 | const QString &todolist ) | 2252 | const QString &todolist ) |
2254 | { | 2253 | { |
2255 | 2254 | ||
2256 | QtopiaFormat qtopiaFormat; | 2255 | QtopiaFormat qtopiaFormat; |
2257 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2256 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2258 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2257 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2259 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2258 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2260 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2259 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2261 | 2260 | ||
2262 | updateView(); | 2261 | updateView(); |
2263 | return true; | 2262 | return true; |
2264 | 2263 | ||
2265 | #if 0 | 2264 | #if 0 |
2266 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2265 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2267 | mCurrentSyncDevice = "qtopia-XML"; | 2266 | mCurrentSyncDevice = "qtopia-XML"; |
2268 | if ( mSyncManager->mAskForPreferences ) | 2267 | if ( mSyncManager->mAskForPreferences ) |
2269 | edit_sync_options(); | 2268 | edit_sync_options(); |
2270 | qApp->processEvents(); | 2269 | qApp->processEvents(); |
2271 | CalendarLocal* calendar = new CalendarLocal(); | 2270 | CalendarLocal* calendar = new CalendarLocal(); |
2272 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2271 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2273 | bool syncOK = false; | 2272 | bool syncOK = false; |
2274 | QtopiaFormat qtopiaFormat; | 2273 | QtopiaFormat qtopiaFormat; |
2275 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2274 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2276 | bool loadOk = true; | 2275 | bool loadOk = true; |
2277 | if ( !categories.isEmpty() ) | 2276 | if ( !categories.isEmpty() ) |
2278 | loadOk = qtopiaFormat.load( calendar, categories ); | 2277 | loadOk = qtopiaFormat.load( calendar, categories ); |
2279 | if ( loadOk && !datebook.isEmpty() ) | 2278 | if ( loadOk && !datebook.isEmpty() ) |
2280 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2279 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2281 | if ( loadOk && !todolist.isEmpty() ) | 2280 | if ( loadOk && !todolist.isEmpty() ) |
2282 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2281 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2283 | 2282 | ||
2284 | if ( loadOk ) { | 2283 | if ( loadOk ) { |
2285 | getEventViewerDialog()->setSyncMode( true ); | 2284 | getEventViewerDialog()->setSyncMode( true ); |
2286 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2285 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2287 | getEventViewerDialog()->setSyncMode( false ); | 2286 | getEventViewerDialog()->setSyncMode( false ); |
2288 | qApp->processEvents(); | 2287 | qApp->processEvents(); |
2289 | if ( syncOK ) { | 2288 | if ( syncOK ) { |
2290 | if ( mSyncManager->mWriteBackFile ) | 2289 | if ( mSyncManager->mWriteBackFile ) |
2291 | { | 2290 | { |
2292 | // write back XML file | 2291 | // write back XML file |
2293 | 2292 | ||
2294 | } | 2293 | } |
2295 | setModified( true ); | 2294 | setModified( true ); |
2296 | } | 2295 | } |
2297 | } else { | 2296 | } else { |
2298 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2297 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2299 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2298 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2300 | question, i18n("Ok")) ; | 2299 | question, i18n("Ok")) ; |
2301 | } | 2300 | } |
2302 | delete calendar; | 2301 | delete calendar; |
2303 | updateView(); | 2302 | updateView(); |
2304 | return syncOK; | 2303 | return syncOK; |
2305 | 2304 | ||
2306 | 2305 | ||
2307 | #endif | 2306 | #endif |
2308 | 2307 | ||
2309 | } | 2308 | } |
2310 | 2309 | ||
2311 | void CalendarView::setSyncEventsReadOnly() | 2310 | void CalendarView::setSyncEventsReadOnly() |
2312 | { | 2311 | { |
2313 | mCalendar->setSyncEventsReadOnly(); | 2312 | mCalendar->setSyncEventsReadOnly(); |
2314 | } | 2313 | } |
2315 | 2314 | ||
2316 | bool CalendarView::loadCalendars() | 2315 | bool CalendarView::loadCalendars() |
2317 | { | 2316 | { |
2318 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2317 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2319 | KopiCalendarFile * cal = calendars.first(); | 2318 | KopiCalendarFile * cal = calendars.first(); |
2320 | mCalendar->setDefaultCalendar( 1 ); | 2319 | mCalendar->setDefaultCalendar( 1 ); |
2321 | openCalendar( MainWindow::defaultFileName(), false ); | 2320 | openCalendar( MainWindow::defaultFileName(), false ); |
2322 | cal = calendars.next(); | 2321 | cal = calendars.next(); |
2323 | while ( cal ) { | 2322 | while ( cal ) { |
2324 | addCalendar( cal ); | 2323 | addCalendar( cal ); |
2325 | cal = calendars.next(); | 2324 | cal = calendars.next(); |
2326 | } | 2325 | } |
2327 | restoreCalendarSettings(); | 2326 | restoreCalendarSettings(); |
2328 | return true; | 2327 | return true; |
2329 | } | 2328 | } |
2330 | bool CalendarView::restoreCalendarSettings() | 2329 | bool CalendarView::restoreCalendarSettings() |
2331 | { | 2330 | { |
2332 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2331 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2333 | KopiCalendarFile * cal = calendars.first(); | 2332 | KopiCalendarFile * cal = calendars.first(); |
2334 | while ( cal ) { | 2333 | while ( cal ) { |
2335 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2334 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2336 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2335 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2337 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2336 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2338 | if ( cal->isStandard ) | 2337 | if ( cal->isStandard ) |
2339 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2338 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2340 | cal = calendars.next(); | 2339 | cal = calendars.next(); |
2341 | } | 2340 | } |
2342 | setSyncEventsReadOnly(); | 2341 | setSyncEventsReadOnly(); |
2343 | mCalendar->reInitAlarmSettings(); | 2342 | mCalendar->reInitAlarmSettings(); |
2344 | updateUnmanagedViews(); | 2343 | updateUnmanagedViews(); |
2345 | updateView(); | 2344 | updateView(); |
2346 | return true; | 2345 | return true; |
2347 | } | 2346 | } |
2348 | void CalendarView::addCalendarId( int id ) | 2347 | void CalendarView::addCalendarId( int id ) |
2349 | { | 2348 | { |
2350 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2349 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2351 | if ( cal ) | 2350 | if ( cal ) |
2352 | addCalendar( cal ); | 2351 | addCalendar( cal ); |
2353 | } | 2352 | } |
2354 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2353 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2355 | { | 2354 | { |
2356 | cal->mErrorOnLoad = false; | 2355 | cal->mErrorOnLoad = false; |
2357 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2356 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2358 | cal->mLoadDt = QDateTime::currentDateTime(); | 2357 | cal->mLoadDt = QDateTime::currentDateTime(); |
2359 | return true; | 2358 | return true; |
2360 | } | 2359 | } |
2361 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2360 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2362 | cal->mErrorOnLoad = true; | 2361 | cal->mErrorOnLoad = true; |
2363 | return false; | 2362 | return false; |
2364 | } | 2363 | } |
2365 | bool CalendarView::openCalendar(QString filename, bool merge) | 2364 | bool CalendarView::openCalendar(QString filename, bool merge) |
2366 | { | 2365 | { |
2367 | 2366 | ||
2368 | if (filename.isEmpty()) { | 2367 | if (filename.isEmpty()) { |
2369 | return false; | 2368 | return false; |
2370 | } | 2369 | } |
2371 | 2370 | ||
2372 | if (!QFile::exists(filename)) { | 2371 | if (!QFile::exists(filename)) { |
2373 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2372 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2374 | return false; | 2373 | return false; |
2375 | } | 2374 | } |
2376 | 2375 | ||
2377 | globalFlagBlockAgenda = 1; | 2376 | globalFlagBlockAgenda = 1; |
2378 | clearAllViews(); | 2377 | clearAllViews(); |
2379 | if (!merge) { | 2378 | if (!merge) { |
2380 | mViewManager->setDocumentId( filename ); | 2379 | mViewManager->setDocumentId( filename ); |
2381 | mCalendar->close(); | 2380 | mCalendar->close(); |
2382 | } | 2381 | } |
2383 | mStorage->setFileName( filename ); | 2382 | mStorage->setFileName( filename ); |
2384 | 2383 | ||
2385 | if ( mStorage->load() ) { | 2384 | if ( mStorage->load() ) { |
2386 | if ( merge ) ;//setModified( true ); | 2385 | if ( merge ) ;//setModified( true ); |
2387 | else { | 2386 | else { |
2388 | //setModified( true ); | 2387 | //setModified( true ); |
2389 | mViewManager->setDocumentId( filename ); | 2388 | mViewManager->setDocumentId( filename ); |
2390 | mDialogManager->setDocumentId( filename ); | 2389 | mDialogManager->setDocumentId( filename ); |
2391 | mTodoList->setDocumentId( filename ); | 2390 | mTodoList->setDocumentId( filename ); |
2392 | } | 2391 | } |
2393 | globalFlagBlockAgenda = 2; | 2392 | globalFlagBlockAgenda = 2; |
2394 | // if ( getLastSyncEvent() ) | 2393 | // if ( getLastSyncEvent() ) |
2395 | // getLastSyncEvent()->setReadOnly( true ); | 2394 | // getLastSyncEvent()->setReadOnly( true ); |
2396 | mCalendar->reInitAlarmSettings(); | 2395 | mCalendar->reInitAlarmSettings(); |
2397 | setSyncEventsReadOnly(); | 2396 | setSyncEventsReadOnly(); |
2398 | //updateUnmanagedViews(); | 2397 | //updateUnmanagedViews(); |
2399 | //updateView(); | 2398 | //updateView(); |
2400 | if ( filename != MainWindow::defaultFileName() ) { | 2399 | if ( filename != MainWindow::defaultFileName() ) { |
2401 | saveCalendar( MainWindow::defaultFileName() ); | 2400 | saveCalendar( MainWindow::defaultFileName() ); |
2402 | } else { | 2401 | } else { |
2403 | QFileInfo finf ( MainWindow::defaultFileName()); | 2402 | QFileInfo finf ( MainWindow::defaultFileName()); |
2404 | if ( finf.exists() ) { | 2403 | if ( finf.exists() ) { |
2405 | setLoadedFileVersion( finf.lastModified () ); | 2404 | setLoadedFileVersion( finf.lastModified () ); |
2406 | } | 2405 | } |
2407 | } | 2406 | } |
2408 | return true; | 2407 | return true; |
2409 | } else { | 2408 | } else { |
2410 | // while failing to load, the calendar object could | 2409 | // while failing to load, the calendar object could |
2411 | // have become partially populated. Clear it out. | 2410 | // have become partially populated. Clear it out. |
2412 | if ( !merge ) { | 2411 | if ( !merge ) { |
2413 | mCalendar->close(); | 2412 | mCalendar->close(); |
2414 | mViewManager->setDocumentId( filename ); | 2413 | mViewManager->setDocumentId( filename ); |
2415 | mDialogManager->setDocumentId( filename ); | 2414 | mDialogManager->setDocumentId( filename ); |
2416 | mTodoList->setDocumentId( filename ); | 2415 | mTodoList->setDocumentId( filename ); |
2417 | } | 2416 | } |
2418 | 2417 | ||
2419 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2418 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2420 | 2419 | ||
2421 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2420 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2422 | globalFlagBlockAgenda = 2; | 2421 | globalFlagBlockAgenda = 2; |
2423 | mCalendar->reInitAlarmSettings(); | 2422 | mCalendar->reInitAlarmSettings(); |
2424 | setSyncEventsReadOnly(); | 2423 | setSyncEventsReadOnly(); |
2425 | updateUnmanagedViews(); | 2424 | updateUnmanagedViews(); |
2426 | updateView(); | 2425 | updateView(); |
2427 | } | 2426 | } |
2428 | return false; | 2427 | return false; |
2429 | } | 2428 | } |
2430 | void CalendarView::mergeFile( QString fn ) | 2429 | void CalendarView::mergeFile( QString fn ) |
2431 | { | 2430 | { |
2432 | clearAllViews(); | 2431 | clearAllViews(); |
2433 | mCalendar->mergeCalendarFile( fn ); | 2432 | mCalendar->mergeCalendarFile( fn ); |
2434 | mCalendar->reInitAlarmSettings(); | 2433 | mCalendar->reInitAlarmSettings(); |
2435 | setSyncEventsReadOnly(); | 2434 | setSyncEventsReadOnly(); |
2436 | updateUnmanagedViews(); | 2435 | updateUnmanagedViews(); |
2437 | updateView(); | 2436 | updateView(); |
2438 | } | 2437 | } |
2439 | void CalendarView::showOpenError() | 2438 | void CalendarView::showOpenError() |
2440 | { | 2439 | { |
2441 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2440 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2442 | } | 2441 | } |
2443 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2442 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2444 | { | 2443 | { |
2445 | loadedFileVersion = dt; | 2444 | loadedFileVersion = dt; |
2446 | } | 2445 | } |
2447 | bool CalendarView::checkFileChanged(QString fn) | 2446 | bool CalendarView::checkFileChanged(QString fn) |
2448 | { | 2447 | { |
2449 | QFileInfo finf ( fn ); | 2448 | QFileInfo finf ( fn ); |
2450 | if ( !finf.exists() ) | 2449 | if ( !finf.exists() ) |
2451 | return true; | 2450 | return true; |
2452 | QDateTime dt = finf.lastModified (); | 2451 | QDateTime dt = finf.lastModified (); |
2453 | if ( dt <= loadedFileVersion ) | 2452 | if ( dt <= loadedFileVersion ) |
2454 | return false; | 2453 | return false; |
2455 | return true; | 2454 | return true; |
2456 | 2455 | ||
2457 | } | 2456 | } |
2458 | void CalendarView::watchSavedFile() | 2457 | void CalendarView::watchSavedFile() |
2459 | { | 2458 | { |
2460 | QFileInfo finf ( MainWindow::defaultFileName()); | 2459 | QFileInfo finf ( MainWindow::defaultFileName()); |
2461 | if ( !finf.exists() ) | 2460 | if ( !finf.exists() ) |
2462 | return; | 2461 | return; |
2463 | QDateTime dt = finf.lastModified (); | 2462 | QDateTime dt = finf.lastModified (); |
2464 | if ( dt < loadedFileVersion ) { | 2463 | if ( dt < loadedFileVersion ) { |
2465 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2464 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2466 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2465 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2467 | return; | 2466 | return; |
2468 | } | 2467 | } |
2469 | loadedFileVersion = dt; | 2468 | loadedFileVersion = dt; |
2470 | } | 2469 | } |
2471 | bool CalendarView::checkAllFileVersions() | 2470 | bool CalendarView::checkAllFileVersions() |
2472 | { | 2471 | { |
2473 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2472 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2474 | KopiCalendarFile * cal = calendars.first(); | 2473 | KopiCalendarFile * cal = calendars.first(); |
2475 | mCalendar->setDefaultCalendar( 1 ); | 2474 | mCalendar->setDefaultCalendar( 1 ); |
2476 | mCalendar->setDefaultCalendarEnabledOnly(); | 2475 | mCalendar->setDefaultCalendarEnabledOnly(); |
2477 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2476 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2478 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2477 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2479 | restoreCalendarSettings(); | 2478 | restoreCalendarSettings(); |
2480 | return false; | 2479 | return false; |
2481 | } | 2480 | } |
2482 | } | 2481 | } |
2483 | cal = calendars.next(); | 2482 | cal = calendars.next(); |
2484 | QDateTime storeTemp = loadedFileVersion; | 2483 | QDateTime storeTemp = loadedFileVersion; |
2485 | while ( cal ) { | 2484 | while ( cal ) { |
2486 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2485 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2487 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2486 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2488 | mCalendar->setDefaultCalendarEnabledOnly(); | 2487 | mCalendar->setDefaultCalendarEnabledOnly(); |
2489 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2488 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2490 | if ( !checkFileVersion(cal->mFileName )) { | 2489 | if ( !checkFileVersion(cal->mFileName )) { |
2491 | loadedFileVersion = storeTemp; | 2490 | loadedFileVersion = storeTemp; |
2492 | restoreCalendarSettings(); | 2491 | restoreCalendarSettings(); |
2493 | return false; | 2492 | return false; |
2494 | } | 2493 | } |
2495 | } | 2494 | } |
2496 | cal = calendars.next(); | 2495 | cal = calendars.next(); |
2497 | } | 2496 | } |
2498 | loadedFileVersion = storeTemp; | 2497 | loadedFileVersion = storeTemp; |
2499 | return true; | 2498 | return true; |
2500 | } | 2499 | } |
2501 | bool CalendarView::checkFileVersion(QString fn) | 2500 | bool CalendarView::checkFileVersion(QString fn) |
2502 | { | 2501 | { |
2503 | QFileInfo finf ( fn ); | 2502 | QFileInfo finf ( fn ); |
2504 | if ( !finf.exists() ) | 2503 | if ( !finf.exists() ) |
2505 | return true; | 2504 | return true; |
2506 | QDateTime dt = finf.lastModified (); | 2505 | QDateTime dt = finf.lastModified (); |
2507 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2506 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2508 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2507 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2509 | if ( dt <= loadedFileVersion ) | 2508 | if ( dt <= loadedFileVersion ) |
2510 | return true; | 2509 | return true; |
2511 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2510 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2512 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2511 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2513 | i18n("Sync+save")); | 2512 | i18n("Sync+save")); |
2514 | 2513 | ||
2515 | if ( km == KMessageBox::Cancel ) | 2514 | if ( km == KMessageBox::Cancel ) |
2516 | return false; | 2515 | return false; |
2517 | if ( km == KMessageBox::Yes ) | 2516 | if ( km == KMessageBox::Yes ) |
2518 | return true; | 2517 | return true; |
2519 | 2518 | ||
2520 | setSyncDevice("deleteaftersync" ); | 2519 | setSyncDevice("deleteaftersync" ); |
2521 | mSyncManager->mAskForPreferences = true; | 2520 | mSyncManager->mAskForPreferences = true; |
2522 | mSyncManager->mSyncAlgoPrefs = 3; | 2521 | mSyncManager->mSyncAlgoPrefs = 3; |
2523 | mSyncManager->mWriteBackFile = false; | 2522 | mSyncManager->mWriteBackFile = false; |
2524 | mSyncManager->mWriteBackExistingOnly = false; | 2523 | mSyncManager->mWriteBackExistingOnly = false; |
2525 | mSyncManager->mShowSyncSummary = false; | 2524 | mSyncManager->mShowSyncSummary = false; |
2526 | syncCalendar( fn, 3 ); | 2525 | syncCalendar( fn, 3 ); |
2527 | Event * e = getLastSyncEvent(); | 2526 | Event * e = getLastSyncEvent(); |
2528 | if ( e ) | 2527 | if ( e ) |
2529 | mCalendar->deleteEvent( e ); | 2528 | mCalendar->deleteEvent( e ); |
2530 | return true; | 2529 | return true; |
2531 | } | 2530 | } |
2532 | bool CalendarView::saveCalendars() | 2531 | bool CalendarView::saveCalendars() |
2533 | { | 2532 | { |
2534 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2533 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2535 | KopiCalendarFile * cal = calendars.first(); | 2534 | KopiCalendarFile * cal = calendars.first(); |
2536 | mCalendar->setDefaultCalendar( 1 ); | 2535 | mCalendar->setDefaultCalendar( 1 ); |
2537 | mCalendar->setDefaultCalendarEnabledOnly(); | 2536 | mCalendar->setDefaultCalendarEnabledOnly(); |
2538 | QString saveError; | 2537 | QString saveError; |
2539 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) | 2538 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) |
2540 | saveError = cal->mName +"\n"; | 2539 | saveError = cal->mName +"\n"; |
2541 | cal = calendars.next(); | 2540 | cal = calendars.next(); |
2542 | while ( cal ) { | 2541 | while ( cal ) { |
2543 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2542 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2544 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2543 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2545 | mCalendar->setDefaultCalendarEnabledOnly(); | 2544 | mCalendar->setDefaultCalendarEnabledOnly(); |
2546 | if ( saveCalendar( cal->mFileName ) ) | 2545 | if ( saveCalendar( cal->mFileName ) ) |
2547 | cal->mLoadDt = QDateTime::currentDateTime(); | 2546 | cal->mLoadDt = QDateTime::currentDateTime(); |
2548 | else | 2547 | else |
2549 | saveError += cal->mName + "\n"; | 2548 | saveError += cal->mName + "\n"; |
2550 | } | 2549 | } |
2551 | cal = calendars.next(); | 2550 | cal = calendars.next(); |
2552 | } | 2551 | } |
2553 | restoreCalendarSettings(); | 2552 | restoreCalendarSettings(); |
2554 | //saveError = "test error"; | 2553 | //saveError = "test error"; |
2555 | if ( !saveError.isEmpty() ) { | 2554 | if ( !saveError.isEmpty() ) { |
2556 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | 2555 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; |
2557 | KMessageBox::error(this, saveError, i18n("Error saving data")); | 2556 | KMessageBox::error(this, saveError, i18n("Error saving data")); |
2558 | return false; | 2557 | return false; |
2559 | } | 2558 | } |
2560 | return true; | 2559 | return true; |
2561 | } | 2560 | } |
2562 | bool CalendarView::saveCalendar( QString filename ) | 2561 | bool CalendarView::saveCalendar( QString filename ) |
2563 | { | 2562 | { |
2564 | 2563 | ||
2565 | // Store back all unsaved data into calendar object | 2564 | // Store back all unsaved data into calendar object |
2566 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2565 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2567 | if ( mViewManager->currentView() ) | 2566 | if ( mViewManager->currentView() ) |
2568 | mViewManager->currentView()->flushView(); | 2567 | mViewManager->currentView()->flushView(); |
2569 | 2568 | ||
2570 | 2569 | ||
2571 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2570 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2572 | mStorage->setSaveFormat( new ICalFormat() ); | 2571 | mStorage->setSaveFormat( new ICalFormat() ); |
2573 | mStorage->setFileName( filename ); | 2572 | mStorage->setFileName( filename ); |
2574 | bool success; | 2573 | bool success; |
2575 | success = mStorage->save(); | 2574 | success = mStorage->save(); |
2576 | if ( !success ) { | 2575 | if ( !success ) { |
2577 | return false; | 2576 | return false; |
2578 | } | 2577 | } |
2579 | if ( filename == MainWindow::defaultFileName() ) { | 2578 | if ( filename == MainWindow::defaultFileName() ) { |
2580 | setLoadedFileVersion( lfv ); | 2579 | setLoadedFileVersion( lfv ); |
2581 | watchSavedFile(); | 2580 | watchSavedFile(); |
2582 | } | 2581 | } |
2583 | return true; | 2582 | return true; |
2584 | } | 2583 | } |
2585 | 2584 | ||
2586 | void CalendarView::closeCalendar() | 2585 | void CalendarView::closeCalendar() |
2587 | { | 2586 | { |
2588 | 2587 | ||
2589 | // child windows no longer valid | 2588 | // child windows no longer valid |
2590 | clearAllViews(); | 2589 | clearAllViews(); |
2591 | emit closingDown(); | 2590 | emit closingDown(); |
2592 | 2591 | ||
2593 | mCalendar->close(); | 2592 | mCalendar->close(); |
2594 | setModified(false); | 2593 | setModified(false); |
2595 | updateView(); | 2594 | updateView(); |
2596 | } | 2595 | } |
2597 | 2596 | ||
2598 | void CalendarView::archiveCalendar() | 2597 | void CalendarView::archiveCalendar() |
2599 | { | 2598 | { |
2600 | mDialogManager->showArchiveDialog(); | 2599 | mDialogManager->showArchiveDialog(); |
2601 | } | 2600 | } |
2602 | 2601 | ||
2603 | 2602 | ||
2604 | void CalendarView::readSettings() | 2603 | void CalendarView::readSettings() |
2605 | { | 2604 | { |
2606 | 2605 | ||
2607 | 2606 | ||
2608 | // mViewManager->showAgendaView(); | 2607 | // mViewManager->showAgendaView(); |
2609 | QString str; | 2608 | QString str; |
2610 | //qDebug("CalendarView::readSettings() "); | 2609 | //qDebug("CalendarView::readSettings() "); |
2611 | // read settings from the KConfig, supplying reasonable | 2610 | // read settings from the KConfig, supplying reasonable |
2612 | // defaults where none are to be found | 2611 | // defaults where none are to be found |
2613 | KConfig *config = KOGlobals::config(); | 2612 | KConfig *config = KOGlobals::config(); |
2614 | #ifndef KORG_NOSPLITTER | 2613 | #ifndef KORG_NOSPLITTER |
2615 | config->setGroup("KOrganizer Geometry"); | 2614 | config->setGroup("KOrganizer Geometry"); |
2616 | 2615 | ||
2617 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2616 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2618 | if (sizes.count() != 2) { | 2617 | if (sizes.count() != 2) { |
2619 | sizes << mDateNavigator->minimumSizeHint().width(); | 2618 | sizes << mDateNavigator->minimumSizeHint().width(); |
2620 | sizes << 300; | 2619 | sizes << 300; |
2621 | } | 2620 | } |
2622 | mPanner->setSizes(sizes); | 2621 | mPanner->setSizes(sizes); |
2623 | 2622 | ||
2624 | sizes = config->readIntListEntry("Separator2"); | 2623 | sizes = config->readIntListEntry("Separator2"); |
2625 | if ( ( mResourceView && sizes.count() == 4 ) || | 2624 | if ( ( mResourceView && sizes.count() == 4 ) || |
2626 | ( !mResourceView && sizes.count() == 3 ) ) { | 2625 | ( !mResourceView && sizes.count() == 3 ) ) { |
2627 | mLeftSplitter->setSizes(sizes); | 2626 | mLeftSplitter->setSizes(sizes); |
2628 | } | 2627 | } |
2629 | #endif | 2628 | #endif |
2630 | globalFlagBlockAgenda = 1; | 2629 | globalFlagBlockAgenda = 1; |
2631 | mViewManager->showAgendaView(); | 2630 | mViewManager->showAgendaView(); |
2632 | //mViewManager->readSettings( config ); | 2631 | //mViewManager->readSettings( config ); |
2633 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2632 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2634 | readFilterSettings(config); | 2633 | readFilterSettings(config); |
2635 | 2634 | ||
2636 | #ifdef DESKTOP_VERSION | 2635 | #ifdef DESKTOP_VERSION |
2637 | config->setGroup("WidgetLayout"); | 2636 | config->setGroup("WidgetLayout"); |
2638 | QStringList list; | 2637 | QStringList list; |
2639 | list = config->readListEntry("MainLayout"); | 2638 | list = config->readListEntry("MainLayout"); |
2640 | int x,y,w,h; | 2639 | int x,y,w,h; |
2641 | if ( ! list.isEmpty() ) { | 2640 | if ( ! list.isEmpty() ) { |
2642 | x = list[0].toInt(); | 2641 | x = list[0].toInt(); |
2643 | y = list[1].toInt(); | 2642 | y = list[1].toInt(); |
2644 | w = list[2].toInt(); | 2643 | w = list[2].toInt(); |
2645 | h = list[3].toInt(); | 2644 | h = list[3].toInt(); |
2646 | KApplication::testCoords( &x,&y,&w,&h ); | 2645 | KApplication::testCoords( &x,&y,&w,&h ); |
2647 | topLevelWidget()->setGeometry(x,y,w,h); | 2646 | topLevelWidget()->setGeometry(x,y,w,h); |
2648 | 2647 | ||
2649 | } else { | 2648 | } else { |
2650 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2649 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2651 | } | 2650 | } |
2652 | list = config->readListEntry("EditEventLayout"); | 2651 | list = config->readListEntry("EditEventLayout"); |
2653 | if ( ! list.isEmpty() ) { | 2652 | if ( ! list.isEmpty() ) { |
2654 | x = list[0].toInt(); | 2653 | x = list[0].toInt(); |
2655 | y = list[1].toInt(); | 2654 | y = list[1].toInt(); |
2656 | w = list[2].toInt(); | 2655 | w = list[2].toInt(); |
2657 | h = list[3].toInt(); | 2656 | h = list[3].toInt(); |
2658 | KApplication::testCoords( &x,&y,&w,&h ); | 2657 | KApplication::testCoords( &x,&y,&w,&h ); |
2659 | mEventEditor->setGeometry(x,y,w,h); | 2658 | mEventEditor->setGeometry(x,y,w,h); |
2660 | 2659 | ||
2661 | } | 2660 | } |
2662 | list = config->readListEntry("EditTodoLayout"); | 2661 | list = config->readListEntry("EditTodoLayout"); |
2663 | if ( ! list.isEmpty() ) { | 2662 | if ( ! list.isEmpty() ) { |
2664 | x = list[0].toInt(); | 2663 | x = list[0].toInt(); |
2665 | y = list[1].toInt(); | 2664 | y = list[1].toInt(); |
2666 | w = list[2].toInt(); | 2665 | w = list[2].toInt(); |
2667 | h = list[3].toInt(); | 2666 | h = list[3].toInt(); |
2668 | KApplication::testCoords( &x,&y,&w,&h ); | 2667 | KApplication::testCoords( &x,&y,&w,&h ); |
2669 | mTodoEditor->setGeometry(x,y,w,h); | 2668 | mTodoEditor->setGeometry(x,y,w,h); |
2670 | 2669 | ||
2671 | } | 2670 | } |
2672 | list = config->readListEntry("ViewerLayout"); | 2671 | list = config->readListEntry("ViewerLayout"); |
2673 | if ( ! list.isEmpty() ) { | 2672 | if ( ! list.isEmpty() ) { |
2674 | x = list[0].toInt(); | 2673 | x = list[0].toInt(); |
2675 | y = list[1].toInt(); | 2674 | y = list[1].toInt(); |
2676 | w = list[2].toInt(); | 2675 | w = list[2].toInt(); |
2677 | h = list[3].toInt(); | 2676 | h = list[3].toInt(); |
2678 | KApplication::testCoords( &x,&y,&w,&h ); | 2677 | KApplication::testCoords( &x,&y,&w,&h ); |
2679 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2678 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2680 | } | 2679 | } |
2681 | #endif | 2680 | #endif |
2682 | config->setGroup( "Views" ); | 2681 | config->setGroup( "Views" ); |
2683 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2682 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2684 | 2683 | ||
2685 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2684 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2686 | 2685 | ||
2687 | int resetval = 0; | 2686 | int resetval = 0; |
2688 | int maxVal = 0; | 2687 | int maxVal = 0; |
2689 | if (sizes.count() != 3) { | 2688 | if (sizes.count() != 3) { |
2690 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2689 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2691 | resetval = mDateNavigator->sizeHint().width()+2; | 2690 | resetval = mDateNavigator->sizeHint().width()+2; |
2692 | } else { | 2691 | } else { |
2693 | resetval = mDateNavigator->sizeHint().height()+2; | 2692 | resetval = mDateNavigator->sizeHint().height()+2; |
2694 | } | 2693 | } |
2695 | } | 2694 | } |
2696 | if ( resetval ) { | 2695 | if ( resetval ) { |
2697 | sizes.clear(); | 2696 | sizes.clear(); |
2698 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2697 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2699 | maxVal = QApplication::desktop()->width() -10; | 2698 | maxVal = QApplication::desktop()->width() -10; |
2700 | } else { | 2699 | } else { |
2701 | maxVal = QApplication::desktop()->height()-10; | 2700 | maxVal = QApplication::desktop()->height()-10; |
2702 | } | 2701 | } |
2703 | sizes << resetval; | 2702 | sizes << resetval; |
2704 | if ( maxVal < resetval + resetval) | 2703 | if ( maxVal < resetval + resetval) |
2705 | resetval = maxVal - resetval; | 2704 | resetval = maxVal - resetval; |
2706 | sizes << resetval; | 2705 | sizes << resetval; |
2707 | sizes << 100; | 2706 | sizes << 100; |
2708 | } | 2707 | } |
2709 | mLeftFrame->setSizes(sizes); | 2708 | mLeftFrame->setSizes(sizes); |
2710 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2709 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2711 | resetval = 0; | 2710 | resetval = 0; |
2712 | maxVal = 0; | 2711 | maxVal = 0; |
2713 | if (sizes.count() != 2) { | 2712 | if (sizes.count() != 2) { |
2714 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2713 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2715 | resetval = mDateNavigator->sizeHint().width()+2; | 2714 | resetval = mDateNavigator->sizeHint().width()+2; |
2716 | } else { | 2715 | } else { |
2717 | resetval = mDateNavigator->sizeHint().height()+2; | 2716 | resetval = mDateNavigator->sizeHint().height()+2; |
2718 | } | 2717 | } |
2719 | } | 2718 | } |
2720 | if ( resetval ) { | 2719 | if ( resetval ) { |
2721 | sizes.clear(); | 2720 | sizes.clear(); |
2722 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2721 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2723 | maxVal = QApplication::desktop()->width() -10; | 2722 | maxVal = QApplication::desktop()->width() -10; |
2724 | } else { | 2723 | } else { |
2725 | maxVal = QApplication::desktop()->height()-10; | 2724 | maxVal = QApplication::desktop()->height()-10; |
2726 | } | 2725 | } |
2727 | sizes << resetval; | 2726 | sizes << resetval; |
2728 | if ( maxVal < resetval + resetval) | 2727 | if ( maxVal < resetval + resetval) |
2729 | resetval = maxVal - resetval; | 2728 | resetval = maxVal - resetval; |
2730 | sizes << resetval; | 2729 | sizes << resetval; |
2731 | } | 2730 | } |
2732 | mMainFrame->setSizes(sizes); | 2731 | mMainFrame->setSizes(sizes); |
2733 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2732 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2734 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2733 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2735 | else mNavigator->selectDates( dateCount ); | 2734 | else mNavigator->selectDates( dateCount ); |
2736 | // mViewManager->readSettings( config ); | 2735 | // mViewManager->readSettings( config ); |
2737 | updateConfig(); | 2736 | updateConfig(); |
2738 | globalFlagBlockAgenda = 2; | 2737 | globalFlagBlockAgenda = 2; |
2739 | mViewManager->readSettings( config ); | 2738 | mViewManager->readSettings( config ); |
2740 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2739 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2741 | } | 2740 | } |
2742 | 2741 | ||
2743 | void CalendarView::checkSuspendAlarm() | 2742 | void CalendarView::checkSuspendAlarm() |
2744 | { | 2743 | { |
2745 | if ( mSuspendTimer->isActive() ) { | 2744 | if ( mSuspendTimer->isActive() ) { |
2746 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2745 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2747 | } | 2746 | } |
2748 | } | 2747 | } |
2749 | void CalendarView::writeSettings() | 2748 | void CalendarView::writeSettings() |
2750 | { | 2749 | { |
2751 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2750 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2752 | 2751 | ||
2753 | KConfig *config = KOGlobals::config(); | 2752 | KConfig *config = KOGlobals::config(); |
2754 | 2753 | ||
2755 | mViewManager->writeSettings( config ); | 2754 | mViewManager->writeSettings( config ); |
2756 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2755 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2757 | mDialogManager->writeSettings( config ); | 2756 | mDialogManager->writeSettings( config ); |
2758 | //KOPrefs::instance()->usrWriteConfig(); | 2757 | //KOPrefs::instance()->usrWriteConfig(); |
2759 | KOPrefs::instance()->writeConfig(); | 2758 | KOPrefs::instance()->writeConfig(); |
2760 | 2759 | ||
2761 | writeFilterSettings(config); | 2760 | writeFilterSettings(config); |
2762 | config->setGroup( "AppRun" ); | 2761 | config->setGroup( "AppRun" ); |
2763 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2762 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2764 | int days = dt.daysTo( QDate::currentDate() ); | 2763 | int days = dt.daysTo( QDate::currentDate() ); |
2765 | dt = dt.addDays( days ); | 2764 | dt = dt.addDays( days ); |
2766 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2765 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2767 | config->writeEntry( "LatestProgramStopDays", days ); | 2766 | config->writeEntry( "LatestProgramStopDays", days ); |
2768 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2767 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2769 | //qDebug("KO: Writing stop time: %d ", secs); | 2768 | //qDebug("KO: Writing stop time: %d ", secs); |
2770 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2769 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2771 | //QDateTime latest = dt.addSecs ( secs ); | 2770 | //QDateTime latest = dt.addSecs ( secs ); |
2772 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2771 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2773 | config->setGroup( "Views" ); | 2772 | config->setGroup( "Views" ); |
2774 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2773 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2775 | 2774 | ||
2776 | #if 0 | 2775 | #if 0 |
2777 | qDebug("********************* "); | 2776 | qDebug("********************* "); |
2778 | qDebug("Testcode secsto "); | 2777 | qDebug("Testcode secsto "); |
2779 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2778 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2780 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2779 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2781 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2780 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2782 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2781 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2783 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2782 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2784 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2783 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2785 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2784 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2786 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2785 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2787 | qDebug("********************* testcode end"); | 2786 | qDebug("********************* testcode end"); |
2788 | 2787 | ||
2789 | #endif | 2788 | #endif |
2790 | 2789 | ||
2791 | QValueList<int> listINT = mLeftFrame->sizes(); | 2790 | QValueList<int> listINT = mLeftFrame->sizes(); |
2792 | config->writeEntry("Left Splitter Frame",listINT); | 2791 | config->writeEntry("Left Splitter Frame",listINT); |
2793 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2792 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2794 | config->writeEntry("Main Splitter Frame",listINT2); | 2793 | config->writeEntry("Main Splitter Frame",listINT2); |
2795 | #ifdef DESKTOP_VERSION | 2794 | #ifdef DESKTOP_VERSION |
2796 | config->setGroup("WidgetLayout"); | 2795 | config->setGroup("WidgetLayout"); |
2797 | QStringList list ;//= config->readListEntry("MainLayout"); | 2796 | QStringList list ;//= config->readListEntry("MainLayout"); |
2798 | int x,y,w,h; | 2797 | int x,y,w,h; |
2799 | QWidget* wid; | 2798 | QWidget* wid; |
2800 | wid = topLevelWidget(); | 2799 | wid = topLevelWidget(); |
2801 | x = wid->geometry().x(); | 2800 | x = wid->geometry().x(); |
2802 | y = wid->geometry().y(); | 2801 | y = wid->geometry().y(); |
2803 | w = wid->width(); | 2802 | w = wid->width(); |
2804 | h = wid->height(); | 2803 | h = wid->height(); |
2805 | list.clear(); | 2804 | list.clear(); |
2806 | list << QString::number( x ); | 2805 | list << QString::number( x ); |
2807 | list << QString::number( y ); | 2806 | list << QString::number( y ); |
2808 | list << QString::number( w ); | 2807 | list << QString::number( w ); |
2809 | list << QString::number( h ); | 2808 | list << QString::number( h ); |
2810 | config->writeEntry("MainLayout",list ); | 2809 | config->writeEntry("MainLayout",list ); |
2811 | 2810 | ||
2812 | wid = mEventEditor; | 2811 | wid = mEventEditor; |
2813 | x = wid->geometry().x(); | 2812 | x = wid->geometry().x(); |
2814 | y = wid->geometry().y(); | 2813 | y = wid->geometry().y(); |
2815 | w = wid->width(); | 2814 | w = wid->width(); |
2816 | h = wid->height(); | 2815 | h = wid->height(); |
2817 | list.clear(); | 2816 | list.clear(); |
2818 | list << QString::number( x ); | 2817 | list << QString::number( x ); |
2819 | list << QString::number( y ); | 2818 | list << QString::number( y ); |
2820 | list << QString::number( w ); | 2819 | list << QString::number( w ); |
2821 | list << QString::number( h ); | 2820 | list << QString::number( h ); |
2822 | config->writeEntry("EditEventLayout",list ); | 2821 | config->writeEntry("EditEventLayout",list ); |
2823 | 2822 | ||
2824 | wid = mTodoEditor; | 2823 | wid = mTodoEditor; |
2825 | x = wid->geometry().x(); | 2824 | x = wid->geometry().x(); |
2826 | y = wid->geometry().y(); | 2825 | y = wid->geometry().y(); |
2827 | w = wid->width(); | 2826 | w = wid->width(); |
2828 | h = wid->height(); | 2827 | h = wid->height(); |
2829 | list.clear(); | 2828 | list.clear(); |
2830 | list << QString::number( x ); | 2829 | list << QString::number( x ); |
2831 | list << QString::number( y ); | 2830 | list << QString::number( y ); |
2832 | list << QString::number( w ); | 2831 | list << QString::number( w ); |
2833 | list << QString::number( h ); | 2832 | list << QString::number( h ); |
2834 | config->writeEntry("EditTodoLayout",list ); | 2833 | config->writeEntry("EditTodoLayout",list ); |
2835 | wid = getEventViewerDialog(); | 2834 | wid = getEventViewerDialog(); |
2836 | x = wid->geometry().x(); | 2835 | x = wid->geometry().x(); |
2837 | y = wid->geometry().y(); | 2836 | y = wid->geometry().y(); |
2838 | w = wid->width(); | 2837 | w = wid->width(); |
2839 | h = wid->height(); | 2838 | h = wid->height(); |
2840 | list.clear(); | 2839 | list.clear(); |
2841 | list << QString::number( x ); | 2840 | list << QString::number( x ); |
2842 | list << QString::number( y ); | 2841 | list << QString::number( y ); |
2843 | list << QString::number( w ); | 2842 | list << QString::number( w ); |
2844 | list << QString::number( h ); | 2843 | list << QString::number( h ); |
2845 | config->writeEntry("ViewerLayout",list ); | 2844 | config->writeEntry("ViewerLayout",list ); |
2846 | wid = mDialogManager->getSearchDialog(); | 2845 | wid = mDialogManager->getSearchDialog(); |
2847 | if ( wid ) { | 2846 | if ( wid ) { |
2848 | x = wid->geometry().x(); | 2847 | x = wid->geometry().x(); |
2849 | y = wid->geometry().y(); | 2848 | y = wid->geometry().y(); |
2850 | w = wid->width(); | 2849 | w = wid->width(); |
2851 | h = wid->height(); | 2850 | h = wid->height(); |
2852 | list.clear(); | 2851 | list.clear(); |
2853 | list << QString::number( x ); | 2852 | list << QString::number( x ); |
2854 | list << QString::number( y ); | 2853 | list << QString::number( y ); |
2855 | list << QString::number( w ); | 2854 | list << QString::number( w ); |
2856 | list << QString::number( h ); | 2855 | list << QString::number( h ); |
2857 | config->writeEntry("SearchLayout",list ); | 2856 | config->writeEntry("SearchLayout",list ); |
2858 | } | 2857 | } |
2859 | #endif | 2858 | #endif |
2860 | 2859 | ||
2861 | 2860 | ||
2862 | config->sync(); | 2861 | config->sync(); |
2863 | } | 2862 | } |
2864 | 2863 | ||
2865 | void CalendarView::readFilterSettings(KConfig *config) | 2864 | void CalendarView::readFilterSettings(KConfig *config) |
2866 | { | 2865 | { |
2867 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2866 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2868 | 2867 | ||
2869 | mFilters.clear(); | 2868 | mFilters.clear(); |
2870 | 2869 | ||
2871 | config->setGroup("General"); | 2870 | config->setGroup("General"); |
2872 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2871 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2873 | 2872 | ||
2874 | QStringList::ConstIterator it = filterList.begin(); | 2873 | QStringList::ConstIterator it = filterList.begin(); |
2875 | QStringList::ConstIterator end = filterList.end(); | 2874 | QStringList::ConstIterator end = filterList.end(); |
2876 | while(it != end) { | 2875 | while(it != end) { |
2877 | // kdDebug() << " filter: " << (*it) << endl; | 2876 | // kdDebug() << " filter: " << (*it) << endl; |
2878 | 2877 | ||
2879 | CalFilter *filter; | 2878 | CalFilter *filter; |
2880 | filter = new CalFilter(*it); | 2879 | filter = new CalFilter(*it); |
2881 | config->setGroup("Filter_" + (*it).utf8()); | 2880 | config->setGroup("Filter_" + (*it).utf8()); |
2882 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2881 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2883 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2882 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2884 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2883 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2885 | mFilters.append(filter); | 2884 | mFilters.append(filter); |
2886 | 2885 | ||
2887 | ++it; | 2886 | ++it; |
2888 | } | 2887 | } |
2889 | 2888 | ||
2890 | if (mFilters.count() == 0) { | 2889 | if (mFilters.count() == 0) { |
2891 | CalFilter *filter = new CalFilter(i18n("Default")); | 2890 | CalFilter *filter = new CalFilter(i18n("Default")); |
2892 | mFilters.append(filter); | 2891 | mFilters.append(filter); |
2893 | } | 2892 | } |
2894 | mFilterView->updateFilters(); | 2893 | mFilterView->updateFilters(); |
2895 | config->setGroup("FilterView"); | 2894 | config->setGroup("FilterView"); |
2896 | 2895 | ||
2897 | mFilterView->blockSignals(true); | 2896 | mFilterView->blockSignals(true); |
2898 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2897 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2899 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2898 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2900 | mFilterView->blockSignals(false); | 2899 | mFilterView->blockSignals(false); |
2901 | // We do it manually to avoid it being done twice by the above calls | 2900 | // We do it manually to avoid it being done twice by the above calls |
2902 | updateFilter(); | 2901 | updateFilter(); |
2903 | } | 2902 | } |
2904 | 2903 | ||
2905 | void CalendarView::writeFilterSettings(KConfig *config) | 2904 | void CalendarView::writeFilterSettings(KConfig *config) |
2906 | { | 2905 | { |
2907 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2906 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2908 | 2907 | ||
2909 | QStringList filterList; | 2908 | QStringList filterList; |
2910 | 2909 | ||
2911 | CalFilter *filter = mFilters.first(); | 2910 | CalFilter *filter = mFilters.first(); |
2912 | while(filter) { | 2911 | while(filter) { |
2913 | // kdDebug() << " fn: " << filter->name() << endl; | 2912 | // kdDebug() << " fn: " << filter->name() << endl; |
2914 | filterList << filter->name(); | 2913 | filterList << filter->name(); |
2915 | config->setGroup("Filter_" + filter->name().utf8()); | 2914 | config->setGroup("Filter_" + filter->name().utf8()); |
2916 | config->writeEntry("Criteria",filter->criteria()); | 2915 | config->writeEntry("Criteria",filter->criteria()); |
2917 | config->writeEntry("CategoryList",filter->categoryList()); | 2916 | config->writeEntry("CategoryList",filter->categoryList()); |
2918 | filter = mFilters.next(); | 2917 | filter = mFilters.next(); |
2919 | } | 2918 | } |
2920 | config->setGroup("General"); | 2919 | config->setGroup("General"); |
2921 | config->writeEntry("CalendarFilters",filterList); | 2920 | config->writeEntry("CalendarFilters",filterList); |
2922 | 2921 | ||
2923 | config->setGroup("FilterView"); | 2922 | config->setGroup("FilterView"); |
2924 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2923 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2925 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2924 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2926 | } | 2925 | } |
2927 | 2926 | ||
2928 | 2927 | ||
2929 | void CalendarView::goToday() | 2928 | void CalendarView::goToday() |
2930 | { | 2929 | { |
2931 | if ( mViewManager->currentView()->isMonthView() ) | 2930 | if ( mViewManager->currentView()->isMonthView() ) |
2932 | mNavigator->selectTodayMonth(); | 2931 | mNavigator->selectTodayMonth(); |
2933 | else | 2932 | else |
2934 | mNavigator->selectToday(); | 2933 | mNavigator->selectToday(); |
2935 | } | 2934 | } |
2936 | 2935 | ||
2937 | void CalendarView::goNext() | 2936 | void CalendarView::goNext() |
2938 | { | 2937 | { |
2939 | mNavigator->selectNext(); | 2938 | mNavigator->selectNext(); |
2940 | } | 2939 | } |
2941 | 2940 | ||
2942 | void CalendarView::goPrevious() | 2941 | void CalendarView::goPrevious() |
2943 | { | 2942 | { |
2944 | mNavigator->selectPrevious(); | 2943 | mNavigator->selectPrevious(); |
2945 | } | 2944 | } |
2946 | void CalendarView::goNextMonth() | 2945 | void CalendarView::goNextMonth() |
2947 | { | 2946 | { |
2948 | mNavigator->selectNextMonth(); | 2947 | mNavigator->selectNextMonth(); |
2949 | } | 2948 | } |
2950 | 2949 | ||
2951 | void CalendarView::goPreviousMonth() | 2950 | void CalendarView::goPreviousMonth() |
2952 | { | 2951 | { |
2953 | mNavigator->selectPreviousMonth(); | 2952 | mNavigator->selectPreviousMonth(); |
2954 | } | 2953 | } |
2955 | 2954 | ||
2956 | void CalendarView::updateConfig() | 2955 | void CalendarView::updateConfig() |
2957 | { | 2956 | { |
2958 | if ( KOPrefs::instance()->mUseAppColors ) | 2957 | if ( KOPrefs::instance()->mUseAppColors ) |
2959 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2958 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2960 | emit configChanged(); | 2959 | emit configChanged(); |
2961 | mTodoList->updateConfig(); | 2960 | mTodoList->updateConfig(); |
2962 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2961 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2963 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2962 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2964 | // To make the "fill window" configurations work | 2963 | // To make the "fill window" configurations work |
2965 | //mViewManager->raiseCurrentView(); | 2964 | //mViewManager->raiseCurrentView(); |
2966 | } | 2965 | } |
2967 | 2966 | ||
2968 | 2967 | ||
2969 | void CalendarView::eventChanged(Event *event) | 2968 | void CalendarView::eventChanged(Event *event) |
2970 | { | 2969 | { |
2971 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2970 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2972 | //updateUnmanagedViews(); | 2971 | //updateUnmanagedViews(); |
2973 | } | 2972 | } |
2974 | 2973 | ||
2975 | void CalendarView::eventAdded(Event *event) | 2974 | void CalendarView::eventAdded(Event *event) |
2976 | { | 2975 | { |
2977 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2976 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2978 | } | 2977 | } |
2979 | 2978 | ||
2980 | void CalendarView::eventToBeDeleted(Event *) | 2979 | void CalendarView::eventToBeDeleted(Event *) |
2981 | { | 2980 | { |
2982 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2981 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2983 | } | 2982 | } |
2984 | 2983 | ||
2985 | void CalendarView::eventDeleted() | 2984 | void CalendarView::eventDeleted() |
2986 | { | 2985 | { |
2987 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2986 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2988 | } | 2987 | } |
2989 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2988 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2990 | { | 2989 | { |
2991 | changeIncidenceDisplay((Incidence *)which, action); | 2990 | changeIncidenceDisplay((Incidence *)which, action); |
2992 | mDateNavigator->updateView(); //LR | 2991 | mDateNavigator->updateView(); //LR |
2993 | //mDialogManager->updateSearchDialog(); | 2992 | //mDialogManager->updateSearchDialog(); |
2994 | 2993 | ||
2995 | if (which) { | 2994 | if (which) { |
2996 | mViewManager->updateWNview(); | 2995 | mViewManager->updateWNview(); |
2997 | //mTodoList->updateView(); | 2996 | //mTodoList->updateView(); |
2998 | } | 2997 | } |
2999 | 2998 | ||
3000 | } | 2999 | } |
3001 | 3000 | ||
3002 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 3001 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
3003 | { | 3002 | { |
3004 | updateUnmanagedViews(); | 3003 | updateUnmanagedViews(); |
3005 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 3004 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
@@ -4013,1164 +4012,1178 @@ void CalendarView::deleteTodo(Todo *todo) | |||
4013 | if ( !deleteT ) { | 4012 | if ( !deleteT ) { |
4014 | checkExternalId( todo ); | 4013 | checkExternalId( todo ); |
4015 | calendar()->deleteTodo(todo); | 4014 | calendar()->deleteTodo(todo); |
4016 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4015 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4017 | } | 4016 | } |
4018 | updateView(); | 4017 | updateView(); |
4019 | break; | 4018 | break; |
4020 | } // switch | 4019 | } // switch |
4021 | } else { | 4020 | } else { |
4022 | checkExternalId( todo ); | 4021 | checkExternalId( todo ); |
4023 | mCalendar->deleteTodo(todo); | 4022 | mCalendar->deleteTodo(todo); |
4024 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4023 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4025 | updateView(); | 4024 | updateView(); |
4026 | } | 4025 | } |
4027 | 4026 | ||
4028 | emit updateSearchDialog(); | 4027 | emit updateSearchDialog(); |
4029 | } | 4028 | } |
4030 | void CalendarView::deleteJournal(Journal *jour) | 4029 | void CalendarView::deleteJournal(Journal *jour) |
4031 | { | 4030 | { |
4032 | if (!jour) { | 4031 | if (!jour) { |
4033 | KNotifyClient::beep(); | 4032 | KNotifyClient::beep(); |
4034 | return; | 4033 | return; |
4035 | } | 4034 | } |
4036 | if (KOPrefs::instance()->mConfirm) { | 4035 | if (KOPrefs::instance()->mConfirm) { |
4037 | 4036 | ||
4038 | QString des; | 4037 | QString des; |
4039 | if ( !jour->summary().isEmpty() ) { | 4038 | if ( !jour->summary().isEmpty() ) { |
4040 | des = jour->summary(); | 4039 | des = jour->summary(); |
4041 | } else { | 4040 | } else { |
4042 | des = jour->description().left(30); | 4041 | des = jour->description().left(30); |
4043 | des = des.simplifyWhiteSpace (); | 4042 | des = des.simplifyWhiteSpace (); |
4044 | des.replace (QRegExp ("\\n"),"" ); | 4043 | des.replace (QRegExp ("\\n"),"" ); |
4045 | des.replace (QRegExp ("\\r"),"" ); | 4044 | des.replace (QRegExp ("\\r"),"" ); |
4046 | } | 4045 | } |
4047 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 4046 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
4048 | case KMessageBox::Continue: // OK | 4047 | case KMessageBox::Continue: // OK |
4049 | calendar()->deleteJournal(jour); | 4048 | calendar()->deleteJournal(jour); |
4050 | updateView(); | 4049 | updateView(); |
4051 | break; | 4050 | break; |
4052 | } // switch | 4051 | } // switch |
4053 | } else { | 4052 | } else { |
4054 | calendar()->deleteJournal(jour);; | 4053 | calendar()->deleteJournal(jour);; |
4055 | updateView(); | 4054 | updateView(); |
4056 | } | 4055 | } |
4057 | emit updateSearchDialog(); | 4056 | emit updateSearchDialog(); |
4058 | } | 4057 | } |
4059 | 4058 | ||
4060 | void CalendarView::deleteEvent(Event *anEvent) | 4059 | void CalendarView::deleteEvent(Event *anEvent) |
4061 | { | 4060 | { |
4062 | if (!anEvent) { | 4061 | if (!anEvent) { |
4063 | KNotifyClient::beep(); | 4062 | KNotifyClient::beep(); |
4064 | return; | 4063 | return; |
4065 | } | 4064 | } |
4066 | 4065 | ||
4067 | if (anEvent->doesRecur()) { | 4066 | if (anEvent->doesRecur()) { |
4068 | QDate itemDate = mViewManager->currentSelectionDate(); | 4067 | QDate itemDate = mViewManager->currentSelectionDate(); |
4069 | int km; | 4068 | int km; |
4070 | if (!itemDate.isValid()) { | 4069 | if (!itemDate.isValid()) { |
4071 | //kdDebug() << "Date Not Valid" << endl; | 4070 | //kdDebug() << "Date Not Valid" << endl; |
4072 | if (KOPrefs::instance()->mConfirm) { | 4071 | if (KOPrefs::instance()->mConfirm) { |
4073 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4072 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4074 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 4073 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
4075 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 4074 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
4076 | if ( km == KMessageBox::Continue ) | 4075 | if ( km == KMessageBox::Continue ) |
4077 | km = KMessageBox::No; // No = all below | 4076 | km = KMessageBox::No; // No = all below |
4078 | } else | 4077 | } else |
4079 | km = KMessageBox::No; | 4078 | km = KMessageBox::No; |
4080 | } else { | 4079 | } else { |
4081 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4080 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4082 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 4081 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
4083 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 4082 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
4084 | i18n("KO/Pi Confirmation"),i18n("Current"), | 4083 | i18n("KO/Pi Confirmation"),i18n("Current"), |
4085 | i18n("All")); | 4084 | i18n("All")); |
4086 | } | 4085 | } |
4087 | switch(km) { | 4086 | switch(km) { |
4088 | 4087 | ||
4089 | case KMessageBox::No: // Continue // all | 4088 | case KMessageBox::No: // Continue // all |
4090 | //qDebug("KMessageBox::No "); | 4089 | //qDebug("KMessageBox::No "); |
4091 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4090 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4092 | schedule(Scheduler::Cancel,anEvent); | 4091 | schedule(Scheduler::Cancel,anEvent); |
4093 | 4092 | ||
4094 | checkExternalId( anEvent); | 4093 | checkExternalId( anEvent); |
4095 | mCalendar->deleteEvent(anEvent); | 4094 | mCalendar->deleteEvent(anEvent); |
4096 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 4095 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
4097 | break; | 4096 | break; |
4098 | 4097 | ||
4099 | // Disabled because it does not work | 4098 | // Disabled because it does not work |
4100 | //#if 0 | 4099 | //#if 0 |
4101 | case KMessageBox::Yes: // just this one | 4100 | case KMessageBox::Yes: // just this one |
4102 | //QDate qd = mNavigator->selectedDates().first(); | 4101 | //QDate qd = mNavigator->selectedDates().first(); |
4103 | //if (!qd.isValid()) { | 4102 | //if (!qd.isValid()) { |
4104 | // kdDebug() << "no date selected, or invalid date" << endl; | 4103 | // kdDebug() << "no date selected, or invalid date" << endl; |
4105 | // KNotifyClient::beep(); | 4104 | // KNotifyClient::beep(); |
4106 | // return; | 4105 | // return; |
4107 | //} | 4106 | //} |
4108 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 4107 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
4109 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 4108 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
4110 | anEvent->addExDate(itemDate); | 4109 | anEvent->addExDate(itemDate); |
4111 | int duration = anEvent->recurrence()->duration(); | 4110 | int duration = anEvent->recurrence()->duration(); |
4112 | if ( duration > 0 ) { | 4111 | if ( duration > 0 ) { |
4113 | anEvent->recurrence()->setDuration( duration - 1 ); | 4112 | anEvent->recurrence()->setDuration( duration - 1 ); |
4114 | } | 4113 | } |
4115 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 4114 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
4116 | } | 4115 | } |
4117 | break; | 4116 | break; |
4118 | //#endif | 4117 | //#endif |
4119 | } // switch | 4118 | } // switch |
4120 | } else { | 4119 | } else { |
4121 | if (KOPrefs::instance()->mConfirm) { | 4120 | if (KOPrefs::instance()->mConfirm) { |
4122 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4121 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4123 | i18n("\nAre you sure you want\nto delete this event?"), | 4122 | i18n("\nAre you sure you want\nto delete this event?"), |
4124 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 4123 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
4125 | case KMessageBox::Continue: // OK | 4124 | case KMessageBox::Continue: // OK |
4126 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4125 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4127 | schedule(Scheduler::Cancel,anEvent); | 4126 | schedule(Scheduler::Cancel,anEvent); |
4128 | checkExternalId( anEvent); | 4127 | checkExternalId( anEvent); |
4129 | mCalendar->deleteEvent(anEvent); | 4128 | mCalendar->deleteEvent(anEvent); |
4130 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4129 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4131 | break; | 4130 | break; |
4132 | } // switch | 4131 | } // switch |
4133 | } else { | 4132 | } else { |
4134 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4133 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4135 | schedule(Scheduler::Cancel,anEvent); | 4134 | schedule(Scheduler::Cancel,anEvent); |
4136 | checkExternalId( anEvent); | 4135 | checkExternalId( anEvent); |
4137 | mCalendar->deleteEvent(anEvent); | 4136 | mCalendar->deleteEvent(anEvent); |
4138 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4137 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4139 | } | 4138 | } |
4140 | } // if-else | 4139 | } // if-else |
4141 | emit updateSearchDialog(); | 4140 | emit updateSearchDialog(); |
4142 | } | 4141 | } |
4143 | 4142 | ||
4144 | bool CalendarView::deleteEvent(const QString &uid) | 4143 | bool CalendarView::deleteEvent(const QString &uid) |
4145 | { | 4144 | { |
4146 | Event *ev = mCalendar->event(uid); | 4145 | Event *ev = mCalendar->event(uid); |
4147 | if (ev) { | 4146 | if (ev) { |
4148 | deleteEvent(ev); | 4147 | deleteEvent(ev); |
4149 | return true; | 4148 | return true; |
4150 | } else { | 4149 | } else { |
4151 | return false; | 4150 | return false; |
4152 | } | 4151 | } |
4153 | } | 4152 | } |
4154 | 4153 | ||
4155 | /*****************************************************************************/ | 4154 | /*****************************************************************************/ |
4156 | 4155 | ||
4157 | void CalendarView::action_mail() | 4156 | void CalendarView::action_mail() |
4158 | { | 4157 | { |
4159 | #ifndef KORG_NOMAIL | 4158 | #ifndef KORG_NOMAIL |
4160 | KOMailClient mailClient; | 4159 | KOMailClient mailClient; |
4161 | 4160 | ||
4162 | Incidence *incidence = currentSelection(); | 4161 | Incidence *incidence = currentSelection(); |
4163 | 4162 | ||
4164 | if (!incidence) { | 4163 | if (!incidence) { |
4165 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4164 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4166 | return; | 4165 | return; |
4167 | } | 4166 | } |
4168 | if(incidence->attendeeCount() == 0 ) { | 4167 | if(incidence->attendeeCount() == 0 ) { |
4169 | KMessageBox::sorry(this, | 4168 | KMessageBox::sorry(this, |
4170 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4169 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4171 | return; | 4170 | return; |
4172 | } | 4171 | } |
4173 | 4172 | ||
4174 | CalendarLocal cal_tmp; | 4173 | CalendarLocal cal_tmp; |
4175 | Event *event = 0; | 4174 | Event *event = 0; |
4176 | Event *ev = 0; | 4175 | Event *ev = 0; |
4177 | if ( incidence && incidence->typeID() == eventID ) { | 4176 | if ( incidence && incidence->typeID() == eventID ) { |
4178 | event = static_cast<Event *>(incidence); | 4177 | event = static_cast<Event *>(incidence); |
4179 | ev = new Event(*event); | 4178 | ev = new Event(*event); |
4180 | cal_tmp.addEvent(ev); | 4179 | cal_tmp.addEvent(ev); |
4181 | } | 4180 | } |
4182 | ICalFormat mForm(); | 4181 | ICalFormat mForm(); |
4183 | QString attachment = mForm.toString( &cal_tmp ); | 4182 | QString attachment = mForm.toString( &cal_tmp ); |
4184 | if (ev) delete(ev); | 4183 | if (ev) delete(ev); |
4185 | 4184 | ||
4186 | mailClient.mailAttendees(currentSelection(), attachment); | 4185 | mailClient.mailAttendees(currentSelection(), attachment); |
4187 | 4186 | ||
4188 | #endif | 4187 | #endif |
4189 | 4188 | ||
4190 | #if 0 | 4189 | #if 0 |
4191 | Event *anEvent = 0; | 4190 | Event *anEvent = 0; |
4192 | if (mViewManager->currentView()->isEventView()) { | 4191 | if (mViewManager->currentView()->isEventView()) { |
4193 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 4192 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
4194 | } | 4193 | } |
4195 | 4194 | ||
4196 | if (!anEvent) { | 4195 | if (!anEvent) { |
4197 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4196 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4198 | return; | 4197 | return; |
4199 | } | 4198 | } |
4200 | if(anEvent->attendeeCount() == 0 ) { | 4199 | if(anEvent->attendeeCount() == 0 ) { |
4201 | KMessageBox::sorry(this, | 4200 | KMessageBox::sorry(this, |
4202 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4201 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4203 | return; | 4202 | return; |
4204 | } | 4203 | } |
4205 | 4204 | ||
4206 | mailobject.emailEvent(anEvent); | 4205 | mailobject.emailEvent(anEvent); |
4207 | #endif | 4206 | #endif |
4208 | } | 4207 | } |
4209 | 4208 | ||
4210 | 4209 | ||
4211 | void CalendarView::schedule_publish(Incidence *incidence) | 4210 | void CalendarView::schedule_publish(Incidence *incidence) |
4212 | { | 4211 | { |
4213 | Event *event = 0; | 4212 | Event *event = 0; |
4214 | Todo *todo = 0; | 4213 | Todo *todo = 0; |
4215 | 4214 | ||
4216 | if (incidence == 0) { | 4215 | if (incidence == 0) { |
4217 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4216 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4218 | if (incidence == 0) { | 4217 | if (incidence == 0) { |
4219 | incidence = mTodoList->selectedIncidences().first(); | 4218 | incidence = mTodoList->selectedIncidences().first(); |
4220 | } | 4219 | } |
4221 | } | 4220 | } |
4222 | if ( incidence && incidence->typeID() == eventID ) { | 4221 | if ( incidence && incidence->typeID() == eventID ) { |
4223 | event = static_cast<Event *>(incidence); | 4222 | event = static_cast<Event *>(incidence); |
4224 | } else { | 4223 | } else { |
4225 | if ( incidence && incidence->typeID() == todoID ) { | 4224 | if ( incidence && incidence->typeID() == todoID ) { |
4226 | todo = static_cast<Todo *>(incidence); | 4225 | todo = static_cast<Todo *>(incidence); |
4227 | } | 4226 | } |
4228 | } | 4227 | } |
4229 | 4228 | ||
4230 | if (!event && !todo) { | 4229 | if (!event && !todo) { |
4231 | KMessageBox::sorry(this,i18n("No event selected.")); | 4230 | KMessageBox::sorry(this,i18n("No event selected.")); |
4232 | return; | 4231 | return; |
4233 | } | 4232 | } |
4234 | 4233 | ||
4235 | PublishDialog *publishdlg = new PublishDialog(); | 4234 | PublishDialog *publishdlg = new PublishDialog(); |
4236 | if (incidence->attendeeCount()>0) { | 4235 | if (incidence->attendeeCount()>0) { |
4237 | QPtrList<Attendee> attendees = incidence->attendees(); | 4236 | QPtrList<Attendee> attendees = incidence->attendees(); |
4238 | attendees.first(); | 4237 | attendees.first(); |
4239 | while ( attendees.current()!=0 ) { | 4238 | while ( attendees.current()!=0 ) { |
4240 | publishdlg->addAttendee(attendees.current()); | 4239 | publishdlg->addAttendee(attendees.current()); |
4241 | attendees.next(); | 4240 | attendees.next(); |
4242 | } | 4241 | } |
4243 | } | 4242 | } |
4244 | bool send = true; | 4243 | bool send = true; |
4245 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 4244 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
4246 | if ( publishdlg->exec() != QDialog::Accepted ) | 4245 | if ( publishdlg->exec() != QDialog::Accepted ) |
4247 | send = false; | 4246 | send = false; |
4248 | } | 4247 | } |
4249 | if ( send ) { | 4248 | if ( send ) { |
4250 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4249 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4251 | if ( event ) { | 4250 | if ( event ) { |
4252 | Event *ev = new Event(*event); | 4251 | Event *ev = new Event(*event); |
4253 | ev->registerObserver(0); | 4252 | ev->registerObserver(0); |
4254 | ev->clearAttendees(); | 4253 | ev->clearAttendees(); |
4255 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4254 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4256 | delete(ev); | 4255 | delete(ev); |
4257 | } | 4256 | } |
4258 | } else { | 4257 | } else { |
4259 | if ( todo ) { | 4258 | if ( todo ) { |
4260 | Todo *ev = new Todo(*todo); | 4259 | Todo *ev = new Todo(*todo); |
4261 | ev->registerObserver(0); | 4260 | ev->registerObserver(0); |
4262 | ev->clearAttendees(); | 4261 | ev->clearAttendees(); |
4263 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4262 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4264 | delete(ev); | 4263 | delete(ev); |
4265 | } | 4264 | } |
4266 | } | 4265 | } |
4267 | } | 4266 | } |
4268 | } | 4267 | } |
4269 | delete publishdlg; | 4268 | delete publishdlg; |
4270 | } | 4269 | } |
4271 | 4270 | ||
4272 | void CalendarView::schedule_request(Incidence *incidence) | 4271 | void CalendarView::schedule_request(Incidence *incidence) |
4273 | { | 4272 | { |
4274 | schedule(Scheduler::Request,incidence); | 4273 | schedule(Scheduler::Request,incidence); |
4275 | } | 4274 | } |
4276 | 4275 | ||
4277 | void CalendarView::schedule_refresh(Incidence *incidence) | 4276 | void CalendarView::schedule_refresh(Incidence *incidence) |
4278 | { | 4277 | { |
4279 | schedule(Scheduler::Refresh,incidence); | 4278 | schedule(Scheduler::Refresh,incidence); |
4280 | } | 4279 | } |
4281 | 4280 | ||
4282 | void CalendarView::schedule_cancel(Incidence *incidence) | 4281 | void CalendarView::schedule_cancel(Incidence *incidence) |
4283 | { | 4282 | { |
4284 | schedule(Scheduler::Cancel,incidence); | 4283 | schedule(Scheduler::Cancel,incidence); |
4285 | } | 4284 | } |
4286 | 4285 | ||
4287 | void CalendarView::schedule_add(Incidence *incidence) | 4286 | void CalendarView::schedule_add(Incidence *incidence) |
4288 | { | 4287 | { |
4289 | schedule(Scheduler::Add,incidence); | 4288 | schedule(Scheduler::Add,incidence); |
4290 | } | 4289 | } |
4291 | 4290 | ||
4292 | void CalendarView::schedule_reply(Incidence *incidence) | 4291 | void CalendarView::schedule_reply(Incidence *incidence) |
4293 | { | 4292 | { |
4294 | schedule(Scheduler::Reply,incidence); | 4293 | schedule(Scheduler::Reply,incidence); |
4295 | } | 4294 | } |
4296 | 4295 | ||
4297 | void CalendarView::schedule_counter(Incidence *incidence) | 4296 | void CalendarView::schedule_counter(Incidence *incidence) |
4298 | { | 4297 | { |
4299 | schedule(Scheduler::Counter,incidence); | 4298 | schedule(Scheduler::Counter,incidence); |
4300 | } | 4299 | } |
4301 | 4300 | ||
4302 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 4301 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
4303 | { | 4302 | { |
4304 | schedule(Scheduler::Declinecounter,incidence); | 4303 | schedule(Scheduler::Declinecounter,incidence); |
4305 | } | 4304 | } |
4306 | 4305 | ||
4307 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4306 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4308 | { | 4307 | { |
4309 | QDateTime start = QDateTime::currentDateTime(); | 4308 | QDateTime start = QDateTime::currentDateTime(); |
4310 | QDateTime end = start.addDays(daysToPublish); | 4309 | QDateTime end = start.addDays(daysToPublish); |
4311 | 4310 | ||
4312 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4311 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4313 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4312 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4314 | 4313 | ||
4315 | 4314 | ||
4316 | PublishDialog *publishdlg = new PublishDialog(); | 4315 | PublishDialog *publishdlg = new PublishDialog(); |
4317 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4316 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4318 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4317 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4319 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4318 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4320 | delete(freebusy); | 4319 | delete(freebusy); |
4321 | } | 4320 | } |
4322 | } | 4321 | } |
4323 | delete publishdlg; | 4322 | delete publishdlg; |
4324 | } | 4323 | } |
4325 | 4324 | ||
4326 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4325 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4327 | { | 4326 | { |
4328 | Event *event = 0; | 4327 | Event *event = 0; |
4329 | Todo *todo = 0; | 4328 | Todo *todo = 0; |
4330 | 4329 | ||
4331 | if (incidence == 0) { | 4330 | if (incidence == 0) { |
4332 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4331 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4333 | if (incidence == 0) { | 4332 | if (incidence == 0) { |
4334 | incidence = mTodoList->selectedIncidences().first(); | 4333 | incidence = mTodoList->selectedIncidences().first(); |
4335 | } | 4334 | } |
4336 | } | 4335 | } |
4337 | if ( incidence && incidence->typeID() == eventID ) { | 4336 | if ( incidence && incidence->typeID() == eventID ) { |
4338 | event = static_cast<Event *>(incidence); | 4337 | event = static_cast<Event *>(incidence); |
4339 | } | 4338 | } |
4340 | if ( incidence && incidence->typeID() == todoID ) { | 4339 | if ( incidence && incidence->typeID() == todoID ) { |
4341 | todo = static_cast<Todo *>(incidence); | 4340 | todo = static_cast<Todo *>(incidence); |
4342 | } | 4341 | } |
4343 | 4342 | ||
4344 | if (!event && !todo) { | 4343 | if (!event && !todo) { |
4345 | KMessageBox::sorry(this,i18n("No event selected.")); | 4344 | KMessageBox::sorry(this,i18n("No event selected.")); |
4346 | return; | 4345 | return; |
4347 | } | 4346 | } |
4348 | 4347 | ||
4349 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4348 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4350 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4349 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4351 | return; | 4350 | return; |
4352 | } | 4351 | } |
4353 | 4352 | ||
4354 | Event *ev = 0; | 4353 | Event *ev = 0; |
4355 | if (event) ev = new Event(*event); | 4354 | if (event) ev = new Event(*event); |
4356 | Todo *to = 0; | 4355 | Todo *to = 0; |
4357 | if (todo) to = new Todo(*todo); | 4356 | if (todo) to = new Todo(*todo); |
4358 | 4357 | ||
4359 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4358 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4360 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4359 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4361 | if (!me) { | 4360 | if (!me) { |
4362 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4361 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4363 | return; | 4362 | return; |
4364 | } | 4363 | } |
4365 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4364 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4366 | StatusDialog *statdlg = new StatusDialog(this); | 4365 | StatusDialog *statdlg = new StatusDialog(this); |
4367 | if (!statdlg->exec()==QDialog::Accepted) return; | 4366 | if (!statdlg->exec()==QDialog::Accepted) return; |
4368 | me->setStatus( statdlg->status() ); | 4367 | me->setStatus( statdlg->status() ); |
4369 | delete(statdlg); | 4368 | delete(statdlg); |
4370 | } | 4369 | } |
4371 | Attendee *menew = new Attendee(*me); | 4370 | Attendee *menew = new Attendee(*me); |
4372 | if (ev) { | 4371 | if (ev) { |
4373 | ev->clearAttendees(); | 4372 | ev->clearAttendees(); |
4374 | ev->addAttendee(menew,false); | 4373 | ev->addAttendee(menew,false); |
4375 | } else { | 4374 | } else { |
4376 | if (to) { | 4375 | if (to) { |
4377 | todo->clearAttendees(); | 4376 | todo->clearAttendees(); |
4378 | todo->addAttendee(menew,false); | 4377 | todo->addAttendee(menew,false); |
4379 | } | 4378 | } |
4380 | } | 4379 | } |
4381 | } | 4380 | } |
4382 | 4381 | ||
4383 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4382 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4384 | if (ev) { | 4383 | if (ev) { |
4385 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4384 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4386 | } else { | 4385 | } else { |
4387 | if (to) { | 4386 | if (to) { |
4388 | if ( !dlg->addMessage(to,method) ) delete(to); | 4387 | if ( !dlg->addMessage(to,method) ) delete(to); |
4389 | } | 4388 | } |
4390 | } | 4389 | } |
4391 | } | 4390 | } |
4392 | 4391 | ||
4393 | void CalendarView::openAddressbook() | 4392 | void CalendarView::openAddressbook() |
4394 | { | 4393 | { |
4395 | KRun::runCommand("kaddressbook"); | 4394 | KRun::runCommand("kaddressbook"); |
4396 | } | 4395 | } |
4397 | 4396 | ||
4398 | void CalendarView::setModified(bool modified) | 4397 | void CalendarView::setModified(bool modified) |
4399 | { | 4398 | { |
4400 | //qDebug("CalendarView::setModified %d ", modified); | 4399 | //qDebug("CalendarView::setModified %d ", modified); |
4401 | if ( modified ) | 4400 | if ( modified ) |
4402 | emit signalmodified(); | 4401 | emit signalmodified(); |
4403 | mModified = modified; | 4402 | mModified = modified; |
4404 | if ( mModified ) | 4403 | if ( mModified ) |
4405 | emit modifiedChanged(mModified); | 4404 | emit modifiedChanged(mModified); |
4406 | 4405 | ||
4407 | } | 4406 | } |
4408 | 4407 | ||
4409 | bool CalendarView::isReadOnly() | 4408 | bool CalendarView::isReadOnly() |
4410 | { | 4409 | { |
4411 | return mReadOnly; | 4410 | return mReadOnly; |
4412 | } | 4411 | } |
4413 | 4412 | ||
4414 | void CalendarView::setReadOnly(bool readOnly) | 4413 | void CalendarView::setReadOnly(bool readOnly) |
4415 | { | 4414 | { |
4416 | if (mReadOnly != readOnly) { | 4415 | if (mReadOnly != readOnly) { |
4417 | mReadOnly = readOnly; | 4416 | mReadOnly = readOnly; |
4418 | emit readOnlyChanged(mReadOnly); | 4417 | emit readOnlyChanged(mReadOnly); |
4419 | } | 4418 | } |
4420 | } | 4419 | } |
4421 | 4420 | ||
4422 | bool CalendarView::isModified() | 4421 | bool CalendarView::isModified() |
4423 | { | 4422 | { |
4424 | return mModified; | 4423 | return mModified; |
4425 | } | 4424 | } |
4426 | void CalendarView::slotprintSelInc() | 4425 | void CalendarView::slotprintSelInc() |
4427 | { | 4426 | { |
4428 | if ( currentSelection() == 0 ) { | 4427 | if ( currentSelection() == 0 ) { |
4429 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4428 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4430 | return; | 4429 | return; |
4431 | } | 4430 | } |
4432 | showIncidence(); | 4431 | showIncidence(); |
4433 | getEventViewerDialog()->print(); | 4432 | getEventViewerDialog()->print(); |
4434 | 4433 | ||
4435 | } | 4434 | } |
4436 | void CalendarView::printSetup() | 4435 | void CalendarView::printSetup() |
4437 | { | 4436 | { |
4438 | #ifndef KORG_NOPRINTER | 4437 | #ifndef KORG_NOPRINTER |
4439 | createPrinter(); | 4438 | createPrinter(); |
4440 | 4439 | ||
4441 | mCalPrinter->setupPrinter(); | 4440 | mCalPrinter->setupPrinter(); |
4442 | #endif | 4441 | #endif |
4443 | } | 4442 | } |
4444 | 4443 | ||
4445 | void CalendarView::print() | 4444 | void CalendarView::print() |
4446 | { | 4445 | { |
4447 | #ifndef KORG_NOPRINTER | 4446 | #ifndef KORG_NOPRINTER |
4448 | createPrinter(); | 4447 | createPrinter(); |
4449 | 4448 | ||
4450 | DateList tmpDateList = mNavigator->selectedDates(); | 4449 | DateList tmpDateList = mNavigator->selectedDates(); |
4451 | mCalPrinter->print(CalPrinter::Month, | 4450 | mCalPrinter->print(CalPrinter::Month, |
4452 | tmpDateList.first(), tmpDateList.last()); | 4451 | tmpDateList.first(), tmpDateList.last()); |
4453 | #endif | 4452 | #endif |
4454 | } | 4453 | } |
4455 | 4454 | ||
4456 | void CalendarView::printPreview() | 4455 | void CalendarView::printPreview() |
4457 | { | 4456 | { |
4458 | #ifndef KORG_NOPRINTER | 4457 | #ifndef KORG_NOPRINTER |
4459 | kdDebug() << "CalendarView::printPreview()" << endl; | 4458 | kdDebug() << "CalendarView::printPreview()" << endl; |
4460 | 4459 | ||
4461 | createPrinter(); | 4460 | createPrinter(); |
4462 | 4461 | ||
4463 | DateList tmpDateList = mNavigator->selectedDates(); | 4462 | DateList tmpDateList = mNavigator->selectedDates(); |
4464 | 4463 | ||
4465 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4464 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4466 | tmpDateList.last()); | 4465 | tmpDateList.last()); |
4467 | #endif | 4466 | #endif |
4468 | } | 4467 | } |
4469 | bool CalendarView::exportICalendar( QString filename ) | 4468 | bool CalendarView::exportICalendar( QString filename ) |
4470 | { | 4469 | { |
4471 | // Force correct extension | 4470 | // Force correct extension |
4472 | if (filename.right(4) != ".ics") filename += ".ics"; | 4471 | if (filename.right(4) != ".ics") filename += ".ics"; |
4473 | 4472 | ||
4474 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4473 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4475 | return storage.save(); | 4474 | return storage.save(); |
4476 | } | 4475 | } |
4477 | 4476 | ||
4478 | bool CalendarView::exportICalendar() | 4477 | bool CalendarView::exportICalendar() |
4479 | { | 4478 | { |
4480 | return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); | 4479 | return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); |
4481 | } | 4480 | } |
4482 | 4481 | ||
4483 | bool CalendarView::exportVCalendar( QString filename ) | 4482 | bool CalendarView::exportVCalendar( QString filename ) |
4484 | { | 4483 | { |
4485 | if (mCalendar->journals().count() > 0) { | 4484 | if (mCalendar->journals().count() > 0) { |
4486 | int result = KMessageBox::warningContinueCancel(this, | 4485 | int result = KMessageBox::warningContinueCancel(this, |
4487 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4486 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4488 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4487 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4489 | true); | 4488 | true); |
4490 | if (result != KMessageBox::Continue) return false; | 4489 | if (result != KMessageBox::Continue) return false; |
4491 | } | 4490 | } |
4492 | 4491 | ||
4493 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4492 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4494 | 4493 | ||
4495 | // Force correct extension | 4494 | // Force correct extension |
4496 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4495 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4497 | 4496 | ||
4498 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4497 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4499 | return storage.save(); | 4498 | return storage.save(); |
4500 | 4499 | ||
4501 | } | 4500 | } |
4502 | 4501 | ||
4503 | void CalendarView::eventUpdated(Incidence *) | 4502 | void CalendarView::eventUpdated(Incidence *) |
4504 | { | 4503 | { |
4505 | setModified(); | 4504 | setModified(); |
4506 | // Don't call updateView here. The code, which has caused the update of the | 4505 | // Don't call updateView here. The code, which has caused the update of the |
4507 | // event is responsible for updating the view. | 4506 | // event is responsible for updating the view. |
4508 | // updateView(); | 4507 | // updateView(); |
4509 | } | 4508 | } |
4510 | 4509 | ||
4511 | void CalendarView::adaptNavigationUnits() | 4510 | void CalendarView::adaptNavigationUnits() |
4512 | { | 4511 | { |
4513 | if (mViewManager->currentView()->isEventView()) { | 4512 | if (mViewManager->currentView()->isEventView()) { |
4514 | int days = mViewManager->currentView()->currentDateCount(); | 4513 | int days = mViewManager->currentView()->currentDateCount(); |
4515 | if (days == 1) { | 4514 | if (days == 1) { |
4516 | emit changeNavStringPrev(i18n("&Previous Day")); | 4515 | emit changeNavStringPrev(i18n("&Previous Day")); |
4517 | emit changeNavStringNext(i18n("&Next Day")); | 4516 | emit changeNavStringNext(i18n("&Next Day")); |
4518 | } else { | 4517 | } else { |
4519 | emit changeNavStringPrev(i18n("&Previous Week")); | 4518 | emit changeNavStringPrev(i18n("&Previous Week")); |
4520 | emit changeNavStringNext(i18n("&Next Week")); | 4519 | emit changeNavStringNext(i18n("&Next Week")); |
4521 | } | 4520 | } |
4522 | } | 4521 | } |
4523 | } | 4522 | } |
4524 | 4523 | ||
4525 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4524 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4526 | { | 4525 | { |
4527 | if ( incidence ) mTodoList->clearSelection(); | 4526 | if ( incidence ) mTodoList->clearSelection(); |
4528 | processIncidenceSelection( incidence ); | 4527 | processIncidenceSelection( incidence ); |
4529 | } | 4528 | } |
4530 | 4529 | ||
4531 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4530 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4532 | { | 4531 | { |
4533 | if ( incidence && mViewManager->currentView() ) { | 4532 | if ( incidence && mViewManager->currentView() ) { |
4534 | mViewManager->currentView()->clearSelection(); | 4533 | mViewManager->currentView()->clearSelection(); |
4535 | } | 4534 | } |
4536 | processIncidenceSelection( incidence ); | 4535 | processIncidenceSelection( incidence ); |
4537 | } | 4536 | } |
4538 | 4537 | ||
4539 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4538 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4540 | { | 4539 | { |
4541 | emit incidenceSelected( incidence ); | 4540 | emit incidenceSelected( incidence ); |
4542 | if ( incidence == mSelectedIncidence ) return; | 4541 | if ( incidence == mSelectedIncidence ) return; |
4543 | mSelectedIncidence = incidence; | 4542 | mSelectedIncidence = incidence; |
4544 | 4543 | ||
4545 | if ( incidence && incidence->typeID() == eventID ) { | 4544 | if ( incidence && incidence->typeID() == eventID ) { |
4546 | Event *event = static_cast<Event *>( incidence ); | 4545 | Event *event = static_cast<Event *>( incidence ); |
4547 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4546 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4548 | emit organizerEventsSelected( true ); | 4547 | emit organizerEventsSelected( true ); |
4549 | } else { | 4548 | } else { |
4550 | emit organizerEventsSelected(false); | 4549 | emit organizerEventsSelected(false); |
4551 | } | 4550 | } |
4552 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4551 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4553 | KOPrefs::instance()->email() ) ) { | 4552 | KOPrefs::instance()->email() ) ) { |
4554 | emit groupEventsSelected( true ); | 4553 | emit groupEventsSelected( true ); |
4555 | } else { | 4554 | } else { |
4556 | emit groupEventsSelected(false); | 4555 | emit groupEventsSelected(false); |
4557 | } | 4556 | } |
4558 | return; | 4557 | return; |
4559 | } else { | 4558 | } else { |
4560 | if ( incidence && incidence->typeID() == todoID ) { | 4559 | if ( incidence && incidence->typeID() == todoID ) { |
4561 | emit todoSelected( true ); | 4560 | emit todoSelected( true ); |
4562 | Todo *event = static_cast<Todo *>( incidence ); | 4561 | Todo *event = static_cast<Todo *>( incidence ); |
4563 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4562 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4564 | emit organizerEventsSelected( true ); | 4563 | emit organizerEventsSelected( true ); |
4565 | } else { | 4564 | } else { |
4566 | emit organizerEventsSelected(false); | 4565 | emit organizerEventsSelected(false); |
4567 | } | 4566 | } |
4568 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4567 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4569 | KOPrefs::instance()->email() ) ) { | 4568 | KOPrefs::instance()->email() ) ) { |
4570 | emit groupEventsSelected( true ); | 4569 | emit groupEventsSelected( true ); |
4571 | } else { | 4570 | } else { |
4572 | emit groupEventsSelected(false); | 4571 | emit groupEventsSelected(false); |
4573 | } | 4572 | } |
4574 | return; | 4573 | return; |
4575 | } else { | 4574 | } else { |
4576 | emit todoSelected( false ); | 4575 | emit todoSelected( false ); |
4577 | emit organizerEventsSelected(false); | 4576 | emit organizerEventsSelected(false); |
4578 | emit groupEventsSelected(false); | 4577 | emit groupEventsSelected(false); |
4579 | } | 4578 | } |
4580 | return; | 4579 | return; |
4581 | } | 4580 | } |
4582 | 4581 | ||
4583 | /* if ( incidence && incidence->typeID() == todoID ) { | 4582 | /* if ( incidence && incidence->typeID() == todoID ) { |
4584 | emit todoSelected( true ); | 4583 | emit todoSelected( true ); |
4585 | } else { | 4584 | } else { |
4586 | emit todoSelected( false ); | 4585 | emit todoSelected( false ); |
4587 | }*/ | 4586 | }*/ |
4588 | } | 4587 | } |
4589 | 4588 | ||
4590 | 4589 | ||
4591 | void CalendarView::checkClipboard() | 4590 | void CalendarView::checkClipboard() |
4592 | { | 4591 | { |
4593 | #ifndef KORG_NODND | 4592 | #ifndef KORG_NODND |
4594 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4593 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4595 | emit pasteEnabled(true); | 4594 | emit pasteEnabled(true); |
4596 | } else { | 4595 | } else { |
4597 | emit pasteEnabled(false); | 4596 | emit pasteEnabled(false); |
4598 | } | 4597 | } |
4599 | #endif | 4598 | #endif |
4600 | } | 4599 | } |
4601 | 4600 | ||
4602 | void CalendarView::showDates(const DateList &selectedDates) | 4601 | void CalendarView::showDates(const DateList &selectedDates) |
4603 | { | 4602 | { |
4604 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4603 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4605 | 4604 | ||
4606 | 4605 | ||
4607 | if ( !mBlockShowDates ) { | 4606 | if ( !mBlockShowDates ) { |
4608 | if ( mViewManager->currentView() ) { | 4607 | if ( mViewManager->currentView() ) { |
4609 | updateView( selectedDates.first(), selectedDates.last() ); | 4608 | updateView( selectedDates.first(), selectedDates.last() ); |
4610 | } else { | 4609 | } else { |
4611 | mViewManager->showAgendaView(); | 4610 | mViewManager->showAgendaView(); |
4612 | } | 4611 | } |
4613 | } | 4612 | } |
4614 | 4613 | ||
4615 | QDate date = selectedDates.first(); | 4614 | QDate date = selectedDates.first(); |
4616 | if ( ! date.isValid() ) { | 4615 | if ( ! date.isValid() ) { |
4617 | topLevelWidget()->setCaption(""); | 4616 | topLevelWidget()->setCaption(""); |
4618 | return; | 4617 | return; |
4619 | } | 4618 | } |
4620 | 4619 | ||
4621 | QString selDates; | 4620 | QString selDates; |
4622 | selDates = KGlobal::locale()->formatDate( date, true); | 4621 | selDates = KGlobal::locale()->formatDate( date, true); |
4623 | if (selectedDates.first() < selectedDates.last() ) | 4622 | if (selectedDates.first() < selectedDates.last() ) |
4624 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4623 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4625 | else { | 4624 | else { |
4626 | QString addString; | 4625 | QString addString; |
4627 | if ( date == QDateTime::currentDateTime().date() ) | 4626 | if ( date == QDateTime::currentDateTime().date() ) |
4628 | addString = i18n("Today"); | 4627 | addString = i18n("Today"); |
4629 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4628 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4630 | addString = i18n("Tomorrow"); | 4629 | addString = i18n("Tomorrow"); |
4631 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4630 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4632 | addString = i18n("Yesterday"); | 4631 | addString = i18n("Yesterday"); |
4633 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4632 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4634 | addString = i18n("Day before yesterday"); | 4633 | addString = i18n("Day before yesterday"); |
4635 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4634 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4636 | addString = i18n("Day after tomorrow"); | 4635 | addString = i18n("Day after tomorrow"); |
4637 | if ( !addString.isEmpty() ) { | 4636 | if ( !addString.isEmpty() ) { |
4638 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4637 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4639 | return; | 4638 | return; |
4640 | } | 4639 | } |
4641 | } | 4640 | } |
4642 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4641 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4643 | 4642 | ||
4644 | } | 4643 | } |
4645 | 4644 | ||
4646 | QPtrList<CalFilter> CalendarView::filters() | 4645 | QPtrList<CalFilter> CalendarView::filters() |
4647 | { | 4646 | { |
4648 | return mFilters; | 4647 | return mFilters; |
4649 | 4648 | ||
4650 | } | 4649 | } |
4651 | void CalendarView::editFilters() | 4650 | void CalendarView::editFilters() |
4652 | { | 4651 | { |
4653 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4652 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4654 | 4653 | ||
4655 | CalFilter *filter = mFilters.first(); | 4654 | CalFilter *filter = mFilters.first(); |
4656 | while(filter) { | 4655 | while(filter) { |
4657 | filter = mFilters.next(); | 4656 | filter = mFilters.next(); |
4658 | } | 4657 | } |
4659 | 4658 | ||
4660 | mDialogManager->showFilterEditDialog(&mFilters); | 4659 | mDialogManager->showFilterEditDialog(&mFilters); |
4661 | updateFilter(); | 4660 | updateFilter(); |
4662 | } | 4661 | } |
4663 | void CalendarView::toggleFilter() | 4662 | void CalendarView::toggleFilter() |
4664 | { | 4663 | { |
4665 | if ( mLeftFrame->isHidden() ) { | 4664 | if ( mLeftFrame->isHidden() ) { |
4666 | toggleExpand(); | 4665 | toggleExpand(); |
4667 | showFilter( true ); | 4666 | showFilter( true ); |
4668 | } else | 4667 | } else |
4669 | showFilter(! mCalEditView->isVisible()); | 4668 | showFilter(! mCalEditView->isVisible()); |
4670 | } | 4669 | } |
4671 | 4670 | ||
4672 | KOFilterView *CalendarView::filterView() | 4671 | KOFilterView *CalendarView::filterView() |
4673 | { | 4672 | { |
4674 | return mFilterView; | 4673 | return mFilterView; |
4675 | } | 4674 | } |
4676 | void CalendarView::selectFilter( int fil ) | 4675 | void CalendarView::selectFilter( int fil ) |
4677 | { | 4676 | { |
4678 | mFilterView->setSelectedFilter( fil ); | 4677 | mFilterView->setSelectedFilter( fil ); |
4679 | updateUnmanagedViews(); | 4678 | updateUnmanagedViews(); |
4680 | } | 4679 | } |
4681 | void CalendarView::showFilter(bool visible) | 4680 | void CalendarView::showFilter(bool visible) |
4682 | { | 4681 | { |
4683 | #if 1 | 4682 | #if 1 |
4684 | if (visible) { | 4683 | if (visible) { |
4685 | mCalEditView->readConfig(); | 4684 | mCalEditView->readConfig(); |
4686 | mCalEditView->show(); | 4685 | mCalEditView->show(); |
4687 | QValueList<int> sizes; | 4686 | QValueList<int> sizes; |
4688 | sizes = mLeftFrame->sizes(); | 4687 | sizes = mLeftFrame->sizes(); |
4689 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4688 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4690 | sizes.clear(); | 4689 | sizes.clear(); |
4691 | sizes << 100; | 4690 | sizes << 100; |
4692 | sizes << 0; | 4691 | sizes << 0; |
4693 | sizes << 0; | 4692 | sizes << 0; |
4694 | sizes << 100; | 4693 | sizes << 100; |
4695 | mLeftFrame->setSizes(sizes); | 4694 | mLeftFrame->setSizes(sizes); |
4696 | } | 4695 | } |
4697 | #if 0 | 4696 | #if 0 |
4698 | sizes = mLeftFrame->sizes(); | 4697 | sizes = mLeftFrame->sizes(); |
4699 | int ccc = 0; | 4698 | int ccc = 0; |
4700 | while ( ccc < sizes.count()) { | 4699 | while ( ccc < sizes.count()) { |
4701 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4700 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4702 | ++ccc; | 4701 | ++ccc; |
4703 | } | 4702 | } |
4704 | #endif | 4703 | #endif |
4705 | 4704 | ||
4706 | } | 4705 | } |
4707 | else { | 4706 | else { |
4708 | mCalEditView->hide(); | 4707 | mCalEditView->hide(); |
4709 | } | 4708 | } |
4710 | #else | 4709 | #else |
4711 | if (visible) mFilterView->show(); | 4710 | if (visible) mFilterView->show(); |
4712 | else mFilterView->hide(); | 4711 | else mFilterView->hide(); |
4713 | #endif | 4712 | #endif |
4714 | } | 4713 | } |
4715 | void CalendarView::toggleFilerEnabled( ) | 4714 | void CalendarView::toggleFilerEnabled( ) |
4716 | { | 4715 | { |
4717 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4716 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4718 | if ( !mFilterView->filtersEnabled() ) | 4717 | if ( !mFilterView->filtersEnabled() ) |
4719 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4718 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4720 | updateUnmanagedViews(); | 4719 | updateUnmanagedViews(); |
4721 | 4720 | ||
4722 | } | 4721 | } |
4723 | void CalendarView::updateFilter() | 4722 | void CalendarView::updateFilter() |
4724 | { | 4723 | { |
4725 | CalFilter *filter = mFilterView->selectedFilter(); | 4724 | CalFilter *filter = mFilterView->selectedFilter(); |
4726 | if (filter) { | 4725 | if (filter) { |
4727 | QString mess; | 4726 | QString mess; |
4728 | if (mFilterView->filtersEnabled()) { | 4727 | if (mFilterView->filtersEnabled()) { |
4729 | mess = i18n("Filter selected: ")+filter->name(); | 4728 | mess = i18n("Filter selected: ")+filter->name(); |
4730 | filter->setEnabled(true); | 4729 | filter->setEnabled(true); |
4731 | } | 4730 | } |
4732 | else filter->setEnabled(false); | 4731 | else filter->setEnabled(false); |
4733 | mCalendar->setFilter(filter); | 4732 | mCalendar->setFilter(filter); |
4734 | updateView(); | 4733 | updateView(); |
4735 | if ( !mess.isEmpty() ) | 4734 | if ( !mess.isEmpty() ) |
4736 | topLevelWidget()->setCaption( mess ); | 4735 | topLevelWidget()->setCaption( mess ); |
4737 | 4736 | ||
4738 | } | 4737 | } |
4739 | emit filtersUpdated(); | 4738 | emit filtersUpdated(); |
4740 | } | 4739 | } |
4741 | 4740 | ||
4742 | void CalendarView::filterEdited() | 4741 | void CalendarView::filterEdited() |
4743 | { | 4742 | { |
4744 | mFilterView->updateFilters(); | 4743 | mFilterView->updateFilters(); |
4745 | updateFilter(); | 4744 | updateFilter(); |
4746 | writeSettings(); | 4745 | writeSettings(); |
4747 | } | 4746 | } |
4748 | 4747 | ||
4749 | 4748 | ||
4750 | void CalendarView::takeOverEvent() | 4749 | void CalendarView::takeOverEvent() |
4751 | { | 4750 | { |
4752 | Incidence *incidence = currentSelection(); | 4751 | Incidence *incidence = currentSelection(); |
4753 | 4752 | ||
4754 | if (!incidence) return; | 4753 | if (!incidence) return; |
4755 | 4754 | ||
4756 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4755 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4757 | incidence->recreate(); | 4756 | incidence->recreate(); |
4758 | incidence->setReadOnly(false); | 4757 | incidence->setReadOnly(false); |
4759 | 4758 | ||
4760 | updateView(); | 4759 | updateView(); |
4761 | } | 4760 | } |
4762 | 4761 | ||
4763 | void CalendarView::takeOverCalendar() | 4762 | void CalendarView::takeOverCalendar() |
4764 | { | 4763 | { |
4765 | // TODO: Create Calendar::allIncidences() function and use it here | 4764 | // TODO: Create Calendar::allIncidences() function and use it here |
4766 | 4765 | ||
4767 | clearAllViews(); | 4766 | clearAllViews(); |
4768 | QPtrList<Event> events = mCalendar->events(); | 4767 | QPtrList<Event> events = mCalendar->events(); |
4769 | for(uint i=0; i<events.count(); ++i) { | 4768 | for(uint i=0; i<events.count(); ++i) { |
4770 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4769 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4771 | events.at(i)->recreate(); | 4770 | events.at(i)->recreate(); |
4772 | events.at(i)->setReadOnly(false); | 4771 | events.at(i)->setReadOnly(false); |
4773 | } | 4772 | } |
4774 | 4773 | ||
4775 | QPtrList<Todo> todos = mCalendar->todos(); | 4774 | QPtrList<Todo> todos = mCalendar->todos(); |
4776 | for(uint i=0; i<todos.count(); ++i) { | 4775 | for(uint i=0; i<todos.count(); ++i) { |
4777 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4776 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4778 | todos.at(i)->recreate(); | 4777 | todos.at(i)->recreate(); |
4779 | todos.at(i)->setReadOnly(false); | 4778 | todos.at(i)->setReadOnly(false); |
4780 | } | 4779 | } |
4781 | 4780 | ||
4782 | QPtrList<Journal> journals = mCalendar->journals(); | 4781 | QPtrList<Journal> journals = mCalendar->journals(); |
4783 | for(uint i=0; i<journals.count(); ++i) { | 4782 | for(uint i=0; i<journals.count(); ++i) { |
4784 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4783 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4785 | journals.at(i)->recreate(); | 4784 | journals.at(i)->recreate(); |
4786 | journals.at(i)->setReadOnly(false); | 4785 | journals.at(i)->setReadOnly(false); |
4787 | } | 4786 | } |
4788 | 4787 | ||
4789 | updateView(); | 4788 | updateView(); |
4790 | } | 4789 | } |
4791 | 4790 | ||
4792 | void CalendarView::showIntro() | 4791 | void CalendarView::showIntro() |
4793 | { | 4792 | { |
4794 | kdDebug() << "To be implemented." << endl; | 4793 | kdDebug() << "To be implemented." << endl; |
4795 | } | 4794 | } |
4796 | 4795 | ||
4797 | QWidgetStack *CalendarView::viewStack() | 4796 | QWidgetStack *CalendarView::viewStack() |
4798 | { | 4797 | { |
4799 | return mRightFrame; | 4798 | return mRightFrame; |
4800 | } | 4799 | } |
4801 | 4800 | ||
4802 | QWidget *CalendarView::leftFrame() | 4801 | QWidget *CalendarView::leftFrame() |
4803 | { | 4802 | { |
4804 | return ( QWidget *)mLeftFrame; | 4803 | return ( QWidget *)mLeftFrame; |
4805 | } | 4804 | } |
4806 | 4805 | ||
4807 | DateNavigator *CalendarView::dateNavigator() | 4806 | DateNavigator *CalendarView::dateNavigator() |
4808 | { | 4807 | { |
4809 | return mNavigator; | 4808 | return mNavigator; |
4810 | } | 4809 | } |
4811 | 4810 | ||
4812 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4811 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4813 | { | 4812 | { |
4814 | return mDateNavigator->navigatorView(); | 4813 | return mDateNavigator->navigatorView(); |
4815 | } | 4814 | } |
4816 | void CalendarView::toggleDateNavigatorWidget() | 4815 | void CalendarView::toggleDateNavigatorWidget() |
4817 | { | 4816 | { |
4818 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4817 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4819 | 4818 | ||
4820 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4819 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4821 | mDateNavigator->hide(); | 4820 | mDateNavigator->hide(); |
4822 | else | 4821 | else |
4823 | mDateNavigator->show(); | 4822 | mDateNavigator->show(); |
4824 | } | 4823 | } |
4825 | void CalendarView::addView(KOrg::BaseView *view) | 4824 | void CalendarView::addView(KOrg::BaseView *view) |
4826 | { | 4825 | { |
4827 | mViewManager->addView(view); | 4826 | mViewManager->addView(view); |
4828 | } | 4827 | } |
4829 | 4828 | ||
4830 | void CalendarView::showView(KOrg::BaseView *view) | 4829 | void CalendarView::showView(KOrg::BaseView *view) |
4831 | { | 4830 | { |
4832 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4831 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4833 | } | 4832 | } |
4834 | 4833 | ||
4835 | Incidence *CalendarView::currentSelection() | 4834 | Incidence *CalendarView::currentSelection() |
4836 | { | 4835 | { |
4837 | return mViewManager->currentSelection(); | 4836 | return mViewManager->currentSelection(); |
4838 | } | 4837 | } |
4839 | void CalendarView::toggleAllDaySize() | 4838 | void CalendarView::toggleAllDaySize() |
4840 | { | 4839 | { |
4841 | /* | 4840 | /* |
4842 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4841 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4843 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4842 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4844 | else | 4843 | else |
4845 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4844 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4846 | */ | 4845 | */ |
4847 | viewManager()->agendaView()->toggleAllDay(); | 4846 | viewManager()->agendaView()->toggleAllDay(); |
4848 | } | 4847 | } |
4849 | void CalendarView::toggleExpand() | 4848 | void CalendarView::toggleExpand() |
4850 | { | 4849 | { |
4851 | // if ( mLeftFrame->isHidden() ) { | 4850 | // if ( mLeftFrame->isHidden() ) { |
4852 | // mLeftFrame->show(); | 4851 | // mLeftFrame->show(); |
4853 | // emit calendarViewExpanded( false ); | 4852 | // emit calendarViewExpanded( false ); |
4854 | // } else { | 4853 | // } else { |
4855 | // mLeftFrame->hide(); | 4854 | // mLeftFrame->hide(); |
4856 | // emit calendarViewExpanded( true ); | 4855 | // emit calendarViewExpanded( true ); |
4857 | // } | 4856 | // } |
4858 | //qDebug(" CalendarView::toggleExpand()"); | 4857 | //qDebug(" CalendarView::toggleExpand()"); |
4859 | globalFlagBlockAgenda = 1; | 4858 | globalFlagBlockAgenda = 1; |
4860 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4859 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4861 | globalFlagBlockAgenda = 5; | 4860 | globalFlagBlockAgenda = 5; |
4862 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4861 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4863 | //mViewManager->showView( 0, true ); | 4862 | //mViewManager->showView( 0, true ); |
4864 | } | 4863 | } |
4865 | 4864 | ||
4866 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4865 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4867 | { | 4866 | { |
4868 | setModified( modified ); | 4867 | setModified( modified ); |
4869 | } | 4868 | } |
4870 | 4869 | ||
4871 | Todo *CalendarView::selectedTodo() | 4870 | Todo *CalendarView::selectedTodo() |
4872 | { | 4871 | { |
4873 | Incidence *incidence = currentSelection(); | 4872 | Incidence *incidence = currentSelection(); |
4874 | if ( incidence && incidence->typeID() == todoID ) { | 4873 | if ( incidence && incidence->typeID() == todoID ) { |
4875 | return static_cast<Todo *>( incidence ); | 4874 | return static_cast<Todo *>( incidence ); |
4876 | } | 4875 | } |
4877 | 4876 | ||
4878 | incidence = mTodoList->selectedIncidences().first(); | 4877 | incidence = mTodoList->selectedIncidences().first(); |
4879 | if ( incidence && incidence->typeID() == todoID ) { | 4878 | if ( incidence && incidence->typeID() == todoID ) { |
4880 | return static_cast<Todo *>( incidence ); | 4879 | return static_cast<Todo *>( incidence ); |
4881 | } | 4880 | } |
4882 | 4881 | ||
4883 | return 0; | 4882 | return 0; |
4884 | } | 4883 | } |
4885 | 4884 | ||
4886 | void CalendarView::showIncidence() | 4885 | void CalendarView::showIncidence() |
4887 | { | 4886 | { |
4888 | mViewerCallerIsSearchDialog = false; | 4887 | mViewerCallerIsSearchDialog = false; |
4889 | Incidence *incidence = currentSelection(); | 4888 | Incidence *incidence = currentSelection(); |
4890 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4889 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4891 | if ( incidence ) { | 4890 | if ( incidence ) { |
4892 | ShowIncidenceVisitor v; | 4891 | ShowIncidenceVisitor v; |
4893 | v.act( incidence, this ); | 4892 | v.act( incidence, this ); |
4894 | } | 4893 | } |
4895 | } | 4894 | } |
4896 | void CalendarView::editIncidenceDescription() | 4895 | void CalendarView::editIncidenceDescription() |
4897 | { | 4896 | { |
4898 | mFlagEditDescription = true; | 4897 | mFlagEditDescription = true; |
4899 | editIncidence(); | 4898 | editIncidence(); |
4900 | mFlagEditDescription = false; | 4899 | mFlagEditDescription = false; |
4901 | } | 4900 | } |
4902 | void CalendarView::editIncidence() | 4901 | void CalendarView::editIncidence() |
4903 | { | 4902 | { |
4904 | // qDebug("editIncidence() "); | 4903 | // qDebug("editIncidence() "); |
4905 | Incidence *incidence = currentSelection(); | 4904 | Incidence *incidence = currentSelection(); |
4906 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4905 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4907 | if ( incidence ) { | 4906 | if ( incidence ) { |
4908 | EditIncidenceVisitor v; | 4907 | EditIncidenceVisitor v; |
4909 | v.act( incidence, this ); | 4908 | v.act( incidence, this ); |
4910 | } | 4909 | } |
4911 | } | 4910 | } |
4912 | 4911 | ||
4913 | void CalendarView::deleteIncidence() | 4912 | void CalendarView::deleteIncidence() |
4914 | { | 4913 | { |
4915 | Incidence *incidence = currentSelection(); | 4914 | Incidence *incidence = currentSelection(); |
4916 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4915 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4917 | if ( incidence ) { | 4916 | if ( incidence ) { |
4918 | deleteIncidence(incidence); | 4917 | deleteIncidence(incidence); |
4919 | } | 4918 | } |
4920 | } | 4919 | } |
4921 | void CalendarView::showIncidence(QString uid) | 4920 | void CalendarView::showIncidence(QString uid) |
4922 | { | 4921 | { |
4923 | Incidence *inc = mCalendar->incidence( uid ); | 4922 | Incidence *inc = mCalendar->incidence( uid ); |
4924 | if ( inc ) | 4923 | if ( inc ) |
4925 | showIncidence( inc ); | 4924 | showIncidence( inc ); |
4926 | } | 4925 | } |
4927 | void CalendarView::showIncidence(Incidence *incidence) | 4926 | void CalendarView::showIncidence(Incidence *incidence) |
4928 | { | 4927 | { |
4929 | mViewerCallerIsSearchDialog = false; | 4928 | mViewerCallerIsSearchDialog = false; |
4930 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4929 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4931 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4930 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4932 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4931 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4933 | mViewerCallerIsSearchDialog = true; | 4932 | mViewerCallerIsSearchDialog = true; |
4934 | } | 4933 | } |
4935 | } | 4934 | } |
4936 | if ( incidence ) { | 4935 | if ( incidence ) { |
4937 | ShowIncidenceVisitor v; | 4936 | ShowIncidenceVisitor v; |
4938 | v.act( incidence, this ); | 4937 | v.act( incidence, this ); |
4939 | } | 4938 | } |
4940 | } | 4939 | } |
4941 | 4940 | ||
4942 | void CalendarView::editIncidence(Incidence *incidence) | 4941 | void CalendarView::editIncidence(Incidence *incidence) |
4943 | { | 4942 | { |
4944 | if ( incidence ) { | 4943 | if ( incidence ) { |
4945 | 4944 | ||
4946 | EditIncidenceVisitor v; | 4945 | EditIncidenceVisitor v; |
4947 | v.act( incidence, this ); | 4946 | v.act( incidence, this ); |
4948 | 4947 | ||
4949 | } | 4948 | } |
4950 | } | 4949 | } |
4951 | 4950 | ||
4952 | void CalendarView::deleteIncidence(Incidence *incidence) | 4951 | void CalendarView::deleteIncidence(Incidence *incidence) |
4953 | { | 4952 | { |
4954 | //qDebug(" CalendarView::deleteIncidence "); | 4953 | //qDebug(" CalendarView::deleteIncidence "); |
4955 | if ( incidence == 0 ) { | 4954 | if ( incidence == 0 ) { |
4956 | updateView(); | 4955 | updateView(); |
4957 | emit updateSearchDialog(); | 4956 | emit updateSearchDialog(); |
4958 | return; | 4957 | return; |
4959 | } | 4958 | } |
4960 | if ( incidence ) { | 4959 | if ( incidence ) { |
4961 | DeleteIncidenceVisitor v; | 4960 | DeleteIncidenceVisitor v; |
4962 | v.act( incidence, this ); | 4961 | v.act( incidence, this ); |
4963 | } | 4962 | } |
4964 | } | 4963 | } |
4965 | 4964 | ||
4966 | 4965 | ||
4967 | void CalendarView::lookForOutgoingMessages() | 4966 | void CalendarView::lookForOutgoingMessages() |
4968 | { | 4967 | { |
4969 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4968 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4970 | ogd->loadMessages(); | 4969 | ogd->loadMessages(); |
4971 | } | 4970 | } |
4972 | 4971 | ||
4973 | void CalendarView::lookForIncomingMessages() | 4972 | void CalendarView::lookForIncomingMessages() |
4974 | { | 4973 | { |
4975 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4974 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4976 | icd->retrieve(); | 4975 | icd->retrieve(); |
4977 | } | 4976 | } |
4978 | 4977 | ||
4979 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4978 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4980 | { | 4979 | { |
4981 | bool deleteTodo = true; | 4980 | bool deleteTodo = true; |
4982 | QPtrList<Incidence> subTodos; | 4981 | QPtrList<Incidence> subTodos; |
4983 | Incidence *aTodo; | 4982 | Incidence *aTodo; |
4984 | subTodos = t->relations(); | 4983 | subTodos = t->relations(); |
4985 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4984 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4986 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4985 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4987 | deleteTodo = false; | 4986 | deleteTodo = false; |
4988 | } | 4987 | } |
4989 | if ( deleteTodo ) { | 4988 | if ( deleteTodo ) { |
4990 | if ( t->isCompleted() && !t->doesRecur()) { | 4989 | if ( t->isCompleted() && !t->doesRecur()) { |
4991 | checkExternalId( t ); | 4990 | checkExternalId( t ); |
4992 | mCalendar->deleteTodo( t ); | 4991 | mCalendar->deleteTodo( t ); |
4993 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4992 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4994 | } | 4993 | } |
4995 | else | 4994 | else |
4996 | deleteTodo = false; | 4995 | deleteTodo = false; |
4997 | } | 4996 | } |
4998 | return deleteTodo; | 4997 | return deleteTodo; |
4999 | 4998 | ||
5000 | } | 4999 | } |
5001 | void CalendarView::purgeCompleted() | 5000 | void CalendarView::purgeCompleted() |
5002 | { | 5001 | { |
5003 | int result = KMessageBox::warningContinueCancel(this, | 5002 | int result = KMessageBox::warningContinueCancel(this, |
5004 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 5003 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
5005 | 5004 | ||
5006 | if (result == KMessageBox::Continue) { | 5005 | if (result == KMessageBox::Continue) { |
5007 | 5006 | ||
5008 | QPtrList<Todo> todoCal; | 5007 | QPtrList<Todo> todoCal; |
5009 | QPtrList<Todo> rootTodos; | 5008 | QPtrList<Todo> rootTodos; |
5010 | //QPtrList<Incidence> rel; | 5009 | //QPtrList<Incidence> rel; |
5011 | Todo *aTodo; | 5010 | Todo *aTodo; |
5012 | todoCal = calendar()->todos(); | 5011 | todoCal = calendar()->todos(); |
5013 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 5012 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
5014 | if ( !aTodo->relatedTo() ) | 5013 | if ( !aTodo->relatedTo() ) |
5015 | rootTodos.append( aTodo ); | 5014 | rootTodos.append( aTodo ); |
5016 | } | 5015 | } |
5017 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 5016 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
5018 | removeCompletedSubTodos( aTodo ); | 5017 | removeCompletedSubTodos( aTodo ); |
5019 | } | 5018 | } |
5020 | 5019 | ||
5021 | updateView(); | 5020 | updateView(); |
5022 | } | 5021 | } |
5023 | } | 5022 | } |
5024 | 5023 | ||
5025 | void CalendarView::slotCalendarChanged() | 5024 | void CalendarView::slotCalendarChanged() |
5026 | { | 5025 | { |
5027 | ; | 5026 | ; |
5028 | } | 5027 | } |
5029 | 5028 | ||
5030 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 5029 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
5031 | { | 5030 | { |
5032 | //qDebug("CalendarView::keyPressEvent "); | 5031 | //qDebug("CalendarView::keyPressEvent "); |
5033 | e->ignore(); | 5032 | e->ignore(); |
5034 | } | 5033 | } |
5035 | 5034 | ||
5036 | 5035 | ||
5037 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 5036 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
5038 | { | 5037 | { |
5039 | 5038 | ||
5040 | if ( manager != mSyncManager) | 5039 | if ( manager != mSyncManager) |
5041 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 5040 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
5042 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 5041 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
5043 | qDebug("KO: SyncKDE request detected!"); | 5042 | qDebug("KO: SyncKDE request detected!"); |
5044 | } | 5043 | } |
5045 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5044 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5046 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5045 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5047 | return syncCalendar( filename, mode ); | 5046 | if ( !resource.isEmpty() ) { |
5047 | int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | ||
5048 | qDebug( "KO: Sync request for resource: %s", resource.latin1() ); | ||
5049 | |||
5050 | if ( !exclusiveSyncResource ) { | ||
5051 | qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); | ||
5052 | return false; | ||
5053 | } | ||
5054 | mCalendar->setDefaultCalendar( exclusiveSyncResource ); | ||
5055 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
5056 | } | ||
5057 | bool result = syncCalendar( filename, mode ); | ||
5058 | if ( !resource.isEmpty() ) | ||
5059 | restoreCalendarSettings(); | ||
5060 | return result; | ||
5048 | } | 5061 | } |
5049 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 5062 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
5050 | { | 5063 | { |
5051 | //mSyncManager = manager; | 5064 | //mSyncManager = manager; |
5052 | if ( manager != mSyncManager) | 5065 | if ( manager != mSyncManager) |
5053 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 5066 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
5054 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5067 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5055 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5068 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5056 | if ( resource == "sharp" ) | 5069 | if ( resource == "sharp" ) |
5057 | syncExternal( 0 ); | 5070 | syncExternal( 0 ); |
5058 | if ( resource == "phone" ) | 5071 | if ( resource == "phone" ) |
5059 | syncExternal( 1 ); | 5072 | syncExternal( 1 ); |
5060 | // pending setmodified | 5073 | // pending setmodified |
5061 | return true; | 5074 | return true; |
5062 | } | 5075 | } |
5063 | void CalendarView::setSyncManager(KSyncManager* manager) | 5076 | void CalendarView::setSyncManager(KSyncManager* manager) |
5064 | { | 5077 | { |
5065 | mSyncManager = manager; | 5078 | mSyncManager = manager; |
5066 | } | 5079 | } |
5067 | 5080 | ||
5068 | void CalendarView::removeSyncInfo( QString syncProfile) | 5081 | void CalendarView::removeSyncInfo( QString syncProfile) |
5069 | { | 5082 | { |
5070 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 5083 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
5071 | mCalendar->removeSyncInfo( syncProfile ); | 5084 | mCalendar->removeSyncInfo( syncProfile ); |
5072 | 5085 | ||
5073 | } | 5086 | } |
5074 | 5087 | ||
5075 | void CalendarView::undo_delete() | 5088 | void CalendarView::undo_delete() |
5076 | { | 5089 | { |
5077 | //qDebug("undo_delete() "); | 5090 | //qDebug("undo_delete() "); |
5078 | Incidence* undo = mCalendar->undoIncidence(); | 5091 | Incidence* undo = mCalendar->undoIncidence(); |
5079 | if ( !undo ) { | 5092 | if ( !undo ) { |
5080 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 5093 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
5081 | i18n("KO/Pi")); | 5094 | i18n("KO/Pi")); |
5082 | return; | 5095 | return; |
5083 | } | 5096 | } |
5084 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 5097 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
5085 | i18n("\nAre you sure you want\nto restore this?"), | 5098 | i18n("\nAre you sure you want\nto restore this?"), |
5086 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 5099 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
5087 | mCalendar->undoDeleteIncidence(); | 5100 | mCalendar->undoDeleteIncidence(); |
5088 | updateView(); | 5101 | updateView(); |
5089 | } | 5102 | } |
5090 | } | 5103 | } |
5091 | 5104 | ||
5092 | void CalendarView::slotViewerClosed() | 5105 | void CalendarView::slotViewerClosed() |
5093 | { | 5106 | { |
5094 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 5107 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
5095 | } | 5108 | } |
5096 | 5109 | ||
5097 | void CalendarView::resetFocus() | 5110 | void CalendarView::resetFocus() |
5098 | { | 5111 | { |
5099 | if ( mViewerCallerIsSearchDialog ) { | 5112 | if ( mViewerCallerIsSearchDialog ) { |
5100 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 5113 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
5101 | mDialogManager->getSearchDialog()->raise(); | 5114 | mDialogManager->getSearchDialog()->raise(); |
5102 | mDialogManager->getSearchDialog()->setActiveWindow(); | 5115 | mDialogManager->getSearchDialog()->setActiveWindow(); |
5103 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 5116 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
5104 | } else | 5117 | } else |
5105 | mViewerCallerIsSearchDialog = false; | 5118 | mViewerCallerIsSearchDialog = false; |
5106 | } | 5119 | } |
5107 | if ( !mViewerCallerIsSearchDialog ) { | 5120 | if ( !mViewerCallerIsSearchDialog ) { |
5108 | //mViewManager->currentView()->setFocus(); | 5121 | //mViewManager->currentView()->setFocus(); |
5109 | //qDebug("sssssssssssssssset focus "); | 5122 | //qDebug("sssssssssssssssset focus "); |
5110 | topLevelWidget()->raise(); | 5123 | topLevelWidget()->raise(); |
5111 | setActiveWindow(); | 5124 | setActiveWindow(); |
5112 | //setFocus(); | 5125 | //setFocus(); |
5113 | } | 5126 | } |
5114 | mViewerCallerIsSearchDialog = false; | 5127 | mViewerCallerIsSearchDialog = false; |
5115 | } | 5128 | } |
5116 | 5129 | ||
5117 | void CalendarView::showNextAlarms() | 5130 | void CalendarView::showNextAlarms() |
5118 | { | 5131 | { |
5119 | QString message; | 5132 | QString message; |
5120 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 5133 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
5121 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 5134 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
5122 | QString sum = mCalendar->nextSummary(); | 5135 | QString sum = mCalendar->nextSummary(); |
5123 | QDateTime nextA = mNextAlarmDateTime; | 5136 | QDateTime nextA = mNextAlarmDateTime; |
5124 | QDateTime cur = QDateTime::currentDateTime(); | 5137 | QDateTime cur = QDateTime::currentDateTime(); |
5125 | int secs = cur.secsTo( nextA ); | 5138 | int secs = cur.secsTo( nextA ); |
5126 | int min = secs /60; | 5139 | int min = secs /60; |
5127 | int hours = min /60; | 5140 | int hours = min /60; |
5128 | min = min % 60; | 5141 | min = min % 60; |
5129 | int days = hours /24; | 5142 | int days = hours /24; |
5130 | hours = hours % 24; | 5143 | hours = hours % 24; |
5131 | 5144 | ||
5132 | //message = i18n("The next alarm is in:\n"); | 5145 | //message = i18n("The next alarm is in:\n"); |
5133 | if ( days > 1 ) | 5146 | if ( days > 1 ) |
5134 | message += i18n("%1 days\n").arg( days ); | 5147 | message += i18n("%1 days\n").arg( days ); |
5135 | else if ( days == 1 ) | 5148 | else if ( days == 1 ) |
5136 | message += i18n("1 day\n"); | 5149 | message += i18n("1 day\n"); |
5137 | if ( hours > 1 ) | 5150 | if ( hours > 1 ) |
5138 | message += i18n("%1 hours\n").arg( hours ); | 5151 | message += i18n("%1 hours\n").arg( hours ); |
5139 | else if ( hours == 1 ) | 5152 | else if ( hours == 1 ) |
5140 | message += i18n("1 hour\n"); | 5153 | message += i18n("1 hour\n"); |
5141 | if ( min > 1 ) | 5154 | if ( min > 1 ) |
5142 | message += i18n("%1 minutes\n").arg( min ); | 5155 | message += i18n("%1 minutes\n").arg( min ); |
5143 | else if ( min == 1 ) | 5156 | else if ( min == 1 ) |
5144 | message += i18n("1 minute\n"); | 5157 | message += i18n("1 minute\n"); |
5145 | if ( message.isEmpty() ) | 5158 | if ( message.isEmpty() ) |
5146 | message = i18n("The next alarm is in\nless than one minute!"); | 5159 | message = i18n("The next alarm is in\nless than one minute!"); |
5147 | else | 5160 | else |
5148 | message = i18n("The next alarm is in:\n") + message; | 5161 | message = i18n("The next alarm is in:\n") + message; |
5149 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 5162 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
5150 | } else { | 5163 | } else { |
5151 | message = i18n("There is no next alarm."); | 5164 | message = i18n("There is no next alarm."); |
5152 | 5165 | ||
5153 | } | 5166 | } |
5154 | #ifdef DESKTOP_VERSION | 5167 | #ifdef DESKTOP_VERSION |
5155 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 5168 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
5156 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 5169 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
5157 | message += i18n("Enable it in the settings menu, TAB alarm."); | 5170 | message += i18n("Enable it in the settings menu, TAB alarm."); |
5158 | } | 5171 | } |
5159 | 5172 | ||
5160 | #endif | 5173 | #endif |
5161 | KMessageBox::information( this, message); | 5174 | KMessageBox::information( this, message); |
5162 | } | 5175 | } |
5163 | 5176 | ||
5164 | void CalendarView::displayCalendarInfo( int id ) | 5177 | void CalendarView::displayCalendarInfo( int id ) |
5165 | { | 5178 | { |
5166 | int e, t,j; | 5179 | int e, t,j; |
5167 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 5180 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
5168 | QString name = kkf->mName; | 5181 | QString name = kkf->mName; |
5169 | mCalendar->getIncidenceCount( id, e, t, j ); | 5182 | mCalendar->getIncidenceCount( id, e, t, j ); |
5170 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); | 5183 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); |
5171 | QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); | 5184 | QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); |
5172 | mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); | 5185 | mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); |
5173 | KMessageBox::information( this, mess ); | 5186 | KMessageBox::information( this, mess ); |
5174 | 5187 | ||
5175 | 5188 | ||
5176 | } | 5189 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 80f7ed4..f85b6a3 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,675 +1,675 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #include <qscrollbar.h> | 33 | #include <qscrollbar.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qtopia/ir.h> | 35 | #include <qtopia/ir.h> |
36 | #else | 36 | #else |
37 | #define Ir char | 37 | #define Ir char |
38 | #endif | 38 | #endif |
39 | #include <libkcal/calendar.h> | 39 | #include <libkcal/calendar.h> |
40 | #include <libkcal/scheduler.h> | 40 | #include <libkcal/scheduler.h> |
41 | #include <libkcal/calendarresources.h> | 41 | #include <libkcal/calendarresources.h> |
42 | #include <libkcal/resourcecalendar.h> | 42 | #include <libkcal/resourcecalendar.h> |
43 | #include <KDGanttMinimizeSplitter.h> | 43 | #include <KDGanttMinimizeSplitter.h> |
44 | 44 | ||
45 | #include <korganizer/calendarviewbase.h> | 45 | #include <korganizer/calendarviewbase.h> |
46 | 46 | ||
47 | #include <ksyncmanager.h> | 47 | #include <ksyncmanager.h> |
48 | //#include <koprefs.h> | 48 | //#include <koprefs.h> |
49 | 49 | ||
50 | class QWidgetStack; | 50 | class QWidgetStack; |
51 | class QSplitter; | 51 | class QSplitter; |
52 | class KopiCalendarFile; | 52 | class KopiCalendarFile; |
53 | class CalPrinter; | 53 | class CalPrinter; |
54 | class KOFilterView; | 54 | class KOFilterView; |
55 | class KOCalEditView; | 55 | class KOCalEditView; |
56 | class KOViewManager; | 56 | class KOViewManager; |
57 | class KODialogManager; | 57 | class KODialogManager; |
58 | class KOTodoView; | 58 | class KOTodoView; |
59 | class KDateNavigator; | 59 | class KDateNavigator; |
60 | class DateNavigatorContainer; | 60 | class DateNavigatorContainer; |
61 | class DateNavigator; | 61 | class DateNavigator; |
62 | class KOIncidenceEditor; | 62 | class KOIncidenceEditor; |
63 | class KDatePicker; | 63 | class KDatePicker; |
64 | class ResourceView; | 64 | class ResourceView; |
65 | class KOEventEditor; | 65 | class KOEventEditor; |
66 | class KOTodoEditor ; | 66 | class KOTodoEditor ; |
67 | class KOEventViewerDialog; | 67 | class KOEventViewerDialog; |
68 | class KOBeamPrefs; | 68 | class KOBeamPrefs; |
69 | class KSyncProfile; | 69 | class KSyncProfile; |
70 | class AlarmDialog; | 70 | class AlarmDialog; |
71 | class KCal::Attendee; | 71 | class KCal::Attendee; |
72 | 72 | ||
73 | namespace KCal { class FileStorage; } | 73 | namespace KCal { class FileStorage; } |
74 | 74 | ||
75 | using namespace KCal; | 75 | using namespace KCal; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | This is the main calendar widget. It provides the different vies on t he | 78 | This is the main calendar widget. It provides the different vies on t he |
79 | calendar data as well as the date navigator. It also handles synchronisation | 79 | calendar data as well as the date navigator. It also handles synchronisation |
80 | of the different views and controls the different dialogs like preferences, | 80 | of the different views and controls the different dialogs like preferences, |
81 | event editor, search dialog etc. | 81 | event editor, search dialog etc. |
82 | 82 | ||
83 | @short main calendar view widget | 83 | @short main calendar view widget |
84 | @author Cornelius Schumacher | 84 | @author Cornelius Schumacher |
85 | */ | 85 | */ |
86 | 86 | ||
87 | #include <qtextbrowser.h> | 87 | #include <qtextbrowser.h> |
88 | #include <qtextcodec.h> | 88 | #include <qtextcodec.h> |
89 | 89 | ||
90 | class MissedAlarmTextBrowser : public QTextBrowser { | 90 | class MissedAlarmTextBrowser : public QTextBrowser { |
91 | Q_OBJECT | 91 | Q_OBJECT |
92 | public: | 92 | public: |
93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); | 93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); |
94 | ~MissedAlarmTextBrowser(); | 94 | ~MissedAlarmTextBrowser(); |
95 | void setSource(const QString & n); | 95 | void setSource(const QString & n); |
96 | 96 | ||
97 | private: | 97 | private: |
98 | Incidence * getNextInc(QDateTime start ); | 98 | Incidence * getNextInc(QDateTime start ); |
99 | QPtrList<Incidence> mAlarms; | 99 | QPtrList<Incidence> mAlarms; |
100 | signals: | 100 | signals: |
101 | void showIncidence( QString uid); | 101 | void showIncidence( QString uid); |
102 | }; | 102 | }; |
103 | 103 | ||
104 | 104 | ||
105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
106 | { | 106 | { |
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | public: | 108 | public: |
109 | /** | 109 | /** |
110 | Constructs a new calendar view widget. | 110 | Constructs a new calendar view widget. |
111 | 111 | ||
112 | @param calendar calendar document | 112 | @param calendar calendar document |
113 | @param parent parent window | 113 | @param parent parent window |
114 | @param name Qt internal widget object name | 114 | @param name Qt internal widget object name |
115 | */ | 115 | */ |
116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
117 | const char *name = 0 ); | 117 | const char *name = 0 ); |
118 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 118 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
119 | const char *name = 0 ); | 119 | const char *name = 0 ); |
120 | virtual ~CalendarView(); | 120 | virtual ~CalendarView(); |
121 | 121 | ||
122 | Calendar *calendar() { return mCalendar; } | 122 | Calendar *calendar() { return mCalendar; } |
123 | 123 | ||
124 | KOViewManager *viewManager(); | 124 | KOViewManager *viewManager(); |
125 | KODialogManager *dialogManager(); | 125 | KODialogManager *dialogManager(); |
126 | 126 | ||
127 | QDate startDate(); | 127 | QDate startDate(); |
128 | QDate endDate(); | 128 | QDate endDate(); |
129 | 129 | ||
130 | QWidgetStack *viewStack(); | 130 | QWidgetStack *viewStack(); |
131 | QWidget *leftFrame(); | 131 | QWidget *leftFrame(); |
132 | 132 | ||
133 | DateNavigator *dateNavigator(); | 133 | DateNavigator *dateNavigator(); |
134 | KDateNavigator *dateNavigatorWidget(); | 134 | KDateNavigator *dateNavigatorWidget(); |
135 | 135 | ||
136 | void addView(KOrg::BaseView *); | 136 | void addView(KOrg::BaseView *); |
137 | void showView(KOrg::BaseView *); | 137 | void showView(KOrg::BaseView *); |
138 | KOEventViewerDialog* getEventViewerDialog(); | 138 | KOEventViewerDialog* getEventViewerDialog(); |
139 | Incidence *currentSelection(); | 139 | Incidence *currentSelection(); |
140 | void checkSuspendAlarm(); | 140 | void checkSuspendAlarm(); |
141 | void mergeFile( QString fn ); | 141 | void mergeFile( QString fn ); |
142 | 142 | ||
143 | signals: | 143 | signals: |
144 | void save (); | 144 | void save (); |
145 | void saveStopTimer (); | 145 | void saveStopTimer (); |
146 | void tempDisableBR(bool); | 146 | void tempDisableBR(bool); |
147 | /** This todo has been modified */ | 147 | /** This todo has been modified */ |
148 | void todoModified(Todo *, int); | 148 | void todoModified(Todo *, int); |
149 | 149 | ||
150 | /** when change is made to options dialog, the topwidget will catch this | 150 | /** when change is made to options dialog, the topwidget will catch this |
151 | * and emit this signal which notifies all widgets which have registered | 151 | * and emit this signal which notifies all widgets which have registered |
152 | * for notification to update their settings. */ | 152 | * for notification to update their settings. */ |
153 | void configChanged(); | 153 | void configChanged(); |
154 | /** emitted when the topwidget is closing down, so that any attached | 154 | /** emitted when the topwidget is closing down, so that any attached |
155 | child windows can also close. */ | 155 | child windows can also close. */ |
156 | void closingDown(); | 156 | void closingDown(); |
157 | /** emitted right before we die */ | 157 | /** emitted right before we die */ |
158 | void closed(QWidget *); | 158 | void closed(QWidget *); |
159 | 159 | ||
160 | /** Emitted when state of modified flag changes */ | 160 | /** Emitted when state of modified flag changes */ |
161 | void modifiedChanged(bool); | 161 | void modifiedChanged(bool); |
162 | void signalmodified(); | 162 | void signalmodified(); |
163 | 163 | ||
164 | /** Emitted when state of read-only flag changes */ | 164 | /** Emitted when state of read-only flag changes */ |
165 | void readOnlyChanged(bool); | 165 | void readOnlyChanged(bool); |
166 | 166 | ||
167 | /** Emitted when the unit of navigation changes */ | 167 | /** Emitted when the unit of navigation changes */ |
168 | void changeNavStringPrev(const QString &); | 168 | void changeNavStringPrev(const QString &); |
169 | void changeNavStringNext(const QString &); | 169 | void changeNavStringNext(const QString &); |
170 | 170 | ||
171 | /** Emitted when state of events selection has changed and user is organizer*/ | 171 | /** Emitted when state of events selection has changed and user is organizer*/ |
172 | void organizerEventsSelected(bool); | 172 | void organizerEventsSelected(bool); |
173 | /** Emitted when state of events selection has changed and user is attendee*/ | 173 | /** Emitted when state of events selection has changed and user is attendee*/ |
174 | void groupEventsSelected(bool); | 174 | void groupEventsSelected(bool); |
175 | /** | 175 | /** |
176 | Emitted when an incidence gets selected. If the selection is cleared the | 176 | Emitted when an incidence gets selected. If the selection is cleared the |
177 | signal is emitted with 0 as argument. | 177 | signal is emitted with 0 as argument. |
178 | */ | 178 | */ |
179 | void incidenceSelected( Incidence * ); | 179 | void incidenceSelected( Incidence * ); |
180 | /** Emitted, when a todoitem is selected or deselected. */ | 180 | /** Emitted, when a todoitem is selected or deselected. */ |
181 | void todoSelected( bool ); | 181 | void todoSelected( bool ); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | Emitted, when clipboard content changes. Parameter indicates if paste | 184 | Emitted, when clipboard content changes. Parameter indicates if paste |
185 | is possible or not. | 185 | is possible or not. |
186 | */ | 186 | */ |
187 | void pasteEnabled(bool); | 187 | void pasteEnabled(bool); |
188 | 188 | ||
189 | /** Emitted, when the number of incoming messages has changed. */ | 189 | /** Emitted, when the number of incoming messages has changed. */ |
190 | void numIncomingChanged(int); | 190 | void numIncomingChanged(int); |
191 | 191 | ||
192 | /** Emitted, when the number of outgoing messages has changed. */ | 192 | /** Emitted, when the number of outgoing messages has changed. */ |
193 | void numOutgoingChanged(int); | 193 | void numOutgoingChanged(int); |
194 | 194 | ||
195 | /** Send status message, which can e.g. be displayed in the status bar. */ | 195 | /** Send status message, which can e.g. be displayed in the status bar. */ |
196 | void statusMessage(const QString &); | 196 | void statusMessage(const QString &); |
197 | 197 | ||
198 | void calendarViewExpanded( bool ); | 198 | void calendarViewExpanded( bool ); |
199 | void updateSearchDialog(); | 199 | void updateSearchDialog(); |
200 | void filtersUpdated(); | 200 | void filtersUpdated(); |
201 | 201 | ||
202 | 202 | ||
203 | public slots: | 203 | public slots: |
204 | void displayCalendarInfo( int id ); | 204 | void displayCalendarInfo( int id ); |
205 | void nextConflict( bool all, bool allday ); | 205 | void nextConflict( bool all, bool allday ); |
206 | void conflictAll(); | 206 | void conflictAll(); |
207 | void conflictAllday(); | 207 | void conflictAllday(); |
208 | void conflictNotAll(); | 208 | void conflictNotAll(); |
209 | void setCalReadOnly( int id, bool readO ); | 209 | void setCalReadOnly( int id, bool readO ); |
210 | void checkAlarms(); | 210 | void checkAlarms(); |
211 | void checkFiles(); | 211 | void checkFiles(); |
212 | void slotprintSelInc(); | 212 | void slotprintSelInc(); |
213 | void showNextAlarms(); | 213 | void showNextAlarms(); |
214 | void showOpenError(); | 214 | void showOpenError(); |
215 | void watchSavedFile(); | 215 | void watchSavedFile(); |
216 | void recheckTimerAlarm(); | 216 | void recheckTimerAlarm(); |
217 | void checkNextTimerAlarm(); | 217 | void checkNextTimerAlarm(); |
218 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 218 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
219 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 219 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
220 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 220 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
221 | 221 | ||
222 | /** options dialog made a changed to the configuration. we catch this | 222 | /** options dialog made a changed to the configuration. we catch this |
223 | * and notify all widgets which need to update their configuration. */ | 223 | * and notify all widgets which need to update their configuration. */ |
224 | void updateConfig(); | 224 | void updateConfig(); |
225 | 225 | ||
226 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 226 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
227 | const QStringList& anniversaryList, const QStringList& realNameList, | 227 | const QStringList& anniversaryList, const QStringList& realNameList, |
228 | const QStringList& emailList, const QStringList& assembledNameList, | 228 | const QStringList& emailList, const QStringList& assembledNameList, |
229 | const QStringList& uidList); | 229 | const QStringList& uidList); |
230 | 230 | ||
231 | /** | 231 | /** |
232 | Load calendar from file \a filename. If \a merge is true, load | 232 | Load calendar from file \a filename. If \a merge is true, load |
233 | calendar into existing one, if it is false, clear calendar, before | 233 | calendar into existing one, if it is false, clear calendar, before |
234 | loading. Return true, if calendar could be successfully loaded. | 234 | loading. Return true, if calendar could be successfully loaded. |
235 | */ | 235 | */ |
236 | bool openCalendar(QString filename, bool merge=false); | 236 | bool openCalendar(QString filename, bool merge=false); |
237 | bool loadCalendars(); | 237 | bool loadCalendars(); |
238 | bool saveCalendars(); | 238 | bool saveCalendars(); |
239 | bool restoreCalendarSettings(); | 239 | bool restoreCalendarSettings(); |
240 | bool addCalendar( KopiCalendarFile * ); | 240 | bool addCalendar( KopiCalendarFile * ); |
241 | void addCalendarId( int id ); | 241 | void addCalendarId( int id ); |
242 | bool syncCalendar(QString filename,int mode = 0 ); | 242 | bool syncCalendar(QString filename,int mode = 0 ); |
243 | 243 | ||
244 | /** | 244 | /** |
245 | Save calendar data to file. Return true if calendar could be | 245 | Save calendar data to file. Return true if calendar could be |
246 | successfully saved. | 246 | successfully saved. |
247 | */ | 247 | */ |
248 | bool saveCalendar(QString filename); | 248 | bool saveCalendar(QString filename); |
249 | 249 | ||
250 | /** | 250 | /** |
251 | Close calendar. Clear calendar data and reset views to display an empty | 251 | Close calendar. Clear calendar data and reset views to display an empty |
252 | calendar. | 252 | calendar. |
253 | */ | 253 | */ |
254 | void closeCalendar(); | 254 | void closeCalendar(); |
255 | 255 | ||
256 | /** Archive old events of calendar */ | 256 | /** Archive old events of calendar */ |
257 | void archiveCalendar(); | 257 | void archiveCalendar(); |
258 | 258 | ||
259 | void showIncidence(); | 259 | void showIncidence(); |
260 | void editIncidence(); | 260 | void editIncidence(); |
261 | void editIncidenceDescription(); | 261 | void editIncidenceDescription(); |
262 | void deleteIncidence(); | 262 | void deleteIncidence(); |
263 | void cloneIncidence(); | 263 | void cloneIncidence(); |
264 | void moveIncidence(); | 264 | void moveIncidence(); |
265 | void beamIncidence(); | 265 | void beamIncidence(); |
266 | void toggleCancelIncidence(); | 266 | void toggleCancelIncidence(); |
267 | 267 | ||
268 | /** create an editeventwin with supplied date/time, and if bool is true, | 268 | /** create an editeventwin with supplied date/time, and if bool is true, |
269 | * make the event take all day. */ | 269 | * make the event take all day. */ |
270 | void newEvent(QDateTime, QDateTime, bool allDay ); | 270 | void newEvent(QDateTime, QDateTime, bool allDay ); |
271 | void newEvent(QDateTime, QDateTime); | 271 | void newEvent(QDateTime, QDateTime); |
272 | void newEvent(QDateTime fh); | 272 | void newEvent(QDateTime fh); |
273 | void newEvent(QDate dt); | 273 | void newEvent(QDate dt); |
274 | /** create new event without having a date hint. Takes current date as | 274 | /** create new event without having a date hint. Takes current date as |
275 | default hint. */ | 275 | default hint. */ |
276 | void newEvent(); | 276 | void newEvent(); |
277 | void newFloatingEvent(); | 277 | void newFloatingEvent(); |
278 | 278 | ||
279 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 279 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
280 | void showIncidence(Incidence *); | 280 | void showIncidence(Incidence *); |
281 | void showIncidence(QString uid); | 281 | void showIncidence(QString uid); |
282 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 282 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
283 | void editIncidence(Incidence *); | 283 | void editIncidence(Incidence *); |
284 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 284 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
285 | void deleteIncidence(Incidence *); | 285 | void deleteIncidence(Incidence *); |
286 | void cloneIncidence(Incidence *); | 286 | void cloneIncidence(Incidence *); |
287 | void cancelIncidence(Incidence *); | 287 | void cancelIncidence(Incidence *); |
288 | /** Create an editor for the supplied event. */ | 288 | /** Create an editor for the supplied event. */ |
289 | void editEvent(Event *); | 289 | void editEvent(Event *); |
290 | /** Delete the supplied event. */ | 290 | /** Delete the supplied event. */ |
291 | void deleteEvent(Event *); | 291 | void deleteEvent(Event *); |
292 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 292 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
293 | found. */ | 293 | found. */ |
294 | bool deleteEvent(const QString &uid); | 294 | bool deleteEvent(const QString &uid); |
295 | /** Create a read-only viewer dialog for the supplied event. */ | 295 | /** Create a read-only viewer dialog for the supplied event. */ |
296 | void showEvent(Event *); | 296 | void showEvent(Event *); |
297 | 297 | ||
298 | void editJournal(Journal *); | 298 | void editJournal(Journal *); |
299 | void showJournal(Journal *); | 299 | void showJournal(Journal *); |
300 | void deleteJournal(Journal *); | 300 | void deleteJournal(Journal *); |
301 | /** Create an editor dialog for a todo */ | 301 | /** Create an editor dialog for a todo */ |
302 | void editTodo(Todo *); | 302 | void editTodo(Todo *); |
303 | /** Create a read-only viewer dialog for the supplied todo */ | 303 | /** Create a read-only viewer dialog for the supplied todo */ |
304 | void showTodo(Todo *); | 304 | void showTodo(Todo *); |
305 | /** create new todo */ | 305 | /** create new todo */ |
306 | void newTodo(); | 306 | void newTodo(); |
307 | void newTodoDateTime(QDateTime, bool allday); | 307 | void newTodoDateTime(QDateTime, bool allday); |
308 | /** create new todo with a parent todo */ | 308 | /** create new todo with a parent todo */ |
309 | void newSubTodo(); | 309 | void newSubTodo(); |
310 | /** create new todo with a parent todo */ | 310 | /** create new todo with a parent todo */ |
311 | void newSubTodo(Todo *); | 311 | void newSubTodo(Todo *); |
312 | /** Delete todo */ | 312 | /** Delete todo */ |
313 | void deleteTodo(Todo *); | 313 | void deleteTodo(Todo *); |
314 | 314 | ||
315 | 315 | ||
316 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 316 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
317 | * emitted as result. */ | 317 | * emitted as result. */ |
318 | void checkClipboard(); | 318 | void checkClipboard(); |
319 | 319 | ||
320 | /** using the KConfig associated with the kapp variable, read in the | 320 | /** using the KConfig associated with the kapp variable, read in the |
321 | * settings from the config file. | 321 | * settings from the config file. |
322 | */ | 322 | */ |
323 | void readSettings(); | 323 | void readSettings(); |
324 | 324 | ||
325 | /** write current state to config file. */ | 325 | /** write current state to config file. */ |
326 | void writeSettings(); | 326 | void writeSettings(); |
327 | 327 | ||
328 | /** read settings for calendar filters */ | 328 | /** read settings for calendar filters */ |
329 | void readFilterSettings(KConfig *config); | 329 | void readFilterSettings(KConfig *config); |
330 | 330 | ||
331 | /** write settings for calendar filters */ | 331 | /** write settings for calendar filters */ |
332 | void writeFilterSettings(KConfig *config); | 332 | void writeFilterSettings(KConfig *config); |
333 | 333 | ||
334 | /** passes on the message that an event has changed to the currently | 334 | /** passes on the message that an event has changed to the currently |
335 | * activated view so that it can make appropriate display changes. */ | 335 | * activated view so that it can make appropriate display changes. */ |
336 | void changeEventDisplay(Event *, int); | 336 | void changeEventDisplay(Event *, int); |
337 | void changeIncidenceDisplay(Incidence *, int); | 337 | void changeIncidenceDisplay(Incidence *, int); |
338 | void changeTodoDisplay(Todo *, int); | 338 | void changeTodoDisplay(Todo *, int); |
339 | 339 | ||
340 | void eventAdded(Event *); | 340 | void eventAdded(Event *); |
341 | void eventChanged(Event *); | 341 | void eventChanged(Event *); |
342 | void eventToBeDeleted(Event *); | 342 | void eventToBeDeleted(Event *); |
343 | void eventDeleted(); | 343 | void eventDeleted(); |
344 | 344 | ||
345 | void todoAdded(Todo *); | 345 | void todoAdded(Todo *); |
346 | void todoChanged(Todo *); | 346 | void todoChanged(Todo *); |
347 | void todoToBeDeleted(Todo *); | 347 | void todoToBeDeleted(Todo *); |
348 | void todoDeleted(); | 348 | void todoDeleted(); |
349 | 349 | ||
350 | void updateView(const QDate &start, const QDate &end); | 350 | void updateView(const QDate &start, const QDate &end); |
351 | void updateView(); | 351 | void updateView(); |
352 | void clearAllViews(); | 352 | void clearAllViews(); |
353 | 353 | ||
354 | /** Full update of visible todo views */ | 354 | /** Full update of visible todo views */ |
355 | void updateTodoViews(); | 355 | void updateTodoViews(); |
356 | 356 | ||
357 | void updateUnmanagedViews(); | 357 | void updateUnmanagedViews(); |
358 | 358 | ||
359 | /** cut the current appointment to the clipboard */ | 359 | /** cut the current appointment to the clipboard */ |
360 | void edit_cut(); | 360 | void edit_cut(); |
361 | 361 | ||
362 | /** copy the current appointment(s) to the clipboard */ | 362 | /** copy the current appointment(s) to the clipboard */ |
363 | void edit_copy(); | 363 | void edit_copy(); |
364 | 364 | ||
365 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 365 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
366 | void edit_paste(); | 366 | void edit_paste(); |
367 | 367 | ||
368 | /** edit viewing and configuration options. */ | 368 | /** edit viewing and configuration options. */ |
369 | void edit_options(); | 369 | void edit_options(); |
370 | void edit_global_options(); | 370 | void edit_global_options(); |
371 | /** | 371 | /** |
372 | Functions for printing, previewing a print, and setting up printing | 372 | Functions for printing, previewing a print, and setting up printing |
373 | parameters. | 373 | parameters. |
374 | */ | 374 | */ |
375 | void print(); | 375 | void print(); |
376 | void printSetup(); | 376 | void printSetup(); |
377 | void printPreview(); | 377 | void printPreview(); |
378 | 378 | ||
379 | /** Export as iCalendar file */ | 379 | /** Export as iCalendar file */ |
380 | bool exportICalendar(); | 380 | bool exportICalendar(); |
381 | bool exportICalendar( QString fn ); | 381 | bool exportICalendar( QString fn ); |
382 | 382 | ||
383 | /** Export as vCalendar file */ | 383 | /** Export as vCalendar file */ |
384 | bool exportVCalendar( QString fn); | 384 | bool exportVCalendar( QString fn); |
385 | 385 | ||
386 | /** pop up a dialog to show an existing appointment. */ | 386 | /** pop up a dialog to show an existing appointment. */ |
387 | void appointment_show(); | 387 | void appointment_show(); |
388 | /** | 388 | /** |
389 | * pop up an Appointment Dialog to edit an existing appointment.Get | 389 | * pop up an Appointment Dialog to edit an existing appointment.Get |
390 | * information on the appointment from the list of unique IDs that is | 390 | * information on the appointment from the list of unique IDs that is |
391 | * currently in the View, called currIds. | 391 | * currently in the View, called currIds. |
392 | */ | 392 | */ |
393 | void appointment_edit(); | 393 | void appointment_edit(); |
394 | /** | 394 | /** |
395 | * pop up dialog confirming deletion of currently selected event in the | 395 | * pop up dialog confirming deletion of currently selected event in the |
396 | * View. | 396 | * View. |
397 | */ | 397 | */ |
398 | void appointment_delete(); | 398 | void appointment_delete(); |
399 | 399 | ||
400 | /** mails the currently selected event to a particular user as a vCalendar | 400 | /** mails the currently selected event to a particular user as a vCalendar |
401 | attachment. */ | 401 | attachment. */ |
402 | void action_mail(); | 402 | void action_mail(); |
403 | 403 | ||
404 | /* frees a subtodo from it's relation */ | 404 | /* frees a subtodo from it's relation */ |
405 | void todo_unsub( Todo * ); | 405 | void todo_unsub( Todo * ); |
406 | void todo_resub( Todo * parent, Todo * sub ); | 406 | void todo_resub( Todo * parent, Todo * sub ); |
407 | 407 | ||
408 | /** Take ownership of selected event. */ | 408 | /** Take ownership of selected event. */ |
409 | void takeOverEvent(); | 409 | void takeOverEvent(); |
410 | 410 | ||
411 | /** Take ownership of all events in calendar. */ | 411 | /** Take ownership of all events in calendar. */ |
412 | void takeOverCalendar(); | 412 | void takeOverCalendar(); |
413 | 413 | ||
414 | /** query whether or not the calendar is "dirty". */ | 414 | /** query whether or not the calendar is "dirty". */ |
415 | bool isModified(); | 415 | bool isModified(); |
416 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 416 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
417 | void setModified(bool modified=true); | 417 | void setModified(bool modified=true); |
418 | 418 | ||
419 | /** query if the calendar is read-only. */ | 419 | /** query if the calendar is read-only. */ |
420 | bool isReadOnly(); | 420 | bool isReadOnly(); |
421 | /** set state of calendar to read-only */ | 421 | /** set state of calendar to read-only */ |
422 | void setReadOnly(bool readOnly=true); | 422 | void setReadOnly(bool readOnly=true); |
423 | 423 | ||
424 | void eventUpdated(Incidence *); | 424 | void eventUpdated(Incidence *); |
425 | 425 | ||
426 | /* iTIP scheduling actions */ | 426 | /* iTIP scheduling actions */ |
427 | void schedule_publish(Incidence *incidence = 0); | 427 | void schedule_publish(Incidence *incidence = 0); |
428 | void schedule_request(Incidence *incidence = 0); | 428 | void schedule_request(Incidence *incidence = 0); |
429 | void schedule_refresh(Incidence *incidence = 0); | 429 | void schedule_refresh(Incidence *incidence = 0); |
430 | void schedule_cancel(Incidence *incidence = 0); | 430 | void schedule_cancel(Incidence *incidence = 0); |
431 | void schedule_add(Incidence *incidence = 0); | 431 | void schedule_add(Incidence *incidence = 0); |
432 | void schedule_reply(Incidence *incidence = 0); | 432 | void schedule_reply(Incidence *incidence = 0); |
433 | void schedule_counter(Incidence *incidence = 0); | 433 | void schedule_counter(Incidence *incidence = 0); |
434 | void schedule_declinecounter(Incidence *incidence = 0); | 434 | void schedule_declinecounter(Incidence *incidence = 0); |
435 | void schedule_publish_freebusy(int daysToPublish = 30); | 435 | void schedule_publish_freebusy(int daysToPublish = 30); |
436 | 436 | ||
437 | void openAddressbook(); | 437 | void openAddressbook(); |
438 | 438 | ||
439 | void editFilters(); | 439 | void editFilters(); |
440 | void toggleFilerEnabled(); | 440 | void toggleFilerEnabled(); |
441 | QPtrList<CalFilter> filters(); | 441 | QPtrList<CalFilter> filters(); |
442 | void toggleFilter(); | 442 | void toggleFilter(); |
443 | void showFilter(bool visible); | 443 | void showFilter(bool visible); |
444 | void updateFilter(); | 444 | void updateFilter(); |
445 | void filterEdited(); | 445 | void filterEdited(); |
446 | void selectFilter( int ); | 446 | void selectFilter( int ); |
447 | KOFilterView *filterView(); | 447 | KOFilterView *filterView(); |
448 | 448 | ||
449 | void showIntro(); | 449 | void showIntro(); |
450 | 450 | ||
451 | /** Move the curdatepient view date to today */ | 451 | /** Move the curdatepient view date to today */ |
452 | void goToday(); | 452 | void goToday(); |
453 | 453 | ||
454 | /** Move to the next date(s) in the current view */ | 454 | /** Move to the next date(s) in the current view */ |
455 | void goNext(); | 455 | void goNext(); |
456 | 456 | ||
457 | /** Move to the previous date(s) in the current view */ | 457 | /** Move to the previous date(s) in the current view */ |
458 | void goPrevious(); | 458 | void goPrevious(); |
459 | /** Move to the next date(s) in the current view */ | 459 | /** Move to the next date(s) in the current view */ |
460 | void goNextMonth(); | 460 | void goNextMonth(); |
461 | 461 | ||
462 | /** Move to the previous date(s) in the current view */ | 462 | /** Move to the previous date(s) in the current view */ |
463 | void goPreviousMonth(); | 463 | void goPreviousMonth(); |
464 | 464 | ||
465 | void toggleExpand(); | 465 | void toggleExpand(); |
466 | void toggleDateNavigatorWidget(); | 466 | void toggleDateNavigatorWidget(); |
467 | void toggleAllDaySize(); | 467 | void toggleAllDaySize(); |
468 | 468 | ||
469 | /** Look for new messages in the inbox */ | 469 | /** Look for new messages in the inbox */ |
470 | void lookForIncomingMessages(); | 470 | void lookForIncomingMessages(); |
471 | /** Look for new messages in the outbox */ | 471 | /** Look for new messages in the outbox */ |
472 | void lookForOutgoingMessages(); | 472 | void lookForOutgoingMessages(); |
473 | 473 | ||
474 | void processMainViewSelection( Incidence * ); | 474 | void processMainViewSelection( Incidence * ); |
475 | void processTodoListSelection( Incidence * ); | 475 | void processTodoListSelection( Incidence * ); |
476 | 476 | ||
477 | void processIncidenceSelection( Incidence * ); | 477 | void processIncidenceSelection( Incidence * ); |
478 | 478 | ||
479 | void purgeCompleted(); | 479 | void purgeCompleted(); |
480 | bool removeCompletedSubTodos( Todo* ); | 480 | bool removeCompletedSubTodos( Todo* ); |
481 | void slotCalendarChanged(); | 481 | void slotCalendarChanged(); |
482 | bool importBday(); | 482 | bool importBday(); |
483 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 483 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
484 | bool importQtopia( const QString &categoriesFile, | 484 | bool importQtopia( const QString &categoriesFile, |
485 | const QString &datebookFile, | 485 | const QString &datebookFile, |
486 | const QString &tasklistFile ); | 486 | const QString &tasklistFile ); |
487 | void syncExternal( int mode ); | 487 | void syncExternal( int mode ); |
488 | void slotSelectPickerDate( QDate ) ; | 488 | void slotSelectPickerDate( QDate ) ; |
489 | void showDatePicker() ; | 489 | void showDatePicker() ; |
490 | void showDatePickerPopup() ; | 490 | void showDatePickerPopup() ; |
491 | void moveIncidence(Incidence *) ; | 491 | void moveIncidence(Incidence *) ; |
492 | void beamIncidence(Incidence *) ; | 492 | void beamIncidence(Incidence *) ; |
493 | void beamCalendar() ; | 493 | void beamCalendar() ; |
494 | void beamFilteredCalendar() ; | 494 | void beamFilteredCalendar() ; |
495 | void beamIncidenceList(QPtrList<Incidence>) ; | 495 | void beamIncidenceList(QPtrList<Incidence>) ; |
496 | void manageCategories(); | 496 | void manageCategories(); |
497 | void editCategories(); | 497 | void editCategories(); |
498 | int addCategories(); | 498 | int addCategories(); |
499 | void removeCategories(); | 499 | void removeCategories(); |
500 | void setSyncDevice( QString ); | 500 | void setSyncDevice( QString ); |
501 | void setSyncName( QString ); | 501 | void setSyncName( QString ); |
502 | void showDay( QDate ); | 502 | void showDay( QDate ); |
503 | void undo_delete(); | 503 | void undo_delete(); |
504 | protected slots: | 504 | protected slots: |
505 | void resetFocus(); | 505 | void resetFocus(); |
506 | void scrollBarValue(int); | 506 | void scrollBarValue(int); |
507 | void slotViewerClosed(); | 507 | void slotViewerClosed(); |
508 | void timerAlarm(); | 508 | void timerAlarm(); |
509 | void suspendAlarm(); | 509 | void suspendAlarm(); |
510 | void beamDone( Ir *ir ); | 510 | void beamDone( Ir *ir ); |
511 | /** Select a view or adapt the current view to display the specified dates. */ | 511 | /** Select a view or adapt the current view to display the specified dates. */ |
512 | void showDates( const KCal::DateList & ); | 512 | void showDates( const KCal::DateList & ); |
513 | void selectWeekNum ( int ); | 513 | void selectWeekNum ( int ); |
514 | void checkConflictForEvent(); | 514 | void checkConflictForEvent(); |
515 | 515 | ||
516 | public: | 516 | public: |
517 | void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); | 517 | void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); |
518 | // show a standard warning | 518 | // show a standard warning |
519 | // returns KMsgBox::yesNoCancel() | 519 | // returns KMsgBox::yesNoCancel() |
520 | int msgCalModified(); | 520 | int msgCalModified(); |
521 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 521 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource); |
522 | 522 | ||
523 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 523 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
524 | virtual void removeSyncInfo( QString syncProfile); | 524 | virtual void removeSyncInfo( QString syncProfile); |
525 | void setSyncManager(KSyncManager* manager); | 525 | void setSyncManager(KSyncManager* manager); |
526 | void setLoadedFileVersion(QDateTime); | 526 | void setLoadedFileVersion(QDateTime); |
527 | bool checkFileVersion(QString fn); | 527 | bool checkFileVersion(QString fn); |
528 | bool checkAllFileVersions(); | 528 | bool checkAllFileVersions(); |
529 | bool checkFileChanged(QString fn); | 529 | bool checkFileChanged(QString fn); |
530 | Event* getLastSyncEvent(); | 530 | Event* getLastSyncEvent(); |
531 | /** Adapt navigation units correpsonding to step size of navigation of the | 531 | /** Adapt navigation units correpsonding to step size of navigation of the |
532 | * current view. | 532 | * current view. |
533 | */ | 533 | */ |
534 | void adaptNavigationUnits(); | 534 | void adaptNavigationUnits(); |
535 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 535 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
536 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 536 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
537 | //Attendee* getYourAttendee(Event *event); | 537 | //Attendee* getYourAttendee(Event *event); |
538 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 538 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
539 | void setScrollBarStep(int val ); | 539 | void setScrollBarStep(int val ); |
540 | 540 | ||
541 | protected: | 541 | protected: |
542 | Event *mConflictingEvent; | 542 | Event *mConflictingEvent; |
543 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 543 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
544 | 544 | ||
545 | // returns KMsgBox::OKCandel() | 545 | // returns KMsgBox::OKCandel() |
546 | int msgItemDelete(const QString name); | 546 | int msgItemDelete(const QString name); |
547 | void showEventEditor(); | 547 | void showEventEditor(); |
548 | void showTodoEditor(); | 548 | void showTodoEditor(); |
549 | Todo *selectedTodo(); | 549 | Todo *selectedTodo(); |
550 | private: | 550 | private: |
551 | #ifdef DESKTOP_VERSION | 551 | #ifdef DESKTOP_VERSION |
552 | QScrollBar * mDateScrollBar; | 552 | QScrollBar * mDateScrollBar; |
553 | #endif | 553 | #endif |
554 | bool flag_blockConflict; | 554 | bool flag_blockConflict; |
555 | bool flag_blockScrollBar; | 555 | bool flag_blockScrollBar; |
556 | bool flag_checkFileFirsttime; | 556 | bool flag_checkFileFirsttime; |
557 | bool flag_clearallviewsEventDisplay; | 557 | bool flag_clearallviewsEventDisplay; |
558 | bool flag_clearallviewsupdateView; | 558 | bool flag_clearallviewsupdateView; |
559 | QDateTime mNextAlarmDateTime; | 559 | QDateTime mNextAlarmDateTime; |
560 | bool mViewerCallerIsSearchDialog; | 560 | bool mViewerCallerIsSearchDialog; |
561 | bool mBlockShowDates; | 561 | bool mBlockShowDates; |
562 | KSyncManager* mSyncManager; | 562 | KSyncManager* mSyncManager; |
563 | AlarmDialog * mAlarmDialog; | 563 | AlarmDialog * mAlarmDialog; |
564 | QString mAlarmNotification; | 564 | QString mAlarmNotification; |
565 | QString mSuspendAlarmNotification; | 565 | QString mSuspendAlarmNotification; |
566 | QTimer* mSuspendTimer; | 566 | QTimer* mSuspendTimer; |
567 | QTimer* mAlarmTimer; | 567 | QTimer* mAlarmTimer; |
568 | QTimer* mRecheckAlarmTimer; | 568 | QTimer* mRecheckAlarmTimer; |
569 | void computeAlarm( QString ); | 569 | void computeAlarm( QString ); |
570 | void startAlarm( QString, QString ); | 570 | void startAlarm( QString, QString ); |
571 | void setSyncEventsReadOnly(); | 571 | void setSyncEventsReadOnly(); |
572 | 572 | ||
573 | QDateTime loadedFileVersion; | 573 | QDateTime loadedFileVersion; |
574 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 574 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
575 | void checkExternalId( Incidence * inc ); | 575 | void checkExternalId( Incidence * inc ); |
576 | int mGlobalSyncMode; | 576 | int mGlobalSyncMode; |
577 | QString mCurrentSyncDevice; | 577 | QString mCurrentSyncDevice; |
578 | QString mCurrentSyncName; | 578 | QString mCurrentSyncName; |
579 | void init(); | 579 | void init(); |
580 | int mDatePickerMode; | 580 | int mDatePickerMode; |
581 | bool mFlagEditDescription; | 581 | bool mFlagEditDescription; |
582 | QDateTime mLastCalendarSync; | 582 | QDateTime mLastCalendarSync; |
583 | void createPrinter(); | 583 | void createPrinter(); |
584 | 584 | ||
585 | void calendarModified( bool, Calendar * ); | 585 | void calendarModified( bool, Calendar * ); |
586 | 586 | ||
587 | CalPrinter *mCalPrinter; | 587 | CalPrinter *mCalPrinter; |
588 | 588 | ||
589 | QSplitter *mPanner; | 589 | QSplitter *mPanner; |
590 | QSplitter *mLeftSplitter; | 590 | QSplitter *mLeftSplitter; |
591 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; | 591 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; |
592 | QWidgetStack *mRightFrame; | 592 | QWidgetStack *mRightFrame; |
593 | 593 | ||
594 | KDatePicker* mDatePicker; | 594 | KDatePicker* mDatePicker; |
595 | QVBox* mDateFrame; | 595 | QVBox* mDateFrame; |
596 | 596 | ||
597 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. | 597 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. |
598 | 598 | ||
599 | KOFilterView *mFilterView; | 599 | KOFilterView *mFilterView; |
600 | KOCalEditView *mCalEditView; | 600 | KOCalEditView *mCalEditView; |
601 | 601 | ||
602 | ResourceView *mResourceView; | 602 | ResourceView *mResourceView; |
603 | 603 | ||
604 | // calendar object for this viewing instance | 604 | // calendar object for this viewing instance |
605 | Calendar *mCalendar; | 605 | Calendar *mCalendar; |
606 | 606 | ||
607 | CalendarResourceManager *mResourceManager; | 607 | CalendarResourceManager *mResourceManager; |
608 | 608 | ||
609 | FileStorage *mStorage; | 609 | FileStorage *mStorage; |
610 | 610 | ||
611 | DateNavigator *mNavigator; | 611 | DateNavigator *mNavigator; |
612 | 612 | ||
613 | KOViewManager *mViewManager; | 613 | KOViewManager *mViewManager; |
614 | KODialogManager *mDialogManager; | 614 | KODialogManager *mDialogManager; |
615 | 615 | ||
616 | // Calendar filters | 616 | // Calendar filters |
617 | QPtrList<CalFilter> mFilters; | 617 | QPtrList<CalFilter> mFilters; |
618 | 618 | ||
619 | // various housekeeping variables. | 619 | // various housekeeping variables. |
620 | bool mModified; // flag indicating if calendar is modified | 620 | bool mModified; // flag indicating if calendar is modified |
621 | bool mReadOnly; // flag indicating if calendar is read-only | 621 | bool mReadOnly; // flag indicating if calendar is read-only |
622 | QDate mSaveSingleDate; | 622 | QDate mSaveSingleDate; |
623 | 623 | ||
624 | Incidence *mSelectedIncidence; | 624 | Incidence *mSelectedIncidence; |
625 | Incidence *mMoveIncidence; | 625 | Incidence *mMoveIncidence; |
626 | QDate mMoveIncidenceOldDate; | 626 | QDate mMoveIncidenceOldDate; |
627 | KOTodoView *mTodoList; | 627 | KOTodoView *mTodoList; |
628 | KOEventEditor * mEventEditor; | 628 | KOEventEditor * mEventEditor; |
629 | KOTodoEditor * mTodoEditor; | 629 | KOTodoEditor * mTodoEditor; |
630 | KOEventViewerDialog * mEventViewerDialog; | 630 | KOEventViewerDialog * mEventViewerDialog; |
631 | void keyPressEvent ( QKeyEvent *e) ; | 631 | void keyPressEvent ( QKeyEvent *e) ; |
632 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 632 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
633 | }; | 633 | }; |
634 | 634 | ||
635 | 635 | ||
636 | class CalendarViewVisitor : public Incidence::Visitor | 636 | class CalendarViewVisitor : public Incidence::Visitor |
637 | { | 637 | { |
638 | public: | 638 | public: |
639 | CalendarViewVisitor() : mView( 0 ) {} | 639 | CalendarViewVisitor() : mView( 0 ) {} |
640 | 640 | ||
641 | bool act( Incidence *incidence, CalendarView *view ) | 641 | bool act( Incidence *incidence, CalendarView *view ) |
642 | { | 642 | { |
643 | mView = view; | 643 | mView = view; |
644 | return incidence->accept( *this ); | 644 | return incidence->accept( *this ); |
645 | } | 645 | } |
646 | 646 | ||
647 | protected: | 647 | protected: |
648 | CalendarView *mView; | 648 | CalendarView *mView; |
649 | }; | 649 | }; |
650 | 650 | ||
651 | class ShowIncidenceVisitor : public CalendarViewVisitor | 651 | class ShowIncidenceVisitor : public CalendarViewVisitor |
652 | { | 652 | { |
653 | protected: | 653 | protected: |
654 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 654 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
655 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 655 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
656 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 656 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
657 | }; | 657 | }; |
658 | 658 | ||
659 | class EditIncidenceVisitor : public CalendarViewVisitor | 659 | class EditIncidenceVisitor : public CalendarViewVisitor |
660 | { | 660 | { |
661 | protected: | 661 | protected: |
662 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 662 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
663 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 663 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
664 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 664 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
665 | }; | 665 | }; |
666 | 666 | ||
667 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 667 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
668 | { | 668 | { |
669 | protected: | 669 | protected: |
670 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 670 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
671 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 671 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
672 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 672 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
673 | }; | 673 | }; |
674 | 674 | ||
675 | #endif | 675 | #endif |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 1b0e5f4..31ef338 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,636 +1,646 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kglobalsettings.h> | 39 | #include <kglobalsettings.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kemailsettings.h> | 43 | #include <kemailsettings.h> |
44 | #include <kstaticdeleter.h> | 44 | #include <kstaticdeleter.h> |
45 | #include <libkdepim/kpimglobalprefs.h> | 45 | #include <libkdepim/kpimglobalprefs.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "mainwindow.h" | 48 | #include "mainwindow.h" |
49 | 49 | ||
50 | KOPrefs *KOPrefs::mInstance = 0; | 50 | KOPrefs *KOPrefs::mInstance = 0; |
51 | static KStaticDeleter<KOPrefs> insd; | 51 | static KStaticDeleter<KOPrefs> insd; |
52 | 52 | ||
53 | KOPrefs::KOPrefs() : | 53 | KOPrefs::KOPrefs() : |
54 | KPimPrefs("korganizerrc") | 54 | KPimPrefs("korganizerrc") |
55 | { | 55 | { |
56 | mGlobalUpdateDisabled = false; | 56 | mGlobalUpdateDisabled = false; |
57 | mCategoryColors.setAutoDelete(true); | 57 | mCategoryColors.setAutoDelete(true); |
58 | fillMailDefaults(); | 58 | fillMailDefaults(); |
59 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 59 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
60 | QColor defaultHolidayColor = QColor(255,0,0); | 60 | QColor defaultHolidayColor = QColor(255,0,0); |
61 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 61 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
62 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 62 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
63 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 63 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
64 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 64 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
65 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 65 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
66 | QColor defaultTodoRunColor = QColor(99,194,30); | 66 | QColor defaultTodoRunColor = QColor(99,194,30); |
67 | KPrefs::setCurrentGroup("General"); | 67 | KPrefs::setCurrentGroup("General"); |
68 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 68 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
69 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 69 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
70 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 70 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
71 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 71 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
72 | addItemBool("ShowIconList",&mShowIconList,true); | 72 | addItemBool("ShowIconList",&mShowIconList,true); |
73 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 73 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
74 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 74 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
75 | addItemBool("ShowIconDay6",&mShowIconDay6,true); | 75 | addItemBool("ShowIconDay6",&mShowIconDay6,true); |
76 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 76 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
77 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 77 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
78 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 78 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
79 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 79 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
80 | addItemBool("ShowIconBack",&mShowIconBack,true); | 80 | addItemBool("ShowIconBack",&mShowIconBack,true); |
81 | addItemBool("ShowIconToday",&mShowIconToday,true); | 81 | addItemBool("ShowIconToday",&mShowIconToday,true); |
82 | addItemBool("ShowIconForward",&mShowIconForward,true); | 82 | addItemBool("ShowIconForward",&mShowIconForward,true); |
83 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 83 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
84 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); | 84 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); |
85 | addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); | 85 | addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); |
86 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 86 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
87 | addItemBool("ShowIconNext",&mShowIconNext,true); | 87 | addItemBool("ShowIconNext",&mShowIconNext,true); |
88 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 88 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
89 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 89 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
90 | addItemBool("ShowIconFilter",&mShowIconFilter,false); | 90 | addItemBool("ShowIconFilter",&mShowIconFilter,false); |
91 | addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); | 91 | addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); |
92 | 92 | ||
93 | bool addIcons = false; | 93 | bool addIcons = false; |
94 | #ifdef DESKTOP_VERSION | 94 | #ifdef DESKTOP_VERSION |
95 | addIcons = true; | 95 | addIcons = true; |
96 | #endif | 96 | #endif |
97 | addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); | 97 | addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); |
98 | addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); | 98 | addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); |
99 | addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); | 99 | addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); |
100 | addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); | 100 | addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); |
101 | 101 | ||
102 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); | 102 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); |
103 | 103 | ||
104 | addItemBool("AskForQuit",&mAskForQuit,false); | 104 | addItemBool("AskForQuit",&mAskForQuit,false); |
105 | 105 | ||
106 | #ifndef DESKTOP_VERSION | 106 | #ifndef DESKTOP_VERSION |
107 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 107 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
108 | #else | 108 | #else |
109 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 109 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
110 | #endif | 110 | #endif |
111 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 111 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
112 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 112 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
113 | addItemBool("ToolBarHorV",&mToolBarHorV, true ); | 113 | addItemBool("ToolBarHorV",&mToolBarHorV, true ); |
114 | addItemBool("ToolBarUpV",&mToolBarUpV, false ); | 114 | addItemBool("ToolBarUpV",&mToolBarUpV, false ); |
115 | addItemBool("ToolBarHorN",&mToolBarHorN, true ); | 115 | addItemBool("ToolBarHorN",&mToolBarHorN, true ); |
116 | addItemBool("ToolBarUpN",&mToolBarUpN, false ); | 116 | addItemBool("ToolBarUpN",&mToolBarUpN, false ); |
117 | addItemBool("ToolBarHorF",&mToolBarHorF, true ); | 117 | addItemBool("ToolBarHorF",&mToolBarHorF, true ); |
118 | addItemBool("ToolBarUpF",&mToolBarUpF, false ); | 118 | addItemBool("ToolBarUpF",&mToolBarUpF, false ); |
119 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 119 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
120 | addItemBool("WhatsNextTime2Lines",&mWhatsNextTime2Lines, false ); | 120 | addItemBool("WhatsNextTime2Lines",&mWhatsNextTime2Lines, false ); |
121 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 121 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
122 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 122 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
123 | 123 | ||
124 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 124 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
125 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); | 125 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); |
126 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); | 126 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); |
127 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); | 127 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); |
128 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 128 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
129 | addItemInt("AllDay Size",&mAllDaySize,28); | 129 | addItemInt("AllDay Size",&mAllDaySize,28); |
130 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 130 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
131 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 131 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
132 | 132 | ||
133 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 133 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
134 | addItemStringList("EventSummary User",&mEventSummaryUser); | 134 | addItemStringList("EventSummary User",&mEventSummaryUser); |
135 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 135 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
136 | addItemStringList("JournalSummary User",&mJournalSummaryUser); | 136 | addItemStringList("JournalSummary User",&mJournalSummaryUser); |
137 | 137 | ||
138 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 138 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
139 | addItemBool("Enable Project View",&mEnableProjectView,false); | 139 | addItemBool("Enable Project View",&mEnableProjectView,false); |
140 | addItemBool("Auto Save",&mAutoSave,false); | 140 | addItemBool("Auto Save",&mAutoSave,false); |
141 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 141 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
142 | addItemBool("Confirm Deletes",&mConfirm,true); | 142 | addItemBool("Confirm Deletes",&mConfirm,true); |
143 | addItemString("Archive File",&mArchiveFile); | 143 | addItemString("Archive File",&mArchiveFile); |
144 | addItemString("Html Export File",&mHtmlExportFile, | 144 | addItemString("Html Export File",&mHtmlExportFile, |
145 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 145 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
146 | addItemBool("Html With Save",&mHtmlWithSave,false); | 146 | addItemBool("Html With Save",&mHtmlWithSave,false); |
147 | 147 | ||
148 | KPrefs::setCurrentGroup("Personal Settings"); | 148 | KPrefs::setCurrentGroup("Personal Settings"); |
149 | 149 | ||
150 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 150 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
151 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 151 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
152 | addItemBool("Bcc",&mBcc,false); | 152 | addItemBool("Bcc",&mBcc,false); |
153 | 153 | ||
154 | KPrefs::setCurrentGroup("Time & Date"); | 154 | KPrefs::setCurrentGroup("Time & Date"); |
155 | 155 | ||
156 | 156 | ||
157 | addItemInt("Default Start Time",&mStartTime,10); | 157 | addItemInt("Default Start Time",&mStartTime,10); |
158 | addItemInt("Default Duration",&mDefaultDuration,2); | 158 | addItemInt("Default Duration",&mDefaultDuration,2); |
159 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 159 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
160 | KPrefs::setCurrentGroup("AlarmSettings"); | 160 | KPrefs::setCurrentGroup("AlarmSettings"); |
161 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 161 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
162 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 162 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
163 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 163 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
164 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 164 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
165 | 165 | ||
166 | 166 | ||
167 | KPrefs::setCurrentGroup("Calendar"); | 167 | KPrefs::setCurrentGroup("Calendar"); |
168 | 168 | ||
169 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 169 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
170 | 170 | ||
171 | KPrefs::setCurrentGroup("Fonts"); | 171 | KPrefs::setCurrentGroup("Fonts"); |
172 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 172 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
173 | QFont fon = KGlobalSettings::generalFont(); | 173 | QFont fon = KGlobalSettings::generalFont(); |
174 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); | 174 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); |
175 | addItemFont("MonthView Font",&mMonthViewFont,fon); | 175 | addItemFont("MonthView Font",&mMonthViewFont,fon); |
176 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); | 176 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); |
177 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); | 177 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); |
178 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); | 178 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); |
179 | addItemFont("TodoView Font",&mTodoViewFont,fon); | 179 | addItemFont("TodoView Font",&mTodoViewFont,fon); |
180 | addItemFont("ListView Font",&mListViewFont,fon); | 180 | addItemFont("ListView Font",&mListViewFont,fon); |
181 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); | 181 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); |
182 | addItemFont("EditBox Font",&mEditBoxFont,fon); | 182 | addItemFont("EditBox Font",&mEditBoxFont,fon); |
183 | addItemFont("JournalView Font",&mJornalViewFont,fon); | 183 | addItemFont("JournalView Font",&mJornalViewFont,fon); |
184 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); | 184 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); |
185 | addItemFont("EventView Font",&mEventViewFont,fon); | 185 | addItemFont("EventView Font",&mEventViewFont,fon); |
186 | 186 | ||
187 | KPrefs::setCurrentGroup("RemoteSyncing"); | 187 | KPrefs::setCurrentGroup("RemoteSyncing"); |
188 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 188 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
189 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 189 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
190 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 190 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
191 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 191 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
192 | 192 | ||
193 | #ifdef _WIN32_ | 193 | #ifdef _WIN32_ |
194 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 194 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
195 | #else | 195 | #else |
196 | QString hdp= locateLocal("data","korganizer")+"/"; | 196 | QString hdp= locateLocal("data","korganizer")+"/"; |
197 | #endif | 197 | #endif |
198 | 198 | ||
199 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 199 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
200 | 200 | ||
201 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 201 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
202 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 202 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
203 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 203 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
204 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 204 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
205 | 205 | ||
206 | 206 | ||
207 | KPrefs::setCurrentGroup("Locale"); | 207 | KPrefs::setCurrentGroup("Locale"); |
208 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 208 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
209 | 209 | ||
210 | 210 | ||
211 | KPrefs::setCurrentGroup("Colors"); | 211 | KPrefs::setCurrentGroup("Colors"); |
212 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 212 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
213 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 213 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
214 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 214 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
215 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); | 215 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); |
216 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 216 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
217 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 217 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
218 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 218 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
219 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 219 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
220 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); | 220 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); |
221 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 221 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
222 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 222 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
223 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 223 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
224 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 224 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
225 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 225 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
226 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); | 226 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); |
227 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 227 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
228 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 228 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
229 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 229 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
230 | addItemBool("UseAppColors",&mUseAppColors,false); | 230 | addItemBool("UseAppColors",&mUseAppColors,false); |
231 | 231 | ||
232 | 232 | ||
233 | KPrefs::setCurrentGroup("Conflicts"); | 233 | KPrefs::setCurrentGroup("Conflicts"); |
234 | addItemBool("EnableAutoDetect",&mDetectConflicts,true); | 234 | addItemBool("EnableAutoDetect",&mDetectConflicts,true); |
235 | addItemBool("CheckConflictsFree",&mIncludeFree,true); | 235 | addItemBool("CheckConflictsFree",&mIncludeFree,true); |
236 | addItemBool("CheckConflictsAllDayAllDay",&mCheckConflictsAllDayAllDay,false); | 236 | addItemBool("CheckConflictsAllDayAllDay",&mCheckConflictsAllDayAllDay,false); |
237 | addItemBool("CheckConflictsAllDayNonAD",&mCheckConflictsAllDayNonAD,false); | 237 | addItemBool("CheckConflictsAllDayNonAD",&mCheckConflictsAllDayNonAD,false); |
238 | addItemBool("CheckConflictsNonADAllDay",&mCheckConflictsNonADAllDay,false); | 238 | addItemBool("CheckConflictsNonADAllDay",&mCheckConflictsNonADAllDay,false); |
239 | addItemBool("CheckConflictsNonADNonAD",&mCheckConflictsNonADNonAD,true); | 239 | addItemBool("CheckConflictsNonADNonAD",&mCheckConflictsNonADNonAD,true); |
240 | addItemString("FilterConflictEditItem", &mFilterConflictEditItem ,"nofilter" ); | 240 | addItemString("FilterConflictEditItem", &mFilterConflictEditItem ,"nofilter" ); |
241 | addItemString("FilterConflictAllItem", &mFilterConflictAllItem ,"nofilter" ); | 241 | addItemString("FilterConflictAllItem", &mFilterConflictAllItem ,"nofilter" ); |
242 | 242 | ||
243 | KPrefs::setCurrentGroup("Views"); | 243 | KPrefs::setCurrentGroup("Views"); |
244 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); | 244 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); |
245 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); | 245 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); |
246 | addItemInt("Hour Size",&mHourSize,8); | 246 | addItemInt("Hour Size",&mHourSize,8); |
247 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 247 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
248 | addItemBool("ShowLongAllday",&mLongAllday,true); | 248 | addItemBool("ShowLongAllday",&mLongAllday,true); |
249 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 249 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
250 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 250 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
251 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 251 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
252 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 252 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
253 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 253 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
254 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); | 254 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); |
255 | #ifdef DESKTOP_VERION | 255 | #ifdef DESKTOP_VERION |
256 | addItemBool("Enable ToolTips",&mEnableToolTips,true); | 256 | addItemBool("Enable ToolTips",&mEnableToolTips,true); |
257 | #else | 257 | #else |
258 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 258 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
259 | #endif | 259 | #endif |
260 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 260 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
261 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 261 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
262 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 262 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
263 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 263 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
264 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); | 264 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); |
265 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 265 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
266 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 266 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
267 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 267 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
268 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 268 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
269 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; | 269 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; |
270 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); | 270 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); |
271 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 271 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
272 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 272 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
273 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 273 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
274 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 274 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
275 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 275 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
276 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); | 276 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); |
277 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); | 277 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); |
278 | addItemBool("MonthViewWeekRowlayout",&mMonthViewWeekRowlayout,false); | 278 | addItemBool("MonthViewWeekRowlayout",&mMonthViewWeekRowlayout,false); |
279 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 279 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
280 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 280 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
281 | #ifdef DESKTOP_VERSION | 281 | #ifdef DESKTOP_VERSION |
282 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 282 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
283 | #else | 283 | #else |
284 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 284 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
285 | #endif | 285 | #endif |
286 | addItemInt("Day Begins",&mDayBegins,7); | 286 | addItemInt("Day Begins",&mDayBegins,7); |
287 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 287 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
288 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 288 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
289 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 289 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
290 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 290 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
291 | 291 | ||
292 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 292 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
293 | addItemBool("Full View Month",&mFullViewMonth,true); | 293 | addItemBool("Full View Month",&mFullViewMonth,true); |
294 | addItemBool("Full View Todo",&mFullViewTodo,true); | 294 | addItemBool("Full View Todo",&mFullViewTodo,true); |
295 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 295 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
296 | 296 | ||
297 | addItemInt("Next X Days",&mNextXDays,3); | 297 | addItemInt("Next X Days",&mNextXDays,3); |
298 | 298 | ||
299 | KPrefs::setCurrentGroup("Printer"); | 299 | KPrefs::setCurrentGroup("Printer"); |
300 | 300 | ||
301 | KPrefs::setCurrentGroup("Layout"); | 301 | KPrefs::setCurrentGroup("Layout"); |
302 | 302 | ||
303 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 303 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
304 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 304 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
305 | 305 | ||
306 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 306 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
307 | 307 | ||
308 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 308 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
309 | 309 | ||
310 | KPrefs::setCurrentGroup("Group Scheduling"); | 310 | KPrefs::setCurrentGroup("Group Scheduling"); |
311 | 311 | ||
312 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 312 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
313 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 313 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
314 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 314 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
315 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 315 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
316 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 316 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
317 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 317 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
318 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 318 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
319 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 319 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
320 | 320 | ||
321 | KPrefs::setCurrentGroup( "Editors" ); | 321 | KPrefs::setCurrentGroup( "Editors" ); |
322 | 322 | ||
323 | addItemStringList( "EventTemplates", &mEventTemplates ); | 323 | addItemStringList( "EventTemplates", &mEventTemplates ); |
324 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 324 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
325 | 325 | ||
326 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 326 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
327 | 327 | ||
328 | KPrefs::setCurrentGroup( "ViewOptions" ); | 328 | KPrefs::setCurrentGroup( "ViewOptions" ); |
329 | addItemBool("EVshowDetails",&mEVshowDetails,true); | 329 | addItemBool("EVshowDetails",&mEVshowDetails,true); |
330 | addItemBool("EVshowCreated",&mEVshowCreated,true); | 330 | addItemBool("EVshowCreated",&mEVshowCreated,true); |
331 | addItemBool("EVshowChanged",&mEVshowChanged,true); | 331 | addItemBool("EVshowChanged",&mEVshowChanged,true); |
332 | addItemBool("WTshowDetails",&mWTshowDetails,false); | 332 | addItemBool("WTshowDetails",&mWTshowDetails,false); |
333 | addItemBool("WTshowCreated",&mWTshowCreated,false); | 333 | addItemBool("WTshowCreated",&mWTshowCreated,false); |
334 | addItemBool("WTshowChanged",&mWTshowChanged,false); | 334 | addItemBool("WTshowChanged",&mWTshowChanged,false); |
335 | mCalendars.setAutoDelete( true ); | 335 | mCalendars.setAutoDelete( true ); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | KOPrefs::~KOPrefs() | 339 | KOPrefs::~KOPrefs() |
340 | { | 340 | { |
341 | if (mInstance == this) | 341 | if (mInstance == this) |
342 | mInstance = insd.setObject(0); | 342 | mInstance = insd.setObject(0); |
343 | mCalendars.setAutoDelete( true ); | 343 | mCalendars.setAutoDelete( true ); |
344 | mCalendars.clear(); | 344 | mCalendars.clear(); |
345 | //qDebug("KOPrefs::~KOPrefs() "); | 345 | //qDebug("KOPrefs::~KOPrefs() "); |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | KOPrefs *KOPrefs::instance() | 349 | KOPrefs *KOPrefs::instance() |
350 | { | 350 | { |
351 | if (!mInstance) { | 351 | if (!mInstance) { |
352 | mInstance = insd.setObject(new KOPrefs()); | 352 | mInstance = insd.setObject(new KOPrefs()); |
353 | mInstance->readConfig(); | 353 | mInstance->readConfig(); |
354 | } | 354 | } |
355 | 355 | ||
356 | return mInstance; | 356 | return mInstance; |
357 | } | 357 | } |
358 | 358 | ||
359 | void KOPrefs::usrSetDefaults() | 359 | void KOPrefs::usrSetDefaults() |
360 | { | 360 | { |
361 | 361 | ||
362 | } | 362 | } |
363 | 363 | ||
364 | void KOPrefs::fillMailDefaults() | 364 | void KOPrefs::fillMailDefaults() |
365 | { | 365 | { |
366 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 366 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
367 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 367 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
368 | } | 368 | } |
369 | 369 | ||
370 | void KOPrefs::setTimeZoneIdDefault() | 370 | void KOPrefs::setTimeZoneIdDefault() |
371 | { | 371 | { |
372 | ; | 372 | ; |
373 | } | 373 | } |
374 | 374 | ||
375 | void KOPrefs::setAllDefaults() | 375 | void KOPrefs::setAllDefaults() |
376 | { | 376 | { |
377 | setCategoryDefaults(); | 377 | setCategoryDefaults(); |
378 | mEventSummaryUser = getDefaultList() ; | 378 | mEventSummaryUser = getDefaultList() ; |
379 | mTodoSummaryUser = getDefaultList() ; | 379 | mTodoSummaryUser = getDefaultList() ; |
380 | mJournalSummaryUser = getDefaultList() ; | 380 | mJournalSummaryUser = getDefaultList() ; |
381 | mLocationDefaults = getLocationDefaultList(); | 381 | mLocationDefaults = getLocationDefaultList(); |
382 | } | 382 | } |
383 | 383 | ||
384 | void KOPrefs::setCategoryDefaults() | 384 | void KOPrefs::setCategoryDefaults() |
385 | { | 385 | { |
386 | mCustomCategories.clear(); | 386 | mCustomCategories.clear(); |
387 | mCustomCategories = getDefaultList(); | 387 | mCustomCategories = getDefaultList(); |
388 | 388 | ||
389 | QStringList::Iterator it; | 389 | QStringList::Iterator it; |
390 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 390 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
391 | setCategoryColor(*it,mDefaultCategoryColor); | 391 | setCategoryColor(*it,mDefaultCategoryColor); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | QStringList KOPrefs::getLocationDefaultList() | 394 | QStringList KOPrefs::getLocationDefaultList() |
395 | { | 395 | { |
396 | QStringList retval ; | 396 | QStringList retval ; |
397 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 397 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
398 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") | 398 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") |
399 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 399 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
400 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 400 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
401 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 401 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
402 | 402 | ||
403 | retval.sort(); | 403 | retval.sort(); |
404 | return retval; | 404 | return retval; |
405 | } | 405 | } |
406 | QStringList KOPrefs::getDefaultList() | 406 | QStringList KOPrefs::getDefaultList() |
407 | { | 407 | { |
408 | QStringList retval ; | 408 | QStringList retval ; |
409 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") | 409 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") |
410 | << i18n("Break") | 410 | << i18n("Break") |
411 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") | 411 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") |
412 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") | 412 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") |
413 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") | 413 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") |
414 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") | 414 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") |
415 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") | 415 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") |
416 | << i18n("Vacation") ; | 416 | << i18n("Vacation") ; |
417 | retval.sort(); | 417 | retval.sort(); |
418 | //qDebug("cat %s ", retval.join("-").latin1()); | 418 | //qDebug("cat %s ", retval.join("-").latin1()); |
419 | return retval; | 419 | return retval; |
420 | } | 420 | } |
421 | // << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") | 421 | // << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") |
422 | void KOPrefs::usrReadConfig() | 422 | void KOPrefs::usrReadConfig() |
423 | { | 423 | { |
424 | config()->setGroup("General"); | 424 | config()->setGroup("General"); |
425 | 425 | ||
426 | //qDebug("KOPrefs::usrReadConfig() "); | 426 | //qDebug("KOPrefs::usrReadConfig() "); |
427 | mCustomCategories = config()->readListEntry("Custom Categories"); | 427 | mCustomCategories = config()->readListEntry("Custom Categories"); |
428 | mOldLoadedLanguage = mOldLanguage ; | 428 | mOldLoadedLanguage = mOldLanguage ; |
429 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 429 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
430 | if (mLocationDefaults.isEmpty()) { | 430 | if (mLocationDefaults.isEmpty()) { |
431 | mLocationDefaults = getLocationDefaultList(); | 431 | mLocationDefaults = getLocationDefaultList(); |
432 | } | 432 | } |
433 | 433 | ||
434 | if (mEventSummaryUser.isEmpty()) { | 434 | if (mEventSummaryUser.isEmpty()) { |
435 | mEventSummaryUser = getDefaultList() ; | 435 | mEventSummaryUser = getDefaultList() ; |
436 | } | 436 | } |
437 | if (mTodoSummaryUser.isEmpty()) { | 437 | if (mTodoSummaryUser.isEmpty()) { |
438 | mTodoSummaryUser = getDefaultList() ; | 438 | mTodoSummaryUser = getDefaultList() ; |
439 | } | 439 | } |
440 | 440 | ||
441 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 441 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
442 | 442 | ||
443 | config()->setGroup("Personal Settings"); | 443 | config()->setGroup("Personal Settings"); |
444 | mName = config()->readEntry("user_name",""); | 444 | mName = config()->readEntry("user_name",""); |
445 | mEmail = config()->readEntry("user_email",""); | 445 | mEmail = config()->readEntry("user_email",""); |
446 | fillMailDefaults(); | 446 | fillMailDefaults(); |
447 | 447 | ||
448 | config()->setGroup("Category Colors"); | 448 | config()->setGroup("Category Colors"); |
449 | QStringList::Iterator it; | 449 | QStringList::Iterator it; |
450 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 450 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
451 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 451 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
452 | 452 | ||
453 | } | 453 | } |
454 | KConfig fc (locateLocal("config","kopicalendarrc")); | 454 | KConfig fc (locateLocal("config","kopicalendarrc")); |
455 | fc.setGroup("CC"); | 455 | fc.setGroup("CC"); |
456 | int numCals = fc.readNumEntry("NumberCalendars",0 ); | 456 | int numCals = fc.readNumEntry("NumberCalendars",0 ); |
457 | mNextAvailableCalendar = 1; | 457 | mNextAvailableCalendar = 1; |
458 | if ( numCals == 0 ) { | 458 | if ( numCals == 0 ) { |
459 | KopiCalendarFile *kkf = getNewCalendar(); | 459 | KopiCalendarFile *kkf = getNewCalendar(); |
460 | kkf->isStandard = true; | 460 | kkf->isStandard = true; |
461 | kkf->mName = i18n("Standard"); | 461 | kkf->mName = i18n("Standard"); |
462 | kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); | 462 | kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); |
463 | } | 463 | } |
464 | while ( mNextAvailableCalendar <= numCals ) { | 464 | while ( mNextAvailableCalendar <= numCals ) { |
465 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); | 465 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); |
466 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); | 466 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); |
467 | KopiCalendarFile *kkf = getNewCalendar(); | 467 | KopiCalendarFile *kkf = getNewCalendar(); |
468 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); | 468 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); |
469 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); | 469 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); |
470 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); | 470 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); |
471 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); | 471 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); |
472 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); | 472 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); |
473 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); | 473 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); |
474 | kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) ); | 474 | kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) ); |
475 | kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); | 475 | kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); |
476 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); | 476 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); |
477 | if ( kkf->mCalNumber == 1 ) { | 477 | if ( kkf->mCalNumber == 1 ) { |
478 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | 478 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); |
479 | } | 479 | } |
480 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); | 480 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); |
481 | if ( kkf->mName == i18n("Birthdays") ) { | 481 | if ( kkf->mName == i18n("Birthdays") ) { |
482 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); | 482 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); |
483 | } | 483 | } |
484 | if ( kkf->isRelative ) | 484 | if ( kkf->isRelative ) |
485 | kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); | 485 | kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); |
486 | } | 486 | } |
487 | 487 | ||
488 | KPimPrefs::usrReadConfig(); | 488 | KPimPrefs::usrReadConfig(); |
489 | } | 489 | } |
490 | 490 | ||
491 | KopiCalendarFile * KOPrefs::getCalendar( int num ) | 491 | KopiCalendarFile * KOPrefs::getCalendar( int num ) |
492 | { | 492 | { |
493 | return mDefCalColors[num-1]; | 493 | return mDefCalColors[num-1]; |
494 | } | 494 | } |
495 | 495 | ||
496 | KopiCalendarFile * KOPrefs::getNewCalendar() | 496 | KopiCalendarFile * KOPrefs::getNewCalendar() |
497 | { | 497 | { |
498 | KopiCalendarFile * kkf = new KopiCalendarFile(); | 498 | KopiCalendarFile * kkf = new KopiCalendarFile(); |
499 | kkf->mCalNumber = mNextAvailableCalendar; | 499 | kkf->mCalNumber = mNextAvailableCalendar; |
500 | mDefCalColors.resize( mNextAvailableCalendar ); | 500 | mDefCalColors.resize( mNextAvailableCalendar ); |
501 | mDefCalColors[mNextAvailableCalendar-1] = kkf; | 501 | mDefCalColors[mNextAvailableCalendar-1] = kkf; |
502 | ++mNextAvailableCalendar; | 502 | ++mNextAvailableCalendar; |
503 | kkf->mDefaultColor = mEventColor; | 503 | kkf->mDefaultColor = mEventColor; |
504 | kkf->mName = i18n("New Calendar"); | 504 | kkf->mName = i18n("New Calendar"); |
505 | mCalendars.append( kkf ); | 505 | mCalendars.append( kkf ); |
506 | return kkf; | 506 | return kkf; |
507 | } | 507 | } |
508 | void KOPrefs::deleteCalendar( int num ) | 508 | void KOPrefs::deleteCalendar( int num ) |
509 | { | 509 | { |
510 | KopiCalendarFile * kkf = mCalendars.first(); | 510 | KopiCalendarFile * kkf = mCalendars.first(); |
511 | while ( kkf ) { | 511 | while ( kkf ) { |
512 | if ( kkf->mCalNumber == num ) { | 512 | if ( kkf->mCalNumber == num ) { |
513 | qDebug("KOPrefs::deleteCalendar %d ", num ); | 513 | qDebug("KOPrefs::deleteCalendar %d ", num ); |
514 | mCalendars.remove( kkf ); | 514 | mCalendars.remove( kkf ); |
515 | delete kkf; | 515 | delete kkf; |
516 | return; | 516 | return; |
517 | } | 517 | } |
518 | kkf = mCalendars.next(); | 518 | kkf = mCalendars.next(); |
519 | } | 519 | } |
520 | } | 520 | } |
521 | int KOPrefs::getCalendarID( const QString & name ) | 521 | int KOPrefs::getCalendarID( const QString & name ) |
522 | { | 522 | { |
523 | KopiCalendarFile * kkf = mCalendars.first(); | 523 | KopiCalendarFile * kkf = mCalendars.first(); |
524 | while ( kkf ) { | 524 | while ( kkf ) { |
525 | if ( name == kkf->mName) | 525 | if ( name == kkf->mName) |
526 | return kkf->mCalNumber; | 526 | return kkf->mCalNumber; |
527 | kkf = mCalendars.next(); | 527 | kkf = mCalendars.next(); |
528 | } | 528 | } |
529 | return 1; | 529 | return 1; |
530 | } | 530 | } |
531 | int KOPrefs::getFuzzyCalendarID( const QString & name ) | ||
532 | { | ||
533 | KopiCalendarFile * kkf = mCalendars.first(); | ||
534 | while ( kkf ) { | ||
535 | if ( name.lower() == kkf->mName.lower()) | ||
536 | return kkf->mCalNumber; | ||
537 | kkf = mCalendars.next(); | ||
538 | } | ||
539 | return 0; | ||
540 | } | ||
531 | QString KOPrefs::calName( int calNum) const | 541 | QString KOPrefs::calName( int calNum) const |
532 | { | 542 | { |
533 | return (mDefCalColors[calNum-1])->mName; | 543 | return (mDefCalColors[calNum-1])->mName; |
534 | } | 544 | } |
535 | QColor KOPrefs::defaultColor( int calNum ) const | 545 | QColor KOPrefs::defaultColor( int calNum ) const |
536 | { | 546 | { |
537 | if ( calNum == 1 ) return mEventColor; | 547 | if ( calNum == 1 ) return mEventColor; |
538 | return (mDefCalColors[calNum-1])->mDefaultColor; | 548 | return (mDefCalColors[calNum-1])->mDefaultColor; |
539 | } | 549 | } |
540 | void KOPrefs::usrWriteConfig() | 550 | void KOPrefs::usrWriteConfig() |
541 | { | 551 | { |
542 | config()->setGroup("General"); | 552 | config()->setGroup("General"); |
543 | config()->writeEntry("Custom Categories",mCustomCategories); | 553 | config()->writeEntry("Custom Categories",mCustomCategories); |
544 | 554 | ||
545 | config()->setGroup("Personal Settings"); | 555 | config()->setGroup("Personal Settings"); |
546 | config()->writeEntry("user_name",mName); | 556 | config()->writeEntry("user_name",mName); |
547 | config()->writeEntry("user_email",mEmail); | 557 | config()->writeEntry("user_email",mEmail); |
548 | 558 | ||
549 | config()->setGroup("Category Colors"); | 559 | config()->setGroup("Category Colors"); |
550 | QDictIterator<QColor> it(mCategoryColors); | 560 | QDictIterator<QColor> it(mCategoryColors); |
551 | while (it.current()) { | 561 | while (it.current()) { |
552 | config()->writeEntry(it.currentKey(),*(it.current())); | 562 | config()->writeEntry(it.currentKey(),*(it.current())); |
553 | ++it; | 563 | ++it; |
554 | } | 564 | } |
555 | KConfig fc (locateLocal("config","kopicalendarrc")); | 565 | KConfig fc (locateLocal("config","kopicalendarrc")); |
556 | fc.setGroup("CC"); | 566 | fc.setGroup("CC"); |
557 | fc.deleteGroup( "CC"); | 567 | fc.deleteGroup( "CC"); |
558 | fc.setGroup("CC"); | 568 | fc.setGroup("CC"); |
559 | fc.writeEntry("NumberCalendars",mCalendars.count()); | 569 | fc.writeEntry("NumberCalendars",mCalendars.count()); |
560 | int numCal = 1; | 570 | int numCal = 1; |
561 | int writeCal = 0; | 571 | int writeCal = 0; |
562 | while ( numCal < mNextAvailableCalendar ) { | 572 | while ( numCal < mNextAvailableCalendar ) { |
563 | KopiCalendarFile * kkf = mCalendars.first(); | 573 | KopiCalendarFile * kkf = mCalendars.first(); |
564 | while ( kkf ) { | 574 | while ( kkf ) { |
565 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); | 575 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); |
566 | if ( kkf->mCalNumber == numCal ) { | 576 | if ( kkf->mCalNumber == numCal ) { |
567 | ++writeCal; | 577 | ++writeCal; |
568 | //qDebug("Write calendar %d %d ", numCal , writeCal); | 578 | //qDebug("Write calendar %d %d ", numCal , writeCal); |
569 | QString prefix = "Cal_" + QString::number( writeCal ); | 579 | QString prefix = "Cal_" + QString::number( writeCal ); |
570 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); | 580 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); |
571 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); | 581 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); |
572 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); | 582 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); |
573 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); | 583 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); |
574 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); | 584 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); |
575 | fc.writeEntry( prefix+"_Name", kkf->mName); | 585 | fc.writeEntry( prefix+"_Name", kkf->mName); |
576 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); | 586 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); |
577 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); | 587 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); |
578 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); | 588 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); |
579 | } | 589 | } |
580 | kkf = mCalendars.next(); | 590 | kkf = mCalendars.next(); |
581 | } | 591 | } |
582 | ++numCal; | 592 | ++numCal; |
583 | } | 593 | } |
584 | fc.sync(); | 594 | fc.sync(); |
585 | KPimPrefs::usrWriteConfig(); | 595 | KPimPrefs::usrWriteConfig(); |
586 | } | 596 | } |
587 | 597 | ||
588 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 598 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
589 | { | 599 | { |
590 | mCategoryColors.replace(cat,new QColor(color)); | 600 | mCategoryColors.replace(cat,new QColor(color)); |
591 | } | 601 | } |
592 | 602 | ||
593 | QColor *KOPrefs::categoryColor(QString cat) | 603 | QColor *KOPrefs::categoryColor(QString cat) |
594 | { | 604 | { |
595 | QColor *color = 0; | 605 | QColor *color = 0; |
596 | 606 | ||
597 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 607 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
598 | 608 | ||
599 | if (color) return color; | 609 | if (color) return color; |
600 | else return &mDefaultCategoryColor; | 610 | else return &mDefaultCategoryColor; |
601 | } | 611 | } |
602 | 612 | ||
603 | void KOPrefs::setFullName(const QString &name) | 613 | void KOPrefs::setFullName(const QString &name) |
604 | { | 614 | { |
605 | mName = name; | 615 | mName = name; |
606 | } | 616 | } |
607 | 617 | ||
608 | void KOPrefs::setEmail(const QString &email) | 618 | void KOPrefs::setEmail(const QString &email) |
609 | { | 619 | { |
610 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 620 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
611 | mEmail = email; | 621 | mEmail = email; |
612 | } | 622 | } |
613 | 623 | ||
614 | QString KOPrefs::fullName() | 624 | QString KOPrefs::fullName() |
615 | { | 625 | { |
616 | if (mEmailControlCenter) { | 626 | if (mEmailControlCenter) { |
617 | KEMailSettings settings; | 627 | KEMailSettings settings; |
618 | return settings.getSetting(KEMailSettings::RealName); | 628 | return settings.getSetting(KEMailSettings::RealName); |
619 | } else { | 629 | } else { |
620 | return mName; | 630 | return mName; |
621 | } | 631 | } |
622 | } | 632 | } |
623 | 633 | ||
624 | QString KOPrefs::email() | 634 | QString KOPrefs::email() |
625 | { | 635 | { |
626 | if (mEmailControlCenter) { | 636 | if (mEmailControlCenter) { |
627 | KEMailSettings settings; | 637 | KEMailSettings settings; |
628 | return settings.getSetting(KEMailSettings::EmailAddress); | 638 | return settings.getSetting(KEMailSettings::EmailAddress); |
629 | } else { | 639 | } else { |
630 | return mEmail; | 640 | return mEmail; |
631 | } | 641 | } |
632 | } | 642 | } |
633 | KConfig* KOPrefs::getConfig() | 643 | KConfig* KOPrefs::getConfig() |
634 | { | 644 | { |
635 | return config(); | 645 | return config(); |
636 | } | 646 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index bac8010..70da096 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,376 +1,377 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | 26 | ||
27 | #include <libkdepim/kpimprefs.h> | 27 | #include <libkdepim/kpimprefs.h> |
28 | #include <qdict.h> | 28 | #include <qdict.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qobject.h> | 30 | #include <qobject.h> |
31 | 31 | ||
32 | class KConfig; | 32 | class KConfig; |
33 | class QFont; | 33 | class QFont; |
34 | class QColor; | 34 | class QColor; |
35 | class QStringList; | 35 | class QStringList; |
36 | 36 | ||
37 | #define VIEW_WN_VIEW 1 | 37 | #define VIEW_WN_VIEW 1 |
38 | #define VIEW_NX_VIEW 2 | 38 | #define VIEW_NX_VIEW 2 |
39 | #define VIEW_J_VIEW 3 | 39 | #define VIEW_J_VIEW 3 |
40 | #define VIEW_A_VIEW 4 | 40 | #define VIEW_A_VIEW 4 |
41 | #define VIEW_ML_VIEW 5 | 41 | #define VIEW_ML_VIEW 5 |
42 | #define VIEW_M_VIEW 6 | 42 | #define VIEW_M_VIEW 6 |
43 | #define VIEW_L_VIEW 7 | 43 | #define VIEW_L_VIEW 7 |
44 | #define VIEW_T_VIEW 8 | 44 | #define VIEW_T_VIEW 8 |
45 | 45 | ||
46 | class KopiCalendarFile : public QObject | 46 | class KopiCalendarFile : public QObject |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | KopiCalendarFile( ) : QObject( ) | 49 | KopiCalendarFile( ) : QObject( ) |
50 | { | 50 | { |
51 | isStandard = false; | 51 | isStandard = false; |
52 | isEnabled = true; | 52 | isEnabled = true; |
53 | isAlarmEnabled = true; | 53 | isAlarmEnabled = true; |
54 | isReadOnly = false; | 54 | isReadOnly = false; |
55 | mName = "Calendar"; | 55 | mName = "Calendar"; |
56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; | 56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; |
57 | mSavedFileName = "icalfile.ics"; | 57 | mSavedFileName = "icalfile.ics"; |
58 | mCalNumber = 0; | 58 | mCalNumber = 0; |
59 | mDefaultColor = Qt::red; | 59 | mDefaultColor = Qt::red; |
60 | mErrorOnLoad = false; | 60 | mErrorOnLoad = false; |
61 | isRelative = false; | 61 | isRelative = false; |
62 | } | 62 | } |
63 | bool isStandard; | 63 | bool isStandard; |
64 | bool isEnabled; | 64 | bool isEnabled; |
65 | bool isAlarmEnabled; | 65 | bool isAlarmEnabled; |
66 | bool isReadOnly; | 66 | bool isReadOnly; |
67 | bool mErrorOnLoad; | 67 | bool mErrorOnLoad; |
68 | QString mName; | 68 | QString mName; |
69 | QString mFileName; | 69 | QString mFileName; |
70 | QString mSavedFileName; | 70 | QString mSavedFileName; |
71 | bool isRelative; | 71 | bool isRelative; |
72 | int mCalNumber; | 72 | int mCalNumber; |
73 | QColor mDefaultColor; | 73 | QColor mDefaultColor; |
74 | QDateTime mLoadDt; | 74 | QDateTime mLoadDt; |
75 | }; | 75 | }; |
76 | class KOPrefs : public KPimPrefs | 76 | class KOPrefs : public KPimPrefs |
77 | { | 77 | { |
78 | public: | 78 | public: |
79 | enum { FormatVCalendar, FormatICalendar }; | 79 | enum { FormatVCalendar, FormatICalendar }; |
80 | enum { MailClientKMail, MailClientSendmail }; | 80 | enum { MailClientKMail, MailClientSendmail }; |
81 | enum { IMIPDummy, IMIPKMail }; | 81 | enum { IMIPDummy, IMIPKMail }; |
82 | enum { IMIPOutbox, IMIPdirectsend }; | 82 | enum { IMIPOutbox, IMIPdirectsend }; |
83 | enum { neverAuto, addressbookAuto, selectedAuto }; | 83 | enum { neverAuto, addressbookAuto, selectedAuto }; |
84 | enum { standardDestination, askDestination }; | 84 | enum { standardDestination, askDestination }; |
85 | 85 | ||
86 | virtual ~KOPrefs(); | 86 | virtual ~KOPrefs(); |
87 | 87 | ||
88 | /** Get instance of KOPrefs. It is made sure that there is only one | 88 | /** Get instance of KOPrefs. It is made sure that there is only one |
89 | instance. */ | 89 | instance. */ |
90 | static KOPrefs *instance(); | 90 | static KOPrefs *instance(); |
91 | 91 | ||
92 | /** Set preferences to default values */ | 92 | /** Set preferences to default values */ |
93 | void usrSetDefaults(); | 93 | void usrSetDefaults(); |
94 | 94 | ||
95 | /** Read preferences from config file */ | 95 | /** Read preferences from config file */ |
96 | void usrReadConfig(); | 96 | void usrReadConfig(); |
97 | 97 | ||
98 | /** Write preferences to config file */ | 98 | /** Write preferences to config file */ |
99 | void usrWriteConfig(); | 99 | void usrWriteConfig(); |
100 | void setCategoryDefaults(); | 100 | void setCategoryDefaults(); |
101 | void setAllDefaults(); | 101 | void setAllDefaults(); |
102 | KopiCalendarFile * getNewCalendar(); | 102 | KopiCalendarFile * getNewCalendar(); |
103 | KopiCalendarFile * getCalendar( int ); | 103 | KopiCalendarFile * getCalendar( int ); |
104 | void deleteCalendar( int ); | 104 | void deleteCalendar( int ); |
105 | QColor defaultColor( int ) const; | 105 | QColor defaultColor( int ) const; |
106 | QString calName( int ) const; | 106 | QString calName( int ) const; |
107 | int getCalendarID( const QString & name ); | 107 | int getCalendarID( const QString & name ); |
108 | int getFuzzyCalendarID( const QString & name ); | ||
108 | protected: | 109 | protected: |
109 | void setTimeZoneIdDefault(); | 110 | void setTimeZoneIdDefault(); |
110 | 111 | ||
111 | /** Fill empty mail fields with default values. */ | 112 | /** Fill empty mail fields with default values. */ |
112 | void fillMailDefaults(); | 113 | void fillMailDefaults(); |
113 | 114 | ||
114 | private: | 115 | private: |
115 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 116 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
116 | object. */ | 117 | object. */ |
117 | KOPrefs(); | 118 | KOPrefs(); |
118 | 119 | ||
119 | static KOPrefs *mInstance; | 120 | static KOPrefs *mInstance; |
120 | QStringList getDefaultList(); | 121 | QStringList getDefaultList(); |
121 | QStringList getLocationDefaultList(); | 122 | QStringList getLocationDefaultList(); |
122 | public: | 123 | public: |
123 | // preferences data | 124 | // preferences data |
124 | KConfig* getConfig(); | 125 | KConfig* getConfig(); |
125 | void setFullName(const QString &); | 126 | void setFullName(const QString &); |
126 | QString fullName(); | 127 | QString fullName(); |
127 | void setEmail(const QString &); | 128 | void setEmail(const QString &); |
128 | QString email(); | 129 | QString email(); |
129 | 130 | ||
130 | QString mAdditional; | 131 | QString mAdditional; |
131 | 132 | ||
132 | bool mEmailControlCenter; | 133 | bool mEmailControlCenter; |
133 | 134 | ||
134 | bool mBcc; | 135 | bool mBcc; |
135 | bool mAutoSave; | 136 | bool mAutoSave; |
136 | int mAutoSaveInterval; | 137 | int mAutoSaveInterval; |
137 | bool mConfirm; | 138 | bool mConfirm; |
138 | 139 | ||
139 | bool mEnableGroupScheduling; | 140 | bool mEnableGroupScheduling; |
140 | bool mEnableProjectView; | 141 | bool mEnableProjectView; |
141 | 142 | ||
142 | int mDefaultFormat; | 143 | int mDefaultFormat; |
143 | int mMailClient; | 144 | int mMailClient; |
144 | 145 | ||
145 | int mStartTime; | 146 | int mStartTime; |
146 | int mDefaultDuration; | 147 | int mDefaultDuration; |
147 | int mAlarmTime; | 148 | int mAlarmTime; |
148 | 149 | ||
149 | int mWorkingHoursStart; | 150 | int mWorkingHoursStart; |
150 | int mWorkingHoursEnd; | 151 | int mWorkingHoursEnd; |
151 | bool mExcludeHolidays; | 152 | bool mExcludeHolidays; |
152 | bool mExcludeSaturdays; | 153 | bool mExcludeSaturdays; |
153 | bool mMarcusBainsShowSeconds; | 154 | bool mMarcusBainsShowSeconds; |
154 | 155 | ||
155 | QFont mTimeBarFont; | 156 | QFont mTimeBarFont; |
156 | QFont mMonthViewFont; | 157 | QFont mMonthViewFont; |
157 | QFont mAgendaViewFont; | 158 | QFont mAgendaViewFont; |
158 | QFont mMarcusBainsFont; | 159 | QFont mMarcusBainsFont; |
159 | QFont mTimeLabelsFont; | 160 | QFont mTimeLabelsFont; |
160 | QFont mTodoViewFont; | 161 | QFont mTodoViewFont; |
161 | QFont mListViewFont; | 162 | QFont mListViewFont; |
162 | QFont mDateNavigatorFont; | 163 | QFont mDateNavigatorFont; |
163 | QFont mEditBoxFont; | 164 | QFont mEditBoxFont; |
164 | QFont mJornalViewFont; | 165 | QFont mJornalViewFont; |
165 | QFont mWhatsNextFont; | 166 | QFont mWhatsNextFont; |
166 | QFont mEventViewFont; | 167 | QFont mEventViewFont; |
167 | 168 | ||
168 | 169 | ||
169 | 170 | ||
170 | 171 | ||
171 | QColor mHolidayColor; | 172 | QColor mHolidayColor; |
172 | QColor mHighlightColor; | 173 | QColor mHighlightColor; |
173 | QColor mEventColor; | 174 | QColor mEventColor; |
174 | QColor mTodoDoneColor; | 175 | QColor mTodoDoneColor; |
175 | QColor mAgendaBgColor; | 176 | QColor mAgendaBgColor; |
176 | QColor mWorkingHoursColor; | 177 | QColor mWorkingHoursColor; |
177 | QColor mTodoDueTodayColor; | 178 | QColor mTodoDueTodayColor; |
178 | QColor mTodoOverdueColor; | 179 | QColor mTodoOverdueColor; |
179 | QColor mTodoRunColor; | 180 | QColor mTodoRunColor; |
180 | QColor mMonthViewEvenColor; | 181 | QColor mMonthViewEvenColor; |
181 | QColor mMonthViewOddColor; | 182 | QColor mMonthViewOddColor; |
182 | QColor mMonthViewHolidayColor; | 183 | QColor mMonthViewHolidayColor; |
183 | bool mMonthViewUsesDayColors; | 184 | bool mMonthViewUsesDayColors; |
184 | bool mMonthViewSatSunTog; | 185 | bool mMonthViewSatSunTog; |
185 | bool mMonthViewWeek; | 186 | bool mMonthViewWeek; |
186 | bool mMonthViewWeekRowlayout; | 187 | bool mMonthViewWeekRowlayout; |
187 | QColor mAppColor1; | 188 | QColor mAppColor1; |
188 | QColor mAppColor2; | 189 | QColor mAppColor2; |
189 | bool mUseAppColors; | 190 | bool mUseAppColors; |
190 | 191 | ||
191 | int mDayBegins; | 192 | int mDayBegins; |
192 | int mHourSize; | 193 | int mHourSize; |
193 | int mAllDaySize; | 194 | int mAllDaySize; |
194 | bool mShowFullMenu; | 195 | bool mShowFullMenu; |
195 | bool mDailyRecur; | 196 | bool mDailyRecur; |
196 | bool mWeeklyRecur; | 197 | bool mWeeklyRecur; |
197 | bool mLongAllday; | 198 | bool mLongAllday; |
198 | bool mMonthDailyRecur; | 199 | bool mMonthDailyRecur; |
199 | bool mMonthWeeklyRecur; | 200 | bool mMonthWeeklyRecur; |
200 | bool mMonthShowIcons; | 201 | bool mMonthShowIcons; |
201 | bool mMonthShowTimes; | 202 | bool mMonthShowTimes; |
202 | bool mMonthShowShort; | 203 | bool mMonthShowShort; |
203 | bool mEnableToolTips; | 204 | bool mEnableToolTips; |
204 | bool mEnableMonthScroll; | 205 | bool mEnableMonthScroll; |
205 | bool mFullViewMonth; | 206 | bool mFullViewMonth; |
206 | bool mMonthViewUsesCategoryColor; | 207 | bool mMonthViewUsesCategoryColor; |
207 | bool mFullViewTodo; | 208 | bool mFullViewTodo; |
208 | bool mShowCompletedTodo; | 209 | bool mShowCompletedTodo; |
209 | bool mMarcusBainsEnabled; | 210 | bool mMarcusBainsEnabled; |
210 | int mNextXDays; | 211 | int mNextXDays; |
211 | int mWhatsNextDays; | 212 | int mWhatsNextDays; |
212 | bool mWhatsNextTime2Lines; | 213 | bool mWhatsNextTime2Lines; |
213 | int mWhatsNextPrios; | 214 | int mWhatsNextPrios; |
214 | bool mEnableQuickTodo; | 215 | bool mEnableQuickTodo; |
215 | 216 | ||
216 | bool mCompactDialogs; | 217 | bool mCompactDialogs; |
217 | bool mVerticalScreen; | 218 | bool mVerticalScreen; |
218 | 219 | ||
219 | bool mShowIconNewTodo; | 220 | bool mShowIconNewTodo; |
220 | bool mShowIconNewEvent; | 221 | bool mShowIconNewEvent; |
221 | bool mShowIconSearch; | 222 | bool mShowIconSearch; |
222 | bool mShowIconList; | 223 | bool mShowIconList; |
223 | bool mShowIconDay1; | 224 | bool mShowIconDay1; |
224 | bool mShowIconDay5; | 225 | bool mShowIconDay5; |
225 | bool mShowIconDay6; | 226 | bool mShowIconDay6; |
226 | bool mShowIconDay7; | 227 | bool mShowIconDay7; |
227 | bool mShowIconMonth; | 228 | bool mShowIconMonth; |
228 | bool mShowIconTodoview; | 229 | bool mShowIconTodoview; |
229 | bool mShowIconBackFast; | 230 | bool mShowIconBackFast; |
230 | bool mShowIconBack; | 231 | bool mShowIconBack; |
231 | bool mShowIconToday; | 232 | bool mShowIconToday; |
232 | bool mShowIconForward; | 233 | bool mShowIconForward; |
233 | bool mShowIconForwardFast; | 234 | bool mShowIconForwardFast; |
234 | bool mShowIconWhatsThis; | 235 | bool mShowIconWhatsThis; |
235 | bool mShowIconWeekNum; | 236 | bool mShowIconWeekNum; |
236 | bool mShowIconNextDays; | 237 | bool mShowIconNextDays; |
237 | bool mShowIconNext; | 238 | bool mShowIconNext; |
238 | bool mShowIconJournal; | 239 | bool mShowIconJournal; |
239 | bool mShowIconFilter; | 240 | bool mShowIconFilter; |
240 | bool mShowIconOnetoolbar; | 241 | bool mShowIconOnetoolbar; |
241 | bool mShowIconNavigator; | 242 | bool mShowIconNavigator; |
242 | bool mShowIconAllday; | 243 | bool mShowIconAllday; |
243 | bool mShowIconFilterview; | 244 | bool mShowIconFilterview; |
244 | bool mShowIconToggleFull; | 245 | bool mShowIconToggleFull; |
245 | 246 | ||
246 | bool mShowIconStretch; | 247 | bool mShowIconStretch; |
247 | 248 | ||
248 | bool mToolBarHor; | 249 | bool mToolBarHor; |
249 | bool mToolBarUp; | 250 | bool mToolBarUp; |
250 | bool mToolBarHorV; | 251 | bool mToolBarHorV; |
251 | bool mToolBarUpV; | 252 | bool mToolBarUpV; |
252 | bool mToolBarHorN; | 253 | bool mToolBarHorN; |
253 | bool mToolBarUpN; | 254 | bool mToolBarUpN; |
254 | bool mToolBarHorF; | 255 | bool mToolBarHorF; |
255 | bool mToolBarUpF; | 256 | bool mToolBarUpF; |
256 | bool mToolBarMiniIcons; | 257 | bool mToolBarMiniIcons; |
257 | 258 | ||
258 | bool mAskForQuit; | 259 | bool mAskForQuit; |
259 | bool mUsePassWd; | 260 | bool mUsePassWd; |
260 | bool mShowSyncEvents; | 261 | bool mShowSyncEvents; |
261 | bool mShowTodoInAgenda; | 262 | bool mShowTodoInAgenda; |
262 | bool mShowCompletedTodoInAgenda; | 263 | bool mShowCompletedTodoInAgenda; |
263 | bool mShowTimeInAgenda; | 264 | bool mShowTimeInAgenda; |
264 | bool mHideNonStartedTodos; | 265 | bool mHideNonStartedTodos; |
265 | 266 | ||
266 | bool mBlockPopupMenu; | 267 | bool mBlockPopupMenu; |
267 | 268 | ||
268 | int mLastSyncTime; | 269 | int mLastSyncTime; |
269 | void setCategoryColor(QString cat,const QColor & color); | 270 | void setCategoryColor(QString cat,const QColor & color); |
270 | QColor *categoryColor(QString cat); | 271 | QColor *categoryColor(QString cat); |
271 | 272 | ||
272 | QString mArchiveFile; | 273 | QString mArchiveFile; |
273 | QString mHtmlExportFile; | 274 | QString mHtmlExportFile; |
274 | bool mHtmlWithSave; | 275 | bool mHtmlWithSave; |
275 | 276 | ||
276 | QStringList mSelectedPlugins; | 277 | QStringList mSelectedPlugins; |
277 | 278 | ||
278 | QString mLastImportFile; | 279 | QString mLastImportFile; |
279 | QString mLastVcalFile; | 280 | QString mLastVcalFile; |
280 | QString mLastSaveFile; | 281 | QString mLastSaveFile; |
281 | QString mLastLoadFile; | 282 | QString mLastLoadFile; |
282 | 283 | ||
283 | 284 | ||
284 | QString mDefaultAlarmFile; | 285 | QString mDefaultAlarmFile; |
285 | int mIMIPScheduler; | 286 | int mIMIPScheduler; |
286 | int mIMIPSend; | 287 | int mIMIPSend; |
287 | QStringList mAdditionalMails; | 288 | QStringList mAdditionalMails; |
288 | int mIMIPAutoRefresh; | 289 | int mIMIPAutoRefresh; |
289 | int mIMIPAutoInsertReply; | 290 | int mIMIPAutoInsertReply; |
290 | int mIMIPAutoInsertRequest; | 291 | int mIMIPAutoInsertRequest; |
291 | int mIMIPAutoFreeBusy; | 292 | int mIMIPAutoFreeBusy; |
292 | int mIMIPAutoFreeBusyReply; | 293 | int mIMIPAutoFreeBusyReply; |
293 | 294 | ||
294 | QStringList mTodoTemplates; | 295 | QStringList mTodoTemplates; |
295 | QStringList mEventTemplates; | 296 | QStringList mEventTemplates; |
296 | 297 | ||
297 | int mDestination; | 298 | int mDestination; |
298 | 299 | ||
299 | 300 | ||
300 | bool mEditOnDoubleClick; | 301 | bool mEditOnDoubleClick; |
301 | bool mViewChangeHoldFullscreen; | 302 | bool mViewChangeHoldFullscreen; |
302 | bool mViewChangeHoldNonFullscreen; | 303 | bool mViewChangeHoldNonFullscreen; |
303 | bool mCenterOnCurrentTime; | 304 | bool mCenterOnCurrentTime; |
304 | bool mSetTimeToDayStartAt; | 305 | bool mSetTimeToDayStartAt; |
305 | bool mHighlightCurrentDay; | 306 | bool mHighlightCurrentDay; |
306 | bool mUseHighlightLightColor; | 307 | bool mUseHighlightLightColor; |
307 | bool mListViewMonthTimespan; | 308 | bool mListViewMonthTimespan; |
308 | bool mWNViewShowsParents; | 309 | bool mWNViewShowsParents; |
309 | bool mWNViewShowsPast; | 310 | bool mWNViewShowsPast; |
310 | bool mWNViewShowLocation; | 311 | bool mWNViewShowLocation; |
311 | bool mTodoViewShowsPercentage; | 312 | bool mTodoViewShowsPercentage; |
312 | bool mTodoViewUsesCatColors; | 313 | bool mTodoViewUsesCatColors; |
313 | bool mMonthViewUsesBigFont; | 314 | bool mMonthViewUsesBigFont; |
314 | bool mTodoViewUsesSmallFont; | 315 | bool mTodoViewUsesSmallFont; |
315 | bool mTodoViewUsesForegroundColor; | 316 | bool mTodoViewUsesForegroundColor; |
316 | bool mMonthViewUsesForegroundColor; | 317 | bool mMonthViewUsesForegroundColor; |
317 | 318 | ||
318 | bool mHightlightDateTimeEdit; | 319 | bool mHightlightDateTimeEdit; |
319 | bool mShortDateInViewer; | 320 | bool mShortDateInViewer; |
320 | 321 | ||
321 | bool mShowDateNavigator; | 322 | bool mShowDateNavigator; |
322 | 323 | ||
323 | QStringList mLocationDefaults; | 324 | QStringList mLocationDefaults; |
324 | QStringList mEventSummaryUser; | 325 | QStringList mEventSummaryUser; |
325 | QStringList mTodoSummaryUser; | 326 | QStringList mTodoSummaryUser; |
326 | QStringList mJournalSummaryUser; | 327 | QStringList mJournalSummaryUser; |
327 | 328 | ||
328 | bool mUseInternalAlarmNotification; | 329 | bool mUseInternalAlarmNotification; |
329 | int mAlarmPlayBeeps; | 330 | int mAlarmPlayBeeps; |
330 | int mAlarmSuspendTime; | 331 | int mAlarmSuspendTime; |
331 | int mAlarmSuspendCount; | 332 | int mAlarmSuspendCount; |
332 | int mAlarmBeepInterval; | 333 | int mAlarmBeepInterval; |
333 | int mOldLanguage; | 334 | int mOldLanguage; |
334 | int mOldLoadedLanguage; | 335 | int mOldLoadedLanguage; |
335 | 336 | ||
336 | 337 | ||
337 | QString mActiveSyncPort; | 338 | QString mActiveSyncPort; |
338 | QString mActiveSyncIP; | 339 | QString mActiveSyncIP; |
339 | 340 | ||
340 | // settings for eventviewer | 341 | // settings for eventviewer |
341 | bool mEVshowDetails; | 342 | bool mEVshowDetails; |
342 | bool mEVshowCreated; | 343 | bool mEVshowCreated; |
343 | bool mEVshowChanged; | 344 | bool mEVshowChanged; |
344 | bool mWTshowDetails; | 345 | bool mWTshowDetails; |
345 | bool mWTshowCreated; | 346 | bool mWTshowCreated; |
346 | bool mWTshowChanged; | 347 | bool mWTshowChanged; |
347 | 348 | ||
348 | int mCurrentDisplayedView; | 349 | int mCurrentDisplayedView; |
349 | QPtrList<KopiCalendarFile> mCalendars; | 350 | QPtrList<KopiCalendarFile> mCalendars; |
350 | int mNextAvailableCalendar; | 351 | int mNextAvailableCalendar; |
351 | bool mGlobalUpdateDisabled; | 352 | bool mGlobalUpdateDisabled; |
352 | 353 | ||
353 | 354 | ||
354 | bool mDetectConflicts; | 355 | bool mDetectConflicts; |
355 | bool mIncludeFree; | 356 | bool mIncludeFree; |
356 | bool mCheckConflictsAllDayAllDay; | 357 | bool mCheckConflictsAllDayAllDay; |
357 | bool mCheckConflictsAllDayNonAD; | 358 | bool mCheckConflictsAllDayNonAD; |
358 | bool mCheckConflictsNonADAllDay; | 359 | bool mCheckConflictsNonADAllDay; |
359 | bool mCheckConflictsNonADNonAD; | 360 | bool mCheckConflictsNonADNonAD; |
360 | QString mFilterConflictEditItem; | 361 | QString mFilterConflictEditItem; |
361 | QString mFilterConflictAllItem; | 362 | QString mFilterConflictAllItem; |
362 | 363 | ||
363 | private: | 364 | private: |
364 | QDict<QColor> mCategoryColors; | 365 | QDict<QColor> mCategoryColors; |
365 | QArray<KopiCalendarFile*> mDefCalColors; | 366 | QArray<KopiCalendarFile*> mDefCalColors; |
366 | QColor mDefaultCategoryColor; | 367 | QColor mDefaultCategoryColor; |
367 | 368 | ||
368 | QFont mDefaultTimeBarFont; | 369 | QFont mDefaultTimeBarFont; |
369 | QFont mDefaultViewFont; | 370 | QFont mDefaultViewFont; |
370 | QFont mDefaultMonthViewFont; | 371 | QFont mDefaultMonthViewFont; |
371 | 372 | ||
372 | QString mName; | 373 | QString mName; |
373 | QString mEmail; | 374 | QString mEmail; |
374 | }; | 375 | }; |
375 | 376 | ||
376 | #endif | 377 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index d71264f..a64eb34 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1720 +1,1751 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | #include <qapplication.h> | 52 | #include <qapplication.h> |
53 | 53 | ||
54 | #include <klocale.h> | 54 | #include <klocale.h> |
55 | #include <kglobal.h> | 55 | #include <kglobal.h> |
56 | #include <kconfig.h> | 56 | #include <kconfig.h> |
57 | #include <kfiledialog.h> | 57 | #include <kfiledialog.h> |
58 | 58 | ||
59 | QDateTime KSyncManager::mRequestedSyncEvent; | 59 | QDateTime KSyncManager::mRequestedSyncEvent; |
60 | 60 | ||
61 | 61 | ||
62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) | 63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
64 | { | 64 | { |
65 | mServerSocket = 0; | 65 | mServerSocket = 0; |
66 | bar = new QProgressBar ( 1, 0 ); | 66 | bar = new QProgressBar ( 1, 0 ); |
67 | bar->setCaption (""); | 67 | bar->setCaption (""); |
68 | mWriteBackInPast = 2; | 68 | mWriteBackInPast = 2; |
69 | 69 | ||
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | KSyncManager::~KSyncManager() | 73 | KSyncManager::~KSyncManager() |
74 | { | 74 | { |
75 | delete bar; | 75 | delete bar; |
76 | } | 76 | } |
77 | 77 | ||
78 | void KSyncManager::setDefaultFileName( QString s) | 78 | void KSyncManager::setDefaultFileName( QString s) |
79 | { | 79 | { |
80 | mDefFileName = s ; | 80 | mDefFileName = s ; |
81 | if ( mPrefs->mPassiveSyncAutoStart ) | 81 | if ( mPrefs->mPassiveSyncAutoStart ) |
82 | enableQuick( false ); | 82 | enableQuick( false ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void KSyncManager::fillSyncMenu() | 85 | void KSyncManager::fillSyncMenu() |
86 | { | 86 | { |
87 | if ( mSyncMenu->count() ) | 87 | if ( mSyncMenu->count() ) |
88 | mSyncMenu->clear(); | 88 | mSyncMenu->clear(); |
89 | 89 | ||
90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
91 | mSyncMenu->insertSeparator(); | 91 | mSyncMenu->insertSeparator(); |
92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
95 | clearMenu->insertSeparator(); | 95 | clearMenu->insertSeparator(); |
96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
97 | mSyncMenu->insertSeparator(); | 97 | mSyncMenu->insertSeparator(); |
98 | if ( mServerSocket == 0 ) { | 98 | if ( mServerSocket == 0 ) { |
99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
100 | } else { | 100 | } else { |
101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
102 | } | 102 | } |
103 | mSyncMenu->insertSeparator(); | 103 | mSyncMenu->insertSeparator(); |
104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
105 | mSyncMenu->insertSeparator(); | 105 | mSyncMenu->insertSeparator(); |
106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
107 | config.setGroup("General"); | 107 | config.setGroup("General"); |
108 | QStringList prof = config.readListEntry("SyncProfileNames"); | 108 | QStringList prof = config.readListEntry("SyncProfileNames"); |
109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
110 | if ( prof.count() < 2 ) { | 110 | if ( prof.count() < 2 ) { |
111 | prof.clear(); | 111 | prof.clear(); |
112 | QString externalName; | 112 | QString externalName; |
113 | #ifdef DESKTOP_VERSION | 113 | #ifdef DESKTOP_VERSION |
114 | #ifdef _WIN32_ | 114 | #ifdef _WIN32_ |
115 | externalName = "OutLook(not_implemented)"; | 115 | externalName = "OutLook(not_implemented)"; |
116 | #else | 116 | #else |
117 | externalName = "KDE_Desktop"; | 117 | externalName = "KDE_Desktop"; |
118 | #endif | 118 | #endif |
119 | #else | 119 | #else |
120 | externalName = "Sharp_DTM"; | 120 | externalName = "Sharp_DTM"; |
121 | #endif | 121 | #endif |
122 | prof << externalName; | 122 | prof << externalName; |
123 | prof << i18n("Local_file"); | 123 | prof << i18n("Local_file"); |
124 | prof << i18n("Last_file"); | 124 | prof << i18n("Last_file"); |
125 | KSyncProfile* temp = new KSyncProfile (); | 125 | KSyncProfile* temp = new KSyncProfile (); |
126 | temp->setName( prof[0] ); | 126 | temp->setName( prof[0] ); |
127 | temp->writeConfig(&config); | 127 | temp->writeConfig(&config); |
128 | temp->setName( prof[1] ); | 128 | temp->setName( prof[1] ); |
129 | temp->writeConfig(&config); | 129 | temp->writeConfig(&config); |
130 | temp->setName( prof[2] ); | 130 | temp->setName( prof[2] ); |
131 | temp->writeConfig(&config); | 131 | temp->writeConfig(&config); |
132 | config.setGroup("General"); | 132 | config.setGroup("General"); |
133 | config.writeEntry("SyncProfileNames",prof); | 133 | config.writeEntry("SyncProfileNames",prof); |
134 | config.writeEntry("ExternSyncProfiles",externalName); | 134 | config.writeEntry("ExternSyncProfiles",externalName); |
135 | config.sync(); | 135 | config.sync(); |
136 | delete temp; | 136 | delete temp; |
137 | } | 137 | } |
138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
139 | mSyncProfileNames = prof; | 139 | mSyncProfileNames = prof; |
140 | unsigned int i; | 140 | unsigned int i; |
141 | for ( i = 0; i < prof.count(); ++i ) { | 141 | for ( i = 0; i < prof.count(); ++i ) { |
142 | QString insertText = prof[i]; | 142 | QString insertText = prof[i]; |
143 | if ( i == 0 ) { | 143 | if ( i == 0 ) { |
144 | #ifdef DESKTOP_VERSION | 144 | #ifdef DESKTOP_VERSION |
145 | #ifdef _WIN32_ | 145 | #ifdef _WIN32_ |
146 | insertText = "OutLook(not_implemented)"; | 146 | insertText = "OutLook(not_implemented)"; |
147 | #else | 147 | #else |
148 | insertText = "KDE_Desktop"; | 148 | insertText = "KDE_Desktop"; |
149 | #endif | 149 | #endif |
150 | #else | 150 | #else |
151 | insertText = "Sharp_DTM"; | 151 | insertText = "Sharp_DTM"; |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | mSyncMenu->insertItem( insertText, 1000+i ); | 154 | mSyncMenu->insertItem( insertText, 1000+i ); |
155 | clearMenu->insertItem( insertText, 1000+i ); | 155 | clearMenu->insertItem( insertText, 1000+i ); |
156 | if ( i == 2 ) | 156 | if ( i == 2 ) |
157 | mSyncMenu->insertSeparator(); | 157 | mSyncMenu->insertSeparator(); |
158 | } | 158 | } |
159 | QDir app_dir; | 159 | QDir app_dir; |
160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
161 | if ( mTargetApp == PWMPI) { | 161 | if ( mTargetApp == PWMPI) { |
162 | mSyncMenu->removeItem( 1000 ); | 162 | mSyncMenu->removeItem( 1000 ); |
163 | clearMenu->removeItem( 1000 ); | 163 | clearMenu->removeItem( 1000 ); |
164 | } | 164 | } |
165 | #ifndef DESKTOP_VERSION | 165 | #ifndef DESKTOP_VERSION |
166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
167 | mSyncMenu->removeItem( 1000 ); | 167 | mSyncMenu->removeItem( 1000 ); |
168 | clearMenu->removeItem( 1000 ); | 168 | clearMenu->removeItem( 1000 ); |
169 | } | 169 | } |
170 | #endif | 170 | #endif |
171 | mSyncMenu->removeItem( 1002 ); | 171 | mSyncMenu->removeItem( 1002 ); |
172 | clearMenu->removeItem( 1002 ); | 172 | clearMenu->removeItem( 1002 ); |
173 | } | 173 | } |
174 | void KSyncManager::slotClearMenu( int action ) | 174 | void KSyncManager::slotClearMenu( int action ) |
175 | { | 175 | { |
176 | QString syncDevice; | 176 | QString syncDevice; |
177 | if ( action > 999 ) { | 177 | if ( action > 999 ) { |
178 | syncDevice = mSyncProfileNames[action - 1000] ; | 178 | syncDevice = mSyncProfileNames[action - 1000] ; |
179 | } | 179 | } |
180 | 180 | ||
181 | 181 | ||
182 | 182 | ||
183 | int result = 0; | 183 | int result = 0; |
184 | QString sd; | 184 | QString sd; |
185 | if ( syncDevice.isEmpty() ) | 185 | if ( syncDevice.isEmpty() ) |
186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
187 | else | 187 | else |
188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
189 | 189 | ||
190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
191 | 0, 1 ); | 191 | 0, 1 ); |
192 | if ( result ) | 192 | if ( result ) |
193 | return; | 193 | return; |
194 | mImplementation->removeSyncInfo( syncDevice ); | 194 | mImplementation->removeSyncInfo( syncDevice ); |
195 | } | 195 | } |
196 | void KSyncManager::slotSyncMenu( int action ) | 196 | void KSyncManager::slotSyncMenu( int action ) |
197 | { | 197 | { |
198 | qDebug("KSM::syncaction %d ", action); | 198 | qDebug("KSM::syncaction %d ", action); |
199 | mCurrentResourceLocal = ""; | ||
199 | if ( action == 5000 ) | 200 | if ( action == 5000 ) |
200 | return; | 201 | return; |
201 | mSyncWithDesktop = false; | 202 | mSyncWithDesktop = false; |
202 | if ( action == 0 ) { | 203 | if ( action == 0 ) { |
203 | 204 | ||
204 | // seems to be a Qt2 event handling bug | 205 | // seems to be a Qt2 event handling bug |
205 | // syncmenu.clear causes a segfault at first time | 206 | // syncmenu.clear causes a segfault at first time |
206 | // when we call it after the main event loop, it is ok | 207 | // when we call it after the main event loop, it is ok |
207 | // same behaviour when calling OM/Pi via QCOP for the first time | 208 | // same behaviour when calling OM/Pi via QCOP for the first time |
208 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 209 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
209 | //confSync(); | 210 | //confSync(); |
210 | 211 | ||
211 | return; | 212 | return; |
212 | } | 213 | } |
213 | if ( action == 1 ) { | 214 | if ( action == 1 ) { |
214 | multiSync( true ); | 215 | multiSync( true ); |
215 | return; | 216 | return; |
216 | } | 217 | } |
217 | if ( action == 2 ) { | 218 | if ( action == 2 ) { |
218 | enableQuick(); | 219 | enableQuick(); |
219 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 220 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
220 | return; | 221 | return; |
221 | } | 222 | } |
222 | if ( action == 3 ) { | 223 | if ( action == 3 ) { |
223 | delete mServerSocket; | 224 | delete mServerSocket; |
224 | mServerSocket = 0; | 225 | mServerSocket = 0; |
225 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 226 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
226 | return; | 227 | return; |
227 | } | 228 | } |
228 | 229 | ||
229 | if (blockSave()) | 230 | if (blockSave()) |
230 | return; | 231 | return; |
231 | 232 | ||
232 | setBlockSave(true); | 233 | setBlockSave(true); |
233 | bool silent = false; | 234 | bool silent = false; |
234 | if ( action == 999 ) { | 235 | if ( action == 999 ) { |
235 | //special mode for silent syncing | 236 | //special mode for silent syncing |
236 | action = 1000; | 237 | action = 1000; |
237 | silent = true; | 238 | silent = true; |
238 | } | 239 | } |
239 | 240 | ||
240 | mCurrentSyncProfile = action - 1000 ; | 241 | mCurrentSyncProfile = action - 1000 ; |
241 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 242 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
242 | mCurrentSyncName = mLocalMachineName ; | 243 | mCurrentSyncName = mLocalMachineName ; |
243 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 244 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
244 | KSyncProfile* temp = new KSyncProfile (); | 245 | KSyncProfile* temp = new KSyncProfile (); |
245 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 246 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
246 | temp->readConfig(&config); | 247 | temp->readConfig(&config); |
247 | if (silent) { | 248 | if (silent) { |
248 | mAskForPreferences = false; | 249 | mAskForPreferences = false; |
249 | mShowSyncSummary = false; | 250 | mShowSyncSummary = false; |
250 | mWriteBackFile = true; | 251 | mWriteBackFile = true; |
251 | mSyncAlgoPrefs = 2;// take newest | 252 | mSyncAlgoPrefs = 2;// take newest |
252 | } | 253 | } |
253 | else { | 254 | else { |
254 | mAskForPreferences = temp->getAskForPreferences(); | 255 | mAskForPreferences = temp->getAskForPreferences(); |
255 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 256 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
256 | mWriteBackFile = temp->getWriteBackFile(); | 257 | mWriteBackFile = temp->getWriteBackFile(); |
257 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 258 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
258 | } | 259 | } |
259 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 260 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
260 | mIsKapiFile = temp->getIsKapiFile(); | 261 | mIsKapiFile = temp->getIsKapiFile(); |
261 | mWriteBackInFuture = 0; | 262 | mWriteBackInFuture = 0; |
262 | if ( temp->getWriteBackFuture() ) { | 263 | if ( temp->getWriteBackFuture() ) { |
263 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 264 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
264 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 265 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
265 | } | 266 | } |
266 | mFilterInCal = temp->getFilterInCal(); | 267 | mFilterInCal = temp->getFilterInCal(); |
267 | mFilterOutCal = temp->getFilterOutCal(); | 268 | mFilterOutCal = temp->getFilterOutCal(); |
268 | mFilterInAB = temp->getFilterInAB(); | 269 | mFilterInAB = temp->getFilterInAB(); |
269 | mFilterOutAB = temp->getFilterOutAB(); | 270 | mFilterOutAB = temp->getFilterOutAB(); |
270 | 271 | ||
271 | if ( action == 1000 ) { | 272 | if ( action == 1000 ) { |
272 | mIsKapiFile = false; | 273 | mIsKapiFile = false; |
273 | #ifdef DESKTOP_VERSION | 274 | #ifdef DESKTOP_VERSION |
274 | syncKDE(); | 275 | syncKDE(); |
275 | #else | 276 | #else |
276 | syncSharp(); | 277 | syncSharp(); |
277 | #endif | 278 | #endif |
278 | 279 | ||
279 | } else if ( action == 1001 ) { | 280 | } else if ( action == 1001 ) { |
280 | syncLocalFile(); | 281 | syncLocalFile(); |
281 | 282 | ||
282 | } else if ( action == 1002 ) { | 283 | } else if ( action == 1002 ) { |
283 | mWriteBackFile = false; | 284 | mWriteBackFile = false; |
284 | mAskForPreferences = false; | 285 | mAskForPreferences = false; |
285 | mShowSyncSummary = false; | 286 | mShowSyncSummary = false; |
286 | mSyncAlgoPrefs = 3; | 287 | mSyncAlgoPrefs = 3; |
287 | quickSyncLocalFile(); | 288 | quickSyncLocalFile(); |
288 | 289 | ||
289 | } else if ( action >= 1003 ) { | 290 | } else if ( action >= 1003 ) { |
290 | if ( temp->getIsLocalFileSync() ) { | 291 | if ( temp->getIsLocalFileSync() ) { |
291 | switch(mTargetApp) | 292 | switch(mTargetApp) |
292 | { | 293 | { |
293 | case (KAPI): | 294 | case (KAPI): |
294 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 295 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
295 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 296 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
296 | break; | 297 | break; |
297 | case (KOPI): | 298 | case (KOPI): |
298 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 299 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
299 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 300 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
300 | break; | 301 | break; |
301 | case (PWMPI): | 302 | case (PWMPI): |
302 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 303 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
303 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 304 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
304 | break; | 305 | break; |
305 | default: | 306 | default: |
306 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 307 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
307 | break; | 308 | break; |
308 | 309 | ||
309 | } | 310 | } |
310 | } else { | 311 | } else { |
311 | if ( temp->getIsPhoneSync() ) { | 312 | if ( temp->getIsPhoneSync() ) { |
312 | mPhoneDevice = temp->getPhoneDevice( ) ; | 313 | mPhoneDevice = temp->getPhoneDevice( ) ; |
313 | mPhoneConnection = temp->getPhoneConnection( ); | 314 | mPhoneConnection = temp->getPhoneConnection( ); |
314 | mPhoneModel = temp->getPhoneModel( ); | 315 | mPhoneModel = temp->getPhoneModel( ); |
315 | syncPhone(); | 316 | syncPhone(); |
316 | } else if ( temp->getIsPiSync() ) { | 317 | } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { |
318 | mSpecificResources.clear(); | ||
317 | if ( mTargetApp == KAPI ) { | 319 | if ( mTargetApp == KAPI ) { |
318 | mPassWordPiSync = temp->getRemotePwAB(); | 320 | mPassWordPiSync = temp->getRemotePwAB(); |
319 | mActiveSyncPort = temp->getRemotePortAB(); | 321 | mActiveSyncPort = temp->getRemotePortAB(); |
320 | mActiveSyncIP = temp->getRemoteIPAB(); | 322 | mActiveSyncIP = temp->getRemoteIPAB(); |
321 | } else if ( mTargetApp == KOPI ) { | 323 | } else if ( mTargetApp == KOPI ) { |
324 | if ( temp->getIsPiSyncSpec() ) | ||
325 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() ); | ||
322 | mPassWordPiSync = temp->getRemotePw(); | 326 | mPassWordPiSync = temp->getRemotePw(); |
323 | mActiveSyncPort = temp->getRemotePort(); | 327 | mActiveSyncPort = temp->getRemotePort(); |
324 | mActiveSyncIP = temp->getRemoteIP(); | 328 | mActiveSyncIP = temp->getRemoteIP(); |
325 | } else { | 329 | } else { |
326 | mPassWordPiSync = temp->getRemotePwPWM(); | 330 | mPassWordPiSync = temp->getRemotePwPWM(); |
327 | mActiveSyncPort = temp->getRemotePortPWM(); | 331 | mActiveSyncPort = temp->getRemotePortPWM(); |
328 | mActiveSyncIP = temp->getRemoteIPPWM(); | 332 | mActiveSyncIP = temp->getRemoteIPPWM(); |
329 | } | 333 | } |
330 | syncPi(); | 334 | syncPi(); |
331 | while ( !mPisyncFinished ) { | 335 | while ( !mPisyncFinished ) { |
332 | //qDebug("waiting "); | 336 | //qDebug("waiting "); |
333 | qApp->processEvents(); | 337 | qApp->processEvents(); |
334 | } | 338 | } |
335 | } else | 339 | } else |
336 | syncRemote( temp ); | 340 | syncRemote( temp ); |
337 | 341 | ||
338 | } | 342 | } |
339 | } | 343 | } |
340 | delete temp; | 344 | delete temp; |
341 | setBlockSave(false); | 345 | setBlockSave(false); |
342 | } | 346 | } |
343 | 347 | ||
344 | void KSyncManager::enableQuick( bool ask ) | 348 | void KSyncManager::enableQuick( bool ask ) |
345 | { | 349 | { |
346 | bool autoStart; | 350 | bool autoStart; |
347 | bool changed = false; | 351 | bool changed = false; |
348 | if ( ask ) { | 352 | if ( ask ) { |
349 | QDialog dia ( 0, "input-dialog", true ); | 353 | QDialog dia ( 0, "input-dialog", true ); |
350 | QLineEdit lab ( &dia ); | 354 | QLineEdit lab ( &dia ); |
351 | QVBoxLayout lay( &dia ); | 355 | QVBoxLayout lay( &dia ); |
352 | lab.setText( mPrefs->mPassiveSyncPort ); | 356 | lab.setText( mPrefs->mPassiveSyncPort ); |
353 | lay.setMargin(7); | 357 | lay.setMargin(7); |
354 | lay.setSpacing(7); | 358 | lay.setSpacing(7); |
355 | int po = 9197+mTargetApp; | 359 | int po = 9197+mTargetApp; |
356 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); | 360 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); |
357 | lay.addWidget( &label); | 361 | lay.addWidget( &label); |
358 | lay.addWidget( &lab); | 362 | lay.addWidget( &lab); |
359 | 363 | ||
360 | QLineEdit lepw ( &dia ); | 364 | QLineEdit lepw ( &dia ); |
361 | lepw.setText( mPrefs->mPassiveSyncPw ); | 365 | lepw.setText( mPrefs->mPassiveSyncPw ); |
362 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 366 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
363 | lay.addWidget( &label2); | 367 | lay.addWidget( &label2); |
364 | lay.addWidget( &lepw); | 368 | lay.addWidget( &lepw); |
365 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 369 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
366 | lay.addWidget( &autostart); | 370 | lay.addWidget( &autostart); |
367 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 371 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
368 | #ifdef DESKTOP_VERSION | 372 | #ifdef DESKTOP_VERSION |
369 | #ifdef _WIN32_ | 373 | #ifdef _WIN32_ |
370 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 374 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
371 | syncdesktop.hide();// not implemented! | 375 | syncdesktop.hide();// not implemented! |
372 | #else | 376 | #else |
373 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 377 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
374 | #endif | 378 | #endif |
375 | lay.addWidget( &syncdesktop); | 379 | lay.addWidget( &syncdesktop); |
376 | #else | 380 | #else |
377 | mPrefs->mPassiveSyncWithDesktop = false; | 381 | mPrefs->mPassiveSyncWithDesktop = false; |
378 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 382 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
379 | syncdesktop.hide(); | 383 | syncdesktop.hide(); |
380 | #endif | 384 | #endif |
381 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 385 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
382 | 386 | ||
383 | QPushButton pb ( "OK", &dia); | 387 | QPushButton pb ( "OK", &dia); |
384 | lay.addWidget( &pb ); | 388 | lay.addWidget( &pb ); |
385 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 389 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
386 | dia.resize( 230,120 ); | 390 | dia.resize( 230,120 ); |
387 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 391 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
388 | dia.show(); | 392 | dia.show(); |
389 | #ifndef DESKTOP_VERSION | 393 | #ifndef DESKTOP_VERSION |
390 | int dw = QApplication::desktop()->width(); | 394 | int dw = QApplication::desktop()->width(); |
391 | int dh = QApplication::desktop()->height(); | 395 | int dh = QApplication::desktop()->height(); |
392 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); | 396 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); |
393 | #endif | 397 | #endif |
394 | if ( ! dia.exec() ) | 398 | if ( ! dia.exec() ) |
395 | return; | 399 | return; |
396 | dia.hide(); | 400 | dia.hide(); |
397 | qApp->processEvents(); | 401 | qApp->processEvents(); |
398 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 402 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
399 | changed = true; | 403 | changed = true; |
400 | mPrefs->mPassiveSyncPw = lepw.text(); | 404 | mPrefs->mPassiveSyncPw = lepw.text(); |
401 | } | 405 | } |
402 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 406 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
403 | mPrefs->mPassiveSyncPort = lab.text(); | 407 | mPrefs->mPassiveSyncPort = lab.text(); |
404 | changed = true; | 408 | changed = true; |
405 | } | 409 | } |
406 | autoStart = autostart.isChecked(); | 410 | autoStart = autostart.isChecked(); |
407 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 411 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
408 | changed = true; | 412 | changed = true; |
409 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 413 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
410 | } | 414 | } |
411 | } | 415 | } |
412 | else | 416 | else |
413 | autoStart = mPrefs->mPassiveSyncAutoStart; | 417 | autoStart = mPrefs->mPassiveSyncAutoStart; |
414 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 418 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
415 | changed = true; | 419 | changed = true; |
416 | bool ok; | 420 | bool ok; |
417 | mPrefs->mPassiveSyncAutoStart = false; | 421 | mPrefs->mPassiveSyncAutoStart = false; |
418 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); | 422 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); |
419 | qDebug("%d ", port_t); | 423 | qDebug("%d ", port_t); |
420 | if ( ! ok || port_t > 65535 ) { | 424 | if ( ! ok || port_t > 65535 ) { |
421 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); | 425 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); |
422 | return; | 426 | return; |
423 | } | 427 | } |
424 | Q_UINT16 port = port_t; | 428 | Q_UINT16 port = port_t; |
425 | //qDebug("port %d ", port); | 429 | //qDebug("port %d ", port); |
426 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 430 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
427 | mServerSocket->setFileName( defaultFileName() );//bbb | 431 | mServerSocket->setFileName( defaultFileName() );//bbb |
428 | if ( !mServerSocket->ok() ) { | 432 | if ( !mServerSocket->ok() ) { |
429 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); | 433 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); |
430 | delete mServerSocket; | 434 | delete mServerSocket; |
431 | mServerSocket = 0; | 435 | mServerSocket = 0; |
432 | return; | 436 | return; |
433 | } | 437 | } |
434 | mPrefs->mPassiveSyncAutoStart = autoStart; | 438 | mPrefs->mPassiveSyncAutoStart = autoStart; |
435 | if ( changed ) { | 439 | if ( changed ) { |
436 | mPrefs->writeConfig(); | 440 | mPrefs->writeConfig(); |
437 | } | 441 | } |
438 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 442 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
439 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 443 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
440 | } | 444 | } |
441 | void KSyncManager::displayErrorPort() | 445 | void KSyncManager::displayErrorPort() |
442 | { | 446 | { |
443 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); | 447 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); |
444 | } | 448 | } |
445 | void KSyncManager::syncLocalFile() | 449 | void KSyncManager::syncLocalFile() |
446 | { | 450 | { |
447 | 451 | ||
448 | QString fn =mPrefs->mLastSyncedLocalFile; | 452 | QString fn =mPrefs->mLastSyncedLocalFile; |
449 | QString ext; | 453 | QString ext; |
450 | 454 | ||
451 | switch(mTargetApp) | 455 | switch(mTargetApp) |
452 | { | 456 | { |
453 | case (KAPI): | 457 | case (KAPI): |
454 | ext = "(*.vcf)"; | 458 | ext = "(*.vcf)"; |
455 | break; | 459 | break; |
456 | case (KOPI): | 460 | case (KOPI): |
457 | ext = "(*.ics/*.vcs)"; | 461 | ext = "(*.ics/*.vcs)"; |
458 | break; | 462 | break; |
459 | case (PWMPI): | 463 | case (PWMPI): |
460 | ext = "(*.pwm)"; | 464 | ext = "(*.pwm)"; |
461 | break; | 465 | break; |
462 | default: | 466 | default: |
463 | qDebug("KSM::syncLocalFile: invalid apptype selected"); | 467 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
464 | break; | 468 | break; |
465 | 469 | ||
466 | } | 470 | } |
467 | 471 | ||
468 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 472 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
469 | if ( fn == "" ) | 473 | if ( fn == "" ) |
470 | return; | 474 | return; |
471 | if ( syncWithFile( fn, false ) ) { | 475 | if ( syncWithFile( fn, false ) ) { |
472 | qDebug("KSM::syncLocalFile() successful "); | 476 | qDebug("KSM::syncLocalFile() successful "); |
473 | } | 477 | } |
474 | 478 | ||
475 | } | 479 | } |
476 | 480 | ||
477 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 481 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
478 | { | 482 | { |
479 | bool ret = false; | 483 | bool ret = false; |
480 | QFileInfo info; | 484 | QFileInfo info; |
481 | info.setFile( fn ); | 485 | info.setFile( fn ); |
482 | QString mess; | 486 | QString mess; |
483 | if ( !info. exists() ) { | 487 | if ( !info. exists() ) { |
484 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 488 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
485 | QMessageBox::warning( mParent, i18n("Warning!"), | 489 | QMessageBox::warning( mParent, i18n("Warning!"), |
486 | mess ); | 490 | mess ); |
487 | return ret; | 491 | return ret; |
488 | } | 492 | } |
489 | int result = 0; | 493 | int result = 0; |
490 | if ( !quick ) { | 494 | if ( !quick ) { |
491 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 495 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
492 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 496 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
493 | mess, | 497 | mess, |
494 | i18n("Sync"), i18n("Cancel"), 0, | 498 | i18n("Sync"), i18n("Cancel"), 0, |
495 | 0, 1 ); | 499 | 0, 1 ); |
496 | if ( result ) | 500 | if ( result ) |
497 | return false; | 501 | return false; |
498 | } | 502 | } |
499 | if ( mAskForPreferences ) | 503 | if ( mAskForPreferences ) |
500 | if ( !edit_sync_options()) { | 504 | if ( !edit_sync_options()) { |
501 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 505 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
502 | return false; | 506 | return false; |
503 | } | 507 | } |
504 | if ( result == 0 ) { | 508 | if ( result == 0 ) { |
505 | //qDebug("Now sycing ... "); | 509 | //qDebug("Now sycing ... "); |
506 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 510 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) |
507 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 511 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
508 | else | 512 | else |
509 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 513 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
510 | if ( ! quick ) | 514 | if ( ! quick ) |
511 | mPrefs->mLastSyncedLocalFile = fn; | 515 | mPrefs->mLastSyncedLocalFile = fn; |
512 | } | 516 | } |
513 | return ret; | 517 | return ret; |
514 | } | 518 | } |
515 | 519 | ||
516 | void KSyncManager::quickSyncLocalFile() | 520 | void KSyncManager::quickSyncLocalFile() |
517 | { | 521 | { |
518 | 522 | ||
519 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 523 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
520 | qDebug("KSM::quick syncLocalFile() successful "); | 524 | qDebug("KSM::quick syncLocalFile() successful "); |
521 | 525 | ||
522 | } | 526 | } |
523 | } | 527 | } |
524 | 528 | ||
525 | void KSyncManager::multiSync( bool askforPrefs ) | 529 | void KSyncManager::multiSync( bool askforPrefs ) |
526 | { | 530 | { |
527 | if (blockSave()) | 531 | if (blockSave()) |
528 | return; | 532 | return; |
529 | setBlockSave(true); | 533 | setBlockSave(true); |
534 | mCurrentResourceLocal = ""; | ||
530 | if ( askforPrefs ) { | 535 | if ( askforPrefs ) { |
531 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 536 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
532 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 537 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
533 | question, | 538 | question, |
534 | i18n("Yes"), i18n("No"), | 539 | i18n("Yes"), i18n("No"), |
535 | 0, 0 ) != 0 ) { | 540 | 0, 0 ) != 0 ) { |
536 | setBlockSave(false); | 541 | setBlockSave(false); |
537 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 542 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
538 | return; | 543 | return; |
539 | } | 544 | } |
540 | } | 545 | } |
541 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 546 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
542 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 547 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
543 | if ( askforPrefs ) { | 548 | if ( askforPrefs ) { |
544 | if ( !edit_sync_options()) { | 549 | if ( !edit_sync_options()) { |
545 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 550 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
546 | return; | 551 | return; |
547 | } | 552 | } |
548 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 553 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
549 | } | 554 | } |
550 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 555 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
551 | qApp->processEvents(); | 556 | qApp->processEvents(); |
552 | int num = ringSync() ; | 557 | int num = ringSync() ; |
553 | if ( num > 1 ) | 558 | if ( num > 1 ) |
554 | ringSync(); | 559 | ringSync(); |
555 | setBlockSave(false); | 560 | setBlockSave(false); |
556 | if ( num ) | 561 | if ( num ) |
557 | emit save(); | 562 | emit save(); |
558 | if ( num ) | 563 | if ( num ) |
559 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 564 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
560 | else | 565 | else |
561 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 566 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
562 | return; | 567 | return; |
563 | } | 568 | } |
564 | 569 | ||
565 | int KSyncManager::ringSync() | 570 | int KSyncManager::ringSync() |
566 | { | 571 | { |
567 | 572 | ||
568 | int syncedProfiles = 0; | 573 | int syncedProfiles = 0; |
569 | unsigned int i; | 574 | unsigned int i; |
570 | QTime timer; | 575 | QTime timer; |
571 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 576 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
572 | QStringList syncProfileNames = mSyncProfileNames; | 577 | QStringList syncProfileNames = mSyncProfileNames; |
573 | KSyncProfile* temp = new KSyncProfile (); | 578 | KSyncProfile* temp = new KSyncProfile (); |
574 | mAskForPreferences = false; | 579 | mAskForPreferences = false; |
580 | mCurrentResourceLocal = ""; | ||
575 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 581 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
576 | mCurrentSyncProfile = i; | 582 | mCurrentSyncProfile = i; |
577 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 583 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
578 | temp->readConfig(&config); | 584 | temp->readConfig(&config); |
579 | 585 | ||
580 | bool includeInRingSync = false; | 586 | bool includeInRingSync = false; |
581 | switch(mTargetApp) | 587 | switch(mTargetApp) |
582 | { | 588 | { |
583 | case (KAPI): | 589 | case (KAPI): |
584 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 590 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
585 | break; | 591 | break; |
586 | case (KOPI): | 592 | case (KOPI): |
587 | includeInRingSync = temp->getIncludeInRingSync(); | 593 | includeInRingSync = temp->getIncludeInRingSync(); |
588 | break; | 594 | break; |
589 | case (PWMPI): | 595 | case (PWMPI): |
590 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 596 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
591 | break; | 597 | break; |
592 | default: | 598 | default: |
593 | qDebug("KSM::ringSync: invalid apptype selected"); | 599 | qDebug("KSM::ringSync: invalid apptype selected"); |
594 | break; | 600 | break; |
595 | 601 | ||
596 | } | 602 | } |
597 | 603 | ||
598 | 604 | ||
599 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 605 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
600 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 606 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
601 | ++syncedProfiles; | 607 | ++syncedProfiles; |
602 | mSyncWithDesktop = false; | 608 | mSyncWithDesktop = false; |
603 | // mAskForPreferences = temp->getAskForPreferences(); | 609 | // mAskForPreferences = temp->getAskForPreferences(); |
604 | mWriteBackFile = temp->getWriteBackFile(); | 610 | mWriteBackFile = temp->getWriteBackFile(); |
605 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 611 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
606 | mIsKapiFile = temp->getIsKapiFile(); | 612 | mIsKapiFile = temp->getIsKapiFile(); |
607 | mWriteBackInFuture = 0; | 613 | mWriteBackInFuture = 0; |
608 | if ( temp->getWriteBackFuture() ) { | 614 | if ( temp->getWriteBackFuture() ) { |
609 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 615 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
610 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 616 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
611 | } | 617 | } |
612 | mFilterInCal = temp->getFilterInCal(); | 618 | mFilterInCal = temp->getFilterInCal(); |
613 | mFilterOutCal = temp->getFilterOutCal(); | 619 | mFilterOutCal = temp->getFilterOutCal(); |
614 | mFilterInAB = temp->getFilterInAB(); | 620 | mFilterInAB = temp->getFilterInAB(); |
615 | mFilterOutAB = temp->getFilterOutAB(); | 621 | mFilterOutAB = temp->getFilterOutAB(); |
616 | mShowSyncSummary = false; | 622 | mShowSyncSummary = false; |
617 | mCurrentSyncDevice = syncProfileNames[i] ; | 623 | mCurrentSyncDevice = syncProfileNames[i] ; |
618 | mCurrentSyncName = mLocalMachineName; | 624 | mCurrentSyncName = mLocalMachineName; |
619 | if ( i == 0 ) { | 625 | if ( i == 0 ) { |
620 | mIsKapiFile = false; | 626 | mIsKapiFile = false; |
621 | #ifdef DESKTOP_VERSION | 627 | #ifdef DESKTOP_VERSION |
622 | syncKDE(); | 628 | syncKDE(); |
623 | #else | 629 | #else |
624 | syncSharp(); | 630 | syncSharp(); |
625 | #endif | 631 | #endif |
626 | } else { | 632 | } else { |
627 | if ( temp->getIsLocalFileSync() ) { | 633 | if ( temp->getIsLocalFileSync() ) { |
628 | switch(mTargetApp) | 634 | switch(mTargetApp) |
629 | { | 635 | { |
630 | case (KAPI): | 636 | case (KAPI): |
631 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 637 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
632 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 638 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
633 | break; | 639 | break; |
634 | case (KOPI): | 640 | case (KOPI): |
635 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 641 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
636 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 642 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
637 | break; | 643 | break; |
638 | case (PWMPI): | 644 | case (PWMPI): |
639 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 645 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
640 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 646 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
641 | break; | 647 | break; |
642 | default: | 648 | default: |
643 | qDebug("KSM: invalid apptype selected"); | 649 | qDebug("KSM: invalid apptype selected"); |
644 | break; | 650 | break; |
645 | } | 651 | } |
646 | } else { | 652 | } else { |
647 | if ( temp->getIsPhoneSync() ) { | 653 | if ( temp->getIsPhoneSync() ) { |
648 | mPhoneDevice = temp->getPhoneDevice( ) ; | 654 | mPhoneDevice = temp->getPhoneDevice( ) ; |
649 | mPhoneConnection = temp->getPhoneConnection( ); | 655 | mPhoneConnection = temp->getPhoneConnection( ); |
650 | mPhoneModel = temp->getPhoneModel( ); | 656 | mPhoneModel = temp->getPhoneModel( ); |
651 | syncPhone(); | 657 | syncPhone(); |
652 | } else if ( temp->getIsPiSync() ) { | 658 | } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { |
659 | mSpecificResources.clear(); | ||
653 | if ( mTargetApp == KAPI ) { | 660 | if ( mTargetApp == KAPI ) { |
654 | mPassWordPiSync = temp->getRemotePwAB(); | 661 | mPassWordPiSync = temp->getRemotePwAB(); |
655 | mActiveSyncPort = temp->getRemotePortAB(); | 662 | mActiveSyncPort = temp->getRemotePortAB(); |
656 | mActiveSyncIP = temp->getRemoteIPAB(); | 663 | mActiveSyncIP = temp->getRemoteIPAB(); |
657 | } else if ( mTargetApp == KOPI ) { | 664 | } else if ( mTargetApp == KOPI ) { |
665 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() ); | ||
658 | mPassWordPiSync = temp->getRemotePw(); | 666 | mPassWordPiSync = temp->getRemotePw(); |
659 | mActiveSyncPort = temp->getRemotePort(); | 667 | mActiveSyncPort = temp->getRemotePort(); |
660 | mActiveSyncIP = temp->getRemoteIP(); | 668 | mActiveSyncIP = temp->getRemoteIP(); |
661 | } else { | 669 | } else { |
662 | mPassWordPiSync = temp->getRemotePwPWM(); | 670 | mPassWordPiSync = temp->getRemotePwPWM(); |
663 | mActiveSyncPort = temp->getRemotePortPWM(); | 671 | mActiveSyncPort = temp->getRemotePortPWM(); |
664 | mActiveSyncIP = temp->getRemoteIPPWM(); | 672 | mActiveSyncIP = temp->getRemoteIPPWM(); |
665 | } | 673 | } |
666 | syncPi(); | 674 | syncPi(); |
667 | while ( !mPisyncFinished ) { | 675 | while ( !mPisyncFinished ) { |
668 | //qDebug("waiting "); | 676 | //qDebug("waiting "); |
669 | qApp->processEvents(); | 677 | qApp->processEvents(); |
670 | } | 678 | } |
671 | timer.start(); | 679 | timer.start(); |
672 | while ( timer.elapsed () < 2000 ) { | 680 | while ( timer.elapsed () < 2000 ) { |
673 | qApp->processEvents(); | 681 | qApp->processEvents(); |
674 | } | 682 | } |
675 | } else | 683 | } else |
676 | syncRemote( temp, false ); | 684 | syncRemote( temp, false ); |
677 | 685 | ||
678 | } | 686 | } |
679 | } | 687 | } |
680 | timer.start(); | 688 | timer.start(); |
681 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 689 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
682 | while ( timer.elapsed () < 2000 ) { | 690 | while ( timer.elapsed () < 2000 ) { |
683 | qApp->processEvents(); | 691 | qApp->processEvents(); |
684 | #ifndef _WIN32_ | 692 | #ifndef _WIN32_ |
685 | sleep (1); | 693 | sleep (1); |
686 | #endif | 694 | #endif |
687 | } | 695 | } |
688 | 696 | ||
689 | } | 697 | } |
690 | 698 | ||
691 | } | 699 | } |
692 | delete temp; | 700 | delete temp; |
693 | return syncedProfiles; | 701 | return syncedProfiles; |
694 | } | 702 | } |
695 | 703 | ||
696 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 704 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
697 | { | 705 | { |
698 | QString question; | 706 | QString question; |
699 | if ( ask ) { | 707 | if ( ask ) { |
700 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 708 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
701 | if ( QMessageBox::information( mParent, i18n("Sync"), | 709 | if ( QMessageBox::information( mParent, i18n("Sync"), |
702 | question, | 710 | question, |
703 | i18n("Yes"), i18n("No"), | 711 | i18n("Yes"), i18n("No"), |
704 | 0, 0 ) != 0 ) | 712 | 0, 0 ) != 0 ) |
705 | return; | 713 | return; |
706 | } | 714 | } |
707 | 715 | ||
708 | QString preCommand; | 716 | QString preCommand; |
709 | QString localTempFile; | 717 | QString localTempFile; |
710 | QString postCommand; | 718 | QString postCommand; |
711 | 719 | ||
712 | switch(mTargetApp) | 720 | switch(mTargetApp) |
713 | { | 721 | { |
714 | case (KAPI): | 722 | case (KAPI): |
715 | preCommand = prof->getPreSyncCommandAB(); | 723 | preCommand = prof->getPreSyncCommandAB(); |
716 | postCommand = prof->getPostSyncCommandAB(); | 724 | postCommand = prof->getPostSyncCommandAB(); |
717 | localTempFile = prof->getLocalTempFileAB(); | 725 | localTempFile = prof->getLocalTempFileAB(); |
718 | break; | 726 | break; |
719 | case (KOPI): | 727 | case (KOPI): |
720 | preCommand = prof->getPreSyncCommand(); | 728 | preCommand = prof->getPreSyncCommand(); |
721 | postCommand = prof->getPostSyncCommand(); | 729 | postCommand = prof->getPostSyncCommand(); |
722 | localTempFile = prof->getLocalTempFile(); | 730 | localTempFile = prof->getLocalTempFile(); |
723 | break; | 731 | break; |
724 | case (PWMPI): | 732 | case (PWMPI): |
725 | preCommand = prof->getPreSyncCommandPWM(); | 733 | preCommand = prof->getPreSyncCommandPWM(); |
726 | postCommand = prof->getPostSyncCommandPWM(); | 734 | postCommand = prof->getPostSyncCommandPWM(); |
727 | localTempFile = prof->getLocalTempFilePWM(); | 735 | localTempFile = prof->getLocalTempFilePWM(); |
728 | break; | 736 | break; |
729 | default: | 737 | default: |
730 | qDebug("KSM::syncRemote: invalid apptype selected"); | 738 | qDebug("KSM::syncRemote: invalid apptype selected"); |
731 | break; | 739 | break; |
732 | } | 740 | } |
733 | 741 | ||
734 | 742 | ||
735 | int fi; | 743 | int fi; |
736 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 744 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
737 | QString pwd = getPassword(); | 745 | QString pwd = getPassword(); |
738 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 746 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
739 | 747 | ||
740 | } | 748 | } |
741 | int maxlen = 30; | 749 | int maxlen = 30; |
742 | if ( QApplication::desktop()->width() > 320 ) | 750 | if ( QApplication::desktop()->width() > 320 ) |
743 | maxlen += 25; | 751 | maxlen += 25; |
744 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 752 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
745 | int fileSize = 0; | 753 | int fileSize = 0; |
746 | int result = system ( preCommand ); | 754 | int result = system ( preCommand ); |
747 | // 0 : okay | 755 | // 0 : okay |
748 | // 256: no such file or dir | 756 | // 256: no such file or dir |
749 | // | 757 | // |
750 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); | 758 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); |
751 | if ( result != 0 ) { | 759 | if ( result != 0 ) { |
752 | unsigned int len = maxlen; | 760 | unsigned int len = maxlen; |
753 | while ( len < preCommand.length() ) { | 761 | while ( len < preCommand.length() ) { |
754 | preCommand.insert( len , "\n" ); | 762 | preCommand.insert( len , "\n" ); |
755 | len += maxlen +2; | 763 | len += maxlen +2; |
756 | } | 764 | } |
757 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; | 765 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; |
758 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 766 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
759 | question, | 767 | question, |
760 | i18n("Okay!")) ; | 768 | i18n("Okay!")) ; |
761 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 769 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
762 | return; | 770 | return; |
763 | } | 771 | } |
764 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 772 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
765 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 773 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
766 | 774 | ||
767 | if ( syncWithFile( localTempFile, true ) ) { | 775 | if ( syncWithFile( localTempFile, true ) ) { |
768 | 776 | ||
769 | if ( mWriteBackFile ) { | 777 | if ( mWriteBackFile ) { |
770 | int fi; | 778 | int fi; |
771 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 779 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
772 | QString pwd = getPassword(); | 780 | QString pwd = getPassword(); |
773 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 781 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
774 | 782 | ||
775 | } | 783 | } |
776 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 784 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
777 | result = system ( postCommand ); | 785 | result = system ( postCommand ); |
778 | qDebug("KSM::Sync:Writing back file result: %d ", result); | 786 | qDebug("KSM::Sync:Writing back file result: %d ", result); |
779 | if ( result != 0 ) { | 787 | if ( result != 0 ) { |
780 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 788 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
781 | return; | 789 | return; |
782 | } else { | 790 | } else { |
783 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 791 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
784 | } | 792 | } |
785 | } | 793 | } |
786 | } | 794 | } |
787 | return; | 795 | return; |
788 | } | 796 | } |
789 | bool KSyncManager::edit_pisync_options() | 797 | bool KSyncManager::edit_pisync_options() |
790 | { | 798 | { |
791 | QDialog dia( mParent, "dia", true ); | 799 | QDialog dia( mParent, "dia", true ); |
792 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 800 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
793 | QVBoxLayout lay ( &dia ); | 801 | QVBoxLayout lay ( &dia ); |
794 | lay.setSpacing( 5 ); | 802 | lay.setSpacing( 5 ); |
795 | lay.setMargin( 3 ); | 803 | lay.setMargin( 3 ); |
796 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 804 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
797 | lay.addWidget( &lab1 ); | 805 | lay.addWidget( &lab1 ); |
798 | QLineEdit le1 (&dia ); | 806 | QLineEdit le1 (&dia ); |
799 | lay.addWidget( &le1 ); | 807 | lay.addWidget( &le1 ); |
800 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 808 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
801 | lay.addWidget( &lab2 ); | 809 | lay.addWidget( &lab2 ); |
802 | QLineEdit le2 (&dia ); | 810 | QLineEdit le2 (&dia ); |
803 | lay.addWidget( &le2 ); | 811 | lay.addWidget( &le2 ); |
804 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); | 812 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); |
805 | lay.addWidget( &lab3 ); | 813 | lay.addWidget( &lab3 ); |
806 | QLineEdit le3 (&dia ); | 814 | QLineEdit le3 (&dia ); |
807 | lay.addWidget( &le3 ); | 815 | lay.addWidget( &le3 ); |
808 | QPushButton pb ( "OK", &dia); | 816 | QPushButton pb ( "OK", &dia); |
809 | lay.addWidget( &pb ); | 817 | lay.addWidget( &pb ); |
810 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 818 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
811 | le1.setText( mPassWordPiSync ); | 819 | le1.setText( mPassWordPiSync ); |
812 | le2.setText( mActiveSyncIP ); | 820 | le2.setText( mActiveSyncIP ); |
813 | le3.setText( mActiveSyncPort ); | 821 | le3.setText( mActiveSyncPort ); |
814 | if ( dia.exec() ) { | 822 | if ( dia.exec() ) { |
815 | mPassWordPiSync = le1.text(); | 823 | mPassWordPiSync = le1.text(); |
816 | mActiveSyncPort = le3.text(); | 824 | mActiveSyncPort = le3.text(); |
817 | mActiveSyncIP = le2.text(); | 825 | mActiveSyncIP = le2.text(); |
818 | return true; | 826 | return true; |
819 | } | 827 | } |
820 | return false; | 828 | return false; |
821 | } | 829 | } |
822 | bool KSyncManager::edit_sync_options() | 830 | bool KSyncManager::edit_sync_options() |
823 | { | 831 | { |
824 | 832 | ||
825 | QDialog dia( mParent, "dia", true ); | 833 | QDialog dia( mParent, "dia", true ); |
826 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 834 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
827 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 835 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
828 | QVBoxLayout lay ( &dia ); | 836 | QVBoxLayout lay ( &dia ); |
829 | lay.setSpacing( 2 ); | 837 | lay.setSpacing( 2 ); |
830 | lay.setMargin( 3 ); | 838 | lay.setMargin( 3 ); |
831 | lay.addWidget(&gr); | 839 | lay.addWidget(&gr); |
832 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 840 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
833 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 841 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
834 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 842 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
835 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 843 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
836 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 844 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
837 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 845 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
838 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 846 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
839 | QPushButton pb ( "OK", &dia); | 847 | QPushButton pb ( "OK", &dia); |
840 | lay.addWidget( &pb ); | 848 | lay.addWidget( &pb ); |
841 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 849 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
842 | switch ( mSyncAlgoPrefs ) { | 850 | switch ( mSyncAlgoPrefs ) { |
843 | case 0: | 851 | case 0: |
844 | loc.setChecked( true); | 852 | loc.setChecked( true); |
845 | break; | 853 | break; |
846 | case 1: | 854 | case 1: |
847 | rem.setChecked( true ); | 855 | rem.setChecked( true ); |
848 | break; | 856 | break; |
849 | case 2: | 857 | case 2: |
850 | newest.setChecked( true); | 858 | newest.setChecked( true); |
851 | break; | 859 | break; |
852 | case 3: | 860 | case 3: |
853 | ask.setChecked( true); | 861 | ask.setChecked( true); |
854 | break; | 862 | break; |
855 | case 4: | 863 | case 4: |
856 | f_loc.setChecked( true); | 864 | f_loc.setChecked( true); |
857 | break; | 865 | break; |
858 | case 5: | 866 | case 5: |
859 | f_rem.setChecked( true); | 867 | f_rem.setChecked( true); |
860 | break; | 868 | break; |
861 | case 6: | 869 | case 6: |
862 | // both.setChecked( true); | 870 | // both.setChecked( true); |
863 | break; | 871 | break; |
864 | default: | 872 | default: |
865 | break; | 873 | break; |
866 | } | 874 | } |
867 | if ( dia.exec() ) { | 875 | if ( dia.exec() ) { |
868 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 876 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
869 | return true; | 877 | return true; |
870 | } | 878 | } |
871 | return false; | 879 | return false; |
872 | } | 880 | } |
873 | 881 | ||
874 | QString KSyncManager::getPassword( ) | 882 | QString KSyncManager::getPassword( ) |
875 | { | 883 | { |
876 | QString retfile = ""; | 884 | QString retfile = ""; |
877 | QDialog dia ( mParent, "input-dialog", true ); | 885 | QDialog dia ( mParent, "input-dialog", true ); |
878 | QLineEdit lab ( &dia ); | 886 | QLineEdit lab ( &dia ); |
879 | lab.setEchoMode( QLineEdit::Password ); | 887 | lab.setEchoMode( QLineEdit::Password ); |
880 | QVBoxLayout lay( &dia ); | 888 | QVBoxLayout lay( &dia ); |
881 | lay.setMargin(7); | 889 | lay.setMargin(7); |
882 | lay.setSpacing(7); | 890 | lay.setSpacing(7); |
883 | lay.addWidget( &lab); | 891 | lay.addWidget( &lab); |
884 | dia.setFixedSize( 230,50 ); | 892 | dia.setFixedSize( 230,50 ); |
885 | dia.setCaption( i18n("Enter password") ); | 893 | dia.setCaption( i18n("Enter password") ); |
886 | QPushButton pb ( "OK", &dia); | 894 | QPushButton pb ( "OK", &dia); |
887 | lay.addWidget( &pb ); | 895 | lay.addWidget( &pb ); |
888 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 896 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
889 | dia.show(); | 897 | dia.show(); |
890 | int res = dia.exec(); | 898 | int res = dia.exec(); |
891 | if ( res ) | 899 | if ( res ) |
892 | retfile = lab.text(); | 900 | retfile = lab.text(); |
893 | dia.hide(); | 901 | dia.hide(); |
894 | qApp->processEvents(); | 902 | qApp->processEvents(); |
895 | return retfile; | 903 | return retfile; |
896 | 904 | ||
897 | } | 905 | } |
898 | 906 | ||
899 | 907 | ||
900 | void KSyncManager::confSync() | 908 | void KSyncManager::confSync() |
901 | { | 909 | { |
902 | static KSyncPrefsDialog* sp = 0; | 910 | static KSyncPrefsDialog* sp = 0; |
903 | if ( ! sp ) { | 911 | if ( ! sp ) { |
904 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 912 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
905 | } | 913 | } |
906 | sp->usrReadConfig(); | 914 | sp->usrReadConfig(); |
907 | #ifndef DESKTOP_VERSION | 915 | #ifndef DESKTOP_VERSION |
908 | sp->showMaximized(); | 916 | sp->showMaximized(); |
909 | #else | 917 | #else |
910 | sp->show(); | 918 | sp->show(); |
911 | #endif | 919 | #endif |
912 | sp->exec(); | 920 | sp->exec(); |
913 | QStringList oldSyncProfileNames = mSyncProfileNames; | 921 | QStringList oldSyncProfileNames = mSyncProfileNames; |
914 | mSyncProfileNames = sp->getSyncProfileNames(); | 922 | mSyncProfileNames = sp->getSyncProfileNames(); |
915 | mLocalMachineName = sp->getLocalMachineName (); | 923 | mLocalMachineName = sp->getLocalMachineName (); |
916 | int ii; | 924 | int ii; |
917 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 925 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
918 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 926 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
919 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 927 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
920 | } | 928 | } |
921 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 929 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
922 | } | 930 | } |
923 | void KSyncManager::syncKDE() | 931 | void KSyncManager::syncKDE() |
924 | { | 932 | { |
925 | mSyncWithDesktop = true; | 933 | mSyncWithDesktop = true; |
926 | emit save(); | 934 | emit save(); |
927 | switch(mTargetApp) | 935 | switch(mTargetApp) |
928 | { | 936 | { |
929 | case (KAPI): | 937 | case (KAPI): |
930 | { | 938 | { |
931 | #ifdef DESKTOP_VERSION | 939 | #ifdef DESKTOP_VERSION |
932 | QString command = "kdeabdump33"; | 940 | QString command = "kdeabdump33"; |
933 | QString commandfile = "kdeabdump33"; | 941 | QString commandfile = "kdeabdump33"; |
934 | QString commandpath = qApp->applicationDirPath () + "/"; | 942 | QString commandpath = qApp->applicationDirPath () + "/"; |
935 | #else | 943 | #else |
936 | QString command = "kdeabdump33"; | 944 | QString command = "kdeabdump33"; |
937 | QString commandfile = "kdeabdump33"; | 945 | QString commandfile = "kdeabdump33"; |
938 | QString commandpath = QDir::homeDirPath ()+"/"; | 946 | QString commandpath = QDir::homeDirPath ()+"/"; |
939 | #endif | 947 | #endif |
940 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 948 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
941 | command = commandfile; | 949 | command = commandfile; |
942 | else | 950 | else |
943 | command = commandpath+commandfile; | 951 | command = commandpath+commandfile; |
944 | 952 | ||
945 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 953 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
946 | int result = system ( command.latin1()); | 954 | int result = system ( command.latin1()); |
947 | qDebug("AB dump 33 command call result: %d ", result); | 955 | qDebug("AB dump 33 command call result: %d ", result); |
948 | if ( result != 0 ) { | 956 | if ( result != 0 ) { |
949 | qDebug("Calling AB dump version 33 failed. Trying 34... "); | 957 | qDebug("Calling AB dump version 33 failed. Trying 34... "); |
950 | commandfile = "kdeabdump34"; | 958 | commandfile = "kdeabdump34"; |
951 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 959 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
952 | command = commandfile; | 960 | command = commandfile; |
953 | else | 961 | else |
954 | command = commandpath+commandfile; | 962 | command = commandpath+commandfile; |
955 | result = system ( command.latin1()); | 963 | result = system ( command.latin1()); |
956 | qDebug("AB dump 34 command call result: %d ", result); | 964 | qDebug("AB dump 34 command call result: %d ", result); |
957 | if ( result != 0 ) { | 965 | if ( result != 0 ) { |
958 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 966 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
959 | return; | 967 | return; |
960 | } | 968 | } |
961 | } | 969 | } |
962 | if ( syncWithFile( fileName,true ) ) { | 970 | if ( syncWithFile( fileName,true ) ) { |
963 | if ( mWriteBackFile ) { | 971 | if ( mWriteBackFile ) { |
964 | command += " --read"; | 972 | command += " --read"; |
965 | system ( command.latin1()); | 973 | system ( command.latin1()); |
966 | } | 974 | } |
967 | } | 975 | } |
968 | 976 | ||
969 | } | 977 | } |
970 | break; | 978 | break; |
971 | case (KOPI): | 979 | case (KOPI): |
972 | { | 980 | { |
973 | #ifdef DESKTOP_VERSION | 981 | #ifdef DESKTOP_VERSION |
974 | QString command = "kdecaldump33"; | 982 | QString command = "kdecaldump33"; |
975 | QString commandfile = "kdecaldump33"; | 983 | QString commandfile = "kdecaldump33"; |
976 | QString commandpath = qApp->applicationDirPath () + "/"; | 984 | QString commandpath = qApp->applicationDirPath () + "/"; |
977 | #else | 985 | #else |
978 | QString command = "kdecaldump33"; | 986 | QString command = "kdecaldump33"; |
979 | QString commandfile = "kdecaldump33"; | 987 | QString commandfile = "kdecaldump33"; |
980 | QString commandpath = QDir::homeDirPath ()+"/"; | 988 | QString commandpath = QDir::homeDirPath ()+"/"; |
981 | #endif | 989 | #endif |
982 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 990 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
983 | command = commandfile; | 991 | command = commandfile; |
984 | else | 992 | else |
985 | command = commandpath+commandfile; | 993 | command = commandpath+commandfile; |
986 | 994 | ||
987 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 995 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
988 | int result = system ( command.latin1()); | 996 | int result = system ( command.latin1()); |
989 | qDebug("Cal dump 33 command call result result: %d ", result); | 997 | qDebug("Cal dump 33 command call result result: %d ", result); |
990 | if ( result != 0 ) { | 998 | if ( result != 0 ) { |
991 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); | 999 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); |
992 | commandfile = "kdecaldump34"; | 1000 | commandfile = "kdecaldump34"; |
993 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1001 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
994 | command = commandfile; | 1002 | command = commandfile; |
995 | else | 1003 | else |
996 | command = commandpath+commandfile; | 1004 | command = commandpath+commandfile; |
997 | result = system ( command.latin1()); | 1005 | result = system ( command.latin1()); |
998 | qDebug("Cal dump 34 command call result result: %d ", result); | 1006 | qDebug("Cal dump 34 command call result result: %d ", result); |
999 | if ( result != 0 ) { | 1007 | if ( result != 0 ) { |
1000 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 1008 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
1001 | return; | 1009 | return; |
1002 | } | 1010 | } |
1003 | } | 1011 | } |
1004 | if ( syncWithFile( fileName,true ) ) { | 1012 | if ( syncWithFile( fileName,true ) ) { |
1005 | if ( mWriteBackFile ) { | 1013 | if ( mWriteBackFile ) { |
1006 | command += " --read"; | 1014 | command += " --read"; |
1007 | system ( command.latin1()); | 1015 | system ( command.latin1()); |
1008 | } | 1016 | } |
1009 | } | 1017 | } |
1010 | 1018 | ||
1011 | } | 1019 | } |
1012 | break; | 1020 | break; |
1013 | case (PWMPI): | 1021 | case (PWMPI): |
1014 | 1022 | ||
1015 | break; | 1023 | break; |
1016 | default: | 1024 | default: |
1017 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 1025 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
1018 | break; | 1026 | break; |
1019 | 1027 | ||
1020 | } | 1028 | } |
1021 | } | 1029 | } |
1022 | 1030 | ||
1023 | void KSyncManager::syncSharp() | 1031 | void KSyncManager::syncSharp() |
1024 | { | 1032 | { |
1025 | 1033 | ||
1026 | if ( ! syncExternalApplication("sharp") ) | 1034 | if ( ! syncExternalApplication("sharp") ) |
1027 | qDebug("KSM::ERROR sync sharp "); | 1035 | qDebug("KSM::ERROR sync sharp "); |
1028 | } | 1036 | } |
1029 | 1037 | ||
1030 | bool KSyncManager::syncExternalApplication(QString resource) | 1038 | bool KSyncManager::syncExternalApplication(QString resource) |
1031 | { | 1039 | { |
1032 | 1040 | ||
1033 | emit save(); | 1041 | emit save(); |
1034 | 1042 | ||
1035 | if ( mAskForPreferences ) | 1043 | if ( mAskForPreferences ) |
1036 | if ( !edit_sync_options()) { | 1044 | if ( !edit_sync_options()) { |
1037 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1045 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1038 | return false; | 1046 | return false; |
1039 | } | 1047 | } |
1040 | 1048 | ||
1041 | qDebug("KSM::Sync extern %s", resource.latin1()); | 1049 | qDebug("KSM::Sync extern %s", resource.latin1()); |
1042 | 1050 | ||
1043 | bool syncOK = mImplementation->syncExternal(this, resource); | 1051 | bool syncOK = mImplementation->syncExternal(this, resource); |
1044 | 1052 | ||
1045 | return syncOK; | 1053 | return syncOK; |
1046 | 1054 | ||
1047 | } | 1055 | } |
1048 | 1056 | ||
1049 | void KSyncManager::syncPhone() | 1057 | void KSyncManager::syncPhone() |
1050 | { | 1058 | { |
1051 | 1059 | ||
1052 | syncExternalApplication("phone"); | 1060 | syncExternalApplication("phone"); |
1053 | 1061 | ||
1054 | } | 1062 | } |
1055 | 1063 | ||
1056 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 1064 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
1057 | { | 1065 | { |
1058 | if (!bar->isVisible()) | 1066 | if (!bar->isVisible()) |
1059 | { | 1067 | { |
1060 | int w = 300; | 1068 | int w = 300; |
1061 | if ( QApplication::desktop()->width() < 320 ) | 1069 | if ( QApplication::desktop()->width() < 320 ) |
1062 | w = 220; | 1070 | w = 220; |
1063 | int h = bar->sizeHint().height() ; | 1071 | int h = bar->sizeHint().height() ; |
1064 | int dw = QApplication::desktop()->width(); | 1072 | int dw = QApplication::desktop()->width(); |
1065 | int dh = QApplication::desktop()->height(); | 1073 | int dh = QApplication::desktop()->height(); |
1066 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1074 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1067 | bar->setCaption (caption); | 1075 | bar->setCaption (caption); |
1068 | bar->setTotalSteps ( total ) ; | 1076 | bar->setTotalSteps ( total ) ; |
1069 | bar->show(); | 1077 | bar->show(); |
1070 | } | 1078 | } |
1071 | bar->raise(); | 1079 | bar->raise(); |
1072 | bar->setProgress( percentage ); | 1080 | bar->setProgress( percentage ); |
1073 | qApp->processEvents(); | 1081 | qApp->processEvents(); |
1074 | } | 1082 | } |
1075 | 1083 | ||
1076 | void KSyncManager::hideProgressBar() | 1084 | void KSyncManager::hideProgressBar() |
1077 | { | 1085 | { |
1078 | bar->hide(); | 1086 | bar->hide(); |
1079 | qApp->processEvents(); | 1087 | qApp->processEvents(); |
1080 | } | 1088 | } |
1081 | 1089 | ||
1082 | bool KSyncManager::isProgressBarCanceled() | 1090 | bool KSyncManager::isProgressBarCanceled() |
1083 | { | 1091 | { |
1084 | return !bar->isVisible(); | 1092 | return !bar->isVisible(); |
1085 | } | 1093 | } |
1086 | 1094 | ||
1087 | QString KSyncManager::syncFileName() | 1095 | QString KSyncManager::syncFileName() |
1088 | { | 1096 | { |
1089 | 1097 | ||
1090 | QString fn = "tempfile"; | 1098 | QString fn = "tempfile"; |
1091 | switch(mTargetApp) | 1099 | switch(mTargetApp) |
1092 | { | 1100 | { |
1093 | case (KAPI): | 1101 | case (KAPI): |
1094 | fn = "tempsyncab.vcf"; | 1102 | fn = "tempsyncab.vcf"; |
1095 | break; | 1103 | break; |
1096 | case (KOPI): | 1104 | case (KOPI): |
1097 | fn = "tempsynccal.ics"; | 1105 | fn = "tempsynccal.ics"; |
1098 | break; | 1106 | break; |
1099 | case (PWMPI): | 1107 | case (PWMPI): |
1100 | fn = "tempsyncpw.pwm"; | 1108 | fn = "tempsyncpw.pwm"; |
1101 | break; | 1109 | break; |
1102 | default: | 1110 | default: |
1103 | break; | 1111 | break; |
1104 | } | 1112 | } |
1105 | #ifdef DESKTOP_VERSION | 1113 | #ifdef DESKTOP_VERSION |
1106 | return locateLocal( "tmp", fn ); | 1114 | return locateLocal( "tmp", fn ); |
1107 | #else | 1115 | #else |
1108 | return (QString( "/tmp/" )+ fn ); | 1116 | return (QString( "/tmp/" )+ fn ); |
1109 | #endif | 1117 | #endif |
1110 | } | 1118 | } |
1111 | 1119 | ||
1112 | void KSyncManager::syncPi() | 1120 | void KSyncManager::syncPi() |
1113 | { | 1121 | { |
1114 | mIsKapiFile = true; | 1122 | mIsKapiFile = true; |
1115 | mPisyncFinished = false; | 1123 | mPisyncFinished = false; |
1116 | qApp->processEvents(); | 1124 | qApp->processEvents(); |
1117 | if ( mAskForPreferences ) | 1125 | if ( mAskForPreferences ) |
1118 | if ( !edit_pisync_options()) { | 1126 | if ( !edit_pisync_options()) { |
1119 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1127 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1120 | mPisyncFinished = true; | 1128 | mPisyncFinished = true; |
1121 | return; | 1129 | return; |
1122 | } | 1130 | } |
1123 | bool ok; | 1131 | bool ok; |
1124 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1132 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1125 | if ( ! ok ) { | 1133 | if ( ! ok ) { |
1126 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1134 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1127 | mPisyncFinished = true; | 1135 | mPisyncFinished = true; |
1128 | return; | 1136 | return; |
1129 | } | 1137 | } |
1130 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1138 | mCurrentResourceLocal = ""; |
1131 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1139 | mCurrentResourceRemote = ""; |
1132 | commandSocket->readFile( syncFileName() ); | 1140 | if ( mSpecificResources.count() ) { |
1141 | int startLocal = 0; | ||
1142 | int startRemote = mSpecificResources.count()/2; | ||
1143 | while ( startLocal < mSpecificResources.count()/2 ) { | ||
1144 | mPisyncFinished = false; | ||
1145 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; | ||
1146 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; | ||
1147 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | ||
1148 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | ||
1149 | commandSocket->readFile( syncFileName() ); | ||
1150 | while ( !mPisyncFinished ) { | ||
1151 | //qDebug("waiting "); | ||
1152 | qApp->processEvents(); | ||
1153 | } | ||
1154 | ++startLocal; | ||
1155 | } | ||
1156 | } else { | ||
1157 | KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | ||
1158 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | ||
1159 | commandSocket->readFile( syncFileName() ); | ||
1160 | } | ||
1133 | } | 1161 | } |
1134 | 1162 | ||
1135 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1163 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1136 | { | 1164 | { |
1137 | //enum { success, errorW, errorR, quiet }; | 1165 | //enum { success, errorW, errorR, quiet }; |
1138 | 1166 | ||
1139 | 1167 | ||
1140 | 1168 | ||
1141 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || | 1169 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || |
1142 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { | 1170 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { |
1143 | if ( state == KCommandSocket::errorPW ) | 1171 | if ( state == KCommandSocket::errorPW ) |
1144 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); | 1172 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); |
1145 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) | 1173 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) |
1146 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1174 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1147 | else if ( state == KCommandSocket::errorCA ) | 1175 | else if ( state == KCommandSocket::errorCA ) |
1148 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); | 1176 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); |
1149 | else if ( state == KCommandSocket::errorFI ) | 1177 | else if ( state == KCommandSocket::errorFI ) |
1150 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); | 1178 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); |
1151 | else if ( state == KCommandSocket::errorED ) | 1179 | else if ( state == KCommandSocket::errorED ) |
1152 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); | 1180 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); |
1153 | else if ( state == KCommandSocket::errorUN ) | 1181 | else if ( state == KCommandSocket::errorUN ) |
1154 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); | 1182 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); |
1155 | delete s; | 1183 | delete s; |
1156 | if ( state == KCommandSocket::errorR ) { | 1184 | if ( state == KCommandSocket::errorR ) { |
1157 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); | 1185 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); |
1158 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1186 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1159 | commandSocket->sendStop(); | 1187 | commandSocket->sendStop(); |
1160 | } | 1188 | } |
1161 | mPisyncFinished = true; | 1189 | mPisyncFinished = true; |
1162 | return; | 1190 | return; |
1163 | 1191 | ||
1164 | } else if ( state == KCommandSocket::errorW ) { | 1192 | } else if ( state == KCommandSocket::errorW ) { |
1165 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1193 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1166 | mPisyncFinished = true; | 1194 | mPisyncFinished = true; |
1167 | 1195 | ||
1168 | } else if ( state == KCommandSocket::successR ) { | 1196 | } else if ( state == KCommandSocket::successR ) { |
1169 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1197 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1170 | 1198 | ||
1171 | } else if ( state == KCommandSocket::successW ) { | 1199 | } else if ( state == KCommandSocket::successW ) { |
1172 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 1200 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
1173 | mPisyncFinished = true; | 1201 | mPisyncFinished = true; |
1174 | } else if ( state == KCommandSocket::quiet ){ | 1202 | } else if ( state == KCommandSocket::quiet ){ |
1175 | qDebug("KSS: quiet "); | 1203 | qDebug("KSS: quiet "); |
1176 | mPisyncFinished = true; | 1204 | mPisyncFinished = true; |
1177 | } else { | 1205 | } else { |
1178 | qDebug("KSS: Error: unknown state: %d ", state); | 1206 | qDebug("KSS: Error: unknown state: %d ", state); |
1179 | mPisyncFinished = true; | 1207 | mPisyncFinished = true; |
1180 | } | 1208 | } |
1181 | 1209 | ||
1182 | delete s; | 1210 | delete s; |
1183 | } | 1211 | } |
1184 | 1212 | ||
1185 | void KSyncManager::readFileFromSocket() | 1213 | void KSyncManager::readFileFromSocket() |
1186 | { | 1214 | { |
1187 | QString fileName = syncFileName(); | 1215 | QString fileName = syncFileName(); |
1188 | bool syncOK = true; | 1216 | bool syncOK = true; |
1189 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1217 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1190 | if ( ! syncWithFile( fileName , true ) ) { | 1218 | if ( ! syncWithFile( fileName , true ) ) { |
1191 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1219 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1192 | syncOK = false; | 1220 | syncOK = false; |
1193 | } | 1221 | } |
1194 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); | 1222 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); |
1195 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1223 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1196 | if ( mWriteBackFile && syncOK ) { | 1224 | if ( mWriteBackFile && syncOK ) { |
1197 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); | 1225 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); |
1198 | commandSocket->writeFile( fileName ); | 1226 | commandSocket->writeFile( fileName ); |
1199 | } | 1227 | } |
1200 | else { | 1228 | else { |
1201 | commandSocket->sendStop(); | 1229 | commandSocket->sendStop(); |
1202 | if ( syncOK ) | 1230 | if ( syncOK ) |
1203 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1231 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1204 | mPisyncFinished = true; | 1232 | mPisyncFinished = true; |
1205 | } | 1233 | } |
1206 | } | 1234 | } |
1207 | 1235 | ||
1208 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1236 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1209 | { | 1237 | { |
1210 | mPassWord = pw; | 1238 | mPassWord = pw; |
1211 | mSocket = 0; | 1239 | mSocket = 0; |
1212 | mSyncActionDialog = 0; | 1240 | mSyncActionDialog = 0; |
1213 | blockRC = false; | 1241 | blockRC = false; |
1214 | mErrorMessage = 0; | 1242 | mErrorMessage = 0; |
1215 | } | 1243 | } |
1216 | 1244 | ||
1217 | void KServerSocket::newConnection ( int socket ) | 1245 | void KServerSocket::newConnection ( int socket ) |
1218 | { | 1246 | { |
1219 | // qDebug("KServerSocket:New connection %d ", socket); | 1247 | // qDebug("KServerSocket:New connection %d ", socket); |
1220 | if ( mSocket ) { | 1248 | if ( mSocket ) { |
1221 | qDebug("KSS::newConnection Socket deleted! "); | 1249 | qDebug("KSS::newConnection Socket deleted! "); |
1222 | delete mSocket; | 1250 | delete mSocket; |
1223 | mSocket = 0; | 1251 | mSocket = 0; |
1224 | } | 1252 | } |
1225 | mSocket = new QSocket( this ); | 1253 | mSocket = new QSocket( this ); |
1226 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1254 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1227 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1255 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1228 | mSocket->setSocket( socket ); | 1256 | mSocket->setSocket( socket ); |
1229 | } | 1257 | } |
1230 | 1258 | ||
1231 | void KServerSocket::discardClient() | 1259 | void KServerSocket::discardClient() |
1232 | { | 1260 | { |
1233 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1261 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1234 | } | 1262 | } |
1235 | void KServerSocket::deleteSocket() | 1263 | void KServerSocket::deleteSocket() |
1236 | { | 1264 | { |
1237 | qDebug("KSS::deleteSocket"); | 1265 | qDebug("KSS::deleteSocket"); |
1238 | if ( mSocket ) { | 1266 | if ( mSocket ) { |
1239 | delete mSocket; | 1267 | delete mSocket; |
1240 | mSocket = 0; | 1268 | mSocket = 0; |
1241 | } | 1269 | } |
1242 | if ( mErrorMessage ) | 1270 | if ( mErrorMessage ) |
1243 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); | 1271 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); |
1244 | } | 1272 | } |
1245 | void KServerSocket::readClient() | 1273 | void KServerSocket::readClient() |
1246 | { | 1274 | { |
1247 | if ( blockRC ) | 1275 | if ( blockRC ) |
1248 | return; | 1276 | return; |
1249 | if ( mSocket == 0 ) { | 1277 | if ( mSocket == 0 ) { |
1250 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); | 1278 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); |
1251 | return; | 1279 | return; |
1252 | } | 1280 | } |
1253 | if ( mErrorMessage ) { | 1281 | if ( mErrorMessage ) { |
1254 | mErrorMessage = 999; | 1282 | mErrorMessage = 999; |
1255 | error_connect("ERROR_ED\r\n\r\n"); | 1283 | error_connect("ERROR_ED\r\n\r\n"); |
1256 | return; | 1284 | return; |
1257 | } | 1285 | } |
1258 | mErrorMessage = 0; | 1286 | mErrorMessage = 0; |
1259 | //qDebug("KServerSocket::readClient()"); | 1287 | //qDebug("KServerSocket::readClient()"); |
1260 | if ( mSocket->canReadLine() ) { | 1288 | if ( mSocket->canReadLine() ) { |
1261 | QString line = mSocket->readLine(); | 1289 | QString line = mSocket->readLine(); |
1262 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1290 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1263 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1291 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1264 | if ( tokens[0] == "GET" ) { | 1292 | if ( tokens[0] == "GET" ) { |
1265 | if ( tokens[1] == mPassWord ) { | 1293 | if ( tokens[1] == mPassWord ) { |
1266 | //emit sendFile( mSocket ); | 1294 | //emit sendFile( mSocket ); |
1267 | bool ok = false; | 1295 | bool ok = false; |
1268 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1296 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1269 | if ( ok ) { | 1297 | if ( ok ) { |
1270 | KSyncManager::mRequestedSyncEvent = dt; | 1298 | KSyncManager::mRequestedSyncEvent = dt; |
1271 | } | 1299 | } |
1272 | else | 1300 | else |
1273 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1301 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1274 | send_file(); | 1302 | send_file(); |
1275 | } | 1303 | } |
1276 | else { | 1304 | else { |
1277 | mErrorMessage = 1; | 1305 | mErrorMessage = 1; |
1278 | error_connect("ERROR_PW\r\n\r\n"); | 1306 | error_connect("ERROR_PW\r\n\r\n"); |
1279 | } | 1307 | } |
1280 | } | 1308 | } |
1281 | if ( tokens[0] == "PUT" ) { | 1309 | if ( tokens[0] == "PUT" ) { |
1282 | if ( tokens[1] == mPassWord ) { | 1310 | if ( tokens[1] == mPassWord ) { |
1283 | //emit getFile( mSocket ); | 1311 | //emit getFile( mSocket ); |
1284 | blockRC = true; | 1312 | blockRC = true; |
1285 | get_file(); | 1313 | get_file(); |
1286 | } | 1314 | } |
1287 | else { | 1315 | else { |
1288 | mErrorMessage = 2; | 1316 | mErrorMessage = 2; |
1289 | error_connect("ERROR_PW\r\n\r\n"); | 1317 | error_connect("ERROR_PW\r\n\r\n"); |
1290 | end_connect(); | 1318 | end_connect(); |
1291 | } | 1319 | } |
1292 | } | 1320 | } |
1293 | if ( tokens[0] == "STOP" ) { | 1321 | if ( tokens[0] == "STOP" ) { |
1294 | //emit endConnect(); | 1322 | //emit endConnect(); |
1295 | end_connect(); | 1323 | end_connect(); |
1296 | } | 1324 | } |
1297 | } | 1325 | } |
1298 | } | 1326 | } |
1299 | void KServerSocket::displayErrorMessage() | 1327 | void KServerSocket::displayErrorMessage() |
1300 | { | 1328 | { |
1301 | if ( mErrorMessage == 1 ) { | 1329 | if ( mErrorMessage == 1 ) { |
1302 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1330 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1303 | mErrorMessage = 0; | 1331 | mErrorMessage = 0; |
1304 | } | 1332 | } |
1305 | else if ( mErrorMessage == 2 ) { | 1333 | else if ( mErrorMessage == 2 ) { |
1306 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1334 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1307 | mErrorMessage = 0; | 1335 | mErrorMessage = 0; |
1308 | } | 1336 | } |
1309 | } | 1337 | } |
1310 | void KServerSocket::error_connect( QString errmess ) | 1338 | void KServerSocket::error_connect( QString errmess ) |
1311 | { | 1339 | { |
1312 | QTextStream os( mSocket ); | 1340 | QTextStream os( mSocket ); |
1313 | os.setEncoding( QTextStream::Latin1 ); | 1341 | os.setEncoding( QTextStream::Latin1 ); |
1314 | os << errmess ; | 1342 | os << errmess ; |
1315 | mSocket->close(); | 1343 | mSocket->close(); |
1316 | if ( mSocket->state() == QSocket::Idle ) { | 1344 | if ( mSocket->state() == QSocket::Idle ) { |
1317 | QTimer::singleShot( 0, this , SLOT ( discardClient())); | 1345 | QTimer::singleShot( 0, this , SLOT ( discardClient())); |
1318 | } | 1346 | } |
1319 | } | 1347 | } |
1320 | void KServerSocket::end_connect() | 1348 | void KServerSocket::end_connect() |
1321 | { | 1349 | { |
1322 | delete mSyncActionDialog; | 1350 | delete mSyncActionDialog; |
1323 | mSyncActionDialog = 0; | 1351 | mSyncActionDialog = 0; |
1324 | } | 1352 | } |
1325 | void KServerSocket::send_file() | 1353 | void KServerSocket::send_file() |
1326 | { | 1354 | { |
1327 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1355 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1328 | if ( mSyncActionDialog ) | 1356 | if ( mSyncActionDialog ) |
1329 | delete mSyncActionDialog; | 1357 | delete mSyncActionDialog; |
1330 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1358 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1331 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1359 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1332 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1360 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1333 | label->setAlignment ( Qt::AlignHCenter ); | 1361 | label->setAlignment ( Qt::AlignHCenter ); |
1334 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1362 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1335 | lay->addWidget( label); | 1363 | lay->addWidget( label); |
1336 | lay->setMargin(7); | 1364 | lay->setMargin(7); |
1337 | lay->setSpacing(7); | 1365 | lay->setSpacing(7); |
1338 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1366 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1339 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); | 1367 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); |
1340 | //secs = 333; | 1368 | //secs = 333; |
1341 | if ( secs < 0 ) | 1369 | if ( secs < 0 ) |
1342 | secs = secs * (-1); | 1370 | secs = secs * (-1); |
1343 | if ( secs > 30 ) | 1371 | if ( secs > 30 ) |
1344 | //if ( true ) | 1372 | //if ( true ) |
1345 | { | 1373 | { |
1346 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); | 1374 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); |
1347 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1375 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1348 | label->setAlignment ( Qt::AlignHCenter ); | 1376 | label->setAlignment ( Qt::AlignHCenter ); |
1349 | lay->addWidget( label); | 1377 | lay->addWidget( label); |
1350 | if ( secs > 180 ) | 1378 | if ( secs > 180 ) |
1351 | { | 1379 | { |
1352 | if ( secs > 300 ) { | 1380 | if ( secs > 300 ) { |
1353 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { | 1381 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { |
1354 | qDebug("KSS::Sync cancelled ,cs"); | 1382 | qDebug("KSS::Sync cancelled ,cs"); |
1355 | mErrorMessage = 0; | 1383 | mErrorMessage = 0; |
1356 | end_connect(); | 1384 | end_connect(); |
1357 | error_connect("ERROR_CA\r\n\r\n"); | 1385 | error_connect("ERROR_CA\r\n\r\n"); |
1358 | return ; | 1386 | return ; |
1359 | } | 1387 | } |
1360 | } | 1388 | } |
1361 | QFont f = label->font(); | 1389 | QFont f = label->font(); |
1362 | f.setPointSize ( f.pointSize() *2 ); | 1390 | f.setPointSize ( f.pointSize() *2 ); |
1363 | f. setBold (true ); | 1391 | f. setBold (true ); |
1364 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1392 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1365 | label->setFont( f ); | 1393 | label->setFont( f ); |
1366 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); | 1394 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); |
1367 | label->setText( warning ); | 1395 | label->setText( warning ); |
1368 | label->setAlignment ( Qt::AlignHCenter ); | 1396 | label->setAlignment ( Qt::AlignHCenter ); |
1369 | lay->addWidget( label); | 1397 | lay->addWidget( label); |
1370 | mSyncActionDialog->setFixedSize( 230, 300); | 1398 | mSyncActionDialog->setFixedSize( 230, 300); |
1371 | } else { | 1399 | } else { |
1372 | mSyncActionDialog->setFixedSize( 230, 200); | 1400 | mSyncActionDialog->setFixedSize( 230, 200); |
1373 | } | 1401 | } |
1374 | } else { | 1402 | } else { |
1375 | mSyncActionDialog->setFixedSize( 230, 120); | 1403 | mSyncActionDialog->setFixedSize( 230, 120); |
1376 | } | 1404 | } |
1377 | } else | 1405 | } else |
1378 | mSyncActionDialog->setFixedSize( 230, 120); | 1406 | mSyncActionDialog->setFixedSize( 230, 120); |
1379 | mSyncActionDialog->show(); | 1407 | mSyncActionDialog->show(); |
1380 | mSyncActionDialog->raise(); | 1408 | mSyncActionDialog->raise(); |
1381 | emit request_file(); | 1409 | emit request_file(); |
1382 | qApp->processEvents(); | 1410 | qApp->processEvents(); |
1383 | QString fileName = mFileName; | 1411 | QString fileName = mFileName; |
1384 | QFile file( fileName ); | 1412 | QFile file( fileName ); |
1385 | if (!file.open( IO_ReadOnly ) ) { | 1413 | if (!file.open( IO_ReadOnly ) ) { |
1386 | mErrorMessage = 0; | 1414 | mErrorMessage = 0; |
1387 | end_connect(); | 1415 | end_connect(); |
1388 | error_connect("ERROR_FI\r\n\r\n"); | 1416 | error_connect("ERROR_FI\r\n\r\n"); |
1389 | return ; | 1417 | return ; |
1390 | } | 1418 | } |
1391 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 1419 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
1392 | QTextStream ts( &file ); | 1420 | QTextStream ts( &file ); |
1393 | ts.setEncoding( QTextStream::Latin1 ); | 1421 | ts.setEncoding( QTextStream::Latin1 ); |
1394 | 1422 | ||
1395 | QTextStream os( mSocket ); | 1423 | QTextStream os( mSocket ); |
1396 | os.setEncoding( QTextStream::Latin1 ); | 1424 | os.setEncoding( QTextStream::Latin1 ); |
1397 | while ( ! ts.atEnd() ) { | 1425 | while ( ! ts.atEnd() ) { |
1398 | os << ts.readLine() << "\r\n"; | 1426 | os << ts.readLine() << "\r\n"; |
1399 | } | 1427 | } |
1400 | os << "\r\n"; | 1428 | os << "\r\n"; |
1401 | //os << ts.read(); | 1429 | //os << ts.read(); |
1402 | file.close(); | 1430 | file.close(); |
1403 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1431 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1404 | mSocket->close(); | 1432 | mSocket->close(); |
1405 | if ( mSocket->state() == QSocket::Idle ) | 1433 | if ( mSocket->state() == QSocket::Idle ) |
1406 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1434 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1407 | } | 1435 | } |
1408 | void KServerSocket::get_file() | 1436 | void KServerSocket::get_file() |
1409 | { | 1437 | { |
1410 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1438 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1411 | 1439 | ||
1412 | piTime.start(); | 1440 | piTime.start(); |
1413 | piFileString = ""; | 1441 | piFileString = ""; |
1414 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1442 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1415 | } | 1443 | } |
1416 | 1444 | ||
1417 | 1445 | ||
1418 | void KServerSocket::readBackFileFromSocket() | 1446 | void KServerSocket::readBackFileFromSocket() |
1419 | { | 1447 | { |
1420 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1448 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1421 | while ( mSocket->canReadLine () ) { | 1449 | while ( mSocket->canReadLine () ) { |
1422 | piTime.restart(); | 1450 | piTime.restart(); |
1423 | QString line = mSocket->readLine (); | 1451 | QString line = mSocket->readLine (); |
1424 | piFileString += line; | 1452 | piFileString += line; |
1425 | //qDebug("readline: %s ", line.latin1()); | 1453 | //qDebug("readline: %s ", line.latin1()); |
1426 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1454 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1427 | 1455 | ||
1428 | } | 1456 | } |
1429 | if ( piTime.elapsed () < 3000 ) { | 1457 | if ( piTime.elapsed () < 3000 ) { |
1430 | // wait for more | 1458 | // wait for more |
1431 | //qDebug("waitformore "); | 1459 | //qDebug("waitformore "); |
1432 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1460 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1433 | return; | 1461 | return; |
1434 | } | 1462 | } |
1435 | QString fileName = mFileName; | 1463 | QString fileName = mFileName; |
1436 | QFile file ( fileName ); | 1464 | QFile file ( fileName ); |
1437 | if (!file.open( IO_WriteOnly ) ) { | 1465 | if (!file.open( IO_WriteOnly ) ) { |
1438 | delete mSyncActionDialog; | 1466 | delete mSyncActionDialog; |
1439 | mSyncActionDialog = 0; | 1467 | mSyncActionDialog = 0; |
1440 | qDebug("KSS:Error open read back file "); | 1468 | qDebug("KSS:Error open read back file "); |
1441 | piFileString = ""; | 1469 | piFileString = ""; |
1442 | emit file_received( false ); | 1470 | emit file_received( false ); |
1443 | blockRC = false; | 1471 | blockRC = false; |
1444 | return ; | 1472 | return ; |
1445 | 1473 | ||
1446 | } | 1474 | } |
1447 | 1475 | ||
1448 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1476 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1449 | QTextStream ts ( &file ); | 1477 | QTextStream ts ( &file ); |
1450 | ts.setEncoding( QTextStream::Latin1 ); | 1478 | ts.setEncoding( QTextStream::Latin1 ); |
1451 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1479 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1452 | ts << piFileString; | 1480 | ts << piFileString; |
1453 | mSocket->close(); | 1481 | mSocket->close(); |
1454 | if ( mSocket->state() == QSocket::Idle ) | 1482 | if ( mSocket->state() == QSocket::Idle ) |
1455 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1483 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1456 | file.close(); | 1484 | file.close(); |
1457 | piFileString = ""; | 1485 | piFileString = ""; |
1458 | emit file_received( true ); | 1486 | emit file_received( true ); |
1459 | delete mSyncActionDialog; | 1487 | delete mSyncActionDialog; |
1460 | mSyncActionDialog = 0; | 1488 | mSyncActionDialog = 0; |
1461 | blockRC = false; | 1489 | blockRC = false; |
1462 | 1490 | ||
1463 | } | 1491 | } |
1464 | 1492 | ||
1465 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) | 1493 | KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) |
1466 | { | 1494 | { |
1495 | mRemoteResource = remres; | ||
1496 | if ( mRemoteResource.isEmpty() ) | ||
1497 | mRemoteResource = "ALL"; | ||
1467 | mPassWord = password; | 1498 | mPassWord = password; |
1468 | mSocket = 0; | 1499 | mSocket = 0; |
1469 | mFirst = false; | 1500 | mFirst = false; |
1470 | mFirstLine = true; | 1501 | mFirstLine = true; |
1471 | mPort = port; | 1502 | mPort = port; |
1472 | mHost = host; | 1503 | mHost = host; |
1473 | tlw = cap; | 1504 | tlw = cap; |
1474 | mRetVal = quiet; | 1505 | mRetVal = quiet; |
1475 | mTimerSocket = new QTimer ( this ); | 1506 | mTimerSocket = new QTimer ( this ); |
1476 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); | 1507 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); |
1477 | mConnectProgress.setCaption( i18n("Pi-Sync") ); | 1508 | mConnectProgress.setCaption( i18n("Pi-Sync") ); |
1478 | connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); | 1509 | connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); |
1479 | mConnectCount = -1; | 1510 | mConnectCount = -1; |
1480 | } | 1511 | } |
1481 | void KCommandSocket::sendFileRequest() | 1512 | void KCommandSocket::sendFileRequest() |
1482 | { | 1513 | { |
1483 | if ( tlw ) | 1514 | if ( tlw ) |
1484 | tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); | 1515 | tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); |
1485 | mConnectProgress.hide(); | 1516 | mConnectProgress.hide(); |
1486 | mConnectCount = 300;mConnectMax = 300; | 1517 | mConnectCount = 300;mConnectMax = 300; |
1487 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); | 1518 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); |
1488 | mTimerSocket->start( 100, true ); | 1519 | mTimerSocket->start( 100, true ); |
1489 | QTextStream os( mSocket ); | 1520 | QTextStream os( mSocket ); |
1490 | os.setEncoding( QTextStream::Latin1 ); | 1521 | os.setEncoding( QTextStream::Latin1 ); |
1491 | 1522 | ||
1492 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); | 1523 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); |
1493 | os << "GET " << mPassWord << curDt <<"\r\n\r\n"; | 1524 | os << "GET " << mPassWord << curDt << mRemoteResource << "\r\n\r\n"; |
1494 | } | 1525 | } |
1495 | 1526 | ||
1496 | void KCommandSocket::readFile( QString fn ) | 1527 | void KCommandSocket::readFile( QString fn ) |
1497 | { | 1528 | { |
1498 | if ( !mSocket ) { | 1529 | if ( !mSocket ) { |
1499 | mSocket = new QSocket( this ); | 1530 | mSocket = new QSocket( this ); |
1500 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1531 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1501 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1532 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1502 | connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); | 1533 | connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); |
1503 | } | 1534 | } |
1504 | mFileString = ""; | 1535 | mFileString = ""; |
1505 | mFileName = fn; | 1536 | mFileName = fn; |
1506 | mFirst = true; | 1537 | mFirst = true; |
1507 | if ( tlw ) | 1538 | if ( tlw ) |
1508 | tlw->setCaption( i18n("Trying to connect to remote...") ); | 1539 | tlw->setCaption( i18n("Trying to connect to remote...") ); |
1509 | mConnectCount = 30;mConnectMax = 30; | 1540 | mConnectCount = 30;mConnectMax = 30; |
1510 | mTimerSocket->start( 1000, true ); | 1541 | mTimerSocket->start( 1000, true ); |
1511 | mSocket->connectToHost( mHost, mPort ); | 1542 | mSocket->connectToHost( mHost, mPort ); |
1512 | qDebug("KSS: Waiting for connection"); | 1543 | qDebug("KSS: Waiting for connection"); |
1513 | } | 1544 | } |
1514 | void KCommandSocket::updateConnectDialog() | 1545 | void KCommandSocket::updateConnectDialog() |
1515 | { | 1546 | { |
1516 | 1547 | ||
1517 | if ( mConnectCount == mConnectMax ) { | 1548 | if ( mConnectCount == mConnectMax ) { |
1518 | //qDebug("MAXX %d", mConnectMax); | 1549 | //qDebug("MAXX %d", mConnectMax); |
1519 | mConnectProgress.setTotalSteps ( 30 ); | 1550 | mConnectProgress.setTotalSteps ( 30 ); |
1520 | mConnectProgress.show(); | 1551 | mConnectProgress.show(); |
1521 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); | 1552 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); |
1522 | } | 1553 | } |
1523 | //qDebug("updateConnectDialog() %d", mConnectCount); | 1554 | //qDebug("updateConnectDialog() %d", mConnectCount); |
1524 | mConnectProgress.raise(); | 1555 | mConnectProgress.raise(); |
1525 | mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); | 1556 | mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); |
1526 | --mConnectCount; | 1557 | --mConnectCount; |
1527 | if ( mConnectCount > 0 ) | 1558 | if ( mConnectCount > 0 ) |
1528 | mTimerSocket->start( 1000, true ); | 1559 | mTimerSocket->start( 1000, true ); |
1529 | else | 1560 | else |
1530 | deleteSocket(); | 1561 | deleteSocket(); |
1531 | 1562 | ||
1532 | } | 1563 | } |
1533 | void KCommandSocket::writeFile( QString fileName ) | 1564 | void KCommandSocket::writeFile( QString fileName ) |
1534 | { | 1565 | { |
1535 | if ( !mSocket ) { | 1566 | if ( !mSocket ) { |
1536 | mSocket = new QSocket( this ); | 1567 | mSocket = new QSocket( this ); |
1537 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1568 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1538 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1569 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1539 | } | 1570 | } |
1540 | mFileName = fileName ; | 1571 | mFileName = fileName ; |
1541 | mConnectCount = 30;mConnectMax = 30; | 1572 | mConnectCount = 30;mConnectMax = 30; |
1542 | mTimerSocket->start( 1000, true ); | 1573 | mTimerSocket->start( 1000, true ); |
1543 | mSocket->connectToHost( mHost, mPort ); | 1574 | mSocket->connectToHost( mHost, mPort ); |
1544 | } | 1575 | } |
1545 | void KCommandSocket::writeFileToSocket() | 1576 | void KCommandSocket::writeFileToSocket() |
1546 | { | 1577 | { |
1547 | mTimerSocket->stop(); | 1578 | mTimerSocket->stop(); |
1548 | QFile file2( mFileName ); | 1579 | QFile file2( mFileName ); |
1549 | if (!file2.open( IO_ReadOnly ) ) { | 1580 | if (!file2.open( IO_ReadOnly ) ) { |
1550 | mConnectProgress.hide(); | 1581 | mConnectProgress.hide(); |
1551 | mConnectCount = -1; | 1582 | mConnectCount = -1; |
1552 | mRetVal= errorW; | 1583 | mRetVal= errorW; |
1553 | mSocket->close(); | 1584 | mSocket->close(); |
1554 | if ( mSocket->state() == QSocket::Idle ) | 1585 | if ( mSocket->state() == QSocket::Idle ) |
1555 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1586 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1556 | return ; | 1587 | return ; |
1557 | } | 1588 | } |
1558 | mConnectProgress.setTotalSteps ( file2.size() ); | 1589 | mConnectProgress.setTotalSteps ( file2.size() ); |
1559 | mConnectProgress.show(); | 1590 | mConnectProgress.show(); |
1560 | int count = 0; | 1591 | int count = 0; |
1561 | mConnectProgress.setLabelText( i18n("Sending back synced file...") ); | 1592 | mConnectProgress.setLabelText( i18n("Sending back synced file...") ); |
1562 | mConnectProgress.setProgress( count ); | 1593 | mConnectProgress.setProgress( count ); |
1563 | mConnectProgress.blockSignals( true ); | 1594 | mConnectProgress.blockSignals( true ); |
1564 | QTextStream ts2( &file2 ); | 1595 | QTextStream ts2( &file2 ); |
1565 | ts2.setEncoding( QTextStream::Latin1 ); | 1596 | ts2.setEncoding( QTextStream::Latin1 ); |
1566 | QTextStream os2( mSocket ); | 1597 | QTextStream os2( mSocket ); |
1567 | os2.setEncoding( QTextStream::Latin1 ); | 1598 | os2.setEncoding( QTextStream::Latin1 ); |
1568 | os2 << "PUT " << mPassWord << "\r\n\r\n";; | 1599 | os2 << "PUT " << mPassWord << "\r\n\r\n";; |
1569 | int byteCount = 0; | 1600 | int byteCount = 0; |
1570 | int byteMax = file2.size()/53; | 1601 | int byteMax = file2.size()/53; |
1571 | while ( ! ts2.atEnd() ) { | 1602 | while ( ! ts2.atEnd() ) { |
1572 | qApp->processEvents(); | 1603 | qApp->processEvents(); |
1573 | if ( byteCount > byteMax ) { | 1604 | if ( byteCount > byteMax ) { |
1574 | byteCount = 0; | 1605 | byteCount = 0; |
1575 | mConnectProgress.setProgress( count ); | 1606 | mConnectProgress.setProgress( count ); |
1576 | } | 1607 | } |
1577 | QString temp = ts2.readLine(); | 1608 | QString temp = ts2.readLine(); |
1578 | count += temp.length(); | 1609 | count += temp.length(); |
1579 | byteCount += temp.length(); | 1610 | byteCount += temp.length(); |
1580 | os2 << temp << "\r\n"; | 1611 | os2 << temp << "\r\n"; |
1581 | } | 1612 | } |
1582 | file2.close(); | 1613 | file2.close(); |
1583 | mConnectProgress.hide(); | 1614 | mConnectProgress.hide(); |
1584 | mConnectCount = -1; | 1615 | mConnectCount = -1; |
1585 | os2 << "\r\n"; | 1616 | os2 << "\r\n"; |
1586 | mRetVal= successW; | 1617 | mRetVal= successW; |
1587 | mSocket->close(); | 1618 | mSocket->close(); |
1588 | if ( mSocket->state() == QSocket::Idle ) | 1619 | if ( mSocket->state() == QSocket::Idle ) |
1589 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1620 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1590 | mConnectProgress.blockSignals( false ); | 1621 | mConnectProgress.blockSignals( false ); |
1591 | } | 1622 | } |
1592 | void KCommandSocket::sendStop() | 1623 | void KCommandSocket::sendStop() |
1593 | { | 1624 | { |
1594 | if ( !mSocket ) { | 1625 | if ( !mSocket ) { |
1595 | mSocket = new QSocket( this ); | 1626 | mSocket = new QSocket( this ); |
1596 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1627 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1597 | } | 1628 | } |
1598 | mSocket->connectToHost( mHost, mPort ); | 1629 | mSocket->connectToHost( mHost, mPort ); |
1599 | QTextStream os2( mSocket ); | 1630 | QTextStream os2( mSocket ); |
1600 | os2.setEncoding( QTextStream::Latin1 ); | 1631 | os2.setEncoding( QTextStream::Latin1 ); |
1601 | os2 << "STOP\r\n\r\n"; | 1632 | os2 << "STOP\r\n\r\n"; |
1602 | mSocket->close(); | 1633 | mSocket->close(); |
1603 | if ( mSocket->state() == QSocket::Idle ) | 1634 | if ( mSocket->state() == QSocket::Idle ) |
1604 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1635 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1605 | } | 1636 | } |
1606 | 1637 | ||
1607 | void KCommandSocket::startReadFileFromSocket() | 1638 | void KCommandSocket::startReadFileFromSocket() |
1608 | { | 1639 | { |
1609 | if ( ! mFirst ) | 1640 | if ( ! mFirst ) |
1610 | return; | 1641 | return; |
1611 | mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); | 1642 | mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); |
1612 | mFirst = false; | 1643 | mFirst = false; |
1613 | mFileString = ""; | 1644 | mFileString = ""; |
1614 | mTime.start(); | 1645 | mTime.start(); |
1615 | mFirstLine = true; | 1646 | mFirstLine = true; |
1616 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1647 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1617 | 1648 | ||
1618 | } | 1649 | } |
1619 | void KCommandSocket::readFileFromSocket() | 1650 | void KCommandSocket::readFileFromSocket() |
1620 | { | 1651 | { |
1621 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1652 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1622 | while ( mSocket->canReadLine () ) { | 1653 | while ( mSocket->canReadLine () ) { |
1623 | mTime.restart(); | 1654 | mTime.restart(); |
1624 | QString line = mSocket->readLine (); | 1655 | QString line = mSocket->readLine (); |
1625 | if ( mFirstLine ) { | 1656 | if ( mFirstLine ) { |
1626 | mFirstLine = false; | 1657 | mFirstLine = false; |
1627 | if ( line.left( 6 ) == "ERROR_" ) { | 1658 | if ( line.left( 6 ) == "ERROR_" ) { |
1628 | mTimerSocket->stop(); | 1659 | mTimerSocket->stop(); |
1629 | mConnectCount = -1; | 1660 | mConnectCount = -1; |
1630 | if ( line.left( 8 ) == "ERROR_PW" ) { | 1661 | if ( line.left( 8 ) == "ERROR_PW" ) { |
1631 | mRetVal = errorPW; | 1662 | mRetVal = errorPW; |
1632 | deleteSocket(); | 1663 | deleteSocket(); |
1633 | return ; | 1664 | return ; |
1634 | } | 1665 | } |
1635 | if ( line.left( 8 ) == "ERROR_CA" ) { | 1666 | if ( line.left( 8 ) == "ERROR_CA" ) { |
1636 | mRetVal = errorCA; | 1667 | mRetVal = errorCA; |
1637 | deleteSocket(); | 1668 | deleteSocket(); |
1638 | return ; | 1669 | return ; |
1639 | } | 1670 | } |
1640 | if ( line.left( 8 ) == "ERROR_FI" ) { | 1671 | if ( line.left( 8 ) == "ERROR_FI" ) { |
1641 | mRetVal = errorFI; | 1672 | mRetVal = errorFI; |
1642 | deleteSocket(); | 1673 | deleteSocket(); |
1643 | return ; | 1674 | return ; |
1644 | } | 1675 | } |
1645 | if ( line.left( 8 ) == "ERROR_ED" ) { | 1676 | if ( line.left( 8 ) == "ERROR_ED" ) { |
1646 | mRetVal = errorED; | 1677 | mRetVal = errorED; |
1647 | deleteSocket(); | 1678 | deleteSocket(); |
1648 | return ; | 1679 | return ; |
1649 | } | 1680 | } |
1650 | mRetVal = errorUN; | 1681 | mRetVal = errorUN; |
1651 | deleteSocket(); | 1682 | deleteSocket(); |
1652 | return ; | 1683 | return ; |
1653 | } | 1684 | } |
1654 | } | 1685 | } |
1655 | mFileString += line; | 1686 | mFileString += line; |
1656 | //qDebug("readline: %s ", line.latin1()); | 1687 | //qDebug("readline: %s ", line.latin1()); |
1657 | } | 1688 | } |
1658 | if ( mTime.elapsed () < 3000 ) { | 1689 | if ( mTime.elapsed () < 3000 ) { |
1659 | // wait for more | 1690 | // wait for more |
1660 | //qDebug("waitformore "); | 1691 | //qDebug("waitformore "); |
1661 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1692 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1662 | return; | 1693 | return; |
1663 | } | 1694 | } |
1664 | mTimerSocket->stop(); | 1695 | mTimerSocket->stop(); |
1665 | mConnectCount = -1; | 1696 | mConnectCount = -1; |
1666 | mConnectProgress.hide(); | 1697 | mConnectProgress.hide(); |
1667 | QString fileName = mFileName; | 1698 | QString fileName = mFileName; |
1668 | QFile file ( fileName ); | 1699 | QFile file ( fileName ); |
1669 | if (!file.open( IO_WriteOnly ) ) { | 1700 | if (!file.open( IO_WriteOnly ) ) { |
1670 | mFileString = ""; | 1701 | mFileString = ""; |
1671 | mRetVal = errorR; | 1702 | mRetVal = errorR; |
1672 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); | 1703 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); |
1673 | deleteSocket(); | 1704 | deleteSocket(); |
1674 | return ; | 1705 | return ; |
1675 | 1706 | ||
1676 | } | 1707 | } |
1677 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1708 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1678 | QTextStream ts ( &file ); | 1709 | QTextStream ts ( &file ); |
1679 | ts.setEncoding( QTextStream::Latin1 ); | 1710 | ts.setEncoding( QTextStream::Latin1 ); |
1680 | ts << mFileString; | 1711 | ts << mFileString; |
1681 | file.close(); | 1712 | file.close(); |
1682 | mFileString = ""; | 1713 | mFileString = ""; |
1683 | mRetVal = successR; | 1714 | mRetVal = successR; |
1684 | mSocket->close(); | 1715 | mSocket->close(); |
1685 | // if state is not idle, deleteSocket(); is called via | 1716 | // if state is not idle, deleteSocket(); is called via |
1686 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1717 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1687 | if ( mSocket->state() == QSocket::Idle ) | 1718 | if ( mSocket->state() == QSocket::Idle ) |
1688 | deleteSocket(); | 1719 | deleteSocket(); |
1689 | } | 1720 | } |
1690 | 1721 | ||
1691 | void KCommandSocket::deleteSocket() | 1722 | void KCommandSocket::deleteSocket() |
1692 | { | 1723 | { |
1693 | //qDebug("KCommandSocket::deleteSocket() "); | 1724 | //qDebug("KCommandSocket::deleteSocket() "); |
1694 | mConnectProgress.hide(); | 1725 | mConnectProgress.hide(); |
1695 | 1726 | ||
1696 | if ( mConnectCount >= 0 ) { | 1727 | if ( mConnectCount >= 0 ) { |
1697 | mTimerSocket->stop(); | 1728 | mTimerSocket->stop(); |
1698 | mRetVal = errorTO; | 1729 | mRetVal = errorTO; |
1699 | qDebug("KCS::Connection to remote host timed out"); | 1730 | qDebug("KCS::Connection to remote host timed out"); |
1700 | if ( mSocket ) { | 1731 | if ( mSocket ) { |
1701 | mSocket->close(); | 1732 | mSocket->close(); |
1702 | //if ( mSocket->state() == QSocket::Idle ) | 1733 | //if ( mSocket->state() == QSocket::Idle ) |
1703 | // deleteSocket(); | 1734 | // deleteSocket(); |
1704 | delete mSocket; | 1735 | delete mSocket; |
1705 | mSocket = 0; | 1736 | mSocket = 0; |
1706 | } | 1737 | } |
1707 | if ( mConnectCount == 0 ) | 1738 | if ( mConnectCount == 0 ) |
1708 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); | 1739 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); |
1709 | else if ( tlw ) | 1740 | else if ( tlw ) |
1710 | tlw->setCaption( i18n("Connection to remote host cancelled!") ); | 1741 | tlw->setCaption( i18n("Connection to remote host cancelled!") ); |
1711 | emit commandFinished( this, mRetVal ); | 1742 | emit commandFinished( this, mRetVal ); |
1712 | return; | 1743 | return; |
1713 | } | 1744 | } |
1714 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1745 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1715 | if ( mSocket) | 1746 | if ( mSocket) |
1716 | delete mSocket; | 1747 | delete mSocket; |
1717 | mSocket = 0; | 1748 | mSocket = 0; |
1718 | qDebug("commandFinished "); | 1749 | qDebug("commandFinished "); |
1719 | emit commandFinished( this, mRetVal ); | 1750 | emit commandFinished( this, mRetVal ); |
1720 | } | 1751 | } |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index d3734da..f4654ce 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,237 +1,241 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | $Id$ | 20 | $Id$ |
21 | */ | 21 | */ |
22 | #ifndef _KSYNCMANAGER_H | 22 | #ifndef _KSYNCMANAGER_H |
23 | #define _KSYNCMANAGER_H | 23 | #define _KSYNCMANAGER_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qsocket.h> | 27 | #include <qsocket.h> |
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qserversocket.h> | 29 | #include <qserversocket.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qprogressdialog.h> | 32 | #include <qprogressdialog.h> |
33 | #include <kdialog.h> | 33 | #include <kdialog.h> |
34 | 34 | ||
35 | class QPopupMenu; | 35 | class QPopupMenu; |
36 | class KSyncProfile; | 36 | class KSyncProfile; |
37 | class KPimPrefs; | 37 | class KPimPrefs; |
38 | class QWidget; | 38 | class QWidget; |
39 | class KSyncManager; | 39 | class KSyncManager; |
40 | class KSyncInterface; | 40 | class KSyncInterface; |
41 | class QProgressBar; | 41 | class QProgressBar; |
42 | 42 | ||
43 | 43 | ||
44 | class KServerSocket : public QServerSocket | 44 | class KServerSocket : public QServerSocket |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | 47 | ||
48 | public: | 48 | public: |
49 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 49 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
50 | 50 | ||
51 | void newConnection ( int socket ) ; | 51 | void newConnection ( int socket ) ; |
52 | void setFileName( QString fn ) {mFileName = fn;}; | 52 | void setFileName( QString fn ) {mFileName = fn;}; |
53 | signals: | 53 | signals: |
54 | void file_received( bool ); | 54 | void file_received( bool ); |
55 | void request_file(); | 55 | void request_file(); |
56 | void saveFile(); | 56 | void saveFile(); |
57 | void endConnect(); | 57 | void endConnect(); |
58 | private slots: | 58 | private slots: |
59 | void discardClient(); | 59 | void discardClient(); |
60 | void deleteSocket(); | 60 | void deleteSocket(); |
61 | void readClient(); | 61 | void readClient(); |
62 | void displayErrorMessage(); | 62 | void displayErrorMessage(); |
63 | void readBackFileFromSocket(); | 63 | void readBackFileFromSocket(); |
64 | private : | 64 | private : |
65 | int mErrorMessage; | 65 | int mErrorMessage; |
66 | bool blockRC; | 66 | bool blockRC; |
67 | void send_file(); | 67 | void send_file(); |
68 | void get_file(); | 68 | void get_file(); |
69 | void end_connect(); | 69 | void end_connect(); |
70 | void error_connect( QString ); | 70 | void error_connect( QString ); |
71 | QDialog* mSyncActionDialog; | 71 | QDialog* mSyncActionDialog; |
72 | QSocket* mSocket; | 72 | QSocket* mSocket; |
73 | QString mPassWord; | 73 | QString mPassWord; |
74 | QString mFileName; | 74 | QString mFileName; |
75 | QTime piTime; | 75 | QTime piTime; |
76 | QString piFileString; | 76 | QString piFileString; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | class KCommandSocket : public QObject | 79 | class KCommandSocket : public QObject |
80 | { | 80 | { |
81 | Q_OBJECT | 81 | Q_OBJECT |
82 | public: | 82 | public: |
83 | enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; | 83 | enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; |
84 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); | 84 | KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); |
85 | void readFile( QString ); | 85 | void readFile( QString ); |
86 | void writeFile( QString ); | 86 | void writeFile( QString ); |
87 | void sendStop(); | 87 | void sendStop(); |
88 | 88 | ||
89 | private slots : | 89 | private slots : |
90 | void sendFileRequest(); | 90 | void sendFileRequest(); |
91 | void updateConnectDialog(); | 91 | void updateConnectDialog(); |
92 | 92 | ||
93 | signals: | 93 | signals: |
94 | void commandFinished( KCommandSocket*, int ); | 94 | void commandFinished( KCommandSocket*, int ); |
95 | private slots: | 95 | private slots: |
96 | void startReadFileFromSocket(); | 96 | void startReadFileFromSocket(); |
97 | void readFileFromSocket(); | 97 | void readFileFromSocket(); |
98 | void deleteSocket(); | 98 | void deleteSocket(); |
99 | void writeFileToSocket(); | 99 | void writeFileToSocket(); |
100 | private : | 100 | private : |
101 | QString mRemoteResource; | ||
101 | int mConnectCount; | 102 | int mConnectCount; |
102 | int mConnectMax; | 103 | int mConnectMax; |
103 | KProgressDialog mConnectProgress; | 104 | KProgressDialog mConnectProgress; |
104 | QWidget* tlw; | 105 | QWidget* tlw; |
105 | QSocket* mSocket; | 106 | QSocket* mSocket; |
106 | QString mPassWord; | 107 | QString mPassWord; |
107 | Q_UINT16 mPort; | 108 | Q_UINT16 mPort; |
108 | QString mHost; | 109 | QString mHost; |
109 | QString mFileName; | 110 | QString mFileName; |
110 | QTimer* mTimerSocket; | 111 | QTimer* mTimerSocket; |
111 | int mRetVal; | 112 | int mRetVal; |
112 | QTime mTime; | 113 | QTime mTime; |
113 | QString mFileString; | 114 | QString mFileString; |
114 | bool mFirst; | 115 | bool mFirst; |
115 | bool mFirstLine; | 116 | bool mFirstLine; |
116 | }; | 117 | }; |
117 | 118 | ||
118 | 119 | ||
119 | class KSyncManager : public QObject | 120 | class KSyncManager : public QObject |
120 | { | 121 | { |
121 | Q_OBJECT | 122 | Q_OBJECT |
122 | 123 | ||
123 | public: | 124 | public: |
124 | enum TargetApp { | 125 | enum TargetApp { |
125 | KOPI = 0, | 126 | KOPI = 0, |
126 | KAPI = 1, | 127 | KAPI = 1, |
127 | PWMPI = 2 }; | 128 | PWMPI = 2 }; |
128 | 129 | ||
129 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 130 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
130 | ~KSyncManager() ; | 131 | ~KSyncManager() ; |
131 | 132 | ||
132 | void multiSync( bool askforPrefs ); | 133 | void multiSync( bool askforPrefs ); |
133 | bool blockSave() { return mBlockSaveFlag; } | 134 | bool blockSave() { return mBlockSaveFlag; } |
134 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 135 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
135 | void setDefaultFileName( QString s) ; | 136 | void setDefaultFileName( QString s) ; |
136 | QString defaultFileName() { return mDefFileName ;} | 137 | QString defaultFileName() { return mDefFileName ;} |
137 | QString syncFileName(); | 138 | QString syncFileName(); |
138 | void enableQuick( bool ask = true); | 139 | void enableQuick( bool ask = true); |
139 | 140 | ||
140 | bool syncWithDesktop () { return mSyncWithDesktop;} | 141 | bool syncWithDesktop () { return mSyncWithDesktop;} |
141 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 142 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
142 | QString getCurrentSyncName() { return mCurrentSyncName; } | 143 | QString getCurrentSyncName() { return mCurrentSyncName; } |
143 | 144 | ||
144 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 145 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
145 | void hideProgressBar(); | 146 | void hideProgressBar(); |
146 | bool isProgressBarCanceled(); | 147 | bool isProgressBarCanceled(); |
147 | 148 | ||
148 | // sync stuff | 149 | // sync stuff |
149 | QString mLocalMachineName; | 150 | QString mLocalMachineName; |
150 | QStringList mExternSyncProfiles; | 151 | QStringList mExternSyncProfiles; |
151 | QStringList mSyncProfileNames; | 152 | QStringList mSyncProfileNames; |
152 | bool mAskForPreferences; | 153 | bool mAskForPreferences; |
153 | bool mShowSyncSummary; | 154 | bool mShowSyncSummary; |
154 | bool mIsKapiFile; | 155 | bool mIsKapiFile; |
155 | bool mWriteBackExistingOnly; | 156 | bool mWriteBackExistingOnly; |
156 | int mSyncAlgoPrefs; | 157 | int mSyncAlgoPrefs; |
157 | bool mWriteBackFile; | 158 | bool mWriteBackFile; |
158 | int mWriteBackInFuture; | 159 | int mWriteBackInFuture; |
159 | int mWriteBackInPast; | 160 | int mWriteBackInPast; |
160 | QString mPhoneDevice; | 161 | QString mPhoneDevice; |
161 | QString mPhoneConnection; | 162 | QString mPhoneConnection; |
162 | QString mPhoneModel; | 163 | QString mPhoneModel; |
163 | QString mPassWordPiSync; | 164 | QString mPassWordPiSync; |
164 | QString mActiveSyncPort; | 165 | QString mActiveSyncPort; |
165 | QString mActiveSyncIP ; | 166 | QString mActiveSyncIP ; |
166 | QString mFilterInCal; | 167 | QString mFilterInCal; |
167 | QString mFilterOutCal; | 168 | QString mFilterOutCal; |
168 | QString mFilterInAB; | 169 | QString mFilterInAB; |
169 | QString mFilterOutAB; | 170 | QString mFilterOutAB; |
170 | static QDateTime mRequestedSyncEvent; | 171 | static QDateTime mRequestedSyncEvent; |
171 | 172 | ||
172 | signals: | 173 | signals: |
173 | void save(); | 174 | void save(); |
174 | void request_file(); | 175 | void request_file(); |
175 | void getFile( bool ); | 176 | void getFile( bool ); |
176 | 177 | ||
177 | public slots: | 178 | public slots: |
178 | void slotSyncMenu( int ); | 179 | void slotSyncMenu( int ); |
179 | void slotClearMenu( int action ); | 180 | void slotClearMenu( int action ); |
180 | void deleteCommandSocket(KCommandSocket*s, int state); | 181 | void deleteCommandSocket(KCommandSocket*s, int state); |
181 | void readFileFromSocket(); | 182 | void readFileFromSocket(); |
182 | void fillSyncMenu(); | 183 | void fillSyncMenu(); |
183 | 184 | ||
184 | private: | 185 | private: |
185 | void syncPi(); | 186 | void syncPi(); |
186 | KServerSocket * mServerSocket; | 187 | KServerSocket * mServerSocket; |
187 | KPimPrefs* mPrefs; | 188 | KPimPrefs* mPrefs; |
188 | QString mDefFileName; | 189 | QString mDefFileName; |
189 | QString mCurrentSyncDevice; | 190 | QString mCurrentSyncDevice; |
190 | QString mCurrentSyncName; | 191 | QString mCurrentSyncName; |
191 | void quickSyncLocalFile(); | 192 | void quickSyncLocalFile(); |
192 | bool syncWithFile( QString fn , bool quick ); | 193 | bool syncWithFile( QString fn , bool quick ); |
193 | void syncLocalFile(); | 194 | void syncLocalFile(); |
194 | void syncPhone(); | 195 | void syncPhone(); |
195 | void syncSharp(); | 196 | void syncSharp(); |
196 | void syncKDE(); | 197 | void syncKDE(); |
197 | bool syncExternalApplication(QString); | 198 | bool syncExternalApplication(QString); |
198 | int mCurrentSyncProfile ; | 199 | int mCurrentSyncProfile ; |
199 | void syncRemote( KSyncProfile* prof, bool ask = true); | 200 | void syncRemote( KSyncProfile* prof, bool ask = true); |
200 | bool edit_sync_options(); | 201 | bool edit_sync_options(); |
201 | bool edit_pisync_options(); | 202 | bool edit_pisync_options(); |
202 | int ringSync(); | 203 | int ringSync(); |
203 | QString getPassword( ); | 204 | QString getPassword( ); |
204 | bool mPisyncFinished; | 205 | bool mPisyncFinished; |
206 | QStringList mSpecificResources; | ||
207 | QString mCurrentResourceLocal; | ||
208 | QString mCurrentResourceRemote; | ||
205 | bool mBlockSaveFlag; | 209 | bool mBlockSaveFlag; |
206 | QWidget* mParent; | 210 | QWidget* mParent; |
207 | KSyncInterface* mImplementation; | 211 | KSyncInterface* mImplementation; |
208 | TargetApp mTargetApp; | 212 | TargetApp mTargetApp; |
209 | QPopupMenu* mSyncMenu; | 213 | QPopupMenu* mSyncMenu; |
210 | QProgressBar* bar; | 214 | QProgressBar* bar; |
211 | bool mSyncWithDesktop; | 215 | bool mSyncWithDesktop; |
212 | 216 | ||
213 | private slots: | 217 | private slots: |
214 | void displayErrorPort(); | 218 | void displayErrorPort(); |
215 | void confSync(); | 219 | void confSync(); |
216 | 220 | ||
217 | 221 | ||
218 | }; | 222 | }; |
219 | 223 | ||
220 | 224 | ||
221 | class KSyncInterface | 225 | class KSyncInterface |
222 | { | 226 | { |
223 | public : | 227 | public : |
224 | virtual void removeSyncInfo( QString syncProfile) = 0; | 228 | virtual void removeSyncInfo( QString syncProfile) = 0; |
225 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 229 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; |
226 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 230 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
227 | { | 231 | { |
228 | // empty implementation, because some syncable applications do not | 232 | // empty implementation, because some syncable applications do not |
229 | // have an external(sharpdtm) syncmode, like pwmanager. | 233 | // have an external(sharpdtm) syncmode, like pwmanager. |
230 | return false; | 234 | return false; |
231 | } | 235 | } |
232 | 236 | ||
233 | 237 | ||
234 | }; | 238 | }; |
235 | 239 | ||
236 | 240 | ||
237 | #endif | 241 | #endif |
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp index 292cde1..27f7932 100644 --- a/libkdepim/ksyncprefsdialog.cpp +++ b/libkdepim/ksyncprefsdialog.cpp | |||
@@ -1,903 +1,903 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qbuttongroup.h> | 27 | #include <qbuttongroup.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qfont.h> | 29 | #include <qfont.h> |
30 | #include <qslider.h> | 30 | #include <qslider.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qvbox.h> | 35 | #include <qvbox.h> |
36 | #include <qhbox.h> | 36 | #include <qhbox.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qstrlist.h> | 42 | #include <qstrlist.h> |
43 | #include <qapplication.h> | 43 | #include <qapplication.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qscrollview.h> | 45 | #include <qscrollview.h> |
46 | #include <qvgroupbox.h> | 46 | #include <qvgroupbox.h> |
47 | #include <qhgroupbox.h> | 47 | #include <qhgroupbox.h> |
48 | 48 | ||
49 | #include <kcolorbutton.h> | 49 | #include <kcolorbutton.h> |
50 | #include <kdebug.h> | 50 | #include <kdebug.h> |
51 | #include <klocale.h> | 51 | #include <klocale.h> |
52 | #include <kglobal.h> | 52 | #include <kglobal.h> |
53 | #include <kfontdialog.h> | 53 | #include <kfontdialog.h> |
54 | #include <kmessagebox.h> | 54 | #include <kmessagebox.h> |
55 | #include <kcolordialog.h> | 55 | #include <kcolordialog.h> |
56 | #include <kiconloader.h> | 56 | #include <kiconloader.h> |
57 | #include <kemailsettings.h> | 57 | #include <kemailsettings.h> |
58 | #include <kstandarddirs.h> | 58 | #include <kstandarddirs.h> |
59 | #include <kfiledialog.h> | 59 | #include <kfiledialog.h> |
60 | #include <kmessagebox.h> | 60 | #include <kmessagebox.h> |
61 | 61 | ||
62 | //#include <kurlrequester.h> | 62 | //#include <kurlrequester.h> |
63 | #include <klineedit.h> | 63 | #include <klineedit.h> |
64 | #include "ksyncprofile.h" | 64 | #include "ksyncprofile.h" |
65 | 65 | ||
66 | 66 | ||
67 | //#include "koprefs.h" | 67 | //#include "koprefs.h" |
68 | 68 | ||
69 | #include "ksyncprefsdialog.h" | 69 | #include "ksyncprefsdialog.h" |
70 | //#include "koglobals.h" | 70 | //#include "koglobals.h" |
71 | 71 | ||
72 | 72 | ||
73 | KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : | 73 | KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : |
74 | KDialog(parent,name,true) | 74 | KDialog(parent,name,true) |
75 | { | 75 | { |
76 | 76 | ||
77 | setCaption( i18n("Synchronization Preferences")); | 77 | setCaption( i18n("Synchronization Preferences")); |
78 | 78 | ||
79 | mSyncProfiles.setAutoDelete( true ); | 79 | mSyncProfiles.setAutoDelete( true ); |
80 | setupSyncAlgTab(); | 80 | setupSyncAlgTab(); |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | KSyncPrefsDialog::~KSyncPrefsDialog() | 84 | KSyncPrefsDialog::~KSyncPrefsDialog() |
85 | { | 85 | { |
86 | } | 86 | } |
87 | 87 | ||
88 | void KSyncPrefsDialog::setupSyncAlgTab() | 88 | void KSyncPrefsDialog::setupSyncAlgTab() |
89 | { | 89 | { |
90 | QLabel * lab; | 90 | QLabel * lab; |
91 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); | 91 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); |
92 | QVBox * mainbox = new QVBox( this ); | 92 | QVBox * mainbox = new QVBox( this ); |
93 | QScrollView* sv = new QScrollView( mainbox ); | 93 | QScrollView* sv = new QScrollView( mainbox ); |
94 | QHBoxLayout * lay = new QHBoxLayout( this ); | 94 | QHBoxLayout * lay = new QHBoxLayout( this ); |
95 | lay->addWidget( mainbox ); | 95 | lay->addWidget( mainbox ); |
96 | QHBox * b_box = new QHBox( mainbox ); | 96 | QHBox * b_box = new QHBox( mainbox ); |
97 | 97 | ||
98 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); | 98 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); |
99 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); | 99 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); |
100 | button = new QPushButton( i18n("Cancel"), b_box ); | 100 | button = new QPushButton( i18n("Cancel"), b_box ); |
101 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); | 101 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); |
102 | //QBoxLayout * sl = new QVBoxLayout(this ); | 102 | //QBoxLayout * sl = new QVBoxLayout(this ); |
103 | //sl->addWidget ( sv ); | 103 | //sl->addWidget ( sv ); |
104 | sv->setResizePolicy ( QScrollView::AutoOneFit ); | 104 | sv->setResizePolicy ( QScrollView::AutoOneFit ); |
105 | QFrame *topFrame = new QFrame ( sv ); | 105 | QFrame *topFrame = new QFrame ( sv ); |
106 | sv->addChild( topFrame ); | 106 | sv->addChild( topFrame ); |
107 | mSetupSyncAlgTab = topFrame; | 107 | mSetupSyncAlgTab = topFrame; |
108 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 108 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
109 | topLayout->setSpacing(spacingHint()); | 109 | topLayout->setSpacing(spacingHint()); |
110 | topLayout->setMargin(marginHint()); | 110 | topLayout->setMargin(marginHint()); |
111 | 111 | ||
112 | //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); | 112 | //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); |
113 | int iii = 0; | 113 | int iii = 0; |
114 | //topLayout->addMultiCellWidget(lab , iii,iii,0,1); | 114 | //topLayout->addMultiCellWidget(lab , iii,iii,0,1); |
115 | //++iii; | 115 | //++iii; |
116 | 116 | ||
117 | mMyMachineName = new QLineEdit(topFrame); | 117 | mMyMachineName = new QLineEdit(topFrame); |
118 | lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); | 118 | lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); |
119 | topLayout->addWidget(lab ,iii,0); | 119 | topLayout->addWidget(lab ,iii,0); |
120 | topLayout->addWidget(mMyMachineName,iii,1); | 120 | topLayout->addWidget(mMyMachineName,iii,1); |
121 | ++iii; | 121 | ++iii; |
122 | 122 | ||
123 | QHBox* buttonbox = new QHBox( topFrame); | 123 | QHBox* buttonbox = new QHBox( topFrame); |
124 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); | 124 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); |
125 | ++iii; | 125 | ++iii; |
126 | button = new QPushButton( i18n("New profile"), buttonbox ); | 126 | button = new QPushButton( i18n("New profile"), buttonbox ); |
127 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); | 127 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); |
128 | 128 | ||
129 | button = new QPushButton( i18n("Clone profile"), buttonbox ); | 129 | button = new QPushButton( i18n("Clone profile"), buttonbox ); |
130 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); | 130 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); |
131 | 131 | ||
132 | button = new QPushButton( i18n("Delete profile"), buttonbox ); | 132 | button = new QPushButton( i18n("Delete profile"), buttonbox ); |
133 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); | 133 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); |
134 | 134 | ||
135 | mProfileBox = new QComboBox(topFrame); | 135 | mProfileBox = new QComboBox(topFrame); |
136 | mProfileBox->setEditable ( true ); | 136 | mProfileBox->setEditable ( true ); |
137 | mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); | 137 | mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); |
138 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); | 138 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); |
139 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); | 139 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); |
140 | 140 | ||
141 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); | 141 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); |
142 | topLayout->addWidget(lab ,iii,0); | 142 | topLayout->addWidget(lab ,iii,0); |
143 | topLayout->addWidget(mProfileBox, iii,1); | 143 | topLayout->addWidget(mProfileBox, iii,1); |
144 | ++iii; | 144 | ++iii; |
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); | 148 | QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); |
149 | new QLabel( i18n("Include in multiple "), iims ); | 149 | new QLabel( i18n("Include in multiple "), iims ); |
150 | mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); | 150 | mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); |
151 | mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); | 151 | mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); |
152 | mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); | 152 | mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); |
153 | new QLabel( i18n(" sync"), iims ); | 153 | new QLabel( i18n(" sync"), iims ); |
154 | topLayout->addMultiCellWidget(iims, iii,iii,0,1); | 154 | topLayout->addMultiCellWidget(iims, iii,iii,0,1); |
155 | ++iii; | 155 | ++iii; |
156 | QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); | 156 | QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); |
157 | topLayout->addMultiCellWidget(gb0, iii,iii,0,1); | 157 | topLayout->addMultiCellWidget(gb0, iii,iii,0,1); |
158 | ++iii; | 158 | ++iii; |
159 | QButtonGroup* gr; | 159 | QButtonGroup* gr; |
160 | { | 160 | { |
161 | QVGroupBox* topFrame = gb0; | 161 | QVGroupBox* topFrame = gb0; |
162 | 162 | ||
163 | 163 | ||
164 | 164 | ||
165 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); | 165 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); |
166 | //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); | 166 | //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); |
167 | //++iii; | 167 | //++iii; |
168 | gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); | 168 | gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); |
169 | //topLayout->addMultiCellWidget(gr, iii,iii,0,1); | 169 | //topLayout->addMultiCellWidget(gr, iii,iii,0,1); |
170 | //++iii; | 170 | //++iii; |
171 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); | 171 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); |
172 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); | 172 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); |
173 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); | 173 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); |
174 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); | 174 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); |
175 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); | 175 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); |
176 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); | 176 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); |
177 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); | 177 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); |
178 | 178 | ||
179 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); | 179 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); |
180 | //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); | 180 | //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); |
181 | //++iii; | 181 | //++iii; |
182 | 182 | ||
183 | #if 0 | 183 | #if 0 |
184 | QHGroupBox* gb51 = new QHGroupBox( i18n("Local resources to sync with:"), topFrame); | 184 | QHGroupBox* gb51 = new QHGroupBox( i18n("Local resources to sync with:"), topFrame); |
185 | { | 185 | { |
186 | QVBox * fibo2 = new QVBox ( gb51 ); | 186 | QVBox * fibo2 = new QVBox ( gb51 ); |
187 | new QLabel ( i18n("Calendar resources:"), fibo2 ); | 187 | new QLabel ( i18n("Calendar resources:"), fibo2 ); |
188 | //mFilterInCal = new QComboBox( fibo2 ); | 188 | //mFilterInCal = new QComboBox( fibo2 ); |
189 | fibo2 = new QVBox ( gb51 ); | 189 | fibo2 = new QVBox ( gb51 ); |
190 | new QLabel ( i18n("Addressbook resources:"), fibo2 ); | 190 | new QLabel ( i18n("Addressbook resources:"), fibo2 ); |
191 | //mFilterInAB = new QComboBox( fibo2 ); | 191 | //mFilterInAB = new QComboBox( fibo2 ); |
192 | } | 192 | } |
193 | #endif | 193 | #endif |
194 | QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); | 194 | QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); |
195 | QVBox * fibo2 = new QVBox ( gb5 ); | 195 | QVBox * fibo2 = new QVBox ( gb5 ); |
196 | new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); | 196 | new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); |
197 | mFilterInCal = new QComboBox( fibo2 ); | 197 | mFilterInCal = new QComboBox( fibo2 ); |
198 | fibo2 = new QVBox ( gb5 ); | 198 | fibo2 = new QVBox ( gb5 ); |
199 | new QLabel ( i18n("Incoming addressbook filter:"), fibo2 ); | 199 | new QLabel ( i18n("Incoming addressbook filter:"), fibo2 ); |
200 | mFilterInAB = new QComboBox( fibo2 ); | 200 | mFilterInAB = new QComboBox( fibo2 ); |
201 | 201 | ||
202 | mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); | 202 | mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); |
203 | // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); | 203 | // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); |
204 | // ++iii; | 204 | // ++iii; |
205 | 205 | ||
206 | QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); | 206 | QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); |
207 | //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); | 207 | //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); |
208 | //++iii; | 208 | //++iii; |
209 | { | 209 | { |
210 | QVGroupBox*topFrame = gb2; | 210 | QVGroupBox*topFrame = gb2; |
211 | mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); | 211 | mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); |
212 | QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); | 212 | QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); |
213 | QVBox * fibo = new QVBox ( gb4 ); | 213 | QVBox * fibo = new QVBox ( gb4 ); |
214 | new QLabel ( i18n("Outgoing calendar filter:"), fibo ); | 214 | new QLabel ( i18n("Outgoing calendar filter:"), fibo ); |
215 | mFilterOutCal = new QComboBox( fibo ); | 215 | mFilterOutCal = new QComboBox( fibo ); |
216 | fibo = new QVBox ( gb4 ); | 216 | fibo = new QVBox ( gb4 ); |
217 | new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); | 217 | new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); |
218 | mFilterOutAB = new QComboBox( fibo ); | 218 | mFilterOutAB = new QComboBox( fibo ); |
219 | //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); | 219 | //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); |
220 | //++iii; | 220 | //++iii; |
221 | mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); | 221 | mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); |
222 | //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); | 222 | //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); |
223 | //++iii; | 223 | //++iii; |
224 | QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame); | 224 | QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame); |
225 | connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); | 225 | connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); |
226 | new QLabel( i18n("From ") , gb3 ); | 226 | new QLabel( i18n("From ") , gb3 ); |
227 | mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3); | 227 | mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3); |
228 | new QLabel( i18n(" weeks in the past to ") , gb3 ); | 228 | new QLabel( i18n(" weeks in the past to ") , gb3 ); |
229 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3); | 229 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3); |
230 | new QLabel( i18n(" weeks in the future ") , gb3 ); | 230 | new QLabel( i18n(" weeks in the future ") , gb3 ); |
231 | //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); | 231 | //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); |
232 | //++iii; | 232 | //++iii; |
233 | gb3->setEnabled( false ); | 233 | gb3->setEnabled( false ); |
234 | connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); | 234 | connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); |
235 | } | 235 | } |
236 | connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); | 236 | connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); |
237 | 237 | ||
238 | } | 238 | } |
239 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); | 239 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); |
240 | gr = proGr; | 240 | gr = proGr; |
241 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); | 241 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); |
242 | ++iii; | 242 | ++iii; |
243 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); | 243 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); |
244 | mIsPi = new QRadioButton ( i18n("Pi-Sync - all resources ( direct Kx/Pi to Kx/Pi sync )"), gr ); | 244 | mIsPi = new QRadioButton ( i18n("Pi-Sync - all resources ( direct Kx/Pi to Kx/Pi sync )"), gr ); |
245 | connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 245 | connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
246 | mIsPiSpecific = new QRadioButton ( i18n("Pi-Sync - selected resources ( direct Kx/Pi to Kx/Pi sync )"), gr ); | 246 | mIsPiSpecific = new QRadioButton ( i18n("Pi-Sync - selected resources ( direct Kx/Pi to Kx/Pi sync )"), gr ); |
247 | connect (mIsPiSpecific, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 247 | connect (mIsPiSpecific, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
248 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); | 248 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); |
249 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 249 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
250 | mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); | 250 | mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); |
251 | connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 251 | connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
252 | 252 | ||
253 | QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); | 253 | QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); |
254 | topLayout->addMultiCellWidget(gb1, iii,iii,0,1); | 254 | topLayout->addMultiCellWidget(gb1, iii,iii,0,1); |
255 | ++iii; | 255 | ++iii; |
256 | 256 | ||
257 | // ****************************************** | 257 | // ****************************************** |
258 | // Profile kind specific settings | 258 | // Profile kind specific settings |
259 | { | 259 | { |
260 | // *** phone ******************************* | 260 | // *** phone ******************************* |
261 | QVGroupBox* topFrame = gb1; | 261 | QVGroupBox* topFrame = gb1; |
262 | phoneWidget = new QVBox( topFrame); | 262 | phoneWidget = new QVBox( topFrame); |
263 | //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); | 263 | //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); |
264 | //++iii; | 264 | //++iii; |
265 | mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); | 265 | mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); |
266 | QHBox* temphb = new QHBox( phoneWidget ); | 266 | QHBox* temphb = new QHBox( phoneWidget ); |
267 | new QLabel( i18n("I/O device: "), temphb ); | 267 | new QLabel( i18n("I/O device: "), temphb ); |
268 | mPhoneDevice = new QLineEdit( temphb); | 268 | mPhoneDevice = new QLineEdit( temphb); |
269 | button = new QPushButton( i18n("Help..."), temphb ); | 269 | button = new QPushButton( i18n("Help..."), temphb ); |
270 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); | 270 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); |
271 | 271 | ||
272 | 272 | ||
273 | temphb = new QHBox( phoneWidget ); | 273 | temphb = new QHBox( phoneWidget ); |
274 | new QLabel( i18n("Connection: "), temphb ); | 274 | new QLabel( i18n("Connection: "), temphb ); |
275 | mPhoneConnection = new QLineEdit( temphb); | 275 | mPhoneConnection = new QLineEdit( temphb); |
276 | button = new QPushButton( i18n("Help..."), temphb ); | 276 | button = new QPushButton( i18n("Help..."), temphb ); |
277 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); | 277 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); |
278 | 278 | ||
279 | 279 | ||
280 | temphb = new QHBox( phoneWidget ); | 280 | temphb = new QHBox( phoneWidget ); |
281 | new QLabel( i18n("Model(opt.): "), temphb ); | 281 | new QLabel( i18n("Model(opt.): "), temphb ); |
282 | mPhoneModel = new QLineEdit( temphb); | 282 | mPhoneModel = new QLineEdit( temphb); |
283 | button = new QPushButton( i18n("Help..."), temphb ); | 283 | button = new QPushButton( i18n("Help..."), temphb ); |
284 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); | 284 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); |
285 | 285 | ||
286 | // *** local******************************* | 286 | // *** local******************************* |
287 | localFileWidget = new QVBox( topFrame); | 287 | localFileWidget = new QVBox( topFrame); |
288 | //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); | 288 | //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); |
289 | //++iii; | 289 | //++iii; |
290 | temphb = new QHBox( localFileWidget ); | 290 | temphb = new QHBox( localFileWidget ); |
291 | 291 | ||
292 | lab = new QLabel( i18n("Local file Cal:"), temphb ); | 292 | lab = new QLabel( i18n("Local file Cal:"), temphb ); |
293 | lab = new QLabel( i18n("Local file ABook:"), temphb ); | 293 | lab = new QLabel( i18n("Local file ABook:"), temphb ); |
294 | lab = new QLabel( i18n("Local file PWMgr:"), temphb ); | 294 | lab = new QLabel( i18n("Local file PWMgr:"), temphb ); |
295 | temphb = new QHBox( localFileWidget ); | 295 | temphb = new QHBox( localFileWidget ); |
296 | button = new QPushButton( i18n("Choose..."), temphb ); | 296 | button = new QPushButton( i18n("Choose..."), temphb ); |
297 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); | 297 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); |
298 | button = new QPushButton( i18n("Choose..."), temphb ); | 298 | button = new QPushButton( i18n("Choose..."), temphb ); |
299 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); | 299 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); |
300 | button = new QPushButton( i18n("Choose..."), temphb ); | 300 | button = new QPushButton( i18n("Choose..."), temphb ); |
301 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); | 301 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); |
302 | temphb = new QHBox( localFileWidget ); | 302 | temphb = new QHBox( localFileWidget ); |
303 | 303 | ||
304 | mRemoteFile = new QLineEdit( temphb); | 304 | mRemoteFile = new QLineEdit( temphb); |
305 | mRemoteFileAB = new QLineEdit( temphb); | 305 | mRemoteFileAB = new QLineEdit( temphb); |
306 | mRemoteFilePWM = new QLineEdit( temphb); | 306 | mRemoteFilePWM = new QLineEdit( temphb); |
307 | mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); | 307 | mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); |
308 | 308 | ||
309 | 309 | ||
310 | // *** remote******************************* | 310 | // *** remote******************************* |
311 | remoteFileWidget = new QVBox( topFrame); | 311 | remoteFileWidget = new QVBox( topFrame); |
312 | //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); | 312 | //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); |
313 | //++iii; | 313 | //++iii; |
314 | temphb = new QHBox( remoteFileWidget ); | 314 | temphb = new QHBox( remoteFileWidget ); |
315 | new QLabel( i18n("Calendar:"), temphb); | 315 | new QLabel( i18n("Calendar:"), temphb); |
316 | new QLabel( i18n("AddressBook:"), temphb); | 316 | new QLabel( i18n("AddressBook:"), temphb); |
317 | new QLabel( i18n("PWManager:"), temphb); | 317 | new QLabel( i18n("PWManager:"), temphb); |
318 | 318 | ||
319 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); | 319 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); |
320 | temphb = new QHBox( remoteFileWidget ); | 320 | temphb = new QHBox( remoteFileWidget ); |
321 | mRemotePrecommand = new QLineEdit(temphb); | 321 | mRemotePrecommand = new QLineEdit(temphb); |
322 | mRemotePrecommandAB = new QLineEdit(temphb); | 322 | mRemotePrecommandAB = new QLineEdit(temphb); |
323 | mRemotePrecommandPWM = new QLineEdit(temphb); | 323 | mRemotePrecommandPWM = new QLineEdit(temphb); |
324 | 324 | ||
325 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); | 325 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); |
326 | temphb = new QHBox( remoteFileWidget ); | 326 | temphb = new QHBox( remoteFileWidget ); |
327 | mLocalTempFile = new QLineEdit(temphb); | 327 | mLocalTempFile = new QLineEdit(temphb); |
328 | mLocalTempFileAB = new QLineEdit(temphb); | 328 | mLocalTempFileAB = new QLineEdit(temphb); |
329 | mLocalTempFilePWM = new QLineEdit(temphb); | 329 | mLocalTempFilePWM = new QLineEdit(temphb); |
330 | 330 | ||
331 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); | 331 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); |
332 | temphb = new QHBox( remoteFileWidget ); | 332 | temphb = new QHBox( remoteFileWidget ); |
333 | mRemotePostcommand = new QLineEdit(temphb ); | 333 | mRemotePostcommand = new QLineEdit(temphb ); |
334 | mRemotePostcommandAB = new QLineEdit(temphb ); | 334 | mRemotePostcommandAB = new QLineEdit(temphb ); |
335 | mRemotePostcommandPWM = new QLineEdit(temphb ); | 335 | mRemotePostcommandPWM = new QLineEdit(temphb ); |
336 | mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); | 336 | mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); |
337 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); | 337 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); |
338 | temphb = new QHBox( remoteFileWidget ); | 338 | temphb = new QHBox( remoteFileWidget ); |
339 | button = new QPushButton( i18n("ssh/scp"), temphb ); | 339 | button = new QPushButton( i18n("ssh/scp"), temphb ); |
340 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); | 340 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); |
341 | button = new QPushButton( i18n("ftp"), temphb ); | 341 | button = new QPushButton( i18n("ftp"), temphb ); |
342 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); | 342 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); |
343 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); | 343 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); |
344 | 344 | ||
345 | // *** pi-sync******************************* | 345 | // *** pi-sync******************************* |
346 | piWidget = new QVBox( topFrame); | 346 | piWidget = new QVBox( topFrame); |
347 | //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); | 347 | //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); |
348 | //++iii; | 348 | //++iii; |
349 | temphb = new QHBox( piWidget ); | 349 | temphb = new QHBox( piWidget ); |
350 | new QLabel( i18n("Calendar:"), temphb); | 350 | new QLabel( i18n("Calendar:"), temphb); |
351 | new QLabel( i18n("AddressBook:"), temphb); | 351 | new QLabel( i18n("AddressBook:"), temphb); |
352 | new QLabel( i18n("PWManager:"), temphb); | 352 | new QLabel( i18n("PWManager:"), temphb); |
353 | 353 | ||
354 | lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); | 354 | lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); |
355 | temphb = new QHBox( piWidget ); | 355 | temphb = new QHBox( piWidget ); |
356 | mRemotePw = new QLineEdit(temphb); | 356 | mRemotePw = new QLineEdit(temphb); |
357 | mRemotePwAB = new QLineEdit(temphb); | 357 | mRemotePwAB = new QLineEdit(temphb); |
358 | mRemotePwPWM = new QLineEdit(temphb); | 358 | mRemotePwPWM = new QLineEdit(temphb); |
359 | 359 | ||
360 | lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); | 360 | lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); |
361 | temphb = new QHBox( piWidget ); | 361 | temphb = new QHBox( piWidget ); |
362 | mRemoteIP = new QLineEdit(temphb); | 362 | mRemoteIP = new QLineEdit(temphb); |
363 | mRemoteIPAB = new QLineEdit(temphb); | 363 | mRemoteIPAB = new QLineEdit(temphb); |
364 | mRemoteIPPWM = new QLineEdit(temphb); | 364 | mRemoteIPPWM = new QLineEdit(temphb); |
365 | 365 | ||
366 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); | 366 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); |
367 | temphb = new QHBox( piWidget ); | 367 | temphb = new QHBox( piWidget ); |
368 | mRemotePort = new QLineEdit(temphb); | 368 | mRemotePort = new QLineEdit(temphb); |
369 | mRemotePortAB = new QLineEdit(temphb); | 369 | mRemotePortAB = new QLineEdit(temphb); |
370 | mRemotePortPWM = new QLineEdit(temphb); | 370 | mRemotePortPWM = new QLineEdit(temphb); |
371 | 371 | ||
372 | lab = new QLabel( i18n("Local/remote Resource sync partners"), piWidget); | 372 | lab = new QLabel( i18n("Local/remote Resource sync partners"), piWidget); |
373 | mTableBox = new QHBox( piWidget ); | 373 | mTableBox = new QHBox( piWidget ); |
374 | mResTableKopi = new QTable( 1, 1, mTableBox ); | 374 | mResTableKopi = new QTable( 1, 1, mTableBox ); |
375 | mResTableKapi = new QTable( 1, 1, mTableBox ); | 375 | mResTableKapi = new QTable( 1, 1, mTableBox ); |
376 | mResTablePwmpi = new QTable( 1, 1, mTableBox ); | 376 | mResTablePwmpi = new QTable( 1, 1, mTableBox ); |
377 | mResTableKopi->horizontalHeader()->setLabel( 0, i18n("Remote") ); | 377 | mResTableKopi->horizontalHeader()->setLabel( 0, i18n("Remote") ); |
378 | mResTableKapi->horizontalHeader()->setLabel( 0, i18n("Remote") ); | 378 | mResTableKapi->horizontalHeader()->setLabel( 0, i18n("Remote") ); |
379 | mResTablePwmpi->horizontalHeader()->setLabel( 0, i18n("Remote") ); | 379 | mResTablePwmpi->horizontalHeader()->setLabel( 0, i18n("Remote") ); |
380 | mResTableKopi->setLeftMargin( 80 ); | 380 | mResTableKopi->setLeftMargin( 80 ); |
381 | } | 381 | } |
382 | // ****************************************** | 382 | // ****************************************** |
383 | // Profile kind specific settings END | 383 | // Profile kind specific settings END |
384 | 384 | ||
385 | } | 385 | } |
386 | 386 | ||
387 | void KSyncPrefsDialog::readResources() | 387 | void KSyncPrefsDialog::readResources() |
388 | { | 388 | { |
389 | mResourcesKopi.clear(); | 389 | mResourcesKopi.clear(); |
390 | mResourcesKapi.clear(); | 390 | mResourcesKapi.clear(); |
391 | KConfig fc(locateLocal("config","kopicalendarrc")); | 391 | KConfig fc(locateLocal("config","kopicalendarrc")); |
392 | fc.setGroup("CC"); | 392 | fc.setGroup("CC"); |
393 | int numCals = fc.readNumEntry("NumberCalendars",0 ); | 393 | int numCals = fc.readNumEntry("NumberCalendars",0 ); |
394 | int curCal = 1; | 394 | int curCal = 1; |
395 | while ( curCal <= numCals ) { | 395 | while ( curCal <= numCals ) { |
396 | QString prefix = "Cal_" +QString::number( curCal ); | 396 | QString prefix = "Cal_" +QString::number( curCal ); |
397 | QString name = fc.readEntry( prefix+"_Name", "Calendar"); | 397 | QString name = fc.readEntry( prefix+"_Name", "Calendar"); |
398 | mResourcesKopi.append( name ); | 398 | mResourcesKopi.append( name ); |
399 | ++curCal; | 399 | ++curCal; |
400 | } | 400 | } |
401 | mResTableKopi->setNumRows( mResourcesKopi.count() ); | 401 | mResTableKopi->setNumRows( mResourcesKopi.count() ); |
402 | int i; | 402 | int i; |
403 | for ( i = 0;i < mResourcesKopi.count(); ++i ) { | 403 | for ( i = 0;i < mResourcesKopi.count(); ++i ) { |
404 | mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] ); | 404 | mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] ); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | void KSyncPrefsDialog::readFilter() | 407 | void KSyncPrefsDialog::readFilter() |
408 | { | 408 | { |
409 | mFilterKapi.clear(); | 409 | mFilterKapi.clear(); |
410 | mFilterKopi.clear(); | 410 | mFilterKopi.clear(); |
411 | KConfig cfgko(locateLocal("config","korganizerrc")); | 411 | KConfig cfgko(locateLocal("config","korganizerrc")); |
412 | KConfig cfgka(locateLocal("config","kaddressbookrc")); | 412 | KConfig cfgka(locateLocal("config","kaddressbookrc")); |
413 | cfgko.setGroup("General"); | 413 | cfgko.setGroup("General"); |
414 | mFilterKopi = cfgko.readListEntry("CalendarFilters"); | 414 | mFilterKopi = cfgko.readListEntry("CalendarFilters"); |
415 | cfgka.setGroup("Filter"); | 415 | cfgka.setGroup("Filter"); |
416 | int count = cfgka.readNumEntry( "Count", 0 ); | 416 | int count = cfgka.readNumEntry( "Count", 0 ); |
417 | for ( int i = 0; i < count; i++ ) { | 417 | for ( int i = 0; i < count; i++ ) { |
418 | cfgka.setGroup("Filter_"+QString::number( i ) ); | 418 | cfgka.setGroup("Filter_"+QString::number( i ) ); |
419 | mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); | 419 | mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); |
420 | } | 420 | } |
421 | mFilterOutCal->clear(); | 421 | mFilterOutCal->clear(); |
422 | mFilterInCal->clear(); | 422 | mFilterInCal->clear(); |
423 | mFilterOutAB->clear(); | 423 | mFilterOutAB->clear(); |
424 | mFilterInAB->clear(); | 424 | mFilterInAB->clear(); |
425 | QStringList temp = mFilterKopi; | 425 | QStringList temp = mFilterKopi; |
426 | temp.prepend(i18n("No Filter") ); | 426 | temp.prepend(i18n("No Filter") ); |
427 | mFilterOutCal->insertStringList( temp ); | 427 | mFilterOutCal->insertStringList( temp ); |
428 | mFilterInCal->insertStringList( temp ); | 428 | mFilterInCal->insertStringList( temp ); |
429 | temp = mFilterKapi; | 429 | temp = mFilterKapi; |
430 | temp.prepend(i18n("No Filter") ); | 430 | temp.prepend(i18n("No Filter") ); |
431 | mFilterOutAB->insertStringList( temp ); | 431 | mFilterOutAB->insertStringList( temp ); |
432 | mFilterInAB->insertStringList( temp ); | 432 | mFilterInAB->insertStringList( temp ); |
433 | } | 433 | } |
434 | 434 | ||
435 | void KSyncPrefsDialog::slotOK() | 435 | void KSyncPrefsDialog::slotOK() |
436 | { | 436 | { |
437 | if ( mMyMachineName->text() == "undefined" ) { | 437 | if ( mMyMachineName->text() == "undefined" ) { |
438 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); | 438 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); |
439 | return; | 439 | return; |
440 | } | 440 | } |
441 | int i; | 441 | int i; |
442 | for (i = 0; i < mSyncProfileNames.count(); ++ i) { | 442 | for (i = 0; i < mSyncProfileNames.count(); ++ i) { |
443 | if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { | 443 | if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { |
444 | KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); | 444 | KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); |
445 | return; | 445 | return; |
446 | } | 446 | } |
447 | } | 447 | } |
448 | usrWriteConfig(); | 448 | usrWriteConfig(); |
449 | QDialog::accept(); | 449 | QDialog::accept(); |
450 | } | 450 | } |
451 | void KSyncPrefsDialog::accept() | 451 | void KSyncPrefsDialog::accept() |
452 | { | 452 | { |
453 | slotOK(); | 453 | slotOK(); |
454 | } | 454 | } |
455 | void KSyncPrefsDialog::chooseFile() | 455 | void KSyncPrefsDialog::chooseFile() |
456 | { | 456 | { |
457 | QString fn = QDir::homeDirPath(); | 457 | QString fn = QDir::homeDirPath(); |
458 | 458 | ||
459 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 459 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
460 | if ( fn == "" ) | 460 | if ( fn == "" ) |
461 | return; | 461 | return; |
462 | mRemoteFile->setText( fn ); | 462 | mRemoteFile->setText( fn ); |
463 | } | 463 | } |
464 | 464 | ||
465 | void KSyncPrefsDialog::chooseFileAB() | 465 | void KSyncPrefsDialog::chooseFileAB() |
466 | { | 466 | { |
467 | QString fn = QDir::homeDirPath(); | 467 | QString fn = QDir::homeDirPath(); |
468 | 468 | ||
469 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); | 469 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); |
470 | if ( fn == "" ) | 470 | if ( fn == "" ) |
471 | return; | 471 | return; |
472 | mRemoteFileAB->setText( fn ); | 472 | mRemoteFileAB->setText( fn ); |
473 | } | 473 | } |
474 | 474 | ||
475 | void KSyncPrefsDialog::chooseFilePWM() | 475 | void KSyncPrefsDialog::chooseFilePWM() |
476 | { | 476 | { |
477 | QString fn = QDir::homeDirPath(); | 477 | QString fn = QDir::homeDirPath(); |
478 | 478 | ||
479 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); | 479 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); |
480 | if ( fn == "" ) | 480 | if ( fn == "" ) |
481 | return; | 481 | return; |
482 | mRemoteFilePWM->setText( fn ); | 482 | mRemoteFilePWM->setText( fn ); |
483 | } | 483 | } |
484 | 484 | ||
485 | void KSyncPrefsDialog::textChanged( const QString & s ) | 485 | void KSyncPrefsDialog::textChanged( const QString & s ) |
486 | { | 486 | { |
487 | if ( mProfileBox->count() == 0 ) | 487 | if ( mProfileBox->count() == 0 ) |
488 | return; | 488 | return; |
489 | if ( currentSelection < 3 ) { | 489 | if ( currentSelection < 3 ) { |
490 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); | 490 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); |
491 | mProfileBox->blockSignals( true ); | 491 | mProfileBox->blockSignals( true ); |
492 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); | 492 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); |
493 | mProfileBox->blockSignals( false ); | 493 | mProfileBox->blockSignals( false ); |
494 | return; | 494 | return; |
495 | } | 495 | } |
496 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); | 496 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); |
497 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; | 497 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; |
498 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; | 498 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; |
499 | prof->setName( s ); | 499 | prof->setName( s ); |
500 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; | 500 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; |
501 | } | 501 | } |
502 | void KSyncPrefsDialog::profileChanged( int item ) | 502 | void KSyncPrefsDialog::profileChanged( int item ) |
503 | { | 503 | { |
504 | //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); | 504 | //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); |
505 | KSyncProfile* prof; | 505 | KSyncProfile* prof; |
506 | saveProfile(); | 506 | saveProfile(); |
507 | readFilter(); | 507 | readFilter(); |
508 | readResources(); | 508 | readResources(); |
509 | currentSelection = item; | 509 | currentSelection = item; |
510 | prof = mSyncProfiles.at(item) ; | 510 | prof = mSyncProfiles.at(item) ; |
511 | 511 | ||
512 | mRemotePw->setText(prof->getRemotePw()); | 512 | mRemotePw->setText(prof->getRemotePw()); |
513 | mRemoteIP->setText(prof->getRemoteIP()); | 513 | mRemoteIP->setText(prof->getRemoteIP()); |
514 | mRemotePort->setText(prof->getRemotePort()); | 514 | mRemotePort->setText(prof->getRemotePort()); |
515 | 515 | ||
516 | mRemotePwAB->setText(prof->getRemotePwAB()); | 516 | mRemotePwAB->setText(prof->getRemotePwAB()); |
517 | mRemoteIPAB->setText(prof->getRemoteIPAB()); | 517 | mRemoteIPAB->setText(prof->getRemoteIPAB()); |
518 | mRemotePortAB->setText(prof->getRemotePortAB()); | 518 | mRemotePortAB->setText(prof->getRemotePortAB()); |
519 | 519 | ||
520 | mRemotePwPWM->setText(prof->getRemotePwPWM()); | 520 | mRemotePwPWM->setText(prof->getRemotePwPWM()); |
521 | mRemoteIPPWM->setText(prof->getRemoteIPPWM()); | 521 | mRemoteIPPWM->setText(prof->getRemoteIPPWM()); |
522 | mRemotePortPWM->setText(prof->getRemotePortPWM()); | 522 | mRemotePortPWM->setText(prof->getRemotePortPWM()); |
523 | 523 | ||
524 | mRemotePrecommand->setText(prof->getPreSyncCommand()); | 524 | mRemotePrecommand->setText(prof->getPreSyncCommand()); |
525 | mRemotePostcommand->setText(prof->getPostSyncCommand()); | 525 | mRemotePostcommand->setText(prof->getPostSyncCommand()); |
526 | mLocalTempFile->setText(prof->getLocalTempFile()); | 526 | mLocalTempFile->setText(prof->getLocalTempFile()); |
527 | mRemoteFile->setText(prof->getRemoteFileName()) ; | 527 | mRemoteFile->setText(prof->getRemoteFileName()) ; |
528 | 528 | ||
529 | mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); | 529 | mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); |
530 | mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); | 530 | mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); |
531 | mLocalTempFileAB->setText(prof->getLocalTempFileAB()); | 531 | mLocalTempFileAB->setText(prof->getLocalTempFileAB()); |
532 | mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; | 532 | mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; |
533 | 533 | ||
534 | mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); | 534 | mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); |
535 | mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); | 535 | mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); |
536 | mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); | 536 | mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); |
537 | mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; | 537 | mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; |
538 | 538 | ||
539 | if ( mWriteContactToSIM ) | 539 | if ( mWriteContactToSIM ) |
540 | mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); | 540 | mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); |
541 | mPhoneDevice->setText(prof->getPhoneDevice()); | 541 | mPhoneDevice->setText(prof->getPhoneDevice()); |
542 | mPhoneConnection->setText(prof->getPhoneConnection()); | 542 | mPhoneConnection->setText(prof->getPhoneConnection()); |
543 | mPhoneModel->setText(prof->getPhoneModel()); | 543 | mPhoneModel->setText(prof->getPhoneModel()); |
544 | 544 | ||
545 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); | 545 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); |
546 | mAskForPreferences->setChecked( prof->getAskForPreferences()); | 546 | mAskForPreferences->setChecked( prof->getAskForPreferences()); |
547 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); | 547 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); |
548 | mWriteBackFile->setChecked( prof->getWriteBackFile()); | 548 | mWriteBackFile->setChecked( prof->getWriteBackFile()); |
549 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); | 549 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); |
550 | mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); | 550 | mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); |
551 | mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); | 551 | mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); |
552 | mWriteBackFuture->setChecked( prof->getWriteBackFuture()); | 552 | mWriteBackFuture->setChecked( prof->getWriteBackFuture()); |
553 | mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); | 553 | mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); |
554 | mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() ); | 554 | mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() ); |
555 | 555 | ||
556 | mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 ); | 556 | mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 ); |
557 | mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 ); | 557 | mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 ); |
558 | mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 ); | 558 | mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 ); |
559 | mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 ); | 559 | mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 ); |
560 | 560 | ||
561 | switch ( prof->getSyncPrefs() ) { | 561 | switch ( prof->getSyncPrefs() ) { |
562 | case 0: | 562 | case 0: |
563 | loc->setChecked( true); | 563 | loc->setChecked( true); |
564 | break; | 564 | break; |
565 | case 1: | 565 | case 1: |
566 | rem->setChecked( true ); | 566 | rem->setChecked( true ); |
567 | break; | 567 | break; |
568 | case 2: | 568 | case 2: |
569 | newest->setChecked( true); | 569 | newest->setChecked( true); |
570 | break; | 570 | break; |
571 | case 3: | 571 | case 3: |
572 | ask->setChecked( true); | 572 | ask->setChecked( true); |
573 | break; | 573 | break; |
574 | case 4: | 574 | case 4: |
575 | f_loc->setChecked( true); | 575 | f_loc->setChecked( true); |
576 | break; | 576 | break; |
577 | case 5: | 577 | case 5: |
578 | f_rem->setChecked( true); | 578 | f_rem->setChecked( true); |
579 | break; | 579 | break; |
580 | case 6: | 580 | case 6: |
581 | //both->setChecked( true); | 581 | //both->setChecked( true); |
582 | break; | 582 | break; |
583 | default: | 583 | default: |
584 | break; | 584 | break; |
585 | } | 585 | } |
586 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; | 586 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; |
587 | mIsPhone->setChecked(prof->getIsPhoneSync()) ; | 587 | mIsPhone->setChecked(prof->getIsPhoneSync()) ; |
588 | mIsPi->setChecked(prof->getIsPiSync()) ; | 588 | mIsPi->setChecked(prof->getIsPiSync()) ; |
589 | mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ; | 589 | mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ; |
590 | mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; | 590 | mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; |
591 | mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; | 591 | mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; |
592 | 592 | ||
593 | 593 | ||
594 | QStringList res = QStringList::split( ":",prof->getResSpecKopi()); | 594 | QStringList res = QStringList::split( ":",prof->getResSpecKopi()); |
595 | int i; | 595 | int i= res.count()/2; |
596 | for ( i = 0;i < res.count(); ++i ) { | 596 | for ( ;i < res.count(); ++i ) { |
597 | mResTableKopi->setText( i, 0, res[i] ); | 597 | mResTableKopi->setText( i, 0, res[i] ); |
598 | } | 598 | } |
599 | res = QStringList::split( ":",prof->getResSpecKapi()); | 599 | res = QStringList::split( ":",prof->getResSpecKapi()); |
600 | for ( i = 0;i < res.count(); ++i ) { | 600 | for ( i = 0;i < res.count(); ++i ) { |
601 | mResTableKapi->setText( i, 0, res[i] ); | 601 | mResTableKapi->setText( i, 0, res[i] ); |
602 | } | 602 | } |
603 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec()); | 603 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec()); |
604 | proGr->setEnabled( item > 2 ); | 604 | proGr->setEnabled( item > 2 ); |
605 | if ( item < 3 ) { | 605 | if ( item < 3 ) { |
606 | localFileWidget->hide(); | 606 | localFileWidget->hide(); |
607 | remoteFileWidget->hide(); | 607 | remoteFileWidget->hide(); |
608 | phoneWidget->hide(); | 608 | phoneWidget->hide(); |
609 | piWidget->hide(); | 609 | piWidget->hide(); |
610 | 610 | ||
611 | } else | 611 | } else |
612 | kindChanged( prof->getIsLocalFileSync() ); | 612 | kindChanged( prof->getIsLocalFileSync() ); |
613 | } | 613 | } |
614 | 614 | ||
615 | void KSyncPrefsDialog::fillSSH() | 615 | void KSyncPrefsDialog::fillSSH() |
616 | { | 616 | { |
617 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | 617 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); |
618 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | 618 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); |
619 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); | 619 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); |
620 | mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); | 620 | mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); |
621 | mLocalTempFileAB->setText("/tmp/std.vcf" ); | 621 | mLocalTempFileAB->setText("/tmp/std.vcf" ); |
622 | mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); | 622 | mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); |
623 | mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); | 623 | mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); |
624 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); | 624 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); |
625 | mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); | 625 | mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); |
626 | } | 626 | } |
627 | void KSyncPrefsDialog::fillFTP() | 627 | void KSyncPrefsDialog::fillFTP() |
628 | { | 628 | { |
629 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); | 629 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); |
630 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | 630 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); |
631 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | 631 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); |
632 | mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); | 632 | mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); |
633 | mLocalTempFileAB->setText("/tmp/std.vcf" ); | 633 | mLocalTempFileAB->setText("/tmp/std.vcf" ); |
634 | mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); | 634 | mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); |
635 | 635 | ||
636 | mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); | 636 | mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); |
637 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); | 637 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); |
638 | mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); | 638 | mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); |
639 | 639 | ||
640 | } | 640 | } |
641 | void KSyncPrefsDialog::kindChanged( bool b ) | 641 | void KSyncPrefsDialog::kindChanged( bool b ) |
642 | { | 642 | { |
643 | 643 | ||
644 | if ( mIsLocal->isChecked () ) { | 644 | if ( mIsLocal->isChecked () ) { |
645 | mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); | 645 | mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); |
646 | } else { | 646 | } else { |
647 | mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); | 647 | mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); |
648 | } | 648 | } |
649 | 649 | ||
650 | if ( mIsLocal->isChecked () ) | 650 | if ( mIsLocal->isChecked () ) |
651 | localFileWidget->show(); | 651 | localFileWidget->show(); |
652 | else | 652 | else |
653 | localFileWidget->hide(); | 653 | localFileWidget->hide(); |
654 | 654 | ||
655 | if ( mIsNotLocal->isChecked () ) | 655 | if ( mIsNotLocal->isChecked () ) |
656 | remoteFileWidget->show(); | 656 | remoteFileWidget->show(); |
657 | else | 657 | else |
658 | remoteFileWidget->hide(); | 658 | remoteFileWidget->hide(); |
659 | 659 | ||
660 | if ( mIsPhone->isChecked () ) { | 660 | if ( mIsPhone->isChecked () ) { |
661 | phoneWidget->show(); | 661 | phoneWidget->show(); |
662 | } | 662 | } |
663 | else { | 663 | else { |
664 | phoneWidget->hide(); | 664 | phoneWidget->hide(); |
665 | } | 665 | } |
666 | 666 | ||
667 | if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) { | 667 | if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) { |
668 | piWidget->show(); | 668 | piWidget->show(); |
669 | if (mIsPiSpecific->isChecked () ) { | 669 | if (mIsPiSpecific->isChecked () ) { |
670 | mTableBox->show(); | 670 | mTableBox->show(); |
671 | } | 671 | } |
672 | else { | 672 | else { |
673 | mTableBox->hide(); | 673 | mTableBox->hide(); |
674 | } | 674 | } |
675 | } | 675 | } |
676 | else { | 676 | else { |
677 | piWidget->hide(); | 677 | piWidget->hide(); |
678 | } | 678 | } |
679 | 679 | ||
680 | 680 | ||
681 | } | 681 | } |
682 | void KSyncPrefsDialog::deleteProfile() | 682 | void KSyncPrefsDialog::deleteProfile() |
683 | { | 683 | { |
684 | //qDebug("KSyncPrefsDialog::deleteProfile() "); | 684 | //qDebug("KSyncPrefsDialog::deleteProfile() "); |
685 | if ( currentSelection >= 0 ) { | 685 | if ( currentSelection >= 0 ) { |
686 | if ( currentSelection < 3 ) { | 686 | if ( currentSelection < 3 ) { |
687 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); | 687 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); |
688 | return; | 688 | return; |
689 | } | 689 | } |
690 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); | 690 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); |
691 | mSyncProfiles.remove( temp ); | 691 | mSyncProfiles.remove( temp ); |
692 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); | 692 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); |
693 | insertProfiles(); | 693 | insertProfiles(); |
694 | } | 694 | } |
695 | } | 695 | } |
696 | 696 | ||
697 | void KSyncPrefsDialog::saveProfile() | 697 | void KSyncPrefsDialog::saveProfile() |
698 | { | 698 | { |
699 | KSyncProfile* prof; | 699 | KSyncProfile* prof; |
700 | if ( currentSelection >= 0 ) { | 700 | if ( currentSelection >= 0 ) { |
701 | prof = mSyncProfiles.at(currentSelection) ; | 701 | prof = mSyncProfiles.at(currentSelection) ; |
702 | 702 | ||
703 | prof->setRemotePw( mRemotePw->text()); | 703 | prof->setRemotePw( mRemotePw->text()); |
704 | prof->setRemoteIP( mRemoteIP->text()); | 704 | prof->setRemoteIP( mRemoteIP->text()); |
705 | prof->setRemotePort( mRemotePort->text()); | 705 | prof->setRemotePort( mRemotePort->text()); |
706 | 706 | ||
707 | prof->setRemotePwAB( mRemotePwAB->text()); | 707 | prof->setRemotePwAB( mRemotePwAB->text()); |
708 | prof->setRemoteIPAB( mRemoteIPAB->text()); | 708 | prof->setRemoteIPAB( mRemoteIPAB->text()); |
709 | prof->setRemotePortAB( mRemotePortAB->text()); | 709 | prof->setRemotePortAB( mRemotePortAB->text()); |
710 | 710 | ||
711 | prof->setRemotePwPWM( mRemotePwPWM->text()); | 711 | prof->setRemotePwPWM( mRemotePwPWM->text()); |
712 | prof->setRemoteIPPWM( mRemoteIPPWM->text()); | 712 | prof->setRemoteIPPWM( mRemoteIPPWM->text()); |
713 | prof->setRemotePortPWM( mRemotePortPWM->text()); | 713 | prof->setRemotePortPWM( mRemotePortPWM->text()); |
714 | 714 | ||
715 | prof->setPreSyncCommand( mRemotePrecommand->text()); | 715 | prof->setPreSyncCommand( mRemotePrecommand->text()); |
716 | prof->setPostSyncCommand( mRemotePostcommand->text() ); | 716 | prof->setPostSyncCommand( mRemotePostcommand->text() ); |
717 | prof->setLocalTempFile( mLocalTempFile->text()); | 717 | prof->setLocalTempFile( mLocalTempFile->text()); |
718 | prof->setRemoteFileName( mRemoteFile->text() ); | 718 | prof->setRemoteFileName( mRemoteFile->text() ); |
719 | prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); | 719 | prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); |
720 | prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); | 720 | prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); |
721 | prof->setLocalTempFileAB( mLocalTempFileAB->text()); | 721 | prof->setLocalTempFileAB( mLocalTempFileAB->text()); |
722 | prof->setRemoteFileNameAB( mRemoteFileAB->text() ); | 722 | prof->setRemoteFileNameAB( mRemoteFileAB->text() ); |
723 | prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); | 723 | prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); |
724 | prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); | 724 | prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); |
725 | prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); | 725 | prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); |
726 | prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); | 726 | prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); |
727 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); | 727 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); |
728 | prof->setAskForPreferences( mAskForPreferences->isChecked()); | 728 | prof->setAskForPreferences( mAskForPreferences->isChecked()); |
729 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); | 729 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); |
730 | prof->setWriteBackFile( mWriteBackFile->isChecked()); | 730 | prof->setWriteBackFile( mWriteBackFile->isChecked()); |
731 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); | 731 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); |
732 | prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); | 732 | prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); |
733 | prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); | 733 | prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); |
734 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; | 734 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; |
735 | prof->setSyncPrefs( syncprefs); | 735 | prof->setSyncPrefs( syncprefs); |
736 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); | 736 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); |
737 | prof->setIsPhoneSync( mIsPhone->isChecked() ); | 737 | prof->setIsPhoneSync( mIsPhone->isChecked() ); |
738 | prof->setIsPiSync( mIsPi->isChecked() ); | 738 | prof->setIsPiSync( mIsPi->isChecked() ); |
739 | prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() ); | 739 | prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() ); |
740 | prof->setIsKapiFile( mIsKapiFileL->isChecked() ); | 740 | prof->setIsKapiFile( mIsKapiFileL->isChecked() ); |
741 | prof->setWriteBackFuture(mWriteBackFuture->isChecked()); | 741 | prof->setWriteBackFuture(mWriteBackFuture->isChecked()); |
742 | prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); | 742 | prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); |
743 | prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); | 743 | prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); |
744 | if ( mWriteContactToSIM ) | 744 | if ( mWriteContactToSIM ) |
745 | prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); | 745 | prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); |
746 | prof->setPhoneDevice( mPhoneDevice->text() ); | 746 | prof->setPhoneDevice( mPhoneDevice->text() ); |
747 | prof->setPhoneConnection( mPhoneConnection->text() ); | 747 | prof->setPhoneConnection( mPhoneConnection->text() ); |
748 | prof->setPhoneModel( mPhoneModel->text() ); | 748 | prof->setPhoneModel( mPhoneModel->text() ); |
749 | prof->setFilterInCal ( mFilterInCal->currentText ()); | 749 | prof->setFilterInCal ( mFilterInCal->currentText ()); |
750 | prof->setFilterOutCal ( mFilterOutCal ->currentText ()); | 750 | prof->setFilterOutCal ( mFilterOutCal ->currentText ()); |
751 | prof->setFilterInAB ( mFilterInAB ->currentText ()); | 751 | prof->setFilterInAB ( mFilterInAB ->currentText ()); |
752 | prof->setFilterOutAB ( mFilterOutAB ->currentText ()); | 752 | prof->setFilterOutAB ( mFilterOutAB ->currentText ()); |
753 | if ( mIsPiSpecific->isChecked() ) { | 753 | if ( mIsPiSpecific->isChecked() ) { |
754 | 754 | ||
755 | QStringList res; | 755 | QStringList res = mResourcesKopi; |
756 | int i; | 756 | int i; |
757 | for ( i = 0;i < mResourcesKopi.count(); ++i ) { | 757 | for ( i = 0;i < mResourcesKopi.count(); ++i ) { |
758 | res.append( mResTableKopi->text( i, 0 )); | 758 | res.append( mResTableKopi->text( i, 0 )); |
759 | } | 759 | } |
760 | prof->setResSpecKopi( res.join(":")); | 760 | prof->setResSpecKopi( res.join(":")); |
761 | } | 761 | } |
762 | } | 762 | } |
763 | } | 763 | } |
764 | 764 | ||
765 | void KSyncPrefsDialog::insertProfiles() | 765 | void KSyncPrefsDialog::insertProfiles() |
766 | { | 766 | { |
767 | int curItem = mProfileBox->currentItem(); | 767 | int curItem = mProfileBox->currentItem(); |
768 | mProfileBox->blockSignals( true ); | 768 | mProfileBox->blockSignals( true ); |
769 | mProfileBox->clear(); | 769 | mProfileBox->clear(); |
770 | mProfileBox->insertStringList (mSyncProfileNames ); | 770 | mProfileBox->insertStringList (mSyncProfileNames ); |
771 | int item = mSyncProfileNames.count() -1; | 771 | int item = mSyncProfileNames.count() -1; |
772 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) | 772 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) |
773 | mProfileBox->setCurrentItem( curItem ); | 773 | mProfileBox->setCurrentItem( curItem ); |
774 | else if ( item >= 0 ) { | 774 | else if ( item >= 0 ) { |
775 | mProfileBox->setCurrentItem( item ); | 775 | mProfileBox->setCurrentItem( item ); |
776 | } | 776 | } |
777 | currentSelection = -1; | 777 | currentSelection = -1; |
778 | if ( mSyncProfileNames.count() > 0 ) { | 778 | if ( mSyncProfileNames.count() > 0 ) { |
779 | //qDebug(" profileChanged( mProfileBox->currentItem() "); | 779 | //qDebug(" profileChanged( mProfileBox->currentItem() "); |
780 | profileChanged( mProfileBox->currentItem() ); | 780 | profileChanged( mProfileBox->currentItem() ); |
781 | currentSelection = mProfileBox->currentItem(); | 781 | currentSelection = mProfileBox->currentItem(); |
782 | } | 782 | } |
783 | mProfileBox->blockSignals( false ); | 783 | mProfileBox->blockSignals( false ); |
784 | } | 784 | } |
785 | 785 | ||
786 | void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) | 786 | void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) |
787 | { | 787 | { |
788 | saveProfile(); | 788 | saveProfile(); |
789 | mSyncProfiles.append( temp ); | 789 | mSyncProfiles.append( temp ); |
790 | mSyncProfileNames << temp->getName(); | 790 | mSyncProfileNames << temp->getName(); |
791 | insertProfiles(); | 791 | insertProfiles(); |
792 | int last = mProfileBox->count() -1; | 792 | int last = mProfileBox->count() -1; |
793 | mProfileBox->blockSignals( true ); | 793 | mProfileBox->blockSignals( true ); |
794 | mProfileBox->setCurrentItem( last ); | 794 | mProfileBox->setCurrentItem( last ); |
795 | mProfileBox->blockSignals( false ); | 795 | mProfileBox->blockSignals( false ); |
796 | profileChanged(last); | 796 | profileChanged(last); |
797 | } | 797 | } |
798 | void KSyncPrefsDialog::newProfile() | 798 | void KSyncPrefsDialog::newProfile() |
799 | { | 799 | { |
800 | addProfile ( new KSyncProfile () ); | 800 | addProfile ( new KSyncProfile () ); |
801 | } | 801 | } |
802 | 802 | ||
803 | void KSyncPrefsDialog::cloneProfile() | 803 | void KSyncPrefsDialog::cloneProfile() |
804 | { | 804 | { |
805 | if ( currentSelection >= 0 ) | 805 | if ( currentSelection >= 0 ) |
806 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; | 806 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; |
807 | else | 807 | else |
808 | newProfile(); | 808 | newProfile(); |
809 | } | 809 | } |
810 | 810 | ||
811 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) | 811 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) |
812 | { | 812 | { |
813 | mMyMachineName->setText( name ); | 813 | mMyMachineName->setText( name ); |
814 | 814 | ||
815 | } | 815 | } |
816 | QString KSyncPrefsDialog::getLocalMachineName ( ) | 816 | QString KSyncPrefsDialog::getLocalMachineName ( ) |
817 | { | 817 | { |
818 | return mMyMachineName->text(); | 818 | return mMyMachineName->text(); |
819 | } | 819 | } |
820 | 820 | ||
821 | QStringList KSyncPrefsDialog::getSyncProfileNames() | 821 | QStringList KSyncPrefsDialog::getSyncProfileNames() |
822 | { | 822 | { |
823 | return mSyncProfileNames; | 823 | return mSyncProfileNames; |
824 | } | 824 | } |
825 | void KSyncPrefsDialog::usrReadConfig() | 825 | void KSyncPrefsDialog::usrReadConfig() |
826 | { | 826 | { |
827 | //KConfig *config = KOGlobals::config(); | 827 | //KConfig *config = KOGlobals::config(); |
828 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 828 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
829 | config.setGroup("General"); | 829 | config.setGroup("General"); |
830 | mSyncProfileNames =config.readListEntry("SyncProfileNames"); | 830 | mSyncProfileNames =config.readListEntry("SyncProfileNames"); |
831 | mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); | 831 | mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); |
832 | int i; | 832 | int i; |
833 | KSyncProfile* temp ; | 833 | KSyncProfile* temp ; |
834 | mSyncProfiles.clear(); | 834 | mSyncProfiles.clear(); |
835 | for ( i = 0; i < mSyncProfileNames.count();++i ) { | 835 | for ( i = 0; i < mSyncProfileNames.count();++i ) { |
836 | temp = new KSyncProfile (); | 836 | temp = new KSyncProfile (); |
837 | temp->setName( mSyncProfileNames[i] ); | 837 | temp->setName( mSyncProfileNames[i] ); |
838 | temp->readConfig( &config ); | 838 | temp->readConfig( &config ); |
839 | mSyncProfiles.append( temp ); | 839 | mSyncProfiles.append( temp ); |
840 | } | 840 | } |
841 | insertProfiles(); | 841 | insertProfiles(); |
842 | //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); | 842 | //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); |
843 | } | 843 | } |
844 | 844 | ||
845 | 845 | ||
846 | void KSyncPrefsDialog::usrWriteConfig() | 846 | void KSyncPrefsDialog::usrWriteConfig() |
847 | { | 847 | { |
848 | saveProfile(); | 848 | saveProfile(); |
849 | if ( currentSelection >= 0 ) | 849 | if ( currentSelection >= 0 ) |
850 | profileChanged(currentSelection); | 850 | profileChanged(currentSelection); |
851 | //KConfig *config = KOGlobals::config(); | 851 | //KConfig *config = KOGlobals::config(); |
852 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 852 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
853 | KSyncProfile* prof = mSyncProfiles.first(); | 853 | KSyncProfile* prof = mSyncProfiles.first(); |
854 | QStringList externalSyncProfileNames; | 854 | QStringList externalSyncProfileNames; |
855 | externalSyncProfileNames.append("Sharp_DTM");; | 855 | externalSyncProfileNames.append("Sharp_DTM");; |
856 | while ( prof ) { | 856 | while ( prof ) { |
857 | prof->writeConfig(&config); | 857 | prof->writeConfig(&config); |
858 | if ( prof->getIsPhoneSync( ) ) | 858 | if ( prof->getIsPhoneSync( ) ) |
859 | externalSyncProfileNames.append(prof->getName( ) ); | 859 | externalSyncProfileNames.append(prof->getName( ) ); |
860 | prof = mSyncProfiles.next(); | 860 | prof = mSyncProfiles.next(); |
861 | } | 861 | } |
862 | //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; | 862 | //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; |
863 | //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); | 863 | //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); |
864 | config.setGroup("General"); | 864 | config.setGroup("General"); |
865 | config.writeEntry("SyncProfileNames",mSyncProfileNames); | 865 | config.writeEntry("SyncProfileNames",mSyncProfileNames); |
866 | config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); | 866 | config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); |
867 | config.writeEntry("LocalMachineName",mMyMachineName->text()); | 867 | config.writeEntry("LocalMachineName",mMyMachineName->text()); |
868 | config.sync(); | 868 | config.sync(); |
869 | } | 869 | } |
870 | 870 | ||
871 | void KSyncPrefsDialog::helpDevice() | 871 | void KSyncPrefsDialog::helpDevice() |
872 | { | 872 | { |
873 | QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); | 873 | QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); |
874 | #ifdef _WIN32_ | 874 | #ifdef _WIN32_ |
875 | hint += "Leave empty for Irda.\n" | 875 | hint += "Leave empty for Irda.\n" |
876 | "com1:\n(first serial port)\n" | 876 | "com1:\n(first serial port)\n" |
877 | "usb not supported\n" | 877 | "usb not supported\n" |
878 | "???\n(bluetooth device address)\n"; | 878 | "???\n(bluetooth device address)\n"; |
879 | 879 | ||
880 | #else | 880 | #else |
881 | hint += "/dev/ircomm\n(Irda)\n" | 881 | hint += "/dev/ircomm\n(Irda)\n" |
882 | "/dev/ttyS0\n(first serial port)\n" | 882 | "/dev/ttyS0\n(first serial port)\n" |
883 | "/dev/ttyUSB0\n(first device usb port)\n" | 883 | "/dev/ttyUSB0\n(first device usb port)\n" |
884 | "???\n(bluetooth device address)\n"; | 884 | "???\n(bluetooth device address)\n"; |
885 | #endif | 885 | #endif |
886 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); | 886 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); |
887 | } | 887 | } |
888 | void KSyncPrefsDialog::helpModel() | 888 | void KSyncPrefsDialog::helpModel() |
889 | { | 889 | { |
890 | QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); | 890 | QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); |
891 | hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; | 891 | hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; |
892 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); | 892 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); |
893 | 893 | ||
894 | } | 894 | } |
895 | void KSyncPrefsDialog::helpConnection() | 895 | void KSyncPrefsDialog::helpConnection() |
896 | { | 896 | { |
897 | QString hint = i18n("Insert kind of connection,e.g.:\n"); | 897 | QString hint = i18n("Insert kind of connection,e.g.:\n"); |
898 | hint += "irda | Nokia FBUS over infrared\n" | 898 | hint += "irda | Nokia FBUS over infrared\n" |
899 | "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" | 899 | "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" |
900 | "irdaobex | set also model as obex\n" | 900 | "irdaobex | set also model as obex\n" |
901 | "fbus | Nokia FBUS2 serial\n"; | 901 | "fbus | Nokia FBUS2 serial\n"; |
902 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); | 902 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); |
903 | } | 903 | } |