From kde-pim Wed Aug 13 19:10:27 2003 From: Mark Bucciarelli Date: Wed, 13 Aug 2003 19:10:27 +0000 To: kde-pim Subject: [Kde-pim] [PATCH] iCalendar object comments X-MARC-Message: https://marc.info/?l=kde-pim&m=106080212918261 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_j0oO/A57au0ygs0" --Boundary-00=_j0oO/A57au0ygs0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline The attached patch adds the ability to read and write comments with iCalendar objects. The COMMENT attribute can be applied to a JOURNAL, TODO, EVENT, TIMEZONE, and FREEBUSY object. The COMMENT tag can appear zero to many times. I put it the comment attribute in incident base code, but I'm not sure if this is the right place. An ALARM is the one iCal object that does not allow a COMMENT attribute. Not sure how to implement this restriction, however. It seems stupid to duplicate the code in each of the five objects that do support comments just because one subclass of incidenceBase doesn't. Suggestions are welcome. By the way, this is how I have KArm currently storing comments. I'll back that out to use the DESCRIPTION attribute until I hear whether this patch gets in or not. Regards, Mark --Boundary-00=_j0oO/A57au0ygs0 Content-Type: text/x-diff; charset="us-ascii"; name="libkcal-comments.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="libkcal-comments.patch" ? .icalformatimpl.cpp.swp Index: icalformatimpl.cpp =================================================================== RCS file: /home/kde/kdepim/libkcal/icalformatimpl.cpp,v retrieving revision 1.83 diff -u -p -r1.83 icalformatimpl.cpp --- icalformatimpl.cpp 22 Jul 2003 18:56:46 -0000 1.83 +++ icalformatimpl.cpp 13 Aug 2003 18:54:11 -0000 @@ -427,6 +428,12 @@ void ICalFormatImpl::writeIncidenceBase( } } + // comments + QStringList comments = incidenceBase->comments(); + for (QStringList::Iterator it=comments.begin(); it!=comments.end(); ++it) { + icalcomponent_add_property(parent, icalproperty_new_comment((*it).utf8())); + } + // custom properties writeCustomProperties( parent, incidenceBase ); } @@ -1294,6 +1301,11 @@ void ICalFormatImpl::readIncidenceBase(i case ICAL_ATTENDEE_PROPERTY: // attendee incidenceBase->addAttendee(readAttendee(p)); + break; + + case ICAL_COMMENT_PROPERTY: + incidenceBase->addComment( + QString::fromUtf8(icalproperty_get_comment(p))); break; default: Index: incidencebase.cpp =================================================================== RCS file: /home/kde/kdepim/libkcal/incidencebase.cpp,v retrieving revision 1.18 diff -u -p -r1.18 incidencebase.cpp --- incidencebase.cpp 22 Jul 2003 18:56:46 -0000 1.18 +++ incidencebase.cpp 13 Aug 2003 18:54:13 -0000 @@ -186,7 +186,39 @@ void IncidenceBase::setFloats(bool f) updated(); } +// +// comments +// +void IncidenceBase::addComment(const QString& comment) { + mComments += comment; +} +bool IncidenceBase::removeComment(QString& comment) { + bool found = false; + QStringList::Iterator i; + + i = mComments.begin(); + while (!found && ++i != mComments.end()) { + if ( (*i) == comment) { + found = true; + mComments.remove(i); + } + } + + return found; +} + +void IncidenceBase::clearComments() { + mComments.clear(); +} + +QStringList IncidenceBase::comments() { + return mComments; +} + +// +// attendees +// void IncidenceBase::addAttendee(Attendee *a, bool doupdate) { // kdDebug(5800) << "IncidenceBase::addAttendee()" << endl; Index: incidencebase.h =================================================================== RCS file: /home/kde/kdepim/libkcal/incidencebase.h,v retrieving revision 1.14 diff -u -p -r1.14 incidencebase.h --- incidencebase.h 22 Jul 2003 18:56:46 -0000 1.14 +++ incidencebase.h 13 Aug 2003 18:54:13 -0000 @@ -96,6 +96,35 @@ class IncidenceBase : public CustomPrope /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ void setFloats(bool f); + // + // Comments + // + + /** + * Add a comment to this incidence. + * + * Does not add a linefeed character. Just appends the text as passed in. + * + * @param comment The comment to add. + */ + void addComment(const QString& comment); + + /** + * Remove a comment from the event. + * + * Removes first comment whose string is an exact match for the string + * passed in. + * + * @return true if match found, false otherwise. + */ + bool removeComment(QString& comment); + + /** Delete all comments associated with this incidence. */ + void clearComments(); + + /** Return all comments associated with this incidence. */ + QStringList comments(); + /** Add Attendee to this incidence. IncidenceBase takes ownership of the Attendee object. @@ -140,6 +169,7 @@ class IncidenceBase : public CustomPrope QString mUid; QDateTime mLastModified; Attendee::List mAttendees; + QStringList mComments; bool mFloats; --Boundary-00=_j0oO/A57au0ygs0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kde-pim mailing list kde-pim@mail.kde.org http://mail.kde.org/mailman/listinfo/kde-pim kde-pim home page at http://pim.kde.org/ --Boundary-00=_j0oO/A57au0ygs0--