summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-21 15:38:31 (UTC)
committer zautrix <zautrix>2005-01-21 15:38:31 (UTC)
commit4afdcfcac216b428ada79f4750cf7447e3175333 (patch) (unidiff)
tree8f70936ac23137c3f6fb00fce33edbfe3d821f59 /korganizer
parent234b9425bebd41b556277cdd94138fafecc32b45 (diff)
downloadkdepimpi-4afdcfcac216b428ada79f4750cf7447e3175333.zip
kdepimpi-4afdcfcac216b428ada79f4750cf7447e3175333.tar.gz
kdepimpi-4afdcfcac216b428ada79f4750cf7447e3175333.tar.bz2
some fixes
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
@@ -1,457 +1,457 @@
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 23
24#include <kiconloader.h> 24#include <kiconloader.h>
25#include "kotodoviewitem.h" 25#include "kotodoviewitem.h"
26#include "kotodoview.h" 26#include "kotodoview.h"
27#include "koprefs.h" 27#include "koprefs.h"
28 28
29KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) 29KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo)
30 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 30 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
31{ 31{
32 construct(); 32 construct();
33} 33}
34 34
35KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) 35KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo )
36 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 36 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
37{ 37{
38 construct(); 38 construct();
39} 39}
40 40
41QString KOTodoViewItem::key(int column,bool) const 41QString KOTodoViewItem::key(int column,bool) const
42{ 42{
43 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 43 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
44 if (it == mKeyMap.end()) { 44 if (it == mKeyMap.end()) {
45 return text(column).lower(); 45 return text(column).lower();
46 } else { 46 } else {
47 return *it; 47 return *it;
48 } 48 }
49} 49}
50 50
51void KOTodoViewItem:: setup() 51void KOTodoViewItem:: setup()
52{ 52{
53 53
54 int h = 20; 54 int h = 20;
55 if ( listView () ) { 55 if ( listView () ) {
56 QFontMetrics fm ( listView ()->font () ); 56 QFontMetrics fm ( listView ()->font () );
57 h = fm.height(); 57 h = fm.height();
58 } 58 }
59 setHeight( h ); 59 setHeight( h );
60 60
61} 61}
62void KOTodoViewItem::setSortKey(int column,const QString &key) 62void KOTodoViewItem::setSortKey(int column,const QString &key)
63{ 63{
64 mKeyMap.insert(column,key); 64 mKeyMap.insert(column,key);
65} 65}
66 66
67#if QT_VERSION >= 300 67#if QT_VERSION >= 300
68void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, 68void 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;
382 int boxOffset = 2; 382 int boxOffset = 2;
383 int xOffset = 2; 383 int xOffset = 2;
384 if (qApp->desktop()->width() < 300 ) { 384 if (qApp->desktop()->width() < 300 ) {
385 BoxSize = 14; 385 BoxSize = 14;
386 boxOffset = -1; 386 boxOffset = -1;
387 xOffset = 1; 387 xOffset = 1;
388 // marg = 0; 388 // marg = 0;
389 } 389 }
390 if ( height() < BoxSize ) { 390 if ( height() < BoxSize ) {
391 boxOffset = boxOffset - ((BoxSize - height())/2) ; 391 boxOffset = boxOffset - ((BoxSize - height())/2) ;
392 // qDebug("boxOffset %d height %d", boxOffset, height() ); 392 // qDebug("boxOffset %d height %d", boxOffset, height() );
393 BoxSize = height(); 393 BoxSize = height();
394 394
395 } 395 }
396 //bool winStyle = lv->style() == WindowsStyle; 396 //bool winStyle = lv->style() == WindowsStyle;
397 397
398 int lineStart = 5; 398 int lineStart = 5;
399 if ( myType == Controller ) { 399 if ( myType == Controller ) {
400 if ( !pixmap( 0 ) ) 400 if ( !pixmap( 0 ) )
401 r += BoxSize + 4; 401 r += BoxSize + 4;
402 } else { 402 } else {
403 ASSERT( lv ); //### 403 ASSERT( lv ); //###
404 //QFontMetrics fm( lv->font() ); 404 //QFontMetrics fm( lv->font() );
405 //int d = fm.height(); 405 //int d = fm.height();
406 int x = 0; 406 int x = 0;
407 int y = (height() - BoxSize) / 2; 407 int y = (height() - BoxSize) / 2;
408 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); 408 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) );
409 if ( myType == CheckBox ) { 409 if ( myType == CheckBox ) {
410 if ( isEnabled() ) 410 if ( isEnabled() )
411 p->setPen( QPen( _cg.text(), 1 ) ); 411 p->setPen( QPen( _cg.text(), 1 ) );
412 else 412 else
413 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); 413 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) );
414 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); 414 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
415 lineStart = x+marg; 415 lineStart = x+marg;
416 ///////////////////// 416 /////////////////////
417 x++; 417 x++;
418 y++; 418 y++;
419 if ( isOn() ) { 419 if ( isOn() ) {
420 QPointArray a( 7*2 ); 420 QPointArray a( 7*2 );
421 int i, xx, yy; 421 int i, xx, yy;
422 xx = x+xOffset+marg+(boxOffset/2); 422 xx = x+xOffset+marg+(boxOffset/2);
423 yy = y+5+boxOffset; 423 yy = y+5+boxOffset;
424 for ( i=0; i<3; i++ ) { 424 for ( i=0; i<3; i++ ) {
425 a.setPoint( 2*i, xx, yy ); 425 a.setPoint( 2*i, xx, yy );
426 a.setPoint( 2*i+1, xx, yy+2 ); 426 a.setPoint( 2*i+1, xx, yy+2 );
427 // qDebug(" "); 427 // qDebug(" ");
428 xx++; yy++; 428 xx++; yy++;
429 } 429 }
430 yy -= 2; 430 yy -= 2;
431 for ( i=3; i<7; i++ ) { 431 for ( i=3; i<7; i++ ) {
432 a.setPoint( 2*i, xx, yy ); 432 a.setPoint( 2*i, xx, yy );
433 a.setPoint( 2*i+1, xx, yy+2 ); 433 a.setPoint( 2*i+1, xx, yy+2 );
434 xx++; yy--; 434 xx++; yy--;
435 } 435 }
436 p->setPen( darkGreen ); 436 p->setPen( darkGreen );
437 p->drawLineSegments( a ); 437 p->drawLineSegments( a );
438 } 438 }
439 //////////////////////// 439 ////////////////////////
440 } 440 }
441 r += BoxSize + 4; 441 r += BoxSize + 4;
442 } 442 }
443 443
444 p->translate( r, 0 ); 444 p->translate( r, 0 );
445 p->setPen( QPen( _cg.text() ) ); 445 p->setPen( QPen( _cg.text() ) );
446 QListViewItem::paintCell( p, _cg, column, width - r, align ); 446 QListViewItem::paintCell( p, _cg, column, width - r, align );
447 if ( mTodo->cancelled () ) { 447 if ( mTodo->cancelled () ) {
448 p->setPen( black ); 448 p->setPen( black );
449 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); 449 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() );
450 int wid = br.width() +lineStart; 450 int wid = br.width() +lineStart;
451 if ( wid > width-3 ) 451 if ( wid > width-3 )
452 wid = width-3; 452 wid = width-3;
453 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); 453 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 );
454 454
455 } 455 }
456 456
457} 457}