summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidencebase.cpp4
-rw-r--r--libkcal/todo.cpp4
2 files changed, 6 insertions, 2 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 1e99082..b5fe2e6 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -111,193 +111,195 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
if ( i1.duration() != i2.duration() )
return false;
}
} else {
return false;
}
return ( i1.organizer() == i2.organizer() &&
// i1.uid() == i2.uid() &&
// Don't compare lastModified, otherwise the operator is not
// of much use. We are not comparing for identity, after all.
i1.doesFloat() == i2.doesFloat() &&
i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
// no need to compare mObserver
}
QDateTime IncidenceBase::getEvenTime( QDateTime dt )
{
QTime t = dt.time();
dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
return dt;
}
void IncidenceBase::setUid(const QString &uid)
{
mUid = uid;
updated();
}
QString IncidenceBase::uid() const
{
return mUid;
}
void IncidenceBase::setLastModified(const QDateTime &lm)
{
// DON'T! updated() because we call this from
// Calendar::updateEvent().
mLastModified = getEvenTime(lm);
//qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
}
QDateTime IncidenceBase::lastModified() const
{
return mLastModified;
}
void IncidenceBase::setOrganizer(const QString &o)
{
// we don't check for readonly here, because it is
// possible that by setting the organizer we are changing
// the event's readonly status...
mOrganizer = o;
if (mOrganizer.left(7).upper() == "MAILTO:")
mOrganizer = mOrganizer.remove(0,7);
updated();
}
QString IncidenceBase::organizer() const
{
return mOrganizer;
}
void IncidenceBase::setReadOnly( bool readOnly )
{
mReadOnly = readOnly;
}
void IncidenceBase::setDtStart(const QDateTime &dtStart)
{
// if (mReadOnly) return;
mDtStart = getEvenTime(dtStart);
updated();
}
QDateTime IncidenceBase::dtStart() const
{
return mDtStart;
}
QString IncidenceBase::dtStartTimeStr() const
{
return KGlobal::locale()->formatTime(dtStart().time());
}
QString IncidenceBase::dtStartDateStr(bool shortfmt) const
{
return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
}
QString IncidenceBase::dtStartStr(bool shortfmt) const
{
- return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
+ if ( doesFloat() )
+ return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
+ return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
}
bool IncidenceBase::doesFloat() const
{
return mFloats;
}
void IncidenceBase::setFloats(bool f)
{
if (mReadOnly) return;
mFloats = f;
updated();
}
bool IncidenceBase::addAttendee(Attendee *a, bool doupdate)
{
if (mReadOnly) return false;
if (a->name().left(7).upper() == "MAILTO:")
a->setName(a->name().remove(0,7));
QPtrListIterator<Attendee> qli(mAttendees);
qli.toFirst();
while (qli) {
if (*qli.current() == *a)
return false;
++qli;
}
mAttendees.append(a);
if (doupdate) updated();
return true;
}
#if 0
void IncidenceBase::removeAttendee(Attendee *a)
{
if (mReadOnly) return;
mAttendees.removeRef(a);
updated();
}
void IncidenceBase::removeAttendee(const char *n)
{
Attendee *a;
if (mReadOnly) return;
for (a = mAttendees.first(); a; a = mAttendees.next())
if (a->getName() == n) {
mAttendees.remove();
break;
}
}
#endif
void IncidenceBase::clearAttendees()
{
if (mReadOnly) return;
mAttendees.clear();
}
#if 0
Attendee *IncidenceBase::getAttendee(const char *n) const
{
QPtrListIterator<Attendee> qli(mAttendees);
qli.toFirst();
while (qli) {
if (qli.current()->getName() == n)
return qli.current();
++qli;
}
return 0L;
}
#endif
Attendee *IncidenceBase::attendeeByMail(const QString &email)
{
QPtrListIterator<Attendee> qli(mAttendees);
qli.toFirst();
while (qli) {
if (qli.current()->email().lower() == email.lower())
return qli.current();
++qli;
}
return 0L;
}
Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
{
QPtrListIterator<Attendee> qli(mAttendees);
QStringList mails = emails;
if (!email.isEmpty()) {
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 39d16b6..a496404 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -98,193 +98,195 @@ bool Todo::contains ( Todo* from )
QString nCat;
unsigned int iii;
for ( iii = 0; iii < catFrom.count();++iii ) {
nCat = catFrom[iii];
if ( !nCat.isEmpty() )
if ( !cat.contains( nCat )) {
return false;
}
}
if ( from->isCompleted() ) {
if ( !isCompleted() )
return false;
}
if( priority() != from->priority() )
return false;
return true;
}
bool KCal::operator==( const Todo& t1, const Todo& t2 )
{
bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
if ( ! ret )
return false;
if ( t1.hasDueDate() == t2.hasDueDate() ) {
if ( t1.hasDueDate() ) {
if ( t1.doesFloat() == t2.doesFloat() ) {
if ( t1.doesFloat() ) {
if ( t1.dtDue().date() != t2.dtDue().date() )
return false;
} else
if ( t1.dtDue() != t2.dtDue() )
return false;
} else
return false;// float !=
}
} else
return false;
if ( t1.percentComplete() != t2.percentComplete() )
return false;
if ( t1.isCompleted() ) {
if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) {
if ( t1.hasCompletedDate() ) {
if ( t1.completed() != t2.completed() )
return false;
}
} else
return false;
}
return true;
}
void Todo::setDtDue(const QDateTime &dtDue)
{
//int diffsecs = mDtDue.secsTo(dtDue);
/*if (mReadOnly) return;
const QPtrList<Alarm>& alarms = alarms();
for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) {
if (alarm->enabled()) {
alarm->setTime(alarm->time().addSecs(diffsecs));
}
}*/
mDtDue = getEvenTime(dtDue);
//kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl;
/*const QPtrList<Alarm>& alarms = alarms();
for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next())
alarm->setAlarmStart(mDtDue);*/
updated();
}
QDateTime Todo::dtDue() const
{
return mDtDue;
}
QString Todo::dtDueTimeStr() const
{
return KGlobal::locale()->formatTime(mDtDue.time());
}
QString Todo::dtDueDateStr(bool shortfmt) const
{
return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
}
QString Todo::dtDueStr(bool shortfmt) const
{
- return KGlobal::locale()->formatDateTime(mDtDue, shortfmt);
+ if ( doesFloat() )
+ return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
+ return KGlobal::locale()->formatDateTime(mDtDue, shortfmt);
}
// retval 0 : no found
// 1 : due for date found
// 2 : overdue for date found
int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos )
{
int retval = 0;
if ( isCompleted() )
return 0;
if ( hasDueDate() ) {
if ( dtDue().date() < date )
return 2;
// we do not return, because we may find an overdue sub todo
if ( dtDue().date() == date )
retval = 1;
}
if ( checkSubtodos ) {
Incidence *aTodo;
for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos );
if ( ret == 2 )
return 2;
if ( ret == 1)
retval = 1;
}
}
return retval;
}
int Todo::hasDueSubTodo( bool checkSubtodos ) //= true
{
return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos );
}
bool Todo::hasDueDate() const
{
return mHasDueDate;
}
void Todo::setHasDueDate(bool f)
{
if (mReadOnly) return;
mHasDueDate = f;
updated();
}
#if 0
void Todo::setStatus(const QString &statStr)
{
if (mReadOnly) return;
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");