author | zautrix <zautrix> | 2005-10-24 18:01:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-24 18:01:08 (UTC) |
commit | 9b626f37040b4da2a23cdce2d9241218b84d3d88 (patch) (unidiff) | |
tree | bab5b6f2978610c4be1c105a7c3388337621d7c3 /korganizer | |
parent | ae59704dc0643963d0ed648baf7186b741c3ecb2 (diff) | |
download | kdepimpi-9b626f37040b4da2a23cdce2d9241218b84d3d88.zip kdepimpi-9b626f37040b4da2a23cdce2d9241218b84d3d88.tar.gz kdepimpi-9b626f37040b4da2a23cdce2d9241218b84d3d88.tar.bz2 |
fixx
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 848e9e7..519bb16 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -1,570 +1,579 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <qapp.h> | 22 | #include <qapp.h> |
23 | #include <kglobal.h> | 23 | #include <kglobal.h> |
24 | 24 | ||
25 | #include <kiconloader.h> | 25 | #include <kiconloader.h> |
26 | #include "kotodoviewitem.h" | 26 | #include "kotodoviewitem.h" |
27 | #include "kotodoview.h" | 27 | #include "kotodoview.h" |
28 | #include "koprefs.h" | 28 | #include "koprefs.h" |
29 | 29 | ||
30 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) | 30 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) |
31 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 31 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
32 | { | 32 | { |
33 | construct(); | 33 | construct(); |
34 | } | 34 | } |
35 | 35 | ||
36 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) | 36 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) |
37 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 37 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
38 | { | 38 | { |
39 | construct(); | 39 | construct(); |
40 | } | 40 | } |
41 | 41 | ||
42 | QString KOTodoViewItem::key(int column,bool) const | 42 | QString KOTodoViewItem::key(int column,bool) const |
43 | { | 43 | { |
44 | if ( column == 0 ) | ||
45 | return text(0).lower(); | ||
46 | if ( column == 1 ) { | ||
47 | if ( mTodo->isCompleted() ) { | ||
48 | return "6"+QString::number(mTodo->priority())+text(0).lower(); | ||
49 | } | ||
50 | return QString::number(mTodo->priority())+text(0).lower(); | ||
51 | } | ||
44 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | 52 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); |
45 | if (it == mKeyMap.end()) { | 53 | if (it == mKeyMap.end()) { |
46 | return text(column).lower(); | 54 | return text(column).lower(); |
47 | } else { | 55 | } else { |
56 | if ( column == 2 ) { | ||
57 | return *it+text(0).lower(); | ||
58 | } | ||
48 | return *it; | 59 | return *it; |
49 | } | 60 | } |
50 | } | 61 | } |
51 | 62 | ||
52 | void KOTodoViewItem:: setup() | 63 | void KOTodoViewItem:: setup() |
53 | { | 64 | { |
54 | 65 | ||
55 | int h = 20; | 66 | int h = 20; |
56 | if ( listView () ) { | 67 | if ( listView () ) { |
57 | QFontMetrics fm ( listView ()->font () ); | 68 | QFontMetrics fm ( listView ()->font () ); |
58 | h = fm.height(); | 69 | h = fm.height(); |
59 | } | 70 | } |
60 | setHeight( h ); | 71 | setHeight( h ); |
61 | 72 | ||
62 | } | 73 | } |
63 | void KOTodoViewItem::setSortKey(int column,const QString &key) | 74 | void KOTodoViewItem::setSortKey(int column,const QString &key) |
64 | { | 75 | { |
65 | mKeyMap.insert(column,key); | 76 | mKeyMap.insert(column,key); |
66 | } | 77 | } |
67 | 78 | ||
68 | #if QT_VERSION >= 0x030000 | 79 | #if QT_VERSION >= 0x030000 |
69 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, | 80 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, |
70 | int y,int h) | 81 | int y,int h) |
71 | { | 82 | { |
72 | QListViewItem::paintBranches(p,cg,w,y,h); | 83 | QListViewItem::paintBranches(p,cg,w,y,h); |
73 | } | 84 | } |
74 | #else | 85 | #else |
75 | #endif | 86 | #endif |
76 | 87 | ||
77 | void KOTodoViewItem::construct() | 88 | void KOTodoViewItem::construct() |
78 | { | 89 | { |
79 | // qDebug("KOTodoViewItem::construct() "); | 90 | // qDebug("KOTodoViewItem::construct() "); |
80 | m_init = true; | 91 | m_init = true; |
81 | QString keyd = "=="; | 92 | QString keyd = "=="; |
82 | QString keyt = "=="; | 93 | QString keyt = "=="; |
83 | QString skeyd = "=="; | 94 | QString skeyd = "=="; |
84 | QString skeyt = "=="; | 95 | QString skeyt = "=="; |
85 | 96 | ||
86 | setOn(mTodo->isCompleted()); | 97 | setOn(mTodo->isCompleted()); |
87 | setText(0,mTodo->summary()); | 98 | setText(0,mTodo->summary()); |
88 | setText(1,QString::number(mTodo->priority())); | 99 | setText(1,QString::number(mTodo->priority())); |
89 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 100 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
90 | if (mTodo->percentComplete()<100) { | 101 | if (mTodo->percentComplete()<100) { |
91 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 102 | setSortKey(2,QString::number(mTodo->percentComplete())); |
92 | else setSortKey(2,QString::number(mTodo->percentComplete())); | ||
93 | } | 103 | } |
94 | else { | 104 | else { |
95 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 105 | setSortKey(2,"999"); |
96 | else setSortKey(2,QString::number(99)); | ||
97 | } | 106 | } |
98 | if (mTodo->hasDueDate()) { | 107 | if (mTodo->hasDueDate()) { |
99 | setText(3, mTodo->dtDueDateStr()); | 108 | setText(3, mTodo->dtDueDateStr()); |
100 | QDate d = mTodo->dtDue().date(); | 109 | QDate d = mTodo->dtDue().date(); |
101 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 110 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
102 | // setSortKey(3,keyd); | 111 | // setSortKey(3,keyd); |
103 | if (mTodo->doesFloat()) { | 112 | if (mTodo->doesFloat()) { |
104 | setText(4,""); | 113 | setText(4,""); |
105 | } | 114 | } |
106 | else { | 115 | else { |
107 | setText(4,mTodo->dtDueTimeStr()); | 116 | setText(4,mTodo->dtDueTimeStr()); |
108 | QTime t = mTodo->dtDue().time(); | 117 | QTime t = mTodo->dtDue().time(); |
109 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 118 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
110 | //setSortKey(4,keyt); | 119 | //setSortKey(4,keyt); |
111 | } | 120 | } |
112 | } else { | 121 | } else { |
113 | setText(3,""); | 122 | setText(3,""); |
114 | setText(4,""); | 123 | setText(4,""); |
115 | } | 124 | } |
116 | setSortKey(3,keyd); | 125 | setSortKey(3,keyd); |
117 | setSortKey(4,keyt); | 126 | setSortKey(4,keyt); |
118 | 127 | #if 0 | |
119 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); | 128 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); |
120 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 129 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
121 | 130 | #endif | |
122 | keyd = ""; | 131 | keyd = ""; |
123 | keyt = ""; | 132 | keyt = ""; |
124 | 133 | ||
125 | if (mTodo->isRunning() ) { | 134 | if (mTodo->isRunning() ) { |
126 | QDate d = mTodo->runStart().date(); | 135 | QDate d = mTodo->runStart().date(); |
127 | QTime t = mTodo->runStart().time(); | 136 | QTime t = mTodo->runStart().time(); |
128 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 137 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
129 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 138 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
130 | keyd = KGlobal::locale()->formatDate( d , true); | 139 | keyd = KGlobal::locale()->formatDate( d , true); |
131 | keyt = KGlobal::locale()->formatTime( t ); | 140 | keyt = KGlobal::locale()->formatTime( t ); |
132 | 141 | ||
133 | } else { | 142 | } else { |
134 | 143 | ||
135 | if (mTodo->hasStartDate()) { | 144 | if (mTodo->hasStartDate()) { |
136 | keyd = mTodo->dtStartDateStr(); | 145 | keyd = mTodo->dtStartDateStr(); |
137 | QDate d = mTodo->dtStart().date(); | 146 | QDate d = mTodo->dtStart().date(); |
138 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 147 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
139 | 148 | ||
140 | if ( !mTodo->doesFloat()) { | 149 | if ( !mTodo->doesFloat()) { |
141 | keyt = mTodo->dtStartTimeStr(); | 150 | keyt = mTodo->dtStartTimeStr(); |
142 | QTime t = mTodo->dtStart().time(); | 151 | QTime t = mTodo->dtStart().time(); |
143 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 152 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
144 | 153 | ||
145 | } | 154 | } |
146 | 155 | ||
147 | } | 156 | } |
148 | } | 157 | } |
149 | setText(5,keyd); | 158 | setText(5,keyd); |
150 | setText(6,keyt); | 159 | setText(6,keyt); |
151 | setSortKey(5,skeyd); | 160 | setSortKey(5,skeyd); |
152 | setSortKey(6,skeyt); | 161 | setSortKey(6,skeyt); |
153 | 162 | ||
154 | //setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); | 163 | //setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); |
155 | setText(7,mTodo->categoriesStr()); | 164 | setText(7,mTodo->categoriesStr()); |
156 | setText(8,KOPrefs::instance()->calName( mTodo->calID())); | 165 | setText(8,KOPrefs::instance()->calName( mTodo->calID())); |
157 | setText(9, KGlobal::locale()->formatDateTime( mTodo->lastModified(), true, true )); | 166 | setText(9, KGlobal::locale()->formatDateTime( mTodo->lastModified(), true, true )); |
158 | setText(10, KGlobal::locale()->formatDateTime( mTodo->created(), true, true )); | 167 | setText(10, KGlobal::locale()->formatDateTime( mTodo->created(), true, true )); |
159 | setText(11, KGlobal::locale()->formatDateTime( mTodo->lastModifiedSub(), true, true )); | 168 | setText(11, KGlobal::locale()->formatDateTime( mTodo->lastModifiedSub(), true, true )); |
160 | QString key; | 169 | QString key; |
161 | QDate d; | 170 | QDate d; |
162 | QTime t; | 171 | QTime t; |
163 | setSortKey(9,mTodo->lastModifiedSortKey()); | 172 | setSortKey(9,mTodo->lastModifiedSortKey()); |
164 | d = mTodo->created().date(); | 173 | d = mTodo->created().date(); |
165 | t = mTodo->created().time(); | 174 | t = mTodo->created().time(); |
166 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); | 175 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); |
167 | setSortKey(10,key); | 176 | setSortKey(10,key); |
168 | setSortKey(11,mTodo->lastModifiedSubSortKey()); | 177 | setSortKey(11,mTodo->lastModifiedSubSortKey()); |
169 | 178 | ||
170 | #if 0 | 179 | #if 0 |
171 | // Find sort id in description. It's the text behind the last '#' character | 180 | // Find sort id in description. It's the text behind the last '#' character |
172 | // found in the description. White spaces are removed from beginning and end | 181 | // found in the description. White spaces are removed from beginning and end |
173 | // of sort id. | 182 | // of sort id. |
174 | int pos = mTodo->description().findRev('#'); | 183 | int pos = mTodo->description().findRev('#'); |
175 | if (pos < 0) { | 184 | if (pos < 0) { |
176 | setText(6,""); | 185 | setText(6,""); |
177 | } else { | 186 | } else { |
178 | QString str = mTodo->description().mid(pos+1); | 187 | QString str = mTodo->description().mid(pos+1); |
179 | str.stripWhiteSpace(); | 188 | str.stripWhiteSpace(); |
180 | setText(6,str); | 189 | setText(6,str); |
181 | } | 190 | } |
182 | #endif | 191 | #endif |
183 | 192 | ||
184 | m_known = false; | 193 | m_known = false; |
185 | m_init = false; | 194 | m_init = false; |
186 | 195 | ||
187 | setMyPixmap(); | 196 | setMyPixmap(); |
188 | 197 | ||
189 | } | 198 | } |
190 | void KOTodoViewItem::setMyPixmap() | 199 | void KOTodoViewItem::setMyPixmap() |
191 | { | 200 | { |
192 | int size = 5; | 201 | int size = 5; |
193 | QPixmap pixi = QPixmap( 1, 1 ); | 202 | QPixmap pixi = QPixmap( 1, 1 ); |
194 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 203 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
195 | // pixi = SmallIcon("redcross16"); | 204 | // pixi = SmallIcon("redcross16"); |
196 | // } else { | 205 | // } else { |
197 | QPainter p; | 206 | QPainter p; |
198 | 207 | ||
199 | int pixSize = 0; | 208 | int pixSize = 0; |
200 | QPixmap pPix = QPixmap( size, size ); | 209 | QPixmap pPix = QPixmap( size, size ); |
201 | if ( mTodo->description().length() > 0 ) { | 210 | if ( mTodo->description().length() > 0 ) { |
202 | pixi.resize(size, pixSize+size); | 211 | pixi.resize(size, pixSize+size); |
203 | pPix.fill( Qt::darkGreen ); | 212 | pPix.fill( Qt::darkGreen ); |
204 | p.begin( &pixi ); | 213 | p.begin( &pixi ); |
205 | p. drawPixmap ( 0, pixSize, pPix); | 214 | p. drawPixmap ( 0, pixSize, pPix); |
206 | p.end(); | 215 | p.end(); |
207 | pixSize += size; | 216 | pixSize += size; |
208 | } | 217 | } |
209 | if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { | 218 | if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { |
210 | pixi.resize(size, pixSize+size); | 219 | pixi.resize(size, pixSize+size); |
211 | pPix.fill( Qt::red ); | 220 | pPix.fill( Qt::red ); |
212 | p.begin( &pixi ); | 221 | p.begin( &pixi ); |
213 | p. drawPixmap ( 0, pixSize, pPix); | 222 | p. drawPixmap ( 0, pixSize, pPix); |
214 | p.end(); | 223 | p.end(); |
215 | pixSize += size; | 224 | pixSize += size; |
216 | } | 225 | } |
217 | if ( mTodo->doesRecur() ) { | 226 | if ( mTodo->doesRecur() ) { |
218 | pixi.resize(size, pixSize+size); | 227 | pixi.resize(size, pixSize+size); |
219 | pPix.fill( Qt::blue ); | 228 | pPix.fill( Qt::blue ); |
220 | p.begin( &pixi ); | 229 | p.begin( &pixi ); |
221 | p. drawPixmap ( 0, pixSize, pPix); | 230 | p. drawPixmap ( 0, pixSize, pPix); |
222 | p.end(); | 231 | p.end(); |
223 | pixSize += size; | 232 | pixSize += size; |
224 | } | 233 | } |
225 | // } | 234 | // } |
226 | if ( pixi.width() > 1 ) { | 235 | if ( pixi.width() > 1 ) { |
227 | setPixmap ( 0,pixi ) ; | 236 | setPixmap ( 0,pixi ) ; |
228 | } else { | 237 | } else { |
229 | setPixmap ( 0,QPixmap() ) ; | 238 | setPixmap ( 0,QPixmap() ) ; |
230 | } | 239 | } |
231 | } | 240 | } |
232 | void KOTodoViewItem::stateChange(bool state) | 241 | void KOTodoViewItem::stateChange(bool state) |
233 | { | 242 | { |
234 | // qDebug("KOTodoViewItem::stateChange %d ", state); | 243 | // qDebug("KOTodoViewItem::stateChange %d ", state); |
235 | // do not change setting on startup | 244 | // do not change setting on startup |
236 | if ( m_init ) return; | 245 | if ( m_init ) return; |
237 | if (isOn()!=state) { | 246 | if (isOn()!=state) { |
238 | setOn(state); | 247 | setOn(state); |
239 | //qDebug("SETON "); | 248 | //qDebug("SETON "); |
240 | return; | 249 | return; |
241 | } | 250 | } |
242 | if ( mTodo->isCompleted() == state ) { | 251 | if ( mTodo->isCompleted() == state ) { |
243 | //qDebug("STATECHANGE:nothing to do "); | 252 | //qDebug("STATECHANGE:nothing to do "); |
244 | return; | 253 | return; |
245 | } | 254 | } |
246 | QString keyd = "=="; | 255 | QString keyd = "=="; |
247 | QString keyt = "=="; | 256 | QString keyt = "=="; |
248 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); | 257 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); |
249 | if ( mTodo->doesRecur() ){ | 258 | if ( mTodo->doesRecur() ){ |
250 | QDateTime start = mTodo->dtStart(); | 259 | QDateTime start = mTodo->dtStart(); |
251 | mTodo->setCompleted(state); | 260 | mTodo->setCompleted(state); |
252 | if ( start != mTodo->dtStart() ) { | 261 | if ( start != mTodo->dtStart() ) { |
253 | if ( state && !mTodo->isCompleted() ) { | 262 | if ( state && !mTodo->isCompleted() ) { |
254 | setOn( false ); | 263 | setOn( false ); |
255 | state = false; | 264 | state = false; |
256 | } | 265 | } |
257 | } | 266 | } |
258 | } else | 267 | } else |
259 | mTodo->setCompleted(state); | 268 | mTodo->setCompleted(state); |
260 | 269 | ||
261 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); | 270 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); |
262 | 271 | ||
263 | if (mTodo->hasDueDate()) { | 272 | if (mTodo->hasDueDate()) { |
264 | setText(3, mTodo->dtDueDateStr()); | 273 | setText(3, mTodo->dtDueDateStr()); |
265 | QDate d = mTodo->dtDue().date(); | 274 | QDate d = mTodo->dtDue().date(); |
266 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 275 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
267 | setSortKey(3,keyd); | 276 | setSortKey(3,keyd); |
268 | if (mTodo->doesFloat()) { | 277 | if (mTodo->doesFloat()) { |
269 | setText(4,""); | 278 | setText(4,""); |
270 | } | 279 | } |
271 | else { | 280 | else { |
272 | setText(4,mTodo->dtDueTimeStr()); | 281 | setText(4,mTodo->dtDueTimeStr()); |
273 | QTime t = mTodo->dtDue().time(); | 282 | QTime t = mTodo->dtDue().time(); |
274 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 283 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
275 | setSortKey(4,keyt); | 284 | setSortKey(4,keyt); |
276 | } | 285 | } |
277 | } | 286 | } |
278 | if (mTodo->hasStartDate()) { | 287 | if (mTodo->hasStartDate()) { |
279 | QString skeyt = "=="; | 288 | QString skeyt = "=="; |
280 | QString skeyd = "=="; | 289 | QString skeyd = "=="; |
281 | setText(5, mTodo->dtStartDateStr()); | 290 | setText(5, mTodo->dtStartDateStr()); |
282 | QDate d = mTodo->dtStart().date(); | 291 | QDate d = mTodo->dtStart().date(); |
283 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 292 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
284 | 293 | ||
285 | if (mTodo->doesFloat()) { | 294 | if (mTodo->doesFloat()) { |
286 | setText(6,""); | 295 | setText(6,""); |
287 | } | 296 | } |
288 | else { | 297 | else { |
289 | setText(6,mTodo->dtStartTimeStr()); | 298 | setText(6,mTodo->dtStartTimeStr()); |
290 | QTime t = mTodo->dtStart().time(); | 299 | QTime t = mTodo->dtStart().time(); |
291 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 300 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
292 | 301 | ||
293 | } | 302 | } |
294 | setSortKey(5,skeyd); | 303 | setSortKey(5,skeyd); |
295 | setSortKey(6,skeyt); | 304 | setSortKey(6,skeyt); |
296 | } | 305 | } |
297 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 306 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
298 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 307 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
299 | 308 | ||
300 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 309 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
301 | if (mTodo->percentComplete()<100) { | 310 | if (mTodo->percentComplete()<100) { |
302 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 311 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
303 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 312 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
304 | } | 313 | } |
305 | else { | 314 | else { |
306 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 315 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
307 | else setSortKey(2,QString::number(99)); | 316 | else setSortKey(2,QString::number(99)); |
308 | } | 317 | } |
309 | if ( state ) { | 318 | if ( state ) { |
310 | QListViewItem * myChild = firstChild(); | 319 | QListViewItem * myChild = firstChild(); |
311 | KOTodoViewItem *item; | 320 | KOTodoViewItem *item; |
312 | while( myChild ) { | 321 | while( myChild ) { |
313 | //qDebug("stateCH "); | 322 | //qDebug("stateCH "); |
314 | item = static_cast<KOTodoViewItem*>(myChild); | 323 | item = static_cast<KOTodoViewItem*>(myChild); |
315 | item->stateChange(state); | 324 | item->stateChange(state); |
316 | myChild = myChild->nextSibling(); | 325 | myChild = myChild->nextSibling(); |
317 | } | 326 | } |
318 | } else { | 327 | } else { |
319 | QListViewItem * myChild = parent(); | 328 | QListViewItem * myChild = parent(); |
320 | if ( myChild ) | 329 | if ( myChild ) |
321 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); | 330 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); |
322 | } | 331 | } |
323 | mTodoView->modified(true); | 332 | mTodoView->modified(true); |
324 | setMyPixmap(); | 333 | setMyPixmap(); |
325 | mTodoView->setTodoModified( mTodo ); | 334 | mTodoView->setTodoModified( mTodo ); |
326 | } | 335 | } |
327 | 336 | ||
328 | bool KOTodoViewItem::isAlternate() | 337 | bool KOTodoViewItem::isAlternate() |
329 | { | 338 | { |
330 | #if 0 | 339 | #if 0 |
331 | //if ( m_known ) return m_odd; | 340 | //if ( m_known ) return m_odd; |
332 | //qDebug("test "); | 341 | //qDebug("test "); |
333 | KOTodoViewItem *item = static_cast<KOTodoViewItem *>(itemAbove()); | 342 | KOTodoViewItem *item = static_cast<KOTodoViewItem *>(itemAbove()); |
334 | if ( item ) { | 343 | if ( item ) { |
335 | m_known = item->m_known; | 344 | m_known = item->m_known; |
336 | if ( m_known ) { | 345 | if ( m_known ) { |
337 | m_odd = !item->m_odd ; | 346 | m_odd = !item->m_odd ; |
338 | return m_odd; | 347 | return m_odd; |
339 | } | 348 | } |
340 | } else { | 349 | } else { |
341 | item = static_cast<KOTodoViewItem *>(itemBelow()); | 350 | item = static_cast<KOTodoViewItem *>(itemBelow()); |
342 | if ( item ) { | 351 | if ( item ) { |
343 | m_known = item->m_known; | 352 | m_known = item->m_known; |
344 | if ( m_known ) { | 353 | if ( m_known ) { |
345 | m_odd = !item->m_odd ; | 354 | m_odd = !item->m_odd ; |
346 | return m_odd; | 355 | return m_odd; |
347 | } | 356 | } |
348 | } | 357 | } |
349 | } | 358 | } |
350 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 359 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
351 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); | 360 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); |
352 | bool previous = true; | 361 | bool previous = true; |
353 | qDebug("WHILE "); | 362 | qDebug("WHILE "); |
354 | while ( item ) { | 363 | while ( item ) { |
355 | item->m_odd = !previous; | 364 | item->m_odd = !previous; |
356 | item->m_known = true; | 365 | item->m_known = true; |
357 | previous = !previous; | 366 | previous = !previous; |
358 | item = static_cast<KOTodoViewItem *>(item->itemBelow()); | 367 | item = static_cast<KOTodoViewItem *>(item->itemBelow()); |
359 | } | 368 | } |
360 | return m_odd; | 369 | return m_odd; |
361 | 370 | ||
362 | #else | 371 | #else |
363 | 372 | ||
364 | //KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 373 | //KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
365 | //if (lv && lv->alternateBackground().isValid()) | 374 | //if (lv && lv->alternateBackground().isValid()) |
366 | { | 375 | { |
367 | KOTodoViewItem *above = static_cast<KOTodoViewItem *>(itemAbove()); | 376 | KOTodoViewItem *above = static_cast<KOTodoViewItem *>(itemAbove()); |
368 | m_known = above ? above->m_known : true; | 377 | m_known = above ? above->m_known : true; |
369 | if (m_known) | 378 | if (m_known) |
370 | { | 379 | { |
371 | m_odd = above ? !above->m_odd : false; | 380 | m_odd = above ? !above->m_odd : false; |
372 | } | 381 | } |
373 | else | 382 | else |
374 | { | 383 | { |
375 | KOTodoViewItem *item; | 384 | KOTodoViewItem *item; |
376 | bool previous = true; | 385 | bool previous = true; |
377 | if (QListViewItem::parent()) | 386 | if (QListViewItem::parent()) |
378 | { | 387 | { |
379 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); | 388 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); |
380 | if (item) | 389 | if (item) |
381 | previous = item->m_odd; | 390 | previous = item->m_odd; |
382 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); | 391 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); |
383 | } | 392 | } |
384 | else | 393 | else |
385 | { | 394 | { |
386 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 395 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
387 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); | 396 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); |
388 | } | 397 | } |
389 | 398 | ||
390 | while(item) | 399 | while(item) |
391 | { | 400 | { |
392 | item->m_odd = previous = !previous; | 401 | item->m_odd = previous = !previous; |
393 | item->m_known = true; | 402 | item->m_known = true; |
394 | item = static_cast<KOTodoViewItem *>(item->nextSibling()); | 403 | item = static_cast<KOTodoViewItem *>(item->nextSibling()); |
395 | } | 404 | } |
396 | } | 405 | } |
397 | return m_odd; | 406 | return m_odd; |
398 | } | 407 | } |
399 | return false; | 408 | return false; |
400 | #endif | 409 | #endif |
401 | } | 410 | } |
402 | 411 | ||
403 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 412 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
404 | { | 413 | { |
405 | QColorGroup _cg = cg; | 414 | QColorGroup _cg = cg; |
406 | QColorGroup::ColorRole role; | 415 | QColorGroup::ColorRole role; |
407 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning()) | 416 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning()) |
408 | role = QColorGroup::Text; | 417 | role = QColorGroup::Text; |
409 | else | 418 | else |
410 | role = QColorGroup::Base; | 419 | role = QColorGroup::Base; |
411 | //#ifndef KORG_NOLVALTERNATION | 420 | //#ifndef KORG_NOLVALTERNATION |
412 | if (isAlternate()) | 421 | if (isAlternate()) |
413 | _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); | 422 | _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); |
414 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; | 423 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; |
415 | QColor colorToSet; | 424 | QColor colorToSet; |
416 | if ( column == 0 && mTodo->calID() > 1 ) { | 425 | if ( column == 0 && mTodo->calID() > 1 ) { |
417 | setColor = true; | 426 | setColor = true; |
418 | colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() ); | 427 | colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() ); |
419 | } else if ( setColor ) { | 428 | } else if ( setColor ) { |
420 | QStringList categories = mTodo->categories(); | 429 | QStringList categories = mTodo->categories(); |
421 | QString cat = categories.first(); | 430 | QString cat = categories.first(); |
422 | if ( !cat.isEmpty()) { | 431 | if ( !cat.isEmpty()) { |
423 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); | 432 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); |
424 | } else | 433 | } else |
425 | setColor = false; | 434 | setColor = false; |
426 | } | 435 | } |
427 | bool openMode = !isOpen(); | 436 | bool openMode = !isOpen(); |
428 | // maybe we are in flat-display-mode | 437 | // maybe we are in flat-display-mode |
429 | if ( !firstChild() ) | 438 | if ( !firstChild() ) |
430 | openMode = false; | 439 | openMode = false; |
431 | bool colorRunning = mTodo->isRunning(); | 440 | bool colorRunning = mTodo->isRunning(); |
432 | if ( ! colorRunning && openMode ) | 441 | if ( ! colorRunning && openMode ) |
433 | colorRunning = mTodo->hasRunningSub(); | 442 | colorRunning = mTodo->hasRunningSub(); |
434 | if ( colorRunning ) { | 443 | if ( colorRunning ) { |
435 | setColor = true; | 444 | setColor = true; |
436 | colorToSet = KOPrefs::instance()->mTodoRunColor; | 445 | colorToSet = KOPrefs::instance()->mTodoRunColor; |
437 | } else { | 446 | } else { |
438 | int odue = mTodo->hasDueSubTodo( openMode ); | 447 | int odue = mTodo->hasDueSubTodo( openMode ); |
439 | if (odue == 2) { | 448 | if (odue == 2) { |
440 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; | 449 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; |
441 | setColor = true; | 450 | setColor = true; |
442 | } else if ( odue == 1 ) { | 451 | } else if ( odue == 1 ) { |
443 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; | 452 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; |
444 | setColor = true; | 453 | setColor = true; |
445 | } | 454 | } |
446 | } | 455 | } |
447 | 456 | ||
448 | 457 | ||
449 | if ( setColor ) { | 458 | if ( setColor ) { |
450 | _cg.setColor(role,colorToSet ); | 459 | _cg.setColor(role,colorToSet ); |
451 | if ( role == QColorGroup::Base) { | 460 | if ( role == QColorGroup::Base) { |
452 | int rgb = colorToSet.red(); | 461 | int rgb = colorToSet.red(); |
453 | rgb += colorToSet.blue()/2; | 462 | rgb += colorToSet.blue()/2; |
454 | rgb += colorToSet.green(); | 463 | rgb += colorToSet.green(); |
455 | if ( rgb < 200 ) | 464 | if ( rgb < 200 ) |
456 | _cg.setColor(QColorGroup::Text,Qt::white ); | 465 | _cg.setColor(QColorGroup::Text,Qt::white ); |
457 | } | 466 | } |
458 | } | 467 | } |
459 | //#endif | 468 | //#endif |
460 | if ( column > 0 ){ | 469 | if ( column > 0 ){ |
461 | if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { | 470 | if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { |
462 | p->save(); | 471 | p->save(); |
463 | int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); | 472 | int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); |
464 | 473 | ||
465 | p->fillRect( 0, 0, width, height(), _cg.base() ); // background | 474 | p->fillRect( 0, 0, width, height(), _cg.base() ); // background |
466 | // p->setPen(Qt::black ); //border | 475 | // p->setPen(Qt::black ); //border |
467 | // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling | 476 | // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling |
468 | QColor fc = KOPrefs::instance()->mHighlightColor; | 477 | QColor fc = KOPrefs::instance()->mHighlightColor; |
469 | if ( mTodo->percentComplete() == 100 ) | 478 | if ( mTodo->percentComplete() == 100 ) |
470 | fc = darkGreen; | 479 | fc = darkGreen; |
471 | p->drawRect( 2, 2, width-4, height()-4); | 480 | p->drawRect( 2, 2, width-4, height()-4); |
472 | p->fillRect( 3, 3, progress, height()-6, | 481 | p->fillRect( 3, 3, progress, height()-6, |
473 | fc ); | 482 | fc ); |
474 | p->restore(); | 483 | p->restore(); |
475 | } else { | 484 | } else { |
476 | QCheckListItem::paintCell(p, _cg, column, width, alignment); | 485 | QCheckListItem::paintCell(p, _cg, column, width, alignment); |
477 | } | 486 | } |
478 | return; | 487 | return; |
479 | } | 488 | } |
480 | 489 | ||
481 | int align = alignment; | 490 | int align = alignment; |
482 | 491 | ||
483 | if ( !p ) | 492 | if ( !p ) |
484 | return; | 493 | return; |
485 | 494 | ||
486 | p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); | 495 | p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); |
487 | 496 | ||
488 | QListView *lv = listView(); | 497 | QListView *lv = listView(); |
489 | if ( !lv ) | 498 | if ( !lv ) |
490 | return; | 499 | return; |
491 | int marg = 2;//lv->itemMargin(); | 500 | int marg = 2;//lv->itemMargin(); |
492 | int r = 0; | 501 | int r = 0; |
493 | QCheckListItem::Type myType = QCheckListItem::CheckBox; | 502 | QCheckListItem::Type myType = QCheckListItem::CheckBox; |
494 | int BoxSize = 20; | 503 | int BoxSize = 20; |
495 | int boxOffset = 2; | 504 | int boxOffset = 2; |
496 | int xOffset = 2; | 505 | int xOffset = 2; |
497 | if (qApp->desktop()->width() < 300 ) { | 506 | if (qApp->desktop()->width() < 300 ) { |
498 | BoxSize = 14; | 507 | BoxSize = 14; |
499 | boxOffset = -1; | 508 | boxOffset = -1; |
500 | xOffset = 1; | 509 | xOffset = 1; |
501 | // marg = 0; | 510 | // marg = 0; |
502 | } | 511 | } |
503 | if ( height() < BoxSize ) { | 512 | if ( height() < BoxSize ) { |
504 | boxOffset = boxOffset - ((BoxSize - height())/2) ; | 513 | boxOffset = boxOffset - ((BoxSize - height())/2) ; |
505 | // qDebug("boxOffset %d height %d", boxOffset, height() ); | 514 | // qDebug("boxOffset %d height %d", boxOffset, height() ); |
506 | BoxSize = height(); | 515 | BoxSize = height(); |
507 | 516 | ||
508 | } | 517 | } |
509 | //bool winStyle = lv->style() == WindowsStyle; | 518 | //bool winStyle = lv->style() == WindowsStyle; |
510 | 519 | ||
511 | int lineStart = 5; | 520 | int lineStart = 5; |
512 | if ( myType == Controller ) { | 521 | if ( myType == Controller ) { |
513 | if ( !pixmap( 0 ) ) | 522 | if ( !pixmap( 0 ) ) |
514 | r += BoxSize + 4; | 523 | r += BoxSize + 4; |
515 | } else { | 524 | } else { |
516 | ASSERT( lv ); //### | 525 | ASSERT( lv ); //### |
517 | //QFontMetrics fm( lv->font() ); | 526 | //QFontMetrics fm( lv->font() ); |
518 | //int d = fm.height(); | 527 | //int d = fm.height(); |
519 | int x = 0; | 528 | int x = 0; |
520 | int y = (height() - BoxSize) / 2; | 529 | int y = (height() - BoxSize) / 2; |
521 | //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); | 530 | //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); |
522 | if ( myType == CheckBox ) { | 531 | if ( myType == CheckBox ) { |
523 | if ( isEnabled() ) | 532 | if ( isEnabled() ) |
524 | p->setPen( QPen( _cg.text(), 1 ) ); | 533 | p->setPen( QPen( _cg.text(), 1 ) ); |
525 | else | 534 | else |
526 | p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); | 535 | p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); |
527 | p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); | 536 | p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); |
528 | lineStart = x+marg; | 537 | lineStart = x+marg; |
529 | ///////////////////// | 538 | ///////////////////// |
530 | x++; | 539 | x++; |
531 | y++; | 540 | y++; |
532 | if ( isOn() ) { | 541 | if ( isOn() ) { |
533 | QPointArray a( 7*2 ); | 542 | QPointArray a( 7*2 ); |
534 | int i, xx, yy; | 543 | int i, xx, yy; |
535 | xx = x+xOffset+marg+(boxOffset/2); | 544 | xx = x+xOffset+marg+(boxOffset/2); |
536 | yy = y+5+boxOffset; | 545 | yy = y+5+boxOffset; |
537 | for ( i=0; i<3; i++ ) { | 546 | for ( i=0; i<3; i++ ) { |
538 | a.setPoint( 2*i, xx, yy ); | 547 | a.setPoint( 2*i, xx, yy ); |
539 | a.setPoint( 2*i+1, xx, yy+2 ); | 548 | a.setPoint( 2*i+1, xx, yy+2 ); |
540 | // qDebug(" "); | 549 | // qDebug(" "); |
541 | xx++; yy++; | 550 | xx++; yy++; |
542 | } | 551 | } |
543 | yy -= 2; | 552 | yy -= 2; |
544 | for ( i=3; i<7; i++ ) { | 553 | for ( i=3; i<7; i++ ) { |
545 | a.setPoint( 2*i, xx, yy ); | 554 | a.setPoint( 2*i, xx, yy ); |
546 | a.setPoint( 2*i+1, xx, yy+2 ); | 555 | a.setPoint( 2*i+1, xx, yy+2 ); |
547 | xx++; yy--; | 556 | xx++; yy--; |
548 | } | 557 | } |
549 | p->setPen( darkGreen ); | 558 | p->setPen( darkGreen ); |
550 | p->drawLineSegments( a ); | 559 | p->drawLineSegments( a ); |
551 | } | 560 | } |
552 | //////////////////////// | 561 | //////////////////////// |
553 | } | 562 | } |
554 | r += BoxSize + 4; | 563 | r += BoxSize + 4; |
555 | } | 564 | } |
556 | 565 | ||
557 | p->translate( r, 0 ); | 566 | p->translate( r, 0 ); |
558 | p->setPen( QPen( _cg.text() ) ); | 567 | p->setPen( QPen( _cg.text() ) ); |
559 | QListViewItem::paintCell( p, _cg, column, width - r, align ); | 568 | QListViewItem::paintCell( p, _cg, column, width - r, align ); |
560 | if ( mTodo->cancelled () ) { | 569 | if ( mTodo->cancelled () ) { |
561 | p->setPen( black ); | 570 | p->setPen( black ); |
562 | QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); | 571 | QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); |
563 | int wid = br.width() +lineStart; | 572 | int wid = br.width() +lineStart; |
564 | if ( wid > width-3 ) | 573 | if ( wid > width-3 ) |
565 | wid = width-3; | 574 | wid = width-3; |
566 | p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); | 575 | p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); |
567 | 576 | ||
568 | } | 577 | } |
569 | 578 | ||
570 | } | 579 | } |