summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (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
@@ -1647,390 +1647,390 @@ void KOAgenda::setStartHour(int startHour)
1647{ 1647{
1648 int startCell = startHour * mRows / 24; 1648 int startCell = startHour * mRows / 24;
1649 setContentsPos(0,startCell * gridSpacingY()); 1649 setContentsPos(0,startCell * gridSpacingY());
1650} 1650}
1651QTime KOAgenda::getEndTime() 1651QTime KOAgenda::getEndTime()
1652{ 1652{
1653 int tim = (contentsY ()+viewport()->height())*24/contentsHeight (); 1653 int tim = (contentsY ()+viewport()->height())*24/contentsHeight ();
1654 if ( tim > 23 ) 1654 if ( tim > 23 )
1655 return QTime ( 23,59,59); 1655 return QTime ( 23,59,59);
1656 return QTime ( tim,0,0); 1656 return QTime ( tim,0,0);
1657} 1657}
1658void KOAgenda::hideUnused() 1658void KOAgenda::hideUnused()
1659{ 1659{
1660 // experimental only 1660 // experimental only
1661 // return; 1661 // return;
1662 KOAgendaItem *item; 1662 KOAgendaItem *item;
1663 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1663 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1664 item->hide(); 1664 item->hide();
1665 } 1665 }
1666} 1666}
1667 1667
1668 1668
1669KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1669KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1670{ 1670{
1671 1671
1672 KOAgendaItem *fi; 1672 KOAgendaItem *fi;
1673 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1673 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1674 if ( fi->incidence() == event ) { 1674 if ( fi->incidence() == event ) {
1675 mUnusedItems.remove(); 1675 mUnusedItems.remove();
1676 fi->init( event, qd ); 1676 fi->init( event, qd );
1677 return fi; 1677 return fi;
1678 } 1678 }
1679 } 1679 }
1680 fi=mUnusedItems.first(); 1680 fi=mUnusedItems.first();
1681 if ( fi ) { 1681 if ( fi ) {
1682 mUnusedItems.remove(); 1682 mUnusedItems.remove();
1683 fi->init( event, qd ); 1683 fi->init( event, qd );
1684 return fi; 1684 return fi;
1685 } 1685 }
1686 // qDebug("new KOAgendaItem "); 1686 // qDebug("new KOAgendaItem ");
1687 1687
1688 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1688 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1689 agendaItem->installEventFilter(this); 1689 agendaItem->installEventFilter(this);
1690 addChild(agendaItem,0,0); 1690 addChild(agendaItem,0,0);
1691 return agendaItem; 1691 return agendaItem;
1692} 1692}
1693KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1693KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1694{ 1694{
1695 KOAgendaItem *item; 1695 KOAgendaItem *item;
1696 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1696 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1697 if ( item->incidence() == todo ) { 1697 if ( item->incidence() == todo ) {
1698 mItems.remove(); 1698 mItems.remove();
1699 return item; 1699 return item;
1700 } 1700 }
1701 } 1701 }
1702 return 0; 1702 return 0;
1703} 1703}
1704 1704
1705 1705
1706void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1706void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1707{ 1707{
1708 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1708 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1709 KOAgendaItem *item; 1709 KOAgendaItem *item;
1710 item = getItemForTodo ( todo ); 1710 item = getItemForTodo ( todo );
1711 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1711 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1712 if ( item ) { 1712 if ( item ) {
1713 blockSignals( true ); 1713 blockSignals( true );
1714 //qDebug("item found "); 1714 //qDebug("item found ");
1715 item->hide(); 1715 item->hide();
1716 item->setCellX(-2, -1 ); 1716 item->setCellX(-2, -1 );
1717 item->select(false); 1717 item->select(false);
1718 mUnusedItems.append( item ); 1718 mUnusedItems.append( item );
1719 mItems.remove( item ); 1719 mItems.remove( item );
1720 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1720 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1721 KOAgendaItem *itemit; 1721 KOAgendaItem *itemit;
1722 //globalFlagBlockAgendaItemPaint = 1; 1722 //globalFlagBlockAgendaItemPaint = 1;
1723 for ( itemit=oldconflictItems.first(); itemit != 0; 1723 for ( itemit=oldconflictItems.first(); itemit != 0;
1724 itemit=oldconflictItems.next() ) { 1724 itemit=oldconflictItems.next() ) {
1725 if ( itemit != item ) 1725 if ( itemit != item )
1726 placeSubCells(itemit); 1726 placeSubCells(itemit);
1727 } 1727 }
1728 qApp->processEvents(); 1728 qApp->processEvents();
1729 //globalFlagBlockAgendaItemPaint = 0; 1729 //globalFlagBlockAgendaItemPaint = 0;
1730 for ( itemit=oldconflictItems.first(); itemit != 0; 1730 for ( itemit=oldconflictItems.first(); itemit != 0;
1731 itemit=oldconflictItems.next() ) { 1731 itemit=oldconflictItems.next() ) {
1732 globalFlagBlockAgendaItemUpdate = 0; 1732 globalFlagBlockAgendaItemUpdate = 0;
1733 if ( itemit != item ) 1733 if ( itemit != item )
1734 itemit->repaintMe(); 1734 itemit->repaintMe();
1735 globalFlagBlockAgendaItemUpdate = 1; 1735 globalFlagBlockAgendaItemUpdate = 1;
1736 //qDebug("sigleshot "); 1736 //qDebug("sigleshot ");
1737 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); 1737 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() ));
1738 //itemit->repaint( false ); repaintItem() 1738 //itemit->repaint( false ); repaintItem()
1739 } 1739 }
1740 blockSignals( false ); 1740 blockSignals( false );
1741 } 1741 }
1742 if ( remove ) { 1742 if ( 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;
1941 mGridSpacingY = height() - 2 * frameWidth() - 1; 1941 mGridSpacingY = height() - 2 * frameWidth() - 1;
1942 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1942 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1943 // mGridSpacingY = height(); 1943 // mGridSpacingY = height();
1944 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1944 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1945 1945
1946 KOAgendaItem *item; 1946 KOAgendaItem *item;
1947 int subCellWidth; 1947 int subCellWidth;
1948 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1948 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1949 subCellWidth = mGridSpacingY / item->subCells(); 1949 subCellWidth = mGridSpacingY / item->subCells();
1950 int diff = 0; 1950 int diff = 0;
1951 diff = item->resizeMe(mGridSpacingX ,mGridSpacingX * item->cellWidth(),subCellWidth); 1951 diff = item->resizeMe(mGridSpacingX ,mGridSpacingX * item->cellWidth(),subCellWidth);
1952 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1952 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1953 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1953 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1954 item->cellX() * mGridSpacingX) + diff, 1954 item->cellX() * mGridSpacingX) + diff,
1955 item->subCell() * subCellWidth); 1955 item->subCell() * subCellWidth);
1956 } 1956 }
1957 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1957 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1958 } else { 1958 } else {
1959 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 1959 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
1960 if (height() > mGridSpacingY * mRows + 1 ) { 1960 if (height() > mGridSpacingY * mRows + 1 ) {
1961 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1961 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1962 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1962 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1963 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1963 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1964 emit resizedSignal(); 1964 emit resizedSignal();
1965 } else 1965 } else
1966 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1966 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1967 KOAgendaItem *item; 1967 KOAgendaItem *item;
1968 int subCellWidth; 1968 int subCellWidth;
1969 1969
1970 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1970 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1971 subCellWidth = mGridSpacingX / item->subCells(); 1971 subCellWidth = mGridSpacingX / item->subCells();
1972 item->resize(subCellWidth,item->height()); 1972 item->resize(subCellWidth,item->height());
1973 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1973 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1974 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1974 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1975 item->cellX() * mGridSpacingX) + 1975 item->cellX() * mGridSpacingX) +
1976 item->subCell() * subCellWidth,childY(item)); 1976 item->subCell() * subCellWidth,childY(item));
1977 } 1977 }
1978 } 1978 }
1979 int cw = contentsWidth(); 1979 int cw = contentsWidth();
1980 int ch = contentsHeight(); 1980 int ch = contentsHeight();
1981 if ( mAllDayMode ) { 1981 if ( mAllDayMode ) {
1982 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1982 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1983 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { 1983 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) {
1984 //qDebug("paintPixAll->resize "); 1984 //qDebug("paintPixAll->resize ");
1985 paintPixAll->resize( cw, ch ); 1985 paintPixAll->resize( cw, ch );
1986 } 1986 }
1987 } else { 1987 } else {
1988 QPixmap* paintPix = KOAgendaItem::paintPix(); 1988 QPixmap* paintPix = KOAgendaItem::paintPix();
1989 if ( paintPix->width() < cw || paintPix->height() < ch ) { 1989 if ( paintPix->width() < cw || paintPix->height() < ch ) {
1990 //qDebug("paintPix->resize "); 1990 //qDebug("paintPix->resize ");
1991 paintPix->resize( cw , ch ); 1991 paintPix->resize( cw , ch );
1992 } 1992 }
1993 } 1993 }
1994 1994
1995 checkScrollBoundaries(); 1995 checkScrollBoundaries();
1996 drawContentsToPainter(); 1996 drawContentsToPainter();
1997 viewport()->repaint(false); 1997 viewport()->repaint(false);
1998} 1998}
1999 1999
2000void KOAgenda::scrollUp() 2000void KOAgenda::scrollUp()
2001{ 2001{
2002 scrollBy(0,-mScrollOffset); 2002 scrollBy(0,-mScrollOffset);
2003} 2003}
2004 2004
2005 2005
2006void KOAgenda::scrollDown() 2006void KOAgenda::scrollDown()
2007{ 2007{
2008 scrollBy(0,mScrollOffset); 2008 scrollBy(0,mScrollOffset);
2009} 2009}
2010 2010
2011void KOAgenda::popupAlarm() 2011void KOAgenda::popupAlarm()
2012{ 2012{
2013 if (!mClickedItem) { 2013 if (!mClickedItem) {
2014 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 2014 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
2015 return; 2015 return;
2016 } 2016 }
2017 // TODO: deal correctly with multiple alarms 2017 // TODO: deal correctly with multiple alarms
2018 Alarm* alarm; 2018 Alarm* alarm;
2019 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 2019 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
2020 for(alarm=list.first();alarm;alarm=list.next()) { 2020 for(alarm=list.first();alarm;alarm=list.next()) {
2021 alarm->toggleAlarm(); 2021 alarm->toggleAlarm();
2022 } 2022 }
2023 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 2023 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
2024 mClickedItem->paintMe( true ); 2024 mClickedItem->paintMe( true );
2025 mClickedItem->repaint( false ); 2025 mClickedItem->repaint( false );
2026} 2026}
2027 2027
2028/* 2028/*
2029 Calculates the minimum width 2029 Calculates the minimum width
2030*/ 2030*/
2031int KOAgenda::minimumWidth() const 2031int KOAgenda::minimumWidth() const
2032{ 2032{
2033 // TODO:: develop a way to dynamically determine the minimum width 2033 // TODO:: develop a way to dynamically determine the minimum width
2034 int min = 100; 2034 int min = 100;
2035 2035
2036 return min; 2036 return min;
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 7a685d8..81681df 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -393,475 +393,477 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
393 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 393 int xx = pos().x()+(width()-completedPxmp.width()-3 );
394 int yyy = yy+3; 394 int yyy = yy+3;
395 if ( tempTodo->isCompleted() ) 395 if ( tempTodo->isCompleted() )
396 paint->drawPixmap ( xx, yyy, completedPxmp ); 396 paint->drawPixmap ( xx, yyy, completedPxmp );
397 else { 397 else {
398 paint->drawPixmap ( xx, yyy, overduePxmp ); 398 paint->drawPixmap ( xx, yyy, overduePxmp );
399 399
400 } 400 }
401 } 401 }
402 bool addIcon = false; 402 bool addIcon = false;
403 if ( ! small || w > 3 * h || h > 3* w ) 403 if ( ! small || w > 3 * h || h > 3* w )
404 addIcon = updateIcons( paint, horLayout ); 404 addIcon = updateIcons( paint, horLayout );
405 405
406 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 406 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
407 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); 407 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0);
408 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 408 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
409 if ( ! small ) { 409 if ( ! small ) {
410 x += 3; yy += 3;w -= 6; h-= 5; 410 x += 3; yy += 3;w -= 6; h-= 5;
411 } else { 411 } else {
412 x += 2; yy += 1;w -= 4; h-= 4; 412 x += 2; yy += 1;w -= 4; h-= 4;
413 if ( nfh < 6.01 ) { 413 if ( nfh < 6.01 ) {
414 yy -= 2; 414 yy -= 2;
415 h += 4; 415 h += 4;
416 } 416 }
417 else 417 else
418 if ( nfh < h -2 ) 418 if ( nfh < h -2 )
419 ++yy; 419 ++yy;
420 } 420 }
421 int align; 421 int align;
422#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
423 align = ( AlignLeft|WordBreak|AlignTop); 423 align = ( AlignLeft|WordBreak|AlignTop);
424#else 424#else
425 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 425 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
426#endif 426#endif
427 if ( addIcon ) { 427 if ( addIcon ) {
428 if ( ! horLayout ) { 428 if ( ! horLayout ) {
429 x += AGENDA_ICON_SIZE+3; 429 x += AGENDA_ICON_SIZE+3;
430 w -= (AGENDA_ICON_SIZE+3); 430 w -= (AGENDA_ICON_SIZE+3);
431 } 431 }
432 else { 432 else {
433 yy+= AGENDA_ICON_SIZE+2; 433 yy+= AGENDA_ICON_SIZE+2;
434 h -=(AGENDA_ICON_SIZE+3); 434 h -=(AGENDA_ICON_SIZE+3);
435 } 435 }
436 } 436 }
437 if ( mWhiteText ) 437 if ( mWhiteText )
438 paint->setPen ( white); 438 paint->setPen ( white);
439 if ( x < 0 ) { 439 if ( x < 0 ) {
440 w = w+x-3; 440 w = w+x-3;
441 x = 3; 441 x = 3;
442 if ( !horLayout && addIcon ) 442 if ( !horLayout && addIcon )
443 x += AGENDA_ICON_SIZE+3; 443 x += AGENDA_ICON_SIZE+3;
444 if ( w > parentWidget()->width() ){ 444 if ( w > parentWidget()->width() ){
445 w = parentWidget()->width() - 6; 445 w = parentWidget()->width() - 6;
446#ifndef DESKTOP_VERSION 446#ifndef DESKTOP_VERSION
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() 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;
772 setCellY(newYTop, newYBottom); 774 setCellY(newYTop, newYBottom);
773} 775}
774 776
775void KOAgendaItem::expandLeft(int dx) 777void KOAgendaItem::expandLeft(int dx)
776{ 778{
777 int newX = cellX() + dx; 779 int newX = cellX() + dx;
778 int newXWidth = cellXWidth(); 780 int newXWidth = cellXWidth();
779 if (newX > newXWidth) newX = newXWidth; 781 if (newX > newXWidth) newX = newXWidth;
780 setCellX(newX,newXWidth); 782 setCellX(newX,newXWidth);
781} 783}
782 784
783void KOAgendaItem::expandRight(int dx) 785void KOAgendaItem::expandRight(int dx)
784{ 786{
785 int newX = cellX(); 787 int newX = cellX();
786 int newXWidth = cellXWidth() + dx; 788 int newXWidth = cellXWidth() + dx;
787 if (newXWidth < newX) newXWidth = newX; 789 if (newXWidth < newX) newXWidth = newX;
788 setCellX(newX,newXWidth); 790 setCellX(newX,newXWidth);
789} 791}
790 792
791QToolTipGroup *KOAgendaItem::toolTipGroup() 793QToolTipGroup *KOAgendaItem::toolTipGroup()
792{ 794{
793 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 795 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
794 return mToolTipGroup; 796 return mToolTipGroup;
795} 797}
796 798
797void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 799void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
798{ 800{
799#ifndef KORG_NODND 801#ifndef KORG_NODND
800 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 802 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
801 !QTextDrag::canDecode( e ) ) { 803 !QTextDrag::canDecode( e ) ) {
802 e->ignore(); 804 e->ignore();
803 return; 805 return;
804 } 806 }
805 e->accept(); 807 e->accept();
806#endif 808#endif
807} 809}
808 810
809void KOAgendaItem::dropEvent( QDropEvent *e ) 811void KOAgendaItem::dropEvent( QDropEvent *e )
810{ 812{
811#ifndef KORG_NODND 813#ifndef KORG_NODND
812 QString text; 814 QString text;
813 if(QTextDrag::decode(e,text)) 815 if(QTextDrag::decode(e,text))
814 { 816 {
815 kdDebug() << "Dropped : " << text << endl; 817 kdDebug() << "Dropped : " << text << endl;
816 QStringList emails = QStringList::split(",",text); 818 QStringList emails = QStringList::split(",",text);
817 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 819 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
818 kdDebug() << " Email: " << (*it) << endl; 820 kdDebug() << " Email: " << (*it) << endl;
819 int pos = (*it).find("<"); 821 int pos = (*it).find("<");
820 QString name = (*it).left(pos); 822 QString name = (*it).left(pos);
821 QString email = (*it).mid(pos); 823 QString email = (*it).mid(pos);
822 if (!email.isEmpty()) { 824 if (!email.isEmpty()) {
823 mIncidence->addAttendee(new Attendee(name,email)); 825 mIncidence->addAttendee(new Attendee(name,email));
824 } 826 }
825 } 827 }
826 } 828 }
827#endif 829#endif
828} 830}
829 831
830 832
831QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 833QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
832{ 834{
833 return mConflictItems; 835 return mConflictItems;
834} 836}
835 837
836void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 838void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
837{ 839{
838 mConflictItems = ci; 840 mConflictItems = ci;
839 KOAgendaItem *item; 841 KOAgendaItem *item;
840 for ( item=mConflictItems.first(); item != 0; 842 for ( item=mConflictItems.first(); item != 0;
841 item=mConflictItems.next() ) { 843 item=mConflictItems.next() ) {
842 item->addConflictItem(this); 844 item->addConflictItem(this);
843 } 845 }
844} 846}
845 847
846void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 848void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
847{ 849{
848 if (mConflictItems.find(ci)<0) 850 if (mConflictItems.find(ci)<0)
849 mConflictItems.append(ci); 851 mConflictItems.append(ci);
850} 852}
851 853
852bool KOAgendaItem::checkLayout() 854bool KOAgendaItem::checkLayout()
853{ 855{
854 if ( !mConflictItems.count() ) 856 if ( !mConflictItems.count() )
855 return true; 857 return true;
856 int max = 0; 858 int max = 0;
857 KOAgendaItem *item; 859 KOAgendaItem *item;
858 for ( item=mConflictItems.first(); item != 0; 860 for ( item=mConflictItems.first(); item != 0;
859 item=mConflictItems.next() ) { 861 item=mConflictItems.next() ) {
860 if ( item->subCells() > max ) 862 if ( item->subCells() > max )
861 max = item->subCells(); 863 max = item->subCells();
862 } 864 }
863 if ( max > subCells() ) { 865 if ( max > subCells() ) {
864 setSubCells( max ); 866 setSubCells( max );
865 return false; 867 return false;
866 } 868 }
867 return true; 869 return true;
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index 97acd4c..37d89a6 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -1,167 +1,167 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
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
@@ -1046,385 +1046,384 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
1046 endDt = startDt.addSecs(lenInSecs); 1046 endDt = startDt.addSecs(lenInSecs);
1047 1047
1048 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 1048 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
1049 if (item->lastMultiItem()) { 1049 if (item->lastMultiItem()) {
1050 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1050 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1051 endDt.setDate(startDate. 1051 endDt.setDate(startDate.
1052 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1052 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1053 } else { 1053 } else {
1054 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1054 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1055 endDt.setDate(startDate); 1055 endDt.setDate(startDate);
1056 } 1056 }
1057 } 1057 }
1058 } else { 1058 } else {
1059 // todo 1059 // todo
1060 if (item->lastMultiItem()) { 1060 if (item->lastMultiItem()) {
1061 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1061 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1062 endDt.setDate(startDate. 1062 endDt.setDate(startDate.
1063 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1063 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1064 } else { 1064 } else {
1065 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1065 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1066 if ( item->cellYBottom() > 0 ) 1066 if ( item->cellYBottom() > 0 )
1067 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1067 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1068 else 1068 else
1069 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1069 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1070 endDt.setDate(startDate); 1070 endDt.setDate(startDate);
1071 } 1071 }
1072 } 1072 }
1073 } 1073 }
1074 if ( item->incidence()->typeID() == eventID ) { 1074 if ( item->incidence()->typeID() == eventID ) {
1075 item->incidence()->setDtStart(startDt); 1075 item->incidence()->setDtStart(startDt);
1076 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1076 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1077 } else if ( item->incidence()->typeID() == todoID ) { 1077 } else if ( item->incidence()->typeID() == todoID ) {
1078 Todo* to = static_cast<Todo*>(item->incidence()); 1078 Todo* to = static_cast<Todo*>(item->incidence());
1079 1079
1080 to->setDtDue(endDt); 1080 to->setDtDue(endDt);
1081 if ( to->hasStartDate() ) { 1081 if ( to->hasStartDate() ) {
1082 if (to->dtStart() >= to->dtDue() ) 1082 if (to->dtStart() >= to->dtDue() )
1083 to->setDtStart(to->dtDue().addDays( -2 )); 1083 to->setDtStart(to->dtDue().addDays( -2 ));
1084 } 1084 }
1085 1085
1086 } 1086 }
1087 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1087 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1088 item->incidence()->setRevision(item->incidence()->revision()+1); 1088 item->incidence()->setRevision(item->incidence()->revision()+1);
1089 item->setItemDate(startDt.date()); 1089 item->setItemDate(startDt.date());
1090 //item->updateItem(); 1090 //item->updateItem();
1091 if ( item->incidence()->typeID() == todoID ) { 1091 if ( item->incidence()->typeID() == todoID ) {
1092 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1092 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1093 1093
1094 } 1094 }
1095 else 1095 else
1096 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1096 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1097 item->updateItem(); 1097 item->updateItem();
1098} 1098}
1099 1099
1100void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1100void KOAgendaView::showDates( const QDate &start, const QDate &end )
1101{ 1101{
1102 // kdDebug() << "KOAgendaView::selectDates" << endl; 1102 // kdDebug() << "KOAgendaView::selectDates" << endl;
1103 1103
1104 mSelectedDates.clear(); 1104 mSelectedDates.clear();
1105 // qDebug("KOAgendaView::showDates "); 1105 // qDebug("KOAgendaView::showDates ");
1106 QDate d = start; 1106 QDate d = start;
1107 while (d <= end) { 1107 while (d <= end) {
1108 mSelectedDates.append(d); 1108 mSelectedDates.append(d);
1109 d = d.addDays( 1 ); 1109 d = d.addDays( 1 );
1110 } 1110 }
1111 1111
1112 // and update the view 1112 // and update the view
1113 fillAgenda(); 1113 fillAgenda();
1114} 1114}
1115 1115
1116 1116
1117void KOAgendaView::showEvents(QPtrList<Event>) 1117void KOAgendaView::showEvents(QPtrList<Event>)
1118{ 1118{
1119 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1119 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1120} 1120}
1121 1121
1122void KOAgendaView::changeEventDisplay(Event *, int) 1122void KOAgendaView::changeEventDisplay(Event *, int)
1123{ 1123{
1124 // qDebug("KOAgendaView::changeEventDisplay "); 1124 // qDebug("KOAgendaView::changeEventDisplay ");
1125 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1125 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1126 // this should be re-written to be MUCH smarter. Right now we 1126 // this should be re-written to be MUCH smarter. Right now we
1127 // are just playing dumb. 1127 // are just playing dumb.
1128 fillAgenda(); 1128 fillAgenda();
1129} 1129}
1130 1130
1131void KOAgendaView::fillAgenda(const QDate &) 1131void KOAgendaView::fillAgenda(const QDate &)
1132{ 1132{
1133 // qDebug("KOAgendaView::fillAgenda "); 1133 // qDebug("KOAgendaView::fillAgenda ");
1134 fillAgenda(); 1134 fillAgenda();
1135} 1135}
1136 1136
1137void KOAgendaView::fillAgenda() 1137void KOAgendaView::fillAgenda()
1138{ 1138{
1139 if ( globalFlagBlockStartup ) 1139 if ( globalFlagBlockStartup )
1140 return; 1140 return;
1141 if ( globalFlagBlockAgenda == 1 ) 1141 if ( globalFlagBlockAgenda == 1 )
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
1335 ++curCol; 1334 ++curCol;
1336 } 1335 }
1337 mAgenda->hideUnused(); 1336 mAgenda->hideUnused();
1338 mAllDayAgenda->hideUnused(); 1337 mAllDayAgenda->hideUnused();
1339 mAgenda->checkScrollBoundaries(); 1338 mAgenda->checkScrollBoundaries();
1340 deleteSelectedDateTime(); 1339 deleteSelectedDateTime();
1341 createDayLabels(); 1340 createDayLabels();
1342 emit incidenceSelected( 0 ); 1341 emit incidenceSelected( 0 );
1343 1342
1344 if ( globalFlagBlockAgenda == 2 ) { 1343 if ( globalFlagBlockAgenda == 2 ) {
1345 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1344 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1346 setStartHour( KOPrefs::instance()->mDayBegins ); 1345 setStartHour( KOPrefs::instance()->mDayBegins );
1347 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1346 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1348 setStartHour( QTime::currentTime ().hour() ); 1347 setStartHour( QTime::currentTime ().hour() );
1349 } 1348 }
1350 qApp->processEvents(); 1349 qApp->processEvents();
1351 globalFlagBlockAgenda = 0; 1350 globalFlagBlockAgenda = 0;
1352 mAllDayAgenda->drawContentsToPainter(); 1351 mAllDayAgenda->drawContentsToPainter();
1353 mAgenda->drawContentsToPainter(); 1352 mAgenda->drawContentsToPainter();
1354 repaintAgenda(); 1353 repaintAgenda();
1355 startIdleTimeout(); 1354 startIdleTimeout();
1356 onlyOne = false; 1355 onlyOne = false;
1357} 1356}
1358void KOAgendaView::repaintAgenda() 1357void KOAgendaView::repaintAgenda()
1359{ 1358{
1360 mAgenda->viewport()->repaint( false ); 1359 mAgenda->viewport()->repaint( false );
1361 mAllDayAgenda->viewport()->repaint( false ); 1360 mAllDayAgenda->viewport()->repaint( false );
1362 mAgenda->finishUpdate(); 1361 mAgenda->finishUpdate();
1363 mAllDayAgenda->finishUpdate(); 1362 mAllDayAgenda->finishUpdate();
1364} 1363}
1365 1364
1366 1365
1367void KOAgendaView::clearView() 1366void KOAgendaView::clearView()
1368{ 1367{
1369 mAllDayAgenda->clear(); 1368 mAllDayAgenda->clear();
1370 mAgenda->clear(); 1369 mAgenda->clear();
1371} 1370}
1372void KOAgendaView::clearList() 1371void KOAgendaView::clearList()
1373{ 1372{
1374 clearView(); 1373 clearView();
1375 mAllDayAgenda->hideUnused(); 1374 mAllDayAgenda->hideUnused();
1376 mAgenda->hideUnused(); 1375 mAgenda->hideUnused();
1377} 1376}
1378 1377
1379void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1378void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1380 const QDate &td) 1379 const QDate &td)
1381{ 1380{
1382#ifndef KORG_NOPRINTER 1381#ifndef KORG_NOPRINTER
1383 if (fd == td) 1382 if (fd == td)
1384 calPrinter->preview(CalPrinter::Day, fd, td); 1383 calPrinter->preview(CalPrinter::Day, fd, td);
1385 else 1384 else
1386 calPrinter->preview(CalPrinter::Week, fd, td); 1385 calPrinter->preview(CalPrinter::Week, fd, td);
1387#endif 1386#endif
1388} 1387}
1389 1388
1390// void KOAgendaView::updateMovedTodo() 1389// void KOAgendaView::updateMovedTodo()
1391// { 1390// {
1392// // updateConfig(); 1391// // updateConfig();
1393// // emit updateTodoViews(); 1392// // emit updateTodoViews();
1394// } 1393// }
1395 1394
1396void KOAgendaView::slotShowDateView( int mode , int d ) 1395void KOAgendaView::slotShowDateView( int mode , int d )
1397{ 1396{
1398 if ( d >= mSelectedDates.count() ) { 1397 if ( d >= mSelectedDates.count() ) {
1399 qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); 1398 qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() );
1400 1399
1401 } else { 1400 } else {
1402 QDate day = mSelectedDates[d]; 1401 QDate day = mSelectedDates[d];
1403 emit showDateView(mode , day ); 1402 emit showDateView(mode , day );
1404 } 1403 }
1405 1404
1406} 1405}
1407void KOAgendaView::newEvent(int gx, int gy) 1406void KOAgendaView::newEvent(int gx, int gy)
1408{ 1407{
1409 if (!mSelectedDates.count()) return; 1408 if (!mSelectedDates.count()) return;
1410 1409
1411 QDate day = mSelectedDates[gx]; 1410 QDate day = mSelectedDates[gx];
1412 1411
1413 QTime time = mAgenda->gyToTime(gy); 1412 QTime time = mAgenda->gyToTime(gy);
1414 QDateTime dt(day,time); 1413 QDateTime dt(day,time);
1415 // if ( dt < QDateTime::currentDateTime () ) 1414 // if ( dt < QDateTime::currentDateTime () )
1416 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1415 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1417 emit newEventSignal(dt); 1416 emit newEventSignal(dt);
1418} 1417}
1419 1418
1420void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1419void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1421{ 1420{
1422 if (!mSelectedDates.count()) return; 1421 if (!mSelectedDates.count()) return;
1423 1422
1424 QDate dayStart = mSelectedDates[gxStart]; 1423 QDate dayStart = mSelectedDates[gxStart];
1425 QDate dayEnd = mSelectedDates[gxEnd]; 1424 QDate dayEnd = mSelectedDates[gxEnd];
1426 1425
1427 QTime timeStart = mAgenda->gyToTime(gyStart); 1426 QTime timeStart = mAgenda->gyToTime(gyStart);
1428 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1427 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1429 1428
1430 QDateTime dtStart(dayStart,timeStart); 1429 QDateTime dtStart(dayStart,timeStart);