summaryrefslogtreecommitdiffabout
path: root/libkcal/todo.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/todo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 0c1e3e4..3d2de61 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -1,187 +1,245 @@
/*
This file is part of libkcal.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <kglobal.h>
#include <klocale.h>
#include <kdebug.h>
#include "todo.h"
using namespace KCal;
Todo::Todo(): Incidence()
{
// mStatus = TENTATIVE;
mHasDueDate = false;
setHasStartDate( false );
mCompleted = getEvenTime(QDateTime::currentDateTime());
mHasCompletedDate = false;
mPercentComplete = 0;
}
Todo::Todo(const Todo &t) : Incidence(t)
{
mDtDue = t.mDtDue;
mHasDueDate = t.mHasDueDate;
mCompleted = t.mCompleted;
mHasCompletedDate = t.mHasCompletedDate;
mPercentComplete = t.mPercentComplete;
}
Todo::~Todo()
{
}
Incidence *Todo::clone()
{
return new Todo(*this);
}
+bool Todo::contains ( Todo* from )
+{
+ if ( !from->summary().isEmpty() )
+ if ( !summary().startsWith( from->summary() ))
+ return false;
+ if ( from->hasStartDate() ) {
+ if ( !hasStartDate() )
+ return false;
+ if ( from->dtStart() != dtStart())
+ return false;
+ }
+ if ( from->hasDueDate() ){
+ if ( !hasDueDate() )
+ return false;
+ if ( from->dtDue() != dtDue())
+ return false;
+ }
+ if ( !from->location().isEmpty() )
+ if ( !location().startsWith( from->location() ) )
+ return false;
+ if ( !from->description().isEmpty() )
+ if ( !description().startsWith( from->description() ))
+ return false;
+ if ( from->alarms().count() ) {
+ Alarm *a = from->alarms().first();
+ if ( a->enabled() ){
+ if ( !alarms().count() )
+ return false;
+ Alarm *b = alarms().first();
+ if( ! b->enabled() )
+ return false;
+ if ( ! (a->offset() == b->offset() ))
+ return false;
+ }
+ }
+
+ QStringList cat = categories();
+ QStringList catFrom = from->categories();
+ QString nCat;
+ 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);
}
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