From 793d117812b4da36c9c11d90cccba347cbc6e208 Mon Sep 17 00:00:00 2001 From: zautrix Date: Wed, 08 Jun 2005 10:34:22 +0000 Subject: changed incidence type to a faster access method --- diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 720ad78..7c7466b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -170,13 +170,13 @@ MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrListgetNextOccurence( start, &ok ); if ( !ok ) continue; - if ( inc->type() == "Event" ) { + if ( inc->typeID() == eventID ) { tempText += "href=\"event:"; - } else if ( inc->type() == "Todo" ) { + } else if ( inc->typeID() == todoID ) { tempText += "href=\"todo:"; } tempText += inc->uid() + "\">"; - if ( inc->type() == "Todo" ) + if ( inc->typeID() == todoID ) tempText += i18n("Todo: "); if ( inc->summary().length() > 0 ) tempText += inc->summary(); @@ -973,12 +973,12 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b //full = true; //debug only if ( full ) { bool equ = false; - if ( local->type() == "Event" ) { + if ( local->typeID() == eventID ) { equ = (*((Event*) local) == *((Event*) remote)); } - else if ( local->type() =="Todo" ) + else if ( local->typeID() == todoID ) equ = (*((Todo*) local) == (*(Todo*) remote)); - else if ( local->type() =="Journal" ) + else if ( local->typeID() == journalID ) equ = (*((Journal*) local) == *((Journal*) remote)); if ( equ ) { //qDebug("equal "); @@ -1099,7 +1099,7 @@ void CalendarView::checkExternSyncEvent( QPtrList lastSync , Incidence* t //qDebug(" lastSync.count() == 0"); return; } - if ( toDelete->type() == "Journal" ) + if ( toDelete->typeID() == journalID ) return; Event* eve = lastSync.first(); @@ -1109,7 +1109,7 @@ void CalendarView::checkExternSyncEvent( QPtrList lastSync , Incidence* t if ( !id.isEmpty() ) { QString des = eve->description(); QString pref = "e"; - if ( toDelete->type() == "Todo" ) + if ( toDelete->typeID() == todoID ) pref = "t"; des += pref+ id + ","; eve->setReadOnly( false ); @@ -1286,7 +1286,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { QString des = eventLSync->description(); QString pref = "e"; - if ( inR->type() == "Todo" ) + if ( inR->typeID() == todoID ) pref = "t"; if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); @@ -1343,7 +1343,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int bool skipIncidence = false; if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) skipIncidence = true; if ( !skipIncidence ) { inR = remote->incidence( uid ); @@ -1399,14 +1399,14 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); while ( inR ) { - if ( inR->type() == "Todo" ) { + if ( inR->typeID() == todoID ) { Todo * t = (Todo*)inR; if ( t->hasDueDate() ) dt = t->dtDue(); else dt = cur.addSecs( 62 ); } - else if (inR->type() == "Event" ) { + else if (inR->typeID() == eventID ) { bool ok; dt = inR->getNextOccurence( cur, &ok ); if ( !ok ) @@ -2477,7 +2477,7 @@ void CalendarView::edit_cut() Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { - if ( incidence && incidence->type() == "Event" ) { + if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast(incidence); } } @@ -2498,7 +2498,7 @@ void CalendarView::edit_copy() Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { - if ( incidence && incidence->type() == "Event" ) { + if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast(incidence); } } @@ -2550,7 +2550,7 @@ void CalendarView::slotSelectPickerDate( QDate d) if ( mDatePickerMode == 1 ) { mNavigator->slotDaySelect( d ); } else if ( mDatePickerMode == 2 ) { - if ( mMoveIncidence->type() == "Todo" ) { + if ( mMoveIncidence->typeID() == todoID ) { Todo * to = (Todo *) mMoveIncidence; QTime tim; int len = 0; @@ -2581,7 +2581,7 @@ void CalendarView::slotSelectPickerDate( QDate d) // PENDING implement this Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); mCalendar()->addIncidence( newInc ); - if ( mMoveIncidence->type() == "Todo" ) + if ( mMoveIncidence->typeID() == todoID ) emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); else emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); @@ -2767,7 +2767,7 @@ void CalendarView::moveIncidence(Incidence * inc ) mDatePickerMode = 2; mMoveIncidence = inc ; QDate da; - if ( mMoveIncidence->type() == "Todo" ) { + if ( mMoveIncidence->typeID() == todoID ) { Todo * to = (Todo *) mMoveIncidence; if ( to->hasDueDate() ) da = to->dtDue().date(); @@ -2900,7 +2900,7 @@ void CalendarView::cloneIncidence(Incidence * orgInc ) Incidence * newInc = orgInc->clone(); newInc->recreate(); - if ( newInc->type() == "Todo" ) { + if ( newInc->typeID() == todoID ) { Todo* t = (Todo*) newInc; bool cloneSub = false; if ( orgInc->relations().count() ) { @@ -3164,7 +3164,7 @@ void CalendarView::appointment_show() Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { - if ( incidence && incidence->type() == "Event" ) { + if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast(incidence); } } @@ -3184,7 +3184,7 @@ void CalendarView::appointment_edit() Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { - if ( incidence && incidence->type() == "Event" ) { + if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast(incidence); } } @@ -3204,7 +3204,7 @@ void CalendarView::appointment_delete() Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { - if ( incidence && incidence->type() == "Event" ) { + if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast(incidence); } } @@ -3405,7 +3405,7 @@ void CalendarView::action_mail() CalendarLocal cal_tmp; Event *event = 0; Event *ev = 0; - if ( incidence && incidence->type() == "Event" ) { + if ( incidence && incidence->typeID() == eventID ) { event = static_cast(incidence); ev = new Event(*event); cal_tmp.addEvent(ev); @@ -3450,10 +3450,10 @@ void CalendarView::schedule_publish(Incidence *incidence) incidence = mTodoList->selectedIncidences().first(); } } - if ( incidence && incidence->type() == "Event" ) { + if ( incidence && incidence->typeID() == eventID ) { event = static_cast(incidence); } else { - if ( incidence && incidence->type() == "Todo" ) { + if ( incidence && incidence->typeID() == todoID ) { todo = static_cast(incidence); } } @@ -3565,10 +3565,10 @@ void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) incidence = mTodoList->selectedIncidences().first(); } } - if ( incidence && incidence->type() == "Event" ) { + if ( incidence && incidence->typeID() == eventID ) { event = static_cast(incidence); } - if ( incidence && incidence->type() == "Todo" ) { + if ( incidence && incidence->typeID() == todoID ) { todo = static_cast(incidence); } @@ -3772,7 +3772,7 @@ void CalendarView::processIncidenceSelection( Incidence *incidence ) emit incidenceSelected( mSelectedIncidence ); - if ( incidence && incidence->type() == "Event" ) { + if ( incidence && incidence->typeID() == eventID ) { Event *event = static_cast( incidence ); if ( event->organizer() == KOPrefs::instance()->email() ) { emit organizerEventsSelected( true ); @@ -3787,7 +3787,7 @@ void CalendarView::processIncidenceSelection( Incidence *incidence ) } return; } else { - if ( incidence && incidence->type() == "Todo" ) { + if ( incidence && incidence->typeID() == todoID ) { emit todoSelected( true ); Todo *event = static_cast( incidence ); if ( event->organizer() == KOPrefs::instance()->email() ) { @@ -3810,7 +3810,7 @@ void CalendarView::processIncidenceSelection( Incidence *incidence ) return; } - /* if ( incidence && incidence->type() == "Todo" ) { + /* if ( incidence && incidence->typeID() == todoID ) { emit todoSelected( true ); } else { emit todoSelected( false ); @@ -4065,12 +4065,12 @@ void CalendarView::calendarModified( bool modified, Calendar * ) Todo *CalendarView::selectedTodo() { Incidence *incidence = currentSelection(); - if ( incidence && incidence->type() == "Todo" ) { + if ( incidence && incidence->typeID() == todoID ) { return static_cast( incidence ); } incidence = mTodoList->selectedIncidences().first(); - if ( incidence && incidence->type() == "Todo" ) { + if ( incidence && incidence->typeID() == todoID ) { return static_cast( incidence ); } diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 2a2acb1..fc213d8 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -753,7 +753,7 @@ void KOAgenda::startItemAction(QPoint viewportPos) } } else { int gridDistanceY = (y - gy * mGridSpacingY); - bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); + bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); if (allowResize && gridDistanceY < mResizeBorderWidth && mActionItem->cellYTop() == mCurrentCellY && !mActionItem->firstMultiItem()) { @@ -912,7 +912,7 @@ void KOAgenda::endItemAction() QPtrList oldconflictItems ;//= placeItem->conflictItems(); KOAgendaItem *item; - if ( placeItem->incidence()->type() == "Todo" ) { + if ( placeItem->incidence()->typeID() == todoID ) { mSelectedItem = 0; //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); modifiedItem->mLastMoveXPos = mCurrentCellX; diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index df2e478..5a3c4d2 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -106,7 +106,7 @@ void KOAgendaItem::init ( Incidence *incidence, QDate qd ) mLastMultiItem = 0; computeText(); - if ( (incidence->type() == "Todo") && + if ( (incidence->typeID() == todoID ) && ( !((static_cast(incidence))->isCompleted()) && ((static_cast(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { if ( (static_cast(incidence))->dtDue() < QDateTime::currentDateTime().date()) @@ -118,13 +118,13 @@ void KOAgendaItem::init ( Incidence *incidence, QDate qd ) QStringList categories = mIncidence->categories(); QString cat = categories.first(); if (cat.isEmpty()) { - if ( (incidence->type() == "Todo") &&((static_cast(incidence))->isCompleted()) ) + if ( (incidence->typeID() == todoID ) &&((static_cast(incidence))->isCompleted()) ) mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; else mBackgroundColor =KOPrefs::instance()->mEventColor; } else { mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); - if ( (incidence->type() == "Todo") &&((static_cast(incidence))->isCompleted()) ) { + if ( (incidence->typeID() == todoID ) &&((static_cast(incidence))->isCompleted()) ) { if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; } @@ -359,7 +359,7 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint ) paint->fillRect ( x, yy, w, h, mBackgroundColor ); static const QPixmap completedPxmp = SmallIcon("greenhook16"); static const QPixmap overduePxmp = SmallIcon("redcross16"); - if ( mIncidence->type() == "Todo" ) { + if ( mIncidence->typeID() == todoID ) { Todo* tempTodo = static_cast(mIncidence); int xx = pos().x()+(width()-completedPxmp.width()-3 ); int yyy = yy+3; @@ -540,7 +540,7 @@ void KOAgendaItem::paintEvent ( QPaintEvent *e ) void KOAgendaItem::computeText() { mDisplayedText = mIncidence->summary(); - if ( (mIncidence->type() == "Todo") ) { + if ( (mIncidence->typeID() == todoID ) ) { if ( static_cast(mIncidence)->hasDueDate() ) { if ( static_cast(mIncidence)->dtDue().date() < QDate::currentDate() ) mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast(mIncidence))->dtDue().date(), true)+")"; @@ -572,7 +572,7 @@ void KOAgendaItem::computeText() #ifdef DESKTOP_VERSION QString tipText = mIncidence->summary(); if ( !mIncidence->doesFloat() ) { - if ( mIncidence->type() == "Event" ) { + if ( mIncidence->typeID() == eventID ) { if ( (static_cast(mIncidence))->isMultiDay() ) { tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); tipText += "\n"+i18n("To: ")+(static_cast(mIncidence))->dtEndStr(); @@ -582,13 +582,13 @@ void KOAgendaItem::computeText() tipText += " - "+(static_cast(mIncidence))->dtEndTimeStr(); } } - else if ( mIncidence->type() == "Todo" ) { + else if ( mIncidence->typeID() == todoID ) { if (mIncidence->hasStartDate()) tipText += "\n"+i18n("Start: ")+ (static_cast(mIncidence))->dtStartStr(); if (((Todo*)mIncidence)->hasDueDate()) tipText += "\n"+i18n("Due: ")+ (static_cast(mIncidence))->dtDueStr(); } - } else if ( mIncidence->type() == "Todo" ) { + } else if ( mIncidence->typeID() == todoID ) { if (mIncidence->hasStartDate()) tipText += "\n"+i18n("Start: ")+ (static_cast(mIncidence))->dtStartDateStr(); if (((Todo*)mIncidence)->hasDueDate()) diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 7022e02..be51694 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -400,8 +400,8 @@ void KOListView::setAlarm() while ( qitem ) { if ( qitem->isSelected() ) { Incidence* inc = ((KOListViewItem *) qitem)->data(); - if ( inc->type() != "Journal" ) { - if ( inc->type() == "Todo" ) { + if ( inc->typeID() != journalID ) { + if ( inc->typeID() == todoID ) { if ( ((Todo*)inc)->hasDueDate() ) sel.append(((KOListViewItem *)qitem)); } else @@ -488,7 +488,7 @@ void KOListView::setCategories( bool removeOld ) if( item ) { Incidence* inc = item->data() ; bool setSub = false; - if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) { + if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) { int result = KMessageBox::warningYesNoCancel(this, i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), i18n("Todo has subtodos"), @@ -611,7 +611,7 @@ void KOListView::saveDescriptionToFile() Incidence *incidence = delSel.first(); icount = 0; while ( incidence ) { - if ( incidence->type() == "Journal" ) { + if ( incidence->typeID() == journalID ) { text += "\n************************************\n"; text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); @@ -621,7 +621,7 @@ void KOListView::saveDescriptionToFile() } else { if ( !incidence->description().isEmpty() ) { text += "\n************************************\n"; - if ( incidence->type() == "Todo" ) + if ( incidence->typeID() == todoID ) text += i18n("To-Do: "); text += incidence->summary(); if ( incidence->hasStartDate() ) @@ -669,7 +669,7 @@ void KOListView::writeToFile( bool iCal ) while ( item ) { if ( item->isSelected() ) { if ( !journal ) - if ( ((KOListViewItem *)item)->data()->type() == "Journal") + if ( ((KOListViewItem *)item)->data()->typeID() == journalID ) journal = true; delSel.append(((KOListViewItem *)item)->data()); ++icount; diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 5aaf360..2602487 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -702,7 +702,7 @@ void KOTodoView::updateView() // qDebug("todo %s ", todo->summary().latin1()); Incidence *incidence = todo->relatedTo(); while ( incidence ) { - if ( incidence->type() == "Todo") { + if ( incidence->typeID() == todoID ) { //qDebug("related %s ",incidence->summary().latin1() ); if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { //qDebug("related not found "); @@ -844,7 +844,7 @@ QMap::ConstIterator pendingSubtodo = 0; Incidence *incidence = todo->relatedTo(); - if (incidence && incidence->type() == "Todo") { + if (incidence && incidence->typeID() == todoID ) { Todo *relatedTodo = static_cast(incidence); // kdDebug() << " has Related" << endl; diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 62d7ede..e8574a0 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp @@ -489,14 +489,14 @@ bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool a bool ok = true; if ( reply ) { noc = ev->getNextOccurence( cdt, &ok ); - if (! ok && ev->type() == "Event") + if (! ok && ev->typeID() == eventID) return false; } bool bDay = false; if ( ev->isBirthday() || ev->isAnniversary() ) bDay = true; tempText += ""; - if (ev->type()=="Event") { + if (ev->typeID() == eventID ) { if (reply) { if (!ev->doesFloat()) tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; @@ -620,8 +620,8 @@ bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool a if ( ev->cancelled() ) tempText += ""; tempText += "type()=="Event") tempText += "href=\"event:"; - if (ev->type()=="Todo") tempText += "href=\"todo:"; + if (ev->typeID() == eventID ) tempText += "href=\"event:"; + if (ev->typeID() == todoID ) tempText += "href=\"todo:"; tempText += ev->uid() + "\">"; if ( ev->summary().length() > 0 ) tempText += ev->summary(); @@ -631,7 +631,7 @@ bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool a noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); if ( ok ) { int years = 0; - if ( ev->type() =="Todo" ) { + if ( ev->typeID() == todoID ) { years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); } else years = noc.date().year() - ev->dtStart().date().year(); diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 53b65b2..481eab4 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1332,11 +1332,11 @@ void MainWindow::exportToPhone( int mode ) QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); while ( incidence ) { - if ( incidence->type() != "Journal" ) { + if ( incidence->typeID() != journalID ) { bool add = true; if ( inFuture ) { QDateTime dt; - if ( incidence->type() == "Todo" ) { + if ( incidence->typeID() == todoID ) { Todo * t = (Todo*)incidence; if ( t->hasDueDate() ) dt = t->dtDue(); @@ -1596,7 +1596,7 @@ void MainWindow::processIncidenceSelection( Incidence *incidence ) //KGlobal::locale()->formatDateTime(nextA, true); QString startString = ""; - if ( incidence->type() != "Todo" ) { + if ( incidence->typeID() != todoID ) { if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { if ( incidence->doesFloat() ) { startString += ": "+incidence->dtStartDateStr( true ); @@ -1634,13 +1634,13 @@ void MainWindow::processIncidenceSelection( Incidence *incidence ) enableIncidenceActions( true ); - if ( incidence->type() == "Event" ) { + if ( incidence->typeID() == eventID ) { mShowAction->setText( i18n("Show Event...") ); mEditAction->setText( i18n("Edit Event...") ); mDeleteAction->setText( i18n("Delete Event...") ); mNewSubTodoAction->setEnabled( false ); - } else if ( incidence->type() == "Todo" ) { + } else if ( incidence->typeID() == todoID ) { mShowAction->setText( i18n("Show Todo...") ); mEditAction->setText( i18n("Edit Todo...") ); mDeleteAction->setText( i18n("Delete Todo...") ); diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index ed39ddb..7e8e2c5 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp @@ -353,11 +353,11 @@ bool Calendar::addIncidence(Incidence *i) } void Calendar::deleteIncidence(Incidence *in) { - if ( in->type() == "Event" ) + if ( in->typeID() == eventID ) deleteEvent( (Event*) in ); - else if ( in->type() =="Todo" ) + else if ( in->typeID() == todoID ) deleteTodo( (Todo*) in); - else if ( in->type() =="Journal" ) + else if ( in->typeID() == journalID ) deleteJournal( (Journal*) in ); } diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index bc76c0b..fe74052 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -458,9 +458,7 @@ Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) { - kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " - << to.toString() << ")\n"; - + Alarm::List alarms; Event *e; @@ -488,8 +486,6 @@ void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; if ( alarm->enabled() ) { if ( alarm->time() >= from && alarm->time() <= to ) { - kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() - << "': " << alarm->time().toString() << endl; alarms.append( alarm ); } } diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp index c425dfc..20078a7 100644 --- a/libkcal/calfilter.cpp +++ b/libkcal/calfilter.cpp @@ -78,11 +78,11 @@ void CalFilter::apply(QPtrList *eventlist) } bool CalFilter::filterCalendarItem(Incidence *in) { - if ( in->type() == "Event" ) + if ( in->typeID() == eventID ) return filterEvent( (Event*) in ); - else if ( in->type() =="Todo" ) + else if ( in->typeID() == todoID ) return filterTodo( (Todo*) in); - else if ( in->type() =="Journal" ) + else if ( in->typeID () == journalID ) return filterJournal( (Journal*) in ); return false; } diff --git a/libkcal/event.h b/libkcal/event.h index 8729956..287d403 100644 --- a/libkcal/event.h +++ b/libkcal/event.h @@ -40,6 +40,7 @@ class Event : public Incidence ~Event(); QCString type() const { return "Event"; } + IncTypeID typeID() const { return eventID; } Incidence *clone(); QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; diff --git a/libkcal/freebusy.h b/libkcal/freebusy.h index 054feda..d741c72 100644 --- a/libkcal/freebusy.h +++ b/libkcal/freebusy.h @@ -48,6 +48,7 @@ class FreeBusy : public IncidenceBase ~FreeBusy(); QCString type() const { return "FreeBusy"; } + IncTypeID typeID() const { return freebusyID; } virtual QDateTime dtEnd() const; bool setDtEnd( const QDateTime &end ); diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp index 3a2aac6..d9fe40b 100644 --- a/libkcal/icalformat.cpp +++ b/libkcal/icalformat.cpp @@ -384,12 +384,12 @@ ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal, Incidence *existingIncidence = cal->event(incidence->uid()); if (existingIncidence) { // TODO: check, if cast is required, or if it can be done by virtual funcs. - if (existingIncidence->type() == "Todo") { + if (existingIncidence->typeID() == todoID ) { Todo *todo = static_cast(existingIncidence); icalcomponent_add_component(calendarComponent, mImpl->writeTodo(todo)); } - if (existingIncidence->type() == "Event") { + if (existingIncidence->typeID() == eventID ) { Event *event = static_cast(existingIncidence); icalcomponent_add_component(calendarComponent, mImpl->writeEvent(event)); diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 2405682..3e28714 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp @@ -2155,15 +2155,15 @@ icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence, icalcomponent_add_property(message,icalproperty_new_method(icalmethod)); // TODO: check, if dynamic cast is required - if(incidence->type() == "Todo") { + if(incidence->typeID() == todoID ) { Todo *todo = static_cast(incidence); icalcomponent_add_component(message,writeTodo(todo)); } - if(incidence->type() == "Event") { + if(incidence->typeID() == eventID ) { Event *event = static_cast(incidence); icalcomponent_add_component(message,writeEvent(event)); } - if(incidence->type() == "FreeBusy") { + if(incidence->typeID() == freebusyID) { FreeBusy *freebusy = static_cast(incidence); icalcomponent_add_component(message,writeFreeBusy(freebusy, method)); } diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 762103f..f446197 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -236,7 +236,7 @@ Incidence* Incidence::recreateCloneException( QDate d ) if ( doesRecur() ) { addExDate( d ); newInc->recurrence()->unsetRecurs(); - if ( type() == "Event") { + if ( typeID() == eventID ) { int len = dtStart().secsTo( ((Event*)this)->dtEnd()); QTime tim = dtStart().time(); newInc->setDtStart( QDateTime(d, tim) ); @@ -724,7 +724,7 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const if ( hasStartDate () ) { incidenceStart = dtStart(); } - if ( type() =="Todo" ) { + if ( typeID() == todoID ) { if ( ((Todo*)this)->hasDueDate() ) incidenceStart = ((Todo*)this)->dtDue(); } @@ -736,7 +736,7 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const QDateTime Incidence::dtStart() const { if ( doesRecur() ) { - if ( type() == "Todo" ) { + if ( typeID() == todoID ) { ((Todo*)this)->checkSetCompletedFalse(); } } diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index 8624786..05209e0 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h @@ -34,6 +34,7 @@ namespace KCal { typedef QValueList DateList; + enum IncTypeID { eventID,todoID,journalID,freebusyID }; /** This class provides the base class common to all calendar components. @@ -51,6 +52,7 @@ class IncidenceBase : public CustomProperties virtual ~IncidenceBase(); virtual QCString type() const = 0; + virtual IncTypeID typeID() const = 0; /** Set the unique id for the event */ void setUid(const QString &); diff --git a/libkcal/journal.h b/libkcal/journal.h index 2c1d7ea..1cd0a22 100644 --- a/libkcal/journal.h +++ b/libkcal/journal.h @@ -37,6 +37,7 @@ class Journal : public Incidence ~Journal(); QCString type() const { return "Journal"; } + IncTypeID typeID() const { return journalID; } Incidence *clone(); QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 7d61b7f..d1ace4f 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp @@ -21,9 +21,9 @@ QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bo mCreated = created ; mModified = modified; mText = ""; - if ( inc->type() == "Event" ) + if ( inc->typeID() == eventID ) setEvent((Event *) inc ); - else if ( inc->type() == "Todo" ) + else if ( inc->typeID() == todoID ) setTodo((Todo *) inc ); return mText; } diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 38ba2c7..c97a61e 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -130,7 +130,7 @@ void Todo::saveParents() if (!relatedTo() ) return; Incidence * inc = relatedTo(); - if ( inc->type() != "Todo" ) + if ( inc->typeID() != todoID ) return; Todo* to = (Todo*)inc; bool saveTodo = false; @@ -564,8 +564,9 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_d void Todo::checkSetCompletedFalse() { - if ( !hasRecurrenceID() ) { + if ( !mHasRecurrenceID ) { qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); + return; } // qDebug("Todo::checkSetCompletedFalse()"); //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); diff --git a/libkcal/todo.h b/libkcal/todo.h index ab8fdf1..501c2ba 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h @@ -41,6 +41,7 @@ namespace KCal { ~Todo(); typedef ListBase List; QCString type() const { return "Todo"; } + IncTypeID typeID() const { return todoID; } /** Return an exact copy of this todo. */ Incidence *clone(); -- cgit v0.9.0.2