summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-09 14:48:54 (UTC)
committer zautrix <zautrix>2005-07-09 14:48:54 (UTC)
commit875884b2517f9b82153a14852c0f1676f985494f (patch) (unidiff)
tree89e1c773a2fdae7a4f2e2fb9ba9d4c59e921d60f
parentfa7a30172aa502aaa9e81868e5960efba76cbb0d (diff)
downloadkdepimpi-875884b2517f9b82153a14852c0f1676f985494f.zip
kdepimpi-875884b2517f9b82153a14852c0f1676f985494f.tar.gz
kdepimpi-875884b2517f9b82153a14852c0f1676f985494f.tar.bz2
layout fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp2
-rw-r--r--korganizer/kotodoview.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index b5a59af..498d9b0 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1593,513 +1593,513 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
1593 uint weekNum = 6; 1593 uint weekNum = 6;
1594 mStartDate = start; 1594 mStartDate = start;
1595 if ( mShowWeekView ) { 1595 if ( mShowWeekView ) {
1596 weekNum = 1; 1596 weekNum = 1;
1597 cells = &mCellsW; 1597 cells = &mCellsW;
1598 dayLabels = &mDayLabelsW; 1598 dayLabels = &mDayLabelsW;
1599 weekLabels = &mWeekLabelsW; 1599 weekLabels = &mWeekLabelsW;
1600 if ( !KGlobal::locale()->weekStartsMonday() ) { 1600 if ( !KGlobal::locale()->weekStartsMonday() ) {
1601 mStartDate = mStartDate.addDays( 1 ); 1601 mStartDate = mStartDate.addDays( 1 );
1602 } 1602 }
1603 } else { 1603 } else {
1604 cells = &mCells; 1604 cells = &mCells;
1605 dayLabels = &mDayLabels; 1605 dayLabels = &mDayLabels;
1606 weekLabels = &mWeekLabels; 1606 weekLabels = &mWeekLabels;
1607 } 1607 }
1608 1608
1609 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1609 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1610 1610
1611 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1611 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1612 mWeekStartsMonday = true; 1612 mWeekStartsMonday = true;
1613 } 1613 }
1614 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1614 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1615 1615
1616 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1616 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1617 mStartDate = mStartDate.addDays( -1 ); 1617 mStartDate = mStartDate.addDays( -1 );
1618 } 1618 }
1619 uint i; 1619 uint i;
1620 for( i = 0; i < (*cells).size(); ++i ) { 1620 for( i = 0; i < (*cells).size(); ++i ) {
1621 QDate date = mStartDate.addDays( i ); 1621 QDate date = mStartDate.addDays( i );
1622 (*cells)[i]->setDate( date ); 1622 (*cells)[i]->setDate( date );
1623 1623
1624#ifndef KORG_NOPLUGINS 1624#ifndef KORG_NOPLUGINS
1625 // add holiday, if present 1625 // add holiday, if present
1626 QString hstring(KOCore::self()->holiday(date)); 1626 QString hstring(KOCore::self()->holiday(date));
1627 (*cells)[i]->setHoliday( hstring ); 1627 (*cells)[i]->setHoliday( hstring );
1628#endif 1628#endif
1629 1629
1630 } 1630 }
1631 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1631 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1632 for( i = 0; i < weekNum; ++i ) { 1632 for( i = 0; i < weekNum; ++i ) {
1633 int wno; 1633 int wno;
1634 // remember, according to ISO 8601, the first week of the year is the 1634 // remember, according to ISO 8601, the first week of the year is the
1635 // first week that contains a thursday. Thus we must subtract off 4, 1635 // first week that contains a thursday. Thus we must subtract off 4,
1636 // not just 1. 1636 // not just 1.
1637 int dayOfYear = date.dayOfYear(); 1637 int dayOfYear = date.dayOfYear();
1638 if (dayOfYear % 7 != 0) 1638 if (dayOfYear % 7 != 0)
1639 wno = dayOfYear / 7 + 1; 1639 wno = dayOfYear / 7 + 1;
1640 else 1640 else
1641 wno =dayOfYear / 7; 1641 wno =dayOfYear / 7;
1642 (*weekLabels)[i]->setWeekNum( wno ); 1642 (*weekLabels)[i]->setWeekNum( wno );
1643 date = date.addDays( 7 ); 1643 date = date.addDays( 7 );
1644 } 1644 }
1645 updateView(); 1645 updateView();
1646} 1646}
1647 1647
1648void KOMonthView::showEvents(QPtrList<Event>) 1648void KOMonthView::showEvents(QPtrList<Event>)
1649{ 1649{
1650 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1650 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1651} 1651}
1652 1652
1653void KOMonthView::changeEventDisplay(Event *, int) 1653void KOMonthView::changeEventDisplay(Event *, int)
1654{ 1654{
1655 // this should be re-written to be much more efficient, but this 1655 // this should be re-written to be much more efficient, but this
1656 // quick-and-dirty-hack gets the job done for right now. 1656 // quick-and-dirty-hack gets the job done for right now.
1657 //qDebug("KOMonthView::changeEventDisplay "); 1657 //qDebug("KOMonthView::changeEventDisplay ");
1658 updateView(); 1658 updateView();
1659} 1659}
1660 1660
1661void KOMonthView::updateView() 1661void KOMonthView::updateView()
1662{ 1662{
1663 1663
1664 if ( !updatePossible ) 1664 if ( !updatePossible )
1665 return; 1665 return;
1666 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1666 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1667 //QTime ti; 1667 //QTime ti;
1668 //ti.start(); 1668 //ti.start();
1669 clearSelection(); 1669 clearSelection();
1670 QPtrVector<MonthViewCell> *cells; 1670 QPtrVector<MonthViewCell> *cells;
1671 if ( mShowWeekView ) { 1671 if ( mShowWeekView ) {
1672 cells = &mCellsW; 1672 cells = &mCellsW;
1673 } else { 1673 } else {
1674 cells = &mCells; 1674 cells = &mCells;
1675 } 1675 }
1676#if 1 1676#if 1
1677 int i; 1677 int i;
1678 int timeSpan = (*cells).size()-1; 1678 int timeSpan = (*cells).size()-1;
1679 if ( KOPrefs::instance()->mMonthViewWeek ) 1679 if ( KOPrefs::instance()->mMonthViewWeek )
1680 timeSpan = 6; 1680 timeSpan = 6;
1681 for( i = 0; i < timeSpan + 1; ++i ) { 1681 for( i = 0; i < timeSpan + 1; ++i ) {
1682 (*cells)[i]->startUpdateCell(); 1682 (*cells)[i]->startUpdateCell();
1683 } 1683 }
1684 1684
1685 QPtrList<Event> events = calendar()->events(); 1685 QPtrList<Event> events = calendar()->events();
1686 Event *event; 1686 Event *event;
1687 QDateTime dt; 1687 QDateTime dt;
1688 QDate endDate = mStartDate.addDays( timeSpan ); 1688 QDate endDate = mStartDate.addDays( timeSpan );
1689 for( event = events.first(); event; event = events.next() ) { // for event 1689 for( event = events.first(); event; event = events.next() ) { // for event
1690 if ( event->doesRecur() ) { 1690 if ( event->doesRecur() ) {
1691 bool last; 1691 bool last;
1692 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1692 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1693 QDateTime incidenceEnd; 1693 QDateTime incidenceEnd;
1694 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1694 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1695 bool invalid = false; 1695 bool invalid = false;
1696 while( true ) { 1696 while( true ) {
1697 if ( incidenceStart.isValid() ) { 1697 if ( incidenceStart.isValid() ) {
1698 incidenceEnd = incidenceStart.addDays( eventlen ); 1698 incidenceEnd = incidenceStart.addDays( eventlen );
1699 int st = incidenceStart.date().daysTo( endDate ); 1699 int st = incidenceStart.date().daysTo( endDate );
1700 if ( st >= 0 ) { // start before timeend 1700 if ( st >= 0 ) { // start before timeend
1701 int end = mStartDate.daysTo( incidenceEnd.date() ); 1701 int end = mStartDate.daysTo( incidenceEnd.date() );
1702 if ( end >= 0 ) { // end after timestart --- got one! 1702 if ( end >= 0 ) { // end after timestart --- got one!
1703 //normalize 1703 //normalize
1704 st = timeSpan - st; 1704 st = timeSpan - st;
1705 if ( st < 0 ) st = 0; 1705 if ( st < 0 ) st = 0;
1706 if ( end > timeSpan ) end = timeSpan; 1706 if ( end > timeSpan ) end = timeSpan;
1707 int iii; 1707 int iii;
1708 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1708 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1709 for ( iii = st;iii<= end;++iii) 1709 for ( iii = st;iii<= end;++iii)
1710 (*cells)[iii]->insertEvent( event ); 1710 (*cells)[iii]->insertEvent( event );
1711 } 1711 }
1712 } 1712 }
1713 } else { 1713 } else {
1714 if ( invalid ) 1714 if ( invalid )
1715 break; 1715 break;
1716 invalid = true; 1716 invalid = true;
1717 //qDebug("invalid %s", event->summary().latin1()); 1717 //qDebug("invalid %s", event->summary().latin1());
1718 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1718 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1719 } 1719 }
1720 if ( last ) 1720 if ( last )
1721 break; 1721 break;
1722 bool ok; 1722 bool ok;
1723 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1723 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1724 if ( ! ok ) 1724 if ( ! ok )
1725 break; 1725 break;
1726 if ( incidenceStart.date() > endDate ) 1726 if ( incidenceStart.date() > endDate )
1727 break; 1727 break;
1728 } 1728 }
1729 } else { // no recur 1729 } else { // no recur
1730 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1730 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1731 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1731 if ( event->uid().left(15) == QString("last-syncEvent-") )
1732 continue; 1732 continue;
1733 int st = event->dtStart().date().daysTo( endDate ); 1733 int st = event->dtStart().date().daysTo( endDate );
1734 if ( st >= 0 ) { // start before timeend 1734 if ( st >= 0 ) { // start before timeend
1735 int end = mStartDate.daysTo( event->dtEnd().date() ); 1735 int end = mStartDate.daysTo( event->dtEnd().date() );
1736 if ( end >= 0 ) { // end after timestart --- got one! 1736 if ( end >= 0 ) { // end after timestart --- got one!
1737 //normalize 1737 //normalize
1738 st = timeSpan - st; 1738 st = timeSpan - st;
1739 if ( st < 0 ) st = 0; 1739 if ( st < 0 ) st = 0;
1740 if ( end > timeSpan ) end = timeSpan; 1740 if ( end > timeSpan ) end = timeSpan;
1741 int iii; 1741 int iii;
1742 for ( iii = st;iii<= end;++iii) 1742 for ( iii = st;iii<= end;++iii)
1743 (*cells)[iii]->insertEvent( event ); 1743 (*cells)[iii]->insertEvent( event );
1744 } 1744 }
1745 } 1745 }
1746 } 1746 }
1747 } 1747 }
1748 // insert due todos 1748 // insert due todos
1749 QPtrList<Todo> todos = calendar()->todos( ); 1749 QPtrList<Todo> todos = calendar()->todos( );
1750 Todo *todo; 1750 Todo *todo;
1751 for(todo = todos.first(); todo; todo = todos.next()) { 1751 for(todo = todos.first(); todo; todo = todos.next()) {
1752 //insertTodo( todo ); 1752 //insertTodo( todo );
1753 if ( todo->hasDueDate() ) { 1753 if ( todo->hasDueDate() ) {
1754 int day = mStartDate.daysTo( todo->dtDue().date() ); 1754 int day = mStartDate.daysTo( todo->dtDue().date() );
1755 if ( day >= 0 && day < timeSpan + 1) { 1755 if ( day >= 0 && day < timeSpan + 1) {
1756 (*cells)[day]->insertTodo( todo ); 1756 (*cells)[day]->insertTodo( todo );
1757 } 1757 }
1758 } 1758 }
1759 } 1759 }
1760 1760
1761 for( i = 0; i < timeSpan+1; ++i ) { 1761 for( i = 0; i < timeSpan+1; ++i ) {
1762 (*cells)[i]->finishUpdateCell(); 1762 (*cells)[i]->finishUpdateCell();
1763 } 1763 }
1764 processSelectionChange(); 1764 processSelectionChange();
1765 //qApp->processEvents(); 1765 //qApp->processEvents();
1766 for( i = 0; i < timeSpan+1; ++i ) { 1766 for( i = 0; i < timeSpan+1; ++i ) {
1767 //(*cells)[i]->repaintfinishUpdateCell(); 1767 //(*cells)[i]->repaintfinishUpdateCell();
1768 QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); 1768 QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) );
1769 } 1769 }
1770 setKeyBFocus(); 1770 setKeyBFocus();
1771#else 1771#else
1772 // old code 1772 // old code
1773 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1773 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1774 int i; 1774 int i;
1775 for( i = 0; i < (*cells).count(); ++i ) { 1775 for( i = 0; i < (*cells).count(); ++i ) {
1776 (*cells)[i]->updateCell(); 1776 (*cells)[i]->updateCell();
1777 } 1777 }
1778 1778
1779 //qDebug("KOMonthView::updateView() "); 1779 //qDebug("KOMonthView::updateView() ");
1780 processSelectionChange(); 1780 processSelectionChange();
1781 // qDebug("---------------------------------------------------------------------+ "); 1781 // qDebug("---------------------------------------------------------------------+ ");
1782 (*cells)[0]->setFocus(); 1782 (*cells)[0]->setFocus();
1783#endif 1783#endif
1784 1784
1785 //qDebug("update time %d ", ti.elapsed()); 1785 //qDebug("update time %d ", ti.elapsed());
1786} 1786}
1787 1787
1788void KOMonthView::setKeyBoardFocus() 1788void KOMonthView::setKeyBoardFocus()
1789{ 1789{
1790 //qDebug("KOMonthView::setKeyBoardFocus() "); 1790 //qDebug("KOMonthView::setKeyBoardFocus() ");
1791 bool shootAgain = false; 1791 bool shootAgain = false;
1792 if ( mShowWeekView ) { 1792 if ( mShowWeekView ) {
1793 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1793 shootAgain = !mWeekLabelsW[1]->hasFocus();
1794 mWeekLabelsW[1]->setFocus(); 1794 mWeekLabelsW[1]->setFocus();
1795 } 1795 }
1796 else { 1796 else {
1797 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1797 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1798 mWeekLabels[mNumWeeks]->setFocus(); 1798 mWeekLabels[mNumWeeks]->setFocus();
1799 } 1799 }
1800 --mKBFcounter; 1800 --mKBFcounter;
1801 if ( shootAgain && mKBFcounter > 0 ) { 1801 if ( shootAgain && mKBFcounter > 0 ) {
1802 QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); 1802 QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) );
1803 } 1803 }
1804} 1804}
1805void KOMonthView::setKeyBFocus() 1805void KOMonthView::setKeyBFocus()
1806{ 1806{
1807 //qDebug("KOMonthView::setKeyBFocus() "); 1807 //qDebug("KOMonthView::setKeyBFocus() ");
1808 mKBFcounter = 10; 1808 mKBFcounter = 10;
1809 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1809 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1810} 1810}
1811void KOMonthView::resizeEvent(QResizeEvent * e) 1811void KOMonthView::resizeEvent(QResizeEvent * e)
1812{ 1812{
1813 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1813 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1814 if ( isVisible() ) { 1814 if ( isVisible() ) {
1815 //qDebug("KOMonthView::isVisible "); 1815 //qDebug("KOMonthView::isVisible ");
1816 slotComputeLayout(); 1816 slotComputeLayout();
1817 } else 1817 } else
1818 mComputeLayoutTimer->start( 100 ); 1818 mComputeLayoutTimer->start( 100 );
1819 if ( e ) 1819 if ( e )
1820 KOEventView::resizeEvent( e ); 1820 KOEventView::resizeEvent( e );
1821} 1821}
1822 1822
1823void KOMonthView::slotComputeLayout() 1823void KOMonthView::slotComputeLayout()
1824{ 1824{
1825 mComputeLayoutTimer->stop(); 1825 mComputeLayoutTimer->stop();
1826 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1826 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1827 computeLayout(); 1827 computeLayout();
1828 clPending = true; 1828 clPending = true;
1829 setKeyBFocus(); 1829 setKeyBFocus();
1830} 1830}
1831 1831
1832void KOMonthView::doComputeLayoutWeek() 1832void KOMonthView::doComputeLayoutWeek()
1833{ 1833{
1834 1834
1835 int daysToShow; 1835 int daysToShow;
1836 bool combinedSatSun = false; 1836 bool combinedSatSun = false;
1837 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1837 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1838 daysToShow = 6; 1838 daysToShow = 6;
1839 combinedSatSun = true; 1839 combinedSatSun = true;
1840 } 1840 }
1841 int wid = width();//e 1841 int wid = width();//e
1842 int hei = height()-1-mNavigatorBar->height(); 1842 int hei = height()-1-mNavigatorBar->height();
1843#ifdef DESKTOP_VERSION 1843#ifdef DESKTOP_VERSION
1844 if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { 1844 if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) {
1845 daysToShow = 2; 1845 daysToShow = 2;
1846 } else 1846 } else
1847#endif 1847#endif
1848 { 1848 {
1849 if ( wid < hei ) 1849 if ( wid < hei + 40 )
1850 daysToShow = 2; 1850 daysToShow = 2;
1851 else 1851 else
1852 daysToShow = 3; 1852 daysToShow = 3;
1853 } 1853 }
1854 bool landscape = (daysToShow == 3); 1854 bool landscape = (daysToShow == 3);
1855 mShowSatSunComp = true; 1855 mShowSatSunComp = true;
1856 combinedSatSun = true; 1856 combinedSatSun = true;
1857 1857
1858 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1858 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1859 QFontMetrics fm ( mWeekLabels[0]->font() ); 1859 QFontMetrics fm ( mWeekLabels[0]->font() );
1860 int weeklabelwid = fm.width( "888" ); 1860 int weeklabelwid = fm.width( "888" );
1861 wid -= weeklabelwid; 1861 wid -= weeklabelwid;
1862 1862
1863 int colWid = wid / daysToShow; 1863 int colWid = wid / daysToShow;
1864 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1864 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1865 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1865 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1866 int colModulo = wid % daysToShow; 1866 int colModulo = wid % daysToShow;
1867 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1867 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1868 //qDebug("rowmod %d ", rowModulo); 1868 //qDebug("rowmod %d ", rowModulo);
1869 int i; 1869 int i;
1870 int x,y,w,h; 1870 int x,y,w,h;
1871 x= 0; 1871 x= 0;
1872 y= 0; 1872 y= 0;
1873 w = colWid; 1873 w = colWid;
1874 h = dayLabelHei ; 1874 h = dayLabelHei ;
1875 for ( i = 0; i < 7; i++) { 1875 for ( i = 0; i < 7; i++) {
1876 if ( i && !( i % daysToShow) && i < 6) { 1876 if ( i && !( i % daysToShow) && i < 6) {
1877 y += hei/(5-daysToShow); 1877 y += hei/(5-daysToShow);
1878 x = 0; 1878 x = 0;
1879 w = colWid; 1879 w = colWid;
1880 } 1880 }
1881 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1881 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1882 ++w; 1882 ++w;
1883 } 1883 }
1884 int xC,yC,wC,hC; 1884 int xC,yC,wC,hC;
1885 if ( i >= 5 ) { 1885 if ( i >= 5 ) {
1886 int wi = width() - x - weeklabelwid; 1886 int wi = width() - x - weeklabelwid;
1887 if ( i == 5 ) { 1887 if ( i == 5 ) {
1888 xC = x+weeklabelwid; 1888 xC = x+weeklabelwid;
1889 yC = y; 1889 yC = y;
1890 wC = wi/2+wi%2; 1890 wC = wi/2+wi%2;
1891 hC = h; 1891 hC = h;
1892 } else { 1892 } else {
1893 xC = x+weeklabelwid; 1893 xC = x+weeklabelwid;
1894 yC = y; 1894 yC = y;
1895 wC = wi; 1895 wC = wi;
1896 hC = h; 1896 hC = h;
1897 } 1897 }
1898 x = x - w + wi - (wi/2 ); 1898 x = x - w + wi - (wi/2 );
1899 } 1899 }
1900 else { 1900 else {
1901 int wi = w; 1901 int wi = w;
1902 if ( !(( i+1) % daysToShow)) { 1902 if ( !(( i+1) % daysToShow)) {
1903 wi = width() - x - weeklabelwid; 1903 wi = width() - x - weeklabelwid;
1904 } 1904 }
1905 xC = x+weeklabelwid; 1905 xC = x+weeklabelwid;
1906 yC = y; 1906 yC = y;
1907 wC = wi; 1907 wC = wi;
1908 hC = h; 1908 hC = h;
1909 } 1909 }
1910 mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); 1910 mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC);
1911 1911
1912 1912
1913 x += w; 1913 x += w;
1914 } 1914 }
1915 x= 0; 1915 x= 0;
1916 y= dayLabelHei; 1916 y= dayLabelHei;
1917 w = colWid; 1917 w = colWid;
1918 h = cellHei; 1918 h = cellHei;
1919 int max = 0; 1919 int max = 0;
1920 int w_count = mCellsW.count(); 1920 int w_count = mCellsW.count();
1921 for ( i = 0; i < w_count; ++i) { 1921 for ( i = 0; i < w_count; ++i) {
1922 if ( i > 6 ) { 1922 if ( i > 6 ) {
1923 mCellsW[i]->hide(); 1923 mCellsW[i]->hide();
1924 continue; 1924 continue;
1925 } 1925 }
1926 1926
1927 w = colWid; 1927 w = colWid;
1928 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1928 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1929 ++w; 1929 ++w;
1930 } 1930 }
1931 if ( i == (daysToShow-1-rowModulo)*7) 1931 if ( i == (daysToShow-1-rowModulo)*7)
1932 ++h; 1932 ++h;
1933 1933
1934 int xC,yC,wC,hC; 1934 int xC,yC,wC,hC;
1935 if ( i >= 5 ) { 1935 if ( i >= 5 ) {
1936 if ( i ==5 ) { 1936 if ( i ==5 ) {
1937 max = h/2; 1937 max = h/2;
1938 xC = x+weeklabelwid; 1938 xC = x+weeklabelwid;
1939 yC = y; 1939 yC = y;
1940 wC = w; 1940 wC = w;
1941 hC = max; 1941 hC = max;
1942 x -= w ;y += h/2; 1942 x -= w ;y += h/2;
1943 } else { 1943 } else {
1944 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1944 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1945 ++w; 1945 ++w;
1946 } 1946 }
1947 max = h-h/2; 1947 max = h-h/2;
1948 xC = x+weeklabelwid; 1948 xC = x+weeklabelwid;
1949 yC = y; 1949 yC = y;
1950 wC = w; 1950 wC = w;
1951 hC = max; 1951 hC = max;
1952 y -= h/2; 1952 y -= h/2;
1953 } 1953 }
1954 } else { 1954 } else {
1955 max = h; 1955 max = h;
1956 xC = x+weeklabelwid; 1956 xC = x+weeklabelwid;
1957 yC = y; 1957 yC = y;
1958 wC = w; 1958 wC = w;
1959 hC = h; 1959 hC = h;
1960 } 1960 }
1961 mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); 1961 mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC );
1962 1962
1963 1963
1964 x += w; 1964 x += w;
1965 if ( x + w/2 > wid ) { 1965 if ( x + w/2 > wid ) {
1966 x = 0; 1966 x = 0;
1967 y += h+dayLabelHei ; 1967 y += h+dayLabelHei ;
1968 } 1968 }
1969 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); 1969 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 );
1970 } 1970 }
1971 y= dayLabelHei; 1971 y= dayLabelHei;
1972 h = cellHei ; 1972 h = cellHei ;
1973 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1973 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1974 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1974 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1975 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1975 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1976 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1976 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1977 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1977 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1978 updateDayLabels(); 1978 updateDayLabels();
1979 //bool forceUpdate = !updatePossible; 1979 //bool forceUpdate = !updatePossible;
1980 updatePossible = true; 1980 updatePossible = true;
1981 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1981 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1982 //if ( forceUpdate ) 1982 //if ( forceUpdate )
1983 // updateView(); 1983 // updateView();
1984} 1984}
1985void KOMonthView::computeLayoutWeek() 1985void KOMonthView::computeLayoutWeek()
1986{ 1986{
1987 static int lastWid = 0; 1987 static int lastWid = 0;
1988 static int lastHei = 0; 1988 static int lastHei = 0;
1989 int tWid = topLevelWidget()->size().width(); 1989 int tWid = topLevelWidget()->size().width();
1990 int tHei = topLevelWidget()->size().height(); 1990 int tHei = topLevelWidget()->size().height();
1991 int wid = width();//e 1991 int wid = width();//e
1992 int hei = height()-1-mNavigatorBar->height(); 1992 int hei = height()-1-mNavigatorBar->height();
1993 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1993 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1994 return; 1994 return;
1995 1995
1996 if ( lastWid == width() && lastHei == height() ) { 1996 if ( lastWid == width() && lastHei == height() ) {
1997 //qDebug("KOListWeekView::No compute layout needed "); 1997 //qDebug("KOListWeekView::No compute layout needed ");
1998 return; 1998 return;
1999 } 1999 }
2000 lastWid = width(); 2000 lastWid = width();
2001 lastHei = height(); 2001 lastHei = height();
2002 doComputeLayoutWeek(); 2002 doComputeLayoutWeek();
2003} 2003}
2004int KOMonthView::mapWeekLayout( int index, bool landscape ) 2004int KOMonthView::mapWeekLayout( int index, bool landscape )
2005{ 2005{
2006 if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) 2006 if ( KOPrefs::instance()->mMonthViewWeekRowlayout )
2007 return index; 2007 return index;
2008 int diff = 0; 2008 int diff = 0;
2009 if ( !landscape ) diff = 1; 2009 if ( !landscape ) diff = 1;
2010 switch( index ) { 2010 switch( index ) {
2011 case 0: 2011 case 0:
2012 case 5: 2012 case 5:
2013 case 6: 2013 case 6:
2014 return index; 2014 return index;
2015 break; 2015 break;
2016 case 1: 2016 case 1:
2017 return 2+diff; 2017 return 2+diff;
2018 break; 2018 break;
2019 case 2: 2019 case 2:
2020 return 4-(3*diff); 2020 return 4-(3*diff);
2021 break; 2021 break;
2022 case 3: 2022 case 3:
2023 return 1+(3*diff); 2023 return 1+(3*diff);
2024 break; 2024 break;
2025 case 4: 2025 case 4:
2026 return 3-diff; 2026 return 3-diff;
2027 break; 2027 break;
2028 default: 2028 default:
2029 qDebug("KO: Error in mapping week layout "); 2029 qDebug("KO: Error in mapping week layout ");
2030 return index; 2030 return index;
2031 break; 2031 break;
2032 } 2032 }
2033 return index; 2033 return index;
2034} 2034}
2035void KOMonthView::computeLayout() 2035void KOMonthView::computeLayout()
2036{ 2036{
2037 2037
2038 2038
2039 static int lastWid = 0; 2039 static int lastWid = 0;
2040 static int lastHei = 0; 2040 static int lastHei = 0;
2041 2041
2042 if ( mShowWeekView ){ 2042 if ( mShowWeekView ){
2043 computeLayoutWeek(); 2043 computeLayoutWeek();
2044 return; 2044 return;
2045 } 2045 }
2046 int daysToShow = 7; 2046 int daysToShow = 7;
2047 bool combinedSatSun = false; 2047 bool combinedSatSun = false;
2048 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 2048 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
2049 daysToShow = 6; 2049 daysToShow = 6;
2050 combinedSatSun = true; 2050 combinedSatSun = true;
2051 } 2051 }
2052 int tWid = topLevelWidget()->size().width(); 2052 int tWid = topLevelWidget()->size().width();
2053 int tHei = topLevelWidget()->size().height(); 2053 int tHei = topLevelWidget()->size().height();
2054 2054
2055 int wid = width();//e 2055 int wid = width();//e
2056 int hei = height()-1-mNavigatorBar->height(); 2056 int hei = height()-1-mNavigatorBar->height();
2057 2057
2058 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 2058 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
2059 return; 2059 return;
2060 } 2060 }
2061 if ( lastWid == width() && lastHei == height() ){ 2061 if ( lastWid == width() && lastHei == height() ){
2062 //qDebug("KOMonthview::No compute layout needed "); 2062 //qDebug("KOMonthview::No compute layout needed ");
2063 return; 2063 return;
2064 } 2064 }
2065 2065
2066 lastWid = width(); 2066 lastWid = width();
2067 lastHei = height(); 2067 lastHei = height();
2068 //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 2068 //qDebug("KOMonthView::computeLayout() MMM ------------------- ");
2069 QFontMetrics fm ( mWeekLabels[0]->font() ); 2069 QFontMetrics fm ( mWeekLabels[0]->font() );
2070 int weeklabelwid = fm.width( "888" ); 2070 int weeklabelwid = fm.width( "888" );
2071 wid -= weeklabelwid; 2071 wid -= weeklabelwid;
2072 2072
2073 int colWid = wid / daysToShow; 2073 int colWid = wid / daysToShow;
2074 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 2074 int dayLabelHei = mDayLabels[0]->sizeHint().height();
2075 int cellHei = (hei - dayLabelHei) /6; 2075 int cellHei = (hei - dayLabelHei) /6;
2076 int colModulo = wid % daysToShow; 2076 int colModulo = wid % daysToShow;
2077 int rowModulo = (hei- dayLabelHei) % 6; 2077 int rowModulo = (hei- dayLabelHei) % 6;
2078 //qDebug("rowmod %d ", rowModulo); 2078 //qDebug("rowmod %d ", rowModulo);
2079 int i; 2079 int i;
2080 int x,y,w,h; 2080 int x,y,w,h;
2081 x= 0; 2081 x= 0;
2082 y= 0; 2082 y= 0;
2083 w = colWid; 2083 w = colWid;
2084 h = dayLabelHei ; 2084 h = dayLabelHei ;
2085 for ( i = 0; i < 7; i++) { 2085 for ( i = 0; i < 7; i++) {
2086 if ( i == daysToShow-colModulo ) 2086 if ( i == daysToShow-colModulo )
2087 ++w; 2087 ++w;
2088 if ( combinedSatSun ) { 2088 if ( combinedSatSun ) {
2089 if ( i >= daysToShow-1 ) { 2089 if ( i >= daysToShow-1 ) {
2090 2090
2091 if ( i == 6 ) 2091 if ( i == 6 )
2092 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); 2092 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h);
2093 else 2093 else
2094 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 2094 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
2095 x -= w/2 ; 2095 x -= w/2 ;
2096 } 2096 }
2097 else 2097 else
2098 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 2098 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
2099 } else 2099 } else
2100 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 2100 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
2101 x += w; 2101 x += w;
2102 } 2102 }
2103 x= 0; 2103 x= 0;
2104 y= dayLabelHei; 2104 y= dayLabelHei;
2105 w = colWid; 2105 w = colWid;
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index c2ad886..add1819 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -263,513 +263,513 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e)
263 if (destination) destinationEvent = destination->todo(); 263 if (destination) destinationEvent = destination->todo();
264 264
265 Todo *existingTodo = mCalendar->todo(todo->uid()); 265 Todo *existingTodo = mCalendar->todo(todo->uid());
266 266
267 if(existingTodo) { 267 if(existingTodo) {
268 Incidence *to = destinationEvent; 268 Incidence *to = destinationEvent;
269 while(to) { 269 while(to) {
270 if (to->uid() == todo->uid()) { 270 if (to->uid() == todo->uid()) {
271 KMessageBox::sorry(this, 271 KMessageBox::sorry(this,
272 i18n("Cannot move Todo to itself\nor a child of itself"), 272 i18n("Cannot move Todo to itself\nor a child of itself"),
273 i18n("Drop Todo")); 273 i18n("Drop Todo"));
274 delete todo; 274 delete todo;
275 return; 275 return;
276 } 276 }
277 to = to->relatedTo(); 277 to = to->relatedTo();
278 } 278 }
279 internalDrop = true; 279 internalDrop = true;
280 if ( destinationEvent ) 280 if ( destinationEvent )
281 reparentTodoSignal( destinationEvent, existingTodo ); 281 reparentTodoSignal( destinationEvent, existingTodo );
282 else 282 else
283 unparentTodoSignal(existingTodo); 283 unparentTodoSignal(existingTodo);
284 delete todo; 284 delete todo;
285 } else { 285 } else {
286 mCalendar->addTodo(todo); 286 mCalendar->addTodo(todo);
287 emit todoDropped(todo, KOGlobals::EVENTADDED); 287 emit todoDropped(todo, KOGlobals::EVENTADDED);
288 if ( destinationEvent ) 288 if ( destinationEvent )
289 reparentTodoSignal( destinationEvent, todo ); 289 reparentTodoSignal( destinationEvent, todo );
290 } 290 }
291 } 291 }
292 else { 292 else {
293 QString text; 293 QString text;
294 if (QTextDrag::decode(e,text)) { 294 if (QTextDrag::decode(e,text)) {
295 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 295 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
296 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 296 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
297 qDebug("Dropped : " + text); 297 qDebug("Dropped : " + text);
298 QStringList emails = QStringList::split(",",text); 298 QStringList emails = QStringList::split(",",text);
299 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 299 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
300 int pos = (*it).find("<"); 300 int pos = (*it).find("<");
301 QString name = (*it).left(pos); 301 QString name = (*it).left(pos);
302 QString email = (*it).mid(pos); 302 QString email = (*it).mid(pos);
303 if (!email.isEmpty() && todoi) { 303 if (!email.isEmpty() && todoi) {
304 todoi->todo()->addAttendee(new Attendee(name,email)); 304 todoi->todo()->addAttendee(new Attendee(name,email));
305 } 305 }
306 } 306 }
307 } 307 }
308 else { 308 else {
309 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 309 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
310 e->ignore(); 310 e->ignore();
311 } 311 }
312 } 312 }
313#endif 313#endif
314} 314}
315void KOTodoListView::wheelEvent (QWheelEvent *e) 315void KOTodoListView::wheelEvent (QWheelEvent *e)
316{ 316{
317 QListView::wheelEvent (e); 317 QListView::wheelEvent (e);
318} 318}
319 319
320void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 320void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
321{ 321{
322 322
323 QPoint p(contentsToViewport(e->pos())); 323 QPoint p(contentsToViewport(e->pos()));
324 QListViewItem *i = itemAt(p); 324 QListViewItem *i = itemAt(p);
325 bool rootClicked = true; 325 bool rootClicked = true;
326 if (i) { 326 if (i) {
327 // if the user clicked into the root decoration of the item, don't 327 // if the user clicked into the root decoration of the item, don't
328 // try to start a drag! 328 // try to start a drag!
329 int X = p.x(); 329 int X = p.x();
330 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 330 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
331 if (X > header()->sectionPos(0) + 331 if (X > header()->sectionPos(0) +
332 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 332 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
333 itemMargin() +i->height()|| 333 itemMargin() +i->height()||
334 X < header()->sectionPos(0)) { 334 X < header()->sectionPos(0)) {
335 rootClicked = false; 335 rootClicked = false;
336 } 336 }
337 } else { 337 } else {
338 rootClicked = false; 338 rootClicked = false;
339 } 339 }
340#ifndef KORG_NODND 340#ifndef KORG_NODND
341 mMousePressed = false; 341 mMousePressed = false;
342 if (! rootClicked && !( e->button() == RightButton) ) { 342 if (! rootClicked && !( e->button() == RightButton) ) {
343 mPressPos = e->pos(); 343 mPressPos = e->pos();
344 mMousePressed = true; 344 mMousePressed = true;
345 } else { 345 } else {
346 mMousePressed = false; 346 mMousePressed = false;
347 } 347 }
348#endif 348#endif
349 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 349 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
350#ifndef DESKTOP_VERSION 350#ifndef DESKTOP_VERSION
351 if (!( e->button() == RightButton && rootClicked) ) 351 if (!( e->button() == RightButton && rootClicked) )
352 QListView::contentsMousePressEvent(e); 352 QListView::contentsMousePressEvent(e);
353#else 353#else
354 QListView::contentsMousePressEvent(e); 354 QListView::contentsMousePressEvent(e);
355#endif 355#endif
356} 356}
357void KOTodoListView::paintEvent(QPaintEvent* e) 357void KOTodoListView::paintEvent(QPaintEvent* e)
358{ 358{
359 emit paintNeeded(); 359 emit paintNeeded();
360 QListView::paintEvent( e); 360 QListView::paintEvent( e);
361} 361}
362void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 362void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
363{ 363{
364 364
365#ifndef KORG_NODND 365#ifndef KORG_NODND
366 //QListView::contentsMouseMoveEvent(e); 366 //QListView::contentsMouseMoveEvent(e);
367 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 367 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
368 QApplication::startDragDistance()*3) { 368 QApplication::startDragDistance()*3) {
369 mMousePressed = false; 369 mMousePressed = false;
370 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 370 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
371 if (item) { 371 if (item) {
372 DndFactory factory( mCalendar ); 372 DndFactory factory( mCalendar );
373 ICalDrag *vd = factory.createDrag( 373 ICalDrag *vd = factory.createDrag(
374 ((KOTodoViewItem *)item)->todo(),viewport()); 374 ((KOTodoViewItem *)item)->todo(),viewport());
375 internalDrop = false; 375 internalDrop = false;
376 // we cannot do any senseful here, because the DnD is still broken in Qt 376 // we cannot do any senseful here, because the DnD is still broken in Qt
377 if (vd->drag()) { 377 if (vd->drag()) {
378 if ( !internalDrop ) { 378 if ( !internalDrop ) {
379 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 379 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
380 qDebug("Dnd: External move: Delete drag source "); 380 qDebug("Dnd: External move: Delete drag source ");
381 } else 381 } else
382 qDebug("Dnd: Internal move "); 382 qDebug("Dnd: Internal move ");
383 383
384 } else { 384 } else {
385 if ( !internalDrop ) { 385 if ( !internalDrop ) {
386 qDebug("Dnd: External Copy"); 386 qDebug("Dnd: External Copy");
387 } else 387 } else
388 qDebug("DnD: Internal copy: Copy pending"); 388 qDebug("DnD: Internal copy: Copy pending");
389 } 389 }
390 } 390 }
391 } 391 }
392#endif 392#endif
393} 393}
394void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 394void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
395{ 395{
396 if ( !e->isAutoRepeat() ) { 396 if ( !e->isAutoRepeat() ) {
397 mFlagKeyPressed = false; 397 mFlagKeyPressed = false;
398 } 398 }
399} 399}
400 400
401 401
402void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 402void KOTodoListView::keyPressEvent ( QKeyEvent * e )
403{ 403{
404 qApp->processEvents(); 404 qApp->processEvents();
405 if ( !isVisible() ) { 405 if ( !isVisible() ) {
406 e->ignore(); 406 e->ignore();
407 return; 407 return;
408 } 408 }
409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
410 e->ignore(); 410 e->ignore();
411 // qDebug(" ignore %d",e->isAutoRepeat() ); 411 // qDebug(" ignore %d",e->isAutoRepeat() );
412 return; 412 return;
413 } 413 }
414 if (! e->isAutoRepeat() ) 414 if (! e->isAutoRepeat() )
415 mFlagKeyPressed = true; 415 mFlagKeyPressed = true;
416 QListViewItem* cn; 416 QListViewItem* cn;
417 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 417 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
418 cn = currentItem(); 418 cn = currentItem();
419 if ( cn ) { 419 if ( cn ) {
420 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 420 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
421 if ( ci ){ 421 if ( ci ){
422 if ( e->state() == ShiftButton ) 422 if ( e->state() == ShiftButton )
423 ci->setOn( false ); 423 ci->setOn( false );
424 else 424 else
425 ci->setOn( true ); 425 ci->setOn( true );
426 cn = cn->itemBelow(); 426 cn = cn->itemBelow();
427 if ( cn ) { 427 if ( cn ) {
428 setCurrentItem ( cn ); 428 setCurrentItem ( cn );
429 ensureItemVisible ( cn ); 429 ensureItemVisible ( cn );
430 } 430 }
431 431
432 } 432 }
433 } 433 }
434 434
435 return; 435 return;
436 } 436 }
437 437
438 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 438 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
439 switch ( e->key() ) { 439 switch ( e->key() ) {
440 case Qt::Key_Down: 440 case Qt::Key_Down:
441 case Qt::Key_Up: 441 case Qt::Key_Up:
442 QListView::keyPressEvent ( e ); 442 QListView::keyPressEvent ( e );
443 break; 443 break;
444 case Qt::Key_Left: 444 case Qt::Key_Left:
445 case Qt::Key_Right: 445 case Qt::Key_Right:
446 QListView::keyPressEvent ( e ); 446 QListView::keyPressEvent ( e );
447 e->accept(); 447 e->accept();
448 return; 448 return;
449 break; 449 break;
450 default: 450 default:
451 e->ignore(); 451 e->ignore();
452 break; 452 break;
453 } 453 }
454 return; 454 return;
455 } 455 }
456 e->ignore(); 456 e->ignore();
457} 457}
458void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 458void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
459{ 459{
460 QListView::contentsMouseReleaseEvent(e); 460 QListView::contentsMouseReleaseEvent(e);
461 mMousePressed = false; 461 mMousePressed = false;
462} 462}
463 463
464void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 464void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
465{ 465{
466 if (!e) return; 466 if (!e) return;
467 467
468 QPoint vp = contentsToViewport(e->pos()); 468 QPoint vp = contentsToViewport(e->pos());
469 469
470 QListViewItem *item = itemAt(vp); 470 QListViewItem *item = itemAt(vp);
471 471
472 emit double_Clicked(item); 472 emit double_Clicked(item);
473 if (!item) return; 473 if (!item) return;
474 474
475 emit doubleClicked(item,vp,0); 475 emit doubleClicked(item,vp,0);
476} 476}
477 477
478///////////////////////////////////////////////////////////////////////////// 478/////////////////////////////////////////////////////////////////////////////
479 479
480KOQuickTodo::KOQuickTodo(QWidget *parent) : 480KOQuickTodo::KOQuickTodo(QWidget *parent) :
481 QLineEdit(parent) 481 QLineEdit(parent)
482{ 482{
483 setText(i18n("Click to add new Todo")); 483 setText(i18n("Click to add new Todo"));
484} 484}
485 485
486void KOQuickTodo::focusInEvent(QFocusEvent *ev) 486void KOQuickTodo::focusInEvent(QFocusEvent *ev)
487{ 487{
488 if ( text()==i18n("Click to add new Todo") ) 488 if ( text()==i18n("Click to add new Todo") )
489 setText(""); 489 setText("");
490 QLineEdit::focusInEvent(ev); 490 QLineEdit::focusInEvent(ev);
491} 491}
492 492
493void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 493void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
494{ 494{
495 setText(i18n("Click to add new Todo")); 495 setText(i18n("Click to add new Todo"));
496 QLineEdit::focusOutEvent(ev); 496 QLineEdit::focusOutEvent(ev);
497} 497}
498 498
499///////////////////////////////////////////////////////////////////////////// 499/////////////////////////////////////////////////////////////////////////////
500 500
501KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 501KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
502 KOrg::BaseView(calendar,parent,name) 502 KOrg::BaseView(calendar,parent,name)
503{ 503{
504 mCategoryPopupMenu = 0; 504 mCategoryPopupMenu = 0;
505 mPendingUpdateBeforeRepaint = false; 505 mPendingUpdateBeforeRepaint = false;
506 isFlatDisplay = false; 506 isFlatDisplay = false;
507 mNavigator = 0; 507 mNavigator = 0;
508 QBoxLayout *topLayout = new QVBoxLayout(this); 508 QBoxLayout *topLayout = new QVBoxLayout(this);
509 mName = QString ( name ); 509 mName = QString ( name );
510 mBlockUpdate = false; 510 mBlockUpdate = false;
511 mQuickBar = new QWidget( this ); 511 mQuickBar = new QWidget( this );
512 topLayout->addWidget(mQuickBar); 512 topLayout->addWidget(mQuickBar);
513 513
514 mQuickAdd = new KOQuickTodo(mQuickBar); 514 mQuickAdd = new KOQuickTodo(mQuickBar);
515 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); 515 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar);
516 quickLayout->addWidget( mQuickAdd ); 516 quickLayout->addWidget( mQuickAdd );
517 QPushButton * flat = new QPushButton( "F",mQuickBar ); 517 QPushButton * flat = new QPushButton( "F",mQuickBar );
518 int fixwid = flat->sizeHint().height(); 518 int fixwid = flat->sizeHint().height();
519 if ( QApplication::desktop()->width() > 320 ) 519 if ( QApplication::desktop()->width() >= 800 )
520 fixwid *= 2; 520 fixwid *= 2;
521 flat->setFixedWidth( fixwid ); 521 flat->setFixedWidth( fixwid );
522 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); 522 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat()));
523 QPushButton * allopen = new QPushButton( "O",mQuickBar ); 523 QPushButton * allopen = new QPushButton( "O",mQuickBar );
524 allopen->setFixedWidth( fixwid ); 524 allopen->setFixedWidth( fixwid );
525 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); 525 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen()));
526 QPushButton * allclose = new QPushButton( "C",mQuickBar ); 526 QPushButton * allclose = new QPushButton( "C",mQuickBar );
527 allclose->setFixedWidth( fixwid ); 527 allclose->setFixedWidth( fixwid );
528 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); 528 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose()));
529 QPushButton * s_done = new QPushButton( "D",mQuickBar ); 529 QPushButton * s_done = new QPushButton( "D",mQuickBar );
530 s_done->setPixmap( SmallIcon("greenhook16")); 530 s_done->setPixmap( SmallIcon("greenhook16"));
531 s_done->setFixedWidth( fixwid ); 531 s_done->setFixedWidth( fixwid );
532 s_done->setFixedHeight( flat->sizeHint().height() ); 532 s_done->setFixedHeight( flat->sizeHint().height() );
533 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); 533 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted()));
534 QPushButton * s_run = new QPushButton( "R",mQuickBar ); 534 QPushButton * s_run = new QPushButton( "R",mQuickBar );
535 s_run->setPixmap( SmallIcon("ko16old")); 535 s_run->setPixmap( SmallIcon("ko16old"));
536 s_run->setFixedWidth( fixwid ); 536 s_run->setFixedWidth( fixwid );
537 s_run->setFixedHeight( flat->sizeHint().height() ); 537 s_run->setFixedHeight( flat->sizeHint().height() );
538 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); 538 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning()));
539 539
540 mNewSubBut = new QPushButton( "sub",mQuickBar ); 540 mNewSubBut = new QPushButton( "sub",mQuickBar );
541 mNewSubBut->setFixedWidth( fixwid*3/2 ); 541 mNewSubBut->setFixedWidth( fixwid*3/2 );
542 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); 542 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo()));
543 mNewSubBut->setEnabled( false ); 543 mNewSubBut->setEnabled( false );
544 quickLayout->addWidget( mNewSubBut ); 544 quickLayout->addWidget( mNewSubBut );
545 quickLayout->addWidget( s_done ); 545 quickLayout->addWidget( s_done );
546 quickLayout->addWidget( s_run ); 546 quickLayout->addWidget( s_run );
547 547
548 quickLayout->addWidget( allopen ); 548 quickLayout->addWidget( allopen );
549 quickLayout->addWidget( allclose ); 549 quickLayout->addWidget( allclose );
550 quickLayout->addWidget( flat ); 550 quickLayout->addWidget( flat );
551 551
552 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); 552 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide();
553 553
554 mTodoListView = new KOTodoListView(calendar,this, name ); 554 mTodoListView = new KOTodoListView(calendar,this, name );
555 topLayout->addWidget(mTodoListView); 555 topLayout->addWidget(mTodoListView);
556 //mTodoListView->header()->setMaximumHeight(30); 556 //mTodoListView->header()->setMaximumHeight(30);
557 mTodoListView->setRootIsDecorated(true); 557 mTodoListView->setRootIsDecorated(true);
558 mTodoListView->setAllColumnsShowFocus(true); 558 mTodoListView->setAllColumnsShowFocus(true);
559 559
560 mTodoListView->setShowSortIndicator(true); 560 mTodoListView->setShowSortIndicator(true);
561 561
562 mTodoListView->addColumn(i18n("Todo")); 562 mTodoListView->addColumn(i18n("Todo"));
563 mTodoListView->addColumn(i18n("Prio")); 563 mTodoListView->addColumn(i18n("Prio"));
564 mTodoListView->setColumnAlignment(1,AlignHCenter); 564 mTodoListView->setColumnAlignment(1,AlignHCenter);
565 mTodoListView->addColumn(i18n("Complete")); 565 mTodoListView->addColumn(i18n("Complete"));
566 mTodoListView->setColumnAlignment(2,AlignCenter); 566 mTodoListView->setColumnAlignment(2,AlignCenter);
567 567
568 mTodoListView->addColumn(i18n("Due Date")); 568 mTodoListView->addColumn(i18n("Due Date"));
569 mTodoListView->setColumnAlignment(3,AlignLeft); 569 mTodoListView->setColumnAlignment(3,AlignLeft);
570 mTodoListView->addColumn(i18n("Due Time")); 570 mTodoListView->addColumn(i18n("Due Time"));
571 mTodoListView->setColumnAlignment(4,AlignHCenter); 571 mTodoListView->setColumnAlignment(4,AlignHCenter);
572 572
573 mTodoListView->addColumn(i18n("Start Date")); 573 mTodoListView->addColumn(i18n("Start Date"));
574 mTodoListView->setColumnAlignment(5,AlignLeft); 574 mTodoListView->setColumnAlignment(5,AlignLeft);
575 mTodoListView->addColumn(i18n("Start Time")); 575 mTodoListView->addColumn(i18n("Start Time"));
576 mTodoListView->setColumnAlignment(6,AlignHCenter); 576 mTodoListView->setColumnAlignment(6,AlignHCenter);
577 577
578 mTodoListView->addColumn(i18n("Cancelled")); 578 mTodoListView->addColumn(i18n("Cancelled"));
579 mTodoListView->addColumn(i18n("Categories")); 579 mTodoListView->addColumn(i18n("Categories"));
580 mTodoListView->addColumn(i18n("Calendar")); 580 mTodoListView->addColumn(i18n("Calendar"));
581#if 0 581#if 0
582 mTodoListView->addColumn(i18n("Sort Id")); 582 mTodoListView->addColumn(i18n("Sort Id"));
583 mTodoListView->setColumnAlignment(4,AlignHCenter); 583 mTodoListView->setColumnAlignment(4,AlignHCenter);
584#endif 584#endif
585 585
586 mTodoListView->setMinimumHeight( 60 ); 586 mTodoListView->setMinimumHeight( 60 );
587 mTodoListView->setItemsRenameable( true ); 587 mTodoListView->setItemsRenameable( true );
588 mTodoListView->setRenameable( 0 ); 588 mTodoListView->setRenameable( 0 );
589 mTodoListView->setColumnWidth( 0, 120 ); 589 mTodoListView->setColumnWidth( 0, 120 );
590 int iii = 0; 590 int iii = 0;
591 for ( iii = 0; iii< 10 ; ++iii ) 591 for ( iii = 0; iii< 10 ; ++iii )
592 mTodoListView->setColumnWidthMode( iii, QListView::Manual ); 592 mTodoListView->setColumnWidthMode( iii, QListView::Manual );
593 593
594 594
595 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 595 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
596 596
597 mPriorityPopupMenu = new QPopupMenu(this); 597 mPriorityPopupMenu = new QPopupMenu(this);
598 for (int i = 1; i <= 5; i++) { 598 for (int i = 1; i <= 5; i++) {
599 QString label = QString ("%1").arg (i); 599 QString label = QString ("%1").arg (i);
600 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 600 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
601 } 601 }
602 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 602 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
603 603
604 mPercentageCompletedPopupMenu = new QPopupMenu(this); 604 mPercentageCompletedPopupMenu = new QPopupMenu(this);
605 for (int i = 0; i <= 100; i+=20) { 605 for (int i = 0; i <= 100; i+=20) {
606 QString label = QString ("%1 %").arg (i); 606 QString label = QString ("%1 %").arg (i);
607 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 607 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
608 } 608 }
609 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 609 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
610 610
611 611
612 mCategoryPopupMenu = new QPopupMenu (this); 612 mCategoryPopupMenu = new QPopupMenu (this);
613 mCategoryPopupMenu->setCheckable (true); 613 mCategoryPopupMenu->setCheckable (true);
614 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 614 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
615 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); 615 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ()));
616 616
617 mCalPopupMenu = new QPopupMenu (this); 617 mCalPopupMenu = new QPopupMenu (this);
618 mCalPopupMenu->setCheckable (true); 618 mCalPopupMenu->setCheckable (true);
619 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); 619 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int)));
620 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); 620 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ()));
621 621
622 622
623 623
624 624
625 mItemPopupMenu = new QPopupMenu(this); 625 mItemPopupMenu = new QPopupMenu(this);
626 mItemPopupMenu->insertItem(i18n("Show"), this, 626 mItemPopupMenu->insertItem(i18n("Show"), this,
627 SLOT (showTodo())); 627 SLOT (showTodo()));
628 mItemPopupMenu->insertItem(i18n("Edit..."), this, 628 mItemPopupMenu->insertItem(i18n("Edit..."), this,
629 SLOT (editTodo())); 629 SLOT (editTodo()));
630 mItemPopupMenu->insertItem( i18n("Delete..."), this, 630 mItemPopupMenu->insertItem( i18n("Delete..."), this,
631 SLOT (deleteTodo())); 631 SLOT (deleteTodo()));
632 mItemPopupMenu->insertItem( i18n("Clone..."), this, 632 mItemPopupMenu->insertItem( i18n("Clone..."), this,
633 SLOT (cloneTodo())); 633 SLOT (cloneTodo()));
634 mItemPopupMenu->insertItem( i18n("Move..."), this, 634 mItemPopupMenu->insertItem( i18n("Move..."), this,
635 SLOT (moveTodo())); 635 SLOT (moveTodo()));
636#ifndef DESKTOP_VERSION 636#ifndef DESKTOP_VERSION
637 mItemPopupMenu->insertItem( i18n("Beam..."), this, 637 mItemPopupMenu->insertItem( i18n("Beam..."), this,
638 SLOT (beamTodo())); 638 SLOT (beamTodo()));
639#endif 639#endif
640 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 640 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
641 SLOT (cancelTodo())); 641 SLOT (cancelTodo()));
642 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); 642 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu);
643 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); 643 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu);
644 mItemPopupMenu->insertSeparator(); 644 mItemPopupMenu->insertSeparator();
645 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 645 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
646 SLOT (toggleRunningItem())); 646 SLOT (toggleRunningItem()));
647 mItemPopupMenu->insertSeparator(); 647 mItemPopupMenu->insertSeparator();
648 /* 648 /*
649 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 649 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
650 SLOT (newTodo())); 650 SLOT (newTodo()));
651 */ 651 */
652 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 652 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
653 SLOT (newSubTodo())); 653 SLOT (newSubTodo()));
654 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 654 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
655 SLOT (unparentTodo()),0,21); 655 SLOT (unparentTodo()),0,21);
656 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 656 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
657 SLOT (reparentTodo()),0,22); 657 SLOT (reparentTodo()),0,22);
658 mItemPopupMenu->insertSeparator(); 658 mItemPopupMenu->insertSeparator();
659#if 0 659#if 0
660 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), 660 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."),
661 this, SLOT( purgeCompleted() ) ); 661 this, SLOT( purgeCompleted() ) );
662 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 662 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
663 this, SLOT( toggleCompleted() ),0, 33 ); 663 this, SLOT( toggleCompleted() ),0, 33 );
664 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 664 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
665 this, SLOT( toggleQuickTodo() ),0, 34 ); 665 this, SLOT( toggleQuickTodo() ),0, 34 );
666 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 666 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
667 this, SLOT( toggleRunning() ),0, 35 ); 667 this, SLOT( toggleRunning() ),0, 35 );
668 668
669#endif 669#endif
670 mPopupMenu = new QPopupMenu(this); 670 mPopupMenu = new QPopupMenu(this);
671 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 671 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
672 SLOT (newTodo()),0,1); 672 SLOT (newTodo()),0,1);
673 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), 673 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."),
674 this, SLOT(purgeCompleted()),0,2); 674 this, SLOT(purgeCompleted()),0,2);
675 mPopupMenu->insertItem(i18n("Show Completed"), 675 mPopupMenu->insertItem(i18n("Show Completed"),
676 this, SLOT( toggleCompleted() ),0,3 ); 676 this, SLOT( toggleCompleted() ),0,3 );
677 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 677 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
678 this, SLOT( toggleRunning() ),0,5 ); 678 this, SLOT( toggleRunning() ),0,5 );
679 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 679 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
680 this, SLOT( setAllOpen() ),0,6 ); 680 this, SLOT( setAllOpen() ),0,6 );
681 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 681 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
682 this, SLOT( setAllClose() ),0,7 ); 682 this, SLOT( setAllClose() ),0,7 );
683 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 683 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
684 this, SLOT( setAllFlat() ),0,8 ); 684 this, SLOT( setAllFlat() ),0,8 );
685 mPopupMenu->insertSeparator(); 685 mPopupMenu->insertSeparator();
686 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 686 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
687 this, SLOT( toggleQuickTodo() ),0,4 ); 687 this, SLOT( toggleQuickTodo() ),0,4 );
688 mDocPrefs = new DocPrefs( name ); 688 mDocPrefs = new DocPrefs( name );
689 689
690 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 690 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
691 mPopupMenu->setCheckable( true ); 691 mPopupMenu->setCheckable( true );
692 mItemPopupMenu->setCheckable( true ); 692 mItemPopupMenu->setCheckable( true );
693 693
694 694
695 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 695 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
696 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 696 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
697 697
698 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 698 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
699 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 699 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
700 700
701 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 701 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
702 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 702 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
703 703
704 704
705 // Double clicking conflicts with opening/closing the subtree 705 // Double clicking conflicts with opening/closing the subtree
706 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 706 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
707 SLOT( editItem( QListViewItem *) ) ); 707 SLOT( editItem( QListViewItem *) ) );
708 /* 708 /*
709 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 709 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
710 const QPoint &,int ) ), 710 const QPoint &,int ) ),
711 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 711 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
712 */ 712 */
713 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 713 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
714 const QPoint &,int ) ), 714 const QPoint &,int ) ),
715 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 715 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
716 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 716 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
717 SLOT( itemClicked( QListViewItem * ) ) ); 717 SLOT( itemClicked( QListViewItem * ) ) );
718 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 718 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
719 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 719 SLOT( itemDoubleClicked( QListViewItem * ) ) );
720 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 720 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
721 SLOT( updateView() ) ); 721 SLOT( updateView() ) );
722 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 722 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
723 SLOT( todoModified(Todo *, int) ) ); 723 SLOT( todoModified(Todo *, int) ) );
724 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 724 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
725 SLOT( itemStateChanged( QListViewItem * ) ) ); 725 SLOT( itemStateChanged( QListViewItem * ) ) );
726 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 726 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
727 SLOT( itemStateChanged( QListViewItem * ) ) ); 727 SLOT( itemStateChanged( QListViewItem * ) ) );
728 connect( mTodoListView, SIGNAL( paintNeeded() ), 728 connect( mTodoListView, SIGNAL( paintNeeded() ),
729 SLOT( paintNeeded()) ); 729 SLOT( paintNeeded()) );
730 730
731#if 0 731#if 0
732 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 732 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
733 SLOT(selectionChanged(QListViewItem *))); 733 SLOT(selectionChanged(QListViewItem *)));
734 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 734 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
735 SLOT(selectionChanged(QListViewItem *))); 735 SLOT(selectionChanged(QListViewItem *)));
736 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 736 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
737 SLOT(selectionChanged(QListViewItem *))); 737 SLOT(selectionChanged(QListViewItem *)));
738#endif 738#endif
739 739
740 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 740 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
741 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 741 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
742 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 742 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
743 743
744 connect( mTodoListView, SIGNAL(selectionChanged() ), 744 connect( mTodoListView, SIGNAL(selectionChanged() ),
745 SLOT( processSelectionChange() ) ); 745 SLOT( processSelectionChange() ) );
746 connect( mQuickAdd, SIGNAL( returnPressed () ), 746 connect( mQuickAdd, SIGNAL( returnPressed () ),
747 SLOT( addQuickTodo() ) ); 747 SLOT( addQuickTodo() ) );
748 748
749} 749}
750 750
751KOTodoView::~KOTodoView() 751KOTodoView::~KOTodoView()
752{ 752{
753 753
754#if QT_VERSION >= 0x030000 754#if QT_VERSION >= 0x030000
755 755
756#else 756#else
757 delete mKOTodoViewWhatsThis; 757 delete mKOTodoViewWhatsThis;
758#endif 758#endif
759 759
760 delete mDocPrefs; 760 delete mDocPrefs;
761} 761}
762QString KOTodoView::getWhatsThisText(QPoint p) 762QString KOTodoView::getWhatsThisText(QPoint p)
763{ 763{
764 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 764 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
765 if ( item ) 765 if ( item )
766 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 766 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
767 KOPrefs::instance()->mWTshowDetails, 767 KOPrefs::instance()->mWTshowDetails,
768 KOPrefs::instance()->mWTshowCreated, 768 KOPrefs::instance()->mWTshowCreated,
769 KOPrefs::instance()->mWTshowChanged); 769 KOPrefs::instance()->mWTshowChanged);
770 return i18n("That is the todo view" ); 770 return i18n("That is the todo view" );
771 771
772} 772}
773 773
774void KOTodoView::jumpToDate () 774void KOTodoView::jumpToDate ()
775{ 775{