-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 2 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 22 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 6 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 4 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 6 | ||||
-rw-r--r-- | korganizer/kotodoeditor.cpp | 1 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 4 | ||||
-rw-r--r-- | libkcal/event.cpp | 1 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 10 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 53 | ||||
-rw-r--r-- | libkcal/incidence.h | 5 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 4 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 4 | ||||
-rw-r--r-- | libkcal/vcalformat.h | 2 |
18 files changed, 87 insertions, 47 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a76f2ed..a9d42f0 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -3758,9 +3758,9 @@ void CalendarView::deleteEvent(Event *anEvent) KNotifyClient::beep(); return; } - if (anEvent->recurrence()->doesRecur()) { + if (anEvent->doesRecur()) { QDate itemDate = mViewManager->currentSelectionDate(); int km; if (!itemDate.isValid()) { //kdDebug() << "Date Not Valid" << endl; diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 0dd5ef5..c738f7e 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -578,9 +578,9 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) emit signalClearSelection(); slotClearSelection(); selectItem(mActionItem); Incidence *incidence = mActionItem->incidence(); - if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { + if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { mActionItem = 0; } else { startItemAction(viewportPos); } @@ -998,9 +998,9 @@ void KOAgenda::endItemAction() KOAgendaItem *placeItem = mActionItem->firstMultiItem(); if ( !placeItem ) { placeItem = mActionItem; } - if ( placeItem->incidence()->recurrence()->doesRecur() ) { + if ( placeItem->incidence()->doesRecur() ) { Incidence* oldInc = placeItem->incidence(); placeItem->recreateIncidence(); emit addToCalSignal(placeItem->incidence(), oldInc ); } diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 303a92a..49ad9b8 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -233,9 +233,9 @@ bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) ++xOff; else ++yOff; } - if (mIncidence->recurrence()->doesRecur()) { + if (mIncidence->doesRecur()) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); if ( horLayout ) ++xOff; else diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index a01323a..04f30bb 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -1200,9 +1200,9 @@ void KOAgendaView::fillAgenda() // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; if (event->doesFloat()) { - if (event->recurrence()->doesRecur()) { + if (event->doesRecur()) { if (event->isMultiDay() ) { endX = endX - beginX;// endX is now number of days if ( event->recursOn( currentDate ) ) { endX += curCol; diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index ec1154a..057df0d 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -452,9 +452,9 @@ void KODayMatrix::updateViewTimed() mHolidays.clear(); QDate mStartDate = days[0]; QDate endDate = mStartDate.addDays( timeSpan ); for( event = events.first(); event; event = events.next() ) { // for event - ushort recurType = event->recurrence()->doesRecur(); + ushort recurType = event->doesRecur(); if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { continue; } diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index de4e4f7..89504db 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp @@ -896,18 +896,19 @@ void KOEditorRecurrence::readEvent(Incidence *event) int count = 0; int month = 0; setDateTimes( event->dtStart(), dtEnd ); - Recurrence *r = event->recurrence(); - int f = r->frequency(); - int recurs = r->doesRecur(); + + int recurs = event->doesRecur(); mEnabledCheck->setChecked( recurs ); setEnabled( recurs ); int recurrenceType = RecurrenceChooser::Weekly; - + if ( recurs ) { + Recurrence *r = event->recurrence(); + int f = r->frequency(); switch ( recurs ) { case Recurrence::rNone: setDefaults( event->dtStart(), dtEnd ); break; @@ -983,15 +984,16 @@ void KOEditorRecurrence::readEvent(Incidence *event) default: setDefaults( event->dtStart(), dtEnd ); break; } - + } mRecurrenceChooser->setType( recurrenceType ); showCurrentRule( recurrenceType ); mRecurrenceRange->setDateTimes( event->dtStart() ); - if ( r->doesRecur() ) { + if ( event->doesRecur() ) { + Recurrence *r = event->recurrence(); mRecurrenceRange->setDuration( r->duration() ); if ( r->duration() == 0 ) { if ( r->endDate() < event->dtStart().date() ) @@ -1006,14 +1008,18 @@ void KOEditorRecurrence::readEvent(Incidence *event) } void KOEditorRecurrence::writeEvent( Incidence *event ) { + + + if ( !mEnabledCheck->isChecked() ) { + if ( event->doesRecur() ) + event->recurrence()->unsetRecurs(); + } else { Recurrence *r = event->recurrence(); // clear out any old settings; r->unsetRecurs(); - - if ( mEnabledCheck->isChecked() ) { int duration = mRecurrenceRange->duration(); QDate endDate; if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index a690ab1..db695f5 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp @@ -346,11 +346,11 @@ void KOEventViewer::appendEvent(Event *event, int mode ) if (!event->location().isEmpty()) { addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); mMailSubject += i18n(" at ") + event->location(); } - if (event->recurrence()->doesRecur()) { + if (event->doesRecur()) { - QString recurText = event->recurrence()->recurrenceText(); + QString recurText = event->recurrenceText(); addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); bool ok; QDate start = QDate::currentDate(); QDateTime next; @@ -480,9 +480,9 @@ void KOEventViewer::appendTodo(Todo *event, int mode ) } - if (event->recurrence()->doesRecur()) { + if (event->doesRecur()) { QString recurText = event->recurrence()->recurrenceText(); addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index d25f671..e7a5e0e 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -132,9 +132,9 @@ bool ListItemVisitor::visit(Event *e) mItem->setText(5,e->alarms().first()->offsetText() ); } else { mItem->setText(5, i18n("No")); } - mItem->setText(6, e->recurrence()->recurrenceText()); + mItem->setText(6, e->recurrenceText()); if( ! e->doesRecur() ) mItem->setSortKey( 6, "-" ); mItem->setText(7,"---"); mItem->setText(8,"---"); @@ -183,9 +183,9 @@ bool ListItemVisitor::visit(Todo *t) mItem->setText(5,t->alarms().first()->offsetText() ); } else { mItem->setText(5, i18n("No")); } - mItem->setText(6, t->recurrence()->recurrenceText()); + mItem->setText(6, t->recurrenceText()); if( ! t->doesRecur() ) mItem->setSortKey( 6, "-" ); if (t->hasDueDate()) { mItem->setText(7,t->dtDueDateStr()); diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 498d9b0..eea9a4d 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -786,9 +786,9 @@ int MonthViewCell::insertEvent(Event *event) pal = mStandardPalette ; } pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); item->setPalette( pal ); - item->setRecur( event->recurrence()->doesRecur() ); + item->setRecur( event->doesRecur() ); item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); item->setMoreInfo( event->description().length() > 0 ); #ifdef DESKTOP_VERSION Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, @@ -877,9 +877,9 @@ void MonthViewCell::insertTodo(Todo *todo) pal = mStandardPalette ; } pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); item->setPalette( pal ); - item->setRecur( todo->recurrence()->doesRecur() ); + item->setRecur( todo->doesRecur() ); item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); item->setMoreInfo( todo->description().length() > 0 ); insertItem( item , count()); #ifdef DESKTOP_VERSION @@ -1104,8 +1104,10 @@ void MonthViewCell::contextMenu( QListBoxItem *item ) if ( !item ) { mMonthView->showContextMenu( 0 ); return; } + //selection( item ); + //qApp->processEvents(); MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); Incidence *incidence = eventItem->incidence(); if ( incidence ) mMonthView->showContextMenu( incidence ); } diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 100a81b..682f83b 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp @@ -376,8 +376,9 @@ void KOTodoEditor::writeTodo(Todo *event) event->setHasRecurrenceID( false ); } } else { event->setHasRecurrenceID( false ); + if ( event->doesRecur() ) event->recurrence()->unsetRecurs(); } } diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index fafcb58..f88403c 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp @@ -506,9 +506,9 @@ bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool a } else { if (!ev->doesFloat()) { Event *event = static_cast<Event *>(ev); QDateTime st,end; - if ( event->recurrence()->doesRecur() ) { + if ( event->doesRecur() ) { QDate recDate= mEventDate; int days = event->dtStart().date().daysTo (event->dtEnd().date() ); while ( ! event->recursOn( recDate ) ) { recDate = recDate.addDays( -1 ); @@ -621,9 +621,9 @@ bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool a tempText +="["; tempText += "i"; needClose =true; } - if ( ev->recurrence()->doesRecur() ) { + if ( ev->doesRecur() ) { if ( !needClose) tempText +="["; tempText += "r"; needClose =true; diff --git a/libkcal/event.cpp b/libkcal/event.cpp index ad66639..0766fd9 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp @@ -172,8 +172,9 @@ void Event::setDuration(int seconds) Incidence::setDuration(seconds); } bool Event::matchTime(QDateTime*startDT, QDateTime* endDT) { + if ( cancelled() ) return false; if ( ! doesRecur() ) { if ( doesFloat() ) { if ( mDtEnd.addDays( 1 ) < *startDT) return false; diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 4794bc9..f349681 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp @@ -371,21 +371,18 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) incidence->relatedToUid().utf8())); } // recurrence rule stuff - Recurrence *recur = incidence->recurrence(); - if (recur->doesRecur()) { - - icalcomponent_add_property(parent,writeRecurrenceRule(recur)); - } - + if (incidence->doesRecur()) { + icalcomponent_add_property(parent,writeRecurrenceRule(incidence->recurrence())); // recurrence excpetion dates DateList dateList = incidence->exDates(); DateList::ConstIterator exIt; for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { icalcomponent_add_property(parent,icalproperty_new_exdate( writeICalDate(*exIt))); } + } // attachments QPtrList<Attachment> attachments = incidence->attachments(); for (Attachment *at = attachments.first(); at; at = attachments.next()) @@ -1294,8 +1291,9 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) incidence->setIDStr(kp); } // Cancel backwards compatibility mode for subsequent changes by the application + if ( readrec ) incidence->recurrence()->setCompatVersion(); // add categories incidence->setCategories(categories); diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index e4bcc5e..4643a3a 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -32,9 +32,9 @@ using namespace KCal; Incidence::Incidence() : IncidenceBase(), mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) { - mRecurrence = new Recurrence(this); + mRecurrence = 0;//new Recurrence(this); mCancelled = false; recreate(); mHasStartDate = true; mAlarms.setAutoDelete(true); @@ -77,9 +77,12 @@ Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) } mAlarms.setAutoDelete(true); mHasRecurrenceID = i.mHasRecurrenceID; mRecurrenceID = i.mRecurrenceID; + if ( i.mRecurrence ) mRecurrence = new Recurrence( *(i.mRecurrence), this ); + else + mRecurrence = 0; mHoliday = i.mHoliday ; mBirthday = i.mBirthday; mAnniversary = i.mAnniversary; } @@ -92,8 +95,9 @@ Incidence::~Incidence() for (ev=Relations.first();ev;ev=Relations.next()) { if (ev->relatedTo() == this) ev->setRelatedTo(0); } if (relatedTo()) relatedTo()->removeRelation(this); + if ( mRecurrence ) delete mRecurrence; } @@ -207,12 +211,26 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) } } else { return false; } - if (!( *i1.recurrence() == *i2.recurrence()) ) { - qDebug("recurrence is NOT equal "); + if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) { + if (!( *i1.mRecurrence == *i2.mRecurrence) ) { + //qDebug("recurrence is NOT equal "); + return false; + } + } else { + // one ( or both ) recurrence is 0 + if ( i1.mRecurrence == 0 ) { + if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone ) + return false; + } else { + // i1.mRecurrence != 0 + // i2.mRecurrence == 0 + if ( i1.mRecurrence->doesRecur() != Recurrence::rNone ) return false; } + } + return // i1.created() == i2.created() && stringCompare( i1.description(), i2.description() ) && stringCompare( i1.summary(), i2.summary() ) && @@ -278,9 +296,10 @@ void Incidence::cloneRelations( Incidence * newInc ) } void Incidence::setReadOnly( bool readOnly ) { IncidenceBase::setReadOnly( readOnly ); - recurrence()->setRecurReadOnly( readOnly); + if ( mRecurrence ) + mRecurrence->setRecurReadOnly( readOnly); } void Incidence::setLastModifiedSubInvalid() { mLastModifiedSub = QDateTime(); @@ -329,9 +348,11 @@ int Incidence::revision() const void Incidence::setDtStart(const QDateTime &dtStart) { QDateTime dt = getEvenTime(dtStart); - recurrence()->setRecurStart( dt); + + if ( mRecurrence ) + mRecurrence->setRecurStart( dt); IncidenceBase::setDtStart( dt ); } void Incidence::setDescription(const QString &description) @@ -503,17 +524,16 @@ void Incidence::removeRelation(Incidence *event) } bool Incidence::recursOn(const QDate &qd) const { - if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; + if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; else return false; } void Incidence::setExDates(const DateList &exDates) { if (mReadOnly) return; mExDates = exDates; - recurrence()->setRecurExDatesCount(mExDates.count()); updated(); } @@ -697,15 +717,21 @@ bool Incidence::isAlarmEnabled() const return true; } return false; } - -Recurrence *Incidence::recurrence() const +#include <stdlib.h> +Recurrence *Incidence::recurrence() { + if ( ! mRecurrence ) { + mRecurrence = new Recurrence(this); + qDebug("creating new recurence "); + //abort(); + } return mRecurrence; } void Incidence::setRecurrence( Recurrence * r) { + if ( mRecurrence ) delete mRecurrence; mRecurrence = r; } @@ -719,8 +745,13 @@ void Incidence::setLocation(const QString &location) QString Incidence::location() const { return mLocation; } +QString Incidence::recurrenceText() const +{ + if ( mRecurrence ) return mRecurrence->recurrenceText(); + return i18n("No"); +} ushort Incidence::doesRecur() const { if ( mRecurrence ) return mRecurrence->doesRecur(); @@ -732,14 +763,14 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const QDateTime incidenceStart = dt; *ok = false; if ( doesRecur() ) { bool last; - recurrence()->getPreviousDateTime( incidenceStart , &last ); + mRecurrence->getPreviousDateTime( incidenceStart , &last ); int count = 0; if ( !last ) { while ( !last ) { ++count; - incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); + incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); if ( recursOn( incidenceStart.date() ) ) { last = true; // exit while llop } else { if ( last ) { // no alarm on last recurrence diff --git a/libkcal/incidence.h b/libkcal/incidence.h index d4af9f0..8519f01 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h @@ -248,9 +248,9 @@ class Incidence : public IncidenceBase /** Return the recurrence rule associated with this incidence. If there is none, returns an appropriate (non-0) object. */ - Recurrence *recurrence() const; + Recurrence *recurrence(); void setRecurrence(Recurrence * r); /** Forward to Recurrence::doesRecur(). */ @@ -277,11 +277,13 @@ class Incidence : public IncidenceBase bool isHoliday() const; bool isBirthday() const; bool isAnniversary() const; QDateTime lastModifiedSub(); + QString recurrenceText() const; void setLastModifiedSubInvalid(); + Recurrence *mRecurrence; protected: QPtrList<Alarm> mAlarms; QPtrList<Incidence> mRelations; QDateTime mRecurrenceID; @@ -308,9 +310,8 @@ protected: int mSecrecy; int mPriority; // 1 = highest, 2 = less, etc. //QPtrList<Alarm> mAlarms; - Recurrence *mRecurrence; QString mLocation; }; diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 9359fad..f8f40f1 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp @@ -104,9 +104,9 @@ void KIncidenceFormatter::setEvent(Event *event) addTag("b",i18n("Location: ")); mText.append(deTag(event->location())+"<br>"); } - if (event->recurrence()->doesRecur()) { + if (event->doesRecur()) { QString recurText = event->recurrence()->recurrenceText(); addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); @@ -215,9 +215,9 @@ void KIncidenceFormatter::setTodo(Todo *event ) mText += "</font>"; } - if (event->recurrence()->doesRecur()) { + if (event->doesRecur()) { QString recurText = event->recurrence()->recurrenceText(); addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); } diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 8efc1ea..2e19740 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp @@ -391,9 +391,9 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent) return vtodo; } -VObject* VCalFormat::eventToVEvent(const Event *anEvent) +VObject* VCalFormat::eventToVEvent(Event *anEvent) { VObject *vevent; QString tmpStr; @@ -458,9 +458,9 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent) } } // recurrence rule stuff - if (anEvent->recurrence()->doesRecur()) { + if (anEvent->doesRecur()) { // some more variables QPtrList<Recurrence::rMonthPos> tmpPositions; QPtrList<int> tmpDays; int *tmpDay; diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h index c7df017..6dae3d2 100644 --- a/libkcal/vcalformat.h +++ b/libkcal/vcalformat.h @@ -73,9 +73,9 @@ class VCalFormat : public CalFormat { Event *VEventToEvent(VObject *vevent); /** translate a Event into a VTodo-type VObject and return pointer */ VObject *eventToVTodo(const Todo *anEvent); /** translate a Event into a VObject and returns a pointer to it. */ - VObject* eventToVEvent(const Event *anEvent); + VObject* eventToVEvent(Event *anEvent); /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ QString qDateToISO(const QDate &); /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ |