-rw-r--r-- | korganizer/koagendaview.cpp | 3 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 4 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 3 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 8 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 32 | ||||
-rw-r--r-- | libkcal/incidence.h | 5 |
6 files changed, 44 insertions, 11 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index e029fdb..eb3a6cd 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -1409,26 +1409,25 @@ void KOAgendaView::setHolidayMasks() mHolidayMask.resize(mSelectedDates.count()); uint i; for(i=0;i<mSelectedDates.count();++i) { QDate date = mSelectedDates[i]; bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); bool showHoliday = false; if ( KOPrefs::instance()->mExcludeHolidays ) { QPtrList<Event> events = calendar()->events( date, true ); Event *event; for( event = events.first(); event; event = events.next() ) { - if ( event->categories().contains("Holiday") || - event->categories().contains(i18n("Holiday"))) { + if ( event->isHoliday()) { showHoliday = true; break; } } } #ifndef KORG_NOPLUGINS bool showHoliday = KOPrefs::instance()->mExcludeHolidays && !KOCore::self()->holiday(date).isEmpty(); #endif bool showDay = showSaturday || showSunday || showHoliday; diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index d7a4112..36cd990 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -339,32 +339,32 @@ void KODayMatrix::updateViewTimed() // if events are set for the day then remember to draw it bold QPtrList<Event> eventlist = mCalendar->events(days[i]); Event *event; int numEvents = eventlist.count(); QString holiStr = ""; bDays.clearBit(i); for(event=eventlist.first();event != 0;event=eventlist.next()) { ushort recurType = event->recurrence()->doesRecur(); if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { numEvents--; } - if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { + if ( event->isHoliday()) { if ( !holiStr.isEmpty() ) holiStr += "\n"; holiStr += event->summary(); if ( !event->location().isEmpty() ) holiStr += " (" + event->location() + ")"; } - if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { + if ( event->isBirthday()) { if ( !holiStr.isEmpty() ) holiStr += "\n"; holiStr += i18n("Birthday") + ": "+event->summary(); if ( !event->location().isEmpty() ) holiStr += " (" + event->location() + ")"; bDays.setBit(i); } } events[i] = numEvents; //if it is a holy day then draw it red. Sundays are consider holidays, too if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || !holiStr.isEmpty()) { diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 004ff50..76982b4 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -506,26 +506,25 @@ void MonthViewCell::startUpdateCell() void MonthViewCell::insertEvent(Event *event) { QString mToolTipText; mItemList->setFocusPolicy(WheelFocus); if ( !(event->doesRecur() == Recurrence::rNone) ) { if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) return; else if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) return; } - if ( event->categories().contains("Holiday") || - event->categories().contains(i18n("Holiday"))) { + if ( event->isHoliday()) { setHoliday( true ); if ( mDate.dayOfWeek() == 7 ) mItemList->setLineWidth( 3 ); } QString text; int multiday = 0;// 1 = start, 2 = midddle, 3 = end day if (event->isMultiDay()) { QString prefix = "<->";multiday = 2; QString time; if ( event->doesRecur() ) { if ( event->recursOn( mDate) ) { prefix ="->" ;multiday = 1; diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 18dc656..66ff75d 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp @@ -469,25 +469,25 @@ bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool a QDateTime noc; QString tempText; if ( appendTable && !notRed ) { tempText = "<table>"; } bool ok = true; if ( reply ) { noc = ev->getNextOccurence( cdt, &ok ); if (! ok && ev->type() == "Event") return false; } bool bDay = false; - if ( ev->categories().contains( i18n("Birthday") ) || ev->categories().contains( i18n("Anniversary") ) ) + if ( ev->isBirthday() || ev->isAnniversary() ) bDay = true; tempText += "<tr><td><b>"; if (ev->type()=="Event") { if (reply) { if (!ev->doesFloat()) tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; else tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; } else { if (!ev->doesFloat()) { Event *event = static_cast<Event *>(ev); @@ -527,28 +527,28 @@ bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool a tempText += "<font color=\"#F00000\">" + dateText + "</font>"; } else if ( st < cdt ) tempText += "<font color=\"#008000\">" + dateText + "</font>"; else tempText += dateText; } } else { if ( bDay ) { - if ( ev->categories().contains( i18n("Birthday") )) - tempText += "<font color=\"#F00000\">" + i18n("Birthday") +":</font>"; + if ( ev->isBirthday()) + tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>"; else - tempText += "<font color=\"#F00000\">" + i18n("Anniversary")+":</font>"; + tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>"; } else { tempText += i18n("Allday:"); } } } } else { mTodos.append( ev ); tempText += i18n("ToDo:"); if (reply) { tempText += " "; if ( noc != cdt ) { diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 708ee6b..9a36939 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -31,24 +31,28 @@ using namespace KCal; Incidence::Incidence() : IncidenceBase(), mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) { mRecurrence = new Recurrence(this); mCancelled = false; recreate(); mHasStartDate = true; mAlarms.setAutoDelete(true); mAttachments.setAutoDelete(true); mHasRecurrenceID = false; + mHoliday = false; + mBirthday = false; + mAnniversary = false; + } Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) { // TODO: reenable attributes currently commented out. mRevision = i.mRevision; mCreated = i.mCreated; mDescription = i.mDescription; mSummary = i.mSummary; mCategories = i.mCategories; // Incidence *mRelatedTo; Incidence *mRelatedTo; mRelatedTo = 0; @@ -66,38 +70,57 @@ Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) const Alarm *a; while( (a = it.current()) ) { Alarm *b = new Alarm( *a ); b->setParent( this ); mAlarms.append( b ); ++it; } mAlarms.setAutoDelete(true); mHasRecurrenceID = i.mHasRecurrenceID; mRecurrenceID = i.mRecurrenceID; mRecurrence = new Recurrence( *(i.mRecurrence), this ); + mHoliday = i.mHoliday ; + mBirthday = i.mBirthday; + mAnniversary = i.mAnniversary; } Incidence::~Incidence() { Incidence *ev; QPtrList<Incidence> Relations = relations(); for (ev=Relations.first();ev;ev=Relations.next()) { if (ev->relatedTo() == this) ev->setRelatedTo(0); } if (relatedTo()) relatedTo()->removeRelation(this); delete mRecurrence; } + +bool Incidence::isHoliday() const +{ + return mHoliday; +} +bool Incidence::isBirthday() const +{ + + return mBirthday ; +} +bool Incidence::isAnniversary() const +{ + return mAnniversary ; + +} + bool Incidence::hasRecurrenceID() const { return mHasRecurrenceID; } void Incidence::setHasRecurrenceID( bool b ) { mHasRecurrenceID = b; } void Incidence::setRecurrenceID(QDateTime d) { @@ -293,47 +316,54 @@ QString Incidence::description() const void Incidence::setSummary(const QString &summary) { if (mReadOnly) return; mSummary = summary; updated(); } QString Incidence::summary() const { return mSummary; } +void Incidence::checkCategories() +{ + mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); + mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); + mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); +} void Incidence::setCategories(const QStringList &categories) { if (mReadOnly) return; mCategories = categories; + checkCategories(); updated(); } // TODO: remove setCategories(QString) function void Incidence::setCategories(const QString &catStr) { if (mReadOnly) return; mCategories.clear(); if (catStr.isEmpty()) return; mCategories = QStringList::split(",",catStr); QStringList::Iterator it; for(it = mCategories.begin();it != mCategories.end(); ++it) { *it = (*it).stripWhiteSpace(); } - + checkCategories(); updated(); } QStringList Incidence::categories() const { return mCategories; } QString Incidence::categoriesStr() { return mCategories.join(","); } diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 0ae9656..f8da342 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h @@ -261,32 +261,37 @@ class Incidence : public IncidenceBase /** sets the event's hasStartDate value. */ void setHasStartDate(bool f); QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; bool cancelled() const; void setCancelled( bool b ); bool hasRecurrenceID() const; void setHasRecurrenceID( bool b ); void setRecurrenceID(QDateTime); QDateTime recurrenceID () const; QDateTime dtStart() const; + bool isHoliday() const; + bool isBirthday() const; + bool isAnniversary() const; protected: QPtrList<Alarm> mAlarms; QPtrList<Incidence> mRelations; QDateTime mRecurrenceID; bool mHasRecurrenceID; private: + void checkCategories(); + bool mHoliday, mBirthday, mAnniversary; int mRevision; bool mCancelled; // base components of jounal, event and todo QDateTime mCreated; QString mDescription; QString mSummary; QStringList mCategories; Incidence *mRelatedTo; QString mRelatedToUid; DateList mExDates; QPtrList<Attachment> mAttachments; |