summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-30 00:33:46 (UTC)
committer zautrix <zautrix>2005-01-30 00:33:46 (UTC)
commita8fae20ad7bcb59df9a603c88accf3a10401c2f9 (patch) (unidiff)
tree12deeef9bae6d470c244ce9a9916c59d6879f9b2
parentd94b52aa95cc52aa1bef7c9cd99f43c725ed8042 (diff)
downloadkdepimpi-a8fae20ad7bcb59df9a603c88accf3a10401c2f9.zip
kdepimpi-a8fae20ad7bcb59df9a603c88accf3a10401c2f9.tar.gz
kdepimpi-a8fae20ad7bcb59df9a603c88accf3a10401c2f9.tar.bz2
f
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp2
-rw-r--r--korganizer/koeditordetails.cpp13
-rw-r--r--korganizer/koeditordetails.h1
-rw-r--r--korganizer/koeventviewer.cpp6
-rw-r--r--libkcal/dndfactory.h9
5 files changed, 28 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 74aefb7..96fb5ca 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1394,269 +1394,269 @@ bool CalendarView::importBday()
1394 w = 220; 1394 w = 220;
1395 int h = bar.sizeHint().height() ; 1395 int h = bar.sizeHint().height() ;
1396 int dw = QApplication::desktop()->width(); 1396 int dw = QApplication::desktop()->width();
1397 int dh = QApplication::desktop()->height(); 1397 int dh = QApplication::desktop()->height();
1398 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1398 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1399 bar.show(); 1399 bar.show();
1400 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1400 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1401 qApp->processEvents(); 1401 qApp->processEvents();
1402 count = 0; 1402 count = 0;
1403 int addCount = 0; 1403 int addCount = 0;
1404 KCal::Attendee* a = 0; 1404 KCal::Attendee* a = 0;
1405 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1405 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1406 if ( ! bar.isVisible() ) 1406 if ( ! bar.isVisible() )
1407 return false; 1407 return false;
1408 bar.setProgress( count++ ); 1408 bar.setProgress( count++ );
1409 qApp->processEvents(); 1409 qApp->processEvents();
1410 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1410 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1411 if ( (*it).birthday().date().isValid() ){ 1411 if ( (*it).birthday().date().isValid() ){
1412 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1412 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1413 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1413 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1414 ++addCount; 1414 ++addCount;
1415 } 1415 }
1416 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1416 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1417 if ( anni.isValid() ){ 1417 if ( anni.isValid() ){
1418 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1418 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1419 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1419 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1420 ++addCount; 1420 ++addCount;
1421 } 1421 }
1422 } 1422 }
1423 updateView(); 1423 updateView();
1424 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1424 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1425#else //DESKTOP_VERSION 1425#else //DESKTOP_VERSION
1426 1426
1427 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1427 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1428 // the result should now arrive through method insertBirthdays 1428 // the result should now arrive through method insertBirthdays
1429 1429
1430#endif //DESKTOP_VERSION 1430#endif //DESKTOP_VERSION
1431 1431
1432#endif //KORG_NOKABC 1432#endif //KORG_NOKABC
1433 1433
1434 1434
1435 return true; 1435 return true;
1436} 1436}
1437 1437
1438// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1438// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1439void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1439void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1440 const QStringList& anniversaryList, const QStringList& realNameList, 1440 const QStringList& anniversaryList, const QStringList& realNameList,
1441 const QStringList& emailList, const QStringList& assembledNameList, 1441 const QStringList& emailList, const QStringList& assembledNameList,
1442 const QStringList& uidList) 1442 const QStringList& uidList)
1443{ 1443{
1444 //qDebug("KO::CalendarView::insertBirthdays"); 1444 //qDebug("KO::CalendarView::insertBirthdays");
1445 if (uid == this->name()) 1445 if (uid == this->name())
1446 { 1446 {
1447 int count = birthdayList.count(); 1447 int count = birthdayList.count();
1448 int addCount = 0; 1448 int addCount = 0;
1449 KCal::Attendee* a = 0; 1449 KCal::Attendee* a = 0;
1450 1450
1451 //qDebug("CalView 1 %i", count); 1451 //qDebug("CalView 1 %i", count);
1452 1452
1453 QProgressBar bar(count,0 ); 1453 QProgressBar bar(count,0 );
1454 int w = 300; 1454 int w = 300;
1455 if ( QApplication::desktop()->width() < 320 ) 1455 if ( QApplication::desktop()->width() < 320 )
1456 w = 220; 1456 w = 220;
1457 int h = bar.sizeHint().height() ; 1457 int h = bar.sizeHint().height() ;
1458 int dw = QApplication::desktop()->width(); 1458 int dw = QApplication::desktop()->width();
1459 int dh = QApplication::desktop()->height(); 1459 int dh = QApplication::desktop()->height();
1460 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1460 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1461 bar.show(); 1461 bar.show();
1462 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1462 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1463 qApp->processEvents(); 1463 qApp->processEvents();
1464 1464
1465 QDate birthday; 1465 QDate birthday;
1466 QDate anniversary; 1466 QDate anniversary;
1467 QString realName; 1467 QString realName;
1468 QString email; 1468 QString email;
1469 QString assembledName; 1469 QString assembledName;
1470 QString uid; 1470 QString uid;
1471 bool ok = true; 1471 bool ok = true;
1472 for ( int i = 0; i < count; i++) 1472 for ( int i = 0; i < count; i++)
1473 { 1473 {
1474 if ( ! bar.isVisible() ) 1474 if ( ! bar.isVisible() )
1475 return; 1475 return;
1476 bar.setProgress( i ); 1476 bar.setProgress( i );
1477 qApp->processEvents(); 1477 qApp->processEvents();
1478 1478
1479 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1479 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1480 if (!ok) { 1480 if (!ok) {
1481 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1481 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1482 } 1482 }
1483 1483
1484 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1484 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1485 if (!ok) { 1485 if (!ok) {
1486 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1486 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1487 } 1487 }
1488 realName = realNameList[i]; 1488 realName = realNameList[i];
1489 email = emailList[i]; 1489 email = emailList[i];
1490 assembledName = assembledNameList[i]; 1490 assembledName = assembledNameList[i];
1491 uid = uidList[i]; 1491 uid = uidList[i];
1492 //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() ); 1492 //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() );
1493 1493
1494 if ( birthday.isValid() ){ 1494 if ( birthday.isValid() ){
1495 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1495 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1496 KCal::Attendee::ReqParticipant,uid) ; 1496 KCal::Attendee::ReqParticipant,uid) ;
1497 if ( addAnniversary( birthday, assembledName, a, true ) ) 1497 if ( addAnniversary( birthday, assembledName, a, true ) )
1498 ++addCount; 1498 ++addCount;
1499 } 1499 }
1500 1500
1501 if ( anniversary.isValid() ){ 1501 if ( anniversary.isValid() ){
1502 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1502 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1503 KCal::Attendee::ReqParticipant,uid) ; 1503 KCal::Attendee::ReqParticipant,uid) ;
1504 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1504 if ( addAnniversary( anniversary, assembledName, a, false ) )
1505 ++addCount; 1505 ++addCount;
1506 } 1506 }
1507 } 1507 }
1508 1508
1509 updateView(); 1509 updateView();
1510 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1510 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1511 1511
1512 } 1512 }
1513 1513
1514} 1514}
1515 1515
1516 1516
1517 1517
1518bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1518bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1519{ 1519{
1520 //qDebug("addAnni "); 1520 //qDebug("addAnni ");
1521 Event * ev = new Event(); 1521 Event * ev = new Event();
1522 ev->setOrganizer(KOPrefs::instance()->email());
1522 if ( a ) { 1523 if ( a ) {
1523 ev->addAttendee( a ); 1524 ev->addAttendee( a );
1524 } 1525 }
1525 QString kind; 1526 QString kind;
1526 if ( birthday ) { 1527 if ( birthday ) {
1527 kind = i18n( "Birthday" ); 1528 kind = i18n( "Birthday" );
1528 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1529 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1529 } 1530 }
1530 else { 1531 else {
1531 kind = i18n( "Anniversary" ); 1532 kind = i18n( "Anniversary" );
1532 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1533 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1533 } 1534 }
1534 //ev->setOrganizer(a->email());
1535 ev->setCategories( kind ); 1535 ev->setCategories( kind );
1536 ev->setDtStart( QDateTime(date) ); 1536 ev->setDtStart( QDateTime(date) );
1537 ev->setDtEnd( QDateTime(date) ); 1537 ev->setDtEnd( QDateTime(date) );
1538 ev->setFloats( true ); 1538 ev->setFloats( true );
1539 Recurrence * rec = ev->recurrence(); 1539 Recurrence * rec = ev->recurrence();
1540 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1540 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1541 rec->addYearlyNum( date.month() ); 1541 rec->addYearlyNum( date.month() );
1542 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1542 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1543 delete ev; 1543 delete ev;
1544 return false; 1544 return false;
1545 } 1545 }
1546 return true; 1546 return true;
1547 1547
1548} 1548}
1549bool CalendarView::importQtopia( const QString &categories, 1549bool CalendarView::importQtopia( const QString &categories,
1550 const QString &datebook, 1550 const QString &datebook,
1551 const QString &todolist ) 1551 const QString &todolist )
1552{ 1552{
1553 1553
1554 QtopiaFormat qtopiaFormat; 1554 QtopiaFormat qtopiaFormat;
1555 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1555 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1556 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1556 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1557 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1557 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1558 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1558 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1559 1559
1560 updateView(); 1560 updateView();
1561 return true; 1561 return true;
1562 1562
1563#if 0 1563#if 0
1564 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1564 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1565 mCurrentSyncDevice = "qtopia-XML"; 1565 mCurrentSyncDevice = "qtopia-XML";
1566 if ( mSyncManager->mAskForPreferences ) 1566 if ( mSyncManager->mAskForPreferences )
1567 edit_sync_options(); 1567 edit_sync_options();
1568 qApp->processEvents(); 1568 qApp->processEvents();
1569 CalendarLocal* calendar = new CalendarLocal(); 1569 CalendarLocal* calendar = new CalendarLocal();
1570 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1570 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1571 bool syncOK = false; 1571 bool syncOK = false;
1572 QtopiaFormat qtopiaFormat; 1572 QtopiaFormat qtopiaFormat;
1573 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1573 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1574 bool loadOk = true; 1574 bool loadOk = true;
1575 if ( !categories.isEmpty() ) 1575 if ( !categories.isEmpty() )
1576 loadOk = qtopiaFormat.load( calendar, categories ); 1576 loadOk = qtopiaFormat.load( calendar, categories );
1577 if ( loadOk && !datebook.isEmpty() ) 1577 if ( loadOk && !datebook.isEmpty() )
1578 loadOk = qtopiaFormat.load( calendar, datebook ); 1578 loadOk = qtopiaFormat.load( calendar, datebook );
1579 if ( loadOk && !todolist.isEmpty() ) 1579 if ( loadOk && !todolist.isEmpty() )
1580 loadOk = qtopiaFormat.load( calendar, todolist ); 1580 loadOk = qtopiaFormat.load( calendar, todolist );
1581 1581
1582 if ( loadOk ) { 1582 if ( loadOk ) {
1583 getEventViewerDialog()->setSyncMode( true ); 1583 getEventViewerDialog()->setSyncMode( true );
1584 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1584 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1585 getEventViewerDialog()->setSyncMode( false ); 1585 getEventViewerDialog()->setSyncMode( false );
1586 qApp->processEvents(); 1586 qApp->processEvents();
1587 if ( syncOK ) { 1587 if ( syncOK ) {
1588 if ( mSyncManager->mWriteBackFile ) 1588 if ( mSyncManager->mWriteBackFile )
1589 { 1589 {
1590 // write back XML file 1590 // write back XML file
1591 1591
1592 } 1592 }
1593 setModified( true ); 1593 setModified( true );
1594 } 1594 }
1595 } else { 1595 } else {
1596 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1596 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1597 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1597 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1598 question, i18n("Ok")) ; 1598 question, i18n("Ok")) ;
1599 } 1599 }
1600 delete calendar; 1600 delete calendar;
1601 updateView(); 1601 updateView();
1602 return syncOK; 1602 return syncOK;
1603 1603
1604 1604
1605#endif 1605#endif
1606 1606
1607} 1607}
1608 1608
1609void CalendarView::setSyncEventsReadOnly() 1609void CalendarView::setSyncEventsReadOnly()
1610{ 1610{
1611 Event * ev; 1611 Event * ev;
1612 QPtrList<Event> eL = mCalendar->rawEvents(); 1612 QPtrList<Event> eL = mCalendar->rawEvents();
1613 ev = eL.first(); 1613 ev = eL.first();
1614 while ( ev ) { 1614 while ( ev ) {
1615 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1615 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1616 ev->setReadOnly( true ); 1616 ev->setReadOnly( true );
1617 ev = eL.next(); 1617 ev = eL.next();
1618 } 1618 }
1619} 1619}
1620bool CalendarView::openCalendar(QString filename, bool merge) 1620bool CalendarView::openCalendar(QString filename, bool merge)
1621{ 1621{
1622 1622
1623 if (filename.isEmpty()) { 1623 if (filename.isEmpty()) {
1624 return false; 1624 return false;
1625 } 1625 }
1626 1626
1627 if (!QFile::exists(filename)) { 1627 if (!QFile::exists(filename)) {
1628 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1628 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1629 return false; 1629 return false;
1630 } 1630 }
1631 1631
1632 globalFlagBlockAgenda = 1; 1632 globalFlagBlockAgenda = 1;
1633 if (!merge) mCalendar->close(); 1633 if (!merge) mCalendar->close();
1634 1634
1635 mStorage->setFileName( filename ); 1635 mStorage->setFileName( filename );
1636 1636
1637 if ( mStorage->load() ) { 1637 if ( mStorage->load() ) {
1638 if ( merge ) ;//setModified( true ); 1638 if ( merge ) ;//setModified( true );
1639 else { 1639 else {
1640 //setModified( true ); 1640 //setModified( true );
1641 mViewManager->setDocumentId( filename ); 1641 mViewManager->setDocumentId( filename );
1642 mDialogManager->setDocumentId( filename ); 1642 mDialogManager->setDocumentId( filename );
1643 mTodoList->setDocumentId( filename ); 1643 mTodoList->setDocumentId( filename );
1644 } 1644 }
1645 globalFlagBlockAgenda = 2; 1645 globalFlagBlockAgenda = 2;
1646 // if ( getLastSyncEvent() ) 1646 // if ( getLastSyncEvent() )
1647 // getLastSyncEvent()->setReadOnly( true ); 1647 // getLastSyncEvent()->setReadOnly( true );
1648 mCalendar->reInitAlarmSettings(); 1648 mCalendar->reInitAlarmSettings();
1649 setSyncEventsReadOnly(); 1649 setSyncEventsReadOnly();
1650 updateUnmanagedViews(); 1650 updateUnmanagedViews();
1651 updateView(); 1651 updateView();
1652 if ( filename != MainWindow::defaultFileName() ) { 1652 if ( filename != MainWindow::defaultFileName() ) {
1653 saveCalendar( MainWindow::defaultFileName() ); 1653 saveCalendar( MainWindow::defaultFileName() );
1654 } else { 1654 } else {
1655 QFileInfo finf ( MainWindow::defaultFileName()); 1655 QFileInfo finf ( MainWindow::defaultFileName());
1656 if ( finf.exists() ) { 1656 if ( finf.exists() ) {
1657 setLoadedFileVersion( finf.lastModified () ); 1657 setLoadedFileVersion( finf.lastModified () );
1658 } 1658 }
1659 } 1659 }
1660 return true; 1660 return true;
1661 } else { 1661 } else {
1662 // while failing to load, the calendar object could 1662 // while failing to load, the calendar object could
diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp
index cf0a458..ef8025b 100644
--- a/korganizer/koeditordetails.cpp
+++ b/korganizer/koeditordetails.cpp
@@ -1,224 +1,228 @@
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 thse hope that it will be useful, 10 This program is distributed in thse 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 <qtooltip.h> 24#include <qtooltip.h>
25#include <qfiledialog.h> 25#include <qfiledialog.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qapp.h> 32#include <qapp.h>
33 33
34#include <klocale.h> 34#include <klocale.h>
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kiconloader.h> 36#include <kiconloader.h>
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39#ifndef KORG_NOKABC 39#ifndef KORG_NOKABC
40 40
41#ifdef DESKTOP_VERSION 41#ifdef DESKTOP_VERSION
42#include <kabc/addresseedialog.h> 42#include <kabc/addresseedialog.h>
43#else //DESKTOP_VERSION 43#else //DESKTOP_VERSION
44#include <externalapphandler.h> 44#include <externalapphandler.h>
45#endif //DESKTOP_VERSION 45#endif //DESKTOP_VERSION
46 46
47#endif 47#endif
48 48
49#include <libkcal/incidence.h> 49#include <libkcal/incidence.h>
50 50
51#include "koprefs.h" 51#include "koprefs.h"
52 52
53#include "koeditordetails.h" 53#include "koeditordetails.h"
54 54
55template <> 55template <>
56CustomListViewItem<class Attendee *>::~CustomListViewItem() 56CustomListViewItem<class Attendee *>::~CustomListViewItem()
57{ 57{
58 delete mData; 58 delete mData;
59} 59}
60 60
61template <> 61template <>
62void CustomListViewItem<class Attendee *>::updateItem() 62void CustomListViewItem<class Attendee *>::updateItem()
63{ 63{
64 setText(0,mData->name()); 64 setText(0,mData->name());
65 setText(1,mData->email()); 65 setText(1,mData->email());
66 setText(2,mData->roleStr()); 66 setText(2,mData->roleStr());
67 setText(3,mData->statusStr()); 67 setText(3,mData->statusStr());
68 if (mData->RSVP() && !mData->email().isEmpty()) 68 if (mData->RSVP() && !mData->email().isEmpty())
69 setPixmap(4,SmallIcon("mailappt")); 69 setPixmap(4,SmallIcon("mailappt"));
70 else 70 else
71 setPixmap(4,SmallIcon("nomailappt")); 71 setPixmap(4,SmallIcon("nomailappt"));
72} 72}
73 73
74 74
75KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) 75KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name)
76 : QWidget( parent, name), mDisableItemUpdate( false ) 76 : QWidget( parent, name), mDisableItemUpdate( false )
77{ 77{
78 QGridLayout *topLayout = new QGridLayout(this); 78 QGridLayout *topLayout = new QGridLayout(this);
79 topLayout->setSpacing(spacing); 79 topLayout->setSpacing(spacing);
80 80
81 QString organizer = KOPrefs::instance()->email(); 81 QString organizer = KOPrefs::instance()->email();
82 mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this); 82 mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this);
83 83
84 mListView = new KListView(this,"mListView"); 84 mListView = new KListView(this,"mListView");
85 mListView->addColumn(i18n("Name"),180); 85 mListView->addColumn(i18n("Name"),180);
86 mListView->addColumn(i18n("Email"),180); 86 mListView->addColumn(i18n("Email"),180);
87 mListView->addColumn(i18n("Role"),60); 87 mListView->addColumn(i18n("Role"),60);
88 mListView->addColumn(i18n("Status"),100); 88 mListView->addColumn(i18n("Status"),100);
89 mListView->addColumn(i18n("RSVP"),35); 89 mListView->addColumn(i18n("RSVP"),35);
90 if ( KOPrefs::instance()->mCompactDialogs ) { 90 if ( KOPrefs::instance()->mCompactDialogs ) {
91 //mListView->setFixedHeight(78); 91 //mListView->setFixedHeight(78);
92 } 92 }
93 93 mListView->setAllColumnsShowFocus (true );
94 //mListView->setSingleClick( true );
94 connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), 95 connect(mListView,SIGNAL(selectionChanged(QListViewItem *)),
95 SLOT(updateAttendeeInput())); 96 SLOT(updateAttendeeInput()));
96 97
98 connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )),
99 SLOT(itemClicked(QListViewItem * ,const QPoint& , int )));
100
97 QLabel *attendeeLabel = new QLabel(this); 101 QLabel *attendeeLabel = new QLabel(this);
98 attendeeLabel->setText(i18n("Name:")); 102 attendeeLabel->setText(i18n("Name:"));
99 attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); 103 attendeeLabel->setFixedSize( attendeeLabel->sizeHint() );
100 mNameEdit = new QLineEdit(this); 104 mNameEdit = new QLineEdit(this);
101 connect(mNameEdit,SIGNAL(textChanged(const QString &)), 105 connect(mNameEdit,SIGNAL(textChanged(const QString &)),
102 SLOT(updateAttendeeItem())); 106 SLOT(updateAttendeeItem()));
103 107
104 mUidEdit = new QLineEdit(0); 108 mUidEdit = new QLineEdit(0);
105 mUidEdit->setText(""); 109 mUidEdit->setText("");
106 110
107 QLabel *emailLabel = new QLabel(this); 111 QLabel *emailLabel = new QLabel(this);
108 emailLabel->setText(i18n("Email:")); 112 emailLabel->setText(i18n("Email:"));
109 mEmailEdit = new QLineEdit(this); 113 mEmailEdit = new QLineEdit(this);
110 connect(mEmailEdit,SIGNAL(textChanged(const QString &)), 114 connect(mEmailEdit,SIGNAL(textChanged(const QString &)),
111 SLOT(updateAttendeeItem())); 115 SLOT(updateAttendeeItem()));
112 116
113 QLabel *attendeeRoleLabel = new QLabel(this); 117 QLabel *attendeeRoleLabel = new QLabel(this);
114 attendeeRoleLabel->setText(i18n("Role:")); 118 attendeeRoleLabel->setText(i18n("Role:"));
115 mRoleCombo = new QComboBox(false,this); 119 mRoleCombo = new QComboBox(false,this);
116 mRoleCombo->insertStringList(Attendee::roleList()); 120 mRoleCombo->insertStringList(Attendee::roleList());
117 connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); 121 connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem()));
118 122
119 QLabel *statusLabel = new QLabel(this); 123 QLabel *statusLabel = new QLabel(this);
120 statusLabel->setText( i18n("Status:") ); 124 statusLabel->setText( i18n("Status:") );
121 125
122 mStatusCombo = new QComboBox(false,this); 126 mStatusCombo = new QComboBox(false,this);
123 mStatusCombo->insertStringList(Attendee::statusList()); 127 mStatusCombo->insertStringList(Attendee::statusList());
124 connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); 128 connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem()));
125 129
126 mRsvpButton = new QCheckBox(this); 130 mRsvpButton = new QCheckBox(this);
127 mRsvpButton->setText(i18n("Request response")); 131 mRsvpButton->setText(i18n("Request response"));
128 connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); 132 connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem()));
129 QWidget *buttonBox = new QWidget(this); 133 QWidget *buttonBox = new QWidget(this);
130 QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); 134 QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox);
131 135
132 QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); 136 QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox);
133 buttonLayout->addWidget(newButton); 137 buttonLayout->addWidget(newButton);
134 connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); 138 connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee()));
135 139
136 mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); 140 mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox);
137 buttonLayout->addWidget(mRemoveButton); 141 buttonLayout->addWidget(mRemoveButton);
138 connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); 142 connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee()));
139 143
140 mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); 144 mAddressBookButton = new QPushButton(i18n("Address &Book..."),this);
141 // buttonLayout->addWidget(mAddressBookButton); 145 // buttonLayout->addWidget(mAddressBookButton);
142 connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); 146 connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook()));
143 //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); 147 //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () );
144 148
145 if (qApp->desktop()->width() < 640 ) { 149 if (qApp->desktop()->width() < 640 ) {
146 if ( qApp->desktop()->width() < 300 ) 150 if ( qApp->desktop()->width() < 300 )
147 topLayout->setSpacing(1); 151 topLayout->setSpacing(1);
148 ;//mListView->setFixedHeight(80); 152 ;//mListView->setFixedHeight(80);
149 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); 153 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3);
150 topLayout->addMultiCellWidget(mListView,1,1,0,3); 154 topLayout->addMultiCellWidget(mListView,1,1,0,3);
151 topLayout->addWidget(attendeeLabel,3,0); 155 topLayout->addWidget(attendeeLabel,3,0);
152 topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); 156 topLayout->addMultiCellWidget(mNameEdit,3,3,1,2);
153 topLayout->addWidget(emailLabel,4,0); 157 topLayout->addWidget(emailLabel,4,0);
154 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); 158 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2);
155 topLayout->addWidget(attendeeRoleLabel,5,0); 159 topLayout->addWidget(attendeeRoleLabel,5,0);
156 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3); 160 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3);
157 topLayout->addWidget(statusLabel,6,0); 161 topLayout->addWidget(statusLabel,6,0);
158 topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3); 162 topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3);
159 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); 163 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3);
160 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); 164 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
161 topLayout->addMultiCellWidget(buttonBox,3,4,3,3); 165 topLayout->addMultiCellWidget(buttonBox,3,4,3,3);
162 topLayout->setRowStretch(1,2); 166 topLayout->setRowStretch(1,2);
163 topLayout->setColStretch(0,0); 167 topLayout->setColStretch(0,0);
164 topLayout->setColStretch(1,2); 168 topLayout->setColStretch(1,2);
165 topLayout->setColStretch(2,1); 169 topLayout->setColStretch(2,1);
166 topLayout->setColStretch(3,1); 170 topLayout->setColStretch(3,1);
167 171
168 } else { 172 } else {
169 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); 173 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5);
170 topLayout->addMultiCellWidget(mListView,1,1,0,5); 174 topLayout->addMultiCellWidget(mListView,1,1,0,5);
171 topLayout->addWidget(attendeeLabel,3,0); 175 topLayout->addWidget(attendeeLabel,3,0);
172 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); 176 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4);
173 topLayout->addWidget(emailLabel,4,0); 177 topLayout->addWidget(emailLabel,4,0);
174 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); 178 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4);
175 topLayout->addWidget(attendeeRoleLabel,5,0); 179 topLayout->addWidget(attendeeRoleLabel,5,0);
176 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); 180 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2);
177 topLayout->addWidget(statusLabel,5,3); 181 topLayout->addWidget(statusLabel,5,3);
178 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); 182 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5);
179 topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); 183 topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5);
180 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); 184 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
181 topLayout->addMultiCellWidget(buttonBox,3,4,5,5); 185 topLayout->addMultiCellWidget(buttonBox,3,4,5,5);
182 topLayout->setRowStretch(1,5); 186 topLayout->setRowStretch(1,5);
183 topLayout->setColStretch(0,0); 187 topLayout->setColStretch(0,0);
184 } 188 }
185// #if 0 189// #if 0
186// topLayout->setColStretch(2,1); 190// topLayout->setColStretch(2,1);
187// topLayout->addWidget(statusLabel,3,3); 191// topLayout->addWidget(statusLabel,3,3);
188// topLayout->addWidget(mStatusCombo,3,4); 192// topLayout->addWidget(mStatusCombo,3,4);
189// #else 193// #else
190// topLayout->addWidget(statusLabel,4,3); 194// topLayout->addWidget(statusLabel,4,3);
191// // topLayout->addWidget(mStatusCombo,4,3); 195// // topLayout->addWidget(mStatusCombo,4,3);
192// topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); 196// topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5);
193 197
194// #endif 198// #endif
195// // topLayout->setRowStretch(5,1); 199// // topLayout->setRowStretch(5,1);
196// topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); 200// topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1);
197// topLayout->addMultiCellWidget(buttonBox,2,3,5,5); 201// topLayout->addMultiCellWidget(buttonBox,2,3,5,5);
198// topLayout->setRowStretch(1,5); 202// topLayout->setRowStretch(1,5);
199// topLayout->setColStretch(0,0); 203// topLayout->setColStretch(0,0);
200 204
201#ifdef KORG_NOKABC 205#ifdef KORG_NOKABC
202 mAddressBookButton->hide(); 206 mAddressBookButton->hide();
203#endif 207#endif
204 208
205 updateAttendeeInput(); 209 updateAttendeeInput();
206#ifndef DESKTOP_VERSION 210#ifndef DESKTOP_VERSION
207//US listen for arriving address resultsets 211//US listen for arriving address resultsets
208 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), 212 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
209 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); 213 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
210#endif 214#endif
211 215
212} 216}
213 217
214KOEditorDetails::~KOEditorDetails() 218KOEditorDetails::~KOEditorDetails()
215{ 219{
216} 220}
217 221
218void KOEditorDetails::removeAttendee() 222void KOEditorDetails::removeAttendee()
219{ 223{
220 AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); 224 AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem();
221 if (!aItem) return; 225 if (!aItem) return;
222 226
223 Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), 227 Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(),
224 aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), 228 aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(),
@@ -296,146 +300,153 @@ void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& name
296 300
297 Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); 301 Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid);
298 insertAttendee(a); 302 insertAttendee(a);
299 } 303 }
300 } 304 }
301 305
302} 306}
303 307
304void KOEditorDetails::insertAttendee(Attendee *a) 308void KOEditorDetails::insertAttendee(Attendee *a)
305{ 309{
306 AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); 310 AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild();
307 while (first) { 311 while (first) {
308 if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) 312 if ( first->data()->name() == a->name() && first->data()->email() == a->email() )
309 return; 313 return;
310 first = (AttendeeListItem*) first->nextSibling(); 314 first = (AttendeeListItem*) first->nextSibling();
311 } 315 }
312 316
313 AttendeeListItem *item = new AttendeeListItem(a,mListView); 317 AttendeeListItem *item = new AttendeeListItem(a,mListView);
314 mListView->setSelected( item, true ); 318 mListView->setSelected( item, true );
315} 319}
316 320
317void KOEditorDetails::setDefaults() 321void KOEditorDetails::setDefaults()
318{ 322{
319 mRsvpButton->setChecked(true); 323 mRsvpButton->setChecked(true);
320 mListView->clear(); 324 mListView->clear();
321 mdelAttendees.clear(); 325 mdelAttendees.clear();
322 clearAttendeeInput(); 326 clearAttendeeInput();
323 mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); 327 mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email()));
324 328
325 mNameEdit->setText(""); 329 mNameEdit->setText("");
326 mUidEdit->setText(""); 330 mUidEdit->setText("");
327 mEmailEdit->setText(""); 331 mEmailEdit->setText("");
328 mRoleCombo->setCurrentItem( 0 ); 332 mRoleCombo->setCurrentItem( 0 );
329 mStatusCombo->setCurrentItem( 0 ); 333 mStatusCombo->setCurrentItem( 0 );
330 334
331} 335}
332 336
333void KOEditorDetails::readEvent(Incidence *event) 337void KOEditorDetails::readEvent(Incidence *event)
334{ 338{
335 setDefaults(); 339 setDefaults();
336 //mListView->clear(); 340 //mListView->clear();
337 //mdelAttendees.clear(); 341 //mdelAttendees.clear();
338 QPtrList<Attendee> tmpAList = event->attendees(); 342 QPtrList<Attendee> tmpAList = event->attendees();
339 Attendee *a; 343 Attendee *a;
340 for (a = tmpAList.first(); a; a = tmpAList.next()) 344 for (a = tmpAList.first(); a; a = tmpAList.next())
341 insertAttendee(new Attendee(*a)); 345 insertAttendee(new Attendee(*a));
342 346
343 mListView->setSelected( mListView->firstChild(), true ); 347 mListView->setSelected( mListView->firstChild(), true );
344 mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); 348 mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer()));
345} 349}
346 350
347void KOEditorDetails::writeEvent(Incidence *event) 351void KOEditorDetails::writeEvent(Incidence *event)
348{ 352{
349 event->clearAttendees(); 353 event->clearAttendees();
350 QListViewItem *item; 354 QListViewItem *item;
351 AttendeeListItem *a; 355 AttendeeListItem *a;
352 for (item = mListView->firstChild(); item; 356 for (item = mListView->firstChild(); item;
353 item = item->nextSibling()) { 357 item = item->nextSibling()) {
354 a = (AttendeeListItem *)item; 358 a = (AttendeeListItem *)item;
355 event->addAttendee(new Attendee(*(a->data()))); 359 event->addAttendee(new Attendee(*(a->data())));
356 } 360 }
357 event->setOrganizer(KOPrefs::instance()->email()); 361 event->setOrganizer(KOPrefs::instance()->email());
358} 362}
359 363
360void KOEditorDetails::cancelAttendeeEvent(Incidence *event) 364void KOEditorDetails::cancelAttendeeEvent(Incidence *event)
361{ 365{
362 event->clearAttendees(); 366 event->clearAttendees();
363 Attendee * att; 367 Attendee * att;
364 for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { 368 for (att=mdelAttendees.first();att;att=mdelAttendees.next()) {
365 event->addAttendee(new Attendee(*att)); 369 event->addAttendee(new Attendee(*att));
366 } 370 }
367 mdelAttendees.clear(); 371 mdelAttendees.clear();
368} 372}
369 373
370bool KOEditorDetails::validateInput() 374bool KOEditorDetails::validateInput()
371{ 375{
372 return true; 376 return true;
373} 377}
374 378
375void KOEditorDetails::updateAttendeeInput() 379void KOEditorDetails::updateAttendeeInput()
376{ 380{
377 QListViewItem *item = mListView->selectedItem(); 381 QListViewItem *item = mListView->selectedItem();
378 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); 382 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
379 if (aItem) { 383 if (aItem) {
380 fillAttendeeInput( aItem ); 384 fillAttendeeInput( aItem );
381 } else { 385 } else {
382 clearAttendeeInput(); 386 clearAttendeeInput();
383 } 387 }
384} 388}
385 389
386void KOEditorDetails::clearAttendeeInput() 390void KOEditorDetails::clearAttendeeInput()
387{ 391{
388 mNameEdit->setText(""); 392 mNameEdit->setText("");
389 mUidEdit->setText(""); 393 mUidEdit->setText("");
390 mEmailEdit->setText(""); 394 mEmailEdit->setText("");
391 mRoleCombo->setCurrentItem(0); 395 mRoleCombo->setCurrentItem(0);
392 mStatusCombo->setCurrentItem(0); 396 mStatusCombo->setCurrentItem(0);
393 mRsvpButton->setChecked(true); 397 mRsvpButton->setChecked(true);
394 setEnabledAttendeeInput( false ); 398 setEnabledAttendeeInput( false );
395} 399}
396 400
397void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) 401void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem )
398{ 402{
399 Attendee *a = aItem->data(); 403 Attendee *a = aItem->data();
400 mDisableItemUpdate = true; 404 mDisableItemUpdate = true;
401 mNameEdit->setText(a->name()); 405 mNameEdit->setText(a->name());
402 mUidEdit->setText(a->uid()); 406 mUidEdit->setText(a->uid());
403 mEmailEdit->setText(a->email()); 407 mEmailEdit->setText(a->email());
404 mRoleCombo->setCurrentItem(a->role()); 408 mRoleCombo->setCurrentItem(a->role());
405 mStatusCombo->setCurrentItem(a->status()); 409 mStatusCombo->setCurrentItem(a->status());
406 mRsvpButton->setChecked(a->RSVP()); 410 mRsvpButton->setChecked(a->RSVP());
407 411
408 mDisableItemUpdate = false; 412 mDisableItemUpdate = false;
409 413
410 setEnabledAttendeeInput( true ); 414 setEnabledAttendeeInput( true );
411} 415}
412 416
413void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) 417void KOEditorDetails::setEnabledAttendeeInput( bool enabled )
414{ 418{
415 mNameEdit->setEnabled( enabled ); 419 mNameEdit->setEnabled( enabled );
416 mEmailEdit->setEnabled( enabled ); 420 mEmailEdit->setEnabled( enabled );
417 mRoleCombo->setEnabled( enabled ); 421 mRoleCombo->setEnabled( enabled );
418 mStatusCombo->setEnabled( enabled ); 422 mStatusCombo->setEnabled( enabled );
419 mRsvpButton->setEnabled( enabled ); 423 mRsvpButton->setEnabled( enabled );
420 424
421 mRemoveButton->setEnabled( enabled ); 425 mRemoveButton->setEnabled( enabled );
422} 426}
423 427
428void KOEditorDetails::itemClicked(QListViewItem * item ,const QPoint & pnt, int c )
429{
430 if ( item && c == 4 ) {
431 mRsvpButton->setChecked( !mRsvpButton->isChecked() );
432 updateAttendeeItem();
433 }
434}
424void KOEditorDetails::updateAttendeeItem() 435void KOEditorDetails::updateAttendeeItem()
425{ 436{
426 if (mDisableItemUpdate) return; 437 if (mDisableItemUpdate) return;
427 438
428 QListViewItem *item = mListView->selectedItem(); 439 QListViewItem *item = mListView->selectedItem();
429 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); 440 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
430 if ( !aItem ) return; 441 if ( !aItem ) return;
431 442
432 Attendee *a = aItem->data(); 443 Attendee *a = aItem->data();
433 444
434 a->setName( mNameEdit->text() ); 445 a->setName( mNameEdit->text() );
435 a->setUid( mUidEdit->text() ); 446 a->setUid( mUidEdit->text() );
436 a->setEmail( mEmailEdit->text() ); 447 a->setEmail( mEmailEdit->text() );
437 a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); 448 a->setRole( Attendee::Role( mRoleCombo->currentItem() ) );
438 a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); 449 a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) );
439 a->setRSVP( mRsvpButton->isChecked() ); 450 a->setRSVP( mRsvpButton->isChecked() );
440 aItem->updateItem(); 451 aItem->updateItem();
441} 452}
diff --git a/korganizer/koeditordetails.h b/korganizer/koeditordetails.h
index 0cc807f..a33ee82 100644
--- a/korganizer/koeditordetails.h
+++ b/korganizer/koeditordetails.h
@@ -1,108 +1,109 @@
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 _KOEDITORDETAILS_H 23#ifndef _KOEDITORDETAILS_H
24#define _KOEDITORDETAILS_H 24#define _KOEDITORDETAILS_H
25 25
26#include <qmap.h> 26#include <qmap.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qcheckbox.h> 29#include <qcheckbox.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qgroupbox.h> 31#include <qgroupbox.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qmultilineedit.h> 34#include <qmultilineedit.h>
35#include <klistview.h> 35#include <klistview.h>
36#include <qradiobutton.h> 36#include <qradiobutton.h>
37#include <qptrlist.h> 37#include <qptrlist.h>
38 38
39#include <kapplication.h> 39#include <kapplication.h>
40 40
41#include <libkcal/event.h> 41#include <libkcal/event.h>
42 42
43#include "ktimeedit.h" 43#include "ktimeedit.h"
44#include "customlistviewitem.h" 44#include "customlistviewitem.h"
45 45
46class KDateEdit; 46class KDateEdit;
47 47
48using namespace KCal; 48using namespace KCal;
49 49
50typedef CustomListViewItem<Attendee *> AttendeeListItem; 50typedef CustomListViewItem<Attendee *> AttendeeListItem;
51 51
52 52
53class KOEditorDetails : public QWidget 53class KOEditorDetails : public QWidget
54{ 54{
55 Q_OBJECT 55 Q_OBJECT
56 public: 56 public:
57 KOEditorDetails (int spacing = 8,QWidget* parent = 0, const char* name = 0); 57 KOEditorDetails (int spacing = 8,QWidget* parent = 0, const char* name = 0);
58 virtual ~KOEditorDetails(); 58 virtual ~KOEditorDetails();
59 59
60 /** Set widgets to default values */ 60 /** Set widgets to default values */
61 void setDefaults(); 61 void setDefaults();
62 /** Read event object and setup widgets accordingly */ 62 /** Read event object and setup widgets accordingly */
63 void readEvent(Incidence *); 63 void readEvent(Incidence *);
64 /** Write event settings to event object */ 64 /** Write event settings to event object */
65 void writeEvent(Incidence *); 65 void writeEvent(Incidence *);
66 66
67 /** return a clone of the event with attendees to be canceld*/ 67 /** return a clone of the event with attendees to be canceld*/
68 void cancelAttendeeEvent(Incidence *); 68 void cancelAttendeeEvent(Incidence *);
69 /** Check if the input is valid. */ 69 /** Check if the input is valid. */
70 bool validateInput(); 70 bool validateInput();
71 71
72 public slots: 72 public slots:
73 void insertAttendee(Attendee *); 73 void insertAttendee(Attendee *);
74 // called when the app recieves a list of name/email/uid (=addresses) from another app. Usually Ka/Pi 74 // called when the app recieves a list of name/email/uid (=addresses) from another app. Usually Ka/Pi
75 // The first parameter is a uniqueid. It can be used to identify if event 75 // The first parameter is a uniqueid. It can be used to identify if event
76 void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist); 76 void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist);
77 77
78 78
79 protected slots: 79 protected slots:
80 void addNewAttendee(); 80 void addNewAttendee();
81 void removeAttendee(); 81 void removeAttendee();
82 void openAddressBook(); 82 void openAddressBook();
83 void updateAttendeeInput(); 83 void updateAttendeeInput();
84 void clearAttendeeInput(); 84 void clearAttendeeInput();
85 void fillAttendeeInput(AttendeeListItem *); 85 void fillAttendeeInput(AttendeeListItem *);
86 void itemClicked(QListViewItem *,const QPoint & pnt, int c);
86 void updateAttendeeItem(); 87 void updateAttendeeItem();
87 void setEnabledAttendeeInput(bool); 88 void setEnabledAttendeeInput(bool);
88 89
89 private: 90 private:
90 bool mDisableItemUpdate; 91 bool mDisableItemUpdate;
91 92
92 QLineEdit *mNameEdit; 93 QLineEdit *mNameEdit;
93 QLineEdit *mUidEdit; 94 QLineEdit *mUidEdit;
94 QLineEdit *mEmailEdit; 95 QLineEdit *mEmailEdit;
95 KListView *mListView; 96 KListView *mListView;
96 QComboBox* mRoleCombo; 97 QComboBox* mRoleCombo;
97 QCheckBox* mRsvpButton; 98 QCheckBox* mRsvpButton;
98 QComboBox* mStatusCombo; 99 QComboBox* mStatusCombo;
99 QLabel *mOrganizerLabel; 100 QLabel *mOrganizerLabel;
100 101
101 QPushButton* mAddButton; 102 QPushButton* mAddButton;
102 QPushButton* mRemoveButton; 103 QPushButton* mRemoveButton;
103 QPushButton* mAddressBookButton; 104 QPushButton* mAddressBookButton;
104 105
105 QPtrList<Attendee> mdelAttendees; 106 QPtrList<Attendee> mdelAttendees;
106}; 107};
107 108
108#endif 109#endif
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 5de667e..2f0fa9e 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -292,304 +292,308 @@ void KOEventViewer::appendEvent(Event *event, int mode )
292 } else { 292 } else {
293 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 293 mMailSubject += i18n(" - " )+event->dtStartStr( true );
294 294
295 } 295 }
296 296
297 297
298 if (event->isAlarmEnabled()) { 298 if (event->isAlarmEnabled()) {
299 Alarm *alarm =event->alarms().first() ; 299 Alarm *alarm =event->alarms().first() ;
300 QDateTime t = alarm->time(); 300 QDateTime t = alarm->time();
301 int min = t.secsTo( event->dtStart() )/60; 301 int min = t.secsTo( event->dtStart() )/60;
302 QString s =i18n("( %1 min before )").arg( min ); 302 QString s =i18n("( %1 min before )").arg( min );
303 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 303 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
304 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 304 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
305 //addTag("p",s); 305 //addTag("p",s);
306 } 306 }
307 307
308 addTag("b",i18n("Access: ")); 308 addTag("b",i18n("Access: "));
309 mText.append(event->secrecyStr()+"<br>"); 309 mText.append(event->secrecyStr()+"<br>");
310 if (!event->description().isEmpty()) { 310 if (!event->description().isEmpty()) {
311 addTag("p",i18n("<b>Details: </b>")); 311 addTag("p",i18n("<b>Details: </b>"));
312 addTag("p",event->description()); 312 addTag("p",event->description());
313 } 313 }
314 314
315 formatCategories(event); 315 formatCategories(event);
316 316
317 formatReadOnly(event); 317 formatReadOnly(event);
318 formatAttendees(event); 318 formatAttendees(event);
319 319
320 setText(mText); 320 setText(mText);
321 //QWhatsThis::add(this,mText); 321 //QWhatsThis::add(this,mText);
322 322
323} 323}
324 324
325void KOEventViewer::appendTodo(Todo *event, int mode ) 325void KOEventViewer::appendTodo(Todo *event, int mode )
326{ 326{
327 mMailSubject = ""; 327 mMailSubject = "";
328 mCurrentIncidence = event; 328 mCurrentIncidence = event;
329 topLevelWidget()->setCaption(i18n("Todo Viewer")); 329 topLevelWidget()->setCaption(i18n("Todo Viewer"));
330 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 330 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
331 if (mode == 0 ) 331 if (mode == 0 )
332 addTag("h2",event->summary()); 332 addTag("h2",event->summary());
333 else { 333 else {
334 if ( mColorMode == 1 ) { 334 if ( mColorMode == 1 ) {
335 mText +="<font color=\"#00A000\">"; 335 mText +="<font color=\"#00A000\">";
336 } 336 }
337 if ( mColorMode == 2 ) { 337 if ( mColorMode == 2 ) {
338 mText +="<font color=\"#B00000\">"; 338 mText +="<font color=\"#B00000\">";
339 } 339 }
340 if ( mode == 1 ) { 340 if ( mode == 1 ) {
341 addTag("h2",i18n( "Local: " ) +event->summary()); 341 addTag("h2",i18n( "Local: " ) +event->summary());
342 } else { 342 } else {
343 addTag("h2",i18n( "Remote: " ) +event->summary()); 343 addTag("h2",i18n( "Remote: " ) +event->summary());
344 } 344 }
345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
346 if ( mColorMode ) 346 if ( mColorMode )
347 mText += "</font>"; 347 mText += "</font>";
348 } 348 }
349 mMailSubject += i18n( "Todo " )+ event->summary(); 349 mMailSubject += i18n( "Todo " )+ event->summary();
350 if (event->cancelled ()) { 350 if (event->cancelled ()) {
351 mText +="<font color=\"#B00000\">"; 351 mText +="<font color=\"#B00000\">";
352 addTag("i",i18n("This todo has been cancelled!")); 352 addTag("i",i18n("This todo has been cancelled!"));
353 mText.append("<br>"); 353 mText.append("<br>");
354 mText += "</font>"; 354 mText += "</font>";
355 mMailSubject += i18n("(cancelled)"); 355 mMailSubject += i18n("(cancelled)");
356 } 356 }
357 357
358 if (!event->location().isEmpty()) { 358 if (!event->location().isEmpty()) {
359 addTag("b",i18n("Location: ")); 359 addTag("b",i18n("Location: "));
360 mText.append(event->location()+"<br>"); 360 mText.append(event->location()+"<br>");
361 mMailSubject += i18n(" at ") + event->location(); 361 mMailSubject += i18n(" at ") + event->location();
362 } 362 }
363 if (event->hasStartDate()) { 363 if (event->hasStartDate()) {
364 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 364 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
365 } 365 }
366 if (event->hasDueDate()) { 366 if (event->hasDueDate()) {
367 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 367 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
368 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 368 mMailSubject += i18n(" - " )+event->dtDueStr( true );
369 } 369 }
370 addTag("b",i18n("Access: ")); 370 addTag("b",i18n("Access: "));
371 mText.append(event->secrecyStr()+"<br>"); 371 mText.append(event->secrecyStr()+"<br>");
372 if (!event->description().isEmpty()) { 372 if (!event->description().isEmpty()) {
373 addTag("p",i18n("<b>Details: </b>")); 373 addTag("p",i18n("<b>Details: </b>"));
374 addTag("p",event->description()); 374 addTag("p",event->description());
375 } 375 }
376 376
377 formatCategories(event); 377 formatCategories(event);
378 378
379 mText.append(i18n("<p><b>Priority:</b> %2</p>") 379 mText.append(i18n("<p><b>Priority:</b> %2</p>")
380 .arg(QString::number(event->priority()))); 380 .arg(QString::number(event->priority())));
381 381
382 mText.append(i18n("<p><i>%1 % completed</i></p>") 382 mText.append(i18n("<p><i>%1 % completed</i></p>")
383 .arg(event->percentComplete())); 383 .arg(event->percentComplete()));
384 384
385 formatReadOnly(event); 385 formatReadOnly(event);
386 formatAttendees(event); 386 formatAttendees(event);
387 if ( event->relatedTo() ) { 387 if ( event->relatedTo() ) {
388 addTag("b",i18n("Parent todo: ")); 388 addTag("b",i18n("Parent todo: "));
389 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 389 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
390 } 390 }
391 QPtrList<Incidence> Relations = event->relations(); 391 QPtrList<Incidence> Relations = event->relations();
392 Incidence *to; 392 Incidence *to;
393 if ( Relations.first() ) 393 if ( Relations.first() )
394 addTag("b",i18n("Sub todos:<br>")); 394 addTag("b",i18n("Sub todos:<br>"));
395 for (to=Relations.first();to;to=Relations.next()) { 395 for (to=Relations.first();to;to=Relations.next()) {
396 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 396 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
397 397
398 } 398 }
399 setText(mText); 399 setText(mText);
400} 400}
401 401
402void KOEventViewer::formatCategories(Incidence *event) 402void KOEventViewer::formatCategories(Incidence *event)
403{ 403{
404 if (!event->categoriesStr().isEmpty()) { 404 if (!event->categoriesStr().isEmpty()) {
405 if (event->categories().count() == 1) { 405 if (event->categories().count() == 1) {
406 addTag("h3",i18n("Category")); 406 addTag("h3",i18n("Category"));
407 } else { 407 } else {
408 addTag("h3",i18n("Categories")); 408 addTag("h3",i18n("Categories"));
409 } 409 }
410 addTag("p",event->categoriesStr()); 410 addTag("p",event->categoriesStr());
411 } 411 }
412} 412}
413void KOEventViewer::formatAttendees(Incidence *event) 413void KOEventViewer::formatAttendees(Incidence *event)
414{ 414{
415 QPtrList<Attendee> attendees = event->attendees(); 415 QPtrList<Attendee> attendees = event->attendees();
416 if (attendees.count()) { 416 if (attendees.count()) {
417 417
418 418
419 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 419 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
420 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
420 addTag("h3",i18n("Organizer")); 421 addTag("h3",i18n("Organizer"));
421 mText.append("<ul><li>"); 422 mText.append("<ul><li>");
422#ifndef KORG_NOKABC 423#ifndef KORG_NOKABC
423 424
424#ifdef DESKTOP_VERSION 425#ifdef DESKTOP_VERSION
425 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 426 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
426 KABC::Addressee::List addressList; 427 KABC::Addressee::List addressList;
427 addressList = add_book->findByEmail(event->organizer()); 428 addressList = add_book->findByEmail(event->organizer());
428 KABC::Addressee o = addressList.first(); 429 KABC::Addressee o = addressList.first();
429 if (!o.isEmpty() && addressList.size()<2) { 430 if (!o.isEmpty() && addressList.size()<2) {
430 mText += "<a href=\"uid:" + o.uid() + "\">"; 431 mText += "<a href=\"uid:" + o.uid() + "\">";
431 mText += o.formattedName(); 432 mText += o.formattedName();
432 mText += "</a>\n"; 433 mText += "</a>\n";
433 } else { 434 } else {
434 mText.append(event->organizer()); 435 mText.append(event->organizer());
435 } 436 }
436#else //DESKTOP_VERSION 437#else //DESKTOP_VERSION
437 mText += "<a href=\"uid:organizer\">"; 438 mText += "<a href=\"uid:organizer\">";
438 mText += event->organizer(); 439 mText += event->organizer();
439 mText += "</a>\n"; 440 mText += "</a>\n";
440#endif //DESKTOP_VERSION 441#endif //DESKTOP_VERSION
441 442
442 443
443#else 444#else
444 mText.append(event->organizer()); 445 mText.append(event->organizer());
445#endif 446#endif
446 447
447 if (iconPath) { 448 if (iconPath) {
448 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 449 mText += " <a href=\"mailto:" + event->organizer() + "\">";
449 mText += "<IMG src=\"" + iconPath + "\">"; 450 mText += "<IMG src=\"" + iconPath + "\">";
450 mText += "</a>\n"; 451 mText += "</a>\n";
451 } 452 }
452 mText.append("</li></ul>"); 453 mText.append("</li></ul>");
453 454
454 addTag("h3",i18n("Attendees")); 455 addTag("h3",i18n("Attendees"));
455 Attendee *a; 456 Attendee *a;
456 mText.append("<ul>"); 457 mText.append("<ul>");
457 for(a=attendees.first();a;a=attendees.next()) { 458 for(a=attendees.first();a;a=attendees.next()) {
458#ifndef KORG_NOKABC 459#ifndef KORG_NOKABC
459#ifdef DESKTOP_VERSION 460#ifdef DESKTOP_VERSION
460 if (a->name().isEmpty()) { 461 if (a->name().isEmpty()) {
461 addressList = add_book->findByEmail(a->email()); 462 addressList = add_book->findByEmail(a->email());
462 KABC::Addressee o = addressList.first(); 463 KABC::Addressee o = addressList.first();
463 if (!o.isEmpty() && addressList.size()<2) { 464 if (!o.isEmpty() && addressList.size()<2) {
464 mText += "<a href=\"uid:" + o.uid() + "\">"; 465 mText += "<a href=\"uid:" + o.uid() + "\">";
465 mText += o.formattedName(); 466 mText += o.formattedName();
466 mText += "</a>\n"; 467 mText += "</a>\n";
467 } else { 468 } else {
468 mText += "<li>"; 469 mText += "<li>";
469 mText.append(a->email()); 470 mText.append(a->email());
470 mText += "\n"; 471 mText += "\n";
471 } 472 }
472 } else { 473 } else {
473 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 474 mText += "<li><a href=\"uid:" + a->uid() + "\">";
474 if (!a->name().isEmpty()) mText += a->name(); 475 if (!a->name().isEmpty()) mText += a->name();
475 else mText += a->email(); 476 else mText += a->email();
476 mText += "</a>\n"; 477 mText += "</a>\n";
477 } 478 }
478#else //DESKTOP_VERSION 479#else //DESKTOP_VERSION
479 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 480 mText += "<li><a href=\"uid:" + a->uid() + "\">";
480 if (!a->name().isEmpty()) mText += a->name(); 481 if (!a->name().isEmpty()) mText += a->name();
481 else mText += a->email(); 482 else mText += a->email();
482 mText += "</a>\n"; 483 mText += "</a>\n";
483#endif //DESKTOP_VERSION 484#endif //DESKTOP_VERSION
484#else 485#else
485 //qDebug("nokabc "); 486 //qDebug("nokabc ");
486 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 487 mText += "<li><a href=\"uid:" + a->uid() + "\">";
487 if (!a->name().isEmpty()) mText += a->name(); 488 if (!a->name().isEmpty()) mText += a->name();
488 else mText += a->email(); 489 else mText += a->email();
489 mText += "</a>\n"; 490 mText += "</a>\n";
490#endif 491#endif
491 492
492 493
493 if (!a->email().isEmpty()) { 494 if (!a->email().isEmpty()) {
494 if (iconPath) { 495 if (iconPath) {
495 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 496 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
496 mText += "<IMG src=\"" + iconPath + "\">"; 497 if ( a->RSVP() )
498 mText += "<IMG src=\"" + iconPath + "\">";
499 else
500 mText += "<IMG src=\"" + NOiconPath + "\">";
497 mText += "</a>\n"; 501 mText += "</a>\n";
498 } 502 }
499 } 503 }
500 if (a->status() != Attendee::NeedsAction ) 504 if (a->status() != Attendee::NeedsAction )
501 mText +="[" + a->statusStr() + "] "; 505 mText +="[" + a->statusStr() + "] ";
502 if (a->role() == Attendee::Chair ) 506 if (a->role() == Attendee::Chair )
503 mText +="(" + a->roleStr().left(1) + ".)"; 507 mText +="(" + a->roleStr().left(1) + ".)";
504 } 508 }
505 mText.append("</li></ul>"); 509 mText.append("</li></ul>");
506 } 510 }
507 511
508} 512}
509void KOEventViewer::appendJournal(Journal *jour, int mode ) 513void KOEventViewer::appendJournal(Journal *jour, int mode )
510{ 514{
511 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 515 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
512 if (mode == 0 ) { 516 if (mode == 0 ) {
513 addTag("h2",i18n("Journal from: ")); 517 addTag("h2",i18n("Journal from: "));
514 } 518 }
515 else { 519 else {
516 if ( mode == 1 ) { 520 if ( mode == 1 ) {
517 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 521 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
518 } else { 522 } else {
519 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 523 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
520 } 524 }
521 } 525 }
522 topLevelWidget()->setCaption("Journal Viewer"); 526 topLevelWidget()->setCaption("Journal Viewer");
523 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 527 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
524 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 528 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
525 if (!jour->description().isEmpty()) { 529 if (!jour->description().isEmpty()) {
526 addTag("p",jour->description()); 530 addTag("p",jour->description());
527 } 531 }
528 setText(mText); 532 setText(mText);
529} 533}
530 534
531void KOEventViewer::formatReadOnly(Incidence *event) 535void KOEventViewer::formatReadOnly(Incidence *event)
532{ 536{
533 if (event->isReadOnly()) { 537 if (event->isReadOnly()) {
534 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 538 addTag("p","<em>(" + i18n("read-only") + ")</em>");
535 } 539 }
536} 540}
537void KOEventViewer::setSyncMode( bool b ) 541void KOEventViewer::setSyncMode( bool b )
538{ 542{
539 mSyncMode = b; 543 mSyncMode = b;
540} 544}
541 545
542 546
543void KOEventViewer::setTodo(Todo *event, bool clearV ) 547void KOEventViewer::setTodo(Todo *event, bool clearV )
544{ 548{
545 if ( clearV ) 549 if ( clearV )
546 clearEvents(); 550 clearEvents();
547 if ( mSyncMode ) { 551 if ( mSyncMode ) {
548 if ( clearV ) 552 if ( clearV )
549 appendTodo(event,1 ); 553 appendTodo(event,1 );
550 else 554 else
551 appendTodo(event,2); 555 appendTodo(event,2);
552 } else 556 } else
553 appendTodo(event); 557 appendTodo(event);
554} 558}
555void KOEventViewer::setJournal(Journal *event, bool clearV ) 559void KOEventViewer::setJournal(Journal *event, bool clearV )
556{ 560{
557 if ( clearV ) 561 if ( clearV )
558 clearEvents(); 562 clearEvents();
559 if ( mSyncMode ) { 563 if ( mSyncMode ) {
560 if ( clearV ) 564 if ( clearV )
561 appendJournal(event, 1); 565 appendJournal(event, 1);
562 else 566 else
563 appendJournal(event, 2); 567 appendJournal(event, 2);
564 } else 568 } else
565 appendJournal(event); 569 appendJournal(event);
566} 570}
567 571
568void KOEventViewer::setEvent(Event *event) 572void KOEventViewer::setEvent(Event *event)
569{ 573{
570 clearEvents(); 574 clearEvents();
571 if ( mSyncMode ) 575 if ( mSyncMode )
572 appendEvent(event, 1); 576 appendEvent(event, 1);
573 else 577 else
574 appendEvent(event); 578 appendEvent(event);
575} 579}
576 580
577void KOEventViewer::addEvent(Event *event) 581void KOEventViewer::addEvent(Event *event)
578{ 582{
579 if ( mSyncMode ) 583 if ( mSyncMode )
580 appendEvent(event, 2); 584 appendEvent(event, 2);
581 else 585 else
582 appendEvent(event); 586 appendEvent(event);
583} 587}
584 588
585void KOEventViewer::clearEvents(bool now) 589void KOEventViewer::clearEvents(bool now)
586{ 590{
587 mText = ""; 591 mText = "";
588 if (now) setText(mText); 592 if (now) setText(mText);
589} 593}
590 594
591void KOEventViewer::addText(QString text) 595void KOEventViewer::addText(QString text)
592{ 596{
593 mText.append(text); 597 mText.append(text);
594 setText(mText); 598 setText(mText);
595} 599}
diff --git a/libkcal/dndfactory.h b/libkcal/dndfactory.h
index 7e2ca04..2df5259 100644
--- a/libkcal/dndfactory.h
+++ b/libkcal/dndfactory.h
@@ -1,74 +1,83 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org>
6 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 6 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#ifdef DESKTOP_VERSION
25
24#ifndef KCAL_DNDFACTORY_H 26#ifndef KCAL_DNDFACTORY_H
25#define KCAL_DNDFACTORY_H 27#define KCAL_DNDFACTORY_H
26 28
27//#include "libkcal_export.h" 29//#include "libkcal_export.h"
28 30
29namespace KCal { 31namespace KCal {
30 32
31class ICalDrag; 33class ICalDrag;
32class Event; 34class Event;
33class Todo; 35class Todo;
34class Calendar; 36class Calendar;
35#define LIBKCAL_EXPORT 37#define LIBKCAL_EXPORT
36 38
37/** 39/**
38 This class implements functions to create Drag and Drop objects used for 40 This class implements functions to create Drag and Drop objects used for
39 Drag-and-Drop and Copy-and-Paste. 41 Drag-and-Drop and Copy-and-Paste.
40 42
41 @short vCalendar/iCalendar Drag-and-Drop object factory. 43 @short vCalendar/iCalendar Drag-and-Drop object factory.
42*/ 44*/
43class LIBKCAL_EXPORT DndFactory 45class LIBKCAL_EXPORT DndFactory
44{ 46{
45 public: 47 public:
46 DndFactory( Calendar * ); 48 DndFactory( Calendar * );
47 49
48 /** 50 /**
49 Create a drag object. 51 Create a drag object.
50 */ 52 */
51 ICalDrag *createDrag( Incidence *incidence, QWidget *owner ); 53 ICalDrag *createDrag( Incidence *incidence, QWidget *owner );
52 54
53 /** Create Todo object from drop event */ 55 /** Create Todo object from drop event */
54 Todo *createDropTodo(QDropEvent *de); 56 Todo *createDropTodo(QDropEvent *de);
55 /** Create Event object from drop event */ 57 /** Create Event object from drop event */
56 Event *createDrop(QDropEvent *de); 58 Event *createDrop(QDropEvent *de);
57 59
58 /** cut incidence to clipboard */ 60 /** cut incidence to clipboard */
59 void cutIncidence( Incidence * ); 61 void cutIncidence( Incidence * );
60 /** copy the incidence to clipboard */ 62 /** copy the incidence to clipboard */
61 bool copyIncidence( Incidence * ); 63 bool copyIncidence( Incidence * );
62 /** pastes the event or todo and returns a pointer to the new incidence pasted. */ 64 /** pastes the event or todo and returns a pointer to the new incidence pasted. */
63 Incidence *pasteIncidence( const QDate &, const QTime *newTime = 0 ); 65 Incidence *pasteIncidence( const QDate &, const QTime *newTime = 0 );
64 66
65 private: 67 private:
66 Calendar *mCalendar; 68 Calendar *mCalendar;
67 69
68 class Private; 70 class Private;
69 Private *d; 71 Private *d;
70}; 72};
71 73
72} 74}
73 75
74#endif 76#endif
77
78#else // dummy implementation for embedded
79#include "dndfactory_dummy.h"
80#define cutIncidence cutEvent
81#define pasteIncidence pasteEvent
82#define copyIncidence copyEvent
83#endif