summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-08-22 16:28:08 (UTC)
committer zautrix <zautrix>2005-08-22 16:28:08 (UTC)
commit18780cc2342097b343ee2fa50c649f425ddaed34 (patch) (unidiff)
tree6ea015c45835e96451cede982ac79a518141dd29 /korganizer
parent4a5e2a487ee162c1e3d5ea0d1c8d4bd14a65efb9 (diff)
downloadkdepimpi-18780cc2342097b343ee2fa50c649f425ddaed34.zip
kdepimpi-18780cc2342097b343ee2fa50c649f425ddaed34.tar.gz
kdepimpi-18780cc2342097b343ee2fa50c649f425ddaed34.tar.bz2
fix for the lonng agenda float fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp4
-rw-r--r--korganizer/koagendaitem.cpp8
-rw-r--r--korganizer/koagendaitem.h2
-rw-r--r--korganizer/koagendaview.cpp1
4 files changed, 8 insertions, 7 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 796d633..d9d1283 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1815,54 +1815,54 @@ KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int
1815 agendaItem->resize(mGridSpacingX,iheight ); 1815 agendaItem->resize(mGridSpacingX,iheight );
1816 agendaItem->setCellXY(X,YTop,YBottom); 1816 agendaItem->setCellXY(X,YTop,YBottom);
1817 agendaItem->setCellXWidth(X); 1817 agendaItem->setCellXWidth(X);
1818 1818
1819 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1819 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1820 mItems.append(agendaItem); 1820 mItems.append(agendaItem);
1821 1821
1822 placeSubCells(agendaItem); 1822 placeSubCells(agendaItem);
1823 1823
1824 //agendaItem->show(); 1824 //agendaItem->show();
1825 1825
1826 1826
1827 return agendaItem; 1827 return agendaItem;
1828} 1828}
1829 1829
1830 1830
1831/* 1831/*
1832 Insert all-day KOAgendaItem into agenda. 1832 Insert all-day KOAgendaItem into agenda.
1833*/ 1833*/
1834KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1834KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1835{ 1835{
1836 if (!mAllDayMode) { 1836 if (!mAllDayMode) {
1837 return 0; 1837 return 0;
1838 } 1838 }
1839 1839 //qDebug("insertallday %s -- %d - %d ",qd.toString().latin1(), XBegin, XEnd );
1840 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1840 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1841 1841
1842 agendaItem->setCellXY(XBegin,0,0); 1842 agendaItem->setCellXY(XBegin,0,0);
1843 agendaItem->setCellXWidth(XEnd); 1843 agendaItem->setCellXWidth(XEnd);
1844 agendaItem->resizeMe(mGridSpacingX, mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1844 agendaItem->resizeMe(mGridSpacingX, mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY, true );
1845 1845
1846 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1846 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1847 mItems.append(agendaItem); 1847 mItems.append(agendaItem);
1848 1848
1849 placeSubCells(agendaItem); 1849 placeSubCells(agendaItem);
1850 1850
1851 //agendaItem->show(); 1851 //agendaItem->show();
1852 1852
1853 return agendaItem; 1853 return agendaItem;
1854} 1854}
1855 1855
1856 1856
1857void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1857void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1858 int YTop,int YBottom) 1858 int YTop,int YBottom)
1859{ 1859{
1860 if (mAllDayMode) { 1860 if (mAllDayMode) {
1861 ; 1861 ;
1862 return; 1862 return;
1863 } 1863 }
1864 1864
1865 int cellX,cellYTop,cellYBottom; 1865 int cellX,cellYTop,cellYBottom;
1866 QString newtext; 1866 QString newtext;
1867 int width = XEnd - XBegin + 1; 1867 int width = XEnd - XBegin + 1;
1868 int count = 0; 1868 int count = 0;
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 7a685d8..81681df 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -561,49 +561,50 @@ void KOAgendaItem::paintEvent ( QPaintEvent *e )
561 } 561 }
562 } 562 }
563 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 563 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
564 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 564 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
565} 565}
566void KOAgendaItem::computeText() 566void KOAgendaItem::computeText()
567{ 567{
568 mDisplayedText = mIncidence->summary(); 568 mDisplayedText = mIncidence->summary();
569 if ( (mIncidence->typeID() == todoID ) ) { 569 if ( (mIncidence->typeID() == todoID ) ) {
570 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 570 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
571 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 571 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
572 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 572 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
573 else if ( !(mIncidence->doesFloat())) 573 else if ( !(mIncidence->doesFloat()))
574 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 574 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
575 } 575 }
576 } else { 576 } else {
577 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 577 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
578 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 578 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
579 579
580 if ( mAllDay ) { 580 if ( mAllDay ) {
581 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 581 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
582 if ( mIncidence->doesRecur() ) { 582 if ( mIncidence->doesRecur() ) {
583 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; 583 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
584 } else { 584 } else {
585 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 585 int dur = 1+ (static_cast<Event*>(mIncidence))->dtStart().date().daysTo( (static_cast<Event*>(mIncidence))->dtEnd().date() );
586 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) + " ("+QString::number( dur )+i18n(" days") +")" ;
586 } 587 }
587 } 588 }
588 } 589 }
589 } 590 }
590 591
591 if ( !mIncidence->location().isEmpty() ) { 592 if ( !mIncidence->location().isEmpty() ) {
592 if ( mAllDay ) 593 if ( mAllDay )
593 mDisplayedText += " ("; 594 mDisplayedText += " (";
594 else 595 else
595 mDisplayedText += "\n("; 596 mDisplayedText += "\n(";
596 mDisplayedText += mIncidence->location() +")"; 597 mDisplayedText += mIncidence->location() +")";
597 } 598 }
598#ifdef DESKTOP_VERSION 599#ifdef DESKTOP_VERSION
599 QString tipText = mIncidence->summary(); 600 QString tipText = mIncidence->summary();
600 if ( !mIncidence->doesFloat() ) { 601 if ( !mIncidence->doesFloat() ) {
601 if ( mIncidence->typeID() == eventID ) { 602 if ( mIncidence->typeID() == eventID ) {
602 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 603 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
603 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 604 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
604 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 605 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
605 } 606 }
606 else { 607 else {
607 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 608 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
608 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 609 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
609 } 610 }
@@ -637,63 +638,64 @@ void KOAgendaItem::updateItem()
637} 638}
638 639
639void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 640void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
640{ 641{
641 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 642 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
642 paintMe( mSelected ); 643 paintMe( mSelected );
643 repaint( false ); 644 repaint( false );
644} 645}
645 646
646/* 647/*
647 Return height of item in units of agenda cells 648 Return height of item in units of agenda cells
648*/ 649*/
649int KOAgendaItem::cellHeight() 650int KOAgendaItem::cellHeight()
650{ 651{
651 int ret = mCellYBottom - mCellYTop + 1; 652 int ret = mCellYBottom - mCellYTop + 1;
652 if ( ret <= 0 ) { 653 if ( ret <= 0 ) {
653 ret = 1; 654 ret = 1;
654 mCellYBottom = 0; 655 mCellYBottom = 0;
655 mCellYTop = 0; 656 mCellYTop = 0;
656 } 657 }
657 return ret; 658 return ret;
658} 659}
659// it may be that allday agenda items have a needed width > 32000 660// it may be that allday agenda items have a needed width > 32000
660// this code is to fix this problem 661// this code is to fix this problem
661int KOAgendaItem::resizeMe( int grid, int wid, int hei ) 662int KOAgendaItem::resizeMe( int grid, int wid, int hei, bool invalidWidth )
662{ 663{
663 int diff = 0; 664 int diff = 0;
664 if ( mCellX < -3 && mAllDay ) { 665 if ( mCellX < -3 && mAllDay ) {
665 diff = (mCellX + 3) * -grid; 666 diff = (mCellX + 3) * -grid;
666 //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); 667 //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid);
667 if ( diff >= wid ) { 668 if ( diff >= wid ) {
668 // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); 669 // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid);
669 //diff = 0; 670 //diff = 0;
670 } 671 }
671 } 672 }
672 if ( wid == width() || diff >= wid ) 673 if ( (!invalidWidth && wid == width() ) || diff >= wid )
673 resize( wid, hei ); 674 resize( wid, hei );
674 else 675 else
675 resize( wid - diff, hei ); 676 resize( wid - diff, hei );
677 //qDebug("wid %d x %d ", width(), x());
676 return diff; 678 return diff;
677} 679}
678/* 680/*
679 Return height of item in units of agenda cells 681 Return height of item in units of agenda cells
680*/ 682*/
681int KOAgendaItem::cellWidth() 683int KOAgendaItem::cellWidth()
682{ 684{
683 return mCellXWidth - mCellX + 1; 685 return mCellXWidth - mCellX + 1;
684} 686}
685 687
686void KOAgendaItem::setItemDate(QDate qd) 688void KOAgendaItem::setItemDate(QDate qd)
687{ 689{
688 mDate = qd; 690 mDate = qd;
689} 691}
690 692
691void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 693void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
692{ 694{
693 mCellX = X; 695 mCellX = X;
694 mCellYTop = YTop; 696 mCellYTop = YTop;
695 mCellYBottom = YBottom; 697 mCellYBottom = YBottom;
696} 698}
697 699
698void KOAgendaItem::setCellXWidth(int xwidth) 700void KOAgendaItem::setCellXWidth(int xwidth)
699{ 701{
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index 97acd4c..37d89a6 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -88,49 +88,49 @@ class KOAgendaItem : public QWidget
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 bool isAllDay() { return mAllDay; } 111 bool isAllDay() { return mAllDay; }
112 int resizeMe( int grid, int wid, int hei ); 112 int resizeMe( int grid, int wid, int hei, bool invalidHei = false );
113 public slots: 113 public slots:
114 bool updateIcons( QPainter *, bool ); 114 bool updateIcons( QPainter *, bool );
115 void select(bool=true); 115 void select(bool=true);
116 void repaintItem(); 116 void repaintItem();
117 117
118 protected: 118 protected:
119 void dragEnterEvent(QDragEnterEvent *e); 119 void dragEnterEvent(QDragEnterEvent *e);
120 void dropEvent(QDropEvent *e); 120 void dropEvent(QDropEvent *e);
121 void paintEvent ( QPaintEvent * ); 121 void paintEvent ( QPaintEvent * );
122 void resizeEvent ( QResizeEvent *ev ); 122 void resizeEvent ( QResizeEvent *ev );
123 123
124 private: 124 private:
125 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; 125 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
126 bool mAllDay; 126 bool mAllDay;
127 bool mWhiteText; 127 bool mWhiteText;
128 int mCellX; 128 int mCellX;
129 int mCellXWidth; 129 int mCellXWidth;
130 int mCellYTop,mCellYBottom; 130 int mCellYTop,mCellYBottom;
131 int mSubCell; // subcell number of this item 131 int mSubCell; // subcell number of this item
132 int mSubCells; // Total number of subcells in cell of this item 132 int mSubCells; // Total number of subcells in cell of this item
133 int xPaintCoord; 133 int xPaintCoord;
134 int yPaintCoord; 134 int yPaintCoord;
135 int wPaintCoord; 135 int wPaintCoord;
136 int hPaintCoord; 136 int hPaintCoord;
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 1cf03a0..d8a2134 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1214,49 +1214,48 @@ void KOAgendaView::fillAgenda()
1214 if ( curCol == maxCol && maxCol+1 < endX ) { 1214 if ( curCol == maxCol && maxCol+1 < endX ) {
1215 int i; 1215 int i;
1216 for ( i = 1; i< endX; ++i ) { 1216 for ( i = 1; i< endX; ++i ) {
1217 if ( event->recursOn( currentDate.addDays( -i ) ) ) 1217 if ( event->recursOn( currentDate.addDays( -i ) ) )
1218 break; 1218 break;
1219 } 1219 }
1220 if ( i > maxCol ) { 1220 if ( i > maxCol ) {
1221 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1221 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1222 //qDebug("BINGO "); 1222 //qDebug("BINGO ");
1223 } 1223 }
1224 1224
1225 } else { 1225 } else {
1226 QDate dateit = currentDate.addDays( -endX ); 1226 QDate dateit = currentDate.addDays( -endX );
1227 if ( event->recursOn( dateit ) ) { 1227 if ( event->recursOn( dateit ) ) {
1228 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); 1228 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1229 if ( curCol-endX < 0 ) { 1229 if ( curCol-endX < 0 ) {
1230 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1230 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1231 } 1231 }
1232 } 1232 }
1233 } 1233 }
1234 } 1234 }
1235 } else { 1235 } else {
1236 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1236 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1237 } 1237 }
1238
1239 } else { 1238 } else {
1240 if (beginX <= 0 && curCol == 0) { 1239 if (beginX <= 0 && curCol == 0) {
1241 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1240 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1242 } else if (beginX == curCol) { 1241 } else if (beginX == curCol) {
1243 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1242 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1244 } 1243 }
1245 } 1244 }
1246 } else if (event->isMultiDay()) { 1245 } else if (event->isMultiDay()) {
1247 if ( event->doesRecur () ) { 1246 if ( event->doesRecur () ) {
1248 QDate dateit = currentDate; 1247 QDate dateit = currentDate;
1249 int count = 0; 1248 int count = 0;
1250 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1249 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1251 while (! event->recursOn( dateit ) && count <= max ) { 1250 while (! event->recursOn( dateit ) && count <= max ) {
1252 ++count; 1251 ++count;
1253 dateit = dateit.addDays( -1 ); 1252 dateit = dateit.addDays( -1 );
1254 } 1253 }
1255 bool ok; 1254 bool ok;
1256 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1255 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1257 if ( ok ) 1256 if ( ok )
1258 { 1257 {
1259 int secs = event->dtStart().secsTo( event->dtEnd() ); 1258 int secs = event->dtStart().secsTo( event->dtEnd() );
1260 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1259 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1261 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1260 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1262 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1261 endX = currentDate.daysTo(nextOcend.date()) + curCol;