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
@@ -1743,198 +1743,198 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1743 //qDebug("remove****************************************** "); 1743 //qDebug("remove****************************************** ");
1744 return; 1744 return;
1745 } 1745 }
1746 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) 1746 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda )
1747 return; 1747 return;
1748 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1748 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1749 QDate currentDate = QDate::currentDate(); 1749 QDate currentDate = QDate::currentDate();
1750 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1750 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda );
1751 QDateTime dt; 1751 QDateTime dt;
1752 if ( todo->hasCompletedDate() ) 1752 if ( todo->hasCompletedDate() )
1753 dt = todo->completed(); 1753 dt = todo->completed();
1754 else 1754 else
1755 dt = todo->dtDue(); 1755 dt = todo->dtDue();
1756 if ( overdue ) { 1756 if ( overdue ) {
1757 days += todo->dtDue().date().daysTo( currentDate ); 1757 days += todo->dtDue().date().daysTo( currentDate );
1758 } 1758 }
1759 else 1759 else
1760 currentDate = dt.date(); 1760 currentDate = dt.date();
1761 1761
1762 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { 1762 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1763 if ( ! mAllDayMode ) return; 1763 if ( ! mAllDayMode ) return;
1764 // aldayagenda 1764 // aldayagenda
1765 globalFlagBlockAgendaItemPaint = 1; 1765 globalFlagBlockAgendaItemPaint = 1;
1766 item = insertAllDayItem(todo, currentDate,days, days); 1766 item = insertAllDayItem(todo, currentDate,days, days);
1767 item->show(); 1767 item->show();
1768 1768
1769 } 1769 }
1770 else { 1770 else {
1771 if ( mAllDayMode ) return; 1771 if ( mAllDayMode ) return;
1772 // mAgenda 1772 // mAgenda
1773 globalFlagBlockAgendaItemPaint = 1; 1773 globalFlagBlockAgendaItemPaint = 1;
1774 int endY = timeToY(dt.time()) - 1; 1774 int endY = timeToY(dt.time()) - 1;
1775 int hi = 12/KOPrefs::instance()->mHourSize; 1775 int hi = 12/KOPrefs::instance()->mHourSize;
1776 int startY = endY - 1-hi; 1776 int startY = endY - 1-hi;
1777 item = insertItem(todo,currentDate,days,startY,endY); 1777 item = insertItem(todo,currentDate,days,startY,endY);
1778 item->show(); 1778 item->show();
1779 } 1779 }
1780 qApp->processEvents(); 1780 qApp->processEvents();
1781 globalFlagBlockAgendaItemPaint = 0; 1781 globalFlagBlockAgendaItemPaint = 0;
1782 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1782 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1783 KOAgendaItem *itemit; 1783 KOAgendaItem *itemit;
1784 for ( itemit=oldconflictItems.first(); itemit != 0; 1784 for ( itemit=oldconflictItems.first(); itemit != 0;
1785 itemit=oldconflictItems.next() ) { 1785 itemit=oldconflictItems.next() ) {
1786 globalFlagBlockAgendaItemUpdate = 0; 1786 globalFlagBlockAgendaItemUpdate = 0;
1787 itemit->repaintMe(); 1787 itemit->repaintMe();
1788 globalFlagBlockAgendaItemUpdate = 1; 1788 globalFlagBlockAgendaItemUpdate = 1;
1789 itemit->repaint(); 1789 itemit->repaint();
1790 } 1790 }
1791 globalFlagBlockAgendaItemUpdate = 0; 1791 globalFlagBlockAgendaItemUpdate = 0;
1792 item->repaintMe(); 1792 item->repaintMe();
1793 globalFlagBlockAgendaItemUpdate = 1; 1793 globalFlagBlockAgendaItemUpdate = 1;
1794 item->repaint(); 1794 item->repaint();
1795} 1795}
1796/* 1796/*
1797 Insert KOAgendaItem into agenda. 1797 Insert KOAgendaItem into agenda.
1798*/ 1798*/
1799KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1799KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1800{ 1800{
1801 if (mAllDayMode) { 1801 if (mAllDayMode) {
1802 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); 1802 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
1803 return 0; 1803 return 0;
1804 } 1804 }
1805 1805
1806 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1806 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1807 //agendaItem->setFrameStyle(WinPanel|Raised); 1807 //agendaItem->setFrameStyle(WinPanel|Raised);
1808 1808
1809 int YSize = YBottom - YTop + 1; 1809 int YSize = YBottom - YTop + 1;
1810 if (YSize < 0) { 1810 if (YSize < 0) {
1811 YSize = 1; 1811 YSize = 1;
1812 } 1812 }
1813 int iheight = mGridSpacingY * YSize; 1813 int iheight = mGridSpacingY * YSize;
1814 1814
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;
1869 KOAgendaItem *current = 0; 1869 KOAgendaItem *current = 0;
1870 QPtrList<KOAgendaItem> multiItems; 1870 QPtrList<KOAgendaItem> multiItems;
1871 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1871 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1872 if (cellX == XBegin) cellYTop = YTop; 1872 if (cellX == XBegin) cellYTop = YTop;
1873 else cellYTop = 0; 1873 else cellYTop = 0;
1874 if (cellX == XEnd) cellYBottom = YBottom; 1874 if (cellX == XEnd) cellYBottom = YBottom;
1875 else cellYBottom = rows() - 1; 1875 else cellYBottom = rows() - 1;
1876 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1876 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1877 newtext.append(event->summary()); 1877 newtext.append(event->summary());
1878 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1878 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1879 current->setText(newtext); 1879 current->setText(newtext);
1880 multiItems.append(current); 1880 multiItems.append(current);
1881 } 1881 }
1882 1882
1883 KOAgendaItem *next = 0; 1883 KOAgendaItem *next = 0;
1884 KOAgendaItem *last = multiItems.last(); 1884 KOAgendaItem *last = multiItems.last();
1885 KOAgendaItem *first = multiItems.first(); 1885 KOAgendaItem *first = multiItems.first();
1886 KOAgendaItem *setFirst,*setLast; 1886 KOAgendaItem *setFirst,*setLast;
1887 current = first; 1887 current = first;
1888 while (current) { 1888 while (current) {
1889 next = multiItems.next(); 1889 next = multiItems.next();
1890 if (current == first) setFirst = 0; 1890 if (current == first) setFirst = 0;
1891 else setFirst = first; 1891 else setFirst = first;
1892 if (current == last) setLast = 0; 1892 if (current == last) setLast = 0;
1893 else setLast = last; 1893 else setLast = last;
1894 1894
1895 current->setMultiItem(setFirst,next,setLast); 1895 current->setMultiItem(setFirst,next,setLast);
1896 current = next; 1896 current = next;
1897 } 1897 }
1898} 1898}
1899 1899
1900 1900
1901//QSizePolicy KOAgenda::sizePolicy() const 1901//QSizePolicy KOAgenda::sizePolicy() const
1902//{ 1902//{
1903 // Thought this would make the all-day event agenda minimum size and the 1903 // Thought this would make the all-day event agenda minimum size and the
1904 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1904 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1905 // don´t seem to think that an Expanding widget needs more space than a 1905 // don´t seem to think that an Expanding widget needs more space than a
1906 // Preferred one. 1906 // Preferred one.
1907 // But it doesn´t hurt, so it stays. 1907 // But it doesn´t hurt, so it stays.
1908// if (mAllDayMode) { 1908// if (mAllDayMode) {
1909// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1909// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1910// } else { 1910// } else {
1911// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1911// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1912// } 1912// }
1913//} 1913//}
1914void KOAgenda::finishResize ( ) 1914void KOAgenda::finishResize ( )
1915{ 1915{
1916 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1916 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1917 if ( globalFlagBlockAgenda == 0 ) { 1917 if ( globalFlagBlockAgenda == 0 ) {
1918 finishUpdate(); 1918 finishUpdate();
1919 //qDebug("finishUpdate() called "); 1919 //qDebug("finishUpdate() called ");
1920 } 1920 }
1921} 1921}
1922/* 1922/*
1923 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1923 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1924*/ 1924*/
1925void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1925void KOAgenda::resizeEvent ( QResizeEvent *ev )
1926{ 1926{
1927 mSelectionHeight = 0; 1927 mSelectionHeight = 0;
1928 mResizeTimer.start( 150 , true ); 1928 mResizeTimer.start( 150 , true );
1929 computeSizes(); 1929 computeSizes();
1930 QScrollView::resizeEvent( ev ); 1930 QScrollView::resizeEvent( ev );
1931 return; 1931 return;
1932 1932
1933} 1933}
1934void KOAgenda::computeSizes() 1934void KOAgenda::computeSizes()
1935{ 1935{
1936 if ( globalFlagBlockStartup ) 1936 if ( globalFlagBlockStartup )
1937 return; 1937 return;
1938 int frameOffset = frameWidth() * 2 +1; 1938 int frameOffset = frameWidth() * 2 +1;
1939 if (mAllDayMode) { 1939 if (mAllDayMode) {
1940 mGridSpacingX = (width()-frameOffset) / mColumns; 1940 mGridSpacingX = (width()-frameOffset) / mColumns;
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 7a685d8..81681df 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -489,283 +489,285 @@ QPixmap * KOAgendaItem::paintPixAllday()
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() 495void KOAgendaItem::repaintItem()
496{ 496{
497 globalFlagBlockAgendaItemPaint = 0; 497 globalFlagBlockAgendaItemPaint = 0;
498 globalFlagBlockAgenda = 0; 498 globalFlagBlockAgenda = 0;
499 repaint( false ); 499 repaint( false );
500} 500}
501void KOAgendaItem::paintEvent ( QPaintEvent *e ) 501void KOAgendaItem::paintEvent ( QPaintEvent *e )
502{ 502{
503 503
504 if ( globalFlagBlockAgendaItemPaint ) 504 if ( globalFlagBlockAgendaItemPaint )
505 return; 505 return;
506 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 506 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
507 return; 507 return;
508 int yy; 508 int yy;
509 if ( mAllDay ) 509 if ( mAllDay )
510 yy = y(); 510 yy = y();
511 else 511 else
512 yy = mCellYTop * ( height() / cellHeight() ); 512 yy = mCellYTop * ( height() / cellHeight() );
513 int xx = x(); 513 int xx = x();
514 514
515 if ( xPaintCoord != xx || yPaintCoord != yy || 515 if ( xPaintCoord != xx || yPaintCoord != yy ||
516 wPaintCoord != width() || hPaintCoord != height()) { 516 wPaintCoord != width() || hPaintCoord != height()) {
517 xPaintCoord= xx; 517 xPaintCoord= xx;
518 yPaintCoord = yy; 518 yPaintCoord = yy;
519 wPaintCoord = width(); 519 wPaintCoord = width();
520 hPaintCoord = height(); 520 hPaintCoord = height();
521 globalFlagBlockAgendaItemUpdate = 0; 521 globalFlagBlockAgendaItemUpdate = 0;
522 paintMe( mSelected ); 522 paintMe( mSelected );
523 //qDebug("calling paintMe "); 523 //qDebug("calling paintMe ");
524 globalFlagBlockAgendaItemUpdate = 1; 524 globalFlagBlockAgendaItemUpdate = 1;
525 if ( mSelected ) 525 if ( mSelected )
526 return; 526 return;
527 } 527 }
528 int rx, ry, rw, rh; 528 int rx, ry, rw, rh;
529 rx = e->rect().x(); 529 rx = e->rect().x();
530 ry = e->rect().y(); 530 ry = e->rect().y();
531 rw = e->rect().width(); 531 rw = e->rect().width();
532 rh = e->rect().height(); 532 rh = e->rect().height();
533 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 533 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
534 534
535 QPixmap* paintFrom ; 535 QPixmap* paintFrom ;
536 if ( mSelected ) { 536 if ( mSelected ) {
537 paintMe( mSelected ); 537 paintMe( mSelected );
538 return; 538 return;
539 } else { 539 } else {
540 if ( mAllDay ) 540 if ( mAllDay )
541 paintFrom = paintPixAllday(); 541 paintFrom = paintPixAllday();
542 else 542 else
543 paintFrom = paintPix(); 543 paintFrom = paintPix();
544 } 544 }
545 xx += rx; 545 xx += rx;
546 546
547 if ( xx < 0 ) { 547 if ( xx < 0 ) {
548 rw = rw + xx; 548 rw = rw + xx;
549 rx -= xx; 549 rx -= xx;
550 xx = 0; 550 xx = 0;
551 if ( rw <= 1 ) { 551 if ( rw <= 1 ) {
552 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 552 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
553 return; 553 return;
554 } 554 }
555 } 555 }
556 if ( paintFrom->width() < xx+rw ) { 556 if ( paintFrom->width() < xx+rw ) {
557 rw = paintFrom->width() - xx; 557 rw = paintFrom->width() - xx;
558 if ( rw <= 1 ) { 558 if ( rw <= 1 ) {
559 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 559 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
560 return; 560 return;
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 }
610 } 611 }
611 else if ( mIncidence->typeID() == todoID ) { 612 else if ( mIncidence->typeID() == todoID ) {
612 if (mIncidence->hasStartDate()) 613 if (mIncidence->hasStartDate())
613 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 614 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
614 if (((Todo*)mIncidence)->hasDueDate()) 615 if (((Todo*)mIncidence)->hasDueDate())
615 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 616 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
616 } 617 }
617 } else if ( mIncidence->typeID() == todoID ) { 618 } else if ( mIncidence->typeID() == todoID ) {
618 if (mIncidence->hasStartDate()) 619 if (mIncidence->hasStartDate())
619 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 620 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
620 if (((Todo*)mIncidence)->hasDueDate()) 621 if (((Todo*)mIncidence)->hasDueDate())
621 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 622 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
622 } 623 }
623 624
624 if (!mIncidence->location().isEmpty()) { 625 if (!mIncidence->location().isEmpty()) {
625 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 626 tipText += "\n"+i18n("Location: ")+mIncidence->location();
626 } 627 }
627 QToolTip::add(this,tipText,toolTipGroup(),""); 628 QToolTip::add(this,tipText,toolTipGroup(),"");
628#endif 629#endif
629} 630}
630void KOAgendaItem::updateItem() 631void KOAgendaItem::updateItem()
631{ 632{
632 computeText(); 633 computeText();
633 634
634 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 635 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
635 paintMe( mSelected ); 636 paintMe( mSelected );
636 repaint( false); 637 repaint( false);
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{
700 mCellXWidth = xwidth; 702 mCellXWidth = xwidth;
701} 703}
702 704
703void KOAgendaItem::setCellX(int XLeft, int XRight) 705void KOAgendaItem::setCellX(int XLeft, int XRight)
704{ 706{
705 mCellX = XLeft; 707 mCellX = XLeft;
706 mCellXWidth = XRight; 708 mCellXWidth = XRight;
707} 709}
708 710
709void KOAgendaItem::setCellY(int YTop, int YBottom) 711void KOAgendaItem::setCellY(int YTop, int YBottom)
710{ 712{
711 mCellYTop = YTop; 713 mCellYTop = YTop;
712 mCellYBottom = YBottom; 714 mCellYBottom = YBottom;
713} 715}
714 716
715void KOAgendaItem::setSubCell(int subCell) 717void KOAgendaItem::setSubCell(int subCell)
716{ 718{
717 mSubCell = subCell; 719 mSubCell = subCell;
718} 720}
719 721
720void KOAgendaItem::setSubCells(int subCells) 722void KOAgendaItem::setSubCells(int subCells)
721{ 723{
722 mSubCells = subCells; 724 mSubCells = subCells;
723} 725}
724 726
725void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 727void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
726 KOAgendaItem *last) 728 KOAgendaItem *last)
727{ 729{
728 mFirstMultiItem = first; 730 mFirstMultiItem = first;
729 mNextMultiItem = next; 731 mNextMultiItem = next;
730 mLastMultiItem = last; 732 mLastMultiItem = last;
731} 733}
732 734
733void KOAgendaItem::startMove() 735void KOAgendaItem::startMove()
734{ 736{
735 mStartCellX = mCellX; 737 mStartCellX = mCellX;
736 mStartCellXWidth = mCellXWidth; 738 mStartCellXWidth = mCellXWidth;
737 mStartCellYTop = mCellYTop; 739 mStartCellYTop = mCellYTop;
738 mStartCellYBottom = mCellYBottom; 740 mStartCellYBottom = mCellYBottom;
739} 741}
740 742
741void KOAgendaItem::resetMove() 743void KOAgendaItem::resetMove()
742{ 744{
743 mCellX = mStartCellX; 745 mCellX = mStartCellX;
744 mCellXWidth = mStartCellXWidth; 746 mCellXWidth = mStartCellXWidth;
745 mCellYTop = mStartCellYTop; 747 mCellYTop = mStartCellYTop;
746 mCellYBottom = mStartCellYBottom; 748 mCellYBottom = mStartCellYBottom;
747} 749}
748 750
749void KOAgendaItem::moveRelative(int dx, int dy) 751void KOAgendaItem::moveRelative(int dx, int dy)
750{ 752{
751 int newX = cellX() + dx; 753 int newX = cellX() + dx;
752 int newXWidth = cellXWidth() + dx; 754 int newXWidth = cellXWidth() + dx;
753 int newYTop = cellYTop() + dy; 755 int newYTop = cellYTop() + dy;
754 int newYBottom = cellYBottom() + dy; 756 int newYBottom = cellYBottom() + dy;
755 setCellXY(newX,newYTop,newYBottom); 757 setCellXY(newX,newYTop,newYBottom);
756 setCellXWidth(newXWidth); 758 setCellXWidth(newXWidth);
757} 759}
758 760
759void KOAgendaItem::expandTop(int dy) 761void KOAgendaItem::expandTop(int dy)
760{ 762{
761 int newYTop = cellYTop() + dy; 763 int newYTop = cellYTop() + dy;
762 int newYBottom = cellYBottom(); 764 int newYBottom = cellYBottom();
763 if (newYTop > newYBottom) newYTop = newYBottom; 765 if (newYTop > newYBottom) newYTop = newYBottom;
764 setCellY(newYTop, newYBottom); 766 setCellY(newYTop, newYBottom);
765} 767}
766 768
767void KOAgendaItem::expandBottom(int dy) 769void KOAgendaItem::expandBottom(int dy)
768{ 770{
769 int newYTop = cellYTop(); 771 int newYTop = cellYTop();
770 int newYBottom = cellYBottom() + dy; 772 int newYBottom = cellYBottom() + dy;
771 if (newYBottom < newYTop) newYBottom = newYTop; 773 if (newYBottom < newYTop) newYBottom = newYTop;
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index 97acd4c..37d89a6 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -16,152 +16,152 @@
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef KOAGENDAITEM_H 19#ifndef KOAGENDAITEM_H
20#define KOAGENDAITEM_H 20#define KOAGENDAITEM_H
21 21
22#include <qframe.h> 22#include <qframe.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qpalette.h> 26#include <qpalette.h>
27 27
28#include <libkcal/incidence.h> 28#include <libkcal/incidence.h>
29 29
30class KOAgendaItemWhatsThis; 30class KOAgendaItemWhatsThis;
31class QToolTipGroup; 31class QToolTipGroup;
32class QDragEnterEvent; 32class QDragEnterEvent;
33class QDropEvent; 33class QDropEvent;
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37/* 37/*
38 The KOAgendaItem has to make sure that it receives all mouse events, which are 38 The KOAgendaItem has to make sure that it receives all mouse events, which are
39 to be used for dragging and resizing. That means it has to be installed as 39 to be used for dragging and resizing. That means it has to be installed as
40 eventfiler for its children, if it has children, and it has to pass mouse 40 eventfiler for its children, if it has children, and it has to pass mouse
41 events from the cildren to itself. See eventFilter(). 41 events from the cildren to itself. See eventFilter().
42*/ 42*/
43class KOAgendaItem : public QWidget 43class KOAgendaItem : public QWidget
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 public: 46 public:
47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, 47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0,
48 WFlags f=0 ); 48 WFlags f=0 );
49 ~KOAgendaItem(); 49 ~KOAgendaItem();
50 QString getWhatsThisText(); 50 QString getWhatsThisText();
51 void init ( Incidence *incidence, QDate qd ); 51 void init ( Incidence *incidence, QDate qd );
52 int cellX() { return mCellX; } 52 int cellX() { return mCellX; }
53 int cellXWidth() { return mCellXWidth; } 53 int cellXWidth() { return mCellXWidth; }
54 int cellYTop() { return mCellYTop; } 54 int cellYTop() { return mCellYTop; }
55 int cellYBottom() { return mCellYBottom; } 55 int cellYBottom() { return mCellYBottom; }
56 int cellHeight(); 56 int cellHeight();
57 int cellWidth(); 57 int cellWidth();
58 int subCell() { return mSubCell; } 58 int subCell() { return mSubCell; }
59 int subCells() { return mSubCells; } 59 int subCells() { return mSubCells; }
60 60
61 void setCellXY(int X, int YTop, int YBottom); 61 void setCellXY(int X, int YTop, int YBottom);
62 void setCellY(int YTop, int YBottom); 62 void setCellY(int YTop, int YBottom);
63 void setCellX(int XLeft, int XRight); 63 void setCellX(int XLeft, int XRight);
64 void setCellXWidth(int xwidth); 64 void setCellXWidth(int xwidth);
65 void setSubCell(int subCell); 65 void setSubCell(int subCell);
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 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;
137 // Variables to remember start position 137 // Variables to remember start position
138 int mStartCellX; 138 int mStartCellX;
139 int mStartCellXWidth; 139 int mStartCellXWidth;
140 int mStartCellYTop,mStartCellYBottom; 140 int mStartCellYTop,mStartCellYBottom;
141 int mLastMovePos; 141 int mLastMovePos;
142 142
143 // Multi item pointers 143 // Multi item pointers
144 KOAgendaItem *mFirstMultiItem; 144 KOAgendaItem *mFirstMultiItem;
145 KOAgendaItem *mNextMultiItem; 145 KOAgendaItem *mNextMultiItem;
146 KOAgendaItem *mLastMultiItem; 146 KOAgendaItem *mLastMultiItem;
147 147
148 int mFontPixelSize; 148 int mFontPixelSize;
149 Incidence *mIncidence; // corresponding event or todo 149 Incidence *mIncidence; // corresponding event or todo
150 QDate mDate; //date this events occurs (for recurrence) 150 QDate mDate; //date this events occurs (for recurrence)
151 //void showIcon( QLabel*, int ); 151 //void showIcon( QLabel*, int );
152 //QLabel *mTodoIconLabel; 152 //QLabel *mTodoIconLabel;
153 //QLabel *mItemLabel; 153 //QLabel *mItemLabel;
154 //QWidget *mIconBox; 154 //QWidget *mIconBox;
155 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 155 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
156 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 156 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
157 //QLabel *mIconMoreInfo; 157 //QLabel *mIconMoreInfo;
158 static QToolTipGroup *mToolTipGroup; 158 static QToolTipGroup *mToolTipGroup;
159 159
160 QColor mBackgroundColor; 160 QColor mBackgroundColor;
161 QColorGroup mColorGroup; 161 QColorGroup mColorGroup;
162 QString mDisplayedText; 162 QString mDisplayedText;
163 bool mSelected; 163 bool mSelected;
164 QPtrList<KOAgendaItem> mConflictItems; 164 QPtrList<KOAgendaItem> mConflictItems;
165}; 165};
166 166
167#endif // KOAGENDAITEM_H 167#endif // KOAGENDAITEM_H
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 1cf03a0..d8a2134 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1142,193 +1142,192 @@ void KOAgendaView::fillAgenda()
1142 return; 1142 return;
1143 static bool onlyOne = false; 1143 static bool onlyOne = false;
1144 if ( onlyOne ) 1144 if ( onlyOne )
1145 return; 1145 return;
1146 onlyOne = true; 1146 onlyOne = true;
1147 //if ( globalFlagBlockAgenda == 2 ) 1147 //if ( globalFlagBlockAgenda == 2 )
1148 //globalFlagBlockAgenda = 0; 1148 //globalFlagBlockAgenda = 0;
1149 // globalFlagBlockPainting = false; 1149 // globalFlagBlockPainting = false;
1150 if ( globalFlagBlockAgenda == 0 ) 1150 if ( globalFlagBlockAgenda == 0 )
1151 globalFlagBlockAgenda = 1; 1151 globalFlagBlockAgenda = 1;
1152 // clearView(); 1152 // clearView();
1153 //qDebug("fillAgenda()++++ "); 1153 //qDebug("fillAgenda()++++ ");
1154 globalFlagBlockAgendaItemPaint = 1; 1154 globalFlagBlockAgendaItemPaint = 1;
1155 1155
1156 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1156 mAllDayAgenda->changeColumns(mSelectedDates.count());
1157 mAgenda->changeColumns(mSelectedDates.count()); 1157 mAgenda->changeColumns(mSelectedDates.count());
1158 qApp->processEvents(); 1158 qApp->processEvents();
1159 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1159 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1160 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1160 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1161 setHolidayMasks(); 1161 setHolidayMasks();
1162 1162
1163 mMinY.resize(mSelectedDates.count()); 1163 mMinY.resize(mSelectedDates.count());
1164 mMaxY.resize(mSelectedDates.count()); 1164 mMaxY.resize(mSelectedDates.count());
1165 1165
1166 QPtrList<Event> dayEvents; 1166 QPtrList<Event> dayEvents;
1167 1167
1168 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1168 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1169 // Therefore, gtodoset all of them. 1169 // Therefore, gtodoset all of them.
1170 QPtrList<Todo> todos = calendar()->todos(); 1170 QPtrList<Todo> todos = calendar()->todos();
1171 1171
1172 mAgenda->setDateList(mSelectedDates); 1172 mAgenda->setDateList(mSelectedDates);
1173 1173
1174 QDate today = QDate::currentDate(); 1174 QDate today = QDate::currentDate();
1175 1175
1176 DateList::ConstIterator dit; 1176 DateList::ConstIterator dit;
1177 int curCol = 0; 1177 int curCol = 0;
1178 int maxCol = mSelectedDates.count()-1; 1178 int maxCol = mSelectedDates.count()-1;
1179 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1179 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1180 QDate currentDate = *dit; 1180 QDate currentDate = *dit;
1181 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1181 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1182 // << endl; 1182 // << endl;
1183 1183
1184 dayEvents = calendar()->events(currentDate,false); 1184 dayEvents = calendar()->events(currentDate,false);
1185 1185
1186 // Default values, which can never be reached 1186 // Default values, which can never be reached
1187 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1187 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1188 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1188 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1189 1189
1190 unsigned int numEvent; 1190 unsigned int numEvent;
1191 //qDebug("+++++NUMEVENT %d", dayEvents.count()); 1191 //qDebug("+++++NUMEVENT %d", dayEvents.count());
1192 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1192 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1193 Event *event = dayEvents.at(numEvent); 1193 Event *event = dayEvents.at(numEvent);
1194 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1194 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1195 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1195 if ( event->uid().left(15) == QString("last-syncEvent-") )
1196 continue; 1196 continue;
1197 // kdDebug() << " Event: " << event->summary() << endl; 1197 // kdDebug() << " Event: " << event->summary() << endl;
1198 1198
1199 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1199 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1200 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1200 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1201 1201
1202 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1202 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1203 1203
1204 if (event->doesFloat()) { 1204 if (event->doesFloat()) {
1205 if (event->doesRecur()) { 1205 if (event->doesRecur()) {
1206 if (event->isMultiDay() ) { 1206 if (event->isMultiDay() ) {
1207 endX = endX - beginX;// endX is now number of days 1207 endX = endX - beginX;// endX is now number of days
1208 if ( event->recursOn( currentDate ) ) { 1208 if ( event->recursOn( currentDate ) ) {
1209 endX += curCol; 1209 endX += curCol;
1210 beginX = curCol; 1210 beginX = curCol;
1211 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1211 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1212 } else { 1212 } else {
1213 //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1()); 1213 //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1());
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;
1263 1262
1264 } 1263 }
1265 } 1264 }
1266 int startY = mAgenda->timeToY(event->dtStart().time()); 1265 int startY = mAgenda->timeToY(event->dtStart().time());
1267 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1266 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1268 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1267 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1269 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1268 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1270 //qDebug("insert!!! "); 1269 //qDebug("insert!!! ");
1271 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1270 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1272 } 1271 }
1273 if (beginX == curCol) { 1272 if (beginX == curCol) {
1274 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1273 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1275 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1274 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1276 } else if (endX == curCol) { 1275 } else if (endX == curCol) {
1277 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1276 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1278 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1277 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1279 } else { 1278 } else {
1280 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1279 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1281 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1280 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1282 } 1281 }
1283 } else { 1282 } else {
1284 int startY = mAgenda->timeToY(event->dtStart().time()); 1283 int startY = mAgenda->timeToY(event->dtStart().time());
1285 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1284 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1286 if (endY < startY) endY = startY; 1285 if (endY < startY) endY = startY;
1287 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1286 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1288 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1287 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1289 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1288 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1290 } 1289 }
1291 } 1290 }
1292 // ---------- [display Todos -------------- 1291 // ---------- [display Todos --------------
1293 unsigned int numTodo; 1292 unsigned int numTodo;
1294 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1293 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1295 Todo *todo = todos.at(numTodo); 1294 Todo *todo = todos.at(numTodo);
1296 1295
1297 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1296 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1298 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; 1297 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue;
1299 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1298 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1300 // Already completed items can be displayed on their original due date 1299 // Already completed items can be displayed on their original due date
1301 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1300 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1302 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1301 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1303 bool fillIn = false; 1302 bool fillIn = false;
1304 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1303 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1305 fillIn = true; 1304 fillIn = true;
1306 if ( ! fillIn && !todo->hasCompletedDate() ) 1305 if ( ! fillIn && !todo->hasCompletedDate() )
1307 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1306 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1308 if ( fillIn ) { 1307 if ( fillIn ) {
1309 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1308 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1310 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1309 if ( KOPrefs::instance()->mShowTodoInAgenda )
1311 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1310 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1312 } 1311 }
1313 else { 1312 else {
1314 QDateTime dt; 1313 QDateTime dt;
1315 if ( todo->hasCompletedDate() ) 1314 if ( todo->hasCompletedDate() )
1316 dt = todo->completed(); 1315 dt = todo->completed();
1317 else 1316 else
1318 dt = todo->dtDue();; 1317 dt = todo->dtDue();;
1319 1318
1320 1319
1321 int endY = mAgenda->timeToY(dt.time()) - 1; 1320 int endY = mAgenda->timeToY(dt.time()) - 1;
1322 int hi = (18/KOPrefs::instance()->mHourSize); 1321 int hi = (18/KOPrefs::instance()->mHourSize);
1323 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1322 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1324 int startY = endY -hi; 1323 int startY = endY -hi;
1325 1324
1326 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1325 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1327 1326
1328 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1327 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1329 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1328 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1330 } 1329 }
1331 } 1330 }
1332 } 1331 }
1333 // ---------- display Todos] -------------- 1332 // ---------- display Todos] --------------
1334 1333