summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-05 05:29:02 (UTC)
committer zautrix <zautrix>2005-07-05 05:29:02 (UTC)
commit5992ea9025ebddde8be72322c90aac8edeaf4d1c (patch) (unidiff)
treef0d9385d80fe74af453aa23fd69715d66aeaee12
parent671d832454c8b68e0bb44e439f28fb1c768e033d (diff)
downloadkdepimpi-5992ea9025ebddde8be72322c90aac8edeaf4d1c.zip
kdepimpi-5992ea9025ebddde8be72322c90aac8edeaf4d1c.tar.gz
kdepimpi-5992ea9025ebddde8be72322c90aac8edeaf4d1c.tar.bz2
rf
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp6
-rw-r--r--korganizer/koagendaitem.cpp11
-rw-r--r--korganizer/koagendaitem.h1
3 files changed, 15 insertions, 3 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 01cef35..0280c74 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1621,98 +1621,100 @@ KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1621 1621
1622 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1622 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1623 agendaItem->installEventFilter(this); 1623 agendaItem->installEventFilter(this);
1624 addChild(agendaItem,0,0); 1624 addChild(agendaItem,0,0);
1625 return agendaItem; 1625 return agendaItem;
1626} 1626}
1627KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1627KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1628{ 1628{
1629 KOAgendaItem *item; 1629 KOAgendaItem *item;
1630 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1630 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1631 if ( item->incidence() == todo ) { 1631 if ( item->incidence() == todo ) {
1632 mItems.remove(); 1632 mItems.remove();
1633 return item; 1633 return item;
1634 } 1634 }
1635 } 1635 }
1636 return 0; 1636 return 0;
1637} 1637}
1638 1638
1639 1639
1640void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1640void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1641{ 1641{
1642 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1642 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1643 KOAgendaItem *item; 1643 KOAgendaItem *item;
1644 item = getItemForTodo ( todo ); 1644 item = getItemForTodo ( todo );
1645 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1645 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1646 if ( item ) { 1646 if ( item ) {
1647 blockSignals( true ); 1647 blockSignals( true );
1648 //qDebug("item found "); 1648 //qDebug("item found ");
1649 item->hide(); 1649 item->hide();
1650 item->setCellX(-2, -1 ); 1650 item->setCellX(-2, -1 );
1651 item->select(false); 1651 item->select(false);
1652 mUnusedItems.append( item ); 1652 mUnusedItems.append( item );
1653 mItems.remove( item ); 1653 mItems.remove( item );
1654 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1654 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1655 KOAgendaItem *itemit; 1655 KOAgendaItem *itemit;
1656 //globalFlagBlockAgendaItemPaint = 1; 1656 //globalFlagBlockAgendaItemPaint = 1;
1657 for ( itemit=oldconflictItems.first(); itemit != 0; 1657 for ( itemit=oldconflictItems.first(); itemit != 0;
1658 itemit=oldconflictItems.next() ) { 1658 itemit=oldconflictItems.next() ) {
1659 if ( itemit != item ) 1659 if ( itemit != item )
1660 placeSubCells(itemit); 1660 placeSubCells(itemit);
1661 } 1661 }
1662 qApp->processEvents(); 1662 qApp->processEvents();
1663 //globalFlagBlockAgendaItemPaint = 0; 1663 //globalFlagBlockAgendaItemPaint = 0;
1664 for ( itemit=oldconflictItems.first(); itemit != 0; 1664 for ( itemit=oldconflictItems.first(); itemit != 0;
1665 itemit=oldconflictItems.next() ) { 1665 itemit=oldconflictItems.next() ) {
1666 globalFlagBlockAgendaItemUpdate = 0; 1666 globalFlagBlockAgendaItemUpdate = 0;
1667 if ( itemit != item ) 1667 if ( itemit != item )
1668 itemit->repaintMe(); 1668 itemit->repaintMe();
1669 globalFlagBlockAgendaItemUpdate = 1; 1669 globalFlagBlockAgendaItemUpdate = 1;
1670 itemit->repaint(); 1670 //qDebug("sigleshot ");
1671 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() ));
1672 //itemit->repaint( false ); repaintItem()
1671 } 1673 }
1672 blockSignals( false ); 1674 blockSignals( false );
1673 } 1675 }
1674 if ( remove ) { 1676 if ( remove ) {
1675 //qDebug("remove****************************************** "); 1677 //qDebug("remove****************************************** ");
1676 return; 1678 return;
1677 } 1679 }
1678 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) 1680 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda )
1679 return; 1681 return;
1680 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1682 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1681 QDate currentDate = QDate::currentDate(); 1683 QDate currentDate = QDate::currentDate();
1682 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1684 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda );
1683 QDateTime dt; 1685 QDateTime dt;
1684 if ( todo->hasCompletedDate() ) 1686 if ( todo->hasCompletedDate() )
1685 dt = todo->completed(); 1687 dt = todo->completed();
1686 else 1688 else
1687 dt = todo->dtDue(); 1689 dt = todo->dtDue();
1688 if ( overdue ) { 1690 if ( overdue ) {
1689 days += todo->dtDue().date().daysTo( currentDate ); 1691 days += todo->dtDue().date().daysTo( currentDate );
1690 } 1692 }
1691 else 1693 else
1692 currentDate = dt.date(); 1694 currentDate = dt.date();
1693 1695
1694 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { 1696 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1695 if ( ! mAllDayMode ) return; 1697 if ( ! mAllDayMode ) return;
1696 // aldayagenda 1698 // aldayagenda
1697 globalFlagBlockAgendaItemPaint = 1; 1699 globalFlagBlockAgendaItemPaint = 1;
1698 item = insertAllDayItem(todo, currentDate,days, days); 1700 item = insertAllDayItem(todo, currentDate,days, days);
1699 item->show(); 1701 item->show();
1700 1702
1701 } 1703 }
1702 else { 1704 else {
1703 if ( mAllDayMode ) return; 1705 if ( mAllDayMode ) return;
1704 // mAgenda 1706 // mAgenda
1705 globalFlagBlockAgendaItemPaint = 1; 1707 globalFlagBlockAgendaItemPaint = 1;
1706 int endY = timeToY(dt.time()) - 1; 1708 int endY = timeToY(dt.time()) - 1;
1707 int hi = 12/KOPrefs::instance()->mHourSize; 1709 int hi = 12/KOPrefs::instance()->mHourSize;
1708 int startY = endY - 1-hi; 1710 int startY = endY - 1-hi;
1709 item = insertItem(todo,currentDate,days,startY,endY); 1711 item = insertItem(todo,currentDate,days,startY,endY);
1710 item->show(); 1712 item->show();
1711 } 1713 }
1712 qApp->processEvents(); 1714 qApp->processEvents();
1713 globalFlagBlockAgendaItemPaint = 0; 1715 globalFlagBlockAgendaItemPaint = 0;
1714 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1716 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1715 KOAgendaItem *itemit; 1717 KOAgendaItem *itemit;
1716 for ( itemit=oldconflictItems.first(); itemit != 0; 1718 for ( itemit=oldconflictItems.first(); itemit != 0;
1717 itemit=oldconflictItems.next() ) { 1719 itemit=oldconflictItems.next() ) {
1718 globalFlagBlockAgendaItemUpdate = 0; 1720 globalFlagBlockAgendaItemUpdate = 0;
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index f855b03..8675ff6 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -447,103 +447,112 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
447 align = ( AlignHCenter|WordBreak|AlignTop); 447 align = ( AlignHCenter|WordBreak|AlignTop);
448#else 448#else
449 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 449 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
450#endif 450#endif
451 451
452 } 452 }
453 } 453 }
454 QRect dr; 454 QRect dr;
455 if ( w + x > parentWidget()->width() ) 455 if ( w + x > parentWidget()->width() )
456 w = parentWidget()->width()-x; 456 w = parentWidget()->width()-x;
457 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 457 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
458 //qDebug("%d %d %d %d ", x, yy, w, h ); 458 //qDebug("%d %d %d %d ", x, yy, w, h );
459 if ( mIncidence->cancelled() ){ 459 if ( mIncidence->cancelled() ){
460 460
461 461
462 small = ( height() < 20 ); 462 small = ( height() < 20 );
463 463
464 if ( ! small ) { 464 if ( ! small ) {
465 QFontMetrics fm ( paint->font() ); 465 QFontMetrics fm ( paint->font() );
466 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 466 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
467 } 467 }
468 468
469 } 469 }
470 pa.end(); 470 pa.end();
471 471
472} 472}
473 473
474QPixmap * KOAgendaItem::paintPix() 474QPixmap * KOAgendaItem::paintPix()
475{ 475{
476 static QPixmap* mPaintPix = 0; 476 static QPixmap* mPaintPix = 0;
477 if ( ! mPaintPix ) { 477 if ( ! mPaintPix ) {
478 int w = QApplication::desktop()->width(); 478 int w = QApplication::desktop()->width();
479 int h = QApplication::desktop()->height(); 479 int h = QApplication::desktop()->height();
480 mPaintPix = new QPixmap(w,h); 480 mPaintPix = new QPixmap(w,h);
481 } 481 }
482 return mPaintPix ; 482 return mPaintPix ;
483} 483}
484QPixmap * KOAgendaItem::paintPixAllday() 484QPixmap * KOAgendaItem::paintPixAllday()
485{ 485{
486 static QPixmap* mPaintPixA = 0; 486 static QPixmap* mPaintPixA = 0;
487 if ( ! mPaintPixA ) { 487 if ( ! mPaintPixA ) {
488 int w = QApplication::desktop()->width(); 488 int w = QApplication::desktop()->width();
489 int h = QApplication::desktop()->height()/5; 489 int h = QApplication::desktop()->height()/5;
490 mPaintPixA = new QPixmap(w,h); 490 mPaintPixA = new QPixmap(w,h);
491 } 491 }
492 return mPaintPixA ; 492 return mPaintPixA ;
493} 493}
494 494
495void KOAgendaItem::repaintItem()
496{
497 globalFlagBlockAgendaItemPaint = 0;
498 globalFlagBlockAgenda = 0;
499 //qDebug("AAA ");
500 repaint( false );
501 //qDebug("BBB ");
502}
495void KOAgendaItem::paintEvent ( QPaintEvent *e ) 503void KOAgendaItem::paintEvent ( QPaintEvent *e )
496{ 504{
497 505 qDebug("CCC ");
498 if ( globalFlagBlockAgendaItemPaint ) 506 if ( globalFlagBlockAgendaItemPaint )
499 return; 507 return;
500 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 508 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
501 return; 509 return;
510 qDebug("DDD ");
502 int yy; 511 int yy;
503 if ( mAllDay ) 512 if ( mAllDay )
504 yy = y(); 513 yy = y();
505 else 514 else
506 yy = mCellYTop * ( height() / cellHeight() ); 515 yy = mCellYTop * ( height() / cellHeight() );
507 int xx = x(); 516 int xx = x();
508 517
509 if ( xPaintCoord != xx || yPaintCoord != yy || 518 if ( xPaintCoord != xx || yPaintCoord != yy ||
510 wPaintCoord != width() || hPaintCoord != height()) { 519 wPaintCoord != width() || hPaintCoord != height()) {
511 xPaintCoord= xx; 520 xPaintCoord= xx;
512 yPaintCoord = yy; 521 yPaintCoord = yy;
513 wPaintCoord = width(); 522 wPaintCoord = width();
514 hPaintCoord = height(); 523 hPaintCoord = height();
515 globalFlagBlockAgendaItemUpdate = 0; 524 globalFlagBlockAgendaItemUpdate = 0;
516 paintMe( mSelected ); 525 paintMe( mSelected );
517 //qDebug("calling paintMe "); 526 //qDebug("calling paintMe ");
518 globalFlagBlockAgendaItemUpdate = 1; 527 globalFlagBlockAgendaItemUpdate = 1;
519 if ( mSelected ) 528 if ( mSelected )
520 return; 529 return;
521 } 530 }
522 int rx, ry, rw, rh; 531 int rx, ry, rw, rh;
523 rx = e->rect().x(); 532 rx = e->rect().x();
524 ry = e->rect().y(); 533 ry = e->rect().y();
525 rw = e->rect().width(); 534 rw = e->rect().width();
526 rh = e->rect().height(); 535 rh = e->rect().height();
527 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 536 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
528 537
529 QPixmap* paintFrom ; 538 QPixmap* paintFrom ;
530 if ( mSelected ) { 539 if ( mSelected ) {
531 paintMe( mSelected ); 540 paintMe( mSelected );
532 return; 541 return;
533 } else { 542 } else {
534 if ( mAllDay ) 543 if ( mAllDay )
535 paintFrom = paintPixAllday(); 544 paintFrom = paintPixAllday();
536 else 545 else
537 paintFrom = paintPix(); 546 paintFrom = paintPix();
538 } 547 }
539 xx += rx; 548 xx += rx;
540 549
541 if ( xx < 0 ) { 550 if ( xx < 0 ) {
542 rw = rw + xx; 551 rw = rw + xx;
543 rx -= xx; 552 rx -= xx;
544 xx = 0; 553 xx = 0;
545 if ( rw <= 1 ) { 554 if ( rw <= 1 ) {
546 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 555 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
547 return; 556 return;
548 } 557 }
549 } 558 }
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index 3ed68b0..99c564a 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -66,96 +66,97 @@ class KOAgendaItem : public QWidget
66 void setSubCells(int subCells); 66 void setSubCells(int subCells);
67 67
68 /** Start movement */ 68 /** Start movement */
69 void startMove(); 69 void startMove();
70 /** Reset to original values */ 70 /** Reset to original values */
71 void resetMove(); 71 void resetMove();
72 72
73 void moveRelative(int dx,int dy); 73 void moveRelative(int dx,int dy);
74 void expandTop(int dy); 74 void expandTop(int dy);
75 void expandBottom(int dy); 75 void expandBottom(int dy);
76 void expandLeft(int dx); 76 void expandLeft(int dx);
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 QPixmap * paintPix(); 104 static QPixmap * paintPix();
105 static QPixmap * paintPixAllday(); 105 static QPixmap * paintPixAllday();
106 void updateItem(); 106 void updateItem();
107 void computeText(); 107 void computeText();
108 void recreateIncidence(); 108 void recreateIncidence();
109 bool checkLayout(); 109 bool checkLayout();
110 void initColor (); 110 void initColor ();
111 public slots: 111 public slots:
112 bool updateIcons( QPainter *, bool ); 112 bool updateIcons( QPainter *, bool );
113 void select(bool=true); 113 void select(bool=true);
114 void repaintItem();
114 115
115 protected: 116 protected:
116 void dragEnterEvent(QDragEnterEvent *e); 117 void dragEnterEvent(QDragEnterEvent *e);
117 void dropEvent(QDropEvent *e); 118 void dropEvent(QDropEvent *e);
118 void paintEvent ( QPaintEvent * ); 119 void paintEvent ( QPaintEvent * );
119 void resizeEvent ( QResizeEvent *ev ); 120 void resizeEvent ( QResizeEvent *ev );
120 121
121 private: 122 private:
122 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; 123 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
123 bool mAllDay; 124 bool mAllDay;
124 bool mWhiteText; 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;