author | zautrix <zautrix> | 2005-07-03 20:25:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-03 20:25:46 (UTC) |
commit | ad66f0fe56bb88104fb0065ccb599ab0edd35cf4 (patch) (unidiff) | |
tree | 13936362717d3a3ca36404ad5b522574418d1d89 /korganizer | |
parent | f9a1b1e8ac52218360731fae67993704c20f17fe (diff) | |
download | kdepimpi-ad66f0fe56bb88104fb0065ccb599ab0edd35cf4.zip kdepimpi-ad66f0fe56bb88104fb0065ccb599ab0edd35cf4.tar.gz kdepimpi-ad66f0fe56bb88104fb0065ccb599ab0edd35cf4.tar.bz2 |
icon agenda fix
-rw-r--r-- | korganizer/koagendaitem.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index c055eb8..9fe1be4 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -149,117 +149,120 @@ void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | |||
149 | setCellXY(0,0,1); | 149 | setCellXY(0,0,1); |
150 | setCellXWidth(0); | 150 | setCellXWidth(0); |
151 | setSubCell(0); | 151 | setSubCell(0); |
152 | setSubCells(1); | 152 | setSubCells(1); |
153 | setMultiItem(0,0,0); | 153 | setMultiItem(0,0,0); |
154 | startMove(); | 154 | startMove(); |
155 | mSelected = true; | 155 | mSelected = true; |
156 | select(false); | 156 | select(false); |
157 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 157 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
158 | mFontPixelSize = fontinf.height();; | 158 | mFontPixelSize = fontinf.height();; |
159 | hide(); | 159 | hide(); |
160 | xPaintCoord = -1; | 160 | xPaintCoord = -1; |
161 | yPaintCoord = -1; | 161 | yPaintCoord = -1; |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | KOAgendaItem::~KOAgendaItem() | 165 | KOAgendaItem::~KOAgendaItem() |
166 | { | 166 | { |
167 | #if QT_VERSION >= 0x030000 | 167 | #if QT_VERSION >= 0x030000 |
168 | 168 | ||
169 | #else | 169 | #else |
170 | delete mKOAgendaItemWhatsThis; | 170 | delete mKOAgendaItemWhatsThis; |
171 | #endif | 171 | #endif |
172 | 172 | ||
173 | } | 173 | } |
174 | 174 | ||
175 | void KOAgendaItem::recreateIncidence() | 175 | void KOAgendaItem::recreateIncidence() |
176 | { | 176 | { |
177 | #if 0 | 177 | #if 0 |
178 | Incidence* newInc = mIncidence->clone(); | 178 | Incidence* newInc = mIncidence->clone(); |
179 | newInc->recreate(); | 179 | newInc->recreate(); |
180 | if ( mIncidence->doesRecur() ) { | 180 | if ( mIncidence->doesRecur() ) { |
181 | mIncidence->addExDate( mDate ); | 181 | mIncidence->addExDate( mDate ); |
182 | newInc->recurrence()->unsetRecurs(); | 182 | newInc->recurrence()->unsetRecurs(); |
183 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 183 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
184 | QTime tim = mIncidence->dtStart().time(); | 184 | QTime tim = mIncidence->dtStart().time(); |
185 | newInc->setDtStart( QDateTime(mDate, tim) ); | 185 | newInc->setDtStart( QDateTime(mDate, tim) ); |
186 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 186 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
187 | } | 187 | } |
188 | #endif | 188 | #endif |
189 | mIncidence = mIncidence->recreateCloneException( mDate ); | 189 | mIncidence = mIncidence->recreateCloneException( mDate ); |
190 | } | 190 | } |
191 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 191 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
192 | { | 192 | { |
193 | int size = AGENDA_ICON_SIZE; | 193 | int size = AGENDA_ICON_SIZE; |
194 | 194 | ||
195 | int yOff = 0; | 195 | int yOff = 0; |
196 | int xOff = 0; | 196 | int xOff = 0; |
197 | int x = pos().x() +3; | 197 | int x = pos().x(); |
198 | |||
199 | if ( x < 0 ) x = 0; | ||
200 | x += 3; | ||
198 | int y; | 201 | int y; |
199 | if ( mAllDay ) | 202 | if ( mAllDay ) |
200 | y = pos().y()+3; | 203 | y = pos().y()+3; |
201 | else | 204 | else |
202 | y = mCellYTop * ( height() / cellHeight() ) +3; | 205 | y = mCellYTop * ( height() / cellHeight() ) +3; |
203 | 206 | ||
204 | 207 | ||
205 | if ( mIncidence->calID() > 1 ) { | 208 | if ( mIncidence->calID() > 1 ) { |
206 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); | 209 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); |
207 | p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); | 210 | p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); |
208 | if ( horLayout ){ | 211 | if ( horLayout ){ |
209 | ++xOff; | 212 | ++xOff; |
210 | ++x; | 213 | ++x; |
211 | } | 214 | } |
212 | else { | 215 | else { |
213 | ++yOff; | 216 | ++yOff; |
214 | ++y; | 217 | ++y; |
215 | } | 218 | } |
216 | } | 219 | } |
217 | if (mIncidence->cancelled()) { | 220 | if (mIncidence->cancelled() && height() < 20 ) { |
218 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 221 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
219 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 222 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
220 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 223 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
221 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 224 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
222 | if ( horLayout ) | 225 | if ( horLayout ) |
223 | ++xOff; | 226 | ++xOff; |
224 | else | 227 | else |
225 | ++yOff; | 228 | ++yOff; |
226 | } | 229 | } |
227 | if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { | 230 | if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { |
228 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
229 | if ( horLayout ) | 232 | if ( horLayout ) |
230 | ++xOff; | 233 | ++xOff; |
231 | else | 234 | else |
232 | ++yOff; | 235 | ++yOff; |
233 | } | 236 | } |
234 | if (mIncidence->recurrence()->doesRecur()) { | 237 | if (mIncidence->recurrence()->doesRecur()) { |
235 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 238 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
236 | if ( horLayout ) | 239 | if ( horLayout ) |
237 | ++xOff; | 240 | ++xOff; |
238 | else | 241 | else |
239 | ++yOff; | 242 | ++yOff; |
240 | } | 243 | } |
241 | if (mIncidence->description().length() > 0) { | 244 | if (mIncidence->description().length() > 0) { |
242 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 245 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
243 | if ( horLayout ) | 246 | if ( horLayout ) |
244 | ++xOff; | 247 | ++xOff; |
245 | else | 248 | else |
246 | ++yOff; | 249 | ++yOff; |
247 | } | 250 | } |
248 | if (mIncidence->isReadOnly()) { | 251 | if (mIncidence->isReadOnly()) { |
249 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 252 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
250 | if ( horLayout ) | 253 | if ( horLayout ) |
251 | ++xOff; | 254 | ++xOff; |
252 | else | 255 | else |
253 | ++yOff; | 256 | ++yOff; |
254 | } | 257 | } |
255 | 258 | ||
256 | if (mIncidence->attendeeCount()>0) { | 259 | if (mIncidence->attendeeCount()>0) { |
257 | 260 | ||
258 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 261 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
259 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 262 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
260 | if ( horLayout ) | 263 | if ( horLayout ) |
261 | ++xOff; | 264 | ++xOff; |
262 | else | 265 | else |
263 | ++yOff; | 266 | ++yOff; |
264 | } else { | 267 | } else { |
265 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 268 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
@@ -388,96 +391,98 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | |||
388 | int yyy = yy+3; | 391 | int yyy = yy+3; |
389 | if ( tempTodo->isCompleted() ) | 392 | if ( tempTodo->isCompleted() ) |
390 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 393 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
391 | else { | 394 | else { |
392 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 395 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
393 | 396 | ||
394 | } | 397 | } |
395 | } | 398 | } |
396 | bool addIcon = false; | 399 | bool addIcon = false; |
397 | if ( ! small || w > 3 * h || h > 3* w ) | 400 | if ( ! small || w > 3 * h || h > 3* w ) |
398 | addIcon = updateIcons( paint, horLayout ); | 401 | addIcon = updateIcons( paint, horLayout ); |
399 | 402 | ||
400 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 403 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
401 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); | 404 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); |
402 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 405 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
403 | if ( ! small ) { | 406 | if ( ! small ) { |
404 | x += 3; yy += 3;w -= 6; h-= 5; | 407 | x += 3; yy += 3;w -= 6; h-= 5; |
405 | } else { | 408 | } else { |
406 | x += 2; yy += 1;w -= 4; h-= 4; | 409 | x += 2; yy += 1;w -= 4; h-= 4; |
407 | if ( nfh < 6.01 ) { | 410 | if ( nfh < 6.01 ) { |
408 | yy -= 2; | 411 | yy -= 2; |
409 | h += 4; | 412 | h += 4; |
410 | } | 413 | } |
411 | else | 414 | else |
412 | if ( nfh < h -2 ) | 415 | if ( nfh < h -2 ) |
413 | ++yy; | 416 | ++yy; |
414 | } | 417 | } |
415 | int align; | 418 | int align; |
416 | #ifndef DESKTOP_VERSION | 419 | #ifndef DESKTOP_VERSION |
417 | align = ( AlignLeft|WordBreak|AlignTop); | 420 | align = ( AlignLeft|WordBreak|AlignTop); |
418 | #else | 421 | #else |
419 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 422 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
420 | #endif | 423 | #endif |
421 | if ( addIcon ) { | 424 | if ( addIcon ) { |
422 | if ( ! horLayout ) { | 425 | if ( ! horLayout ) { |
423 | x += AGENDA_ICON_SIZE+3; | 426 | x += AGENDA_ICON_SIZE+3; |
424 | w -= (AGENDA_ICON_SIZE+3); | 427 | w -= (AGENDA_ICON_SIZE+3); |
425 | } | 428 | } |
426 | else { | 429 | else { |
427 | yy+= AGENDA_ICON_SIZE+2; | 430 | yy+= AGENDA_ICON_SIZE+2; |
428 | h -=(AGENDA_ICON_SIZE+3); | 431 | h -=(AGENDA_ICON_SIZE+3); |
429 | } | 432 | } |
430 | } | 433 | } |
431 | if ( mWhiteText ) | 434 | if ( mWhiteText ) |
432 | paint->setPen ( white); | 435 | paint->setPen ( white); |
433 | if ( x < 0 ) { | 436 | if ( x < 0 ) { |
434 | w = w+x-3; | 437 | w = w+x-3; |
435 | x = 3; | 438 | x = 3; |
439 | if ( !horLayout && addIcon ) | ||
440 | x += AGENDA_ICON_SIZE+3; | ||
436 | if ( w > parentWidget()->width() ){ | 441 | if ( w > parentWidget()->width() ){ |
437 | w = parentWidget()->width() - 6; | 442 | w = parentWidget()->width() - 6; |
438 | #ifndef DESKTOP_VERSION | 443 | #ifndef DESKTOP_VERSION |
439 | align = ( AlignHCenter|WordBreak|AlignTop); | 444 | align = ( AlignHCenter|WordBreak|AlignTop); |
440 | #else | 445 | #else |
441 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 446 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
442 | #endif | 447 | #endif |
443 | 448 | ||
444 | } | 449 | } |
445 | } | 450 | } |
446 | QRect dr; | 451 | QRect dr; |
447 | if ( w + x > parentWidget()->width() ) | 452 | if ( w + x > parentWidget()->width() ) |
448 | w = parentWidget()->width()-x; | 453 | w = parentWidget()->width()-x; |
449 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 454 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
450 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 455 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
451 | if ( mIncidence->cancelled() ){ | 456 | if ( mIncidence->cancelled() ){ |
452 | 457 | ||
453 | 458 | ||
454 | small = ( height() < 20 ); | 459 | small = ( height() < 20 ); |
455 | 460 | ||
456 | if ( ! small ) { | 461 | if ( ! small ) { |
457 | QFontMetrics fm ( paint->font() ); | 462 | QFontMetrics fm ( paint->font() ); |
458 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 463 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
459 | } | 464 | } |
460 | 465 | ||
461 | } | 466 | } |
462 | pa.end(); | 467 | pa.end(); |
463 | 468 | ||
464 | } | 469 | } |
465 | void KOAgendaItem::resizePixmap( int w , int h ) | 470 | void KOAgendaItem::resizePixmap( int w , int h ) |
466 | { | 471 | { |
467 | paintPix()->resize( w, h ); | 472 | paintPix()->resize( w, h ); |
468 | paintPixSel()->resize( w, h ); | 473 | paintPixSel()->resize( w, h ); |
469 | 474 | ||
470 | } | 475 | } |
471 | QPixmap * KOAgendaItem::paintPix() | 476 | QPixmap * KOAgendaItem::paintPix() |
472 | { | 477 | { |
473 | static QPixmap* mPaintPix = 0; | 478 | static QPixmap* mPaintPix = 0; |
474 | if ( ! mPaintPix ) { | 479 | if ( ! mPaintPix ) { |
475 | int w = QApplication::desktop()->width(); | 480 | int w = QApplication::desktop()->width(); |
476 | int h = QApplication::desktop()->height(); | 481 | int h = QApplication::desktop()->height(); |
477 | mPaintPix = new QPixmap(w,h); | 482 | mPaintPix = new QPixmap(w,h); |
478 | } | 483 | } |
479 | return mPaintPix ; | 484 | return mPaintPix ; |
480 | } | 485 | } |
481 | QPixmap * KOAgendaItem::paintPixAllday() | 486 | QPixmap * KOAgendaItem::paintPixAllday() |
482 | { | 487 | { |
483 | static QPixmap* mPaintPixA = 0; | 488 | static QPixmap* mPaintPixA = 0; |