todo.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <kglobal.h>
00023 #include <klocale.h>
00024 #include <kdebug.h>
00025
00026 #include "todo.h"
00027
00028 using namespace KCal;
00029
00030 Todo::Todo()
00031 {
00032 mHasDueDate = false;
00033 mHasStartDate = false;
00034
00035 mHasCompletedDate = false;
00036 mPercentComplete = 0;
00037 }
00038
00039 Todo::Todo(const Todo &t) : Incidence(t)
00040 {
00041 mDtDue = t.mDtDue;
00042 mHasDueDate = t.mHasDueDate;
00043 mHasStartDate = t.mHasStartDate;
00044 mCompleted = t.mCompleted;
00045 mHasCompletedDate = t.mHasCompletedDate;
00046 mPercentComplete = t.mPercentComplete;
00047 }
00048
00049 Todo::~Todo()
00050 {
00051 }
00052
00053 Todo *Todo::clone()
00054 {
00055 return new Todo( *this );
00056 }
00057
00058
00059 bool Todo::operator==( const Todo& t2 ) const
00060 {
00061 return
00062 static_cast<const Incidence&>(*this) == static_cast<const Incidence&>(t2) &&
00063 dtDue() == t2.dtDue() &&
00064 hasDueDate() == t2.hasDueDate() &&
00065 hasStartDate() == t2.hasStartDate() &&
00066 completed() == t2.completed() &&
00067 hasCompletedDate() == t2.hasCompletedDate() &&
00068 percentComplete() == t2.percentComplete();
00069 }
00070
00071 void Todo::setDtDue(const QDateTime &dtDue)
00072 {
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 mDtDue = dtDue;
00083
00084
00085
00086
00087
00088
00089
00090 updated();
00091 }
00092
00093 QDateTime Todo::dtDue() const
00094 {
00095 return mDtDue;
00096 }
00097
00098 QString Todo::dtDueTimeStr() const
00099 {
00100 return KGlobal::locale()->formatTime(mDtDue.time());
00101 }
00102
00103 QString Todo::dtDueDateStr(bool shortfmt) const
00104 {
00105 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
00106 }
00107
00108 QString Todo::dtDueStr() const
00109 {
00110 return KGlobal::locale()->formatDateTime(mDtDue);
00111 }
00112
00113 bool Todo::hasDueDate() const
00114 {
00115 return mHasDueDate;
00116 }
00117
00118 void Todo::setHasDueDate(bool f)
00119 {
00120 if (mReadOnly) return;
00121 mHasDueDate = f;
00122 updated();
00123 }
00124
00125
00126 bool Todo::hasStartDate() const
00127 {
00128 return mHasStartDate;
00129 }
00130
00131 void Todo::setHasStartDate(bool f)
00132 {
00133 if (mReadOnly) return;
00134 mHasStartDate = f;
00135 updated();
00136 }
00137
00138
00139 bool Todo::isCompleted() const
00140 {
00141 if (mPercentComplete == 100) return true;
00142 else return false;
00143 }
00144
00145 void Todo::setCompleted(bool completed)
00146 {
00147 if (completed) mPercentComplete = 100;
00148 else mPercentComplete = 0;
00149 updated();
00150 }
00151
00152 QDateTime Todo::completed() const
00153 {
00154 return mCompleted;
00155 }
00156
00157 QString Todo::completedStr() const
00158 {
00159 return KGlobal::locale()->formatDateTime(mCompleted);
00160 }
00161
00162 void Todo::setCompleted(const QDateTime &completed)
00163 {
00164 mHasCompletedDate = true;
00165 mPercentComplete = 100;
00166 mCompleted = completed;
00167 updated();
00168 }
00169
00170 bool Todo::hasCompletedDate() const
00171 {
00172 return mHasCompletedDate;
00173 }
00174
00175 int Todo::percentComplete() const
00176 {
00177 return mPercentComplete;
00178 }
00179
00180 void Todo::setPercentComplete(int v)
00181 {
00182 mPercentComplete = v;
00183 updated();
00184 }
00185
This file is part of the documentation for libkcal Library Version 3.2.2.