libkcal Library API Documentation

todo.cpp

00001 /* 00002 This file is part of libkcal. 00003 00004 Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 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 //int diffsecs = mDtDue.secsTo(dtDue); 00074 00075 /*if (mReadOnly) return; 00076 const Alarm::List& alarms = alarms(); 00077 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { 00078 if (alarm->enabled()) { 00079 alarm->setTime(alarm->time().addSecs(diffsecs)); 00080 } 00081 }*/ 00082 mDtDue = dtDue; 00083 00084 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; 00085 00086 /*const Alarm::List& alarms = alarms(); 00087 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) 00088 alarm->setAlarmStart(mDtDue);*/ 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
KDE Logo
This file is part of the documentation for libkcal Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:44 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003