author | zautrix <zautrix> | 2005-02-13 19:07:45 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-13 19:07:45 (UTC) |
commit | 7bd83e913399b8be68a7d37e8f02118ec9eab90e (patch) (side-by-side diff) | |
tree | 284d1592687ea4d3e0c220fafd289a702718dee4 /libkcal | |
parent | 293271fe9e6a9061da329183f8f488d79580f7da (diff) | |
download | kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.zip kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.gz kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.bz2 |
todo fixi
-rw-r--r-- | libkcal/icalformatimpl.cpp | 2 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 16 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 12 | ||||
-rw-r--r-- | libkcal/todo.cpp | 4 |
4 files changed, 27 insertions, 7 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index bb9cb29..2e38ae3 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp @@ -1085,257 +1085,257 @@ Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee) default: case ICAL_ROLE_REQPARTICIPANT: role = Attendee::ReqParticipant; break; case ICAL_ROLE_OPTPARTICIPANT: role = Attendee::OptParticipant; break; case ICAL_ROLE_NONPARTICIPANT: role = Attendee::NonParticipant; break; } } p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); uid = icalparameter_get_xvalue(p); // This should be added, but there seems to be a libical bug here. /*while (p) { // if (icalparameter_get_xname(p) == "X-UID") { uid = icalparameter_get_xvalue(p); p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); } */ return new Attendee( name, email, rsvp, status, role, uid ); } Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) { icalattach *a = icalproperty_get_attach(attach); icalparameter_value v = ICAL_VALUE_NONE; icalparameter_encoding e = ICAL_ENCODING_NONE; Attachment *attachment = 0; /* icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); if (vp) v = icalparameter_get_value(vp); icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); if (ep) e = icalparameter_get_encoding(ep); */ int isurl = icalattach_get_is_url (a); if (isurl == 0) attachment = new Attachment((const char*)icalattach_get_data(a)); else { attachment = new Attachment(QString(icalattach_get_url(a))); } icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); if (p) attachment->setMimeType(QString(icalparameter_get_fmttype(p))); return attachment; } #include <qtextcodec.h> void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) { readIncidenceBase(parent,incidence); icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); bool readrec = false; const char *text; int intvalue; icaltimetype icaltime; icaldurationtype icalduration; struct icalrecurrencetype rectype; QStringList categories; while (p) { icalproperty_kind kind = icalproperty_isa(p); switch (kind) { case ICAL_CREATED_PROPERTY: icaltime = icalproperty_get_created(p); incidence->setCreated(readICalDateTime(icaltime)); break; case ICAL_SEQUENCE_PROPERTY: // sequence intvalue = icalproperty_get_sequence(p); incidence->setRevision(intvalue); break; case ICAL_LASTMODIFIED_PROPERTY: // last modification date icaltime = icalproperty_get_lastmodified(p); incidence->setLastModified(readICalDateTime(icaltime)); break; case ICAL_DTSTART_PROPERTY: // start date and time icaltime = icalproperty_get_dtstart(p); if (icaltime.is_date) { incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0))); incidence->setFloats(true); } else { incidence->setDtStart(readICalDateTime(icaltime)); } break; case ICAL_DURATION_PROPERTY: // start date and time icalduration = icalproperty_get_duration(p); incidence->setDuration(readICalDuration(icalduration)); break; case ICAL_DESCRIPTION_PROPERTY: // description text = icalproperty_get_description(p); incidence->setDescription(QString::fromUtf8(text)); break; case ICAL_SUMMARY_PROPERTY: // summary { text = icalproperty_get_summary(p); incidence->setSummary(QString::fromUtf8(text)); } break; case ICAL_STATUS_PROPERTY: // summary { if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) incidence->setCancelled( true ); } break; case ICAL_LOCATION_PROPERTY: // location text = icalproperty_get_location(p); incidence->setLocation(QString::fromUtf8(text)); break; case ICAL_RECURRENCEID_PROPERTY: icaltime = icalproperty_get_recurrenceid(p); incidence->setRecurrenceID( readICalDateTime(icaltime) ); - qDebug(" RecurrenceID %s",incidence->recurrenceID().toString().latin1() ); + //qDebug(" RecurrenceID %s",incidence->recurrenceID().toString().latin1() ); break; #if 0 // status if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); deleteStr(s); } else incidence->setStatus("NEEDS ACTION"); #endif case ICAL_PRIORITY_PROPERTY: // priority intvalue = icalproperty_get_priority(p); incidence->setPriority(intvalue); break; case ICAL_CATEGORIES_PROPERTY: // categories text = icalproperty_get_categories(p); categories.append(QString::fromUtf8(text)); break; //******************************************* case ICAL_RRULE_PROPERTY: // we do need (maybe )start datetime of incidence for recurrence // such that we can read recurrence only after we read incidence completely readrec = true; rectype = icalproperty_get_rrule(p); break; case ICAL_EXDATE_PROPERTY: icaltime = icalproperty_get_exdate(p); incidence->addExDate(readICalDate(icaltime)); break; case ICAL_CLASS_PROPERTY: { int inttext = icalproperty_get_class(p); if (inttext == ICAL_CLASS_PUBLIC ) { incidence->setSecrecy(Incidence::SecrecyPublic); } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { incidence->setSecrecy(Incidence::SecrecyConfidential); } else { incidence->setSecrecy(Incidence::SecrecyPrivate); } } break; case ICAL_ATTACH_PROPERTY: // attachments incidence->addAttachment(readAttachment(p)); break; default: // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind // << endl; break; } p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); } if ( readrec ) { readRecurrenceRule(rectype,incidence); } // kpilot stuff // TODO: move this application-specific code to kpilot QString kp = incidence->nonKDECustomProperty("X-PILOTID"); if (!kp.isNull()) { incidence->setPilotId(kp.toInt()); } kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); if (!kp.isNull()) { incidence->setSyncStatus(kp.toInt()); } kp = incidence->nonKDECustomProperty("X-KOPIEXTID"); if (!kp.isNull()) { incidence->setIDStr(kp); } // Cancel backwards compatibility mode for subsequent changes by the application incidence->recurrence()->setCompatVersion(); // add categories incidence->setCategories(categories); // iterate through all alarms for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); alarm; alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { readAlarm(alarm,incidence); } } void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) { icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); while (p) { icalproperty_kind kind = icalproperty_isa(p); switch (kind) { case ICAL_UID_PROPERTY: // unique id incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); break; case ICAL_ORGANIZER_PROPERTY: // organizer incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); break; case ICAL_ATTENDEE_PROPERTY: // attendee incidenceBase->addAttendee(readAttendee(p)); break; default: break; } p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); } // custom properties readCustomProperties(parent, incidenceBase); } void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) { QMap<QCString, QString> customProperties; icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 0684af2..708ee6b 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -88,260 +88,268 @@ Incidence::~Incidence() if (relatedTo()) relatedTo()->removeRelation(this); delete mRecurrence; } bool Incidence::hasRecurrenceID() const { return mHasRecurrenceID; } void Incidence::setHasRecurrenceID( bool b ) { mHasRecurrenceID = b; } void Incidence::setRecurrenceID(QDateTime d) { mRecurrenceID = d; mHasRecurrenceID = true; updated(); } QDateTime Incidence::recurrenceID () const { return mRecurrenceID; } bool Incidence::cancelled() const { return mCancelled; } void Incidence::setCancelled( bool b ) { mCancelled = b; updated(); } bool Incidence::hasStartDate() const { return mHasStartDate; } void Incidence::setHasStartDate(bool f) { if (mReadOnly) return; mHasStartDate = f; updated(); } // A string comparison that considers that null and empty are the same static bool stringCompare( const QString& s1, const QString& s2 ) { if ( s1.isEmpty() && s2.isEmpty() ) return true; return s1 == s2; } bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) { if( i1.alarms().count() != i2.alarms().count() ) { return false; // no need to check further } if ( i1.alarms().count() > 0 ) { if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) { qDebug("alarm not equal "); return false; } } #if 0 QPtrListIterator<Alarm> a1( i1.alarms() ); QPtrListIterator<Alarm> a2( i2.alarms() ); for( ; a1.current() && a2.current(); ++a1, ++a2 ) { if( *a1.current() == *a2.current() ) { continue; } else { return false; } } #endif if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { if ( i1.hasRecurrenceID() ) { if ( i1.recurrenceID() != i2.recurrenceID() ) return false; } } else { return false; } if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) return false; if ( i1.hasStartDate() == i2.hasStartDate() ) { if ( i1.hasStartDate() ) { if ( i1.dtStart() != i2.dtStart() ) return false; } } else { return false; } if (!( *i1.recurrence() == *i2.recurrence()) ) { qDebug("recurrence is NOT equal "); return false; } return // i1.created() == i2.created() && stringCompare( i1.description(), i2.description() ) && stringCompare( i1.summary(), i2.summary() ) && i1.categories() == i2.categories() && // no need to compare mRelatedTo stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && // i1.relations() == i2.relations() && i1.exDates() == i2.exDates() && i1.attachments() == i2.attachments() && i1.resources() == i2.resources() && i1.secrecy() == i2.secrecy() && i1.priority() == i2.priority() && i1.cancelled() == i2.cancelled() && stringCompare( i1.location(), i2.location() ); } Incidence* Incidence::recreateCloneException( QDate d ) { Incidence* newInc = clone(); newInc->recreate(); if ( doesRecur() ) { addExDate( d ); newInc->recurrence()->unsetRecurs(); - int len = dtStart().secsTo( ((Event*)this)->dtEnd()); - QTime tim = dtStart().time(); - newInc->setDtStart( QDateTime(d, tim) ); - ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); + if ( type() == "Event") { + int len = dtStart().secsTo( ((Event*)this)->dtEnd()); + QTime tim = dtStart().time(); + newInc->setDtStart( QDateTime(d, tim) ); + ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); + } else { + int len = dtStart().secsTo( ((Todo*)this)->dtDue()); + QTime tim = ((Todo*)this)->dtDue().time(); + ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); + ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); + ((Todo*)this)->setRecurDates(); + } } return newInc; } void Incidence::recreate() { setCreated(QDateTime::currentDateTime()); setUid(CalFormat::createUniqueId()); setRevision(0); setIDStr( ":" ); setLastModified(QDateTime::currentDateTime()); } void Incidence::setReadOnly( bool readOnly ) { IncidenceBase::setReadOnly( readOnly ); recurrence()->setRecurReadOnly( readOnly); } void Incidence::setCreated(QDateTime created) { if (mReadOnly) return; mCreated = getEvenTime(created); } QDateTime Incidence::created() const { return mCreated; } void Incidence::setRevision(int rev) { if (mReadOnly) return; mRevision = rev; updated(); } int Incidence::revision() const { return mRevision; } void Incidence::setDtStart(const QDateTime &dtStart) { QDateTime dt = getEvenTime(dtStart); recurrence()->setRecurStart( dt); IncidenceBase::setDtStart( dt ); } void Incidence::setDescription(const QString &description) { if (mReadOnly) return; mDescription = description; updated(); } QString Incidence::description() const { return mDescription; } void Incidence::setSummary(const QString &summary) { if (mReadOnly) return; mSummary = summary; updated(); } QString Incidence::summary() const { return mSummary; } void Incidence::setCategories(const QStringList &categories) { if (mReadOnly) return; mCategories = categories; 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(); } updated(); } QStringList Incidence::categories() const { return mCategories; } QString Incidence::categoriesStr() { return mCategories.join(","); } void Incidence::setRelatedToUid(const QString &relatedToUid) { if (mReadOnly) return; mRelatedToUid = relatedToUid; } QString Incidence::relatedToUid() const { return mRelatedToUid; } void Incidence::setRelatedTo(Incidence *relatedTo) { //qDebug("Incidence::setRelatedTo %d ", relatedTo); //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 0d9c3f4..cc3088a 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp @@ -67,256 +67,268 @@ void KIncidenceFormatter::setEvent(Event *event) if ( mColorMode ) mText += "</font>"; } if (event->cancelled ()) { mText +="<font color=\"#B00000\">"; addTag("i",i18n("This event has been cancelled!")); mText.append("<br>"); mText += "</font>"; } if (!event->location().isEmpty()) { addTag("b",i18n("Location: ")); mText.append(event->location()+"<br>"); } if (event->doesFloat()) { if (event->isMultiDay()) { mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") .arg(event->dtStartDateStr(shortDate)) .arg(event->dtEndDateStr(shortDate))); } else { mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); } } else { if (event->isMultiDay()) { mText.append(i18n("<p><b>From:</b> %1</p> ") .arg(event->dtStartStr( shortDate))); mText.append(i18n("<p><b>To:</b> %1</p>") .arg(event->dtEndStr(shortDate))); } else { mText.append(i18n("<p><b>On:</b> %1</p> ") .arg(event->dtStartDateStr( shortDate ))); mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") .arg(event->dtStartTimeStr()) .arg(event->dtEndTimeStr())); } } if (event->recurrence()->doesRecur()) { QString recurText = event->recurrence()->recurrenceText(); addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); bool ok; QDate start = QDate::currentDate(); QDateTime next; next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); if ( ok ) { addTag("p",i18n("<b>Next recurrence is on:</b>") ); addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); } else { bool last; QDate nextd; nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); if ( last ) { addTag("p",i18n("<b>Last recurrence was on:</b>") ); addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); } } } if (event->isAlarmEnabled()) { Alarm *alarm =event->alarms().first() ; QDateTime t = alarm->time(); int min = t.secsTo( event->dtStart() )/60; QString s =i18n("(%1 min before)").arg( min ); addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); //addTag("p",s); } addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); // mText.append(event->secrecyStr()+"<br>"); formatCategories(event); if (!event->description().isEmpty()) { addTag("p",i18n("<b>Details: </b>")); addTag("p",event->description()); } formatReadOnly(event); formatAttendees(event); } void KIncidenceFormatter::setTodo(Todo *event ) { int mode = 0; mCurrentIncidence = event; bool shortDate = true; if (mode == 0 ) addTag("h3",event->summary()); else { if ( mColorMode == 1 ) { mText +="<font color=\"#00A000\">"; } if ( mColorMode == 2 ) { mText +="<font color=\"#B00000\">"; } if ( mode == 1 ) { addTag("h2",i18n( "Local: " ) +event->summary()); } else { addTag("h2",i18n( "Remote: " ) +event->summary()); } addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); if ( mColorMode ) mText += "</font>"; } if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { mText +="<font color=\"#B00000\">"; addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); mText += "</font>"; } else { mText.append(i18n("<p><i>%1 % completed</i></p>") .arg(event->percentComplete())); } if (event->cancelled ()) { mText +="<font color=\"#B00000\">"; addTag("i",i18n("This todo has been cancelled!")); mText.append("<br>"); mText += "</font>"; } if (!event->location().isEmpty()) { addTag("b",i18n("Location: ")); mText.append(event->location()+"<br>"); } + + if (event->recurrence()->doesRecur()) { + + QString recurText = event->recurrence()->recurrenceText(); + addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); + } + + if (event->hasStartDate()) { + mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); + } + + if (event->hasDueDate()) { mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); } mText.append(i18n("<p><b>Priority:</b> %2</p>") .arg(QString::number(event->priority()))); addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); formatCategories(event); if (!event->description().isEmpty()) { addTag("p",i18n("<b>Details: </b>")); addTag("p",event->description()); } formatReadOnly(event); formatAttendees(event); } void KIncidenceFormatter::setJournal(Journal* ) { } void KIncidenceFormatter::formatCategories(Incidence *event) { if (!event->categoriesStr().isEmpty()) { addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); //mText.append(event->categoriesStr()); } } void KIncidenceFormatter::addTag(const QString & tag,const QString & text) { int number=text.contains("\n"); QString str = "<" + tag + ">"; QString tmpText=text; QString tmpStr=str; if(number !=-1) { if (number > 0) { int pos=0; QString tmp; for(int i=0;i<=number;i++) { pos=tmpText.find("\n"); tmp=tmpText.left(pos); tmpText=tmpText.right(tmpText.length()-pos-1); tmpStr+=tmp+"<br>"; } } else tmpStr += tmpText; tmpStr+="</" + tag + ">"; mText.append(tmpStr); } else { str += text + "</" + tag + ">"; mText.append(str); } } void KIncidenceFormatter::formatAttendees(Incidence *event) { QPtrList<Attendee> attendees = event->attendees(); if (attendees.count()) { QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); addTag("h3",i18n("Organizer")); mText.append("<ul><li>"); #if 0 //ndef KORG_NOKABC KABC::AddressBook *add_book = KABC::StdAddressBook::self(); KABC::Addressee::List addressList; addressList = add_book->findByEmail(event->organizer()); KABC::Addressee o = addressList.first(); if (!o.isEmpty() && addressList.size()<2) { mText += "<a href=\"uid:" + o.uid() + "\">"; mText += o.formattedName(); mText += "</a>\n"; } else { mText.append(event->organizer()); } #else mText.append(event->organizer()); #endif if (iconPath) { mText += " <a href=\"mailto:" + event->organizer() + "\">"; mText += "<IMG src=\"" + iconPath + "\">"; mText += "</a>\n"; } mText.append("</li></ul>"); addTag("h3",i18n("Attendees")); Attendee *a; mText.append("<ul>"); for(a=attendees.first();a;a=attendees.next()) { #if 0 //ndef KORG_NOKABC if (a->name().isEmpty()) { addressList = add_book->findByEmail(a->email()); KABC::Addressee o = addressList.first(); if (!o.isEmpty() && addressList.size()<2) { mText += "<a href=\"uid:" + o.uid() + "\">"; mText += o.formattedName(); mText += "</a>\n"; } else { mText += "<li>"; mText.append(a->email()); mText += "\n"; } } else { mText += "<li><a href=\"uid:" + a->uid() + "\">"; if (!a->name().isEmpty()) mText += a->name(); else mText += a->email(); mText += "</a>\n"; } #else //qDebug("nokabc "); mText += "<li><a href=\"uid:" + a->uid() + "\">"; if (!a->name().isEmpty()) mText += a->name(); else mText += a->email(); mText += "</a>\n"; #endif if (!a->email().isEmpty()) { if (iconPath) { mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 1f54c2f..39d16b6 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -244,214 +244,214 @@ void Todo::setStatus(const QString &statStr) QString ss(statStr.upper()); if (ss == "X-ACTION") mStatus = NEEDS_ACTION; else if (ss == "NEEDS ACTION") mStatus = NEEDS_ACTION; else if (ss == "ACCEPTED") mStatus = ACCEPTED; else if (ss == "SENT") mStatus = SENT; else if (ss == "TENTATIVE") mStatus = TENTATIVE; else if (ss == "CONFIRMED") mStatus = CONFIRMED; else if (ss == "DECLINED") mStatus = DECLINED; else if (ss == "COMPLETED") mStatus = COMPLETED; else if (ss == "DELEGATED") mStatus = DELEGATED; updated(); } void Todo::setStatus(int status) { if (mReadOnly) return; mStatus = status; updated(); } int Todo::status() const { return mStatus; } QString Todo::statusStr() const { switch(mStatus) { case NEEDS_ACTION: return QString("NEEDS ACTION"); break; case ACCEPTED: return QString("ACCEPTED"); break; case SENT: return QString("SENT"); break; case TENTATIVE: return QString("TENTATIVE"); break; case CONFIRMED: return QString("CONFIRMED"); break; case DECLINED: return QString("DECLINED"); break; case COMPLETED: return QString("COMPLETED"); break; case DELEGATED: return QString("DELEGATED"); break; } return QString(""); } #endif bool Todo::isCompleted() const { if (mPercentComplete == 100) { return true; } else return false; } void Todo::setCompleted(bool completed) { if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { if ( !setRecurDates() ) completed = false; } if (completed) mPercentComplete = 100; else { mPercentComplete = 0; mHasCompletedDate = false; } updated(); } QDateTime Todo::completed() const { return mCompleted; } QString Todo::completedStr( bool shortF ) const { return KGlobal::locale()->formatDateTime(mCompleted, shortF); } void Todo::setCompleted(const QDateTime &completed) { //qDebug("Todo::setCompleted "); if ( mHasCompletedDate ) { // qDebug("has completed data - return "); return; } mHasCompletedDate = true; mPercentComplete = 100; mCompleted = getEvenTime(completed); updated(); } bool Todo::hasCompletedDate() const { return mHasCompletedDate; } int Todo::percentComplete() const { return mPercentComplete; } bool Todo::setRecurDates() { if ( !mHasRecurrenceID ) return true; int secs = mDtStart.secsTo( dtDue() ); bool ok; - qDebug("--------------------setRecurDates() "); + qDebug("T:setRecurDates() "); //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); QDateTime next = getNextOccurence( mRecurrenceID, &ok ); if ( ok ) { mRecurrenceID = next; mDtStart = next; setDtDue( next.addSecs( secs ) ); if ( QDateTime::currentDateTime() > next) return false; } else { setHasRecurrenceID( false ); recurrence()->unsetRecurs(); } return true; } void Todo::setPercentComplete(int v) { if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { if ( !setRecurDates() ) v = 0; } mPercentComplete = v; if ( v != 100 ) mHasCompletedDate = false; updated(); } QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const { if ( isCompleted() || ! hasDueDate() || cancelled() ) { *ok = false; return QDateTime (); } QDateTime incidenceStart; incidenceStart = dtDue(); bool enabled = false; Alarm* alarm; int off = 0; QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; // if ( QDateTime::currentDateTime() > incidenceStart ){ // *ok = false; // return incidenceStart; // } for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { if (alarm->enabled()) { if ( alarm->hasTime () ) { if ( alarm->time() < alarmStart ) { alarmStart = alarm->time(); enabled = true; off = alarmStart.secsTo( incidenceStart ); } } else { int secs = alarm->startOffset().asSeconds(); if ( incidenceStart.addSecs( secs ) < alarmStart ) { alarmStart = incidenceStart.addSecs( secs ); enabled = true; off = -secs; } } } } if ( enabled ) { if ( alarmStart > QDateTime::currentDateTime() ) { *ok = true; * offset = off; return alarmStart; } } *ok = false; return QDateTime (); } void Todo::checkSetCompletedFalse() { if ( !hasRecurrenceID() ) { qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); } // qDebug("Todo::checkSetCompletedFalse()"); //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); setCompleted( false ); - qDebug("Todo::checkSetCompletedFalse++++++++++++++++++++++++++++ "); + qDebug("Todo::checkSetCompletedFalse "); } } |