summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp5
-rw-r--r--korganizer/koagendaitem.h1
2 files changed, 3 insertions, 3 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 1be0aca..e660c32 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -90,97 +90,97 @@ KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool
90} 90}
91QString KOAgendaItem::getWhatsThisText() 91QString KOAgendaItem::getWhatsThisText()
92{ 92{
93 if ( mIncidence ) 93 if ( mIncidence )
94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
95 KOPrefs::instance()->mWTshowDetails, 95 KOPrefs::instance()->mWTshowDetails,
96 KOPrefs::instance()->mWTshowCreated, 96 KOPrefs::instance()->mWTshowCreated,
97 KOPrefs::instance()->mWTshowChanged); 97 KOPrefs::instance()->mWTshowChanged);
98 return "KOAgendaItem::getWhatsThisText()::internal error"; 98 return "KOAgendaItem::getWhatsThisText()::internal error";
99} 99}
100void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 100void KOAgendaItem::init ( Incidence *incidence, QDate qd )
101{ 101{
102 mIncidence = incidence; 102 mIncidence = incidence;
103 mDate = qd; 103 mDate = qd;
104 mFirstMultiItem = 0; 104 mFirstMultiItem = 0;
105 mNextMultiItem = 0; 105 mNextMultiItem = 0;
106 mLastMultiItem = 0; 106 mLastMultiItem = 0;
107 computeText(); 107 computeText();
108 108
109 if ( (incidence->typeID() == todoID ) && 109 if ( (incidence->typeID() == todoID ) &&
110 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 110 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
114 else 114 else
115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
116 } 116 }
117 else { 117 else {
118 QStringList categories = mIncidence->categories(); 118 QStringList categories = mIncidence->categories();
119 QString cat = categories.first(); 119 QString cat = categories.first();
120 if (cat.isEmpty()) { 120 if (cat.isEmpty()) {
121 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) 121 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) )
122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
123 else 123 else
124 mBackgroundColor =KOPrefs::instance()->defaultColor( incidence->calID() ); 124 mBackgroundColor =KOPrefs::instance()->defaultColor( incidence->calID() );
125 } else { 125 } else {
126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
127 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 127 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) {
128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
129 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; 129 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor;
130 } 130 }
131 } 131 }
132 132
133 } 133 }
134 mColorGroup = QColorGroup( mBackgroundColor.light(), 134 mColorGroup = QColorGroup( mBackgroundColor.light(),
135 mBackgroundColor.dark(),mBackgroundColor.light(), 135 mBackgroundColor.dark(),mBackgroundColor.light(),
136 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 136 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
137 setBackgroundColor( mBackgroundColor ); 137 setBackgroundColor( mBackgroundColor );
138 138 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250);
139 mConflictItems.clear(); 139 mConflictItems.clear();
140 setCellXY(0,0,1); 140 setCellXY(0,0,1);
141 setCellXWidth(0); 141 setCellXWidth(0);
142 setSubCell(0); 142 setSubCell(0);
143 setSubCells(1); 143 setSubCells(1);
144 setMultiItem(0,0,0); 144 setMultiItem(0,0,0);
145 startMove(); 145 startMove();
146 mSelected = true; 146 mSelected = true;
147 select(false); 147 select(false);
148 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 148 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
149 mFontPixelSize = fontinf.height();; 149 mFontPixelSize = fontinf.height();;
150 hide(); 150 hide();
151 xPaintCoord = -1; 151 xPaintCoord = -1;
152 yPaintCoord = -1; 152 yPaintCoord = -1;
153} 153}
154 154
155 155
156KOAgendaItem::~KOAgendaItem() 156KOAgendaItem::~KOAgendaItem()
157{ 157{
158#if QT_VERSION >= 0x030000 158#if QT_VERSION >= 0x030000
159 159
160#else 160#else
161 delete mKOAgendaItemWhatsThis; 161 delete mKOAgendaItemWhatsThis;
162#endif 162#endif
163 163
164} 164}
165 165
166void KOAgendaItem::recreateIncidence() 166void KOAgendaItem::recreateIncidence()
167{ 167{
168#if 0 168#if 0
169 Incidence* newInc = mIncidence->clone(); 169 Incidence* newInc = mIncidence->clone();
170 newInc->recreate(); 170 newInc->recreate();
171 if ( mIncidence->doesRecur() ) { 171 if ( mIncidence->doesRecur() ) {
172 mIncidence->addExDate( mDate ); 172 mIncidence->addExDate( mDate );
173 newInc->recurrence()->unsetRecurs(); 173 newInc->recurrence()->unsetRecurs();
174 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 174 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
175 QTime tim = mIncidence->dtStart().time(); 175 QTime tim = mIncidence->dtStart().time();
176 newInc->setDtStart( QDateTime(mDate, tim) ); 176 newInc->setDtStart( QDateTime(mDate, tim) );
177 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 177 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
178 } 178 }
179#endif 179#endif
180 mIncidence = mIncidence->recreateCloneException( mDate ); 180 mIncidence = mIncidence->recreateCloneException( mDate );
181} 181}
182bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 182bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
183{ 183{
184 int size = AGENDA_ICON_SIZE; 184 int size = AGENDA_ICON_SIZE;
185 185
186 int yOff = 0; 186 int yOff = 0;
@@ -360,98 +360,97 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
360 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 360 static const QPixmap completedPxmp = SmallIcon("greenhook16");
361 static const QPixmap overduePxmp = SmallIcon("redcross16"); 361 static const QPixmap overduePxmp = SmallIcon("redcross16");
362 if ( mIncidence->typeID() == todoID ) { 362 if ( mIncidence->typeID() == todoID ) {
363 Todo* tempTodo = static_cast<Todo*>(mIncidence); 363 Todo* tempTodo = static_cast<Todo*>(mIncidence);
364 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 364 int xx = pos().x()+(width()-completedPxmp.width()-3 );
365 int yyy = yy+3; 365 int yyy = yy+3;
366 if ( tempTodo->isCompleted() ) 366 if ( tempTodo->isCompleted() )
367 paint->drawPixmap ( xx, yyy, completedPxmp ); 367 paint->drawPixmap ( xx, yyy, completedPxmp );
368 else { 368 else {
369 paint->drawPixmap ( xx, yyy, overduePxmp ); 369 paint->drawPixmap ( xx, yyy, overduePxmp );
370 370
371 } 371 }
372 } 372 }
373 bool addIcon = false; 373 bool addIcon = false;
374 if ( ! small || w > 3 * h || h > 3* w ) 374 if ( ! small || w > 3 * h || h > 3* w )
375 addIcon = updateIcons( paint, horLayout ); 375 addIcon = updateIcons( paint, horLayout );
376 376
377 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 377 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
378 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); 378 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0);
379 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 379 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
380 if ( ! small ) { 380 if ( ! small ) {
381 x += 3; yy += 3;w -= 6; h-= 5; 381 x += 3; yy += 3;w -= 6; h-= 5;
382 } else { 382 } else {
383 x += 2; yy += 1;w -= 4; h-= 4; 383 x += 2; yy += 1;w -= 4; h-= 4;
384 if ( nfh < 6.01 ) { 384 if ( nfh < 6.01 ) {
385 yy -= 2; 385 yy -= 2;
386 h += 4; 386 h += 4;
387 } 387 }
388 else 388 else
389 if ( nfh < h -2 ) 389 if ( nfh < h -2 )
390 ++yy; 390 ++yy;
391 } 391 }
392 int align; 392 int align;
393#ifndef DESKTOP_VERSION 393#ifndef DESKTOP_VERSION
394 align = ( AlignLeft|WordBreak|AlignTop); 394 align = ( AlignLeft|WordBreak|AlignTop);
395#else 395#else
396 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 396 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
397#endif 397#endif
398 if ( addIcon ) { 398 if ( addIcon ) {
399 if ( ! horLayout ) { 399 if ( ! horLayout ) {
400 x += AGENDA_ICON_SIZE+3; 400 x += AGENDA_ICON_SIZE+3;
401 w -= (AGENDA_ICON_SIZE+3); 401 w -= (AGENDA_ICON_SIZE+3);
402 } 402 }
403 else { 403 else {
404 yy+= AGENDA_ICON_SIZE+2; 404 yy+= AGENDA_ICON_SIZE+2;
405 h -=(AGENDA_ICON_SIZE+3); 405 h -=(AGENDA_ICON_SIZE+3);
406 } 406 }
407 } 407 }
408 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 408 if ( mWhiteText )
409 if ( colsum < 250 )
410 paint->setPen ( white); 409 paint->setPen ( white);
411 if ( x < 0 ) { 410 if ( x < 0 ) {
412 w = w+x-3; 411 w = w+x-3;
413 x = 3; 412 x = 3;
414 if ( w > parentWidget()->width() ){ 413 if ( w > parentWidget()->width() ){
415 w = parentWidget()->width() - 6; 414 w = parentWidget()->width() - 6;
416#ifndef DESKTOP_VERSION 415#ifndef DESKTOP_VERSION
417 align = ( AlignHCenter|WordBreak|AlignTop); 416 align = ( AlignHCenter|WordBreak|AlignTop);
418#else 417#else
419 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 418 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
420#endif 419#endif
421 420
422 } 421 }
423 } 422 }
424 QRect dr; 423 QRect dr;
425 if ( w + x > parentWidget()->width() ) 424 if ( w + x > parentWidget()->width() )
426 w = parentWidget()->width()-x; 425 w = parentWidget()->width()-x;
427 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 426 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
428 //qDebug("%d %d %d %d ", x, yy, w, h ); 427 //qDebug("%d %d %d %d ", x, yy, w, h );
429 if ( mIncidence->cancelled() ){ 428 if ( mIncidence->cancelled() ){
430 429
431 430
432 small = ( height() < 20 ); 431 small = ( height() < 20 );
433 432
434 if ( ! small ) { 433 if ( ! small ) {
435 QFontMetrics fm ( paint->font() ); 434 QFontMetrics fm ( paint->font() );
436 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 435 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
437 } 436 }
438 437
439 } 438 }
440 pa.end(); 439 pa.end();
441 440
442} 441}
443void KOAgendaItem::resizePixmap( int w , int h ) 442void KOAgendaItem::resizePixmap( int w , int h )
444{ 443{
445 paintPix()->resize( w, h ); 444 paintPix()->resize( w, h );
446 paintPixSel()->resize( w, h ); 445 paintPixSel()->resize( w, h );
447 446
448} 447}
449QPixmap * KOAgendaItem::paintPix() 448QPixmap * KOAgendaItem::paintPix()
450{ 449{
451 static QPixmap* mPaintPix = 0; 450 static QPixmap* mPaintPix = 0;
452 if ( ! mPaintPix ) { 451 if ( ! mPaintPix ) {
453 int w = QApplication::desktop()->width(); 452 int w = QApplication::desktop()->width();
454 int h = QApplication::desktop()->height(); 453 int h = QApplication::desktop()->height();
455 mPaintPix = new QPixmap(w,h); 454 mPaintPix = new QPixmap(w,h);
456 } 455 }
457 return mPaintPix ; 456 return mPaintPix ;
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index 53658c0..d1b1940 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -77,88 +77,89 @@ class KOAgendaItem : public QWidget
77 void expandRight(int dx); 77 void expandRight(int dx);
78 int mLastMoveXPos; 78 int mLastMoveXPos;
79 79
80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
81 KOAgendaItem *last); 81 KOAgendaItem *last);
82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } 82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; } 83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; } 84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
85 85
86 Incidence *incidence() const { return mIncidence; } 86 Incidence *incidence() const { return mIncidence; }
87 QDate itemDate() { return mDate; } 87 QDate itemDate() { return mDate; }
88 88
89 /** Update the date of this item's occurence (not in the event) */ 89 /** Update the date of this item's occurence (not in the event) */
90 void setItemDate(QDate qd); 90 void setItemDate(QDate qd);
91 91
92 void setText ( const QString & text ) { mDisplayedText = text; } 92 void setText ( const QString & text ) { mDisplayedText = text; }
93 QString text () { return mDisplayedText; } 93 QString text () { return mDisplayedText; }
94 94
95 virtual bool eventFilter ( QObject *, QEvent * ); 95 virtual bool eventFilter ( QObject *, QEvent * );
96 96
97 static QToolTipGroup *toolTipGroup(); 97 static QToolTipGroup *toolTipGroup();
98 98
99 QPtrList<KOAgendaItem> conflictItems(); 99 QPtrList<KOAgendaItem> conflictItems();
100 void setConflictItems(QPtrList<KOAgendaItem>); 100 void setConflictItems(QPtrList<KOAgendaItem>);
101 void addConflictItem(KOAgendaItem *ci); 101 void addConflictItem(KOAgendaItem *ci);
102 void paintMe( bool, QPainter* painter = 0 ); 102 void paintMe( bool, QPainter* painter = 0 );
103 void repaintMe(); 103 void repaintMe();
104 static void resizePixmap( int, int ); 104 static void resizePixmap( int, int );
105 static QPixmap * paintPix(); 105 static QPixmap * paintPix();
106 static QPixmap * paintPixSel(); 106 static QPixmap * paintPixSel();
107 static QPixmap * paintPixAllday(); 107 static QPixmap * paintPixAllday();
108 void updateItem(); 108 void updateItem();
109 void computeText(); 109 void computeText();
110 void recreateIncidence(); 110 void recreateIncidence();
111 bool checkLayout(); 111 bool checkLayout();
112 public slots: 112 public slots:
113 bool updateIcons( QPainter *, bool ); 113 bool updateIcons( QPainter *, bool );
114 void select(bool=true); 114 void select(bool=true);
115 115
116 protected: 116 protected:
117 void dragEnterEvent(QDragEnterEvent *e); 117 void dragEnterEvent(QDragEnterEvent *e);
118 void dropEvent(QDropEvent *e); 118 void dropEvent(QDropEvent *e);
119 void paintEvent ( QPaintEvent * ); 119 void paintEvent ( QPaintEvent * );
120 void resizeEvent ( QResizeEvent *ev ); 120 void resizeEvent ( QResizeEvent *ev );
121 121
122 private: 122 private:
123 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; 123 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
124 bool mAllDay; 124 bool mAllDay;
125 bool mWhiteText;
125 int mCellX; 126 int mCellX;
126 int mCellXWidth; 127 int mCellXWidth;
127 int mCellYTop,mCellYBottom; 128 int mCellYTop,mCellYBottom;
128 int mSubCell; // subcell number of this item 129 int mSubCell; // subcell number of this item
129 int mSubCells; // Total number of subcells in cell of this item 130 int mSubCells; // Total number of subcells in cell of this item
130 int xPaintCoord; 131 int xPaintCoord;
131 int yPaintCoord; 132 int yPaintCoord;
132 int wPaintCoord; 133 int wPaintCoord;
133 int hPaintCoord; 134 int hPaintCoord;
134 // Variables to remember start position 135 // Variables to remember start position
135 int mStartCellX; 136 int mStartCellX;
136 int mStartCellXWidth; 137 int mStartCellXWidth;
137 int mStartCellYTop,mStartCellYBottom; 138 int mStartCellYTop,mStartCellYBottom;
138 int mLastMovePos; 139 int mLastMovePos;
139 140
140 // Multi item pointers 141 // Multi item pointers
141 KOAgendaItem *mFirstMultiItem; 142 KOAgendaItem *mFirstMultiItem;
142 KOAgendaItem *mNextMultiItem; 143 KOAgendaItem *mNextMultiItem;
143 KOAgendaItem *mLastMultiItem; 144 KOAgendaItem *mLastMultiItem;
144 145
145 int mFontPixelSize; 146 int mFontPixelSize;
146 Incidence *mIncidence; // corresponding event or todo 147 Incidence *mIncidence; // corresponding event or todo
147 QDate mDate; //date this events occurs (for recurrence) 148 QDate mDate; //date this events occurs (for recurrence)
148 //void showIcon( QLabel*, int ); 149 //void showIcon( QLabel*, int );
149 //QLabel *mTodoIconLabel; 150 //QLabel *mTodoIconLabel;
150 //QLabel *mItemLabel; 151 //QLabel *mItemLabel;
151 //QWidget *mIconBox; 152 //QWidget *mIconBox;
152 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 153 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
153 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 154 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
154 //QLabel *mIconMoreInfo; 155 //QLabel *mIconMoreInfo;
155 static QToolTipGroup *mToolTipGroup; 156 static QToolTipGroup *mToolTipGroup;
156 157
157 QColor mBackgroundColor; 158 QColor mBackgroundColor;
158 QColorGroup mColorGroup; 159 QColorGroup mColorGroup;
159 QString mDisplayedText; 160 QString mDisplayedText;
160 bool mSelected; 161 bool mSelected;
161 QPtrList<KOAgendaItem> mConflictItems; 162 QPtrList<KOAgendaItem> mConflictItems;
162}; 163};
163 164
164#endif // KOAGENDAITEM_H 165#endif // KOAGENDAITEM_H