author | zautrix <zautrix> | 2004-10-26 00:26:43 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-26 00:26:43 (UTC) |
commit | d9a3130b909cc32cfdee4cc6136105d9a488f357 (patch) (unidiff) | |
tree | 78e3cb0d8552f5a369f507b6b29eede81754db6b /korganizer | |
parent | 283cdf0b976a66c8e29ac327385472844d92f581 (diff) | |
download | kdepimpi-d9a3130b909cc32cfdee4cc6136105d9a488f357.zip kdepimpi-d9a3130b909cc32cfdee4cc6136105d9a488f357.tar.gz kdepimpi-d9a3130b909cc32cfdee4cc6136105d9a488f357.tar.bz2 |
set organizer when importing b days
-rw-r--r-- | korganizer/calendarview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index e64d83a..284ddbf 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1369,193 +1369,193 @@ bool CalendarView::importBday() | |||
1369 | return true; | 1369 | return true; |
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1372 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1373 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1373 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1374 | const QStringList& anniversaryList, const QStringList& realNameList, | 1374 | const QStringList& anniversaryList, const QStringList& realNameList, |
1375 | const QStringList& emailList, const QStringList& assembledNameList, | 1375 | const QStringList& emailList, const QStringList& assembledNameList, |
1376 | const QStringList& uidList) | 1376 | const QStringList& uidList) |
1377 | { | 1377 | { |
1378 | qDebug("CalendarView::insertBirthdays"); | 1378 | qDebug("CalendarView::insertBirthdays"); |
1379 | if (uid == this->name()) | 1379 | if (uid == this->name()) |
1380 | { | 1380 | { |
1381 | int count = birthdayList.count(); | 1381 | int count = birthdayList.count(); |
1382 | int addCount = 0; | 1382 | int addCount = 0; |
1383 | KCal::Attendee* a = 0; | 1383 | KCal::Attendee* a = 0; |
1384 | 1384 | ||
1385 | qDebug("CalView 1 %i", count); | 1385 | qDebug("CalView 1 %i", count); |
1386 | 1386 | ||
1387 | QProgressBar bar(count,0 ); | 1387 | QProgressBar bar(count,0 ); |
1388 | int w = 300; | 1388 | int w = 300; |
1389 | if ( QApplication::desktop()->width() < 320 ) | 1389 | if ( QApplication::desktop()->width() < 320 ) |
1390 | w = 220; | 1390 | w = 220; |
1391 | int h = bar.sizeHint().height() ; | 1391 | int h = bar.sizeHint().height() ; |
1392 | int dw = QApplication::desktop()->width(); | 1392 | int dw = QApplication::desktop()->width(); |
1393 | int dh = QApplication::desktop()->height(); | 1393 | int dh = QApplication::desktop()->height(); |
1394 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1394 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1395 | bar.show(); | 1395 | bar.show(); |
1396 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1396 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1397 | qApp->processEvents(); | 1397 | qApp->processEvents(); |
1398 | 1398 | ||
1399 | QDate birthday; | 1399 | QDate birthday; |
1400 | QDate anniversary; | 1400 | QDate anniversary; |
1401 | QString realName; | 1401 | QString realName; |
1402 | QString email; | 1402 | QString email; |
1403 | QString assembledName; | 1403 | QString assembledName; |
1404 | QString uid; | 1404 | QString uid; |
1405 | bool ok = true; | 1405 | bool ok = true; |
1406 | for ( int i = 0; i < count; i++) | 1406 | for ( int i = 0; i < count; i++) |
1407 | { | 1407 | { |
1408 | if ( ! bar.isVisible() ) | 1408 | if ( ! bar.isVisible() ) |
1409 | return; | 1409 | return; |
1410 | bar.setProgress( i ); | 1410 | bar.setProgress( i ); |
1411 | qApp->processEvents(); | 1411 | qApp->processEvents(); |
1412 | 1412 | ||
1413 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1413 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1414 | if (!ok) { | 1414 | if (!ok) { |
1415 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1415 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1418 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1419 | if (!ok) { | 1419 | if (!ok) { |
1420 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1420 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1421 | } | 1421 | } |
1422 | realName = realNameList[i]; | 1422 | realName = realNameList[i]; |
1423 | email = emailList[i]; | 1423 | email = emailList[i]; |
1424 | assembledName = assembledNameList[i]; | 1424 | assembledName = assembledNameList[i]; |
1425 | uid = uidList[i]; | 1425 | uid = uidList[i]; |
1426 | //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() ); | 1426 | //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() ); |
1427 | 1427 | ||
1428 | if ( birthday.isValid() ){ | 1428 | if ( birthday.isValid() ){ |
1429 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1429 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1430 | KCal::Attendee::ReqParticipant,uid) ; | 1430 | KCal::Attendee::ReqParticipant,uid) ; |
1431 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1431 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1432 | ++addCount; | 1432 | ++addCount; |
1433 | } | 1433 | } |
1434 | 1434 | ||
1435 | if ( anniversary.isValid() ){ | 1435 | if ( anniversary.isValid() ){ |
1436 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1436 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1437 | KCal::Attendee::ReqParticipant,uid) ; | 1437 | KCal::Attendee::ReqParticipant,uid) ; |
1438 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1438 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1439 | ++addCount; | 1439 | ++addCount; |
1440 | } | 1440 | } |
1441 | } | 1441 | } |
1442 | 1442 | ||
1443 | updateView(); | 1443 | updateView(); |
1444 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1444 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1445 | 1445 | ||
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | 1450 | ||
1451 | 1451 | ||
1452 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1452 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1453 | { | 1453 | { |
1454 | //qDebug("addAnni "); | 1454 | //qDebug("addAnni "); |
1455 | Event * ev = new Event(); | 1455 | Event * ev = new Event(); |
1456 | if ( a ) { | 1456 | if ( a ) { |
1457 | ev->addAttendee( a ); | 1457 | ev->addAttendee( a ); |
1458 | } | 1458 | } |
1459 | QString kind; | 1459 | QString kind; |
1460 | if ( birthday ) | 1460 | if ( birthday ) |
1461 | kind = i18n( "Birthday" ); | 1461 | kind = i18n( "Birthday" ); |
1462 | else | 1462 | else |
1463 | kind = i18n( "Anniversary" ); | 1463 | kind = i18n( "Anniversary" ); |
1464 | ev->setSummary( name + " - " + kind ); | 1464 | ev->setSummary( name + " - " + kind ); |
1465 | ev->setOrganizer( "nobody@nowhere" ); | 1465 | ev->setOrganizer(a->email()); |
1466 | ev->setCategories( kind ); | 1466 | ev->setCategories( kind ); |
1467 | ev->setDtStart( QDateTime(date) ); | 1467 | ev->setDtStart( QDateTime(date) ); |
1468 | ev->setDtEnd( QDateTime(date) ); | 1468 | ev->setDtEnd( QDateTime(date) ); |
1469 | ev->setFloats( true ); | 1469 | ev->setFloats( true ); |
1470 | Recurrence * rec = ev->recurrence(); | 1470 | Recurrence * rec = ev->recurrence(); |
1471 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1471 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1472 | rec->addYearlyNum( date.month() ); | 1472 | rec->addYearlyNum( date.month() ); |
1473 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1473 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1474 | delete ev; | 1474 | delete ev; |
1475 | return false; | 1475 | return false; |
1476 | } | 1476 | } |
1477 | return true; | 1477 | return true; |
1478 | 1478 | ||
1479 | } | 1479 | } |
1480 | bool CalendarView::importQtopia( const QString &categories, | 1480 | bool CalendarView::importQtopia( const QString &categories, |
1481 | const QString &datebook, | 1481 | const QString &datebook, |
1482 | const QString &todolist ) | 1482 | const QString &todolist ) |
1483 | { | 1483 | { |
1484 | 1484 | ||
1485 | QtopiaFormat qtopiaFormat; | 1485 | QtopiaFormat qtopiaFormat; |
1486 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1486 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1487 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1487 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1488 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1488 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1489 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1489 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1490 | 1490 | ||
1491 | updateView(); | 1491 | updateView(); |
1492 | return true; | 1492 | return true; |
1493 | 1493 | ||
1494 | #if 0 | 1494 | #if 0 |
1495 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1495 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1496 | mCurrentSyncDevice = "qtopia-XML"; | 1496 | mCurrentSyncDevice = "qtopia-XML"; |
1497 | if ( mSyncManager->mAskForPreferences ) | 1497 | if ( mSyncManager->mAskForPreferences ) |
1498 | edit_sync_options(); | 1498 | edit_sync_options(); |
1499 | qApp->processEvents(); | 1499 | qApp->processEvents(); |
1500 | CalendarLocal* calendar = new CalendarLocal(); | 1500 | CalendarLocal* calendar = new CalendarLocal(); |
1501 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1501 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1502 | bool syncOK = false; | 1502 | bool syncOK = false; |
1503 | QtopiaFormat qtopiaFormat; | 1503 | QtopiaFormat qtopiaFormat; |
1504 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1504 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1505 | bool loadOk = true; | 1505 | bool loadOk = true; |
1506 | if ( !categories.isEmpty() ) | 1506 | if ( !categories.isEmpty() ) |
1507 | loadOk = qtopiaFormat.load( calendar, categories ); | 1507 | loadOk = qtopiaFormat.load( calendar, categories ); |
1508 | if ( loadOk && !datebook.isEmpty() ) | 1508 | if ( loadOk && !datebook.isEmpty() ) |
1509 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1509 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1510 | if ( loadOk && !todolist.isEmpty() ) | 1510 | if ( loadOk && !todolist.isEmpty() ) |
1511 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1511 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1512 | 1512 | ||
1513 | if ( loadOk ) { | 1513 | if ( loadOk ) { |
1514 | getEventViewerDialog()->setSyncMode( true ); | 1514 | getEventViewerDialog()->setSyncMode( true ); |
1515 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1515 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1516 | getEventViewerDialog()->setSyncMode( false ); | 1516 | getEventViewerDialog()->setSyncMode( false ); |
1517 | qApp->processEvents(); | 1517 | qApp->processEvents(); |
1518 | if ( syncOK ) { | 1518 | if ( syncOK ) { |
1519 | if ( mSyncManager->mWriteBackFile ) | 1519 | if ( mSyncManager->mWriteBackFile ) |
1520 | { | 1520 | { |
1521 | // write back XML file | 1521 | // write back XML file |
1522 | 1522 | ||
1523 | } | 1523 | } |
1524 | setModified( true ); | 1524 | setModified( true ); |
1525 | } | 1525 | } |
1526 | } else { | 1526 | } else { |
1527 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1527 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1528 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1528 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1529 | question, i18n("Ok")) ; | 1529 | question, i18n("Ok")) ; |
1530 | } | 1530 | } |
1531 | delete calendar; | 1531 | delete calendar; |
1532 | updateView(); | 1532 | updateView(); |
1533 | return syncOK; | 1533 | return syncOK; |
1534 | 1534 | ||
1535 | 1535 | ||
1536 | #endif | 1536 | #endif |
1537 | 1537 | ||
1538 | } | 1538 | } |
1539 | 1539 | ||
1540 | void CalendarView::setSyncEventsReadOnly() | 1540 | void CalendarView::setSyncEventsReadOnly() |
1541 | { | 1541 | { |
1542 | Event * ev; | 1542 | Event * ev; |
1543 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1543 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1544 | ev = eL.first(); | 1544 | ev = eL.first(); |
1545 | while ( ev ) { | 1545 | while ( ev ) { |
1546 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1546 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1547 | ev->setReadOnly( true ); | 1547 | ev->setReadOnly( true ); |
1548 | ev = eL.next(); | 1548 | ev = eL.next(); |
1549 | } | 1549 | } |
1550 | } | 1550 | } |
1551 | bool CalendarView::openCalendar(QString filename, bool merge) | 1551 | bool CalendarView::openCalendar(QString filename, bool merge) |
1552 | { | 1552 | { |
1553 | 1553 | ||
1554 | if (filename.isEmpty()) { | 1554 | if (filename.isEmpty()) { |
1555 | return false; | 1555 | return false; |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | if (!QFile::exists(filename)) { | 1558 | if (!QFile::exists(filename)) { |
1559 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1559 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1560 | return false; | 1560 | return false; |
1561 | } | 1561 | } |