summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp11
-rw-r--r--korganizer/kowhatsnextview.cpp11
2 files changed, 19 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1d5a57e..257a4dd 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1478,101 +1478,104 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd
birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
if (!ok) {
;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
}
anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
if (!ok) {
;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
}
realName = realNameList[i];
email = emailList[i];
assembledName = assembledNameList[i];
uid = uidList[i];
//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() );
if ( birthday.isValid() ){
a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
KCal::Attendee::ReqParticipant,uid) ;
if ( addAnniversary( birthday, assembledName, a, true ) )
++addCount;
}
if ( anniversary.isValid() ){
a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
KCal::Attendee::ReqParticipant,uid) ;
if ( addAnniversary( anniversary, assembledName, a, false ) )
++addCount;
}
}
updateView();
topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
}
}
bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
{
//qDebug("addAnni ");
Event * ev = new Event();
if ( a ) {
ev->addAttendee( a );
}
QString kind;
- if ( birthday )
+ if ( birthday ) {
kind = i18n( "Birthday" );
- else
+ ev->setSummary( name + " (" + QString::number(date.year()) +")");
+ }
+ else {
kind = i18n( "Anniversary" );
- ev->setSummary( name + " - " + kind );
+ ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
+ }
ev->setOrganizer(a->email());
ev->setCategories( kind );
ev->setDtStart( QDateTime(date) );
ev->setDtEnd( QDateTime(date) );
ev->setFloats( true );
Recurrence * rec = ev->recurrence();
rec->setYearly(Recurrence::rYearlyMonth,1,-1);
rec->addYearlyNum( date.month() );
if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
delete ev;
return false;
}
return true;
}
bool CalendarView::importQtopia( const QString &categories,
const QString &datebook,
const QString &todolist )
{
QtopiaFormat qtopiaFormat;
qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
updateView();
return true;
#if 0
mGlobalSyncMode = SYNC_MODE_QTOPIA;
mCurrentSyncDevice = "qtopia-XML";
if ( mSyncManager->mAskForPreferences )
edit_sync_options();
qApp->processEvents();
CalendarLocal* calendar = new CalendarLocal();
calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
bool syncOK = false;
QtopiaFormat qtopiaFormat;
qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
bool loadOk = true;
if ( !categories.isEmpty() )
loadOk = qtopiaFormat.load( calendar, categories );
if ( loadOk && !datebook.isEmpty() )
loadOk = qtopiaFormat.load( calendar, datebook );
if ( loadOk && !todolist.isEmpty() )
loadOk = qtopiaFormat.load( calendar, todolist );
@@ -2466,111 +2469,113 @@ void CalendarView::moveIncidence(Incidence * inc )
int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
mDateFrame->show();
}
mDatePickerMode = 2;
mMoveIncidence = inc ;
QDate da;
if ( mMoveIncidence->type() == "Todo" ) {
Todo * to = (Todo *) mMoveIncidence;
if ( to->hasDueDate() )
da = to->dtDue().date();
else
da = QDate::currentDate();
} else {
da = mMoveIncidence->dtStart().date();
}
//PENDING set date for recurring incidence to date of recurrence
//mMoveIncidenceOldDate;
mDatePicker->setDate( da );
}
void CalendarView::showDatePicker( )
{
//qDebug("CalendarView::showDatePicker( ) ");
if ( mDateFrame->isVisible() )
mDateFrame->hide();
else {
int w =mDatePicker->sizeHint().width() ;
int h = mDatePicker->sizeHint().height() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
mDateFrame->show();
}
mDatePickerMode = 1;
mDatePicker->setDate( mNavigator->selectedDates().first() );
}
void CalendarView::showEventEditor()
{
#ifdef DESKTOP_VERSION
mEventEditor->show();
#else
if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
+ qApp->processEvents();
delete mEventEditor;
mEventEditor = mDialogManager->getEventEditor();
topLevelWidget()->setCaption( i18n("") );
}
mEventEditor->showMaximized();
#endif
}
void CalendarView::showTodoEditor()
{
#ifdef DESKTOP_VERSION
mTodoEditor->show();
#else
if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
+ qApp->processEvents();
delete mTodoEditor;
mTodoEditor = mDialogManager->getTodoEditor();
topLevelWidget()->setCaption( i18n("") );
}
mTodoEditor->showMaximized();
#endif
}
void CalendarView::cloneIncidence()
{
Incidence *incidence = currentSelection();
if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
if ( incidence ) {
cloneIncidence(incidence);
}
}
void CalendarView::moveIncidence()
{
Incidence *incidence = currentSelection();
if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
if ( incidence ) {
moveIncidence(incidence);
}
}
void CalendarView::beamIncidence()
{
Incidence *incidence = currentSelection();
if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
if ( incidence ) {
beamIncidence(incidence);
}
}
void CalendarView::toggleCancelIncidence()
{
Incidence *incidence = currentSelection();
if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
if ( incidence ) {
cancelIncidence(incidence);
}
}
void CalendarView::cancelIncidence(Incidence * inc )
{
inc->setCancelled( ! inc->cancelled() );
changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
updateView();
}
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 7166a01..4111c5d 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -555,152 +555,163 @@ bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool a
tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
} else
tempText +=((Todo*)ev)->dtDueTimeStr();
mTodos.append( ev );
}
}
}
tempText += "</b></td><td>";
bool needClose = false;
if ( ev->cancelled() ) {
tempText += "<font color=\"#F00000\">[c";
needClose =true;
}
if ( ev->isAlarmEnabled() ) {
if ( !needClose)
tempText +="[";
tempText += "a";
needClose =true;
}
if ( ev->description().length() > 0 ) {
if ( !needClose)
tempText +="[";
tempText += "i";
needClose =true;
}
if ( ev->recurrence()->doesRecur() ) {
if ( !needClose)
tempText +="[";
tempText += "r";
needClose =true;
}
if ( needClose ) {
tempText += "] ";
}
if ( ev->cancelled() )
tempText += "</font>";
tempText += "<a ";
if (ev->type()=="Event") tempText += "href=\"event:";
if (ev->type()=="Todo") tempText += "href=\"todo:";
tempText += ev->uid() + "\">";
if ( ev->summary().length() > 0 )
tempText += ev->summary();
else
tempText += i18n("-no summary-");
+ if ( ev->categories().contains( i18n("Birthday") ) || ev->categories().contains( i18n("Anniversary") ) ) {
+ noc = ev->getNextOccurence( cdt, &ok );
+ if ( ok ) {
+ int years = noc.date().year() - ev->dtStart().date().year();
+ tempText += i18n(" (%1 y.)"). arg( years );
+ }
+ }
+
tempText += "</a>";
if ( KOPrefs::instance()->mWNViewShowLocation )
if ( !ev->location().isEmpty() )
tempText += " ("+ev->location() +")";
if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents)
tempText += " ["+ev->relatedTo()->summary() +"]";
tempText += "</td></tr>\n";
mText += tempText;
return true;
}
bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
{
if ( mTodos.find( ev ) != mTodos.end() ) return false;
mTodos.append( ev );
if ( !isSub )
mText += "<p>";
else
mText += "<li>";
mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] ";
mText += ind;
bool needClose = false;
if ( ev->cancelled() ) {
mText += "<font color=\"#F00000\">[c";
needClose =true;
}
if ( ev->isAlarmEnabled() ) {
if ( !needClose)
mText +="[";
mText += "a";
needClose =true;
}
if ( ev->description().length() > 0 ) {
if ( !needClose)
mText +="[";
mText += "i";
needClose =true;
}
// if ( ev->recurrence()->doesRecur() ) {
// if ( !needClose)
// mText +="(";
// mText += "r";
// needClose =true;
// }
if ( needClose )
mText += "] ";
if ( ev->cancelled() )
mText += "</font>";
mText += "<a href=\"todo:" + ev->uid() + "\">";
+ if ( ev->summary().length() > 0 )
mText += ev->summary();
+ else
+ mText += i18n("-no summary-");
mText += "</a>";
if ( ((Todo*)ev)->hasDueDate () ) {
QString year = "";
int ye = ((Todo*)ev)->dtDue().date().year();
if ( QDateTime::currentDateTime().date().year() != ye )
year = QString::number( ye );
QString dfs = KGlobal::locale()->dateFormatShort();
KGlobal::locale()->setDateFormatShort("%d.%b");
mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>";
KGlobal::locale()->setDateFormatShort(dfs);
}
if ( KOPrefs::instance()->mWNViewShowLocation )
if ( !ev->location().isEmpty() )
mText += " ("+ev->location() +")";
if ( !isSub ) {
if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
mText += " ["+ev->relatedTo()->summary() +"]";
mText += "</p>\n";
}
else {
ind += "-";
mText += "</li>\n";
}
QPtrList<Incidence> Relations = ev->relations();
Incidence *to;
for (to=Relations.first();to;to=Relations.next()) {
if (!((Todo*)to)->isCompleted())
appendTodo( to, ind , true );
}
return true;
}
/*
void KOWhatsNextView::createEventViewer()
{
if (!mEventViewer) {
mEventViewer = new KOEventViewerDialog(this);
}
}
*/
void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
{
mEventViewer = v;
}
// TODO: Create this function in CalendarView and remove it from here