summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp18
-rw-r--r--korganizer/kotodoviewitem.cpp4
2 files changed, 13 insertions, 9 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 9812321..ca896b5 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -1,630 +1,630 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4 Parts of the source code have been copied from kdpdatebutton.cpp 4 Parts of the source code have been copied from kdpdatebutton.cpp
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source ode for Qt in the source distribution. 22 without including the source ode for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qevent.h> 25#include <qevent.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28#include <qtimer.h> 28#include <qtimer.h>
29 29
30#include <kglobal.h> 30#include <kglobal.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <klocale.h> 32#include <klocale.h>
33 33
34#include <libkcal/vcaldrag.h> 34#include <libkcal/vcaldrag.h>
35#include <libkcal/icaldrag.h> 35#include <libkcal/icaldrag.h>
36#include <libkcal/dndfactory.h> 36#include <libkcal/dndfactory.h>
37#include <libkcal/calendarresources.h> 37#include <libkcal/calendarresources.h>
38#include <libkcal/resourcecalendar.h> 38#include <libkcal/resourcecalendar.h>
39#include <kresources/resourceselectdialog.h> 39#include <kresources/resourceselectdialog.h>
40 40
41#include <kcalendarsystem.h> 41#include <kcalendarsystem.h>
42 42
43#ifndef KORG_NOPLUGINS 43#ifndef KORG_NOPLUGINS
44#include "kocore.h" 44#include "kocore.h"
45#endif 45#endif
46#include "koprefs.h" 46#include "koprefs.h"
47#include "koglobals.h" 47#include "koglobals.h"
48 48
49#include "kodaymatrix.h" 49#include "kodaymatrix.h"
50 50
51// ============================================================================ 51// ============================================================================
52// D Y N A M I C T I P 52// D Y N A M I C T I P
53// ============================================================================ 53// ============================================================================
54 54
55DynamicTip::DynamicTip( QWidget * parent ) 55DynamicTip::DynamicTip( QWidget * parent )
56 : QToolTip( parent ) 56 : QToolTip( parent )
57{ 57{
58 matrix = (KODayMatrix*)parent; 58 matrix = (KODayMatrix*)parent;
59} 59}
60 60
61 61
62void DynamicTip::maybeTip( const QPoint &pos ) 62void DynamicTip::maybeTip( const QPoint &pos )
63{ 63{
64 //calculate which cell of the matrix the mouse is in 64 //calculate which cell of the matrix the mouse is in
65 QRect sz = matrix->frameRect(); 65 QRect sz = matrix->frameRect();
66 int dheight = sz.height()*7 / 42; 66 int dheight = sz.height()*7 / 42;
67 int dwidth = sz.width() / 7; 67 int dwidth = sz.width() / 7;
68 int row = pos.y()/dheight; 68 int row = pos.y()/dheight;
69 int col = pos.x()/dwidth; 69 int col = pos.x()/dwidth;
70 70
71 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 71 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
72 72
73// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 73// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
74// col << "][" << row << "] => " <<(col+row*7) << endl; 74// col << "][" << row << "] => " <<(col+row*7) << endl;
75 75
76 //show holiday names only 76 //show holiday names only
77 QString str = matrix->getHolidayLabel(col+row*7); 77 QString str = matrix->getHolidayLabel(col+row*7);
78 if (str.isEmpty()) return; 78 if (str.isEmpty()) return;
79 tip(rct, str); 79 tip(rct, str);
80} 80}
81 81
82 82
83// ============================================================================ 83// ============================================================================
84// K O D A Y M A T R I X 84// K O D A Y M A T R I X
85// ============================================================================ 85// ============================================================================
86 86
87const int KODayMatrix::NOSELECTION = -1000; 87const int KODayMatrix::NOSELECTION = -1000;
88const int KODayMatrix::NUMDAYS = 42; 88const int KODayMatrix::NUMDAYS = 42;
89 89
90KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 90KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
91 QFrame(parent, name) 91 QFrame(parent, name)
92{ 92{
93 mCalendar = calendar; 93 mCalendar = calendar;
94 mPendingUpdateBeforeRepaint = false; 94 mPendingUpdateBeforeRepaint = false;
95 95
96 // initialize dynamic arrays 96 // initialize dynamic arrays
97 days = new QDate[NUMDAYS]; 97 days = new QDate[NUMDAYS];
98 daylbls = new QString[NUMDAYS]; 98 daylbls = new QString[NUMDAYS];
99 events = new int[NUMDAYS]; 99 events = new int[NUMDAYS];
100 mToolTip = new DynamicTip(this); 100 mToolTip = new DynamicTip(this);
101 101
102 // set default values used for drawing the matrix 102 // set default values used for drawing the matrix
103 mDefaultBackColor = palette().active().base(); 103 mDefaultBackColor = palette().active().base();
104 mDefaultTextColor = palette().active().foreground(); 104 mDefaultTextColor = palette().active().foreground();
105 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 105 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
106 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 106 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
107 mSelectedDaysColor = QColor("white"); 107 mSelectedDaysColor = QColor("white");
108 mTodayMarginWidth = 2; 108 mTodayMarginWidth = 2;
109 mSelEnd = mSelStart = NOSELECTION; 109 mSelEnd = mSelStart = NOSELECTION;
110 110
111 setAcceptDrops(true); 111 setAcceptDrops(true);
112 //setFont( QFont("Arial", 10) ); 112 //setFont( QFont("Arial", 10) );
113 113
114 mUpdateTimer = new QTimer( this ); 114 mUpdateTimer = new QTimer( this );
115 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 115 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
116 mRepaintTimer = new QTimer( this ); 116 mRepaintTimer = new QTimer( this );
117 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 117 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
118 mDayChanged = false; 118 mDayChanged = false;
119 updateView(); 119 updateView();
120} 120}
121 121
122QColor KODayMatrix::getShadedColor(QColor color) 122QColor KODayMatrix::getShadedColor(QColor color)
123{ 123{
124 QColor shaded; 124 QColor shaded;
125 int h=0; 125 int h=0;
126 int s=0; 126 int s=0;
127 int v=0; 127 int v=0;
128 color.hsv(&h,&s,&v); 128 color.hsv(&h,&s,&v);
129 s = s/4; 129 s = s/4;
130 v = 192+v/4; 130 v = 192+v/4;
131 shaded.setHsv(h,s,v); 131 shaded.setHsv(h,s,v);
132 132
133 return shaded; 133 return shaded;
134} 134}
135 135
136KODayMatrix::~KODayMatrix() 136KODayMatrix::~KODayMatrix()
137{ 137{
138 delete [] days; 138 delete [] days;
139 delete [] daylbls; 139 delete [] daylbls;
140 delete [] events; 140 delete [] events;
141 delete mToolTip; 141 delete mToolTip;
142} 142}
143 143
144/* 144/*
145void KODayMatrix::setStartDate(QDate start) 145void KODayMatrix::setStartDate(QDate start)
146{ 146{
147 updateView(start); 147 updateView(start);
148} 148}
149*/ 149*/
150 150
151void KODayMatrix::addSelectedDaysTo(DateList& selDays) 151void KODayMatrix::addSelectedDaysTo(DateList& selDays)
152{ 152{
153 153
154 if (mSelStart == NOSELECTION) { 154 if (mSelStart == NOSELECTION) {
155 return; 155 return;
156 } 156 }
157 157
158 //cope with selection being out of matrix limits at top (< 0) 158 //cope with selection being out of matrix limits at top (< 0)
159 int i0 = mSelStart; 159 int i0 = mSelStart;
160 if (i0 < 0) { 160 if (i0 < 0) {
161 for (int i = i0; i < 0; i++) { 161 for (int i = i0; i < 0; i++) {
162 selDays.append(days[0].addDays(i)); 162 selDays.append(days[0].addDays(i));
163 } 163 }
164 i0 = 0; 164 i0 = 0;
165 } 165 }
166 166
167 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 167 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
168 if (mSelEnd > NUMDAYS-1) { 168 if (mSelEnd > NUMDAYS-1) {
169 for (int i = i0; i <= NUMDAYS-1; i++) { 169 for (int i = i0; i <= NUMDAYS-1; i++) {
170 selDays.append(days[i]); 170 selDays.append(days[i]);
171 } 171 }
172 for (int i = NUMDAYS; i < mSelEnd; i++) { 172 for (int i = NUMDAYS; i < mSelEnd; i++) {
173 selDays.append(days[0].addDays(i)); 173 selDays.append(days[0].addDays(i));
174 } 174 }
175 175
176 // apply normal routine to selection being entirely within matrix limits 176 // apply normal routine to selection being entirely within matrix limits
177 } else { 177 } else {
178 for (int i = i0; i <= mSelEnd; i++) { 178 for (int i = i0; i <= mSelEnd; i++) {
179 selDays.append(days[i]); 179 selDays.append(days[i]);
180 } 180 }
181 } 181 }
182} 182}
183 183
184void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 184void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
185{ 185{
186 mSelStart = startdate.daysTo(start); 186 mSelStart = startdate.daysTo(start);
187 mSelEnd = startdate.daysTo(end); 187 mSelEnd = startdate.daysTo(end);
188} 188}
189 189
190 190
191void KODayMatrix::recalculateToday() 191void KODayMatrix::recalculateToday()
192{ 192{
193 today = -1; 193 today = -1;
194 for (int i=0; i<NUMDAYS; i++) { 194 for (int i=0; i<NUMDAYS; i++) {
195 events[i] = 0; 195 events[i] = 0;
196 days[i] = startdate.addDays(i); 196 days[i] = startdate.addDays(i);
197 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 197 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
198 198
199 // if today is in the currently displayed month, hilight today 199 // if today is in the currently displayed month, hilight today
200 if (days[i].year() == QDate::currentDate().year() && 200 if (days[i].year() == QDate::currentDate().year() &&
201 days[i].month() == QDate::currentDate().month() && 201 days[i].month() == QDate::currentDate().month() &&
202 days[i].day() == QDate::currentDate().day()) { 202 days[i].day() == QDate::currentDate().day()) {
203 today = i; 203 today = i;
204 } 204 }
205 } 205 }
206 // qDebug(QString("Today is visible at %1.").arg(today)); 206 // qDebug(QString("Today is visible at %1.").arg(today));
207} 207}
208 208
209void KODayMatrix::updateView() 209void KODayMatrix::updateView()
210{ 210{
211 updateView(startdate); 211 updateView(startdate);
212} 212}
213void KODayMatrix::repaintViewTimed() 213void KODayMatrix::repaintViewTimed()
214{ 214{
215 //qDebug("KODayMatrix::repaintViewTimed "); 215 qDebug("KODayMatrix::repaintViewTimed ");
216 mRepaintTimer->stop(); 216 mRepaintTimer->stop();
217 repaint(false); 217 repaint(false);
218} 218}
219void KODayMatrix::updateViewTimed() 219void KODayMatrix::updateViewTimed()
220{ 220{
221 221
222 mUpdateTimer->stop(); 222 mUpdateTimer->stop();
223 //qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii ); 223 qDebug("KODayMatrix::updateView(QDate actdate)");
224 for(int i = 0; i < NUMDAYS; i++) { 224 for(int i = 0; i < NUMDAYS; i++) {
225 225
226 // if events are set for the day then remember to draw it bold 226 // if events are set for the day then remember to draw it bold
227 QPtrList<Event> eventlist = mCalendar->events(days[i]); 227 QPtrList<Event> eventlist = mCalendar->events(days[i]);
228 Event *event; 228 Event *event;
229 int numEvents = eventlist.count(); 229 int numEvents = eventlist.count();
230 230
231 for(event=eventlist.first();event != 0;event=eventlist.next()) { 231 for(event=eventlist.first();event != 0;event=eventlist.next()) {
232 ushort recurType = event->recurrence()->doesRecur(); 232 ushort recurType = event->recurrence()->doesRecur();
233 233
234 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 234 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
235 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 235 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
236 numEvents--; 236 numEvents--;
237 } 237 }
238 } 238 }
239 events[i] = numEvents; 239 events[i] = numEvents;
240 240
241 //if it is a holy day then draw it red. Sundays are consider holidays, too 241 //if it is a holy day then draw it red. Sundays are consider holidays, too
242#ifndef KORG_NOPLUGINS 242#ifndef KORG_NOPLUGINS
243 QString holiStr = KOCore::self()->holiday(days[i]); 243 QString holiStr = KOCore::self()->holiday(days[i]);
244#else 244#else
245 QString holiStr = QString::null; 245 QString holiStr = QString::null;
246#endif 246#endif
247 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 247 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
248 !holiStr.isEmpty()) { 248 !holiStr.isEmpty()) {
249 if (holiStr.isNull()) holiStr = ""; 249 if (holiStr.isNull()) holiStr = "";
250 mHolidays[i] = holiStr; 250 mHolidays[i] = holiStr;
251 251
252 } else { 252 } else {
253 mHolidays[i] = QString::null; 253 mHolidays[i] = QString::null;
254 } 254 }
255 } 255 }
256 if ( ! mPendingUpdateBeforeRepaint ) 256 if ( ! mPendingUpdateBeforeRepaint )
257 repaint(false); 257 repaint(false);
258 } 258 }
259void KODayMatrix::updateView(QDate actdate) 259void KODayMatrix::updateView(QDate actdate)
260{ 260{
261 261
262 if ( ! actdate.isValid() ) { 262 if ( ! actdate.isValid() ) {
263 //qDebug("date not valid "); 263 //qDebug("date not valid ");
264 return; 264 return;
265 } 265 }
266 mDayChanged = false; 266 mDayChanged = false;
267 //flag to indicate if the starting day of the matrix has changed by this call 267 //flag to indicate if the starting day of the matrix has changed by this call
268 //mDayChanged = false; 268 //mDayChanged = false;
269 // if a new startdate is to be set then apply Cornelius's calculation 269 // if a new startdate is to be set then apply Cornelius's calculation
270 // of the first day to be shown 270 // of the first day to be shown
271 if (actdate != startdate) { 271 if (actdate != startdate) {
272 // reset index of selection according to shift of starting date from startdate to actdate 272 // reset index of selection according to shift of starting date from startdate to actdate
273 if (mSelStart != NOSELECTION) { 273 if (mSelStart != NOSELECTION) {
274 int tmp = actdate.daysTo(startdate); 274 int tmp = actdate.daysTo(startdate);
275 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 275 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
276 // shift selection if new one would be visible at least partly ! 276 // shift selection if new one would be visible at least partly !
277 277
278 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 278 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
279 // nested if is required for next X display pushed from a different month - correction required 279 // nested if is required for next X display pushed from a different month - correction required
280 // otherwise, for month forward and backward, it must be avoided 280 // otherwise, for month forward and backward, it must be avoided
281 if( mSelStart > NUMDAYS || mSelStart < 0 ) 281 if( mSelStart > NUMDAYS || mSelStart < 0 )
282 mSelStart = mSelStart + tmp; 282 mSelStart = mSelStart + tmp;
283 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 283 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
284 mSelEnd = mSelEnd + tmp; 284 mSelEnd = mSelEnd + tmp;
285 } 285 }
286 } 286 }
287 startdate = actdate; 287 startdate = actdate;
288 mDayChanged = true; 288 mDayChanged = true;
289 recalculateToday(); 289 recalculateToday();
290 } 290 }
291 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 291 qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
292 if ( !isVisible() ) { 292 if ( !isVisible() ) {
293 mPendingUpdateBeforeRepaint = true; 293 mPendingUpdateBeforeRepaint = true;
294 } else { 294 } else {
295#ifdef DESKTOP_VERSION 295#ifdef DESKTOP_VERSION
296 mRepaintTimer->start( 250 ); 296 //mRepaintTimer->start( 250 );
297 mUpdateTimer->start( 2000 ); 297 mUpdateTimer->start( 250 );
298#else 298#else
299 mRepaintTimer->start( 350 ); 299 mRepaintTimer->start( 350 );
300 mUpdateTimer->start( 4000 ); 300 mUpdateTimer->start( 2000 );
301#endif 301#endif
302 } 302 }
303} 303}
304 304
305const QDate& KODayMatrix::getDate(int offset) 305const QDate& KODayMatrix::getDate(int offset)
306{ 306{
307 if (offset < 0 || offset > NUMDAYS-1) { 307 if (offset < 0 || offset > NUMDAYS-1) {
308 qDebug("Wrong offset2 "); 308 qDebug("Wrong offset2 ");
309 return days[0]; 309 return days[0];
310 } 310 }
311 return days[offset]; 311 return days[offset];
312} 312}
313 313
314QString KODayMatrix::getHolidayLabel(int offset) 314QString KODayMatrix::getHolidayLabel(int offset)
315{ 315{
316 if (offset < 0 || offset > NUMDAYS-1) { 316 if (offset < 0 || offset > NUMDAYS-1) {
317 qDebug("Wrong offset1 "); 317 qDebug("Wrong offset1 ");
318 return 0; 318 return 0;
319 } 319 }
320 return mHolidays[offset]; 320 return mHolidays[offset];
321} 321}
322 322
323int KODayMatrix::getDayIndexFrom(int x, int y) 323int KODayMatrix::getDayIndexFrom(int x, int y)
324{ 324{
325 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 325 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
326 6 - x/daysize.width() : x/daysize.width()); 326 6 - x/daysize.width() : x/daysize.width());
327} 327}
328 328
329// ---------------------------------------------------------------------------- 329// ----------------------------------------------------------------------------
330// M O U S E E V E N T H A N D L I N G 330// M O U S E E V E N T H A N D L I N G
331// ---------------------------------------------------------------------------- 331// ----------------------------------------------------------------------------
332 332
333void KODayMatrix::mousePressEvent (QMouseEvent* e) 333void KODayMatrix::mousePressEvent (QMouseEvent* e)
334{ 334{
335 mSelStart = getDayIndexFrom(e->x(), e->y()); 335 mSelStart = getDayIndexFrom(e->x(), e->y());
336 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 336 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
337 mSelInit = mSelStart; 337 mSelInit = mSelStart;
338} 338}
339 339
340void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 340void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
341{ 341{
342 342
343 int tmp = getDayIndexFrom(e->x(), e->y()); 343 int tmp = getDayIndexFrom(e->x(), e->y());
344 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 344 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
345 345
346 if (mSelInit > tmp) { 346 if (mSelInit > tmp) {
347 mSelEnd = mSelInit; 347 mSelEnd = mSelInit;
348 if (tmp != mSelStart) { 348 if (tmp != mSelStart) {
349 mSelStart = tmp; 349 mSelStart = tmp;
350 repaint(); 350 repaint();
351 } 351 }
352 } else { 352 } else {
353 mSelStart = mSelInit; 353 mSelStart = mSelInit;
354 354
355 //repaint only if selection has changed 355 //repaint only if selection has changed
356 if (tmp != mSelEnd) { 356 if (tmp != mSelEnd) {
357 mSelEnd = tmp; 357 mSelEnd = tmp;
358 repaint(); 358 repaint();
359 } 359 }
360 } 360 }
361 361
362 DateList daylist; 362 DateList daylist;
363 if ( mSelStart < 0 ) 363 if ( mSelStart < 0 )
364 mSelStart = 0; 364 mSelStart = 0;
365 for (int i = mSelStart; i <= mSelEnd; i++) { 365 for (int i = mSelStart; i <= mSelEnd; i++) {
366 daylist.append(days[i]); 366 daylist.append(days[i]);
367 } 367 }
368 emit selected((const DateList)daylist); 368 emit selected((const DateList)daylist);
369 369
370} 370}
371 371
372void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 372void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
373{ 373{
374 int tmp = getDayIndexFrom(e->x(), e->y()); 374 int tmp = getDayIndexFrom(e->x(), e->y());
375 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 375 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
376 376
377 if (mSelInit > tmp) { 377 if (mSelInit > tmp) {
378 mSelEnd = mSelInit; 378 mSelEnd = mSelInit;
379 if (tmp != mSelStart) { 379 if (tmp != mSelStart) {
380 mSelStart = tmp; 380 mSelStart = tmp;
381 repaint(); 381 repaint();
382 } 382 }
383 } else { 383 } else {
384 mSelStart = mSelInit; 384 mSelStart = mSelInit;
385 385
386 //repaint only if selection has changed 386 //repaint only if selection has changed
387 if (tmp != mSelEnd) { 387 if (tmp != mSelEnd) {
388 mSelEnd = tmp; 388 mSelEnd = tmp;
389 repaint(); 389 repaint();
390 } 390 }
391 } 391 }
392} 392}
393 393
394// ---------------------------------------------------------------------------- 394// ----------------------------------------------------------------------------
395// D R A G ' N D R O P H A N D L I N G 395// D R A G ' N D R O P H A N D L I N G
396// ---------------------------------------------------------------------------- 396// ----------------------------------------------------------------------------
397 397
398void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 398void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
399{ 399{
400#ifndef KORG_NODND 400#ifndef KORG_NODND
401 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 401 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
402 e->ignore(); 402 e->ignore();
403 return; 403 return;
404 } 404 }
405 405
406 // some visual feedback 406 // some visual feedback
407// oldPalette = palette(); 407// oldPalette = palette();
408// setPalette(my_HilitePalette); 408// setPalette(my_HilitePalette);
409// update(); 409// update();
410#endif 410#endif
411} 411}
412 412
413void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 413void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
414{ 414{
415#ifndef KORG_NODND 415#ifndef KORG_NODND
416 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 416 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
417 e->ignore(); 417 e->ignore();
418 return; 418 return;
419 } 419 }
420 420
421 e->accept(); 421 e->accept();
422#endif 422#endif
423} 423}
424 424
425void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 425void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
426{ 426{
427#ifndef KORG_NODND 427#ifndef KORG_NODND
428// setPalette(oldPalette); 428// setPalette(oldPalette);
429// update(); 429// update();
430#endif 430#endif
431} 431}
432 432
433void KODayMatrix::dropEvent(QDropEvent *e) 433void KODayMatrix::dropEvent(QDropEvent *e)
434{ 434{
435#ifndef KORG_NODND 435#ifndef KORG_NODND
436// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 436// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
437 437
438 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 438 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
439 e->ignore(); 439 e->ignore();
440 return; 440 return;
441 } 441 }
442 442
443 DndFactory factory( mCalendar ); 443 DndFactory factory( mCalendar );
444 Event *event = factory.createDrop(e); 444 Event *event = factory.createDrop(e);
445 445
446 if (event) { 446 if (event) {
447 e->acceptAction(); 447 e->acceptAction();
448 448
449 Event *existingEvent = mCalendar->event(event->uid()); 449 Event *existingEvent = mCalendar->event(event->uid());
450 450
451 if(existingEvent) { 451 if(existingEvent) {
452 // uniquify event 452 // uniquify event
453 event->recreate(); 453 event->recreate();
454/* 454/*
455 KMessageBox::sorry(this, 455 KMessageBox::sorry(this,
456 i18n("Event already exists in this calendar."), 456 i18n("Event already exists in this calendar."),
457 i18n("Drop Event")); 457 i18n("Drop Event"));
458 delete event; 458 delete event;
459 return; 459 return;
460*/ 460*/
461 } 461 }
462// kdDebug() << "Drop new Event" << endl; 462// kdDebug() << "Drop new Event" << endl;
463 // Adjust date 463 // Adjust date
464 QDateTime start = event->dtStart(); 464 QDateTime start = event->dtStart();
465 QDateTime end = event->dtEnd(); 465 QDateTime end = event->dtEnd();
466 int duration = start.daysTo(end); 466 int duration = start.daysTo(end);
467 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 467 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
468 468
469 start.setDate(days[idx]); 469 start.setDate(days[idx]);
470 end.setDate(days[idx].addDays(duration)); 470 end.setDate(days[idx].addDays(duration));
471 471
472 event->setDtStart(start); 472 event->setDtStart(start);
473 event->setDtEnd(end); 473 event->setDtEnd(end);
474 mCalendar->addEvent(event); 474 mCalendar->addEvent(event);
475 475
476 emit eventDropped(event); 476 emit eventDropped(event);
477 } else { 477 } else {
478// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 478// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
479 e->ignore(); 479 e->ignore();
480 } 480 }
481#endif 481#endif
482} 482}
483 483
484// ---------------------------------------------------------------------------- 484// ----------------------------------------------------------------------------
485// P A I N T E V E N T H A N D L I N G 485// P A I N T E V E N T H A N D L I N G
486// ---------------------------------------------------------------------------- 486// ----------------------------------------------------------------------------
487 487
488void KODayMatrix::paintEvent(QPaintEvent * pevent) 488void KODayMatrix::paintEvent(QPaintEvent * pevent)
489{ 489{
490//kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl; 490//kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl;
491 if ( mPendingUpdateBeforeRepaint ) { 491 if ( mPendingUpdateBeforeRepaint ) {
492 updateViewTimed(); 492 updateViewTimed();
493 mPendingUpdateBeforeRepaint = false; 493 mPendingUpdateBeforeRepaint = false;
494 } 494 }
495 QPainter p(this); 495 QPainter p(this);
496 496
497 QRect sz = frameRect(); 497 QRect sz = frameRect();
498 int dheight = daysize.height(); 498 int dheight = daysize.height();
499 int dwidth = daysize.width(); 499 int dwidth = daysize.width();
500 int row,col; 500 int row,col;
501 int selw, selh; 501 int selw, selh;
502 bool isRTL = KOGlobals::self()->reverseLayout(); 502 bool isRTL = KOGlobals::self()->reverseLayout();
503 503
504 // draw background and topleft frame 504 // draw background and topleft frame
505 p.fillRect(pevent->rect(), mDefaultBackColor); 505 p.fillRect(pevent->rect(), mDefaultBackColor);
506 p.setPen(mDefaultTextColor); 506 p.setPen(mDefaultTextColor);
507 p.drawRect(0, 0, sz.width()+1, sz.height()+1); 507 p.drawRect(0, 0, sz.width()+1, sz.height()+1);
508 508
509 // draw selected days with highlighted background color 509 // draw selected days with highlighted background color
510 if (mSelStart != NOSELECTION) { 510 if (mSelStart != NOSELECTION) {
511 511
512 row = mSelStart/7; 512 row = mSelStart/7;
513 col = mSelStart -row*7; 513 col = mSelStart -row*7;
514 QColor selcol = KOPrefs::instance()->mHighlightColor; 514 QColor selcol = KOPrefs::instance()->mHighlightColor;
515 515
516 if (row == mSelEnd/7) { 516 if (row == mSelEnd/7) {
517 // Single row selection 517 // Single row selection
518 p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, 518 p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth,
519 row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); 519 row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol);
520 } else { 520 } else {
521 // draw first row to the right 521 // draw first row to the right
522 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, 522 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth,
523 dheight, selcol); 523 dheight, selcol);
524 // draw full block till last line 524 // draw full block till last line
525 selh = mSelEnd/7-row; 525 selh = mSelEnd/7-row;
526 if (selh > 1) { 526 if (selh > 1) {
527 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); 527 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol);
528 } 528 }
529 // draw last block from left to mSelEnd 529 // draw last block from left to mSelEnd
530 selw = mSelEnd-7*(mSelEnd/7)+1; 530 selw = mSelEnd-7*(mSelEnd/7)+1;
531 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, 531 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight,
532 selw*dwidth, dheight, selcol); 532 selw*dwidth, dheight, selcol);
533 } 533 }
534 } 534 }
535 535
536 // iterate over all days in the matrix and draw the day label in appropriate colors 536 // iterate over all days in the matrix and draw the day label in appropriate colors
537 QColor actcol = mDefaultTextColorShaded; 537 QColor actcol = mDefaultTextColorShaded;
538 p.setPen(actcol); 538 p.setPen(actcol);
539 QPen tmppen; 539 QPen tmppen;
540 for(int i = 0; i < NUMDAYS; i++) { 540 for(int i = 0; i < NUMDAYS; i++) {
541 row = i/7; 541 row = i/7;
542 col = isRTL ? 6-(i-row*7) : i-row*7; 542 col = isRTL ? 6-(i-row*7) : i-row*7;
543 543
544 // if it is the first day of a month switch color from normal to shaded and vice versa 544 // if it is the first day of a month switch color from normal to shaded and vice versa
545 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 545 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
546 if (actcol == mDefaultTextColorShaded) { 546 if (actcol == mDefaultTextColorShaded) {
547 actcol = mDefaultTextColor; 547 actcol = mDefaultTextColor;
548 } else { 548 } else {
549 actcol = mDefaultTextColorShaded; 549 actcol = mDefaultTextColorShaded;
550 } 550 }
551 p.setPen(actcol); 551 p.setPen(actcol);
552 } 552 }
553 553
554 //Reset pen color after selected days block 554 //Reset pen color after selected days block
555 if (i == mSelEnd+1) { 555 if (i == mSelEnd+1) {
556 p.setPen(actcol); 556 p.setPen(actcol);
557 } 557 }
558 558
559 // if today then draw rectangle around day 559 // if today then draw rectangle around day
560 if (today == i) { 560 if (today == i) {
561 tmppen = p.pen(); 561 tmppen = p.pen();
562 QPen mTodayPen(p.pen()); 562 QPen mTodayPen(p.pen());
563 563
564 mTodayPen.setWidth(mTodayMarginWidth); 564 mTodayPen.setWidth(mTodayMarginWidth);
565 //draw red rectangle for holidays 565 //draw red rectangle for holidays
566 if (!mHolidays[i].isNull()) { 566 if (!mHolidays[i].isNull()) {
567 if (actcol == mDefaultTextColor) { 567 if (actcol == mDefaultTextColor) {
568 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 568 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
569 } else { 569 } else {
570 mTodayPen.setColor(mHolidayColorShaded); 570 mTodayPen.setColor(mHolidayColorShaded);
571 } 571 }
572 } 572 }
573 //draw gray rectangle for today if in selection 573 //draw gray rectangle for today if in selection
574 if (i >= mSelStart && i <= mSelEnd) { 574 if (i >= mSelStart && i <= mSelEnd) {
575 QColor grey("grey"); 575 QColor grey("grey");
576 mTodayPen.setColor(grey); 576 mTodayPen.setColor(grey);
577 } 577 }
578 p.setPen(mTodayPen); 578 p.setPen(mTodayPen);
579 p.drawRect(col*dwidth, row*dheight, dwidth, dheight); 579 p.drawRect(col*dwidth, row*dheight, dwidth, dheight);
580 p.setPen(tmppen); 580 p.setPen(tmppen);
581 } 581 }
582 582
583 // if any events are on that day then draw it using a bold font 583 // if any events are on that day then draw it using a bold font
584 if (events[i] > 0) { 584 if (events[i] > 0) {
585 QFont myFont = font(); 585 QFont myFont = font();
586 myFont.setBold(true); 586 myFont.setBold(true);
587 p.setFont(myFont); 587 p.setFont(myFont);
588 } 588 }
589 589
590 // if it is a holiday then use the default holiday color 590 // if it is a holiday then use the default holiday color
591 if (!mHolidays[i].isNull()) { 591 if (!mHolidays[i].isNull()) {
592 if (actcol == mDefaultTextColor) { 592 if (actcol == mDefaultTextColor) {
593 p.setPen(KOPrefs::instance()->mHolidayColor); 593 p.setPen(KOPrefs::instance()->mHolidayColor);
594 } else { 594 } else {
595 p.setPen(mHolidayColorShaded); 595 p.setPen(mHolidayColorShaded);
596 } 596 }
597 } 597 }
598 598
599 // draw selected days with special color 599 // draw selected days with special color
600 // DO NOT specially highlight holidays in selection ! 600 // DO NOT specially highlight holidays in selection !
601 if (i >= mSelStart && i <= mSelEnd) { 601 if (i >= mSelStart && i <= mSelEnd) {
602 p.setPen(mSelectedDaysColor); 602 p.setPen(mSelectedDaysColor);
603 } 603 }
604 604
605 p.drawText(col*dwidth, row*dheight, dwidth, dheight, 605 p.drawText(col*dwidth, row*dheight, dwidth, dheight,
606 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 606 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
607 607
608 // reset color to actual color 608 // reset color to actual color
609 if (!mHolidays[i].isNull()) { 609 if (!mHolidays[i].isNull()) {
610 p.setPen(actcol); 610 p.setPen(actcol);
611 } 611 }
612 // reset bold font to plain font 612 // reset bold font to plain font
613 if (events[i] > 0) { 613 if (events[i] > 0) {
614 QFont myFont = font(); 614 QFont myFont = font();
615 myFont.setBold(false); 615 myFont.setBold(false);
616 p.setFont(myFont); 616 p.setFont(myFont);
617 } 617 }
618 } 618 }
619} 619}
620 620
621// ---------------------------------------------------------------------------- 621// ----------------------------------------------------------------------------
622// R E SI Z E E V E N T H A N D L I N G 622// R E SI Z E E V E N T H A N D L I N G
623// ---------------------------------------------------------------------------- 623// ----------------------------------------------------------------------------
624 624
625void KODayMatrix::resizeEvent(QResizeEvent *) 625void KODayMatrix::resizeEvent(QResizeEvent *)
626{ 626{
627 QRect sz = frameRect(); 627 QRect sz = frameRect();
628 daysize.setHeight(sz.height()*7 / NUMDAYS); 628 daysize.setHeight(sz.height()*7 / NUMDAYS);
629 daysize.setWidth(sz.width() / 7); 629 daysize.setWidth(sz.width() / 7);
630} 630}
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 1edddac..6bdee18 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -1,464 +1,468 @@
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 >= 0x030000 67#if QT_VERSION >= 0x030000
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 { 197 } else {
198 setPixmap ( 0,QPixmap() ) ; 198 setPixmap ( 0,QPixmap() ) ;
199 } 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 if (isOn()!=state) { 206 if (isOn()!=state) {
207 setOn(state); 207 setOn(state);
208 //qDebug("SETON "); 208 //qDebug("SETON ");
209 return; 209 return;
210 } 210 }
211 if ( mTodo->isCompleted() == state ) {
212 //qDebug("STATECHANGE:nothing to do ");
213 return;
214 }
211 QString keyd = "=="; 215 QString keyd = "==";
212 QString keyt = "=="; 216 QString keyt = "==";
213 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); 217 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1());
214 mTodo->setCompleted(state); 218 mTodo->setCompleted(state);
215 if (state) mTodo->setCompleted(QDateTime::currentDateTime()); 219 if (state) mTodo->setCompleted(QDateTime::currentDateTime());
216 220
217 if (mTodo->hasDueDate()) { 221 if (mTodo->hasDueDate()) {
218 setText(3, mTodo->dtDueDateStr()); 222 setText(3, mTodo->dtDueDateStr());
219 QDate d = mTodo->dtDue().date(); 223 QDate d = mTodo->dtDue().date();
220 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 224 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
221 setSortKey(3,keyd); 225 setSortKey(3,keyd);
222 if (mTodo->doesFloat()) { 226 if (mTodo->doesFloat()) {
223 setText(4,""); 227 setText(4,"");
224 } 228 }
225 else { 229 else {
226 setText(4,mTodo->dtDueTimeStr()); 230 setText(4,mTodo->dtDueTimeStr());
227 QTime t = mTodo->dtDue().time(); 231 QTime t = mTodo->dtDue().time();
228 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 232 keyt.sprintf("%02d%02d",t.hour(),t.minute());
229 setSortKey(4,keyt); 233 setSortKey(4,keyt);
230 } 234 }
231 } 235 }
232 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 236 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
233 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 237 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
234 238
235 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 239 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
236 if (mTodo->percentComplete()<100) { 240 if (mTodo->percentComplete()<100) {
237 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
238 else setSortKey(2,QString::number(mTodo->percentComplete())); 242 else setSortKey(2,QString::number(mTodo->percentComplete()));
239 } 243 }
240 else { 244 else {
241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 245 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
242 else setSortKey(2,QString::number(99)); 246 else setSortKey(2,QString::number(99));
243 } 247 }
244 if ( state ) { 248 if ( state ) {
245 QListViewItem * myChild = firstChild(); 249 QListViewItem * myChild = firstChild();
246 KOTodoViewItem *item; 250 KOTodoViewItem *item;
247 while( myChild ) { 251 while( myChild ) {
248 //qDebug("stateCH "); 252 //qDebug("stateCH ");
249 item = static_cast<KOTodoViewItem*>(myChild); 253 item = static_cast<KOTodoViewItem*>(myChild);
250 item->stateChange(state); 254 item->stateChange(state);
251 myChild = myChild->nextSibling(); 255 myChild = myChild->nextSibling();
252 } 256 }
253 } else { 257 } else {
254 QListViewItem * myChild = parent(); 258 QListViewItem * myChild = parent();
255 if ( myChild ) 259 if ( myChild )
256 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); 260 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state);
257 } 261 }
258 mTodoView->modified(true); 262 mTodoView->modified(true);
259 setMyPixmap(); 263 setMyPixmap();
260 mTodoView->setTodoModified( mTodo ); 264 mTodoView->setTodoModified( mTodo );
261} 265}
262 266
263bool KOTodoViewItem::isAlternate() 267bool KOTodoViewItem::isAlternate()
264{ 268{
265#ifndef KORG_NOLVALTERNATION 269#ifndef KORG_NOLVALTERNATION
266 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 270 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
267 if (lv && lv->alternateBackground().isValid()) 271 if (lv && lv->alternateBackground().isValid())
268 { 272 {
269 KOTodoViewItem *above = 0; 273 KOTodoViewItem *above = 0;
270 above = dynamic_cast<KOTodoViewItem *>(itemAbove()); 274 above = dynamic_cast<KOTodoViewItem *>(itemAbove());
271 m_known = above ? above->m_known : true; 275 m_known = above ? above->m_known : true;
272 if (m_known) 276 if (m_known)
273 { 277 {
274 m_odd = above ? !above->m_odd : false; 278 m_odd = above ? !above->m_odd : false;
275 } 279 }
276 else 280 else
277 { 281 {
278 KOTodoViewItem *item; 282 KOTodoViewItem *item;
279 bool previous = true; 283 bool previous = true;
280 if (QListViewItem::parent()) 284 if (QListViewItem::parent())
281 { 285 {
282 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); 286 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent());
283 if (item) 287 if (item)
284 previous = item->m_odd; 288 previous = item->m_odd;
285 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 289 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
286 } 290 }
287 else 291 else
288 { 292 {
289 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); 293 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild());
290 } 294 }
291 295
292 while(item) 296 while(item)
293 { 297 {
294 item->m_odd = previous = !previous; 298 item->m_odd = previous = !previous;
295 item->m_known = true; 299 item->m_known = true;
296 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); 300 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling());
297 } 301 }
298 } 302 }
299 return m_odd; 303 return m_odd;
300 } 304 }
301 return false; 305 return false;
302#else 306#else
303 return false; 307 return false;
304#endif 308#endif
305} 309}
306 310
307void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 311void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
308{ 312{
309 QColorGroup _cg = cg; 313 QColorGroup _cg = cg;
310 QColorGroup::ColorRole role; 314 QColorGroup::ColorRole role;
311 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) 315 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
312 role = QColorGroup::Text; 316 role = QColorGroup::Text;
313 else 317 else
314 role = QColorGroup::Base; 318 role = QColorGroup::Base;
315 //#ifndef KORG_NOLVALTERNATION 319 //#ifndef KORG_NOLVALTERNATION
316 // if (isAlternate()) 320 // if (isAlternate())
317 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 321 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
318 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 322 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
319 QColor colorToSet; 323 QColor colorToSet;
320 if ( setColor ) { 324 if ( setColor ) {
321 QStringList categories = mTodo->categories(); 325 QStringList categories = mTodo->categories();
322 QString cat = categories.first(); 326 QString cat = categories.first();
323 if ( !cat.isEmpty()) { 327 if ( !cat.isEmpty()) {
324 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 328 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
325 } else 329 } else
326 setColor = false; 330 setColor = false;
327 } 331 }
328 if (mTodo->hasDueDate()) { 332 if (mTodo->hasDueDate()) {
329 if (mTodo->dtDue().date()==QDate::currentDate() && 333 if (mTodo->dtDue().date()==QDate::currentDate() &&
330 !mTodo->isCompleted()) { 334 !mTodo->isCompleted()) {
331 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); 335 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor);
332 colorToSet = KOPrefs::instance()->mTodoDueTodayColor; 336 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
333 setColor = true; 337 setColor = true;
334 } 338 }
335 if (mTodo->dtDue().date() < QDate::currentDate() && 339 if (mTodo->dtDue().date() < QDate::currentDate() &&
336 !mTodo->isCompleted()) { 340 !mTodo->isCompleted()) {
337 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor); 341 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor);
338 colorToSet = KOPrefs::instance()->mTodoOverdueColor; 342 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
339 setColor = true; 343 setColor = true;
340 } 344 }
341 } 345 }
342 346
343 if ( setColor ) { 347 if ( setColor ) {
344 _cg.setColor(role,colorToSet ); 348 _cg.setColor(role,colorToSet );
345 if ( role == QColorGroup::Base) { 349 if ( role == QColorGroup::Base) {
346 int rgb = colorToSet.red(); 350 int rgb = colorToSet.red();
347 rgb += colorToSet.blue()/2; 351 rgb += colorToSet.blue()/2;
348 rgb += colorToSet.green(); 352 rgb += colorToSet.green();
349 if ( rgb < 200 ) 353 if ( rgb < 200 )
350 _cg.setColor(QColorGroup::Text,Qt::white ); 354 _cg.setColor(QColorGroup::Text,Qt::white );
351 } 355 }
352 } 356 }
353 //#endif 357 //#endif
354 if ( column > 0 ){ 358 if ( column > 0 ){
355 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { 359 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) {
356 p->save(); 360 p->save();
357 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); 361 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5);
358 362
359 p->fillRect( 0, 0, width, height(), _cg.base() ); // background 363 p->fillRect( 0, 0, width, height(), _cg.base() ); // background
360 // p->setPen(Qt::black ); //border 364 // p->setPen(Qt::black ); //border
361 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling 365 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling
362 QColor fc = KOPrefs::instance()->mHighlightColor; 366 QColor fc = KOPrefs::instance()->mHighlightColor;
363 if ( mTodo->percentComplete() == 100 ) 367 if ( mTodo->percentComplete() == 100 )
364 fc = darkGreen; 368 fc = darkGreen;
365 p->drawRect( 2, 2, width-4, height()-4); 369 p->drawRect( 2, 2, width-4, height()-4);
366 p->fillRect( 3, 3, progress, height()-6, 370 p->fillRect( 3, 3, progress, height()-6,
367 fc ); 371 fc );
368 p->restore(); 372 p->restore();
369 } else { 373 } else {
370 QCheckListItem::paintCell(p, _cg, column, width, alignment); 374 QCheckListItem::paintCell(p, _cg, column, width, alignment);
371 } 375 }
372 return; 376 return;
373 } 377 }
374 378
375 int align = alignment; 379 int align = alignment;
376 380
377 if ( !p ) 381 if ( !p )
378 return; 382 return;
379 383
380 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); 384 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) );
381 385
382 QListView *lv = listView(); 386 QListView *lv = listView();
383 if ( !lv ) 387 if ( !lv )
384 return; 388 return;
385 int marg = 2;//lv->itemMargin(); 389 int marg = 2;//lv->itemMargin();
386 int r = 0; 390 int r = 0;
387 QCheckListItem::Type myType = QCheckListItem::CheckBox; 391 QCheckListItem::Type myType = QCheckListItem::CheckBox;
388 int BoxSize = 20; 392 int BoxSize = 20;
389 int boxOffset = 2; 393 int boxOffset = 2;
390 int xOffset = 2; 394 int xOffset = 2;
391 if (qApp->desktop()->width() < 300 ) { 395 if (qApp->desktop()->width() < 300 ) {
392 BoxSize = 14; 396 BoxSize = 14;
393 boxOffset = -1; 397 boxOffset = -1;
394 xOffset = 1; 398 xOffset = 1;
395 // marg = 0; 399 // marg = 0;
396 } 400 }
397 if ( height() < BoxSize ) { 401 if ( height() < BoxSize ) {
398 boxOffset = boxOffset - ((BoxSize - height())/2) ; 402 boxOffset = boxOffset - ((BoxSize - height())/2) ;
399 // qDebug("boxOffset %d height %d", boxOffset, height() ); 403 // qDebug("boxOffset %d height %d", boxOffset, height() );
400 BoxSize = height(); 404 BoxSize = height();
401 405
402 } 406 }
403 //bool winStyle = lv->style() == WindowsStyle; 407 //bool winStyle = lv->style() == WindowsStyle;
404 408
405 int lineStart = 5; 409 int lineStart = 5;
406 if ( myType == Controller ) { 410 if ( myType == Controller ) {
407 if ( !pixmap( 0 ) ) 411 if ( !pixmap( 0 ) )
408 r += BoxSize + 4; 412 r += BoxSize + 4;
409 } else { 413 } else {
410 ASSERT( lv ); //### 414 ASSERT( lv ); //###
411 //QFontMetrics fm( lv->font() ); 415 //QFontMetrics fm( lv->font() );
412 //int d = fm.height(); 416 //int d = fm.height();
413 int x = 0; 417 int x = 0;
414 int y = (height() - BoxSize) / 2; 418 int y = (height() - BoxSize) / 2;
415 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); 419 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) );
416 if ( myType == CheckBox ) { 420 if ( myType == CheckBox ) {
417 if ( isEnabled() ) 421 if ( isEnabled() )
418 p->setPen( QPen( _cg.text(), 1 ) ); 422 p->setPen( QPen( _cg.text(), 1 ) );
419 else 423 else
420 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); 424 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) );
421 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); 425 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
422 lineStart = x+marg; 426 lineStart = x+marg;
423 ///////////////////// 427 /////////////////////
424 x++; 428 x++;
425 y++; 429 y++;
426 if ( isOn() ) { 430 if ( isOn() ) {
427 QPointArray a( 7*2 ); 431 QPointArray a( 7*2 );
428 int i, xx, yy; 432 int i, xx, yy;
429 xx = x+xOffset+marg+(boxOffset/2); 433 xx = x+xOffset+marg+(boxOffset/2);
430 yy = y+5+boxOffset; 434 yy = y+5+boxOffset;
431 for ( i=0; i<3; i++ ) { 435 for ( i=0; i<3; i++ ) {
432 a.setPoint( 2*i, xx, yy ); 436 a.setPoint( 2*i, xx, yy );
433 a.setPoint( 2*i+1, xx, yy+2 ); 437 a.setPoint( 2*i+1, xx, yy+2 );
434 // qDebug(" "); 438 // qDebug(" ");
435 xx++; yy++; 439 xx++; yy++;
436 } 440 }
437 yy -= 2; 441 yy -= 2;
438 for ( i=3; i<7; i++ ) { 442 for ( i=3; i<7; i++ ) {
439 a.setPoint( 2*i, xx, yy ); 443 a.setPoint( 2*i, xx, yy );
440 a.setPoint( 2*i+1, xx, yy+2 ); 444 a.setPoint( 2*i+1, xx, yy+2 );
441 xx++; yy--; 445 xx++; yy--;
442 } 446 }
443 p->setPen( darkGreen ); 447 p->setPen( darkGreen );
444 p->drawLineSegments( a ); 448 p->drawLineSegments( a );
445 } 449 }
446 //////////////////////// 450 ////////////////////////
447 } 451 }
448 r += BoxSize + 4; 452 r += BoxSize + 4;
449 } 453 }
450 454
451 p->translate( r, 0 ); 455 p->translate( r, 0 );
452 p->setPen( QPen( _cg.text() ) ); 456 p->setPen( QPen( _cg.text() ) );
453 QListViewItem::paintCell( p, _cg, column, width - r, align ); 457 QListViewItem::paintCell( p, _cg, column, width - r, align );
454 if ( mTodo->cancelled () ) { 458 if ( mTodo->cancelled () ) {
455 p->setPen( black ); 459 p->setPen( black );
456 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); 460 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() );
457 int wid = br.width() +lineStart; 461 int wid = br.width() +lineStart;
458 if ( wid > width-3 ) 462 if ( wid > width-3 )
459 wid = width-3; 463 wid = width-3;
460 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); 464 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 );
461 465
462 } 466 }
463 467
464} 468}