summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-19 15:39:43 (UTC)
committer zautrix <zautrix>2005-02-19 15:39:43 (UTC)
commit4858dcb045afc57ce98877cca787c4430146bea8 (patch) (unidiff)
tree9c9ea4b6d93a34d4bea97d7cea0b294c9c8665de
parentd2ed2aaddb88f39f8b2ced18a4ea7f06a63237d3 (diff)
downloadkdepimpi-4858dcb045afc57ce98877cca787c4430146bea8.zip
kdepimpi-4858dcb045afc57ce98877cca787c4430146bea8.tar.gz
kdepimpi-4858dcb045afc57ce98877cca787c4430146bea8.tar.bz2
multiday fixes in monthview
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp91
-rw-r--r--korganizer/komonthview.h2
2 files changed, 69 insertions, 24 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 2fe80af..f558084 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -199,109 +199,148 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
199 mIncidence = incidence; 199 mIncidence = incidence;
200 mDate = qd; 200 mDate = qd;
201 mRecur = false; 201 mRecur = false;
202 mAlarm = false; 202 mAlarm = false;
203 mReply = false; 203 mReply = false;
204 mInfo = false; 204 mInfo = false;
205} 205}
206 206
207void MonthViewItem::paint(QPainter *p) 207void MonthViewItem::paint(QPainter *p)
208{ 208{
209#if QT_VERSION >= 0x030000 209#if QT_VERSION >= 0x030000
210 bool sel = isSelected(); 210 bool sel = isSelected();
211#else 211#else
212 bool sel = selected(); 212 bool sel = selected();
213#endif 213#endif
214 214
215 215
216 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 216 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
217 { 217 {
218 p->setBackgroundColor( palette().color( QPalette::Normal, \ 218 p->setBackgroundColor( palette().color( QPalette::Normal, \
219 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 219 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
220 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 220 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
221 } 221 }
222 int x = 1; 222 int x = 1;
223 int y = 3;//(height() - mRecurPixmap.height()) /2; 223 //int y = 3;//(height() - mRecurPixmap.height()) /2;
224 int size = PIXMAP_SIZE; 224 int size = PIXMAP_SIZE;
225 if ( QApplication::desktop()->width() < 300 ) 225 if ( QApplication::desktop()->width() < 300 )
226 size = 3; 226 size = 3;
227 int y = (height( listBox () ) - size -1 ) /2;
228
227 if ( KOPrefs::instance()->mMonthShowIcons ) { 229 if ( KOPrefs::instance()->mMonthShowIcons ) {
228 if ( mInfo ) { 230 if ( mInfo ) {
229 p->fillRect ( x, y,size,size, Qt::darkGreen ); 231 p->fillRect ( x, y,size,size, Qt::darkGreen );
230 x += size + 1; 232 x += size + 1;
231 } 233 }
232 if ( mRecur ) { 234 if ( mRecur ) {
233 p->fillRect ( x, y,size,size, Qt::blue ); 235 p->fillRect ( x, y,size,size, Qt::blue );
234 x += size + 1; 236 x += size + 1;
235 } 237 }
236 if ( mAlarm ) { 238 if ( mAlarm ) {
237 p->fillRect ( x, y,size,size, Qt::red ); 239 p->fillRect ( x, y,size,size, Qt::red );
238 x += size + 1; 240 x += size + 1;
239 } 241 }
240 if ( mReply ) { 242 if ( mReply ) {
241 p->fillRect ( x, y,size,size, Qt::yellow ); 243 p->fillRect ( x, y,size,size, Qt::yellow );
242 x += size + 1; 244 x += size + 1;
243 } 245 }
244 } 246 }
247 if ( mMultiday ) {
248 int yyy = y+(size/2);
249 int sizeM = size+2;
250 p->setBrush( QBrush::SolidPattern );
251 p->drawLine ( x+sizeM/2, yyy, x +sizeM +sizeM/2-2, yyy ) ;
252 if ( mMultiday == 2 || mMultiday == 3 ) {
253 QPointArray pa ( 3 );
254 pa.setPoint (0, x, yyy );
255 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
256 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
257 p->drawPolygon( pa );
258 }
259 if ( mMultiday == 2 || mMultiday == 1 ) {
260 QPointArray pa ( 3 );
261 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
262 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
263 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
264 p->drawPolygon( pa );
265 }
266 if ( mMultiday == 1 ) {
267 p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
268
269 }
270 if ( mMultiday == 3 ) {
271 p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
272
273 }
274 x += sizeM/2 + 1;
275 x += sizeM + 1;
276 }
245 QFontMetrics fm = p->fontMetrics(); 277 QFontMetrics fm = p->fontMetrics();
246 int yPos; 278 int yPos;
247 int pmheight = size; 279 int pmheight = size;
248 if( pmheight < fm.height() ) 280 if( pmheight < fm.height() )
249 yPos = fm.ascent() + fm.leading()/2; 281 yPos = fm.ascent() + fm.leading()/2;
250 else 282 else
251 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 283 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
252 p->setPen( palette().color( QPalette::Normal, sel ? \ 284 p->setPen( palette().color( QPalette::Normal, sel ? \
253 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 285 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
254 p->drawText( x, yPos, text() ); 286 p->drawText( x, yPos, text() );
255 if ( mIncidence->cancelled() ) { 287 if ( mIncidence->cancelled() ) {
256 int wid = fm.width( text() ); 288 int wid = fm.width( text() );
257 p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); 289 p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3);
258 } 290 }
259 291
260} 292}
261 293
262int MonthViewItem::height(const QListBox *lb) const 294int MonthViewItem::height(const QListBox *lb) const
263{ 295{
264 return lb->fontMetrics().lineSpacing()+1; 296 if ( lb )
297 return lb->fontMetrics().lineSpacing()+1;
298 return 10;
265} 299}
266 300
267int MonthViewItem::width(const QListBox *lb) const 301int MonthViewItem::width(const QListBox *lb) const
268{ 302{
269 int size = PIXMAP_SIZE; 303 int size = PIXMAP_SIZE;
270 if ( QApplication::desktop()->width() < 300 ) 304 if ( QApplication::desktop()->width() < 300 )
271 size = 3; 305 size = 3;
272 int x = 1; 306 int x = 1;
273 if ( mInfo ) { 307 if ( KOPrefs::instance()->mMonthShowIcons ) {
274 x += size + 1; 308 if ( mInfo ) {
275 } 309 x += size + 1;
276 if( mRecur ) { 310 }
277 x += size+1; 311 if( mRecur ) {
278 } 312 x += size+1;
279 if( mAlarm ) { 313 }
280 x += size+1; 314 if( mAlarm ) {
315 x += size+1;
316 }
317 if( mReply ) {
318 x += size+1;
319 }
281 } 320 }
282 if( mReply ) { 321 if( mMultiday ) {
283 x += size+1; 322 x += size+1+2+size/2;
284 } 323 }
285 324
286 return( x + lb->fontMetrics().width( text() ) + 1 ); 325 return( x + lb->fontMetrics().width( text() ) + 1 );
287} 326}
288 327
289 328
290MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 329MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
291 : QWidget( par ), 330 : QWidget( par ),
292 mMonthView( parent ) 331 mMonthView( parent )
293{ 332{
294 333
295 QVBoxLayout *topLayout = new QVBoxLayout( this ); 334 QVBoxLayout *topLayout = new QVBoxLayout( this );
296 335
297 // mLabel = new QLabel( this );QPushButton 336 // mLabel = new QLabel( this );QPushButton
298 mLabel = new QPushButton( this ); 337 mLabel = new QPushButton( this );
299 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 338 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
300 //mLabel->setLineWidth( 1 ); 339 //mLabel->setLineWidth( 1 );
301 //mLabel->setAlignment( AlignCenter ); 340 //mLabel->setAlignment( AlignCenter );
302 mLabel->setFlat( true ); 341 mLabel->setFlat( true );
303 mLabel->setFocusPolicy(NoFocus); 342 mLabel->setFocusPolicy(NoFocus);
304 mItemList = new KNoScrollListBox( this ); 343 mItemList = new KNoScrollListBox( this );
305 mItemList->setMinimumSize( 10, 10 ); 344 mItemList->setMinimumSize( 10, 10 );
306 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 345 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
307 mItemList->setLineWidth( 1 ); 346 mItemList->setLineWidth( 1 );
@@ -443,126 +482,130 @@ void MonthViewCell::startUpdateCell()
443 mItemList->insertItem( item ); 482 mItemList->insertItem( item );
444 mToolTip += mHolidayString+"\n"; 483 mToolTip += mHolidayString+"\n";
445 } 484 }
446} 485}
447 486
448void MonthViewCell::insertEvent(Event *event) 487void MonthViewCell::insertEvent(Event *event)
449{ 488{
450 489
451 mItemList->setFocusPolicy(WheelFocus); 490 mItemList->setFocusPolicy(WheelFocus);
452 if ( !(event->doesRecur() == Recurrence::rNone) ) { 491 if ( !(event->doesRecur() == Recurrence::rNone) ) {
453 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 492 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
454 return; 493 return;
455 else 494 else
456 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 495 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
457 return; 496 return;
458 } 497 }
459 498
460 if ( event->categories().contains("Holiday") || 499 if ( event->categories().contains("Holiday") ||
461 event->categories().contains(i18n("Holiday"))) { 500 event->categories().contains(i18n("Holiday"))) {
462 setHoliday( true ); 501 setHoliday( true );
463 if ( mDate.dayOfWeek() == 7 ) 502 if ( mDate.dayOfWeek() == 7 )
464 mItemList->setLineWidth( 3 ); 503 mItemList->setLineWidth( 3 );
465 } 504 }
466 QString text; 505 QString text;
506 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
467 if (event->isMultiDay()) { 507 if (event->isMultiDay()) {
468 QString prefix = "<->"; 508 QString prefix = "<->";multiday = 2;
509 QString time;
469 if ( event->doesRecur() ) { 510 if ( event->doesRecur() ) {
470 if ( event->recursOn( mDate) ) 511 if ( event->recursOn( mDate) ) {
471 prefix ="->" ; 512 prefix ="->" ;multiday = 1;
513 }
472 else { 514 else {
473 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 515 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
474 if ( event->recursOn( mDate.addDays( -days)) ) 516 if ( event->recursOn( mDate.addDays( -days)) )
475 prefix ="<-" ; 517 prefix ="<-" ;multiday = 3;
476 } 518 }
477 519
478 } else { 520 } else {
479 if (mDate == event->dtStart().date()) { 521 if (mDate == event->dtStart().date()) {
480 prefix ="->" ; 522 prefix ="->" ;multiday = 1;
481 } else if (mDate == event->dtEnd().date()) { 523 } else if (mDate == event->dtEnd().date()) {
482 prefix ="<-" ; 524 prefix ="<-" ;multiday = 3;
483 } 525 }
484 } 526 }
485 if ( !event->doesFloat() ) { 527 if ( !event->doesFloat() ) {
486 if ( mDate == event->dtStart().date () ) 528 if ( mDate == event->dtStart().date () )
487 prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; 529 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
488 else if ( mDate == event->dtEnd().date () ) 530 else if ( mDate == event->dtEnd().date () )
489 prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 531 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
490 532
491 } 533 }
492 text = prefix + event->summary(); 534 text = time + event->summary();
493 mToolTip += text; 535 mToolTip += prefix + text;
494 } else { 536 } else {
495 if (event->doesFloat()) { 537 if (event->doesFloat()) {
496 text = event->summary(); 538 text = event->summary();
497 mToolTip += text; 539 mToolTip += text;
498 } 540 }
499 else { 541 else {
500 text = KGlobal::locale()->formatTime(event->dtStart().time()); 542 text = KGlobal::locale()->formatTime(event->dtStart().time());
501 text += " " + event->summary(); 543 text += " " + event->summary();
502 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 544 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
503 } 545 }
504 } 546 }
505 547
506 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 548 MonthViewItem *item = new MonthViewItem( event, mDate, text );
507 QPalette pal; 549 QPalette pal;
508 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 550 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
509 QStringList categories = event->categories(); 551 QStringList categories = event->categories();
510 QString cat = categories.first(); 552 QString cat = categories.first();
511 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 553 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
512 pal = getPalette(); 554 pal = getPalette();
513 if (cat.isEmpty()) { 555 if (cat.isEmpty()) {
514 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 556 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
515 } else { 557 } else {
516 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 558 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
517 } 559 }
518 560
519 } else { 561 } else {
520 if (cat.isEmpty()) { 562 if (cat.isEmpty()) {
521 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 563 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
522 } else { 564 } else {
523 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 565 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
524 } 566 }
525 } 567 }
526 568
527 } else { 569 } else {
528 pal = mStandardPalette ; 570 pal = mStandardPalette ;
529 } 571 }
530 item->setPalette( pal ); 572 item->setPalette( pal );
531 item->setRecur( event->recurrence()->doesRecur() ); 573 item->setRecur( event->recurrence()->doesRecur() );
532 item->setAlarm( event->isAlarmEnabled() ); 574 item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
533 item->setMoreInfo( event->description().length() > 0 ); 575 item->setMoreInfo( event->description().length() > 0 );
534#ifdef DESKTOP_VERSION 576#ifdef DESKTOP_VERSION
535 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 577 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
536 KOPrefs::instance()->email()); 578 KOPrefs::instance()->email());
537 if ( me != 0 ) { 579 if ( me != 0 ) {
538 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 580 if ( me->status() == Attendee::NeedsAction && me->RSVP())
539 item->setReply(true); 581 item->setReply(true && multiday < 2);
540 else 582 else
541 item->setReply(false); 583 item->setReply(false);
542 } else 584 } else
543 item->setReply(false); 585 item->setReply(false);
544#endif 586#endif
587 item->setMultiDay( multiday );
545 mItemList->insertItem( item ); 588 mItemList->insertItem( item );
546 mToolTip += "\n"; 589 mToolTip += "\n";
547} 590}
548void MonthViewCell::insertTodo(Todo *todo) 591void MonthViewCell::insertTodo(Todo *todo)
549{ 592{
550 mItemList->setFocusPolicy(WheelFocus); 593 mItemList->setFocusPolicy(WheelFocus);
551 QString text; 594 QString text;
552 if (todo->hasDueDate()) { 595 if (todo->hasDueDate()) {
553 if (!todo->doesFloat()) { 596 if (!todo->doesFloat()) {
554 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 597 text += KGlobal::locale()->formatTime(todo->dtDue().time());
555 text += " "; 598 text += " ";
556 } 599 }
557 } 600 }
558 text += i18n("T: %1").arg(todo->summary()); 601 text += i18n("T: %1").arg(todo->summary());
559 602
560 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 603 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
561 //item->setPalette( mStandardPalette ); 604 //item->setPalette( mStandardPalette );
562 QPalette pal; 605 QPalette pal;
563 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 606 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
564 QStringList categories = todo->categories(); 607 QStringList categories = todo->categories();
565 QString cat = categories.first(); 608 QString cat = categories.first();
566 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 609 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
567 pal = getPalette(); 610 pal = getPalette();
568 if (cat.isEmpty()) { 611 if (cat.isEmpty()) {
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 2f6f5dc..b79a41f 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -76,62 +76,64 @@ class KNoScrollListBox: public QListBox
76 void shiftDown(); 76 void shiftDown();
77 void shiftUp(); 77 void shiftUp();
78 void rightClick(); 78 void rightClick();
79 79
80 protected slots: 80 protected slots:
81 void oneDown(); 81 void oneDown();
82 void keyPressEvent(QKeyEvent *); 82 void keyPressEvent(QKeyEvent *);
83 void keyReleaseEvent(QKeyEvent *); 83 void keyReleaseEvent(QKeyEvent *);
84 void mousePressEvent(QMouseEvent *); 84 void mousePressEvent(QMouseEvent *);
85 85
86 private: 86 private:
87 KNOWhatsThis * mWT; 87 KNOWhatsThis * mWT;
88}; 88};
89 89
90 90
91class MonthViewItem: public QListBoxItem 91class MonthViewItem: public QListBoxItem
92{ 92{
93 public: 93 public:
94 MonthViewItem( Incidence *, QDate qd, const QString & title ); 94 MonthViewItem( Incidence *, QDate qd, const QString & title );
95 95
96 void setRecur(bool on) { mRecur = on; } 96 void setRecur(bool on) { mRecur = on; }
97 void setAlarm(bool on) { mAlarm = on; } 97 void setAlarm(bool on) { mAlarm = on; }
98 void setReply(bool on) { mReply = on; } 98 void setReply(bool on) { mReply = on; }
99 void setMoreInfo(bool on) { mInfo = on; } 99 void setMoreInfo(bool on) { mInfo = on; }
100 void setMultiDay(int type) { mMultiday = type; }
100 101
101 102
102 void setPalette(const QPalette &p) { mPalette = p; } 103 void setPalette(const QPalette &p) { mPalette = p; }
103 QPalette palette() const { return mPalette; } 104 QPalette palette() const { return mPalette; }
104 105
105 Incidence *incidence() const { return mIncidence; } 106 Incidence *incidence() const { return mIncidence; }
106 QDate incidenceDate() { return mDate; } 107 QDate incidenceDate() { return mDate; }
107 108
108 protected: 109 protected:
109 virtual void paint(QPainter *); 110 virtual void paint(QPainter *);
110 virtual int height(const QListBox *) const; 111 virtual int height(const QListBox *) const;
111 virtual int width(const QListBox *) const; 112 virtual int width(const QListBox *) const;
112 113
113 private: 114 private:
115 int mMultiday;
114 bool mRecur; 116 bool mRecur;
115 bool mAlarm; 117 bool mAlarm;
116 bool mReply; 118 bool mReply;
117 bool mInfo; 119 bool mInfo;
118 120
119 QPalette mPalette; 121 QPalette mPalette;
120 QDate mDate; 122 QDate mDate;
121 123
122 Incidence *mIncidence; 124 Incidence *mIncidence;
123}; 125};
124 126
125 127
126class KOMonthView; 128class KOMonthView;
127 129
128class MonthViewCell : public QWidget 130class MonthViewCell : public QWidget
129{ 131{
130 Q_OBJECT 132 Q_OBJECT
131 public: 133 public:
132 MonthViewCell(KOMonthView *,QWidget* ); 134 MonthViewCell(KOMonthView *,QWidget* );
133 135
134 void setDate( const QDate & ); 136 void setDate( const QDate & );
135 QDate date() const; 137 QDate date() const;
136 138
137 void setPrimary( bool ); 139 void setPrimary( bool );