author | zautrix <zautrix> | 2005-04-09 20:21:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-09 20:21:58 (UTC) |
commit | 9e43ebbe5867b2da957bb17c35bd357715424cba (patch) (unidiff) | |
tree | b506ba029b50fc46a33d35a39e6f1c768c995f22 /libkcal/todo.cpp | |
parent | 2c39ac46121e8796e780a5321ab777f08792e5ba (diff) | |
download | kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.zip kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.tar.gz kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.tar.bz2 |
todo tt
-rw-r--r-- | libkcal/todo.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index a496404..7dee4cd 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -1,149 +1,193 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "todo.h" | 25 | #include "todo.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | Todo::Todo(): Incidence() | 29 | Todo::Todo(): Incidence() |
30 | { | 30 | { |
31 | // mStatus = TENTATIVE; | 31 | // mStatus = TENTATIVE; |
32 | 32 | ||
33 | mHasDueDate = false; | 33 | mHasDueDate = false; |
34 | setHasStartDate( false ); | 34 | setHasStartDate( false ); |
35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
36 | mHasCompletedDate = false; | 36 | mHasCompletedDate = false; |
37 | mPercentComplete = 0; | 37 | mPercentComplete = 0; |
38 | mRunning = false; | ||
39 | mRunSaveTimer = 0; | ||
38 | } | 40 | } |
39 | 41 | ||
40 | Todo::Todo(const Todo &t) : Incidence(t) | 42 | Todo::Todo(const Todo &t) : Incidence(t) |
41 | { | 43 | { |
42 | mDtDue = t.mDtDue; | 44 | mDtDue = t.mDtDue; |
43 | mHasDueDate = t.mHasDueDate; | 45 | mHasDueDate = t.mHasDueDate; |
44 | mCompleted = t.mCompleted; | 46 | mCompleted = t.mCompleted; |
45 | mHasCompletedDate = t.mHasCompletedDate; | 47 | mHasCompletedDate = t.mHasCompletedDate; |
46 | mPercentComplete = t.mPercentComplete; | 48 | mPercentComplete = t.mPercentComplete; |
49 | mRunning = false; | ||
50 | mRunSaveTimer = 0; | ||
47 | } | 51 | } |
48 | 52 | ||
49 | Todo::~Todo() | 53 | Todo::~Todo() |
50 | { | 54 | { |
55 | setRunning( false ); | ||
56 | } | ||
57 | |||
58 | void Todo::setRunning( bool run ) | ||
59 | { | ||
60 | if ( run == mRunning ) | ||
61 | return; | ||
62 | if ( !mRunSaveTimer ) { | ||
63 | mRunSaveTimer = new QTimer ( this ); | ||
64 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); | ||
65 | } | ||
66 | mRunning = run; | ||
67 | if ( mRunning ) { | ||
68 | mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min | ||
69 | mRunStart = QDateTime::currentDateTime(); | ||
70 | } else { | ||
71 | mRunSaveTimer->stop(); | ||
72 | saveRunningInfoToFile(); | ||
73 | } | ||
74 | } | ||
51 | 75 | ||
76 | void Todo::saveRunningInfoToFile() | ||
77 | { | ||
78 | qDebug("Todo::saveRunningInfoToFile() "); | ||
52 | } | 79 | } |
53 | 80 | ||
81 | int Todo::runTime() | ||
82 | { | ||
83 | if ( !mRunning ) | ||
84 | return 0; | ||
85 | return mRunStart.secsTo( QDateTime::currentDateTime() ); | ||
86 | } | ||
87 | bool Todo::hasRunningSub() | ||
88 | { | ||
89 | if ( mRunning ) | ||
90 | return true; | ||
91 | Incidence *aTodo; | ||
92 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | ||
93 | if ( ((Todo*)aTodo)->hasRunningSub() ) | ||
94 | return true; | ||
95 | } | ||
96 | return false; | ||
97 | } | ||
54 | Incidence *Todo::clone() | 98 | Incidence *Todo::clone() |
55 | { | 99 | { |
56 | return new Todo(*this); | 100 | return new Todo(*this); |
57 | } | 101 | } |
58 | 102 | ||
59 | bool Todo::contains ( Todo* from ) | 103 | bool Todo::contains ( Todo* from ) |
60 | { | 104 | { |
61 | 105 | ||
62 | if ( !from->summary().isEmpty() ) | 106 | if ( !from->summary().isEmpty() ) |
63 | if ( !summary().startsWith( from->summary() )) | 107 | if ( !summary().startsWith( from->summary() )) |
64 | return false; | 108 | return false; |
65 | if ( from->hasStartDate() ) { | 109 | if ( from->hasStartDate() ) { |
66 | if ( !hasStartDate() ) | 110 | if ( !hasStartDate() ) |
67 | return false; | 111 | return false; |
68 | if ( from->dtStart() != dtStart()) | 112 | if ( from->dtStart() != dtStart()) |
69 | return false; | 113 | return false; |
70 | } | 114 | } |
71 | if ( from->hasDueDate() ){ | 115 | if ( from->hasDueDate() ){ |
72 | if ( !hasDueDate() ) | 116 | if ( !hasDueDate() ) |
73 | return false; | 117 | return false; |
74 | if ( from->dtDue() != dtDue()) | 118 | if ( from->dtDue() != dtDue()) |
75 | return false; | 119 | return false; |
76 | } | 120 | } |
77 | if ( !from->location().isEmpty() ) | 121 | if ( !from->location().isEmpty() ) |
78 | if ( !location().startsWith( from->location() ) ) | 122 | if ( !location().startsWith( from->location() ) ) |
79 | return false; | 123 | return false; |
80 | if ( !from->description().isEmpty() ) | 124 | if ( !from->description().isEmpty() ) |
81 | if ( !description().startsWith( from->description() )) | 125 | if ( !description().startsWith( from->description() )) |
82 | return false; | 126 | return false; |
83 | if ( from->alarms().count() ) { | 127 | if ( from->alarms().count() ) { |
84 | Alarm *a = from->alarms().first(); | 128 | Alarm *a = from->alarms().first(); |
85 | if ( a->enabled() ){ | 129 | if ( a->enabled() ){ |
86 | if ( !alarms().count() ) | 130 | if ( !alarms().count() ) |
87 | return false; | 131 | return false; |
88 | Alarm *b = alarms().first(); | 132 | Alarm *b = alarms().first(); |
89 | if( ! b->enabled() ) | 133 | if( ! b->enabled() ) |
90 | return false; | 134 | return false; |
91 | if ( ! (a->offset() == b->offset() )) | 135 | if ( ! (a->offset() == b->offset() )) |
92 | return false; | 136 | return false; |
93 | } | 137 | } |
94 | } | 138 | } |
95 | 139 | ||
96 | QStringList cat = categories(); | 140 | QStringList cat = categories(); |
97 | QStringList catFrom = from->categories(); | 141 | QStringList catFrom = from->categories(); |
98 | QString nCat; | 142 | QString nCat; |
99 | unsigned int iii; | 143 | unsigned int iii; |
100 | for ( iii = 0; iii < catFrom.count();++iii ) { | 144 | for ( iii = 0; iii < catFrom.count();++iii ) { |
101 | nCat = catFrom[iii]; | 145 | nCat = catFrom[iii]; |
102 | if ( !nCat.isEmpty() ) | 146 | if ( !nCat.isEmpty() ) |
103 | if ( !cat.contains( nCat )) { | 147 | if ( !cat.contains( nCat )) { |
104 | return false; | 148 | return false; |
105 | } | 149 | } |
106 | } | 150 | } |
107 | if ( from->isCompleted() ) { | 151 | if ( from->isCompleted() ) { |
108 | if ( !isCompleted() ) | 152 | if ( !isCompleted() ) |
109 | return false; | 153 | return false; |
110 | } | 154 | } |
111 | if( priority() != from->priority() ) | 155 | if( priority() != from->priority() ) |
112 | return false; | 156 | return false; |
113 | 157 | ||
114 | 158 | ||
115 | return true; | 159 | return true; |
116 | 160 | ||
117 | } | 161 | } |
118 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 162 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
119 | { | 163 | { |
120 | 164 | ||
121 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 165 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
122 | if ( ! ret ) | 166 | if ( ! ret ) |
123 | return false; | 167 | return false; |
124 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 168 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
125 | if ( t1.hasDueDate() ) { | 169 | if ( t1.hasDueDate() ) { |
126 | if ( t1.doesFloat() == t2.doesFloat() ) { | 170 | if ( t1.doesFloat() == t2.doesFloat() ) { |
127 | if ( t1.doesFloat() ) { | 171 | if ( t1.doesFloat() ) { |
128 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 172 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
129 | return false; | 173 | return false; |
130 | } else | 174 | } else |
131 | if ( t1.dtDue() != t2.dtDue() ) | 175 | if ( t1.dtDue() != t2.dtDue() ) |
132 | return false; | 176 | return false; |
133 | } else | 177 | } else |
134 | return false;// float != | 178 | return false;// float != |
135 | } | 179 | } |
136 | 180 | ||
137 | } else | 181 | } else |
138 | return false; | 182 | return false; |
139 | if ( t1.percentComplete() != t2.percentComplete() ) | 183 | if ( t1.percentComplete() != t2.percentComplete() ) |
140 | return false; | 184 | return false; |
141 | if ( t1.isCompleted() ) { | 185 | if ( t1.isCompleted() ) { |
142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 186 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
143 | if ( t1.hasCompletedDate() ) { | 187 | if ( t1.hasCompletedDate() ) { |
144 | if ( t1.completed() != t2.completed() ) | 188 | if ( t1.completed() != t2.completed() ) |
145 | return false; | 189 | return false; |
146 | } | 190 | } |
147 | 191 | ||
148 | } else | 192 | } else |
149 | return false; | 193 | return false; |