summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoviewitem.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 347d982..ead8628 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -69,313 +69,313 @@ void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w,
69 int y,int h) 69 int y,int h)
70{ 70{
71 QListViewItem::paintBranches(p,cg,w,y,h); 71 QListViewItem::paintBranches(p,cg,w,y,h);
72} 72}
73#else 73#else
74#endif 74#endif
75 75
76void KOTodoViewItem::construct() 76void KOTodoViewItem::construct()
77{ 77{
78 // qDebug("KOTodoViewItem::construct() "); 78 // qDebug("KOTodoViewItem::construct() ");
79 m_init = true; 79 m_init = true;
80 QString keyd = "=="; 80 QString keyd = "==";
81 QString keyt = "=="; 81 QString keyt = "==";
82 QString skeyd = "=="; 82 QString skeyd = "==";
83 QString skeyt = "=="; 83 QString skeyt = "==";
84 84
85 setOn(mTodo->isCompleted()); 85 setOn(mTodo->isCompleted());
86 setText(0,mTodo->summary()); 86 setText(0,mTodo->summary());
87 setText(1,QString::number(mTodo->priority())); 87 setText(1,QString::number(mTodo->priority()));
88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
89 if (mTodo->percentComplete()<100) { 89 if (mTodo->percentComplete()<100) {
90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
91 else setSortKey(2,QString::number(mTodo->percentComplete())); 91 else setSortKey(2,QString::number(mTodo->percentComplete()));
92 } 92 }
93 else { 93 else {
94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
95 else setSortKey(2,QString::number(99)); 95 else setSortKey(2,QString::number(99));
96 } 96 }
97 if (mTodo->hasDueDate()) { 97 if (mTodo->hasDueDate()) {
98 setText(3, mTodo->dtDueDateStr()); 98 setText(3, mTodo->dtDueDateStr());
99 QDate d = mTodo->dtDue().date(); 99 QDate d = mTodo->dtDue().date();
100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
101 // setSortKey(3,keyd); 101 // setSortKey(3,keyd);
102 if (mTodo->doesFloat()) { 102 if (mTodo->doesFloat()) {
103 setText(4,""); 103 setText(4,"");
104 } 104 }
105 else { 105 else {
106 setText(4,mTodo->dtDueTimeStr()); 106 setText(4,mTodo->dtDueTimeStr());
107 QTime t = mTodo->dtDue().time(); 107 QTime t = mTodo->dtDue().time();
108 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 108 keyt.sprintf("%02d%02d",t.hour(),t.minute());
109 //setSortKey(4,keyt); 109 //setSortKey(4,keyt);
110 } 110 }
111 } else { 111 } else {
112 setText(3,""); 112 setText(3,"");
113 setText(4,""); 113 setText(4,"");
114 } 114 }
115 setSortKey(3,keyd); 115 setSortKey(3,keyd);
116 setSortKey(4,keyt); 116 setSortKey(4,keyt);
117 117
118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); 118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
120 120
121 121
122 122
123 if (mTodo->hasStartDate()) { 123 if (mTodo->hasStartDate()) {
124 setText(5, mTodo->dtStartDateStr()); 124 setText(5, mTodo->dtStartDateStr());
125 QDate d = mTodo->dtStart().date(); 125 QDate d = mTodo->dtStart().date();
126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
127 127
128 if (mTodo->doesFloat()) { 128 if (mTodo->doesFloat()) {
129 setText(6,""); 129 setText(6,"");
130 } 130 }
131 else { 131 else {
132 setText(6,mTodo->dtStartTimeStr()); 132 setText(6,mTodo->dtStartTimeStr());
133 QTime t = mTodo->dtStart().time(); 133 QTime t = mTodo->dtStart().time();
134 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 134 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
135 135
136 } 136 }
137 } else { 137 } else {
138 setText(5,""); 138 setText(5,"");
139 setText(6,""); 139 setText(6,"");
140 } 140 }
141 setSortKey(5,skeyd); 141 setSortKey(5,skeyd);
142 setSortKey(6,skeyt); 142 setSortKey(6,skeyt);
143 143
144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
145 setText(8,mTodo->categoriesStr()); 145 setText(8,mTodo->categoriesStr());
146 146
147#if 0 147#if 0
148 // Find sort id in description. It's the text behind the last '#' character 148 // Find sort id in description. It's the text behind the last '#' character
149 // found in the description. White spaces are removed from beginning and end 149 // found in the description. White spaces are removed from beginning and end
150 // of sort id. 150 // of sort id.
151 int pos = mTodo->description().findRev('#'); 151 int pos = mTodo->description().findRev('#');
152 if (pos < 0) { 152 if (pos < 0) {
153 setText(6,""); 153 setText(6,"");
154 } else { 154 } else {
155 QString str = mTodo->description().mid(pos+1); 155 QString str = mTodo->description().mid(pos+1);
156 str.stripWhiteSpace(); 156 str.stripWhiteSpace();
157 setText(6,str); 157 setText(6,str);
158 } 158 }
159#endif 159#endif
160 160
161 m_known = false; 161 m_known = false;
162 m_init = false; 162 m_init = false;
163 163
164 setMyPixmap(); 164 setMyPixmap();
165 165
166} 166}
167void KOTodoViewItem::setMyPixmap() 167void KOTodoViewItem::setMyPixmap()
168{ 168{
169 int size = 5; 169 int size = 5;
170 QPixmap pixi = QPixmap( 1, 1 ); 170 QPixmap pixi = QPixmap( 1, 1 );
171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
172// pixi = SmallIcon("redcross16"); 172// pixi = SmallIcon("redcross16");
173// } else { 173// } else {
174 QPainter p; 174 QPainter p;
175 175
176 int pixSize = 0; 176 int pixSize = 0;
177 QPixmap pPix = QPixmap( size, size ); 177 QPixmap pPix = QPixmap( size, size );
178 if ( mTodo->description().length() > 0 ) { 178 if ( mTodo->description().length() > 0 ) {
179 pixi.resize(size, pixSize+size); 179 pixi.resize(size, pixSize+size);
180 pPix.fill( Qt::darkGreen ); 180 pPix.fill( Qt::darkGreen );
181 p.begin( &pixi ); 181 p.begin( &pixi );
182 p. drawPixmap ( 0, pixSize, pPix); 182 p. drawPixmap ( 0, pixSize, pPix);
183 p.end(); 183 p.end();
184 pixSize += size; 184 pixSize += size;
185 } 185 }
186 if ( mTodo->isAlarmEnabled() ) { 186 if ( mTodo->isAlarmEnabled() ) {
187 pixi.resize(size, pixSize+size); 187 pixi.resize(size, pixSize+size);
188 pPix.fill( Qt::red ); 188 pPix.fill( Qt::red );
189 p.begin( &pixi ); 189 p.begin( &pixi );
190 p. drawPixmap ( 0, pixSize, pPix); 190 p. drawPixmap ( 0, pixSize, pPix);
191 p.end(); 191 p.end();
192 pixSize += size; 192 pixSize += size;
193 } 193 }
194 // } 194 // }
195 if ( pixi.width() > 1 ) { 195 if ( pixi.width() > 1 ) {
196 setPixmap ( 0,pixi ) ; 196 setPixmap ( 0,pixi ) ;
197 } else {
198 setPixmap ( 0,QPixmap() ) ;
197 } 199 }
198
199
200} 200}
201void KOTodoViewItem::stateChange(bool state) 201void KOTodoViewItem::stateChange(bool state)
202{ 202{
203 // qDebug("KOTodoViewItem::stateChange "); 203 // qDebug("KOTodoViewItem::stateChange ");
204 // do not change setting on startup 204 // do not change setting on startup
205 if ( m_init ) return; 205 if ( m_init ) return;
206 206
207 kdDebug() << "State changed, modified " << state << endl; 207 kdDebug() << "State changed, modified " << state << endl;
208 QString keyd = "=="; 208 QString keyd = "==";
209 QString keyt = "=="; 209 QString keyt = "==";
210 210
211 if (state) mTodo->setCompleted(state); 211 if (state) mTodo->setCompleted(state);
212 else mTodo->setPercentComplete(0); 212 else mTodo->setPercentComplete(0);
213 if (isOn()!=state) { 213 if (isOn()!=state) {
214 setOn(state); 214 setOn(state);
215 } 215 }
216 216
217 if (mTodo->hasDueDate()) { 217 if (mTodo->hasDueDate()) {
218 setText(3, mTodo->dtDueDateStr()); 218 setText(3, mTodo->dtDueDateStr());
219 QDate d = mTodo->dtDue().date(); 219 QDate d = mTodo->dtDue().date();
220 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 220 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
221 setSortKey(3,keyd); 221 setSortKey(3,keyd);
222 if (mTodo->doesFloat()) { 222 if (mTodo->doesFloat()) {
223 setText(4,""); 223 setText(4,"");
224 } 224 }
225 else { 225 else {
226 setText(4,mTodo->dtDueTimeStr()); 226 setText(4,mTodo->dtDueTimeStr());
227 QTime t = mTodo->dtDue().time(); 227 QTime t = mTodo->dtDue().time();
228 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 228 keyt.sprintf("%02d%02d",t.hour(),t.minute());
229 setSortKey(4,keyt); 229 setSortKey(4,keyt);
230 } 230 }
231 } 231 }
232 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 232 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
233 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 233 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
234 234
235 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 235 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
236 if (mTodo->percentComplete()<100) { 236 if (mTodo->percentComplete()<100) {
237 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 237 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
238 else setSortKey(2,QString::number(mTodo->percentComplete())); 238 else setSortKey(2,QString::number(mTodo->percentComplete()));
239 } 239 }
240 else { 240 else {
241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
242 else setSortKey(2,QString::number(99)); 242 else setSortKey(2,QString::number(99));
243 } 243 }
244 QListViewItem * myChild = firstChild(); 244 QListViewItem * myChild = firstChild();
245 KOTodoViewItem *item; 245 KOTodoViewItem *item;
246 while( myChild ) { 246 while( myChild ) {
247 item = static_cast<KOTodoViewItem*>(myChild); 247 item = static_cast<KOTodoViewItem*>(myChild);
248 item->stateChange(state); 248 item->stateChange(state);
249 myChild = myChild->nextSibling(); 249 myChild = myChild->nextSibling();
250 } 250 }
251 mTodoView->modified(true); 251 mTodoView->modified(true);
252 mTodoView->setTodoModified( mTodo );
253 setMyPixmap(); 252 setMyPixmap();
253 mTodoView->setTodoModified( mTodo );
254} 254}
255 255
256bool KOTodoViewItem::isAlternate() 256bool KOTodoViewItem::isAlternate()
257{ 257{
258#ifndef KORG_NOLVALTERNATION 258#ifndef KORG_NOLVALTERNATION
259 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 259 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
260 if (lv && lv->alternateBackground().isValid()) 260 if (lv && lv->alternateBackground().isValid())
261 { 261 {
262 KOTodoViewItem *above = 0; 262 KOTodoViewItem *above = 0;
263 above = dynamic_cast<KOTodoViewItem *>(itemAbove()); 263 above = dynamic_cast<KOTodoViewItem *>(itemAbove());
264 m_known = above ? above->m_known : true; 264 m_known = above ? above->m_known : true;
265 if (m_known) 265 if (m_known)
266 { 266 {
267 m_odd = above ? !above->m_odd : false; 267 m_odd = above ? !above->m_odd : false;
268 } 268 }
269 else 269 else
270 { 270 {
271 KOTodoViewItem *item; 271 KOTodoViewItem *item;
272 bool previous = true; 272 bool previous = true;
273 if (QListViewItem::parent()) 273 if (QListViewItem::parent())
274 { 274 {
275 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); 275 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent());
276 if (item) 276 if (item)
277 previous = item->m_odd; 277 previous = item->m_odd;
278 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 278 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
279 } 279 }
280 else 280 else
281 { 281 {
282 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); 282 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild());
283 } 283 }
284 284
285 while(item) 285 while(item)
286 { 286 {
287 item->m_odd = previous = !previous; 287 item->m_odd = previous = !previous;
288 item->m_known = true; 288 item->m_known = true;
289 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); 289 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling());
290 } 290 }
291 } 291 }
292 return m_odd; 292 return m_odd;
293 } 293 }
294 return false; 294 return false;
295#else 295#else
296 return false; 296 return false;
297#endif 297#endif
298} 298}
299 299
300void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 300void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
301{ 301{
302 QColorGroup _cg = cg; 302 QColorGroup _cg = cg;
303 QColorGroup::ColorRole role; 303 QColorGroup::ColorRole role;
304 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) 304 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
305 role = QColorGroup::Text; 305 role = QColorGroup::Text;
306 else 306 else
307 role = QColorGroup::Base; 307 role = QColorGroup::Base;
308 //#ifndef KORG_NOLVALTERNATION 308 //#ifndef KORG_NOLVALTERNATION
309 // if (isAlternate()) 309 // if (isAlternate())
310 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 310 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
311 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 311 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
312 QColor colorToSet; 312 QColor colorToSet;
313 if ( setColor ) { 313 if ( setColor ) {
314 QStringList categories = mTodo->categories(); 314 QStringList categories = mTodo->categories();
315 QString cat = categories.first(); 315 QString cat = categories.first();
316 if ( !cat.isEmpty()) { 316 if ( !cat.isEmpty()) {
317 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 317 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
318 } else 318 } else
319 setColor = false; 319 setColor = false;
320 } 320 }
321 if (mTodo->hasDueDate()) { 321 if (mTodo->hasDueDate()) {
322 if (mTodo->dtDue().date()==QDate::currentDate() && 322 if (mTodo->dtDue().date()==QDate::currentDate() &&
323 !mTodo->isCompleted()) { 323 !mTodo->isCompleted()) {
324 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); 324 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor);
325 colorToSet = KOPrefs::instance()->mTodoDueTodayColor; 325 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
326 setColor = true; 326 setColor = true;
327 } 327 }
328 if (mTodo->dtDue().date() < QDate::currentDate() && 328 if (mTodo->dtDue().date() < QDate::currentDate() &&
329 !mTodo->isCompleted()) { 329 !mTodo->isCompleted()) {
330 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor); 330 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor);
331 colorToSet = KOPrefs::instance()->mTodoOverdueColor; 331 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
332 setColor = true; 332 setColor = true;
333 } 333 }
334 } 334 }
335 335
336 if ( setColor ) { 336 if ( setColor ) {
337 _cg.setColor(role,colorToSet ); 337 _cg.setColor(role,colorToSet );
338 if ( role == QColorGroup::Base) { 338 if ( role == QColorGroup::Base) {
339 int rgb = colorToSet.red(); 339 int rgb = colorToSet.red();
340 rgb += colorToSet.blue()/2; 340 rgb += colorToSet.blue()/2;
341 rgb += colorToSet.green(); 341 rgb += colorToSet.green();
342 if ( rgb < 200 ) 342 if ( rgb < 200 )
343 _cg.setColor(QColorGroup::Text,Qt::white ); 343 _cg.setColor(QColorGroup::Text,Qt::white );
344 } 344 }
345 } 345 }
346 //#endif 346 //#endif
347 if ( column > 0 ){ 347 if ( column > 0 ){
348 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { 348 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) {
349 p->save(); 349 p->save();
350 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); 350 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5);
351 351
352 p->fillRect( 0, 0, width, height(), _cg.base() ); // background 352 p->fillRect( 0, 0, width, height(), _cg.base() ); // background
353 // p->setPen(Qt::black ); //border 353 // p->setPen(Qt::black ); //border
354 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling 354 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling
355 QColor fc = KOPrefs::instance()->mHighlightColor; 355 QColor fc = KOPrefs::instance()->mHighlightColor;
356 if ( mTodo->percentComplete() == 100 ) 356 if ( mTodo->percentComplete() == 100 )
357 fc = darkGreen; 357 fc = darkGreen;
358 p->drawRect( 2, 2, width-4, height()-4); 358 p->drawRect( 2, 2, width-4, height()-4);
359 p->fillRect( 3, 3, progress, height()-6, 359 p->fillRect( 3, 3, progress, height()-6,
360 fc ); 360 fc );
361 p->restore(); 361 p->restore();
362 } else { 362 } else {
363 QCheckListItem::paintCell(p, _cg, column, width, alignment); 363 QCheckListItem::paintCell(p, _cg, column, width, alignment);
364 } 364 }
365 return; 365 return;
366 } 366 }
367 367
368 int align = alignment; 368 int align = alignment;
369 369
370 if ( !p ) 370 if ( !p )
371 return; 371 return;
372 372
373 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); 373 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) );
374 374
375 QListView *lv = listView(); 375 QListView *lv = listView();
376 if ( !lv ) 376 if ( !lv )
377 return; 377 return;
378 int marg = 2;//lv->itemMargin(); 378 int marg = 2;//lv->itemMargin();
379 int r = 0; 379 int r = 0;
380 QCheckListItem::Type myType = QCheckListItem::CheckBox; 380 QCheckListItem::Type myType = QCheckListItem::CheckBox;
381 int BoxSize = 20; 381 int BoxSize = 20;