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 --- (limited to 'korganizer/calendarview.cpp') 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 ); } -- cgit v0.9.0.2