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') 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...") ); -- cgit v0.9.0.2