-rw-r--r-- | korganizer/koagenda.cpp | 10 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 6 | ||||
-rw-r--r-- | korganizer/koagendaitem.h | 1 |
3 files changed, 8 insertions, 9 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 9b817bc..01cef35 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1724,390 +1724,394 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | |||
1724 | item->repaintMe(); | 1724 | item->repaintMe(); |
1725 | globalFlagBlockAgendaItemUpdate = 1; | 1725 | globalFlagBlockAgendaItemUpdate = 1; |
1726 | item->repaint(); | 1726 | item->repaint(); |
1727 | } | 1727 | } |
1728 | /* | 1728 | /* |
1729 | Insert KOAgendaItem into agenda. | 1729 | Insert KOAgendaItem into agenda. |
1730 | */ | 1730 | */ |
1731 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1731 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1732 | { | 1732 | { |
1733 | if (mAllDayMode) { | 1733 | if (mAllDayMode) { |
1734 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1734 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1735 | return 0; | 1735 | return 0; |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1738 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1739 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1739 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1740 | 1740 | ||
1741 | int YSize = YBottom - YTop + 1; | 1741 | int YSize = YBottom - YTop + 1; |
1742 | if (YSize < 0) { | 1742 | if (YSize < 0) { |
1743 | YSize = 1; | 1743 | YSize = 1; |
1744 | } | 1744 | } |
1745 | int iheight = mGridSpacingY * YSize; | 1745 | int iheight = mGridSpacingY * YSize; |
1746 | 1746 | ||
1747 | agendaItem->resize(mGridSpacingX,iheight ); | 1747 | agendaItem->resize(mGridSpacingX,iheight ); |
1748 | agendaItem->setCellXY(X,YTop,YBottom); | 1748 | agendaItem->setCellXY(X,YTop,YBottom); |
1749 | agendaItem->setCellXWidth(X); | 1749 | agendaItem->setCellXWidth(X); |
1750 | 1750 | ||
1751 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1751 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1752 | mItems.append(agendaItem); | 1752 | mItems.append(agendaItem); |
1753 | 1753 | ||
1754 | placeSubCells(agendaItem); | 1754 | placeSubCells(agendaItem); |
1755 | 1755 | ||
1756 | //agendaItem->show(); | 1756 | //agendaItem->show(); |
1757 | 1757 | ||
1758 | marcus_bains(); | 1758 | marcus_bains(); |
1759 | 1759 | ||
1760 | return agendaItem; | 1760 | return agendaItem; |
1761 | } | 1761 | } |
1762 | 1762 | ||
1763 | 1763 | ||
1764 | /* | 1764 | /* |
1765 | Insert all-day KOAgendaItem into agenda. | 1765 | Insert all-day KOAgendaItem into agenda. |
1766 | */ | 1766 | */ |
1767 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1767 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1768 | { | 1768 | { |
1769 | if (!mAllDayMode) { | 1769 | if (!mAllDayMode) { |
1770 | return 0; | 1770 | return 0; |
1771 | } | 1771 | } |
1772 | 1772 | ||
1773 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1773 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1774 | 1774 | ||
1775 | agendaItem->setCellXY(XBegin,0,0); | 1775 | agendaItem->setCellXY(XBegin,0,0); |
1776 | agendaItem->setCellXWidth(XEnd); | 1776 | agendaItem->setCellXWidth(XEnd); |
1777 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1777 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1778 | 1778 | ||
1779 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1779 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1780 | mItems.append(agendaItem); | 1780 | mItems.append(agendaItem); |
1781 | 1781 | ||
1782 | placeSubCells(agendaItem); | 1782 | placeSubCells(agendaItem); |
1783 | 1783 | ||
1784 | //agendaItem->show(); | 1784 | //agendaItem->show(); |
1785 | 1785 | ||
1786 | return agendaItem; | 1786 | return agendaItem; |
1787 | } | 1787 | } |
1788 | 1788 | ||
1789 | 1789 | ||
1790 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1790 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1791 | int YTop,int YBottom) | 1791 | int YTop,int YBottom) |
1792 | { | 1792 | { |
1793 | if (mAllDayMode) { | 1793 | if (mAllDayMode) { |
1794 | ; | 1794 | ; |
1795 | return; | 1795 | return; |
1796 | } | 1796 | } |
1797 | 1797 | ||
1798 | int cellX,cellYTop,cellYBottom; | 1798 | int cellX,cellYTop,cellYBottom; |
1799 | QString newtext; | 1799 | QString newtext; |
1800 | int width = XEnd - XBegin + 1; | 1800 | int width = XEnd - XBegin + 1; |
1801 | int count = 0; | 1801 | int count = 0; |
1802 | KOAgendaItem *current = 0; | 1802 | KOAgendaItem *current = 0; |
1803 | QPtrList<KOAgendaItem> multiItems; | 1803 | QPtrList<KOAgendaItem> multiItems; |
1804 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1804 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1805 | if (cellX == XBegin) cellYTop = YTop; | 1805 | if (cellX == XBegin) cellYTop = YTop; |
1806 | else cellYTop = 0; | 1806 | else cellYTop = 0; |
1807 | if (cellX == XEnd) cellYBottom = YBottom; | 1807 | if (cellX == XEnd) cellYBottom = YBottom; |
1808 | else cellYBottom = rows() - 1; | 1808 | else cellYBottom = rows() - 1; |
1809 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1809 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1810 | newtext.append(event->summary()); | 1810 | newtext.append(event->summary()); |
1811 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1811 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1812 | current->setText(newtext); | 1812 | current->setText(newtext); |
1813 | multiItems.append(current); | 1813 | multiItems.append(current); |
1814 | } | 1814 | } |
1815 | 1815 | ||
1816 | KOAgendaItem *next = 0; | 1816 | KOAgendaItem *next = 0; |
1817 | KOAgendaItem *last = multiItems.last(); | 1817 | KOAgendaItem *last = multiItems.last(); |
1818 | KOAgendaItem *first = multiItems.first(); | 1818 | KOAgendaItem *first = multiItems.first(); |
1819 | KOAgendaItem *setFirst,*setLast; | 1819 | KOAgendaItem *setFirst,*setLast; |
1820 | current = first; | 1820 | current = first; |
1821 | while (current) { | 1821 | while (current) { |
1822 | next = multiItems.next(); | 1822 | next = multiItems.next(); |
1823 | if (current == first) setFirst = 0; | 1823 | if (current == first) setFirst = 0; |
1824 | else setFirst = first; | 1824 | else setFirst = first; |
1825 | if (current == last) setLast = 0; | 1825 | if (current == last) setLast = 0; |
1826 | else setLast = last; | 1826 | else setLast = last; |
1827 | 1827 | ||
1828 | current->setMultiItem(setFirst,next,setLast); | 1828 | current->setMultiItem(setFirst,next,setLast); |
1829 | current = next; | 1829 | current = next; |
1830 | } | 1830 | } |
1831 | 1831 | ||
1832 | marcus_bains(); | 1832 | marcus_bains(); |
1833 | } | 1833 | } |
1834 | 1834 | ||
1835 | 1835 | ||
1836 | //QSizePolicy KOAgenda::sizePolicy() const | 1836 | //QSizePolicy KOAgenda::sizePolicy() const |
1837 | //{ | 1837 | //{ |
1838 | // Thought this would make the all-day event agenda minimum size and the | 1838 | // Thought this would make the all-day event agenda minimum size and the |
1839 | // normal agenda take the remaining space. But it doesnīt work. The QSplitter | 1839 | // normal agenda take the remaining space. But it doesnīt work. The QSplitter |
1840 | // donīt seem to think that an Expanding widget needs more space than a | 1840 | // donīt seem to think that an Expanding widget needs more space than a |
1841 | // Preferred one. | 1841 | // Preferred one. |
1842 | // But it doesnīt hurt, so it stays. | 1842 | // But it doesnīt hurt, so it stays. |
1843 | // if (mAllDayMode) { | 1843 | // if (mAllDayMode) { |
1844 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1844 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1845 | // } else { | 1845 | // } else { |
1846 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1846 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1847 | // } | 1847 | // } |
1848 | //} | 1848 | //} |
1849 | void KOAgenda::finishResize ( ) | 1849 | void KOAgenda::finishResize ( ) |
1850 | { | 1850 | { |
1851 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1851 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1852 | if ( globalFlagBlockAgenda == 0 ) { | 1852 | if ( globalFlagBlockAgenda == 0 ) { |
1853 | finishUpdate(); | 1853 | finishUpdate(); |
1854 | //qDebug("finishUpdate() called "); | 1854 | //qDebug("finishUpdate() called "); |
1855 | } | 1855 | } |
1856 | } | 1856 | } |
1857 | /* | 1857 | /* |
1858 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1858 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1859 | */ | 1859 | */ |
1860 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1860 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1861 | { | 1861 | { |
1862 | mSelectionHeight = 0; | 1862 | mSelectionHeight = 0; |
1863 | mResizeTimer.start( 150 , true ); | 1863 | mResizeTimer.start( 150 , true ); |
1864 | computeSizes(); | 1864 | computeSizes(); |
1865 | return; | 1865 | return; |
1866 | 1866 | ||
1867 | } | 1867 | } |
1868 | void KOAgenda::computeSizes() | 1868 | void KOAgenda::computeSizes() |
1869 | { | 1869 | { |
1870 | if ( globalFlagBlockStartup ) | 1870 | if ( globalFlagBlockStartup ) |
1871 | return; | 1871 | return; |
1872 | int frameOffset = frameWidth() * 2 +1; | 1872 | int frameOffset = frameWidth() * 2 +1; |
1873 | if (mAllDayMode) { | 1873 | if (mAllDayMode) { |
1874 | mGridSpacingX = (width()-frameOffset) / mColumns; | 1874 | mGridSpacingX = (width()-frameOffset) / mColumns; |
1875 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1875 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1876 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1876 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1877 | // mGridSpacingY = height(); | 1877 | // mGridSpacingY = height(); |
1878 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1878 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1879 | 1879 | ||
1880 | KOAgendaItem *item; | 1880 | KOAgendaItem *item; |
1881 | int subCellWidth; | 1881 | int subCellWidth; |
1882 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1882 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1883 | subCellWidth = mGridSpacingY / item->subCells(); | 1883 | subCellWidth = mGridSpacingY / item->subCells(); |
1884 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1884 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1885 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1885 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1886 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1886 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1887 | item->cellX() * mGridSpacingX, | 1887 | item->cellX() * mGridSpacingX, |
1888 | item->subCell() * subCellWidth); | 1888 | item->subCell() * subCellWidth); |
1889 | } | 1889 | } |
1890 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1890 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1891 | } else { | 1891 | } else { |
1892 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; | 1892 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1893 | if (height() > mGridSpacingY * mRows + 1 ) { | 1893 | if (height() > mGridSpacingY * mRows + 1 ) { |
1894 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1894 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1895 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1895 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1896 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1896 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1897 | emit resizedSignal(); | 1897 | emit resizedSignal(); |
1898 | } else | 1898 | } else |
1899 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1899 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1900 | KOAgendaItem *item; | 1900 | KOAgendaItem *item; |
1901 | int subCellWidth; | 1901 | int subCellWidth; |
1902 | 1902 | ||
1903 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1903 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1904 | subCellWidth = mGridSpacingX / item->subCells(); | 1904 | subCellWidth = mGridSpacingX / item->subCells(); |
1905 | item->resize(subCellWidth,item->height()); | 1905 | item->resize(subCellWidth,item->height()); |
1906 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1906 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1907 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1907 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1908 | item->cellX() * mGridSpacingX) + | 1908 | item->cellX() * mGridSpacingX) + |
1909 | item->subCell() * subCellWidth,childY(item)); | 1909 | item->subCell() * subCellWidth,childY(item)); |
1910 | } | 1910 | } |
1911 | } | 1911 | } |
1912 | int cw = contentsWidth(); | 1912 | int cw = contentsWidth(); |
1913 | int ch = contentsHeight(); | 1913 | int ch = contentsHeight(); |
1914 | if ( mAllDayMode ) { | 1914 | if ( mAllDayMode ) { |
1915 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1915 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1916 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | 1916 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { |
1917 | //qDebug("paintPixAll->resize "); | ||
1917 | paintPixAll->resize( cw, ch ); | 1918 | paintPixAll->resize( cw, ch ); |
1919 | } | ||
1918 | } else { | 1920 | } else { |
1919 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1921 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1920 | if ( paintPix->width() < cw || paintPix->height() < ch ) | 1922 | if ( paintPix->width() < cw || paintPix->height() < ch ) { |
1921 | KOAgendaItem::resizePixmap( cw , ch ); | 1923 | //qDebug("paintPix->resize "); |
1924 | paintPix->resize( cw , ch ); | ||
1925 | } | ||
1922 | } | 1926 | } |
1923 | 1927 | ||
1924 | checkScrollBoundaries(); | 1928 | checkScrollBoundaries(); |
1925 | marcus_bains(); | 1929 | marcus_bains(); |
1926 | drawContentsToPainter(); | 1930 | drawContentsToPainter(); |
1927 | viewport()->repaint(false); | 1931 | viewport()->repaint(false); |
1928 | } | 1932 | } |
1929 | 1933 | ||
1930 | void KOAgenda::scrollUp() | 1934 | void KOAgenda::scrollUp() |
1931 | { | 1935 | { |
1932 | scrollBy(0,-mScrollOffset); | 1936 | scrollBy(0,-mScrollOffset); |
1933 | } | 1937 | } |
1934 | 1938 | ||
1935 | 1939 | ||
1936 | void KOAgenda::scrollDown() | 1940 | void KOAgenda::scrollDown() |
1937 | { | 1941 | { |
1938 | scrollBy(0,mScrollOffset); | 1942 | scrollBy(0,mScrollOffset); |
1939 | } | 1943 | } |
1940 | 1944 | ||
1941 | void KOAgenda::popupAlarm() | 1945 | void KOAgenda::popupAlarm() |
1942 | { | 1946 | { |
1943 | if (!mClickedItem) { | 1947 | if (!mClickedItem) { |
1944 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1948 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1945 | return; | 1949 | return; |
1946 | } | 1950 | } |
1947 | // TODO: deal correctly with multiple alarms | 1951 | // TODO: deal correctly with multiple alarms |
1948 | Alarm* alarm; | 1952 | Alarm* alarm; |
1949 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1953 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1950 | for(alarm=list.first();alarm;alarm=list.next()) { | 1954 | for(alarm=list.first();alarm;alarm=list.next()) { |
1951 | alarm->toggleAlarm(); | 1955 | alarm->toggleAlarm(); |
1952 | } | 1956 | } |
1953 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1957 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1954 | mClickedItem->paintMe( true ); | 1958 | mClickedItem->paintMe( true ); |
1955 | mClickedItem->repaint( false ); | 1959 | mClickedItem->repaint( false ); |
1956 | } | 1960 | } |
1957 | 1961 | ||
1958 | /* | 1962 | /* |
1959 | Calculates the minimum width | 1963 | Calculates the minimum width |
1960 | */ | 1964 | */ |
1961 | int KOAgenda::minimumWidth() const | 1965 | int KOAgenda::minimumWidth() const |
1962 | { | 1966 | { |
1963 | // TODO:: develop a way to dynamically determine the minimum width | 1967 | // TODO:: develop a way to dynamically determine the minimum width |
1964 | int min = 100; | 1968 | int min = 100; |
1965 | 1969 | ||
1966 | return min; | 1970 | return min; |
1967 | } | 1971 | } |
1968 | 1972 | ||
1969 | void KOAgenda::updateConfig() | 1973 | void KOAgenda::updateConfig() |
1970 | { | 1974 | { |
1971 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1975 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1972 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1976 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1973 | if ( mAllDayMode ) { | 1977 | if ( mAllDayMode ) { |
1974 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1978 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1975 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1979 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1976 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1980 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1977 | // setMaximumHeight( mGridSpacingY+1 ); | 1981 | // setMaximumHeight( mGridSpacingY+1 ); |
1978 | viewport()->repaint( false ); | 1982 | viewport()->repaint( false ); |
1979 | //setFixedHeight( mGridSpacingY+1 ); | 1983 | //setFixedHeight( mGridSpacingY+1 ); |
1980 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 1984 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
1981 | } | 1985 | } |
1982 | else { | 1986 | else { |
1983 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 1987 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
1984 | calculateWorkingHours(); | 1988 | calculateWorkingHours(); |
1985 | marcus_bains(); | 1989 | marcus_bains(); |
1986 | } | 1990 | } |
1987 | } | 1991 | } |
1988 | 1992 | ||
1989 | void KOAgenda::checkScrollBoundaries() | 1993 | void KOAgenda::checkScrollBoundaries() |
1990 | { | 1994 | { |
1991 | // Invalidate old values to force update | 1995 | // Invalidate old values to force update |
1992 | mOldLowerScrollValue = -1; | 1996 | mOldLowerScrollValue = -1; |
1993 | mOldUpperScrollValue = -1; | 1997 | mOldUpperScrollValue = -1; |
1994 | 1998 | ||
1995 | checkScrollBoundaries(verticalScrollBar()->value()); | 1999 | checkScrollBoundaries(verticalScrollBar()->value()); |
1996 | } | 2000 | } |
1997 | 2001 | ||
1998 | void KOAgenda::checkScrollBoundaries(int v) | 2002 | void KOAgenda::checkScrollBoundaries(int v) |
1999 | { | 2003 | { |
2000 | if ( mGridSpacingY == 0 ) | 2004 | if ( mGridSpacingY == 0 ) |
2001 | return; | 2005 | return; |
2002 | int yMin = v/mGridSpacingY; | 2006 | int yMin = v/mGridSpacingY; |
2003 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2007 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2004 | 2008 | ||
2005 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2009 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2006 | 2010 | ||
2007 | if (yMin != mOldLowerScrollValue) { | 2011 | if (yMin != mOldLowerScrollValue) { |
2008 | mOldLowerScrollValue = yMin; | 2012 | mOldLowerScrollValue = yMin; |
2009 | emit lowerYChanged(yMin); | 2013 | emit lowerYChanged(yMin); |
2010 | } | 2014 | } |
2011 | if (yMax != mOldUpperScrollValue) { | 2015 | if (yMax != mOldUpperScrollValue) { |
2012 | mOldUpperScrollValue = yMax; | 2016 | mOldUpperScrollValue = yMax; |
2013 | emit upperYChanged(yMax); | 2017 | emit upperYChanged(yMax); |
2014 | } | 2018 | } |
2015 | } | 2019 | } |
2016 | 2020 | ||
2017 | void KOAgenda::deselectItem() | 2021 | void KOAgenda::deselectItem() |
2018 | { | 2022 | { |
2019 | if (mSelectedItem.isNull()) return; | 2023 | if (mSelectedItem.isNull()) return; |
2020 | mSelectedItem->select(false); | 2024 | mSelectedItem->select(false); |
2021 | mSelectedItem = 0; | 2025 | mSelectedItem = 0; |
2022 | } | 2026 | } |
2023 | 2027 | ||
2024 | void KOAgenda::selectItem(KOAgendaItem *item) | 2028 | void KOAgenda::selectItem(KOAgendaItem *item) |
2025 | { | 2029 | { |
2026 | if ((KOAgendaItem *)mSelectedItem == item) return; | 2030 | if ((KOAgendaItem *)mSelectedItem == item) return; |
2027 | deselectItem(); | 2031 | deselectItem(); |
2028 | if (item == 0) { | 2032 | if (item == 0) { |
2029 | emit incidenceSelected( 0 ); | 2033 | emit incidenceSelected( 0 ); |
2030 | return; | 2034 | return; |
2031 | } | 2035 | } |
2032 | mSelectedItem = item; | 2036 | mSelectedItem = item; |
2033 | mSelectedItem->select(); | 2037 | mSelectedItem->select(); |
2034 | emit incidenceSelected( mSelectedItem->incidence() ); | 2038 | emit incidenceSelected( mSelectedItem->incidence() ); |
2035 | } | 2039 | } |
2036 | 2040 | ||
2037 | // This function seems never be called. | 2041 | // This function seems never be called. |
2038 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 2042 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
2039 | { | 2043 | { |
2040 | switch(kev->key()) { | 2044 | switch(kev->key()) { |
2041 | case Key_PageDown: | 2045 | case Key_PageDown: |
2042 | verticalScrollBar()->addPage(); | 2046 | verticalScrollBar()->addPage(); |
2043 | break; | 2047 | break; |
2044 | case Key_PageUp: | 2048 | case Key_PageUp: |
2045 | verticalScrollBar()->subtractPage(); | 2049 | verticalScrollBar()->subtractPage(); |
2046 | break; | 2050 | break; |
2047 | case Key_Down: | 2051 | case Key_Down: |
2048 | verticalScrollBar()->addLine(); | 2052 | verticalScrollBar()->addLine(); |
2049 | break; | 2053 | break; |
2050 | case Key_Up: | 2054 | case Key_Up: |
2051 | verticalScrollBar()->subtractLine(); | 2055 | verticalScrollBar()->subtractLine(); |
2052 | break; | 2056 | break; |
2053 | default: | 2057 | default: |
2054 | ; | 2058 | ; |
2055 | } | 2059 | } |
2056 | } | 2060 | } |
2057 | 2061 | ||
2058 | void KOAgenda::calculateWorkingHours() | 2062 | void KOAgenda::calculateWorkingHours() |
2059 | { | 2063 | { |
2060 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 2064 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
2061 | mWorkingHoursEnable = !mAllDayMode; | 2065 | mWorkingHoursEnable = !mAllDayMode; |
2062 | 2066 | ||
2063 | mWorkingHoursYTop = mGridSpacingY * | 2067 | mWorkingHoursYTop = mGridSpacingY * |
2064 | KOPrefs::instance()->mWorkingHoursStart * 4; | 2068 | KOPrefs::instance()->mWorkingHoursStart * 4; |
2065 | mWorkingHoursYBottom = mGridSpacingY * | 2069 | mWorkingHoursYBottom = mGridSpacingY * |
2066 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 2070 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
2067 | } | 2071 | } |
2068 | 2072 | ||
2069 | 2073 | ||
2070 | DateList KOAgenda::dateList() const | 2074 | DateList KOAgenda::dateList() const |
2071 | { | 2075 | { |
2072 | return mSelectedDates; | 2076 | return mSelectedDates; |
2073 | } | 2077 | } |
2074 | 2078 | ||
2075 | void KOAgenda::setDateList(const DateList &selectedDates) | 2079 | void KOAgenda::setDateList(const DateList &selectedDates) |
2076 | { | 2080 | { |
2077 | mSelectedDates = selectedDates; | 2081 | mSelectedDates = selectedDates; |
2078 | marcus_bains(); | 2082 | marcus_bains(); |
2079 | } | 2083 | } |
2080 | 2084 | ||
2081 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 2085 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
2082 | { | 2086 | { |
2083 | mHolidayMask = mask; | 2087 | mHolidayMask = mask; |
2084 | 2088 | ||
2085 | /* | 2089 | /* |
2086 | kdDebug() << "HolidayMask: "; | 2090 | kdDebug() << "HolidayMask: "; |
2087 | for(uint i=0;i<mask->count();++i) { | 2091 | for(uint i=0;i<mask->count();++i) { |
2088 | kdDebug() << (mask->at(i) ? "*" : "o"); | 2092 | kdDebug() << (mask->at(i) ? "*" : "o"); |
2089 | } | 2093 | } |
2090 | kdDebug() << endl; | 2094 | kdDebug() << endl; |
2091 | */ | 2095 | */ |
2092 | } | 2096 | } |
2093 | 2097 | ||
2094 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 2098 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
2095 | { | 2099 | { |
2096 | 2100 | ||
2097 | QScrollView::contentsMousePressEvent(event); | 2101 | QScrollView::contentsMousePressEvent(event); |
2098 | } | 2102 | } |
2099 | 2103 | ||
2100 | void KOAgenda::storePosition() | 2104 | void KOAgenda::storePosition() |
2101 | { | 2105 | { |
2102 | //mContentPosition | 2106 | //mContentPosition |
2103 | int max = mGridSpacingY*4*24; | 2107 | int max = mGridSpacingY*4*24; |
2104 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 2108 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
2105 | mContentPosition = 0; | 2109 | mContentPosition = 0; |
2106 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 2110 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
2107 | mContentPosition = -1.0; | 2111 | mContentPosition = -1.0; |
2108 | else | 2112 | else |
2109 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 2113 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
2110 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 2114 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
2111 | 2115 | ||
2112 | } | 2116 | } |
2113 | void KOAgenda::restorePosition() | 2117 | void KOAgenda::restorePosition() |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index abb29f7..f855b03 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -281,405 +281,401 @@ bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | |||
281 | if ( horLayout ) | 281 | if ( horLayout ) |
282 | ++xOff; | 282 | ++xOff; |
283 | else | 283 | else |
284 | ++yOff; | 284 | ++yOff; |
285 | 285 | ||
286 | } | 286 | } |
287 | 287 | ||
288 | } | 288 | } |
289 | return ( yOff || xOff ); | 289 | return ( yOff || xOff ); |
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | void KOAgendaItem::select(bool selected) | 293 | void KOAgendaItem::select(bool selected) |
294 | { | 294 | { |
295 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 295 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
296 | if (mSelected == selected) return; | 296 | if (mSelected == selected) return; |
297 | mSelected = selected; | 297 | mSelected = selected; |
298 | if ( ! isVisible() ) | 298 | if ( ! isVisible() ) |
299 | return; | 299 | return; |
300 | if ( firstMultiItem() ) | 300 | if ( firstMultiItem() ) |
301 | firstMultiItem()->select( selected ); | 301 | firstMultiItem()->select( selected ); |
302 | if ( !firstMultiItem() && nextMultiItem() ) { | 302 | if ( !firstMultiItem() && nextMultiItem() ) { |
303 | KOAgendaItem * placeItem = nextMultiItem(); | 303 | KOAgendaItem * placeItem = nextMultiItem(); |
304 | while ( placeItem ) { | 304 | while ( placeItem ) { |
305 | placeItem->select( selected ); | 305 | placeItem->select( selected ); |
306 | placeItem = placeItem->nextMultiItem(); | 306 | placeItem = placeItem->nextMultiItem(); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | globalFlagBlockAgendaItemUpdate = 0; | 309 | globalFlagBlockAgendaItemUpdate = 0; |
310 | paintMe( selected ); | 310 | paintMe( selected ); |
311 | globalFlagBlockAgendaItemUpdate = 1; | 311 | globalFlagBlockAgendaItemUpdate = 1; |
312 | repaint( false ); | 312 | repaint( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | /* | 316 | /* |
317 | The eventFilter has to filter the mouse events of the agenda item childs. The | 317 | The eventFilter has to filter the mouse events of the agenda item childs. The |
318 | events are fed into the event handling method of KOAgendaItem. This allows the | 318 | events are fed into the event handling method of KOAgendaItem. This allows the |
319 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 319 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
320 | */ | 320 | */ |
321 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 321 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
322 | { | 322 | { |
323 | if (e->type() == QEvent::MouseButtonPress || | 323 | if (e->type() == QEvent::MouseButtonPress || |
324 | e->type() == QEvent::MouseButtonDblClick || | 324 | e->type() == QEvent::MouseButtonDblClick || |
325 | e->type() == QEvent::MouseButtonRelease || | 325 | e->type() == QEvent::MouseButtonRelease || |
326 | e->type() == QEvent::MouseMove) { | 326 | e->type() == QEvent::MouseMove) { |
327 | QMouseEvent *me = (QMouseEvent *)e; | 327 | QMouseEvent *me = (QMouseEvent *)e; |
328 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 328 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
329 | mapToGlobal(me->pos())); | 329 | mapToGlobal(me->pos())); |
330 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 330 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
331 | return event(&returnEvent); | 331 | return event(&returnEvent); |
332 | } else { | 332 | } else { |
333 | return false; | 333 | return false; |
334 | } | 334 | } |
335 | } | 335 | } |
336 | void KOAgendaItem::repaintMe( ) | 336 | void KOAgendaItem::repaintMe( ) |
337 | { | 337 | { |
338 | paintMe ( mSelected ); | 338 | paintMe ( mSelected ); |
339 | } | 339 | } |
340 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 340 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
341 | { | 341 | { |
342 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 342 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
343 | return; | 343 | return; |
344 | QPainter pa; | 344 | QPainter pa; |
345 | 345 | ||
346 | if ( mSelected ) { | 346 | if ( mSelected ) { |
347 | pa.begin( this ); | 347 | pa.begin( this ); |
348 | } else { | 348 | } else { |
349 | if ( mAllDay ) | 349 | if ( mAllDay ) |
350 | pa.begin( paintPixAllday() ); | 350 | pa.begin( paintPixAllday() ); |
351 | else | 351 | else |
352 | pa.begin( paintPix() ); | 352 | pa.begin( paintPix() ); |
353 | } | 353 | } |
354 | int x, yy, w, h; | 354 | int x, yy, w, h; |
355 | float nfh = 7.0; | 355 | float nfh = 7.0; |
356 | x = pos().x(); w = width(); h = height (); | 356 | x = pos().x(); w = width(); h = height (); |
357 | if ( mAllDay ) | 357 | if ( mAllDay ) |
358 | yy = y(); | 358 | yy = y(); |
359 | else | 359 | else |
360 | yy = mCellYTop * ( height() / cellHeight() ); | 360 | yy = mCellYTop * ( height() / cellHeight() ); |
361 | if ( mSelected ) { | 361 | if ( mSelected ) { |
362 | pa.translate( -x, -yy ); | 362 | pa.translate( -x, -yy ); |
363 | } | 363 | } |
364 | xPaintCoord= x; | 364 | xPaintCoord= x; |
365 | yPaintCoord = yy; | 365 | yPaintCoord = yy; |
366 | wPaintCoord = width(); | 366 | wPaintCoord = width(); |
367 | hPaintCoord = height(); | 367 | hPaintCoord = height(); |
368 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 368 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
369 | if ( paint == 0 ) | 369 | if ( paint == 0 ) |
370 | paint = &pa; | 370 | paint = &pa; |
371 | bool horLayout = ( w < h ); | 371 | bool horLayout = ( w < h ); |
372 | int maxhei = mFontPixelSize+4; | 372 | int maxhei = mFontPixelSize+4; |
373 | if ( horLayout ) | 373 | if ( horLayout ) |
374 | maxhei += AGENDA_ICON_SIZE -4; | 374 | maxhei += AGENDA_ICON_SIZE -4; |
375 | bool small = ( h < maxhei ); | 375 | bool small = ( h < maxhei ); |
376 | if ( ! small ) | 376 | if ( ! small ) |
377 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 377 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
378 | else { | 378 | else { |
379 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 379 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
380 | f.setBold( false ); | 380 | f.setBold( false ); |
381 | int fh = f.pointSize(); | 381 | int fh = f.pointSize(); |
382 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 382 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
383 | if ( nfh < 6 ) | 383 | if ( nfh < 6 ) |
384 | nfh = 6; | 384 | nfh = 6; |
385 | f.setPointSize( nfh ); | 385 | f.setPointSize( nfh ); |
386 | paint->setFont(f); | 386 | paint->setFont(f); |
387 | } | 387 | } |
388 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 388 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
389 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 389 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
390 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 390 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
391 | if ( mIncidence->typeID() == todoID ) { | 391 | if ( mIncidence->typeID() == todoID ) { |
392 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 392 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
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 | void KOAgendaItem::resizePixmap( int w , int h ) | ||
474 | { | ||
475 | paintPix()->resize( w, h ); | ||
476 | 473 | ||
477 | } | ||
478 | QPixmap * KOAgendaItem::paintPix() | 474 | QPixmap * KOAgendaItem::paintPix() |
479 | { | 475 | { |
480 | static QPixmap* mPaintPix = 0; | 476 | static QPixmap* mPaintPix = 0; |
481 | if ( ! mPaintPix ) { | 477 | if ( ! mPaintPix ) { |
482 | int w = QApplication::desktop()->width(); | 478 | int w = QApplication::desktop()->width(); |
483 | int h = QApplication::desktop()->height(); | 479 | int h = QApplication::desktop()->height(); |
484 | mPaintPix = new QPixmap(w,h); | 480 | mPaintPix = new QPixmap(w,h); |
485 | } | 481 | } |
486 | return mPaintPix ; | 482 | return mPaintPix ; |
487 | } | 483 | } |
488 | QPixmap * KOAgendaItem::paintPixAllday() | 484 | QPixmap * KOAgendaItem::paintPixAllday() |
489 | { | 485 | { |
490 | static QPixmap* mPaintPixA = 0; | 486 | static QPixmap* mPaintPixA = 0; |
491 | if ( ! mPaintPixA ) { | 487 | if ( ! mPaintPixA ) { |
492 | int w = QApplication::desktop()->width(); | 488 | int w = QApplication::desktop()->width(); |
493 | int h = QApplication::desktop()->height()/3; | 489 | int h = QApplication::desktop()->height()/5; |
494 | mPaintPixA = new QPixmap(w,h); | 490 | mPaintPixA = new QPixmap(w,h); |
495 | } | 491 | } |
496 | return mPaintPixA ; | 492 | return mPaintPixA ; |
497 | } | 493 | } |
498 | 494 | ||
499 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 495 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
500 | { | 496 | { |
501 | 497 | ||
502 | if ( globalFlagBlockAgendaItemPaint ) | 498 | if ( globalFlagBlockAgendaItemPaint ) |
503 | return; | 499 | return; |
504 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 500 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
505 | return; | 501 | return; |
506 | int yy; | 502 | int yy; |
507 | if ( mAllDay ) | 503 | if ( mAllDay ) |
508 | yy = y(); | 504 | yy = y(); |
509 | else | 505 | else |
510 | yy = mCellYTop * ( height() / cellHeight() ); | 506 | yy = mCellYTop * ( height() / cellHeight() ); |
511 | int xx = x(); | 507 | int xx = x(); |
512 | 508 | ||
513 | if ( xPaintCoord != xx || yPaintCoord != yy || | 509 | if ( xPaintCoord != xx || yPaintCoord != yy || |
514 | wPaintCoord != width() || hPaintCoord != height()) { | 510 | wPaintCoord != width() || hPaintCoord != height()) { |
515 | xPaintCoord= xx; | 511 | xPaintCoord= xx; |
516 | yPaintCoord = yy; | 512 | yPaintCoord = yy; |
517 | wPaintCoord = width(); | 513 | wPaintCoord = width(); |
518 | hPaintCoord = height(); | 514 | hPaintCoord = height(); |
519 | globalFlagBlockAgendaItemUpdate = 0; | 515 | globalFlagBlockAgendaItemUpdate = 0; |
520 | paintMe( mSelected ); | 516 | paintMe( mSelected ); |
521 | //qDebug("calling paintMe "); | 517 | //qDebug("calling paintMe "); |
522 | globalFlagBlockAgendaItemUpdate = 1; | 518 | globalFlagBlockAgendaItemUpdate = 1; |
523 | if ( mSelected ) | 519 | if ( mSelected ) |
524 | return; | 520 | return; |
525 | } | 521 | } |
526 | int rx, ry, rw, rh; | 522 | int rx, ry, rw, rh; |
527 | rx = e->rect().x(); | 523 | rx = e->rect().x(); |
528 | ry = e->rect().y(); | 524 | ry = e->rect().y(); |
529 | rw = e->rect().width(); | 525 | rw = e->rect().width(); |
530 | rh = e->rect().height(); | 526 | rh = e->rect().height(); |
531 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 527 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
532 | 528 | ||
533 | QPixmap* paintFrom ; | 529 | QPixmap* paintFrom ; |
534 | if ( mSelected ) { | 530 | if ( mSelected ) { |
535 | paintMe( mSelected ); | 531 | paintMe( mSelected ); |
536 | return; | 532 | return; |
537 | } else { | 533 | } else { |
538 | if ( mAllDay ) | 534 | if ( mAllDay ) |
539 | paintFrom = paintPixAllday(); | 535 | paintFrom = paintPixAllday(); |
540 | else | 536 | else |
541 | paintFrom = paintPix(); | 537 | paintFrom = paintPix(); |
542 | } | 538 | } |
543 | xx += rx; | 539 | xx += rx; |
544 | 540 | ||
545 | if ( xx < 0 ) { | 541 | if ( xx < 0 ) { |
546 | rw = rw + xx; | 542 | rw = rw + xx; |
547 | rx -= xx; | 543 | rx -= xx; |
548 | xx = 0; | 544 | xx = 0; |
549 | if ( rw <= 1 ) { | 545 | if ( rw <= 1 ) { |
550 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 546 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
551 | return; | 547 | return; |
552 | } | 548 | } |
553 | } | 549 | } |
554 | if ( paintFrom->width() < xx+rw ) { | 550 | if ( paintFrom->width() < xx+rw ) { |
555 | rw = paintFrom->width() - xx; | 551 | rw = paintFrom->width() - xx; |
556 | if ( rw <= 1 ) { | 552 | if ( rw <= 1 ) { |
557 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 553 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
558 | return; | 554 | return; |
559 | } | 555 | } |
560 | } | 556 | } |
561 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 557 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
562 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 558 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); |
563 | } | 559 | } |
564 | void KOAgendaItem::computeText() | 560 | void KOAgendaItem::computeText() |
565 | { | 561 | { |
566 | mDisplayedText = mIncidence->summary(); | 562 | mDisplayedText = mIncidence->summary(); |
567 | if ( (mIncidence->typeID() == todoID ) ) { | 563 | if ( (mIncidence->typeID() == todoID ) ) { |
568 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 564 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
569 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 565 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
570 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 566 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
571 | else if ( !(mIncidence->doesFloat())) | 567 | else if ( !(mIncidence->doesFloat())) |
572 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 568 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
573 | } | 569 | } |
574 | } else { | 570 | } else { |
575 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 571 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
576 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 572 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
577 | 573 | ||
578 | if ( mAllDay ) { | 574 | if ( mAllDay ) { |
579 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 575 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
580 | if ( mIncidence->doesRecur() ) { | 576 | if ( mIncidence->doesRecur() ) { |
581 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; | 577 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; |
582 | } else { | 578 | } else { |
583 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 579 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
584 | } | 580 | } |
585 | } | 581 | } |
586 | } | 582 | } |
587 | } | 583 | } |
588 | 584 | ||
589 | if ( !mIncidence->location().isEmpty() ) { | 585 | if ( !mIncidence->location().isEmpty() ) { |
590 | if ( mAllDay ) | 586 | if ( mAllDay ) |
591 | mDisplayedText += " ("; | 587 | mDisplayedText += " ("; |
592 | else | 588 | else |
593 | mDisplayedText += "\n("; | 589 | mDisplayedText += "\n("; |
594 | mDisplayedText += mIncidence->location() +")"; | 590 | mDisplayedText += mIncidence->location() +")"; |
595 | } | 591 | } |
596 | #ifdef DESKTOP_VERSION | 592 | #ifdef DESKTOP_VERSION |
597 | QString tipText = mIncidence->summary(); | 593 | QString tipText = mIncidence->summary(); |
598 | if ( !mIncidence->doesFloat() ) { | 594 | if ( !mIncidence->doesFloat() ) { |
599 | if ( mIncidence->typeID() == eventID ) { | 595 | if ( mIncidence->typeID() == eventID ) { |
600 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 596 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
601 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 597 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
602 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 598 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
603 | } | 599 | } |
604 | else { | 600 | else { |
605 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 601 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
606 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 602 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
607 | } | 603 | } |
608 | } | 604 | } |
609 | else if ( mIncidence->typeID() == todoID ) { | 605 | else if ( mIncidence->typeID() == todoID ) { |
610 | if (mIncidence->hasStartDate()) | 606 | if (mIncidence->hasStartDate()) |
611 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 607 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
612 | if (((Todo*)mIncidence)->hasDueDate()) | 608 | if (((Todo*)mIncidence)->hasDueDate()) |
613 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 609 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
614 | } | 610 | } |
615 | } else if ( mIncidence->typeID() == todoID ) { | 611 | } else if ( mIncidence->typeID() == todoID ) { |
616 | if (mIncidence->hasStartDate()) | 612 | if (mIncidence->hasStartDate()) |
617 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 613 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
618 | if (((Todo*)mIncidence)->hasDueDate()) | 614 | if (((Todo*)mIncidence)->hasDueDate()) |
619 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 615 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
620 | } | 616 | } |
621 | 617 | ||
622 | if (!mIncidence->location().isEmpty()) { | 618 | if (!mIncidence->location().isEmpty()) { |
623 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 619 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
624 | } | 620 | } |
625 | QToolTip::add(this,tipText,toolTipGroup(),""); | 621 | QToolTip::add(this,tipText,toolTipGroup(),""); |
626 | #endif | 622 | #endif |
627 | } | 623 | } |
628 | void KOAgendaItem::updateItem() | 624 | void KOAgendaItem::updateItem() |
629 | { | 625 | { |
630 | computeText(); | 626 | computeText(); |
631 | 627 | ||
632 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 628 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
633 | paintMe( mSelected ); | 629 | paintMe( mSelected ); |
634 | repaint( false); | 630 | repaint( false); |
635 | } | 631 | } |
636 | 632 | ||
637 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 633 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
638 | { | 634 | { |
639 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 635 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
640 | paintMe( mSelected ); | 636 | paintMe( mSelected ); |
641 | repaint( false ); | 637 | repaint( false ); |
642 | } | 638 | } |
643 | 639 | ||
644 | /* | 640 | /* |
645 | Return height of item in units of agenda cells | 641 | Return height of item in units of agenda cells |
646 | */ | 642 | */ |
647 | int KOAgendaItem::cellHeight() | 643 | int KOAgendaItem::cellHeight() |
648 | { | 644 | { |
649 | int ret = mCellYBottom - mCellYTop + 1; | 645 | int ret = mCellYBottom - mCellYTop + 1; |
650 | if ( ret <= 0 ) { | 646 | if ( ret <= 0 ) { |
651 | ret = 1; | 647 | ret = 1; |
652 | mCellYBottom = 0; | 648 | mCellYBottom = 0; |
653 | mCellYTop = 0; | 649 | mCellYTop = 0; |
654 | } | 650 | } |
655 | return ret; | 651 | return ret; |
656 | } | 652 | } |
657 | 653 | ||
658 | /* | 654 | /* |
659 | Return height of item in units of agenda cells | 655 | Return height of item in units of agenda cells |
660 | */ | 656 | */ |
661 | int KOAgendaItem::cellWidth() | 657 | int KOAgendaItem::cellWidth() |
662 | { | 658 | { |
663 | return mCellXWidth - mCellX + 1; | 659 | return mCellXWidth - mCellX + 1; |
664 | } | 660 | } |
665 | 661 | ||
666 | void KOAgendaItem::setItemDate(QDate qd) | 662 | void KOAgendaItem::setItemDate(QDate qd) |
667 | { | 663 | { |
668 | mDate = qd; | 664 | mDate = qd; |
669 | } | 665 | } |
670 | 666 | ||
671 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 667 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
672 | { | 668 | { |
673 | mCellX = X; | 669 | mCellX = X; |
674 | mCellYTop = YTop; | 670 | mCellYTop = YTop; |
675 | mCellYBottom = YBottom; | 671 | mCellYBottom = YBottom; |
676 | } | 672 | } |
677 | 673 | ||
678 | void KOAgendaItem::setCellXWidth(int xwidth) | 674 | void KOAgendaItem::setCellXWidth(int xwidth) |
679 | { | 675 | { |
680 | mCellXWidth = xwidth; | 676 | mCellXWidth = xwidth; |
681 | } | 677 | } |
682 | 678 | ||
683 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 679 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
684 | { | 680 | { |
685 | mCellX = XLeft; | 681 | mCellX = XLeft; |
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h index 7103abe..3ed68b0 100644 --- a/korganizer/koagendaitem.h +++ b/korganizer/koagendaitem.h | |||
@@ -1,165 +1,164 @@ | |||
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 | ||
30 | class KOAgendaItemWhatsThis; | 30 | class KOAgendaItemWhatsThis; |
31 | class QToolTipGroup; | 31 | class QToolTipGroup; |
32 | class QDragEnterEvent; | 32 | class QDragEnterEvent; |
33 | class QDropEvent; | 33 | class QDropEvent; |
34 | 34 | ||
35 | using namespace KCal; | 35 | using 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 | */ |
43 | class KOAgendaItem : public QWidget | 43 | class 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 void resizePixmap( int, int ); | ||
105 | static QPixmap * paintPix(); | 104 | static QPixmap * paintPix(); |
106 | static QPixmap * paintPixAllday(); | 105 | static QPixmap * paintPixAllday(); |
107 | void updateItem(); | 106 | void updateItem(); |
108 | void computeText(); | 107 | void computeText(); |
109 | void recreateIncidence(); | 108 | void recreateIncidence(); |
110 | bool checkLayout(); | 109 | bool checkLayout(); |
111 | void initColor (); | 110 | void initColor (); |
112 | public slots: | 111 | public slots: |
113 | bool updateIcons( QPainter *, bool ); | 112 | bool updateIcons( QPainter *, bool ); |
114 | void select(bool=true); | 113 | void select(bool=true); |
115 | 114 | ||
116 | protected: | 115 | protected: |
117 | void dragEnterEvent(QDragEnterEvent *e); | 116 | void dragEnterEvent(QDragEnterEvent *e); |
118 | void dropEvent(QDropEvent *e); | 117 | void dropEvent(QDropEvent *e); |
119 | void paintEvent ( QPaintEvent * ); | 118 | void paintEvent ( QPaintEvent * ); |
120 | void resizeEvent ( QResizeEvent *ev ); | 119 | void resizeEvent ( QResizeEvent *ev ); |
121 | 120 | ||
122 | private: | 121 | private: |
123 | KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; | 122 | KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; |
124 | bool mAllDay; | 123 | bool mAllDay; |
125 | bool mWhiteText; | 124 | bool mWhiteText; |
126 | int mCellX; | 125 | int mCellX; |
127 | int mCellXWidth; | 126 | int mCellXWidth; |
128 | int mCellYTop,mCellYBottom; | 127 | int mCellYTop,mCellYBottom; |
129 | int mSubCell; // subcell number of this item | 128 | int mSubCell; // subcell number of this item |
130 | int mSubCells; // Total number of subcells in cell of this item | 129 | int mSubCells; // Total number of subcells in cell of this item |
131 | int xPaintCoord; | 130 | int xPaintCoord; |
132 | int yPaintCoord; | 131 | int yPaintCoord; |
133 | int wPaintCoord; | 132 | int wPaintCoord; |
134 | int hPaintCoord; | 133 | int hPaintCoord; |
135 | // Variables to remember start position | 134 | // Variables to remember start position |
136 | int mStartCellX; | 135 | int mStartCellX; |
137 | int mStartCellXWidth; | 136 | int mStartCellXWidth; |
138 | int mStartCellYTop,mStartCellYBottom; | 137 | int mStartCellYTop,mStartCellYBottom; |
139 | int mLastMovePos; | 138 | int mLastMovePos; |
140 | 139 | ||
141 | // Multi item pointers | 140 | // Multi item pointers |
142 | KOAgendaItem *mFirstMultiItem; | 141 | KOAgendaItem *mFirstMultiItem; |
143 | KOAgendaItem *mNextMultiItem; | 142 | KOAgendaItem *mNextMultiItem; |
144 | KOAgendaItem *mLastMultiItem; | 143 | KOAgendaItem *mLastMultiItem; |
145 | 144 | ||
146 | int mFontPixelSize; | 145 | int mFontPixelSize; |
147 | Incidence *mIncidence; // corresponding event or todo | 146 | Incidence *mIncidence; // corresponding event or todo |
148 | QDate mDate; //date this events occurs (for recurrence) | 147 | QDate mDate; //date this events occurs (for recurrence) |
149 | //void showIcon( QLabel*, int ); | 148 | //void showIcon( QLabel*, int ); |
150 | //QLabel *mTodoIconLabel; | 149 | //QLabel *mTodoIconLabel; |
151 | //QLabel *mItemLabel; | 150 | //QLabel *mItemLabel; |
152 | //QWidget *mIconBox; | 151 | //QWidget *mIconBox; |
153 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; | 152 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; |
154 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; | 153 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; |
155 | //QLabel *mIconMoreInfo; | 154 | //QLabel *mIconMoreInfo; |
156 | static QToolTipGroup *mToolTipGroup; | 155 | static QToolTipGroup *mToolTipGroup; |
157 | 156 | ||
158 | QColor mBackgroundColor; | 157 | QColor mBackgroundColor; |
159 | QColorGroup mColorGroup; | 158 | QColorGroup mColorGroup; |
160 | QString mDisplayedText; | 159 | QString mDisplayedText; |
161 | bool mSelected; | 160 | bool mSelected; |
162 | QPtrList<KOAgendaItem> mConflictItems; | 161 | QPtrList<KOAgendaItem> mConflictItems; |
163 | }; | 162 | }; |
164 | 163 | ||
165 | #endif // KOAGENDAITEM_H | 164 | #endif // KOAGENDAITEM_H |