author | zautrix <zautrix> | 2004-12-04 04:53:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-04 04:53:22 (UTC) |
commit | 7828f46413766ee5db72dc9bd457eac0868f0646 (patch) (unidiff) | |
tree | d3da09120bdef2b498f836c5b1b97a5b2aa2da99 /korganizer | |
parent | 967f7c879d06961dd7a25d019380c521f7a84792 (diff) | |
download | kdepimpi-7828f46413766ee5db72dc9bd457eac0868f0646.zip kdepimpi-7828f46413766ee5db72dc9bd457eac0868f0646.tar.gz kdepimpi-7828f46413766ee5db72dc9bd457eac0868f0646.tar.bz2 |
fixed some bugs
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 1 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 2 |
3 files changed, 6 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 2321087..3908dbb 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1682,1544 +1682,1548 @@ bool CalendarView::checkFileVersion(QString fn) | |||
1682 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1682 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1683 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1683 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1684 | i18n("Sync+save")); | 1684 | i18n("Sync+save")); |
1685 | 1685 | ||
1686 | if ( km == KMessageBox::Cancel ) | 1686 | if ( km == KMessageBox::Cancel ) |
1687 | return false; | 1687 | return false; |
1688 | if ( km == KMessageBox::Yes ) | 1688 | if ( km == KMessageBox::Yes ) |
1689 | return true; | 1689 | return true; |
1690 | 1690 | ||
1691 | setSyncDevice("deleteaftersync" ); | 1691 | setSyncDevice("deleteaftersync" ); |
1692 | mSyncManager->mAskForPreferences = true; | 1692 | mSyncManager->mAskForPreferences = true; |
1693 | mSyncManager->mSyncAlgoPrefs = 3; | 1693 | mSyncManager->mSyncAlgoPrefs = 3; |
1694 | mSyncManager->mWriteBackFile = false; | 1694 | mSyncManager->mWriteBackFile = false; |
1695 | mSyncManager->mWriteBackExistingOnly = false; | 1695 | mSyncManager->mWriteBackExistingOnly = false; |
1696 | mSyncManager->mShowSyncSummary = false; | 1696 | mSyncManager->mShowSyncSummary = false; |
1697 | syncCalendar( fn, 3 ); | 1697 | syncCalendar( fn, 3 ); |
1698 | Event * e = getLastSyncEvent(); | 1698 | Event * e = getLastSyncEvent(); |
1699 | mCalendar->deleteEvent ( e ); | 1699 | mCalendar->deleteEvent ( e ); |
1700 | updateView(); | 1700 | updateView(); |
1701 | return true; | 1701 | return true; |
1702 | } | 1702 | } |
1703 | 1703 | ||
1704 | bool CalendarView::saveCalendar( QString filename ) | 1704 | bool CalendarView::saveCalendar( QString filename ) |
1705 | { | 1705 | { |
1706 | 1706 | ||
1707 | // Store back all unsaved data into calendar object | 1707 | // Store back all unsaved data into calendar object |
1708 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1708 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1709 | if ( mViewManager->currentView() ) | 1709 | if ( mViewManager->currentView() ) |
1710 | mViewManager->currentView()->flushView(); | 1710 | mViewManager->currentView()->flushView(); |
1711 | 1711 | ||
1712 | 1712 | ||
1713 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1713 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1714 | mStorage->setSaveFormat( new ICalFormat() ); | 1714 | mStorage->setSaveFormat( new ICalFormat() ); |
1715 | mStorage->setFileName( filename ); | 1715 | mStorage->setFileName( filename ); |
1716 | bool success; | 1716 | bool success; |
1717 | success = mStorage->save(); | 1717 | success = mStorage->save(); |
1718 | if ( !success ) { | 1718 | if ( !success ) { |
1719 | return false; | 1719 | return false; |
1720 | } | 1720 | } |
1721 | if ( filename == MainWindow::defaultFileName() ) { | 1721 | if ( filename == MainWindow::defaultFileName() ) { |
1722 | setLoadedFileVersion( lfv ); | 1722 | setLoadedFileVersion( lfv ); |
1723 | watchSavedFile(); | 1723 | watchSavedFile(); |
1724 | } | 1724 | } |
1725 | return true; | 1725 | return true; |
1726 | } | 1726 | } |
1727 | 1727 | ||
1728 | void CalendarView::closeCalendar() | 1728 | void CalendarView::closeCalendar() |
1729 | { | 1729 | { |
1730 | 1730 | ||
1731 | // child windows no longer valid | 1731 | // child windows no longer valid |
1732 | emit closingDown(); | 1732 | emit closingDown(); |
1733 | 1733 | ||
1734 | mCalendar->close(); | 1734 | mCalendar->close(); |
1735 | setModified(false); | 1735 | setModified(false); |
1736 | updateView(); | 1736 | updateView(); |
1737 | } | 1737 | } |
1738 | 1738 | ||
1739 | void CalendarView::archiveCalendar() | 1739 | void CalendarView::archiveCalendar() |
1740 | { | 1740 | { |
1741 | mDialogManager->showArchiveDialog(); | 1741 | mDialogManager->showArchiveDialog(); |
1742 | } | 1742 | } |
1743 | 1743 | ||
1744 | 1744 | ||
1745 | void CalendarView::readSettings() | 1745 | void CalendarView::readSettings() |
1746 | { | 1746 | { |
1747 | 1747 | ||
1748 | 1748 | ||
1749 | // mViewManager->showAgendaView(); | 1749 | // mViewManager->showAgendaView(); |
1750 | QString str; | 1750 | QString str; |
1751 | //qDebug("CalendarView::readSettings() "); | 1751 | //qDebug("CalendarView::readSettings() "); |
1752 | // read settings from the KConfig, supplying reasonable | 1752 | // read settings from the KConfig, supplying reasonable |
1753 | // defaults where none are to be found | 1753 | // defaults where none are to be found |
1754 | KConfig *config = KOGlobals::config(); | 1754 | KConfig *config = KOGlobals::config(); |
1755 | #ifndef KORG_NOSPLITTER | 1755 | #ifndef KORG_NOSPLITTER |
1756 | config->setGroup("KOrganizer Geometry"); | 1756 | config->setGroup("KOrganizer Geometry"); |
1757 | 1757 | ||
1758 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1758 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1759 | if (sizes.count() != 2) { | 1759 | if (sizes.count() != 2) { |
1760 | sizes << mDateNavigator->minimumSizeHint().width(); | 1760 | sizes << mDateNavigator->minimumSizeHint().width(); |
1761 | sizes << 300; | 1761 | sizes << 300; |
1762 | } | 1762 | } |
1763 | mPanner->setSizes(sizes); | 1763 | mPanner->setSizes(sizes); |
1764 | 1764 | ||
1765 | sizes = config->readIntListEntry("Separator2"); | 1765 | sizes = config->readIntListEntry("Separator2"); |
1766 | if ( ( mResourceView && sizes.count() == 4 ) || | 1766 | if ( ( mResourceView && sizes.count() == 4 ) || |
1767 | ( !mResourceView && sizes.count() == 3 ) ) { | 1767 | ( !mResourceView && sizes.count() == 3 ) ) { |
1768 | mLeftSplitter->setSizes(sizes); | 1768 | mLeftSplitter->setSizes(sizes); |
1769 | } | 1769 | } |
1770 | #endif | 1770 | #endif |
1771 | globalFlagBlockAgenda = 1; | 1771 | globalFlagBlockAgenda = 1; |
1772 | mViewManager->showAgendaView(); | 1772 | mViewManager->showAgendaView(); |
1773 | //mViewManager->readSettings( config ); | 1773 | //mViewManager->readSettings( config ); |
1774 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1774 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1775 | readFilterSettings(config); | 1775 | readFilterSettings(config); |
1776 | config->setGroup( "Views" ); | 1776 | config->setGroup( "Views" ); |
1777 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1777 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1778 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1778 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1779 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1779 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1780 | else mNavigator->selectDates( dateCount ); | 1780 | else mNavigator->selectDates( dateCount ); |
1781 | // mViewManager->readSettings( config ); | 1781 | // mViewManager->readSettings( config ); |
1782 | updateConfig(); | 1782 | updateConfig(); |
1783 | globalFlagBlockAgenda = 2; | 1783 | globalFlagBlockAgenda = 2; |
1784 | mViewManager->readSettings( config ); | 1784 | mViewManager->readSettings( config ); |
1785 | #ifdef DESKTOP_VERSION | 1785 | #ifdef DESKTOP_VERSION |
1786 | config->setGroup("WidgetLayout"); | 1786 | config->setGroup("WidgetLayout"); |
1787 | QStringList list; | 1787 | QStringList list; |
1788 | list = config->readListEntry("MainLayout"); | 1788 | list = config->readListEntry("MainLayout"); |
1789 | int x,y,w,h; | 1789 | int x,y,w,h; |
1790 | if ( ! list.isEmpty() ) { | 1790 | if ( ! list.isEmpty() ) { |
1791 | x = list[0].toInt(); | 1791 | x = list[0].toInt(); |
1792 | y = list[1].toInt(); | 1792 | y = list[1].toInt(); |
1793 | w = list[2].toInt(); | 1793 | w = list[2].toInt(); |
1794 | h = list[3].toInt(); | 1794 | h = list[3].toInt(); |
1795 | topLevelWidget()->setGeometry(x,y,w,h); | 1795 | topLevelWidget()->setGeometry(x,y,w,h); |
1796 | 1796 | ||
1797 | } else { | 1797 | } else { |
1798 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1798 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1799 | } | 1799 | } |
1800 | list = config->readListEntry("EditEventLayout"); | 1800 | list = config->readListEntry("EditEventLayout"); |
1801 | if ( ! list.isEmpty() ) { | 1801 | if ( ! list.isEmpty() ) { |
1802 | x = list[0].toInt(); | 1802 | x = list[0].toInt(); |
1803 | y = list[1].toInt(); | 1803 | y = list[1].toInt(); |
1804 | w = list[2].toInt(); | 1804 | w = list[2].toInt(); |
1805 | h = list[3].toInt(); | 1805 | h = list[3].toInt(); |
1806 | mEventEditor->setGeometry(x,y,w,h); | 1806 | mEventEditor->setGeometry(x,y,w,h); |
1807 | 1807 | ||
1808 | } | 1808 | } |
1809 | list = config->readListEntry("EditTodoLayout"); | 1809 | list = config->readListEntry("EditTodoLayout"); |
1810 | if ( ! list.isEmpty() ) { | 1810 | if ( ! list.isEmpty() ) { |
1811 | x = list[0].toInt(); | 1811 | x = list[0].toInt(); |
1812 | y = list[1].toInt(); | 1812 | y = list[1].toInt(); |
1813 | w = list[2].toInt(); | 1813 | w = list[2].toInt(); |
1814 | h = list[3].toInt(); | 1814 | h = list[3].toInt(); |
1815 | mTodoEditor->setGeometry(x,y,w,h); | 1815 | mTodoEditor->setGeometry(x,y,w,h); |
1816 | 1816 | ||
1817 | } | 1817 | } |
1818 | list = config->readListEntry("ViewerLayout"); | 1818 | list = config->readListEntry("ViewerLayout"); |
1819 | if ( ! list.isEmpty() ) { | 1819 | if ( ! list.isEmpty() ) { |
1820 | x = list[0].toInt(); | 1820 | x = list[0].toInt(); |
1821 | y = list[1].toInt(); | 1821 | y = list[1].toInt(); |
1822 | w = list[2].toInt(); | 1822 | w = list[2].toInt(); |
1823 | h = list[3].toInt(); | 1823 | h = list[3].toInt(); |
1824 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1824 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1825 | } | 1825 | } |
1826 | #endif | 1826 | #endif |
1827 | 1827 | ||
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | 1830 | ||
1831 | void CalendarView::writeSettings() | 1831 | void CalendarView::writeSettings() |
1832 | { | 1832 | { |
1833 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1833 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1834 | 1834 | ||
1835 | KConfig *config = KOGlobals::config(); | 1835 | KConfig *config = KOGlobals::config(); |
1836 | 1836 | ||
1837 | #ifndef KORG_NOSPLITTER | 1837 | #ifndef KORG_NOSPLITTER |
1838 | config->setGroup("KOrganizer Geometry"); | 1838 | config->setGroup("KOrganizer Geometry"); |
1839 | 1839 | ||
1840 | QValueList<int> list = mPanner->sizes(); | 1840 | QValueList<int> list = mPanner->sizes(); |
1841 | config->writeEntry("Separator1",list); | 1841 | config->writeEntry("Separator1",list); |
1842 | 1842 | ||
1843 | list = mLeftSplitter->sizes(); | 1843 | list = mLeftSplitter->sizes(); |
1844 | config->writeEntry("Separator2",list); | 1844 | config->writeEntry("Separator2",list); |
1845 | #endif | 1845 | #endif |
1846 | 1846 | ||
1847 | mViewManager->writeSettings( config ); | 1847 | mViewManager->writeSettings( config ); |
1848 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1848 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1849 | mDialogManager->writeSettings( config ); | 1849 | mDialogManager->writeSettings( config ); |
1850 | //KOPrefs::instance()->usrWriteConfig(); | 1850 | //KOPrefs::instance()->usrWriteConfig(); |
1851 | KOPrefs::instance()->writeConfig(); | 1851 | KOPrefs::instance()->writeConfig(); |
1852 | 1852 | ||
1853 | writeFilterSettings(config); | 1853 | writeFilterSettings(config); |
1854 | 1854 | ||
1855 | config->setGroup( "Views" ); | 1855 | config->setGroup( "Views" ); |
1856 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1856 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1857 | 1857 | ||
1858 | #ifdef DESKTOP_VERSION | 1858 | #ifdef DESKTOP_VERSION |
1859 | config->setGroup("WidgetLayout"); | 1859 | config->setGroup("WidgetLayout"); |
1860 | QStringList list ;//= config->readListEntry("MainLayout"); | 1860 | QStringList list ;//= config->readListEntry("MainLayout"); |
1861 | int x,y,w,h; | 1861 | int x,y,w,h; |
1862 | QWidget* wid; | 1862 | QWidget* wid; |
1863 | wid = topLevelWidget(); | 1863 | wid = topLevelWidget(); |
1864 | x = wid->geometry().x(); | 1864 | x = wid->geometry().x(); |
1865 | y = wid->geometry().y(); | 1865 | y = wid->geometry().y(); |
1866 | w = wid->width(); | 1866 | w = wid->width(); |
1867 | h = wid->height(); | 1867 | h = wid->height(); |
1868 | list.clear(); | 1868 | list.clear(); |
1869 | list << QString::number( x ); | 1869 | list << QString::number( x ); |
1870 | list << QString::number( y ); | 1870 | list << QString::number( y ); |
1871 | list << QString::number( w ); | 1871 | list << QString::number( w ); |
1872 | list << QString::number( h ); | 1872 | list << QString::number( h ); |
1873 | config->writeEntry("MainLayout",list ); | 1873 | config->writeEntry("MainLayout",list ); |
1874 | 1874 | ||
1875 | wid = mEventEditor; | 1875 | wid = mEventEditor; |
1876 | x = wid->geometry().x(); | 1876 | x = wid->geometry().x(); |
1877 | y = wid->geometry().y(); | 1877 | y = wid->geometry().y(); |
1878 | w = wid->width(); | 1878 | w = wid->width(); |
1879 | h = wid->height(); | 1879 | h = wid->height(); |
1880 | list.clear(); | 1880 | list.clear(); |
1881 | list << QString::number( x ); | 1881 | list << QString::number( x ); |
1882 | list << QString::number( y ); | 1882 | list << QString::number( y ); |
1883 | list << QString::number( w ); | 1883 | list << QString::number( w ); |
1884 | list << QString::number( h ); | 1884 | list << QString::number( h ); |
1885 | config->writeEntry("EditEventLayout",list ); | 1885 | config->writeEntry("EditEventLayout",list ); |
1886 | 1886 | ||
1887 | wid = mTodoEditor; | 1887 | wid = mTodoEditor; |
1888 | x = wid->geometry().x(); | 1888 | x = wid->geometry().x(); |
1889 | y = wid->geometry().y(); | 1889 | y = wid->geometry().y(); |
1890 | w = wid->width(); | 1890 | w = wid->width(); |
1891 | h = wid->height(); | 1891 | h = wid->height(); |
1892 | list.clear(); | 1892 | list.clear(); |
1893 | list << QString::number( x ); | 1893 | list << QString::number( x ); |
1894 | list << QString::number( y ); | 1894 | list << QString::number( y ); |
1895 | list << QString::number( w ); | 1895 | list << QString::number( w ); |
1896 | list << QString::number( h ); | 1896 | list << QString::number( h ); |
1897 | config->writeEntry("EditTodoLayout",list ); | 1897 | config->writeEntry("EditTodoLayout",list ); |
1898 | wid = getEventViewerDialog(); | 1898 | wid = getEventViewerDialog(); |
1899 | x = wid->geometry().x(); | 1899 | x = wid->geometry().x(); |
1900 | y = wid->geometry().y(); | 1900 | y = wid->geometry().y(); |
1901 | w = wid->width(); | 1901 | w = wid->width(); |
1902 | h = wid->height(); | 1902 | h = wid->height(); |
1903 | list.clear(); | 1903 | list.clear(); |
1904 | list << QString::number( x ); | 1904 | list << QString::number( x ); |
1905 | list << QString::number( y ); | 1905 | list << QString::number( y ); |
1906 | list << QString::number( w ); | 1906 | list << QString::number( w ); |
1907 | list << QString::number( h ); | 1907 | list << QString::number( h ); |
1908 | config->writeEntry("ViewerLayout",list ); | 1908 | config->writeEntry("ViewerLayout",list ); |
1909 | wid = mDialogManager->getSearchDialog(); | 1909 | wid = mDialogManager->getSearchDialog(); |
1910 | if ( wid ) { | 1910 | if ( wid ) { |
1911 | x = wid->geometry().x(); | 1911 | x = wid->geometry().x(); |
1912 | y = wid->geometry().y(); | 1912 | y = wid->geometry().y(); |
1913 | w = wid->width(); | 1913 | w = wid->width(); |
1914 | h = wid->height(); | 1914 | h = wid->height(); |
1915 | list.clear(); | 1915 | list.clear(); |
1916 | list << QString::number( x ); | 1916 | list << QString::number( x ); |
1917 | list << QString::number( y ); | 1917 | list << QString::number( y ); |
1918 | list << QString::number( w ); | 1918 | list << QString::number( w ); |
1919 | list << QString::number( h ); | 1919 | list << QString::number( h ); |
1920 | config->writeEntry("SearchLayout",list ); | 1920 | config->writeEntry("SearchLayout",list ); |
1921 | } | 1921 | } |
1922 | #endif | 1922 | #endif |
1923 | 1923 | ||
1924 | 1924 | ||
1925 | config->sync(); | 1925 | config->sync(); |
1926 | } | 1926 | } |
1927 | 1927 | ||
1928 | void CalendarView::readFilterSettings(KConfig *config) | 1928 | void CalendarView::readFilterSettings(KConfig *config) |
1929 | { | 1929 | { |
1930 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1930 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1931 | 1931 | ||
1932 | mFilters.clear(); | 1932 | mFilters.clear(); |
1933 | 1933 | ||
1934 | config->setGroup("General"); | 1934 | config->setGroup("General"); |
1935 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1935 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1936 | 1936 | ||
1937 | QStringList::ConstIterator it = filterList.begin(); | 1937 | QStringList::ConstIterator it = filterList.begin(); |
1938 | QStringList::ConstIterator end = filterList.end(); | 1938 | QStringList::ConstIterator end = filterList.end(); |
1939 | while(it != end) { | 1939 | while(it != end) { |
1940 | // kdDebug() << " filter: " << (*it) << endl; | 1940 | // kdDebug() << " filter: " << (*it) << endl; |
1941 | 1941 | ||
1942 | CalFilter *filter; | 1942 | CalFilter *filter; |
1943 | filter = new CalFilter(*it); | 1943 | filter = new CalFilter(*it); |
1944 | config->setGroup("Filter_" + (*it)); | 1944 | config->setGroup("Filter_" + (*it)); |
1945 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1945 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1946 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1946 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1947 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1947 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1948 | mFilters.append(filter); | 1948 | mFilters.append(filter); |
1949 | 1949 | ||
1950 | ++it; | 1950 | ++it; |
1951 | } | 1951 | } |
1952 | 1952 | ||
1953 | if (mFilters.count() == 0) { | 1953 | if (mFilters.count() == 0) { |
1954 | CalFilter *filter = new CalFilter(i18n("Default")); | 1954 | CalFilter *filter = new CalFilter(i18n("Default")); |
1955 | mFilters.append(filter); | 1955 | mFilters.append(filter); |
1956 | } | 1956 | } |
1957 | mFilterView->updateFilters(); | 1957 | mFilterView->updateFilters(); |
1958 | config->setGroup("FilterView"); | 1958 | config->setGroup("FilterView"); |
1959 | 1959 | ||
1960 | mFilterView->blockSignals(true); | 1960 | mFilterView->blockSignals(true); |
1961 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1961 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1962 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1962 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1963 | mFilterView->blockSignals(false); | 1963 | mFilterView->blockSignals(false); |
1964 | // We do it manually to avoid it being done twice by the above calls | 1964 | // We do it manually to avoid it being done twice by the above calls |
1965 | updateFilter(); | 1965 | updateFilter(); |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | void CalendarView::writeFilterSettings(KConfig *config) | 1968 | void CalendarView::writeFilterSettings(KConfig *config) |
1969 | { | 1969 | { |
1970 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1970 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1971 | 1971 | ||
1972 | QStringList filterList; | 1972 | QStringList filterList; |
1973 | 1973 | ||
1974 | CalFilter *filter = mFilters.first(); | 1974 | CalFilter *filter = mFilters.first(); |
1975 | while(filter) { | 1975 | while(filter) { |
1976 | // kdDebug() << " fn: " << filter->name() << endl; | 1976 | // kdDebug() << " fn: " << filter->name() << endl; |
1977 | filterList << filter->name(); | 1977 | filterList << filter->name(); |
1978 | config->setGroup("Filter_" + filter->name()); | 1978 | config->setGroup("Filter_" + filter->name()); |
1979 | config->writeEntry("Criteria",filter->criteria()); | 1979 | config->writeEntry("Criteria",filter->criteria()); |
1980 | config->writeEntry("CategoryList",filter->categoryList()); | 1980 | config->writeEntry("CategoryList",filter->categoryList()); |
1981 | filter = mFilters.next(); | 1981 | filter = mFilters.next(); |
1982 | } | 1982 | } |
1983 | config->setGroup("General"); | 1983 | config->setGroup("General"); |
1984 | config->writeEntry("CalendarFilters",filterList); | 1984 | config->writeEntry("CalendarFilters",filterList); |
1985 | 1985 | ||
1986 | config->setGroup("FilterView"); | 1986 | config->setGroup("FilterView"); |
1987 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1987 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1988 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1988 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1989 | } | 1989 | } |
1990 | 1990 | ||
1991 | 1991 | ||
1992 | void CalendarView::goToday() | 1992 | void CalendarView::goToday() |
1993 | { | 1993 | { |
1994 | mNavigator->selectToday(); | 1994 | mNavigator->selectToday(); |
1995 | } | 1995 | } |
1996 | 1996 | ||
1997 | void CalendarView::goNext() | 1997 | void CalendarView::goNext() |
1998 | { | 1998 | { |
1999 | mNavigator->selectNext(); | 1999 | mNavigator->selectNext(); |
2000 | } | 2000 | } |
2001 | 2001 | ||
2002 | void CalendarView::goPrevious() | 2002 | void CalendarView::goPrevious() |
2003 | { | 2003 | { |
2004 | mNavigator->selectPrevious(); | 2004 | mNavigator->selectPrevious(); |
2005 | } | 2005 | } |
2006 | void CalendarView::goNextMonth() | 2006 | void CalendarView::goNextMonth() |
2007 | { | 2007 | { |
2008 | mNavigator->selectNextMonth(); | 2008 | mNavigator->selectNextMonth(); |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | void CalendarView::goPreviousMonth() | 2011 | void CalendarView::goPreviousMonth() |
2012 | { | 2012 | { |
2013 | mNavigator->selectPreviousMonth(); | 2013 | mNavigator->selectPreviousMonth(); |
2014 | } | 2014 | } |
2015 | void CalendarView::writeLocale() | 2015 | void CalendarView::writeLocale() |
2016 | { | 2016 | { |
2017 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2017 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2018 | #if 0 | 2018 | #if 0 |
2019 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2019 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2020 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2020 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2021 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2021 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2022 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2022 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2023 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2023 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2024 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2024 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2025 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2025 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2026 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2026 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2027 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2027 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2028 | KOPrefs::instance()->mDaylightsavingStart, | 2028 | KOPrefs::instance()->mDaylightsavingStart, |
2029 | KOPrefs::instance()->mDaylightsavingEnd ); | 2029 | KOPrefs::instance()->mDaylightsavingEnd ); |
2030 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2030 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2031 | #endif | 2031 | #endif |
2032 | } | 2032 | } |
2033 | void CalendarView::updateConfig() | 2033 | void CalendarView::updateConfig() |
2034 | { | 2034 | { |
2035 | writeLocale(); | 2035 | writeLocale(); |
2036 | if ( KOPrefs::instance()->mUseAppColors ) | 2036 | if ( KOPrefs::instance()->mUseAppColors ) |
2037 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2037 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2038 | emit configChanged(); | 2038 | emit configChanged(); |
2039 | mTodoList->updateConfig(); | 2039 | mTodoList->updateConfig(); |
2040 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2040 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2041 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2041 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2042 | // To make the "fill window" configurations work | 2042 | // To make the "fill window" configurations work |
2043 | //mViewManager->raiseCurrentView(); | 2043 | //mViewManager->raiseCurrentView(); |
2044 | } | 2044 | } |
2045 | 2045 | ||
2046 | 2046 | ||
2047 | void CalendarView::eventChanged(Event *event) | 2047 | void CalendarView::eventChanged(Event *event) |
2048 | { | 2048 | { |
2049 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2049 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2050 | //updateUnmanagedViews(); | 2050 | //updateUnmanagedViews(); |
2051 | } | 2051 | } |
2052 | 2052 | ||
2053 | void CalendarView::eventAdded(Event *event) | 2053 | void CalendarView::eventAdded(Event *event) |
2054 | { | 2054 | { |
2055 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2055 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2056 | } | 2056 | } |
2057 | 2057 | ||
2058 | void CalendarView::eventToBeDeleted(Event *) | 2058 | void CalendarView::eventToBeDeleted(Event *) |
2059 | { | 2059 | { |
2060 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2060 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | void CalendarView::eventDeleted() | 2063 | void CalendarView::eventDeleted() |
2064 | { | 2064 | { |
2065 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2065 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2066 | } | 2066 | } |
2067 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2067 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2068 | { | 2068 | { |
2069 | changeIncidenceDisplay((Incidence *)which, action); | 2069 | changeIncidenceDisplay((Incidence *)which, action); |
2070 | mDateNavigator->updateView(); //LR | 2070 | mDateNavigator->updateView(); //LR |
2071 | //mDialogManager->updateSearchDialog(); | 2071 | //mDialogManager->updateSearchDialog(); |
2072 | 2072 | ||
2073 | if (which) { | 2073 | if (which) { |
2074 | mViewManager->updateWNview(); | 2074 | mViewManager->updateWNview(); |
2075 | //mTodoList->updateView(); | 2075 | //mTodoList->updateView(); |
2076 | } | 2076 | } |
2077 | 2077 | ||
2078 | } | 2078 | } |
2079 | 2079 | ||
2080 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2080 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2081 | { | 2081 | { |
2082 | updateUnmanagedViews(); | 2082 | updateUnmanagedViews(); |
2083 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2083 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2084 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2084 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2085 | mCalendar->checkAlarmForIncidence( 0, true ); | 2085 | mCalendar->checkAlarmForIncidence( 0, true ); |
2086 | if ( mEventViewerDialog ) | 2086 | if ( mEventViewerDialog ) |
2087 | mEventViewerDialog->hide(); | 2087 | mEventViewerDialog->hide(); |
2088 | } | 2088 | } |
2089 | else | 2089 | else |
2090 | mCalendar->checkAlarmForIncidence( which , false ); | 2090 | mCalendar->checkAlarmForIncidence( which , false ); |
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | // most of the changeEventDisplays() right now just call the view's | 2093 | // most of the changeEventDisplays() right now just call the view's |
2094 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2094 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2095 | void CalendarView::changeEventDisplay(Event *which, int action) | 2095 | void CalendarView::changeEventDisplay(Event *which, int action) |
2096 | { | 2096 | { |
2097 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2097 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2098 | changeIncidenceDisplay((Incidence *)which, action); | 2098 | changeIncidenceDisplay((Incidence *)which, action); |
2099 | mDateNavigator->updateView(); | 2099 | mDateNavigator->updateView(); |
2100 | //mDialogManager->updateSearchDialog(); | 2100 | //mDialogManager->updateSearchDialog(); |
2101 | 2101 | ||
2102 | if (which) { | 2102 | if (which) { |
2103 | // If there is an event view visible update the display | 2103 | // If there is an event view visible update the display |
2104 | mViewManager->currentView()->changeEventDisplay(which,action); | 2104 | mViewManager->currentView()->changeEventDisplay(which,action); |
2105 | // TODO: check, if update needed | 2105 | // TODO: check, if update needed |
2106 | // if (which->getTodoStatus()) { | 2106 | // if (which->getTodoStatus()) { |
2107 | mTodoList->updateView(); | 2107 | mTodoList->updateView(); |
2108 | // } | 2108 | // } |
2109 | } else { | 2109 | } else { |
2110 | mViewManager->currentView()->updateView(); | 2110 | mViewManager->currentView()->updateView(); |
2111 | } | 2111 | } |
2112 | } | 2112 | } |
2113 | 2113 | ||
2114 | 2114 | ||
2115 | void CalendarView::updateTodoViews() | 2115 | void CalendarView::updateTodoViews() |
2116 | { | 2116 | { |
2117 | 2117 | ||
2118 | mTodoList->updateView(); | 2118 | mTodoList->updateView(); |
2119 | mViewManager->currentView()->updateView(); | 2119 | mViewManager->currentView()->updateView(); |
2120 | 2120 | ||
2121 | } | 2121 | } |
2122 | 2122 | ||
2123 | 2123 | ||
2124 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2124 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2125 | { | 2125 | { |
2126 | mTodoList->updateView(); | 2126 | mTodoList->updateView(); |
2127 | mViewManager->updateView(start, end); | 2127 | mViewManager->updateView(start, end); |
2128 | //mDateNavigator->updateView(); | 2128 | //mDateNavigator->updateView(); |
2129 | } | 2129 | } |
2130 | 2130 | ||
2131 | void CalendarView::updateView() | 2131 | void CalendarView::updateView() |
2132 | { | 2132 | { |
2133 | DateList tmpList = mNavigator->selectedDates(); | 2133 | DateList tmpList = mNavigator->selectedDates(); |
2134 | 2134 | ||
2135 | // We assume that the navigator only selects consecutive days. | 2135 | // We assume that the navigator only selects consecutive days. |
2136 | updateView( tmpList.first(), tmpList.last() ); | 2136 | updateView( tmpList.first(), tmpList.last() ); |
2137 | } | 2137 | } |
2138 | 2138 | ||
2139 | void CalendarView::updateUnmanagedViews() | 2139 | void CalendarView::updateUnmanagedViews() |
2140 | { | 2140 | { |
2141 | mDateNavigator->updateDayMatrix(); | 2141 | mDateNavigator->updateDayMatrix(); |
2142 | } | 2142 | } |
2143 | 2143 | ||
2144 | int CalendarView::msgItemDelete() | 2144 | int CalendarView::msgItemDelete() |
2145 | { | 2145 | { |
2146 | return KMessageBox::warningContinueCancel(this, | 2146 | return KMessageBox::warningContinueCancel(this, |
2147 | i18n("This item will be\npermanently deleted."), | 2147 | i18n("This item will be\npermanently deleted."), |
2148 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2148 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2149 | } | 2149 | } |
2150 | 2150 | ||
2151 | 2151 | ||
2152 | void CalendarView::edit_cut() | 2152 | void CalendarView::edit_cut() |
2153 | { | 2153 | { |
2154 | Event *anEvent=0; | 2154 | Event *anEvent=0; |
2155 | 2155 | ||
2156 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2156 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2157 | 2157 | ||
2158 | if (mViewManager->currentView()->isEventView()) { | 2158 | if (mViewManager->currentView()->isEventView()) { |
2159 | if ( incidence && incidence->type() == "Event" ) { | 2159 | if ( incidence && incidence->type() == "Event" ) { |
2160 | anEvent = static_cast<Event *>(incidence); | 2160 | anEvent = static_cast<Event *>(incidence); |
2161 | } | 2161 | } |
2162 | } | 2162 | } |
2163 | 2163 | ||
2164 | if (!anEvent) { | 2164 | if (!anEvent) { |
2165 | KNotifyClient::beep(); | 2165 | KNotifyClient::beep(); |
2166 | return; | 2166 | return; |
2167 | } | 2167 | } |
2168 | DndFactory factory( mCalendar ); | 2168 | DndFactory factory( mCalendar ); |
2169 | factory.cutEvent(anEvent); | 2169 | factory.cutEvent(anEvent); |
2170 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2170 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | void CalendarView::edit_copy() | 2173 | void CalendarView::edit_copy() |
2174 | { | 2174 | { |
2175 | Event *anEvent=0; | 2175 | Event *anEvent=0; |
2176 | 2176 | ||
2177 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2177 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2178 | 2178 | ||
2179 | if (mViewManager->currentView()->isEventView()) { | 2179 | if (mViewManager->currentView()->isEventView()) { |
2180 | if ( incidence && incidence->type() == "Event" ) { | 2180 | if ( incidence && incidence->type() == "Event" ) { |
2181 | anEvent = static_cast<Event *>(incidence); | 2181 | anEvent = static_cast<Event *>(incidence); |
2182 | } | 2182 | } |
2183 | } | 2183 | } |
2184 | 2184 | ||
2185 | if (!anEvent) { | 2185 | if (!anEvent) { |
2186 | KNotifyClient::beep(); | 2186 | KNotifyClient::beep(); |
2187 | return; | 2187 | return; |
2188 | } | 2188 | } |
2189 | DndFactory factory( mCalendar ); | 2189 | DndFactory factory( mCalendar ); |
2190 | factory.copyEvent(anEvent); | 2190 | factory.copyEvent(anEvent); |
2191 | } | 2191 | } |
2192 | 2192 | ||
2193 | void CalendarView::edit_paste() | 2193 | void CalendarView::edit_paste() |
2194 | { | 2194 | { |
2195 | QDate date = mNavigator->selectedDates().first(); | 2195 | QDate date = mNavigator->selectedDates().first(); |
2196 | 2196 | ||
2197 | DndFactory factory( mCalendar ); | 2197 | DndFactory factory( mCalendar ); |
2198 | Event *pastedEvent = factory.pasteEvent( date ); | 2198 | Event *pastedEvent = factory.pasteEvent( date ); |
2199 | 2199 | ||
2200 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2200 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2201 | } | 2201 | } |
2202 | 2202 | ||
2203 | void CalendarView::edit_options() | 2203 | void CalendarView::edit_options() |
2204 | { | 2204 | { |
2205 | mDialogManager->showOptionsDialog(); | 2205 | mDialogManager->showOptionsDialog(); |
2206 | //writeSettings(); | 2206 | //writeSettings(); |
2207 | } | 2207 | } |
2208 | 2208 | ||
2209 | void CalendarView::slotSelectPickerDate( QDate d) | 2209 | void CalendarView::slotSelectPickerDate( QDate d) |
2210 | { | 2210 | { |
2211 | mDateFrame->hide(); | 2211 | mDateFrame->hide(); |
2212 | if ( mDatePickerMode == 1 ) { | 2212 | if ( mDatePickerMode == 1 ) { |
2213 | mNavigator->slotDaySelect( d ); | 2213 | mNavigator->slotDaySelect( d ); |
2214 | } else if ( mDatePickerMode == 2 ) { | 2214 | } else if ( mDatePickerMode == 2 ) { |
2215 | if ( mMoveIncidence->type() == "Todo" ) { | 2215 | if ( mMoveIncidence->type() == "Todo" ) { |
2216 | Todo * to = (Todo *) mMoveIncidence; | 2216 | Todo * to = (Todo *) mMoveIncidence; |
2217 | QTime tim; | 2217 | QTime tim; |
2218 | if ( to->hasDueDate() ) | 2218 | if ( to->hasDueDate() ) |
2219 | tim = to->dtDue().time(); | 2219 | tim = to->dtDue().time(); |
2220 | else { | 2220 | else { |
2221 | tim = QTime ( 0,0,0 ); | 2221 | tim = QTime ( 0,0,0 ); |
2222 | to->setFloats( true ); | 2222 | to->setFloats( true ); |
2223 | to->setHasDueDate( true ); | 2223 | to->setHasDueDate( true ); |
2224 | } | 2224 | } |
2225 | QDateTime dt ( d,tim ); | 2225 | QDateTime dt ( d,tim ); |
2226 | to->setDtDue( dt ); | 2226 | to->setDtDue( dt ); |
2227 | todoChanged( to ); | 2227 | todoChanged( to ); |
2228 | } else { | 2228 | } else { |
2229 | QTime tim = mMoveIncidence->dtStart().time(); | 2229 | QTime tim = mMoveIncidence->dtStart().time(); |
2230 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2230 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2231 | QDateTime dt ( d,tim ); | 2231 | QDateTime dt ( d,tim ); |
2232 | mMoveIncidence->setDtStart( dt ); | 2232 | mMoveIncidence->setDtStart( dt ); |
2233 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2233 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2234 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2234 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2235 | } | 2235 | } |
2236 | 2236 | ||
2237 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2237 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2238 | } | 2238 | } |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | void CalendarView::removeCategories() | 2241 | void CalendarView::removeCategories() |
2242 | { | 2242 | { |
2243 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2243 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2244 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2244 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2245 | QStringList catIncList; | 2245 | QStringList catIncList; |
2246 | QStringList newCatList; | 2246 | QStringList newCatList; |
2247 | Incidence* inc = incList.first(); | 2247 | Incidence* inc = incList.first(); |
2248 | int i; | 2248 | int i; |
2249 | int count = 0; | 2249 | int count = 0; |
2250 | while ( inc ) { | 2250 | while ( inc ) { |
2251 | newCatList.clear(); | 2251 | newCatList.clear(); |
2252 | catIncList = inc->categories() ; | 2252 | catIncList = inc->categories() ; |
2253 | for( i = 0; i< catIncList.count(); ++i ) { | 2253 | for( i = 0; i< catIncList.count(); ++i ) { |
2254 | if ( catList.contains (catIncList[i])) | 2254 | if ( catList.contains (catIncList[i])) |
2255 | newCatList.append( catIncList[i] ); | 2255 | newCatList.append( catIncList[i] ); |
2256 | } | 2256 | } |
2257 | newCatList.sort(); | 2257 | newCatList.sort(); |
2258 | inc->setCategories( newCatList.join(",") ); | 2258 | inc->setCategories( newCatList.join(",") ); |
2259 | inc = incList.next(); | 2259 | inc = incList.next(); |
2260 | } | 2260 | } |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | int CalendarView::addCategories() | 2263 | int CalendarView::addCategories() |
2264 | { | 2264 | { |
2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2267 | QStringList catIncList; | 2267 | QStringList catIncList; |
2268 | Incidence* inc = incList.first(); | 2268 | Incidence* inc = incList.first(); |
2269 | int i; | 2269 | int i; |
2270 | int count = 0; | 2270 | int count = 0; |
2271 | while ( inc ) { | 2271 | while ( inc ) { |
2272 | catIncList = inc->categories() ; | 2272 | catIncList = inc->categories() ; |
2273 | for( i = 0; i< catIncList.count(); ++i ) { | 2273 | for( i = 0; i< catIncList.count(); ++i ) { |
2274 | if ( !catList.contains (catIncList[i])) { | 2274 | if ( !catList.contains (catIncList[i])) { |
2275 | catList.append( catIncList[i] ); | 2275 | catList.append( catIncList[i] ); |
2276 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2276 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2277 | ++count; | 2277 | ++count; |
2278 | } | 2278 | } |
2279 | } | 2279 | } |
2280 | inc = incList.next(); | 2280 | inc = incList.next(); |
2281 | } | 2281 | } |
2282 | catList.sort(); | 2282 | catList.sort(); |
2283 | KOPrefs::instance()->mCustomCategories = catList; | 2283 | KOPrefs::instance()->mCustomCategories = catList; |
2284 | return count; | 2284 | return count; |
2285 | } | 2285 | } |
2286 | 2286 | ||
2287 | void CalendarView::manageCategories() | 2287 | void CalendarView::manageCategories() |
2288 | { | 2288 | { |
2289 | KOCatPrefs* cp = new KOCatPrefs(); | 2289 | KOCatPrefs* cp = new KOCatPrefs(); |
2290 | cp->show(); | 2290 | cp->show(); |
2291 | int w =cp->sizeHint().width() ; | 2291 | int w =cp->sizeHint().width() ; |
2292 | int h = cp->sizeHint().height() ; | 2292 | int h = cp->sizeHint().height() ; |
2293 | int dw = QApplication::desktop()->width(); | 2293 | int dw = QApplication::desktop()->width(); |
2294 | int dh = QApplication::desktop()->height(); | 2294 | int dh = QApplication::desktop()->height(); |
2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2296 | if ( !cp->exec() ) { | 2296 | if ( !cp->exec() ) { |
2297 | delete cp; | 2297 | delete cp; |
2298 | return; | 2298 | return; |
2299 | } | 2299 | } |
2300 | int count = 0; | 2300 | int count = 0; |
2301 | if ( cp->addCat() ) { | 2301 | if ( cp->addCat() ) { |
2302 | count = addCategories(); | 2302 | count = addCategories(); |
2303 | if ( count ) { | 2303 | if ( count ) { |
2304 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2304 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2305 | writeSettings(); | 2305 | writeSettings(); |
2306 | } else | 2306 | } else |
2307 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2307 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2308 | } else { | 2308 | } else { |
2309 | removeCategories(); | 2309 | removeCategories(); |
2310 | updateView(); | 2310 | updateView(); |
2311 | } | 2311 | } |
2312 | delete cp; | 2312 | delete cp; |
2313 | } | 2313 | } |
2314 | 2314 | ||
2315 | void CalendarView::beamIncidence(Incidence * Inc) | 2315 | void CalendarView::beamIncidence(Incidence * Inc) |
2316 | { | 2316 | { |
2317 | QPtrList<Incidence> delSel ; | 2317 | QPtrList<Incidence> delSel ; |
2318 | delSel.append(Inc); | 2318 | delSel.append(Inc); |
2319 | beamIncidenceList( delSel ); | 2319 | beamIncidenceList( delSel ); |
2320 | } | 2320 | } |
2321 | void CalendarView::beamCalendar() | 2321 | void CalendarView::beamCalendar() |
2322 | { | 2322 | { |
2323 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2323 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2324 | //qDebug("beamCalendar() "); | 2324 | //qDebug("beamCalendar() "); |
2325 | beamIncidenceList( delSel ); | 2325 | beamIncidenceList( delSel ); |
2326 | } | 2326 | } |
2327 | void CalendarView::beamFilteredCalendar() | 2327 | void CalendarView::beamFilteredCalendar() |
2328 | { | 2328 | { |
2329 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2329 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2330 | //qDebug("beamFilteredCalendar() "); | 2330 | //qDebug("beamFilteredCalendar() "); |
2331 | beamIncidenceList( delSel ); | 2331 | beamIncidenceList( delSel ); |
2332 | } | 2332 | } |
2333 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2333 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2334 | { | 2334 | { |
2335 | if ( beamDialog->exec () == QDialog::Rejected ) | 2335 | if ( beamDialog->exec () == QDialog::Rejected ) |
2336 | return; | 2336 | return; |
2337 | #ifdef DESKTOP_VERSION | 2337 | #ifdef DESKTOP_VERSION |
2338 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2338 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2339 | #else | 2339 | #else |
2340 | QString fn = "/tmp/kopibeamfile"; | 2340 | QString fn = "/tmp/kopibeamfile"; |
2341 | #endif | 2341 | #endif |
2342 | QString mes; | 2342 | QString mes; |
2343 | bool createbup = true; | 2343 | bool createbup = true; |
2344 | if ( createbup ) { | 2344 | if ( createbup ) { |
2345 | QString description = "\n"; | 2345 | QString description = "\n"; |
2346 | CalendarLocal* cal = new CalendarLocal(); | 2346 | CalendarLocal* cal = new CalendarLocal(); |
2347 | if ( beamDialog->beamLocal() ) | 2347 | if ( beamDialog->beamLocal() ) |
2348 | cal->setLocalTime(); | 2348 | cal->setLocalTime(); |
2349 | else | 2349 | else |
2350 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2350 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2351 | Incidence *incidence = delSel.first(); | 2351 | Incidence *incidence = delSel.first(); |
2352 | bool addText = false; | 2352 | bool addText = false; |
2353 | if ( delSel.count() < 10 ) | 2353 | if ( delSel.count() < 10 ) |
2354 | addText = true; | 2354 | addText = true; |
2355 | else { | 2355 | else { |
2356 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2356 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2357 | } | 2357 | } |
2358 | while ( incidence ) { | 2358 | while ( incidence ) { |
2359 | Incidence *in = incidence->clone(); | 2359 | Incidence *in = incidence->clone(); |
2360 | if ( ! in->summary().isEmpty() ) { | 2360 | if ( ! in->summary().isEmpty() ) { |
2361 | in->setDescription(""); | 2361 | in->setDescription(""); |
2362 | } else { | 2362 | } else { |
2363 | in->setSummary( in->description().left(20)); | 2363 | in->setSummary( in->description().left(20)); |
2364 | in->setDescription(""); | 2364 | in->setDescription(""); |
2365 | } | 2365 | } |
2366 | if ( addText ) | 2366 | if ( addText ) |
2367 | description += in->summary() + "\n"; | 2367 | description += in->summary() + "\n"; |
2368 | cal->addIncidence( in ); | 2368 | cal->addIncidence( in ); |
2369 | incidence = delSel.next(); | 2369 | incidence = delSel.next(); |
2370 | } | 2370 | } |
2371 | if ( beamDialog->beamVcal() ) { | 2371 | if ( beamDialog->beamVcal() ) { |
2372 | fn += ".vcs"; | 2372 | fn += ".vcs"; |
2373 | FileStorage storage( cal, fn, new VCalFormat ); | 2373 | FileStorage storage( cal, fn, new VCalFormat ); |
2374 | storage.save(); | 2374 | storage.save(); |
2375 | } else { | 2375 | } else { |
2376 | fn += ".ics"; | 2376 | fn += ".ics"; |
2377 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2377 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2378 | storage.save(); | 2378 | storage.save(); |
2379 | } | 2379 | } |
2380 | delete cal; | 2380 | delete cal; |
2381 | mes = i18n("KO/Pi: Ready for beaming"); | 2381 | mes = i18n("KO/Pi: Ready for beaming"); |
2382 | topLevelWidget()->setCaption(mes); | 2382 | topLevelWidget()->setCaption(mes); |
2383 | KApplication::convert2latin1( fn ); | 2383 | KApplication::convert2latin1( fn ); |
2384 | #ifndef DESKTOP_VERSION | 2384 | #ifndef DESKTOP_VERSION |
2385 | Ir *ir = new Ir( this ); | 2385 | Ir *ir = new Ir( this ); |
2386 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2386 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2387 | ir->send( fn, description, "text/x-vCalendar" ); | 2387 | ir->send( fn, description, "text/x-vCalendar" ); |
2388 | #endif | 2388 | #endif |
2389 | } | 2389 | } |
2390 | } | 2390 | } |
2391 | void CalendarView::beamDone( Ir *ir ) | 2391 | void CalendarView::beamDone( Ir *ir ) |
2392 | { | 2392 | { |
2393 | #ifndef DESKTOP_VERSION | 2393 | #ifndef DESKTOP_VERSION |
2394 | delete ir; | 2394 | delete ir; |
2395 | #endif | 2395 | #endif |
2396 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2396 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2397 | topLevelWidget()->raise(); | 2397 | topLevelWidget()->raise(); |
2398 | } | 2398 | } |
2399 | 2399 | ||
2400 | void CalendarView::moveIncidence(Incidence * inc ) | 2400 | void CalendarView::moveIncidence(Incidence * inc ) |
2401 | { | 2401 | { |
2402 | if ( !inc ) return; | 2402 | if ( !inc ) return; |
2403 | // qDebug("showDatePickerForIncidence( ) "); | 2403 | // qDebug("showDatePickerForIncidence( ) "); |
2404 | if ( mDateFrame->isVisible() ) | 2404 | if ( mDateFrame->isVisible() ) |
2405 | mDateFrame->hide(); | 2405 | mDateFrame->hide(); |
2406 | else { | 2406 | else { |
2407 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2407 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2408 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2408 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2409 | int dw = QApplication::desktop()->width(); | 2409 | int dw = QApplication::desktop()->width(); |
2410 | int dh = QApplication::desktop()->height(); | 2410 | int dh = QApplication::desktop()->height(); |
2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2412 | mDateFrame->show(); | 2412 | mDateFrame->show(); |
2413 | } | 2413 | } |
2414 | mDatePickerMode = 2; | 2414 | mDatePickerMode = 2; |
2415 | mMoveIncidence = inc ; | 2415 | mMoveIncidence = inc ; |
2416 | QDate da; | 2416 | QDate da; |
2417 | if ( mMoveIncidence->type() == "Todo" ) { | 2417 | if ( mMoveIncidence->type() == "Todo" ) { |
2418 | Todo * to = (Todo *) mMoveIncidence; | 2418 | Todo * to = (Todo *) mMoveIncidence; |
2419 | if ( to->hasDueDate() ) | 2419 | if ( to->hasDueDate() ) |
2420 | da = to->dtDue().date(); | 2420 | da = to->dtDue().date(); |
2421 | else | 2421 | else |
2422 | da = QDate::currentDate(); | 2422 | da = QDate::currentDate(); |
2423 | } else { | 2423 | } else { |
2424 | da = mMoveIncidence->dtStart().date(); | 2424 | da = mMoveIncidence->dtStart().date(); |
2425 | } | 2425 | } |
2426 | mDatePicker->setDate( da ); | 2426 | mDatePicker->setDate( da ); |
2427 | } | 2427 | } |
2428 | void CalendarView::showDatePicker( ) | 2428 | void CalendarView::showDatePicker( ) |
2429 | { | 2429 | { |
2430 | //qDebug("CalendarView::showDatePicker( ) "); | 2430 | //qDebug("CalendarView::showDatePicker( ) "); |
2431 | if ( mDateFrame->isVisible() ) | 2431 | if ( mDateFrame->isVisible() ) |
2432 | mDateFrame->hide(); | 2432 | mDateFrame->hide(); |
2433 | else { | 2433 | else { |
2434 | int w =mDatePicker->sizeHint().width() ; | 2434 | int w =mDatePicker->sizeHint().width() ; |
2435 | int h = mDatePicker->sizeHint().height() ; | 2435 | int h = mDatePicker->sizeHint().height() ; |
2436 | int dw = QApplication::desktop()->width(); | 2436 | int dw = QApplication::desktop()->width(); |
2437 | int dh = QApplication::desktop()->height(); | 2437 | int dh = QApplication::desktop()->height(); |
2438 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2438 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2439 | mDateFrame->show(); | 2439 | mDateFrame->show(); |
2440 | } | 2440 | } |
2441 | mDatePickerMode = 1; | 2441 | mDatePickerMode = 1; |
2442 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2442 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2443 | } | 2443 | } |
2444 | 2444 | ||
2445 | void CalendarView::showEventEditor() | 2445 | void CalendarView::showEventEditor() |
2446 | { | 2446 | { |
2447 | #ifdef DESKTOP_VERSION | 2447 | #ifdef DESKTOP_VERSION |
2448 | mEventEditor->show(); | 2448 | mEventEditor->show(); |
2449 | #else | 2449 | #else |
2450 | if ( mEventEditor->width() != QApplication::desktop()->width() ) | ||
2451 | mEventEditor->hide(); | ||
2450 | mEventEditor->showMaximized(); | 2452 | mEventEditor->showMaximized(); |
2451 | #endif | 2453 | #endif |
2452 | } | 2454 | } |
2453 | void CalendarView::showTodoEditor() | 2455 | void CalendarView::showTodoEditor() |
2454 | { | 2456 | { |
2455 | #ifdef DESKTOP_VERSION | 2457 | #ifdef DESKTOP_VERSION |
2456 | mTodoEditor->show(); | 2458 | mTodoEditor->show(); |
2457 | #else | 2459 | #else |
2460 | if ( mTodoEditor->width() != QApplication::desktop()->width() ) | ||
2461 | mTodoEditor->hide(); | ||
2458 | mTodoEditor->showMaximized(); | 2462 | mTodoEditor->showMaximized(); |
2459 | #endif | 2463 | #endif |
2460 | } | 2464 | } |
2461 | 2465 | ||
2462 | void CalendarView::cloneIncidence() | 2466 | void CalendarView::cloneIncidence() |
2463 | { | 2467 | { |
2464 | Incidence *incidence = currentSelection(); | 2468 | Incidence *incidence = currentSelection(); |
2465 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2469 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2466 | if ( incidence ) { | 2470 | if ( incidence ) { |
2467 | cloneIncidence(incidence); | 2471 | cloneIncidence(incidence); |
2468 | } | 2472 | } |
2469 | } | 2473 | } |
2470 | void CalendarView::moveIncidence() | 2474 | void CalendarView::moveIncidence() |
2471 | { | 2475 | { |
2472 | Incidence *incidence = currentSelection(); | 2476 | Incidence *incidence = currentSelection(); |
2473 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2477 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2474 | if ( incidence ) { | 2478 | if ( incidence ) { |
2475 | moveIncidence(incidence); | 2479 | moveIncidence(incidence); |
2476 | } | 2480 | } |
2477 | } | 2481 | } |
2478 | void CalendarView::beamIncidence() | 2482 | void CalendarView::beamIncidence() |
2479 | { | 2483 | { |
2480 | Incidence *incidence = currentSelection(); | 2484 | Incidence *incidence = currentSelection(); |
2481 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2485 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2482 | if ( incidence ) { | 2486 | if ( incidence ) { |
2483 | beamIncidence(incidence); | 2487 | beamIncidence(incidence); |
2484 | } | 2488 | } |
2485 | } | 2489 | } |
2486 | void CalendarView::toggleCancelIncidence() | 2490 | void CalendarView::toggleCancelIncidence() |
2487 | { | 2491 | { |
2488 | Incidence *incidence = currentSelection(); | 2492 | Incidence *incidence = currentSelection(); |
2489 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2493 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2490 | if ( incidence ) { | 2494 | if ( incidence ) { |
2491 | cancelIncidence(incidence); | 2495 | cancelIncidence(incidence); |
2492 | } | 2496 | } |
2493 | } | 2497 | } |
2494 | 2498 | ||
2495 | 2499 | ||
2496 | void CalendarView::cancelIncidence(Incidence * inc ) | 2500 | void CalendarView::cancelIncidence(Incidence * inc ) |
2497 | { | 2501 | { |
2498 | inc->setCancelled( ! inc->cancelled() ); | 2502 | inc->setCancelled( ! inc->cancelled() ); |
2499 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2503 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2500 | updateView(); | 2504 | updateView(); |
2501 | } | 2505 | } |
2502 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2506 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2503 | { | 2507 | { |
2504 | Incidence * newInc = orgInc->clone(); | 2508 | Incidence * newInc = orgInc->clone(); |
2505 | newInc->recreate(); | 2509 | newInc->recreate(); |
2506 | 2510 | ||
2507 | if ( newInc->type() == "Todo" ) { | 2511 | if ( newInc->type() == "Todo" ) { |
2508 | Todo* t = (Todo*) newInc; | 2512 | Todo* t = (Todo*) newInc; |
2509 | mTodoEditor->editTodo( t ); | 2513 | mTodoEditor->editTodo( t ); |
2510 | showTodoEditor(); | 2514 | showTodoEditor(); |
2511 | if ( mTodoEditor->exec() ) { | 2515 | if ( mTodoEditor->exec() ) { |
2512 | mCalendar->addTodo( t ); | 2516 | mCalendar->addTodo( t ); |
2513 | updateView(); | 2517 | updateView(); |
2514 | } else { | 2518 | } else { |
2515 | delete t; | 2519 | delete t; |
2516 | } | 2520 | } |
2517 | } | 2521 | } |
2518 | else { | 2522 | else { |
2519 | Event* e = (Event*) newInc; | 2523 | Event* e = (Event*) newInc; |
2520 | mEventEditor->editEvent( e ); | 2524 | mEventEditor->editEvent( e ); |
2521 | showEventEditor(); | 2525 | showEventEditor(); |
2522 | if ( mEventEditor->exec() ) { | 2526 | if ( mEventEditor->exec() ) { |
2523 | mCalendar->addEvent( e ); | 2527 | mCalendar->addEvent( e ); |
2524 | updateView(); | 2528 | updateView(); |
2525 | } else { | 2529 | } else { |
2526 | delete e; | 2530 | delete e; |
2527 | } | 2531 | } |
2528 | } | 2532 | } |
2529 | } | 2533 | } |
2530 | 2534 | ||
2531 | void CalendarView::newEvent() | 2535 | void CalendarView::newEvent() |
2532 | { | 2536 | { |
2533 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2537 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2534 | KOAgendaView *aView = mViewManager->agendaView(); | 2538 | KOAgendaView *aView = mViewManager->agendaView(); |
2535 | if (aView) { | 2539 | if (aView) { |
2536 | if (aView->selectionStart().isValid()) { | 2540 | if (aView->selectionStart().isValid()) { |
2537 | if (aView->selectedIsAllDay()) { | 2541 | if (aView->selectedIsAllDay()) { |
2538 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2542 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2539 | } else { | 2543 | } else { |
2540 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2544 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2541 | } | 2545 | } |
2542 | return; | 2546 | return; |
2543 | } | 2547 | } |
2544 | } | 2548 | } |
2545 | 2549 | ||
2546 | QDate date = mNavigator->selectedDates().first(); | 2550 | QDate date = mNavigator->selectedDates().first(); |
2547 | QDateTime current = QDateTime::currentDateTime(); | 2551 | QDateTime current = QDateTime::currentDateTime(); |
2548 | if ( date <= current.date() ) { | 2552 | if ( date <= current.date() ) { |
2549 | int hour = current.time().hour() +1; | 2553 | int hour = current.time().hour() +1; |
2550 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2554 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2551 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2555 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2552 | } else | 2556 | } else |
2553 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2557 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2554 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2558 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2555 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2559 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2556 | } | 2560 | } |
2557 | 2561 | ||
2558 | void CalendarView::newEvent(QDateTime fh) | 2562 | void CalendarView::newEvent(QDateTime fh) |
2559 | { | 2563 | { |
2560 | newEvent(fh, | 2564 | newEvent(fh, |
2561 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2565 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2562 | } | 2566 | } |
2563 | 2567 | ||
2564 | void CalendarView::newEvent(QDate dt) | 2568 | void CalendarView::newEvent(QDate dt) |
2565 | { | 2569 | { |
2566 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2570 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2567 | QDateTime(dt, QTime(0,0,0)), true); | 2571 | QDateTime(dt, QTime(0,0,0)), true); |
2568 | } | 2572 | } |
2569 | 2573 | ||
2570 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2574 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2571 | { | 2575 | { |
2572 | 2576 | ||
2573 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2577 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2574 | if ( mFilterView->filtersEnabled() ) { | 2578 | if ( mFilterView->filtersEnabled() ) { |
2575 | CalFilter *filter = mFilterView->selectedFilter(); | 2579 | CalFilter *filter = mFilterView->selectedFilter(); |
2576 | if (filter && filter->showCategories()) { | 2580 | if (filter && filter->showCategories()) { |
2577 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2581 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2578 | } | 2582 | } |
2579 | if ( filter ) | 2583 | if ( filter ) |
2580 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2584 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2581 | } | 2585 | } |
2582 | showEventEditor(); | 2586 | showEventEditor(); |
2583 | } | 2587 | } |
2584 | void CalendarView::todoAdded(Todo * t) | 2588 | void CalendarView::todoAdded(Todo * t) |
2585 | { | 2589 | { |
2586 | 2590 | ||
2587 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2591 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2588 | updateTodoViews(); | 2592 | updateTodoViews(); |
2589 | } | 2593 | } |
2590 | void CalendarView::todoChanged(Todo * t) | 2594 | void CalendarView::todoChanged(Todo * t) |
2591 | { | 2595 | { |
2592 | emit todoModified( t, 4 ); | 2596 | emit todoModified( t, 4 ); |
2593 | // updateTodoViews(); | 2597 | // updateTodoViews(); |
2594 | } | 2598 | } |
2595 | void CalendarView::todoToBeDeleted(Todo *) | 2599 | void CalendarView::todoToBeDeleted(Todo *) |
2596 | { | 2600 | { |
2597 | //qDebug("todoToBeDeleted(Todo *) "); | 2601 | //qDebug("todoToBeDeleted(Todo *) "); |
2598 | updateTodoViews(); | 2602 | updateTodoViews(); |
2599 | } | 2603 | } |
2600 | void CalendarView::todoDeleted() | 2604 | void CalendarView::todoDeleted() |
2601 | { | 2605 | { |
2602 | //qDebug(" todoDeleted()"); | 2606 | //qDebug(" todoDeleted()"); |
2603 | updateTodoViews(); | 2607 | updateTodoViews(); |
2604 | } | 2608 | } |
2605 | 2609 | ||
2606 | 2610 | ||
2607 | 2611 | ||
2608 | void CalendarView::newTodo() | 2612 | void CalendarView::newTodo() |
2609 | { | 2613 | { |
2610 | 2614 | ||
2611 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2615 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2612 | if ( mFilterView->filtersEnabled() ) { | 2616 | if ( mFilterView->filtersEnabled() ) { |
2613 | CalFilter *filter = mFilterView->selectedFilter(); | 2617 | CalFilter *filter = mFilterView->selectedFilter(); |
2614 | if (filter && filter->showCategories()) { | 2618 | if (filter && filter->showCategories()) { |
2615 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2619 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2616 | } | 2620 | } |
2617 | if ( filter ) | 2621 | if ( filter ) |
2618 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2622 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2619 | } | 2623 | } |
2620 | showTodoEditor(); | 2624 | showTodoEditor(); |
2621 | } | 2625 | } |
2622 | 2626 | ||
2623 | void CalendarView::newSubTodo() | 2627 | void CalendarView::newSubTodo() |
2624 | { | 2628 | { |
2625 | Todo *todo = selectedTodo(); | 2629 | Todo *todo = selectedTodo(); |
2626 | if ( todo ) newSubTodo( todo ); | 2630 | if ( todo ) newSubTodo( todo ); |
2627 | } | 2631 | } |
2628 | 2632 | ||
2629 | void CalendarView::newSubTodo(Todo *parentEvent) | 2633 | void CalendarView::newSubTodo(Todo *parentEvent) |
2630 | { | 2634 | { |
2631 | 2635 | ||
2632 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2636 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2633 | showTodoEditor(); | 2637 | showTodoEditor(); |
2634 | } | 2638 | } |
2635 | 2639 | ||
2636 | void CalendarView::newFloatingEvent() | 2640 | void CalendarView::newFloatingEvent() |
2637 | { | 2641 | { |
2638 | DateList tmpList = mNavigator->selectedDates(); | 2642 | DateList tmpList = mNavigator->selectedDates(); |
2639 | QDate date = tmpList.first(); | 2643 | QDate date = tmpList.first(); |
2640 | 2644 | ||
2641 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2645 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2642 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2646 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2643 | } | 2647 | } |
2644 | 2648 | ||
2645 | 2649 | ||
2646 | void CalendarView::editEvent( Event *event ) | 2650 | void CalendarView::editEvent( Event *event ) |
2647 | { | 2651 | { |
2648 | 2652 | ||
2649 | if ( !event ) return; | 2653 | if ( !event ) return; |
2650 | if ( event->isReadOnly() ) { | 2654 | if ( event->isReadOnly() ) { |
2651 | showEvent( event ); | 2655 | showEvent( event ); |
2652 | return; | 2656 | return; |
2653 | } | 2657 | } |
2654 | mEventEditor->editEvent( event , mFlagEditDescription); | 2658 | mEventEditor->editEvent( event , mFlagEditDescription); |
2655 | showEventEditor(); | 2659 | showEventEditor(); |
2656 | } | 2660 | } |
2657 | void CalendarView::editJournal( Journal *jour ) | 2661 | void CalendarView::editJournal( Journal *jour ) |
2658 | { | 2662 | { |
2659 | if ( !jour ) return; | 2663 | if ( !jour ) return; |
2660 | mDialogManager->hideSearchDialog(); | 2664 | mDialogManager->hideSearchDialog(); |
2661 | mViewManager->showJournalView(); | 2665 | mViewManager->showJournalView(); |
2662 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2666 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2663 | } | 2667 | } |
2664 | void CalendarView::editTodo( Todo *todo ) | 2668 | void CalendarView::editTodo( Todo *todo ) |
2665 | { | 2669 | { |
2666 | if ( !todo ) return; | 2670 | if ( !todo ) return; |
2667 | 2671 | ||
2668 | if ( todo->isReadOnly() ) { | 2672 | if ( todo->isReadOnly() ) { |
2669 | showTodo( todo ); | 2673 | showTodo( todo ); |
2670 | return; | 2674 | return; |
2671 | } | 2675 | } |
2672 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2676 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2673 | showTodoEditor(); | 2677 | showTodoEditor(); |
2674 | 2678 | ||
2675 | } | 2679 | } |
2676 | 2680 | ||
2677 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2681 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2678 | { | 2682 | { |
2679 | if ( !mEventViewerDialog ) { | 2683 | if ( !mEventViewerDialog ) { |
2680 | mEventViewerDialog = new KOEventViewerDialog(this); | 2684 | mEventViewerDialog = new KOEventViewerDialog(this); |
2681 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2685 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2682 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2686 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2683 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2687 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2684 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2688 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2685 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2689 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2686 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2690 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2687 | mEventViewerDialog->resize( 640, 480 ); | 2691 | mEventViewerDialog->resize( 640, 480 ); |
2688 | 2692 | ||
2689 | } | 2693 | } |
2690 | return mEventViewerDialog; | 2694 | return mEventViewerDialog; |
2691 | } | 2695 | } |
2692 | void CalendarView::showEvent(Event *event) | 2696 | void CalendarView::showEvent(Event *event) |
2693 | { | 2697 | { |
2694 | getEventViewerDialog()->setEvent(event); | 2698 | getEventViewerDialog()->setEvent(event); |
2695 | getEventViewerDialog()->showMe(); | 2699 | getEventViewerDialog()->showMe(); |
2696 | } | 2700 | } |
2697 | 2701 | ||
2698 | void CalendarView::showTodo(Todo *event) | 2702 | void CalendarView::showTodo(Todo *event) |
2699 | { | 2703 | { |
2700 | getEventViewerDialog()->setTodo(event); | 2704 | getEventViewerDialog()->setTodo(event); |
2701 | getEventViewerDialog()->showMe(); | 2705 | getEventViewerDialog()->showMe(); |
2702 | } | 2706 | } |
2703 | void CalendarView::showJournal( Journal *jour ) | 2707 | void CalendarView::showJournal( Journal *jour ) |
2704 | { | 2708 | { |
2705 | getEventViewerDialog()->setJournal(jour); | 2709 | getEventViewerDialog()->setJournal(jour); |
2706 | getEventViewerDialog()->showMe(); | 2710 | getEventViewerDialog()->showMe(); |
2707 | 2711 | ||
2708 | } | 2712 | } |
2709 | // void CalendarView::todoModified (Todo *event, int changed) | 2713 | // void CalendarView::todoModified (Todo *event, int changed) |
2710 | // { | 2714 | // { |
2711 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2715 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2712 | // // kdDebug() << "Todo modified and open" << endl; | 2716 | // // kdDebug() << "Todo modified and open" << endl; |
2713 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2717 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2714 | // // temp->modified (changed); | 2718 | // // temp->modified (changed); |
2715 | 2719 | ||
2716 | // // } | 2720 | // // } |
2717 | 2721 | ||
2718 | // mViewManager->updateView(); | 2722 | // mViewManager->updateView(); |
2719 | // } | 2723 | // } |
2720 | 2724 | ||
2721 | void CalendarView::appointment_show() | 2725 | void CalendarView::appointment_show() |
2722 | { | 2726 | { |
2723 | Event *anEvent = 0; | 2727 | Event *anEvent = 0; |
2724 | 2728 | ||
2725 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2729 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2726 | 2730 | ||
2727 | if (mViewManager->currentView()->isEventView()) { | 2731 | if (mViewManager->currentView()->isEventView()) { |
2728 | if ( incidence && incidence->type() == "Event" ) { | 2732 | if ( incidence && incidence->type() == "Event" ) { |
2729 | anEvent = static_cast<Event *>(incidence); | 2733 | anEvent = static_cast<Event *>(incidence); |
2730 | } | 2734 | } |
2731 | } | 2735 | } |
2732 | 2736 | ||
2733 | if (!anEvent) { | 2737 | if (!anEvent) { |
2734 | KNotifyClient::beep(); | 2738 | KNotifyClient::beep(); |
2735 | return; | 2739 | return; |
2736 | } | 2740 | } |
2737 | 2741 | ||
2738 | showEvent(anEvent); | 2742 | showEvent(anEvent); |
2739 | } | 2743 | } |
2740 | 2744 | ||
2741 | void CalendarView::appointment_edit() | 2745 | void CalendarView::appointment_edit() |
2742 | { | 2746 | { |
2743 | Event *anEvent = 0; | 2747 | Event *anEvent = 0; |
2744 | 2748 | ||
2745 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2749 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2746 | 2750 | ||
2747 | if (mViewManager->currentView()->isEventView()) { | 2751 | if (mViewManager->currentView()->isEventView()) { |
2748 | if ( incidence && incidence->type() == "Event" ) { | 2752 | if ( incidence && incidence->type() == "Event" ) { |
2749 | anEvent = static_cast<Event *>(incidence); | 2753 | anEvent = static_cast<Event *>(incidence); |
2750 | } | 2754 | } |
2751 | } | 2755 | } |
2752 | 2756 | ||
2753 | if (!anEvent) { | 2757 | if (!anEvent) { |
2754 | KNotifyClient::beep(); | 2758 | KNotifyClient::beep(); |
2755 | return; | 2759 | return; |
2756 | } | 2760 | } |
2757 | 2761 | ||
2758 | editEvent(anEvent); | 2762 | editEvent(anEvent); |
2759 | } | 2763 | } |
2760 | 2764 | ||
2761 | void CalendarView::appointment_delete() | 2765 | void CalendarView::appointment_delete() |
2762 | { | 2766 | { |
2763 | Event *anEvent = 0; | 2767 | Event *anEvent = 0; |
2764 | 2768 | ||
2765 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2769 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2766 | 2770 | ||
2767 | if (mViewManager->currentView()->isEventView()) { | 2771 | if (mViewManager->currentView()->isEventView()) { |
2768 | if ( incidence && incidence->type() == "Event" ) { | 2772 | if ( incidence && incidence->type() == "Event" ) { |
2769 | anEvent = static_cast<Event *>(incidence); | 2773 | anEvent = static_cast<Event *>(incidence); |
2770 | } | 2774 | } |
2771 | } | 2775 | } |
2772 | 2776 | ||
2773 | if (!anEvent) { | 2777 | if (!anEvent) { |
2774 | KNotifyClient::beep(); | 2778 | KNotifyClient::beep(); |
2775 | return; | 2779 | return; |
2776 | } | 2780 | } |
2777 | 2781 | ||
2778 | deleteEvent(anEvent); | 2782 | deleteEvent(anEvent); |
2779 | } | 2783 | } |
2780 | 2784 | ||
2781 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2785 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2782 | { | 2786 | { |
2783 | if (!sub) return; | 2787 | if (!sub) return; |
2784 | if (!parent) return; | 2788 | if (!parent) return; |
2785 | if ( sub->relatedTo() ) | 2789 | if ( sub->relatedTo() ) |
2786 | sub->relatedTo()->removeRelation(sub); | 2790 | sub->relatedTo()->removeRelation(sub); |
2787 | sub->setRelatedTo(parent); | 2791 | sub->setRelatedTo(parent); |
2788 | sub->setRelatedToUid(parent->uid()); | 2792 | sub->setRelatedToUid(parent->uid()); |
2789 | parent->addRelation(sub); | 2793 | parent->addRelation(sub); |
2790 | sub->updated(); | 2794 | sub->updated(); |
2791 | parent->updated(); | 2795 | parent->updated(); |
2792 | setModified(true); | 2796 | setModified(true); |
2793 | updateView(); | 2797 | updateView(); |
2794 | } | 2798 | } |
2795 | void CalendarView::todo_unsub(Todo *anTodo ) | 2799 | void CalendarView::todo_unsub(Todo *anTodo ) |
2796 | { | 2800 | { |
2797 | // Todo *anTodo = selectedTodo(); | 2801 | // Todo *anTodo = selectedTodo(); |
2798 | if (!anTodo) return; | 2802 | if (!anTodo) return; |
2799 | if (!anTodo->relatedTo()) return; | 2803 | if (!anTodo->relatedTo()) return; |
2800 | anTodo->relatedTo()->removeRelation(anTodo); | 2804 | anTodo->relatedTo()->removeRelation(anTodo); |
2801 | anTodo->setRelatedTo(0); | 2805 | anTodo->setRelatedTo(0); |
2802 | anTodo->updated(); | 2806 | anTodo->updated(); |
2803 | anTodo->setRelatedToUid(""); | 2807 | anTodo->setRelatedToUid(""); |
2804 | setModified(true); | 2808 | setModified(true); |
2805 | updateView(); | 2809 | updateView(); |
2806 | } | 2810 | } |
2807 | 2811 | ||
2808 | void CalendarView::deleteTodo(Todo *todo) | 2812 | void CalendarView::deleteTodo(Todo *todo) |
2809 | { | 2813 | { |
2810 | if (!todo) { | 2814 | if (!todo) { |
2811 | KNotifyClient::beep(); | 2815 | KNotifyClient::beep(); |
2812 | return; | 2816 | return; |
2813 | } | 2817 | } |
2814 | if (KOPrefs::instance()->mConfirm) { | 2818 | if (KOPrefs::instance()->mConfirm) { |
2815 | switch (msgItemDelete()) { | 2819 | switch (msgItemDelete()) { |
2816 | case KMessageBox::Continue: // OK | 2820 | case KMessageBox::Continue: // OK |
2817 | if (!todo->relations().isEmpty()) { | 2821 | if (!todo->relations().isEmpty()) { |
2818 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2822 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2819 | i18n("Delete To-Do")); | 2823 | i18n("Delete To-Do")); |
2820 | } else { | 2824 | } else { |
2821 | checkExternalId( todo ); | 2825 | checkExternalId( todo ); |
2822 | calendar()->deleteTodo(todo); | 2826 | calendar()->deleteTodo(todo); |
2823 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2827 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2824 | updateView(); | 2828 | updateView(); |
2825 | } | 2829 | } |
2826 | break; | 2830 | break; |
2827 | } // switch | 2831 | } // switch |
2828 | } else { | 2832 | } else { |
2829 | if (!todo->relations().isEmpty()) { | 2833 | if (!todo->relations().isEmpty()) { |
2830 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2834 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2831 | i18n("Delete To-Do")); | 2835 | i18n("Delete To-Do")); |
2832 | } else { | 2836 | } else { |
2833 | checkExternalId( todo ); | 2837 | checkExternalId( todo ); |
2834 | mCalendar->deleteTodo(todo); | 2838 | mCalendar->deleteTodo(todo); |
2835 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2839 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2836 | updateView(); | 2840 | updateView(); |
2837 | } | 2841 | } |
2838 | } | 2842 | } |
2839 | emit updateSearchDialog(); | 2843 | emit updateSearchDialog(); |
2840 | } | 2844 | } |
2841 | void CalendarView::deleteJournal(Journal *jour) | 2845 | void CalendarView::deleteJournal(Journal *jour) |
2842 | { | 2846 | { |
2843 | if (!jour) { | 2847 | if (!jour) { |
2844 | KNotifyClient::beep(); | 2848 | KNotifyClient::beep(); |
2845 | return; | 2849 | return; |
2846 | } | 2850 | } |
2847 | if (KOPrefs::instance()->mConfirm) { | 2851 | if (KOPrefs::instance()->mConfirm) { |
2848 | switch (msgItemDelete()) { | 2852 | switch (msgItemDelete()) { |
2849 | case KMessageBox::Continue: // OK | 2853 | case KMessageBox::Continue: // OK |
2850 | calendar()->deleteJournal(jour); | 2854 | calendar()->deleteJournal(jour); |
2851 | updateView(); | 2855 | updateView(); |
2852 | break; | 2856 | break; |
2853 | } // switch | 2857 | } // switch |
2854 | } else { | 2858 | } else { |
2855 | calendar()->deleteJournal(jour);; | 2859 | calendar()->deleteJournal(jour);; |
2856 | updateView(); | 2860 | updateView(); |
2857 | } | 2861 | } |
2858 | emit updateSearchDialog(); | 2862 | emit updateSearchDialog(); |
2859 | } | 2863 | } |
2860 | 2864 | ||
2861 | void CalendarView::deleteEvent(Event *anEvent) | 2865 | void CalendarView::deleteEvent(Event *anEvent) |
2862 | { | 2866 | { |
2863 | if (!anEvent) { | 2867 | if (!anEvent) { |
2864 | KNotifyClient::beep(); | 2868 | KNotifyClient::beep(); |
2865 | return; | 2869 | return; |
2866 | } | 2870 | } |
2867 | 2871 | ||
2868 | if (anEvent->recurrence()->doesRecur()) { | 2872 | if (anEvent->recurrence()->doesRecur()) { |
2869 | QDate itemDate = mViewManager->currentSelectionDate(); | 2873 | QDate itemDate = mViewManager->currentSelectionDate(); |
2870 | int km; | 2874 | int km; |
2871 | if (!itemDate.isValid()) { | 2875 | if (!itemDate.isValid()) { |
2872 | //kdDebug() << "Date Not Valid" << endl; | 2876 | //kdDebug() << "Date Not Valid" << endl; |
2873 | if (KOPrefs::instance()->mConfirm) { | 2877 | if (KOPrefs::instance()->mConfirm) { |
2874 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2878 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2875 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2879 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2876 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2880 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2877 | if ( km == KMessageBox::Continue ) | 2881 | if ( km == KMessageBox::Continue ) |
2878 | km = KMessageBox::No; // No = all below | 2882 | km = KMessageBox::No; // No = all below |
2879 | } else | 2883 | } else |
2880 | km = KMessageBox::No; | 2884 | km = KMessageBox::No; |
2881 | } else { | 2885 | } else { |
2882 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2886 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2883 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2887 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2884 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2888 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2885 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2889 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2886 | i18n("All")); | 2890 | i18n("All")); |
2887 | } | 2891 | } |
2888 | switch(km) { | 2892 | switch(km) { |
2889 | 2893 | ||
2890 | case KMessageBox::No: // Continue // all | 2894 | case KMessageBox::No: // Continue // all |
2891 | //qDebug("KMessageBox::No "); | 2895 | //qDebug("KMessageBox::No "); |
2892 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2896 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2893 | schedule(Scheduler::Cancel,anEvent); | 2897 | schedule(Scheduler::Cancel,anEvent); |
2894 | 2898 | ||
2895 | checkExternalId( anEvent); | 2899 | checkExternalId( anEvent); |
2896 | mCalendar->deleteEvent(anEvent); | 2900 | mCalendar->deleteEvent(anEvent); |
2897 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2901 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2898 | break; | 2902 | break; |
2899 | 2903 | ||
2900 | // Disabled because it does not work | 2904 | // Disabled because it does not work |
2901 | //#if 0 | 2905 | //#if 0 |
2902 | case KMessageBox::Yes: // just this one | 2906 | case KMessageBox::Yes: // just this one |
2903 | //QDate qd = mNavigator->selectedDates().first(); | 2907 | //QDate qd = mNavigator->selectedDates().first(); |
2904 | //if (!qd.isValid()) { | 2908 | //if (!qd.isValid()) { |
2905 | // kdDebug() << "no date selected, or invalid date" << endl; | 2909 | // kdDebug() << "no date selected, or invalid date" << endl; |
2906 | // KNotifyClient::beep(); | 2910 | // KNotifyClient::beep(); |
2907 | // return; | 2911 | // return; |
2908 | //} | 2912 | //} |
2909 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2913 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2910 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2914 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2911 | anEvent->addExDate(itemDate); | 2915 | anEvent->addExDate(itemDate); |
2912 | int duration = anEvent->recurrence()->duration(); | 2916 | int duration = anEvent->recurrence()->duration(); |
2913 | if ( duration > 0 ) { | 2917 | if ( duration > 0 ) { |
2914 | anEvent->recurrence()->setDuration( duration - 1 ); | 2918 | anEvent->recurrence()->setDuration( duration - 1 ); |
2915 | } | 2919 | } |
2916 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2920 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2917 | } | 2921 | } |
2918 | break; | 2922 | break; |
2919 | //#endif | 2923 | //#endif |
2920 | } // switch | 2924 | } // switch |
2921 | } else { | 2925 | } else { |
2922 | if (KOPrefs::instance()->mConfirm) { | 2926 | if (KOPrefs::instance()->mConfirm) { |
2923 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2927 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2924 | i18n("\nAre you sure you want\nto delete this event?"), | 2928 | i18n("\nAre you sure you want\nto delete this event?"), |
2925 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2929 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2926 | case KMessageBox::Continue: // OK | 2930 | case KMessageBox::Continue: // OK |
2927 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2931 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2928 | schedule(Scheduler::Cancel,anEvent); | 2932 | schedule(Scheduler::Cancel,anEvent); |
2929 | checkExternalId( anEvent); | 2933 | checkExternalId( anEvent); |
2930 | mCalendar->deleteEvent(anEvent); | 2934 | mCalendar->deleteEvent(anEvent); |
2931 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2935 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2932 | break; | 2936 | break; |
2933 | } // switch | 2937 | } // switch |
2934 | } else { | 2938 | } else { |
2935 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2939 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2936 | schedule(Scheduler::Cancel,anEvent); | 2940 | schedule(Scheduler::Cancel,anEvent); |
2937 | checkExternalId( anEvent); | 2941 | checkExternalId( anEvent); |
2938 | mCalendar->deleteEvent(anEvent); | 2942 | mCalendar->deleteEvent(anEvent); |
2939 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2943 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2940 | } | 2944 | } |
2941 | } // if-else | 2945 | } // if-else |
2942 | emit updateSearchDialog(); | 2946 | emit updateSearchDialog(); |
2943 | } | 2947 | } |
2944 | 2948 | ||
2945 | bool CalendarView::deleteEvent(const QString &uid) | 2949 | bool CalendarView::deleteEvent(const QString &uid) |
2946 | { | 2950 | { |
2947 | Event *ev = mCalendar->event(uid); | 2951 | Event *ev = mCalendar->event(uid); |
2948 | if (ev) { | 2952 | if (ev) { |
2949 | deleteEvent(ev); | 2953 | deleteEvent(ev); |
2950 | return true; | 2954 | return true; |
2951 | } else { | 2955 | } else { |
2952 | return false; | 2956 | return false; |
2953 | } | 2957 | } |
2954 | } | 2958 | } |
2955 | 2959 | ||
2956 | /*****************************************************************************/ | 2960 | /*****************************************************************************/ |
2957 | 2961 | ||
2958 | void CalendarView::action_mail() | 2962 | void CalendarView::action_mail() |
2959 | { | 2963 | { |
2960 | #ifndef KORG_NOMAIL | 2964 | #ifndef KORG_NOMAIL |
2961 | KOMailClient mailClient; | 2965 | KOMailClient mailClient; |
2962 | 2966 | ||
2963 | Incidence *incidence = currentSelection(); | 2967 | Incidence *incidence = currentSelection(); |
2964 | 2968 | ||
2965 | if (!incidence) { | 2969 | if (!incidence) { |
2966 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2970 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2967 | return; | 2971 | return; |
2968 | } | 2972 | } |
2969 | if(incidence->attendeeCount() == 0 ) { | 2973 | if(incidence->attendeeCount() == 0 ) { |
2970 | KMessageBox::sorry(this, | 2974 | KMessageBox::sorry(this, |
2971 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2975 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2972 | return; | 2976 | return; |
2973 | } | 2977 | } |
2974 | 2978 | ||
2975 | CalendarLocal cal_tmp; | 2979 | CalendarLocal cal_tmp; |
2976 | Event *event = 0; | 2980 | Event *event = 0; |
2977 | Event *ev = 0; | 2981 | Event *ev = 0; |
2978 | if ( incidence && incidence->type() == "Event" ) { | 2982 | if ( incidence && incidence->type() == "Event" ) { |
2979 | event = static_cast<Event *>(incidence); | 2983 | event = static_cast<Event *>(incidence); |
2980 | ev = new Event(*event); | 2984 | ev = new Event(*event); |
2981 | cal_tmp.addEvent(ev); | 2985 | cal_tmp.addEvent(ev); |
2982 | } | 2986 | } |
2983 | ICalFormat mForm(); | 2987 | ICalFormat mForm(); |
2984 | QString attachment = mForm.toString( &cal_tmp ); | 2988 | QString attachment = mForm.toString( &cal_tmp ); |
2985 | if (ev) delete(ev); | 2989 | if (ev) delete(ev); |
2986 | 2990 | ||
2987 | mailClient.mailAttendees(currentSelection(), attachment); | 2991 | mailClient.mailAttendees(currentSelection(), attachment); |
2988 | 2992 | ||
2989 | #endif | 2993 | #endif |
2990 | 2994 | ||
2991 | #if 0 | 2995 | #if 0 |
2992 | Event *anEvent = 0; | 2996 | Event *anEvent = 0; |
2993 | if (mViewManager->currentView()->isEventView()) { | 2997 | if (mViewManager->currentView()->isEventView()) { |
2994 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2998 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2995 | } | 2999 | } |
2996 | 3000 | ||
2997 | if (!anEvent) { | 3001 | if (!anEvent) { |
2998 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3002 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2999 | return; | 3003 | return; |
3000 | } | 3004 | } |
3001 | if(anEvent->attendeeCount() == 0 ) { | 3005 | if(anEvent->attendeeCount() == 0 ) { |
3002 | KMessageBox::sorry(this, | 3006 | KMessageBox::sorry(this, |
3003 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3007 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3004 | return; | 3008 | return; |
3005 | } | 3009 | } |
3006 | 3010 | ||
3007 | mailobject.emailEvent(anEvent); | 3011 | mailobject.emailEvent(anEvent); |
3008 | #endif | 3012 | #endif |
3009 | } | 3013 | } |
3010 | 3014 | ||
3011 | 3015 | ||
3012 | void CalendarView::schedule_publish(Incidence *incidence) | 3016 | void CalendarView::schedule_publish(Incidence *incidence) |
3013 | { | 3017 | { |
3014 | Event *event = 0; | 3018 | Event *event = 0; |
3015 | Todo *todo = 0; | 3019 | Todo *todo = 0; |
3016 | 3020 | ||
3017 | if (incidence == 0) { | 3021 | if (incidence == 0) { |
3018 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3022 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3019 | if (incidence == 0) { | 3023 | if (incidence == 0) { |
3020 | incidence = mTodoList->selectedIncidences().first(); | 3024 | incidence = mTodoList->selectedIncidences().first(); |
3021 | } | 3025 | } |
3022 | } | 3026 | } |
3023 | if ( incidence && incidence->type() == "Event" ) { | 3027 | if ( incidence && incidence->type() == "Event" ) { |
3024 | event = static_cast<Event *>(incidence); | 3028 | event = static_cast<Event *>(incidence); |
3025 | } else { | 3029 | } else { |
3026 | if ( incidence && incidence->type() == "Todo" ) { | 3030 | if ( incidence && incidence->type() == "Todo" ) { |
3027 | todo = static_cast<Todo *>(incidence); | 3031 | todo = static_cast<Todo *>(incidence); |
3028 | } | 3032 | } |
3029 | } | 3033 | } |
3030 | 3034 | ||
3031 | if (!event && !todo) { | 3035 | if (!event && !todo) { |
3032 | KMessageBox::sorry(this,i18n("No event selected.")); | 3036 | KMessageBox::sorry(this,i18n("No event selected.")); |
3033 | return; | 3037 | return; |
3034 | } | 3038 | } |
3035 | 3039 | ||
3036 | PublishDialog *publishdlg = new PublishDialog(); | 3040 | PublishDialog *publishdlg = new PublishDialog(); |
3037 | if (incidence->attendeeCount()>0) { | 3041 | if (incidence->attendeeCount()>0) { |
3038 | QPtrList<Attendee> attendees = incidence->attendees(); | 3042 | QPtrList<Attendee> attendees = incidence->attendees(); |
3039 | attendees.first(); | 3043 | attendees.first(); |
3040 | while ( attendees.current()!=0 ) { | 3044 | while ( attendees.current()!=0 ) { |
3041 | publishdlg->addAttendee(attendees.current()); | 3045 | publishdlg->addAttendee(attendees.current()); |
3042 | attendees.next(); | 3046 | attendees.next(); |
3043 | } | 3047 | } |
3044 | } | 3048 | } |
3045 | bool send = true; | 3049 | bool send = true; |
3046 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3050 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3047 | if ( publishdlg->exec() != QDialog::Accepted ) | 3051 | if ( publishdlg->exec() != QDialog::Accepted ) |
3048 | send = false; | 3052 | send = false; |
3049 | } | 3053 | } |
3050 | if ( send ) { | 3054 | if ( send ) { |
3051 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3055 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3052 | if ( event ) { | 3056 | if ( event ) { |
3053 | Event *ev = new Event(*event); | 3057 | Event *ev = new Event(*event); |
3054 | ev->registerObserver(0); | 3058 | ev->registerObserver(0); |
3055 | ev->clearAttendees(); | 3059 | ev->clearAttendees(); |
3056 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3060 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3057 | delete(ev); | 3061 | delete(ev); |
3058 | } | 3062 | } |
3059 | } else { | 3063 | } else { |
3060 | if ( todo ) { | 3064 | if ( todo ) { |
3061 | Todo *ev = new Todo(*todo); | 3065 | Todo *ev = new Todo(*todo); |
3062 | ev->registerObserver(0); | 3066 | ev->registerObserver(0); |
3063 | ev->clearAttendees(); | 3067 | ev->clearAttendees(); |
3064 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3068 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3065 | delete(ev); | 3069 | delete(ev); |
3066 | } | 3070 | } |
3067 | } | 3071 | } |
3068 | } | 3072 | } |
3069 | } | 3073 | } |
3070 | delete publishdlg; | 3074 | delete publishdlg; |
3071 | } | 3075 | } |
3072 | 3076 | ||
3073 | void CalendarView::schedule_request(Incidence *incidence) | 3077 | void CalendarView::schedule_request(Incidence *incidence) |
3074 | { | 3078 | { |
3075 | schedule(Scheduler::Request,incidence); | 3079 | schedule(Scheduler::Request,incidence); |
3076 | } | 3080 | } |
3077 | 3081 | ||
3078 | void CalendarView::schedule_refresh(Incidence *incidence) | 3082 | void CalendarView::schedule_refresh(Incidence *incidence) |
3079 | { | 3083 | { |
3080 | schedule(Scheduler::Refresh,incidence); | 3084 | schedule(Scheduler::Refresh,incidence); |
3081 | } | 3085 | } |
3082 | 3086 | ||
3083 | void CalendarView::schedule_cancel(Incidence *incidence) | 3087 | void CalendarView::schedule_cancel(Incidence *incidence) |
3084 | { | 3088 | { |
3085 | schedule(Scheduler::Cancel,incidence); | 3089 | schedule(Scheduler::Cancel,incidence); |
3086 | } | 3090 | } |
3087 | 3091 | ||
3088 | void CalendarView::schedule_add(Incidence *incidence) | 3092 | void CalendarView::schedule_add(Incidence *incidence) |
3089 | { | 3093 | { |
3090 | schedule(Scheduler::Add,incidence); | 3094 | schedule(Scheduler::Add,incidence); |
3091 | } | 3095 | } |
3092 | 3096 | ||
3093 | void CalendarView::schedule_reply(Incidence *incidence) | 3097 | void CalendarView::schedule_reply(Incidence *incidence) |
3094 | { | 3098 | { |
3095 | schedule(Scheduler::Reply,incidence); | 3099 | schedule(Scheduler::Reply,incidence); |
3096 | } | 3100 | } |
3097 | 3101 | ||
3098 | void CalendarView::schedule_counter(Incidence *incidence) | 3102 | void CalendarView::schedule_counter(Incidence *incidence) |
3099 | { | 3103 | { |
3100 | schedule(Scheduler::Counter,incidence); | 3104 | schedule(Scheduler::Counter,incidence); |
3101 | } | 3105 | } |
3102 | 3106 | ||
3103 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3107 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3104 | { | 3108 | { |
3105 | schedule(Scheduler::Declinecounter,incidence); | 3109 | schedule(Scheduler::Declinecounter,incidence); |
3106 | } | 3110 | } |
3107 | 3111 | ||
3108 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3112 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3109 | { | 3113 | { |
3110 | QDateTime start = QDateTime::currentDateTime(); | 3114 | QDateTime start = QDateTime::currentDateTime(); |
3111 | QDateTime end = start.addDays(daysToPublish); | 3115 | QDateTime end = start.addDays(daysToPublish); |
3112 | 3116 | ||
3113 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3117 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3114 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3118 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3115 | 3119 | ||
3116 | 3120 | ||
3117 | PublishDialog *publishdlg = new PublishDialog(); | 3121 | PublishDialog *publishdlg = new PublishDialog(); |
3118 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3122 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3119 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3123 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3120 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3124 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3121 | delete(freebusy); | 3125 | delete(freebusy); |
3122 | } | 3126 | } |
3123 | } | 3127 | } |
3124 | delete publishdlg; | 3128 | delete publishdlg; |
3125 | } | 3129 | } |
3126 | 3130 | ||
3127 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3131 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3128 | { | 3132 | { |
3129 | Event *event = 0; | 3133 | Event *event = 0; |
3130 | Todo *todo = 0; | 3134 | Todo *todo = 0; |
3131 | 3135 | ||
3132 | if (incidence == 0) { | 3136 | if (incidence == 0) { |
3133 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3137 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3134 | if (incidence == 0) { | 3138 | if (incidence == 0) { |
3135 | incidence = mTodoList->selectedIncidences().first(); | 3139 | incidence = mTodoList->selectedIncidences().first(); |
3136 | } | 3140 | } |
3137 | } | 3141 | } |
3138 | if ( incidence && incidence->type() == "Event" ) { | 3142 | if ( incidence && incidence->type() == "Event" ) { |
3139 | event = static_cast<Event *>(incidence); | 3143 | event = static_cast<Event *>(incidence); |
3140 | } | 3144 | } |
3141 | if ( incidence && incidence->type() == "Todo" ) { | 3145 | if ( incidence && incidence->type() == "Todo" ) { |
3142 | todo = static_cast<Todo *>(incidence); | 3146 | todo = static_cast<Todo *>(incidence); |
3143 | } | 3147 | } |
3144 | 3148 | ||
3145 | if (!event && !todo) { | 3149 | if (!event && !todo) { |
3146 | KMessageBox::sorry(this,i18n("No event selected.")); | 3150 | KMessageBox::sorry(this,i18n("No event selected.")); |
3147 | return; | 3151 | return; |
3148 | } | 3152 | } |
3149 | 3153 | ||
3150 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3154 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3151 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3155 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3152 | return; | 3156 | return; |
3153 | } | 3157 | } |
3154 | 3158 | ||
3155 | Event *ev = 0; | 3159 | Event *ev = 0; |
3156 | if (event) ev = new Event(*event); | 3160 | if (event) ev = new Event(*event); |
3157 | Todo *to = 0; | 3161 | Todo *to = 0; |
3158 | if (todo) to = new Todo(*todo); | 3162 | if (todo) to = new Todo(*todo); |
3159 | 3163 | ||
3160 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3164 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3161 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3165 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3162 | if (!me) { | 3166 | if (!me) { |
3163 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3167 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3164 | return; | 3168 | return; |
3165 | } | 3169 | } |
3166 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3170 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3167 | StatusDialog *statdlg = new StatusDialog(this); | 3171 | StatusDialog *statdlg = new StatusDialog(this); |
3168 | if (!statdlg->exec()==QDialog::Accepted) return; | 3172 | if (!statdlg->exec()==QDialog::Accepted) return; |
3169 | me->setStatus( statdlg->status() ); | 3173 | me->setStatus( statdlg->status() ); |
3170 | delete(statdlg); | 3174 | delete(statdlg); |
3171 | } | 3175 | } |
3172 | Attendee *menew = new Attendee(*me); | 3176 | Attendee *menew = new Attendee(*me); |
3173 | if (ev) { | 3177 | if (ev) { |
3174 | ev->clearAttendees(); | 3178 | ev->clearAttendees(); |
3175 | ev->addAttendee(menew,false); | 3179 | ev->addAttendee(menew,false); |
3176 | } else { | 3180 | } else { |
3177 | if (to) { | 3181 | if (to) { |
3178 | todo->clearAttendees(); | 3182 | todo->clearAttendees(); |
3179 | todo->addAttendee(menew,false); | 3183 | todo->addAttendee(menew,false); |
3180 | } | 3184 | } |
3181 | } | 3185 | } |
3182 | } | 3186 | } |
3183 | 3187 | ||
3184 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3188 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3185 | if (ev) { | 3189 | if (ev) { |
3186 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3190 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3187 | } else { | 3191 | } else { |
3188 | if (to) { | 3192 | if (to) { |
3189 | if ( !dlg->addMessage(to,method) ) delete(to); | 3193 | if ( !dlg->addMessage(to,method) ) delete(to); |
3190 | } | 3194 | } |
3191 | } | 3195 | } |
3192 | } | 3196 | } |
3193 | 3197 | ||
3194 | void CalendarView::openAddressbook() | 3198 | void CalendarView::openAddressbook() |
3195 | { | 3199 | { |
3196 | KRun::runCommand("kaddressbook"); | 3200 | KRun::runCommand("kaddressbook"); |
3197 | } | 3201 | } |
3198 | 3202 | ||
3199 | void CalendarView::setModified(bool modified) | 3203 | void CalendarView::setModified(bool modified) |
3200 | { | 3204 | { |
3201 | if ( modified ) | 3205 | if ( modified ) |
3202 | emit signalmodified(); | 3206 | emit signalmodified(); |
3203 | if (mModified != modified) { | 3207 | if (mModified != modified) { |
3204 | mModified = modified; | 3208 | mModified = modified; |
3205 | emit modifiedChanged(mModified); | 3209 | emit modifiedChanged(mModified); |
3206 | } | 3210 | } |
3207 | } | 3211 | } |
3208 | 3212 | ||
3209 | bool CalendarView::isReadOnly() | 3213 | bool CalendarView::isReadOnly() |
3210 | { | 3214 | { |
3211 | return mReadOnly; | 3215 | return mReadOnly; |
3212 | } | 3216 | } |
3213 | 3217 | ||
3214 | void CalendarView::setReadOnly(bool readOnly) | 3218 | void CalendarView::setReadOnly(bool readOnly) |
3215 | { | 3219 | { |
3216 | if (mReadOnly != readOnly) { | 3220 | if (mReadOnly != readOnly) { |
3217 | mReadOnly = readOnly; | 3221 | mReadOnly = readOnly; |
3218 | emit readOnlyChanged(mReadOnly); | 3222 | emit readOnlyChanged(mReadOnly); |
3219 | } | 3223 | } |
3220 | } | 3224 | } |
3221 | 3225 | ||
3222 | bool CalendarView::isModified() | 3226 | bool CalendarView::isModified() |
3223 | { | 3227 | { |
3224 | return mModified; | 3228 | return mModified; |
3225 | } | 3229 | } |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index a12acd1..9cafc60 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1118 +1,1119 @@ | |||
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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | 27 | ||
28 | #include <qvbox.h> | 28 | #include <qvbox.h> |
29 | #include <kdebug.h> | 29 | #include <kdebug.h> |
30 | #include "koprefs.h" | 30 | #include "koprefs.h" |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/vcaldrag.h> | 37 | #include <libkcal/vcaldrag.h> |
38 | #include <libkcal/calfilter.h> | 38 | #include <libkcal/calfilter.h> |
39 | #include <libkcal/dndfactory.h> | 39 | #include <libkcal/dndfactory.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | #include <kresources/resourceselectdialog.h> | 42 | #include <kresources/resourceselectdialog.h> |
43 | #ifndef DESKTOP_VERSION | 43 | #ifndef DESKTOP_VERSION |
44 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
45 | #else | 45 | #else |
46 | #include <qapplication.h> | 46 | #include <qapplication.h> |
47 | #endif | 47 | #endif |
48 | #ifndef KORG_NOPRINTER | 48 | #ifndef KORG_NOPRINTER |
49 | #include "calprinter.h" | 49 | #include "calprinter.h" |
50 | #endif | 50 | #endif |
51 | #include "docprefs.h" | 51 | #include "docprefs.h" |
52 | 52 | ||
53 | #include "kotodoview.h" | 53 | #include "kotodoview.h" |
54 | using namespace KOrg; | 54 | using namespace KOrg; |
55 | 55 | ||
56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
57 | const char *name) : | 57 | const char *name) : |
58 | KListView(parent,name) | 58 | KListView(parent,name) |
59 | { | 59 | { |
60 | mName = QString ( name ); | 60 | mName = QString ( name ); |
61 | mCalendar = calendar; | 61 | mCalendar = calendar; |
62 | #ifndef DESKTOP_VERSION | 62 | #ifndef DESKTOP_VERSION |
63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
64 | #endif | 64 | #endif |
65 | mOldCurrent = 0; | 65 | mOldCurrent = 0; |
66 | mMousePressed = false; | 66 | mMousePressed = false; |
67 | 67 | ||
68 | setAcceptDrops(true); | 68 | setAcceptDrops(true); |
69 | viewport()->setAcceptDrops(true); | 69 | viewport()->setAcceptDrops(true); |
70 | int size = 16; | 70 | int size = 16; |
71 | if (qApp->desktop()->width() < 300 ) | 71 | if (qApp->desktop()->width() < 300 ) |
72 | size = 12; | 72 | size = 12; |
73 | setTreeStepSize( size + 6 ); | 73 | setTreeStepSize( size + 6 ); |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
78 | { | 78 | { |
79 | #ifndef KORG_NODND | 79 | #ifndef KORG_NODND |
80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
82 | !QTextDrag::canDecode( e ) ) { | 82 | !QTextDrag::canDecode( e ) ) { |
83 | e->ignore(); | 83 | e->ignore(); |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | 86 | ||
87 | mOldCurrent = currentItem(); | 87 | mOldCurrent = currentItem(); |
88 | #endif | 88 | #endif |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
93 | { | 93 | { |
94 | #ifndef KORG_NODND | 94 | #ifndef KORG_NODND |
95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
96 | 96 | ||
97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
98 | !QTextDrag::canDecode( e ) ) { | 98 | !QTextDrag::canDecode( e ) ) { |
99 | e->ignore(); | 99 | e->ignore(); |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | 102 | ||
103 | e->accept(); | 103 | e->accept(); |
104 | #endif | 104 | #endif |
105 | } | 105 | } |
106 | 106 | ||
107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
108 | { | 108 | { |
109 | #ifndef KORG_NODND | 109 | #ifndef KORG_NODND |
110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
111 | 111 | ||
112 | setCurrentItem(mOldCurrent); | 112 | setCurrentItem(mOldCurrent); |
113 | setSelected(mOldCurrent,true); | 113 | setSelected(mOldCurrent,true); |
114 | #endif | 114 | #endif |
115 | } | 115 | } |
116 | 116 | ||
117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
118 | { | 118 | { |
119 | #ifndef KORG_NODND | 119 | #ifndef KORG_NODND |
120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
121 | 121 | ||
122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
123 | !QTextDrag::canDecode( e ) ) { | 123 | !QTextDrag::canDecode( e ) ) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | 127 | ||
128 | DndFactory factory( mCalendar ); | 128 | DndFactory factory( mCalendar ); |
129 | Todo *todo = factory.createDropTodo(e); | 129 | Todo *todo = factory.createDropTodo(e); |
130 | 130 | ||
131 | if (todo) { | 131 | if (todo) { |
132 | e->acceptAction(); | 132 | e->acceptAction(); |
133 | 133 | ||
134 | KOTodoViewItem *destination = | 134 | KOTodoViewItem *destination = |
135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
136 | Todo *destinationEvent = 0; | 136 | Todo *destinationEvent = 0; |
137 | if (destination) destinationEvent = destination->todo(); | 137 | if (destination) destinationEvent = destination->todo(); |
138 | 138 | ||
139 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 139 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
140 | 140 | ||
141 | if(existingTodo) { | 141 | if(existingTodo) { |
142 | // kdDebug() << "Drop existing Todo" << endl; | 142 | // kdDebug() << "Drop existing Todo" << endl; |
143 | Incidence *to = destinationEvent; | 143 | Incidence *to = destinationEvent; |
144 | while(to) { | 144 | while(to) { |
145 | if (to->uid() == todo->uid()) { | 145 | if (to->uid() == todo->uid()) { |
146 | KMessageBox::sorry(this, | 146 | KMessageBox::sorry(this, |
147 | i18n("Cannot move To-Do to itself or a child of itself"), | 147 | i18n("Cannot move To-Do to itself or a child of itself"), |
148 | i18n("Drop To-Do")); | 148 | i18n("Drop To-Do")); |
149 | delete todo; | 149 | delete todo; |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | to = to->relatedTo(); | 152 | to = to->relatedTo(); |
153 | } | 153 | } |
154 | existingTodo->setRelatedTo(destinationEvent); | 154 | existingTodo->setRelatedTo(destinationEvent); |
155 | emit todoDropped(todo); | 155 | emit todoDropped(todo); |
156 | delete todo; | 156 | delete todo; |
157 | } else { | 157 | } else { |
158 | // kdDebug() << "Drop new Todo" << endl; | 158 | // kdDebug() << "Drop new Todo" << endl; |
159 | todo->setRelatedTo(destinationEvent); | 159 | todo->setRelatedTo(destinationEvent); |
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | 161 | ||
162 | emit todoDropped(todo); | 162 | emit todoDropped(todo); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | else { | 165 | else { |
166 | QString text; | 166 | QString text; |
167 | if (QTextDrag::decode(e,text)) { | 167 | if (QTextDrag::decode(e,text)) { |
168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
170 | kdDebug() << "Dropped : " << text << endl; | 170 | kdDebug() << "Dropped : " << text << endl; |
171 | QStringList emails = QStringList::split(",",text); | 171 | QStringList emails = QStringList::split(",",text); |
172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
173 | kdDebug() << " Email: " << (*it) << endl; | 173 | kdDebug() << " Email: " << (*it) << endl; |
174 | int pos = (*it).find("<"); | 174 | int pos = (*it).find("<"); |
175 | QString name = (*it).left(pos); | 175 | QString name = (*it).left(pos); |
176 | QString email = (*it).mid(pos); | 176 | QString email = (*it).mid(pos); |
177 | if (!email.isEmpty() && todoi) { | 177 | if (!email.isEmpty() && todoi) { |
178 | todoi->todo()->addAttendee(new Attendee(name,email)); | 178 | todoi->todo()->addAttendee(new Attendee(name,email)); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | else { | 182 | else { |
183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; | 183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; |
184 | e->ignore(); | 184 | e->ignore(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | #endif | 187 | #endif |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
191 | { | 191 | { |
192 | QListView::contentsMousePressEvent(e); | 192 | QListView::contentsMousePressEvent(e); |
193 | #ifndef KORG_NODND | 193 | #ifndef KORG_NODND |
194 | QPoint p(contentsToViewport(e->pos())); | 194 | QPoint p(contentsToViewport(e->pos())); |
195 | QListViewItem *i = itemAt(p); | 195 | QListViewItem *i = itemAt(p); |
196 | if (i) { | 196 | if (i) { |
197 | // if the user clicked into the root decoration of the item, don't | 197 | // if the user clicked into the root decoration of the item, don't |
198 | // try to start a drag! | 198 | // try to start a drag! |
199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | 199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + |
200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
201 | itemMargin() || | 201 | itemMargin() || |
202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
203 | if (e->button()==Qt::LeftButton) { | 203 | if (e->button()==Qt::LeftButton) { |
204 | mPressPos = e->pos(); | 204 | mPressPos = e->pos(); |
205 | mMousePressed = true; | 205 | mMousePressed = true; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #endif | 209 | #endif |
210 | } | 210 | } |
211 | 211 | ||
212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
213 | { | 213 | { |
214 | 214 | ||
215 | #ifndef KORG_NODND | 215 | #ifndef KORG_NODND |
216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; | 216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; |
217 | QListView::contentsMouseMoveEvent(e); | 217 | QListView::contentsMouseMoveEvent(e); |
218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
219 | QApplication::startDragDistance()) { | 219 | QApplication::startDragDistance()) { |
220 | mMousePressed = false; | 220 | mMousePressed = false; |
221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
222 | if (item) { | 222 | if (item) { |
223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; | 223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; |
224 | DndFactory factory( mCalendar ); | 224 | DndFactory factory( mCalendar ); |
225 | ICalDrag *vd = factory.createDragTodo( | 225 | ICalDrag *vd = factory.createDragTodo( |
226 | ((KOTodoViewItem *)item)->todo(),viewport()); | 226 | ((KOTodoViewItem *)item)->todo(),viewport()); |
227 | if (vd->drag()) { | 227 | if (vd->drag()) { |
228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; | 228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; |
229 | } | 229 | } |
230 | /* | 230 | /* |
231 | QString source = fullPath(item); | 231 | QString source = fullPath(item); |
232 | if ( QFile::exists(source) ) { | 232 | if ( QFile::exists(source) ) { |
233 | QUriDrag* ud = new QUriDrag(viewport()); | 233 | QUriDrag* ud = new QUriDrag(viewport()); |
234 | ud->setFilenames( source ); | 234 | ud->setFilenames( source ); |
235 | if ( ud->drag() ) | 235 | if ( ud->drag() ) |
236 | QMessageBox::information( this, "Drag source", | 236 | QMessageBox::information( this, "Drag source", |
237 | QString("Delete ")+source, "Not implemented" ); | 237 | QString("Delete ")+source, "Not implemented" ); |
238 | */ | 238 | */ |
239 | } | 239 | } |
240 | } | 240 | } |
241 | #endif | 241 | #endif |
242 | } | 242 | } |
243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
244 | { | 244 | { |
245 | 245 | ||
246 | QListViewItem* cn; | 246 | QListViewItem* cn; |
247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
248 | cn = currentItem(); | 248 | cn = currentItem(); |
249 | if ( cn ) { | 249 | if ( cn ) { |
250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
251 | if ( ci ){ | 251 | if ( ci ){ |
252 | if ( e->state() == ShiftButton ) | 252 | if ( e->state() == ShiftButton ) |
253 | ci->setOn( false ); | 253 | ci->setOn( false ); |
254 | else | 254 | else |
255 | ci->setOn( true ); | 255 | ci->setOn( true ); |
256 | cn = cn->nextSibling(); | 256 | cn = cn->nextSibling(); |
257 | if ( cn ) { | 257 | if ( cn ) { |
258 | setCurrentItem ( cn ); | 258 | setCurrentItem ( cn ); |
259 | ensureItemVisible ( cn ); | 259 | ensureItemVisible ( cn ); |
260 | } | 260 | } |
261 | 261 | ||
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | // qDebug("KOTodoListView::keyPressEvent "); | 268 | // qDebug("KOTodoListView::keyPressEvent "); |
269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
270 | switch ( e->key() ) { | 270 | switch ( e->key() ) { |
271 | case Qt::Key_Down: | 271 | case Qt::Key_Down: |
272 | case Qt::Key_Up: | 272 | case Qt::Key_Up: |
273 | QListView::keyPressEvent ( e ); | 273 | QListView::keyPressEvent ( e ); |
274 | break; | 274 | break; |
275 | case Qt::Key_Left: | 275 | case Qt::Key_Left: |
276 | case Qt::Key_Right: | 276 | case Qt::Key_Right: |
277 | QListView::keyPressEvent ( e ); | 277 | QListView::keyPressEvent ( e ); |
278 | e->accept(); | 278 | e->accept(); |
279 | return; | 279 | return; |
280 | break; | 280 | break; |
281 | default: | 281 | default: |
282 | e->ignore(); | 282 | e->ignore(); |
283 | break; | 283 | break; |
284 | } | 284 | } |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | e->ignore(); | 287 | e->ignore(); |
288 | } | 288 | } |
289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
290 | { | 290 | { |
291 | QListView::contentsMouseReleaseEvent(e); | 291 | QListView::contentsMouseReleaseEvent(e); |
292 | mMousePressed = false; | 292 | mMousePressed = false; |
293 | } | 293 | } |
294 | 294 | ||
295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
296 | { | 296 | { |
297 | if (!e) return; | 297 | if (!e) return; |
298 | 298 | ||
299 | QPoint vp = contentsToViewport(e->pos()); | 299 | QPoint vp = contentsToViewport(e->pos()); |
300 | 300 | ||
301 | QListViewItem *item = itemAt(vp); | 301 | QListViewItem *item = itemAt(vp); |
302 | 302 | ||
303 | emit double_Clicked(item); | 303 | emit double_Clicked(item); |
304 | if (!item) return; | 304 | if (!item) return; |
305 | 305 | ||
306 | emit doubleClicked(item,vp,0); | 306 | emit doubleClicked(item,vp,0); |
307 | } | 307 | } |
308 | 308 | ||
309 | ///////////////////////////////////////////////////////////////////////////// | 309 | ///////////////////////////////////////////////////////////////////////////// |
310 | 310 | ||
311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
312 | QLineEdit(parent) | 312 | QLineEdit(parent) |
313 | { | 313 | { |
314 | setText(i18n("Click to add a new Todo")); | 314 | setText(i18n("Click to add a new Todo")); |
315 | } | 315 | } |
316 | 316 | ||
317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
318 | { | 318 | { |
319 | if ( text()==i18n("Click to add a new Todo") ) | 319 | if ( text()==i18n("Click to add a new Todo") ) |
320 | setText(""); | 320 | setText(""); |
321 | QLineEdit::focusInEvent(ev); | 321 | QLineEdit::focusInEvent(ev); |
322 | } | 322 | } |
323 | 323 | ||
324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
325 | { | 325 | { |
326 | setText(i18n("Click to add a new Todo")); | 326 | setText(i18n("Click to add a new Todo")); |
327 | QLineEdit::focusOutEvent(ev); | 327 | QLineEdit::focusOutEvent(ev); |
328 | } | 328 | } |
329 | 329 | ||
330 | ///////////////////////////////////////////////////////////////////////////// | 330 | ///////////////////////////////////////////////////////////////////////////// |
331 | 331 | ||
332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
333 | KOrg::BaseView(calendar,parent,name) | 333 | KOrg::BaseView(calendar,parent,name) |
334 | { | 334 | { |
335 | QBoxLayout *topLayout = new QVBoxLayout(this); | 335 | QBoxLayout *topLayout = new QVBoxLayout(this); |
336 | mName = QString ( name ); | 336 | mName = QString ( name ); |
337 | mBlockUpdate = false; | 337 | mBlockUpdate = false; |
338 | mQuickAdd = new KOQuickTodo(this); | 338 | mQuickAdd = new KOQuickTodo(this); |
339 | topLayout->addWidget(mQuickAdd); | 339 | topLayout->addWidget(mQuickAdd); |
340 | 340 | ||
341 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 341 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
342 | 342 | ||
343 | mTodoListView = new KOTodoListView(calendar,this, name ); | 343 | mTodoListView = new KOTodoListView(calendar,this, name ); |
344 | topLayout->addWidget(mTodoListView); | 344 | topLayout->addWidget(mTodoListView); |
345 | //mTodoListView->header()->setMaximumHeight(30); | 345 | //mTodoListView->header()->setMaximumHeight(30); |
346 | mTodoListView->setRootIsDecorated(true); | 346 | mTodoListView->setRootIsDecorated(true); |
347 | mTodoListView->setAllColumnsShowFocus(true); | 347 | mTodoListView->setAllColumnsShowFocus(true); |
348 | 348 | ||
349 | mTodoListView->setShowSortIndicator(true); | 349 | mTodoListView->setShowSortIndicator(true); |
350 | 350 | ||
351 | mTodoListView->addColumn(i18n("Todo")); | 351 | mTodoListView->addColumn(i18n("Todo")); |
352 | mTodoListView->addColumn(i18n("Prio")); | 352 | mTodoListView->addColumn(i18n("Prio")); |
353 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 353 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
354 | mTodoListView->addColumn(i18n("Complete")); | 354 | mTodoListView->addColumn(i18n("Complete")); |
355 | mTodoListView->setColumnAlignment(2,AlignHCenter); | 355 | mTodoListView->setColumnAlignment(2,AlignHCenter); |
356 | mTodoListView->addColumn(i18n("Due Date")); | 356 | mTodoListView->addColumn(i18n("Due Date")); |
357 | mTodoListView->setColumnAlignment(3,AlignLeft); | 357 | mTodoListView->setColumnAlignment(3,AlignLeft); |
358 | mTodoListView->addColumn(i18n("Due Time")); | 358 | mTodoListView->addColumn(i18n("Due Time")); |
359 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 359 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
360 | mTodoListView->addColumn(i18n("Cancelled")); | 360 | mTodoListView->addColumn(i18n("Cancelled")); |
361 | mTodoListView->addColumn(i18n("Categories")); | 361 | mTodoListView->addColumn(i18n("Categories")); |
362 | #if 0 | 362 | #if 0 |
363 | mTodoListView->addColumn(i18n("Sort Id")); | 363 | mTodoListView->addColumn(i18n("Sort Id")); |
364 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 364 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
365 | #endif | 365 | #endif |
366 | 366 | ||
367 | mTodoListView->setMinimumHeight( 60 ); | 367 | mTodoListView->setMinimumHeight( 60 ); |
368 | mTodoListView->setItemsRenameable( true ); | 368 | mTodoListView->setItemsRenameable( true ); |
369 | mTodoListView->setRenameable( 0 ); | 369 | mTodoListView->setRenameable( 0 ); |
370 | mTodoListView->setColumnWidth( 0, 120 ); | 370 | mTodoListView->setColumnWidth( 0, 120 ); |
371 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 371 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
372 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 372 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
373 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 373 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
374 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 374 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
375 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 375 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
376 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 376 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
377 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | ||
377 | mTodoListView->setColumnAlignment( 2, AlignCenter ); | 378 | mTodoListView->setColumnAlignment( 2, AlignCenter ); |
378 | #if 0 | 379 | #if 0 |
379 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 380 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
380 | #endif | 381 | #endif |
381 | 382 | ||
382 | mPriorityPopupMenu = new QPopupMenu(this); | 383 | mPriorityPopupMenu = new QPopupMenu(this); |
383 | for (int i = 1; i <= 5; i++) { | 384 | for (int i = 1; i <= 5; i++) { |
384 | QString label = QString ("%1").arg (i); | 385 | QString label = QString ("%1").arg (i); |
385 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 386 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
386 | } | 387 | } |
387 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 388 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
388 | 389 | ||
389 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 390 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
390 | for (int i = 0; i <= 100; i+=20) { | 391 | for (int i = 0; i <= 100; i+=20) { |
391 | QString label = QString ("%1 %").arg (i); | 392 | QString label = QString ("%1 %").arg (i); |
392 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 393 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
393 | } | 394 | } |
394 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 395 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
395 | 396 | ||
396 | 397 | ||
397 | 398 | ||
398 | mItemPopupMenu = new QPopupMenu(this); | 399 | mItemPopupMenu = new QPopupMenu(this); |
399 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 400 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
400 | SLOT (showTodo())); | 401 | SLOT (showTodo())); |
401 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 402 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
402 | SLOT (editTodo())); | 403 | SLOT (editTodo())); |
403 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 404 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
404 | SLOT (deleteTodo())); | 405 | SLOT (deleteTodo())); |
405 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 406 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
406 | SLOT (cloneTodo())); | 407 | SLOT (cloneTodo())); |
407 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 408 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
408 | SLOT (moveTodo())); | 409 | SLOT (moveTodo())); |
409 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 410 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
410 | SLOT (beamTodo())); | 411 | SLOT (beamTodo())); |
411 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 412 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
412 | SLOT (cancelTodo())); | 413 | SLOT (cancelTodo())); |
413 | mItemPopupMenu->insertSeparator(); | 414 | mItemPopupMenu->insertSeparator(); |
414 | 415 | ||
415 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 416 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
416 | SLOT (newTodo())); | 417 | SLOT (newTodo())); |
417 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 418 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
418 | SLOT (newSubTodo())); | 419 | SLOT (newSubTodo())); |
419 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 420 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
420 | SLOT (unparentTodo()),0,21); | 421 | SLOT (unparentTodo()),0,21); |
421 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 422 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
422 | SLOT (reparentTodo()),0,22); | 423 | SLOT (reparentTodo()),0,22); |
423 | mItemPopupMenu->insertSeparator(); | 424 | mItemPopupMenu->insertSeparator(); |
424 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 425 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
425 | this, SLOT( purgeCompleted() ) ); | 426 | this, SLOT( purgeCompleted() ) ); |
426 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 427 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
427 | this, SLOT( toggleCompleted() ),0, 33 ); | 428 | this, SLOT( toggleCompleted() ),0, 33 ); |
428 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 429 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
429 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 430 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
430 | 431 | ||
431 | mPopupMenu = new QPopupMenu(this); | 432 | mPopupMenu = new QPopupMenu(this); |
432 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 433 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
433 | SLOT (newTodo()),0,1); | 434 | SLOT (newTodo()),0,1); |
434 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 435 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
435 | this, SLOT(purgeCompleted()),0,2); | 436 | this, SLOT(purgeCompleted()),0,2); |
436 | mPopupMenu->insertItem(i18n("Show Completed"), | 437 | mPopupMenu->insertItem(i18n("Show Completed"), |
437 | this, SLOT( toggleCompleted() ),0,3 ); | 438 | this, SLOT( toggleCompleted() ),0,3 ); |
438 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 439 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
439 | this, SLOT( toggleQuickTodo() ),0,4 ); | 440 | this, SLOT( toggleQuickTodo() ),0,4 ); |
440 | mDocPrefs = new DocPrefs( name ); | 441 | mDocPrefs = new DocPrefs( name ); |
441 | 442 | ||
442 | mPopupMenu->setCheckable( true ); | 443 | mPopupMenu->setCheckable( true ); |
443 | mItemPopupMenu->setCheckable( true ); | 444 | mItemPopupMenu->setCheckable( true ); |
444 | // Double clicking conflicts with opening/closing the subtree | 445 | // Double clicking conflicts with opening/closing the subtree |
445 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 446 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
446 | SLOT( editItem( QListViewItem *) ) ); | 447 | SLOT( editItem( QListViewItem *) ) ); |
447 | /* | 448 | /* |
448 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 449 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
449 | const QPoint &,int ) ), | 450 | const QPoint &,int ) ), |
450 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 451 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
451 | */ | 452 | */ |
452 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 453 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
453 | const QPoint &,int ) ), | 454 | const QPoint &,int ) ), |
454 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 455 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
455 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 456 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
456 | SLOT( itemClicked( QListViewItem * ) ) ); | 457 | SLOT( itemClicked( QListViewItem * ) ) ); |
457 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 458 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
458 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 459 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
459 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), | 460 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), |
460 | SLOT( updateView() ) ); | 461 | SLOT( updateView() ) ); |
461 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 462 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
462 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 463 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
463 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 464 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
464 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 465 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
465 | 466 | ||
466 | #if 0 | 467 | #if 0 |
467 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 468 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
468 | SLOT(selectionChanged(QListViewItem *))); | 469 | SLOT(selectionChanged(QListViewItem *))); |
469 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 470 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
470 | SLOT(selectionChanged(QListViewItem *))); | 471 | SLOT(selectionChanged(QListViewItem *))); |
471 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 472 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
472 | SLOT(selectionChanged(QListViewItem *))); | 473 | SLOT(selectionChanged(QListViewItem *))); |
473 | #endif | 474 | #endif |
474 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 475 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
475 | SLOT( processSelectionChange() ) ); | 476 | SLOT( processSelectionChange() ) ); |
476 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 477 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
477 | SLOT( addQuickTodo() ) ); | 478 | SLOT( addQuickTodo() ) ); |
478 | // if ( QApplication::desktop()->width() < 480 ) { | 479 | // if ( QApplication::desktop()->width() < 480 ) { |
479 | // setNarrow(); | 480 | // setNarrow(); |
480 | // mTodoListView->setColumnWidth( 0, 100 ); | 481 | // mTodoListView->setColumnWidth( 0, 100 ); |
481 | 482 | ||
482 | // } | 483 | // } |
483 | 484 | ||
484 | } | 485 | } |
485 | 486 | ||
486 | KOTodoView::~KOTodoView() | 487 | KOTodoView::~KOTodoView() |
487 | { | 488 | { |
488 | delete mDocPrefs; | 489 | delete mDocPrefs; |
489 | } | 490 | } |
490 | 491 | ||
491 | void KOTodoView::jumpToDate () | 492 | void KOTodoView::jumpToDate () |
492 | { | 493 | { |
493 | // if (mActiveItem) { | 494 | // if (mActiveItem) { |
494 | // mActiveItem->todo()); | 495 | // mActiveItem->todo()); |
495 | // if ( mActiveItem->todo()->hasDueDate() ) | 496 | // if ( mActiveItem->todo()->hasDueDate() ) |
496 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 497 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
497 | } | 498 | } |
498 | 499 | ||
499 | void KOTodoView::setNarrow() | 500 | void KOTodoView::setNarrow() |
500 | { | 501 | { |
501 | //mTodoListView->setColumnWidth( 0, 120 ); | 502 | //mTodoListView->setColumnWidth( 0, 120 ); |
502 | mTodoListView->setColumnWidth( 1, 35 ); | 503 | mTodoListView->setColumnWidth( 1, 35 ); |
503 | mTodoListView->setColumnWidth( 2, 40 ); | 504 | mTodoListView->setColumnWidth( 2, 40 ); |
504 | mTodoListView->setColumnWidth( 3, 80 ); | 505 | mTodoListView->setColumnWidth( 3, 80 ); |
505 | mTodoListView->setColumnWidth( 4, 40 ); | 506 | mTodoListView->setColumnWidth( 4, 40 ); |
506 | mTodoListView->setColumnWidth( 5, 90 ); | 507 | mTodoListView->setColumnWidth( 5, 90 ); |
507 | 508 | ||
508 | } | 509 | } |
509 | void KOTodoView::updateView() | 510 | void KOTodoView::updateView() |
510 | { | 511 | { |
511 | pendingSubtodo = 0; | 512 | pendingSubtodo = 0; |
512 | if ( mBlockUpdate ) { | 513 | if ( mBlockUpdate ) { |
513 | //qDebug("blocked "); | 514 | //qDebug("blocked "); |
514 | return; | 515 | return; |
515 | } | 516 | } |
516 | //qDebug("update "); | 517 | //qDebug("update "); |
517 | // kdDebug() << "KOTodoView::updateView()" << endl; | 518 | // kdDebug() << "KOTodoView::updateView()" << endl; |
518 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 519 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
519 | mTodoListView->clear(); | 520 | mTodoListView->clear(); |
520 | if ( mName == "todolistsmall" ) { | 521 | if ( mName == "todolistsmall" ) { |
521 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 522 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
522 | int ps = fo.pointSize() -2; | 523 | int ps = fo.pointSize() -2; |
523 | if ( ps > 12 ) | 524 | if ( ps > 12 ) |
524 | ps -= 2; | 525 | ps -= 2; |
525 | fo.setPointSize( ps ); | 526 | fo.setPointSize( ps ); |
526 | } | 527 | } |
527 | } | 528 | } |
528 | 529 | ||
529 | mTodoListView->setFont( fo ); | 530 | mTodoListView->setFont( fo ); |
530 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 531 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
531 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 532 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
532 | QPtrList<Todo> todoList = calendar()->todos(); | 533 | QPtrList<Todo> todoList = calendar()->todos(); |
533 | 534 | ||
534 | /* | 535 | /* |
535 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 536 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
536 | Event *t; | 537 | Event *t; |
537 | for(t = todoList.first(); t; t = todoList.next()) { | 538 | for(t = todoList.first(); t; t = todoList.next()) { |
538 | kdDebug() << " " << t->getSummary() << endl; | 539 | kdDebug() << " " << t->getSummary() << endl; |
539 | 540 | ||
540 | if (t->getRelatedTo()) { | 541 | if (t->getRelatedTo()) { |
541 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 542 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
542 | } | 543 | } |
543 | 544 | ||
544 | QPtrList<Event> l = t->getRelations(); | 545 | QPtrList<Event> l = t->getRelations(); |
545 | Event *c; | 546 | Event *c; |
546 | for(c=l.first();c;c=l.next()) { | 547 | for(c=l.first();c;c=l.next()) { |
547 | kdDebug() << " - relation: " << c->getSummary() << endl; | 548 | kdDebug() << " - relation: " << c->getSummary() << endl; |
548 | } | 549 | } |
549 | } | 550 | } |
550 | */ | 551 | */ |
551 | 552 | ||
552 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 553 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
553 | // specific order of events. That means that we have to generate parent items | 554 | // specific order of events. That means that we have to generate parent items |
554 | // recursively for proper hierarchical display of Todos. | 555 | // recursively for proper hierarchical display of Todos. |
555 | mTodoMap.clear(); | 556 | mTodoMap.clear(); |
556 | Todo *todo; | 557 | Todo *todo; |
557 | todo = todoList.first();// todo; todo = todoList.next()) { | 558 | todo = todoList.first();// todo; todo = todoList.next()) { |
558 | while ( todo ) { | 559 | while ( todo ) { |
559 | bool next = true; | 560 | bool next = true; |
560 | // qDebug("todo %s ", todo->summary().latin1()); | 561 | // qDebug("todo %s ", todo->summary().latin1()); |
561 | Incidence *incidence = todo->relatedTo(); | 562 | Incidence *incidence = todo->relatedTo(); |
562 | while ( incidence ) { | 563 | while ( incidence ) { |
563 | if ( incidence->type() == "Todo") { | 564 | if ( incidence->type() == "Todo") { |
564 | //qDebug("related %s ",incidence->summary().latin1() ); | 565 | //qDebug("related %s ",incidence->summary().latin1() ); |
565 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 566 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
566 | //qDebug("related not found "); | 567 | //qDebug("related not found "); |
567 | todoList.remove( ); | 568 | todoList.remove( ); |
568 | todo = todoList.current(); | 569 | todo = todoList.current(); |
569 | next = false; | 570 | next = false; |
570 | incidence = 0; | 571 | incidence = 0; |
571 | 572 | ||
572 | } else { | 573 | } else { |
573 | //qDebug("related found "); | 574 | //qDebug("related found "); |
574 | incidence = incidence->relatedTo(); | 575 | incidence = incidence->relatedTo(); |
575 | } | 576 | } |
576 | } else | 577 | } else |
577 | incidence = 0; | 578 | incidence = 0; |
578 | } | 579 | } |
579 | if ( next ) | 580 | if ( next ) |
580 | todo = todoList.next(); | 581 | todo = todoList.next(); |
581 | } | 582 | } |
582 | // qDebug("again .... "); | 583 | // qDebug("again .... "); |
583 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 584 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
584 | 585 | ||
585 | // qDebug("yytodo %s ", todo->summary().latin1()); | 586 | // qDebug("yytodo %s ", todo->summary().latin1()); |
586 | // } | 587 | // } |
587 | //qDebug("for "); | 588 | //qDebug("for "); |
588 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 589 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
589 | if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) | 590 | if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) |
590 | { | 591 | { |
591 | insertTodoItem(todo); | 592 | insertTodoItem(todo); |
592 | } | 593 | } |
593 | } | 594 | } |
594 | //qDebug("for end "); | 595 | //qDebug("for end "); |
595 | // Restore opened/closed state | 596 | // Restore opened/closed state |
596 | mTodoListView->blockSignals( true ); | 597 | mTodoListView->blockSignals( true ); |
597 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 598 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
598 | mTodoListView->blockSignals( false ); | 599 | mTodoListView->blockSignals( false ); |
599 | mTodoListView->setFocus(); | 600 | mTodoListView->setFocus(); |
600 | processSelectionChange(); | 601 | processSelectionChange(); |
601 | } | 602 | } |
602 | 603 | ||
603 | void KOTodoView::restoreItemState( QListViewItem *item ) | 604 | void KOTodoView::restoreItemState( QListViewItem *item ) |
604 | { | 605 | { |
605 | pendingSubtodo = 0; | 606 | pendingSubtodo = 0; |
606 | while( item ) { | 607 | while( item ) { |
607 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 608 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
608 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 609 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
609 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 610 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
610 | item = item->nextSibling(); | 611 | item = item->nextSibling(); |
611 | } | 612 | } |
612 | } | 613 | } |
613 | 614 | ||
614 | 615 | ||
615 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 616 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
616 | KOTodoView::insertTodoItem(Todo *todo) | 617 | KOTodoView::insertTodoItem(Todo *todo) |
617 | { | 618 | { |
618 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 619 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
619 | // TODO: Check, if dynmaic cast is necessary | 620 | // TODO: Check, if dynmaic cast is necessary |
620 | 621 | ||
621 | pendingSubtodo = 0; | 622 | pendingSubtodo = 0; |
622 | Incidence *incidence = todo->relatedTo(); | 623 | Incidence *incidence = todo->relatedTo(); |
623 | if (incidence && incidence->type() == "Todo") { | 624 | if (incidence && incidence->type() == "Todo") { |
624 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 625 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
625 | 626 | ||
626 | // kdDebug() << " has Related" << endl; | 627 | // kdDebug() << " has Related" << endl; |
627 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 628 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
628 | itemIterator = mTodoMap.find(relatedTodo); | 629 | itemIterator = mTodoMap.find(relatedTodo); |
629 | if (itemIterator == mTodoMap.end()) { | 630 | if (itemIterator == mTodoMap.end()) { |
630 | // kdDebug() << " related not yet in list" << endl; | 631 | // kdDebug() << " related not yet in list" << endl; |
631 | itemIterator = insertTodoItem (relatedTodo); | 632 | itemIterator = insertTodoItem (relatedTodo); |
632 | } | 633 | } |
633 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 634 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
634 | // and one into the map. Sure finding is more easy but why? -zecke | 635 | // and one into the map. Sure finding is more easy but why? -zecke |
635 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 636 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
636 | return mTodoMap.insert(todo,todoItem); | 637 | return mTodoMap.insert(todo,todoItem); |
637 | } else { | 638 | } else { |
638 | // kdDebug() << " no Related" << endl; | 639 | // kdDebug() << " no Related" << endl; |
639 | // see above -zecke | 640 | // see above -zecke |
640 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 641 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
641 | return mTodoMap.insert(todo,todoItem); | 642 | return mTodoMap.insert(todo,todoItem); |
642 | } | 643 | } |
643 | } | 644 | } |
644 | 645 | ||
645 | 646 | ||
646 | void KOTodoView::updateConfig() | 647 | void KOTodoView::updateConfig() |
647 | { | 648 | { |
648 | updateView(); | 649 | updateView(); |
649 | mTodoListView->repaintContents(); | 650 | mTodoListView->repaintContents(); |
650 | } | 651 | } |
651 | 652 | ||
652 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 653 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
653 | { | 654 | { |
654 | QPtrList<Incidence> selected; | 655 | QPtrList<Incidence> selected; |
655 | 656 | ||
656 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 657 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
657 | // if (!item) item = mActiveItem; | 658 | // if (!item) item = mActiveItem; |
658 | if (item) selected.append(item->todo()); | 659 | if (item) selected.append(item->todo()); |
659 | 660 | ||
660 | return selected; | 661 | return selected; |
661 | } | 662 | } |
662 | 663 | ||
663 | QPtrList<Todo> KOTodoView::selectedTodos() | 664 | QPtrList<Todo> KOTodoView::selectedTodos() |
664 | { | 665 | { |
665 | QPtrList<Todo> selected; | 666 | QPtrList<Todo> selected; |
666 | 667 | ||
667 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 668 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
668 | // if (!item) item = mActiveItem; | 669 | // if (!item) item = mActiveItem; |
669 | if (item) selected.append(item->todo()); | 670 | if (item) selected.append(item->todo()); |
670 | 671 | ||
671 | return selected; | 672 | return selected; |
672 | } | 673 | } |
673 | 674 | ||
674 | void KOTodoView::changeEventDisplay(Event *, int) | 675 | void KOTodoView::changeEventDisplay(Event *, int) |
675 | { | 676 | { |
676 | updateView(); | 677 | updateView(); |
677 | } | 678 | } |
678 | 679 | ||
679 | void KOTodoView::showDates(const QDate &, const QDate &) | 680 | void KOTodoView::showDates(const QDate &, const QDate &) |
680 | { | 681 | { |
681 | } | 682 | } |
682 | 683 | ||
683 | void KOTodoView::showEvents(QPtrList<Event>) | 684 | void KOTodoView::showEvents(QPtrList<Event>) |
684 | { | 685 | { |
685 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 686 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
686 | } | 687 | } |
687 | 688 | ||
688 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 689 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
689 | const QDate &td) | 690 | const QDate &td) |
690 | { | 691 | { |
691 | #ifndef KORG_NOPRINTER | 692 | #ifndef KORG_NOPRINTER |
692 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 693 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
693 | #endif | 694 | #endif |
694 | } | 695 | } |
695 | 696 | ||
696 | void KOTodoView::editItem(QListViewItem *item ) | 697 | void KOTodoView::editItem(QListViewItem *item ) |
697 | { | 698 | { |
698 | // qDebug("editItem(QListViewItem *item ) "); | 699 | // qDebug("editItem(QListViewItem *item ) "); |
699 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 700 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
700 | } | 701 | } |
701 | 702 | ||
702 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 703 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
703 | { | 704 | { |
704 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 705 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
705 | } | 706 | } |
706 | 707 | ||
707 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) | 708 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) |
708 | { | 709 | { |
709 | pendingSubtodo = 0; | 710 | pendingSubtodo = 0; |
710 | mActiveItem = (KOTodoViewItem *)item; | 711 | mActiveItem = (KOTodoViewItem *)item; |
711 | if (item) { | 712 | if (item) { |
712 | switch (column){ | 713 | switch (column){ |
713 | case 1: | 714 | case 1: |
714 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 715 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
715 | case 2: | 716 | case 2: |
716 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 717 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
717 | case 3: | 718 | case 3: |
718 | moveTodo(); | 719 | moveTodo(); |
719 | break; | 720 | break; |
720 | case 6: | 721 | case 6: |
721 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 722 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
722 | default: | 723 | default: |
723 | mItemPopupMenu->popup(QCursor::pos()); | 724 | mItemPopupMenu->popup(QCursor::pos()); |
724 | } | 725 | } |
725 | } else mPopupMenu->popup(QCursor::pos()); | 726 | } else mPopupMenu->popup(QCursor::pos()); |
726 | } | 727 | } |
727 | void KOTodoView::newTodo() | 728 | void KOTodoView::newTodo() |
728 | { | 729 | { |
729 | emit newTodoSignal(); | 730 | emit newTodoSignal(); |
730 | } | 731 | } |
731 | 732 | ||
732 | void KOTodoView::newSubTodo() | 733 | void KOTodoView::newSubTodo() |
733 | { | 734 | { |
734 | if (mActiveItem) { | 735 | if (mActiveItem) { |
735 | emit newSubTodoSignal(mActiveItem->todo()); | 736 | emit newSubTodoSignal(mActiveItem->todo()); |
736 | } | 737 | } |
737 | } | 738 | } |
738 | void KOTodoView::unparentTodo() | 739 | void KOTodoView::unparentTodo() |
739 | { | 740 | { |
740 | if (mActiveItem) { | 741 | if (mActiveItem) { |
741 | emit unparentTodoSignal(mActiveItem->todo()); | 742 | emit unparentTodoSignal(mActiveItem->todo()); |
742 | } | 743 | } |
743 | } | 744 | } |
744 | 745 | ||
745 | void KOTodoView::reparentTodo() | 746 | void KOTodoView::reparentTodo() |
746 | { | 747 | { |
747 | if (mActiveItem) { | 748 | if (mActiveItem) { |
748 | qDebug("KOTodoView::reparentTodo() "); | 749 | qDebug("KOTodoView::reparentTodo() "); |
749 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 750 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
750 | pendingSubtodo = mActiveItem; | 751 | pendingSubtodo = mActiveItem; |
751 | } | 752 | } |
752 | } | 753 | } |
753 | void KOTodoView::editTodo() | 754 | void KOTodoView::editTodo() |
754 | { | 755 | { |
755 | if (mActiveItem) { | 756 | if (mActiveItem) { |
756 | emit editTodoSignal(mActiveItem->todo()); | 757 | emit editTodoSignal(mActiveItem->todo()); |
757 | } | 758 | } |
758 | } | 759 | } |
759 | void KOTodoView::cloneTodo() | 760 | void KOTodoView::cloneTodo() |
760 | { | 761 | { |
761 | if (mActiveItem) { | 762 | if (mActiveItem) { |
762 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 763 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
763 | } | 764 | } |
764 | } | 765 | } |
765 | void KOTodoView::cancelTodo() | 766 | void KOTodoView::cancelTodo() |
766 | { | 767 | { |
767 | if (mActiveItem) { | 768 | if (mActiveItem) { |
768 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 769 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
769 | } | 770 | } |
770 | } | 771 | } |
771 | void KOTodoView::moveTodo() | 772 | void KOTodoView::moveTodo() |
772 | { | 773 | { |
773 | if (mActiveItem) { | 774 | if (mActiveItem) { |
774 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 775 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
775 | } | 776 | } |
776 | } | 777 | } |
777 | void KOTodoView::beamTodo() | 778 | void KOTodoView::beamTodo() |
778 | { | 779 | { |
779 | if (mActiveItem) { | 780 | if (mActiveItem) { |
780 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 781 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
781 | } | 782 | } |
782 | } | 783 | } |
783 | 784 | ||
784 | 785 | ||
785 | void KOTodoView::showTodo() | 786 | void KOTodoView::showTodo() |
786 | { | 787 | { |
787 | if (mActiveItem) { | 788 | if (mActiveItem) { |
788 | emit showTodoSignal(mActiveItem->todo()); | 789 | emit showTodoSignal(mActiveItem->todo()); |
789 | } | 790 | } |
790 | } | 791 | } |
791 | 792 | ||
792 | void KOTodoView::deleteTodo() | 793 | void KOTodoView::deleteTodo() |
793 | { | 794 | { |
794 | if (mActiveItem) { | 795 | if (mActiveItem) { |
795 | if (mActiveItem->childCount()) { | 796 | if (mActiveItem->childCount()) { |
796 | KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."), | 797 | KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."), |
797 | i18n("Delete To-Do")); | 798 | i18n("Delete To-Do")); |
798 | } else { | 799 | } else { |
799 | emit deleteTodoSignal(mActiveItem->todo()); | 800 | emit deleteTodoSignal(mActiveItem->todo()); |
800 | } | 801 | } |
801 | } | 802 | } |
802 | } | 803 | } |
803 | 804 | ||
804 | void KOTodoView::setNewPriority(int index) | 805 | void KOTodoView::setNewPriority(int index) |
805 | { | 806 | { |
806 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 807 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
807 | mActiveItem->todo()->setPriority(mPriority[index]); | 808 | mActiveItem->todo()->setPriority(mPriority[index]); |
808 | mActiveItem->construct(); | 809 | mActiveItem->construct(); |
809 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 810 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
810 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 811 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
811 | } | 812 | } |
812 | } | 813 | } |
813 | 814 | ||
814 | void KOTodoView::setNewPercentage(int index) | 815 | void KOTodoView::setNewPercentage(int index) |
815 | { | 816 | { |
816 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 817 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
817 | if (mPercentage[index] == 100) { | 818 | if (mPercentage[index] == 100) { |
818 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 819 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
819 | } else { | 820 | } else { |
820 | mActiveItem->todo()->setCompleted(false); | 821 | mActiveItem->todo()->setCompleted(false); |
821 | } | 822 | } |
822 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 823 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
823 | mActiveItem->construct(); | 824 | mActiveItem->construct(); |
824 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 825 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
825 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 826 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
826 | } | 827 | } |
827 | } | 828 | } |
828 | 829 | ||
829 | 830 | ||
830 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 831 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
831 | { | 832 | { |
832 | QPopupMenu* tempMenu = new QPopupMenu (this); | 833 | QPopupMenu* tempMenu = new QPopupMenu (this); |
833 | QStringList checkedCategories = todoItem->todo()->categories (); | 834 | QStringList checkedCategories = todoItem->todo()->categories (); |
834 | 835 | ||
835 | tempMenu->setCheckable (true); | 836 | tempMenu->setCheckable (true); |
836 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 837 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
837 | it != KOPrefs::instance()->mCustomCategories.end (); | 838 | it != KOPrefs::instance()->mCustomCategories.end (); |
838 | ++it) { | 839 | ++it) { |
839 | int index = tempMenu->insertItem (*it); | 840 | int index = tempMenu->insertItem (*it); |
840 | mCategory[index] = *it; | 841 | mCategory[index] = *it; |
841 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 842 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
842 | } | 843 | } |
843 | 844 | ||
844 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 845 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
845 | return tempMenu; | 846 | return tempMenu; |
846 | 847 | ||
847 | 848 | ||
848 | } | 849 | } |
849 | void KOTodoView::changedCategories(int index) | 850 | void KOTodoView::changedCategories(int index) |
850 | { | 851 | { |
851 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 852 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
852 | QStringList categories = mActiveItem->todo()->categories (); | 853 | QStringList categories = mActiveItem->todo()->categories (); |
853 | if (categories.find (mCategory[index]) != categories.end ()) | 854 | if (categories.find (mCategory[index]) != categories.end ()) |
854 | categories.remove (mCategory[index]); | 855 | categories.remove (mCategory[index]); |
855 | else | 856 | else |
856 | categories.insert (categories.end(), mCategory[index]); | 857 | categories.insert (categories.end(), mCategory[index]); |
857 | categories.sort (); | 858 | categories.sort (); |
858 | mActiveItem->todo()->setCategories (categories); | 859 | mActiveItem->todo()->setCategories (categories); |
859 | mActiveItem->construct(); | 860 | mActiveItem->construct(); |
860 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 861 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
861 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 862 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
862 | } | 863 | } |
863 | } | 864 | } |
864 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 865 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
865 | { | 866 | { |
866 | if ( pendingSubtodo != 0 ) { | 867 | if ( pendingSubtodo != 0 ) { |
867 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 868 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
868 | } | 869 | } |
869 | pendingSubtodo = 0; | 870 | pendingSubtodo = 0; |
870 | if (!item) { | 871 | if (!item) { |
871 | newTodo(); | 872 | newTodo(); |
872 | return; | 873 | return; |
873 | } | 874 | } |
874 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 875 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
875 | editItem( item ); | 876 | editItem( item ); |
876 | else | 877 | else |
877 | showItem( item , QPoint(), 0 ); | 878 | showItem( item , QPoint(), 0 ); |
878 | } | 879 | } |
879 | void KOTodoView::itemClicked(QListViewItem *item) | 880 | void KOTodoView::itemClicked(QListViewItem *item) |
880 | { | 881 | { |
881 | 882 | ||
882 | if (!item) { | 883 | if (!item) { |
883 | if ( pendingSubtodo != 0 ) { | 884 | if ( pendingSubtodo != 0 ) { |
884 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 885 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
885 | } | 886 | } |
886 | pendingSubtodo = 0; | 887 | pendingSubtodo = 0; |
887 | return; | 888 | return; |
888 | } | 889 | } |
889 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 890 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
890 | if ( pendingSubtodo != 0 ) { | 891 | if ( pendingSubtodo != 0 ) { |
891 | bool allowReparent = true; | 892 | bool allowReparent = true; |
892 | QListViewItem *par = item; | 893 | QListViewItem *par = item; |
893 | while ( par ) { | 894 | while ( par ) { |
894 | if ( par == pendingSubtodo ) { | 895 | if ( par == pendingSubtodo ) { |
895 | allowReparent = false; | 896 | allowReparent = false; |
896 | break; | 897 | break; |
897 | } | 898 | } |
898 | par = par->parent(); | 899 | par = par->parent(); |
899 | } | 900 | } |
900 | if ( !allowReparent ) { | 901 | if ( !allowReparent ) { |
901 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 902 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
902 | qDebug("Recursive reparenting not possible "); | 903 | qDebug("Recursive reparenting not possible "); |
903 | pendingSubtodo = 0; | 904 | pendingSubtodo = 0; |
904 | } else { | 905 | } else { |
905 | Todo* newParent = todoItem->todo(); | 906 | Todo* newParent = todoItem->todo(); |
906 | Todo* newSub = pendingSubtodo->todo(); | 907 | Todo* newSub = pendingSubtodo->todo(); |
907 | pendingSubtodo = 0; | 908 | pendingSubtodo = 0; |
908 | emit reparentTodoSignal( newParent,newSub ); | 909 | emit reparentTodoSignal( newParent,newSub ); |
909 | return; | 910 | return; |
910 | } | 911 | } |
911 | } | 912 | } |
912 | int completed = todoItem->todo()->isCompleted(); // Completed or not? | 913 | int completed = todoItem->todo()->isCompleted(); // Completed or not? |
913 | 914 | ||
914 | if (todoItem->isOn()) { | 915 | if (todoItem->isOn()) { |
915 | if (!completed) { | 916 | if (!completed) { |
916 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); | 917 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); |
917 | } | 918 | } |
918 | } else { | 919 | } else { |
919 | if (completed) { | 920 | if (completed) { |
920 | todoItem->todo()->setCompleted(false); | 921 | todoItem->todo()->setCompleted(false); |
921 | } | 922 | } |
922 | } | 923 | } |
923 | } | 924 | } |
924 | 925 | ||
925 | void KOTodoView::setDocumentId( const QString &id ) | 926 | void KOTodoView::setDocumentId( const QString &id ) |
926 | { | 927 | { |
927 | kdDebug() << "KOTodoView::setDocumentId()" << endl; | 928 | kdDebug() << "KOTodoView::setDocumentId()" << endl; |
928 | 929 | ||
929 | mDocPrefs->setDoc( id ); | 930 | mDocPrefs->setDoc( id ); |
930 | } | 931 | } |
931 | 932 | ||
932 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 933 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
933 | { | 934 | { |
934 | if (!item) return; | 935 | if (!item) return; |
935 | 936 | ||
936 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 937 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
937 | 938 | ||
938 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 939 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
939 | 940 | ||
940 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 941 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
941 | } | 942 | } |
942 | 943 | ||
943 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 944 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
944 | { | 945 | { |
945 | mTodoListView->saveLayout(config,group); | 946 | mTodoListView->saveLayout(config,group); |
946 | } | 947 | } |
947 | 948 | ||
948 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 949 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
949 | { | 950 | { |
950 | mTodoListView->restoreLayout(config,group); | 951 | mTodoListView->restoreLayout(config,group); |
951 | } | 952 | } |
952 | 953 | ||
953 | void KOTodoView::processSelectionChange() | 954 | void KOTodoView::processSelectionChange() |
954 | { | 955 | { |
955 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 956 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
956 | 957 | ||
957 | KOTodoViewItem *item = | 958 | KOTodoViewItem *item = |
958 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 959 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
959 | 960 | ||
960 | if ( !item ) { | 961 | if ( !item ) { |
961 | emit incidenceSelected( 0 ); | 962 | emit incidenceSelected( 0 ); |
962 | } else { | 963 | } else { |
963 | emit incidenceSelected( item->todo() ); | 964 | emit incidenceSelected( item->todo() ); |
964 | } | 965 | } |
965 | } | 966 | } |
966 | 967 | ||
967 | void KOTodoView::modified(bool b) | 968 | void KOTodoView::modified(bool b) |
968 | { | 969 | { |
969 | emit isModified(b); | 970 | emit isModified(b); |
970 | } | 971 | } |
971 | void KOTodoView::setTodoModified( Todo* todo ) | 972 | void KOTodoView::setTodoModified( Todo* todo ) |
972 | { | 973 | { |
973 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 974 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
974 | } | 975 | } |
975 | void KOTodoView::clearSelection() | 976 | void KOTodoView::clearSelection() |
976 | { | 977 | { |
977 | mTodoListView->selectAll( false ); | 978 | mTodoListView->selectAll( false ); |
978 | } | 979 | } |
979 | 980 | ||
980 | void KOTodoView::purgeCompleted() | 981 | void KOTodoView::purgeCompleted() |
981 | { | 982 | { |
982 | emit purgeCompletedSignal(); | 983 | emit purgeCompletedSignal(); |
983 | } | 984 | } |
984 | void KOTodoView::toggleQuickTodo() | 985 | void KOTodoView::toggleQuickTodo() |
985 | { | 986 | { |
986 | if ( mQuickAdd->isVisible() ) { | 987 | if ( mQuickAdd->isVisible() ) { |
987 | mQuickAdd->hide(); | 988 | mQuickAdd->hide(); |
988 | KOPrefs::instance()->mEnableQuickTodo = false; | 989 | KOPrefs::instance()->mEnableQuickTodo = false; |
989 | } | 990 | } |
990 | else { | 991 | else { |
991 | mQuickAdd->show(); | 992 | mQuickAdd->show(); |
992 | KOPrefs::instance()->mEnableQuickTodo = true; | 993 | KOPrefs::instance()->mEnableQuickTodo = true; |
993 | } | 994 | } |
994 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 995 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
995 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 996 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
996 | } | 997 | } |
997 | void KOTodoView::toggleCompleted() | 998 | void KOTodoView::toggleCompleted() |
998 | { | 999 | { |
999 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1000 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1000 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1001 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1001 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1002 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1002 | updateView(); | 1003 | updateView(); |
1003 | } | 1004 | } |
1004 | 1005 | ||
1005 | void KOTodoView::addQuickTodo() | 1006 | void KOTodoView::addQuickTodo() |
1006 | { | 1007 | { |
1007 | Todo *todo = new Todo(); | 1008 | Todo *todo = new Todo(); |
1008 | todo->setSummary(mQuickAdd->text()); | 1009 | todo->setSummary(mQuickAdd->text()); |
1009 | todo->setOrganizer(KOPrefs::instance()->email()); | 1010 | todo->setOrganizer(KOPrefs::instance()->email()); |
1010 | CalFilter * cf = mCalendar->filter(); | 1011 | CalFilter * cf = mCalendar->filter(); |
1011 | if ( cf ) { | 1012 | if ( cf ) { |
1012 | if ( cf->isEnabled()&& cf->showCategories()) { | 1013 | if ( cf->isEnabled()&& cf->showCategories()) { |
1013 | todo->setCategories(cf->categoryList()); | 1014 | todo->setCategories(cf->categoryList()); |
1014 | } | 1015 | } |
1015 | if ( cf->isEnabled() ) | 1016 | if ( cf->isEnabled() ) |
1016 | todo->setSecrecy( cf->getSecrecy()); | 1017 | todo->setSecrecy( cf->getSecrecy()); |
1017 | } | 1018 | } |
1018 | mCalendar->addTodo(todo); | 1019 | mCalendar->addTodo(todo); |
1019 | mQuickAdd->setText(""); | 1020 | mQuickAdd->setText(""); |
1020 | todoModified (todo, KOGlobals::EVENTADDED ); | 1021 | todoModified (todo, KOGlobals::EVENTADDED ); |
1021 | updateView(); | 1022 | updateView(); |
1022 | } | 1023 | } |
1023 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1024 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1024 | { | 1025 | { |
1025 | // e->ignore(); | 1026 | // e->ignore(); |
1026 | //return; | 1027 | //return; |
1027 | //qDebug("KOTodoView::keyPressEvent "); | 1028 | //qDebug("KOTodoView::keyPressEvent "); |
1028 | switch ( e->key() ) { | 1029 | switch ( e->key() ) { |
1029 | case Qt::Key_Down: | 1030 | case Qt::Key_Down: |
1030 | case Qt::Key_Up: | 1031 | case Qt::Key_Up: |
1031 | QWidget::keyPressEvent ( e ); | 1032 | QWidget::keyPressEvent ( e ); |
1032 | break; | 1033 | break; |
1033 | 1034 | ||
1034 | case Qt::Key_Q: | 1035 | case Qt::Key_Q: |
1035 | toggleQuickTodo(); | 1036 | toggleQuickTodo(); |
1036 | break; | 1037 | break; |
1037 | case Qt::Key_U: | 1038 | case Qt::Key_U: |
1038 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1039 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1039 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1040 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1040 | unparentTodo(); | 1041 | unparentTodo(); |
1041 | e->accept(); | 1042 | e->accept(); |
1042 | } else | 1043 | } else |
1043 | e->ignore(); | 1044 | e->ignore(); |
1044 | break; | 1045 | break; |
1045 | case Qt::Key_S: | 1046 | case Qt::Key_S: |
1046 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1047 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1047 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1048 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1048 | reparentTodo(); | 1049 | reparentTodo(); |
1049 | e->accept(); | 1050 | e->accept(); |
1050 | } else | 1051 | } else |
1051 | e->ignore(); | 1052 | e->ignore(); |
1052 | break; | 1053 | break; |
1053 | case Qt::Key_P: | 1054 | case Qt::Key_P: |
1054 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1055 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1055 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1056 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1056 | if ( pendingSubtodo ) | 1057 | if ( pendingSubtodo ) |
1057 | itemClicked(mActiveItem); | 1058 | itemClicked(mActiveItem); |
1058 | e->accept(); | 1059 | e->accept(); |
1059 | } else | 1060 | } else |
1060 | e->ignore(); | 1061 | e->ignore(); |
1061 | break; | 1062 | break; |
1062 | case Qt::Key_Escape: | 1063 | case Qt::Key_Escape: |
1063 | if ( pendingSubtodo ) { | 1064 | if ( pendingSubtodo ) { |
1064 | itemClicked(0); | 1065 | itemClicked(0); |
1065 | e->accept(); | 1066 | e->accept(); |
1066 | } else | 1067 | } else |
1067 | e->ignore(); | 1068 | e->ignore(); |
1068 | break; | 1069 | break; |
1069 | default: | 1070 | default: |
1070 | e->ignore(); | 1071 | e->ignore(); |
1071 | } | 1072 | } |
1072 | 1073 | ||
1073 | if ( true ) { | 1074 | if ( true ) { |
1074 | if ( e->key() == Qt::Key_I ) { | 1075 | if ( e->key() == Qt::Key_I ) { |
1075 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1076 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1076 | if ( cn ) { | 1077 | if ( cn ) { |
1077 | mActiveItem = cn; | 1078 | mActiveItem = cn; |
1078 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1079 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1079 | if ( ci ){ | 1080 | if ( ci ){ |
1080 | showTodo(); | 1081 | showTodo(); |
1081 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1082 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1082 | if ( cn ) { | 1083 | if ( cn ) { |
1083 | mTodoListView->setCurrentItem ( cn ); | 1084 | mTodoListView->setCurrentItem ( cn ); |
1084 | mTodoListView->ensureItemVisible ( cn ); | 1085 | mTodoListView->ensureItemVisible ( cn ); |
1085 | } | 1086 | } |
1086 | 1087 | ||
1087 | } | 1088 | } |
1088 | } | 1089 | } |
1089 | e->accept(); | 1090 | e->accept(); |
1090 | 1091 | ||
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | } | 1094 | } |
1094 | 1095 | ||
1095 | } | 1096 | } |
1096 | void KOTodoView::updateTodo( Todo * t, int type ) | 1097 | void KOTodoView::updateTodo( Todo * t, int type ) |
1097 | { | 1098 | { |
1098 | if ( mBlockUpdate) | 1099 | if ( mBlockUpdate) |
1099 | return; | 1100 | return; |
1100 | 1101 | ||
1101 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1102 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1102 | itemIterator = mTodoMap.find(t); | 1103 | itemIterator = mTodoMap.find(t); |
1103 | if (itemIterator != mTodoMap.end()) { | 1104 | if (itemIterator != mTodoMap.end()) { |
1104 | (*itemIterator)->construct(); | 1105 | (*itemIterator)->construct(); |
1105 | } else { | 1106 | } else { |
1106 | if ( type == KOGlobals::EVENTADDED ) { | 1107 | if ( type == KOGlobals::EVENTADDED ) { |
1107 | insertTodoItem( t ); | 1108 | insertTodoItem( t ); |
1108 | } | 1109 | } |
1109 | } | 1110 | } |
1110 | 1111 | ||
1111 | } | 1112 | } |
1112 | 1113 | ||
1113 | void KOTodoView::todoModified(Todo * t , int p ) | 1114 | void KOTodoView::todoModified(Todo * t , int p ) |
1114 | { | 1115 | { |
1115 | mBlockUpdate = true; | 1116 | mBlockUpdate = true; |
1116 | emit todoModifiedSignal ( t, p ); | 1117 | emit todoModifiedSignal ( t, p ); |
1117 | mBlockUpdate = false; | 1118 | mBlockUpdate = false; |
1118 | } | 1119 | } |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 85647b1..ae0b334 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -1,432 +1,432 @@ | |||
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 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <qapp.h> | 22 | #include <qapp.h> |
23 | 23 | ||
24 | #include <kiconloader.h> | 24 | #include <kiconloader.h> |
25 | #include "kotodoviewitem.h" | 25 | #include "kotodoviewitem.h" |
26 | #include "kotodoview.h" | 26 | #include "kotodoview.h" |
27 | #include "koprefs.h" | 27 | #include "koprefs.h" |
28 | 28 | ||
29 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) | 29 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) |
30 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 30 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
31 | { | 31 | { |
32 | construct(); | 32 | construct(); |
33 | } | 33 | } |
34 | 34 | ||
35 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) | 35 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) |
36 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 36 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
37 | { | 37 | { |
38 | construct(); | 38 | construct(); |
39 | } | 39 | } |
40 | 40 | ||
41 | QString KOTodoViewItem::key(int column,bool) const | 41 | QString KOTodoViewItem::key(int column,bool) const |
42 | { | 42 | { |
43 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | 43 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); |
44 | if (it == mKeyMap.end()) { | 44 | if (it == mKeyMap.end()) { |
45 | return text(column); | 45 | return text(column).lower(); |
46 | } else { | 46 | } else { |
47 | return *it; | 47 | return *it; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | void KOTodoViewItem:: setup() | 51 | void KOTodoViewItem:: setup() |
52 | { | 52 | { |
53 | 53 | ||
54 | int h = 20; | 54 | int h = 20; |
55 | if ( listView () ) { | 55 | if ( listView () ) { |
56 | QFontMetrics fm ( listView ()->font () ); | 56 | QFontMetrics fm ( listView ()->font () ); |
57 | h = fm.height(); | 57 | h = fm.height(); |
58 | } | 58 | } |
59 | setHeight( h ); | 59 | setHeight( h ); |
60 | 60 | ||
61 | } | 61 | } |
62 | void KOTodoViewItem::setSortKey(int column,const QString &key) | 62 | void KOTodoViewItem::setSortKey(int column,const QString &key) |
63 | { | 63 | { |
64 | mKeyMap.insert(column,key); | 64 | mKeyMap.insert(column,key); |
65 | } | 65 | } |
66 | 66 | ||
67 | #if QT_VERSION >= 300 | 67 | #if QT_VERSION >= 300 |
68 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, | 68 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, |
69 | int y,int h) | 69 | int y,int h) |
70 | { | 70 | { |
71 | QListViewItem::paintBranches(p,cg,w,y,h); | 71 | QListViewItem::paintBranches(p,cg,w,y,h); |
72 | } | 72 | } |
73 | #else | 73 | #else |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | void KOTodoViewItem::construct() | 76 | void KOTodoViewItem::construct() |
77 | { | 77 | { |
78 | // qDebug("KOTodoViewItem::construct() "); | 78 | // qDebug("KOTodoViewItem::construct() "); |
79 | m_init = true; | 79 | m_init = true; |
80 | QString keyd = "=="; | 80 | QString keyd = "=="; |
81 | QString keyt = "=="; | 81 | QString keyt = "=="; |
82 | 82 | ||
83 | setOn(mTodo->isCompleted()); | 83 | setOn(mTodo->isCompleted()); |
84 | setText(0,mTodo->summary()); | 84 | setText(0,mTodo->summary()); |
85 | setText(1,QString::number(mTodo->priority())); | 85 | setText(1,QString::number(mTodo->priority())); |
86 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 86 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
87 | if (mTodo->percentComplete()<100) { | 87 | if (mTodo->percentComplete()<100) { |
88 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 88 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
89 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 89 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
90 | } | 90 | } |
91 | else { | 91 | else { |
92 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 92 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
93 | else setSortKey(2,QString::number(99)); | 93 | else setSortKey(2,QString::number(99)); |
94 | } | 94 | } |
95 | if (mTodo->hasDueDate()) { | 95 | if (mTodo->hasDueDate()) { |
96 | setText(3, mTodo->dtDueDateStr()); | 96 | setText(3, mTodo->dtDueDateStr()); |
97 | QDate d = mTodo->dtDue().date(); | 97 | QDate d = mTodo->dtDue().date(); |
98 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 98 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
99 | setSortKey(3,keyd); | 99 | setSortKey(3,keyd); |
100 | if (mTodo->doesFloat()) { | 100 | if (mTodo->doesFloat()) { |
101 | setText(4,""); | 101 | setText(4,""); |
102 | } | 102 | } |
103 | else { | 103 | else { |
104 | setText(4,mTodo->dtDueTimeStr()); | 104 | setText(4,mTodo->dtDueTimeStr()); |
105 | QTime t = mTodo->dtDue().time(); | 105 | QTime t = mTodo->dtDue().time(); |
106 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 106 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
107 | setSortKey(4,keyt); | 107 | setSortKey(4,keyt); |
108 | } | 108 | } |
109 | } else { | 109 | } else { |
110 | setText(3,""); | 110 | setText(3,""); |
111 | setText(4,""); | 111 | setText(4,""); |
112 | } | 112 | } |
113 | setSortKey(3,keyd); | 113 | setSortKey(3,keyd); |
114 | setSortKey(4,keyt); | 114 | setSortKey(4,keyt); |
115 | 115 | ||
116 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); | 116 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); |
117 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 117 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
118 | 118 | ||
119 | setText(5,mTodo->cancelled() ? i18n("Yes") : i18n("No")); | 119 | setText(5,mTodo->cancelled() ? i18n("Yes") : i18n("No")); |
120 | setText(6,mTodo->categoriesStr()); | 120 | setText(6,mTodo->categoriesStr()); |
121 | 121 | ||
122 | #if 0 | 122 | #if 0 |
123 | // Find sort id in description. It's the text behind the last '#' character | 123 | // Find sort id in description. It's the text behind the last '#' character |
124 | // found in the description. White spaces are removed from beginning and end | 124 | // found in the description. White spaces are removed from beginning and end |
125 | // of sort id. | 125 | // of sort id. |
126 | int pos = mTodo->description().findRev('#'); | 126 | int pos = mTodo->description().findRev('#'); |
127 | if (pos < 0) { | 127 | if (pos < 0) { |
128 | setText(6,""); | 128 | setText(6,""); |
129 | } else { | 129 | } else { |
130 | QString str = mTodo->description().mid(pos+1); | 130 | QString str = mTodo->description().mid(pos+1); |
131 | str.stripWhiteSpace(); | 131 | str.stripWhiteSpace(); |
132 | setText(6,str); | 132 | setText(6,str); |
133 | } | 133 | } |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | m_known = false; | 136 | m_known = false; |
137 | m_init = false; | 137 | m_init = false; |
138 | 138 | ||
139 | setMyPixmap(); | 139 | setMyPixmap(); |
140 | 140 | ||
141 | } | 141 | } |
142 | void KOTodoViewItem::setMyPixmap() | 142 | void KOTodoViewItem::setMyPixmap() |
143 | { | 143 | { |
144 | int size = 5; | 144 | int size = 5; |
145 | QPixmap pixi = QPixmap( 1, 1 ); | 145 | QPixmap pixi = QPixmap( 1, 1 ); |
146 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 146 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
147 | // pixi = SmallIcon("redcross16"); | 147 | // pixi = SmallIcon("redcross16"); |
148 | // } else { | 148 | // } else { |
149 | QPainter p; | 149 | QPainter p; |
150 | 150 | ||
151 | int pixSize = 0; | 151 | int pixSize = 0; |
152 | QPixmap pPix = QPixmap( size, size ); | 152 | QPixmap pPix = QPixmap( size, size ); |
153 | if ( mTodo->description().length() > 0 ) { | 153 | if ( mTodo->description().length() > 0 ) { |
154 | pixi.resize(size, pixSize+size); | 154 | pixi.resize(size, pixSize+size); |
155 | pPix.fill( Qt::darkGreen ); | 155 | pPix.fill( Qt::darkGreen ); |
156 | p.begin( &pixi ); | 156 | p.begin( &pixi ); |
157 | p. drawPixmap ( 0, pixSize, pPix); | 157 | p. drawPixmap ( 0, pixSize, pPix); |
158 | p.end(); | 158 | p.end(); |
159 | pixSize += size; | 159 | pixSize += size; |
160 | } | 160 | } |
161 | if ( mTodo->isAlarmEnabled() ) { | 161 | if ( mTodo->isAlarmEnabled() ) { |
162 | pixi.resize(size, pixSize+size); | 162 | pixi.resize(size, pixSize+size); |
163 | pPix.fill( Qt::red ); | 163 | pPix.fill( Qt::red ); |
164 | p.begin( &pixi ); | 164 | p.begin( &pixi ); |
165 | p. drawPixmap ( 0, pixSize, pPix); | 165 | p. drawPixmap ( 0, pixSize, pPix); |
166 | p.end(); | 166 | p.end(); |
167 | pixSize += size; | 167 | pixSize += size; |
168 | } | 168 | } |
169 | // } | 169 | // } |
170 | if ( pixi.width() > 1 ) { | 170 | if ( pixi.width() > 1 ) { |
171 | setPixmap ( 0,pixi ) ; | 171 | setPixmap ( 0,pixi ) ; |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | } | 175 | } |
176 | void KOTodoViewItem::stateChange(bool state) | 176 | void KOTodoViewItem::stateChange(bool state) |
177 | { | 177 | { |
178 | // qDebug("KOTodoViewItem::stateChange "); | 178 | // qDebug("KOTodoViewItem::stateChange "); |
179 | // do not change setting on startup | 179 | // do not change setting on startup |
180 | if ( m_init ) return; | 180 | if ( m_init ) return; |
181 | 181 | ||
182 | kdDebug() << "State changed, modified " << state << endl; | 182 | kdDebug() << "State changed, modified " << state << endl; |
183 | QString keyd = "=="; | 183 | QString keyd = "=="; |
184 | QString keyt = "=="; | 184 | QString keyt = "=="; |
185 | 185 | ||
186 | if (state) mTodo->setCompleted(state); | 186 | if (state) mTodo->setCompleted(state); |
187 | else mTodo->setPercentComplete(0); | 187 | else mTodo->setPercentComplete(0); |
188 | if (isOn()!=state) { | 188 | if (isOn()!=state) { |
189 | setOn(state); | 189 | setOn(state); |
190 | } | 190 | } |
191 | 191 | ||
192 | if (mTodo->hasDueDate()) { | 192 | if (mTodo->hasDueDate()) { |
193 | setText(3, mTodo->dtDueDateStr()); | 193 | setText(3, mTodo->dtDueDateStr()); |
194 | QDate d = mTodo->dtDue().date(); | 194 | QDate d = mTodo->dtDue().date(); |
195 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 195 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
196 | setSortKey(3,keyd); | 196 | setSortKey(3,keyd); |
197 | if (mTodo->doesFloat()) { | 197 | if (mTodo->doesFloat()) { |
198 | setText(4,""); | 198 | setText(4,""); |
199 | } | 199 | } |
200 | else { | 200 | else { |
201 | setText(4,mTodo->dtDueTimeStr()); | 201 | setText(4,mTodo->dtDueTimeStr()); |
202 | QTime t = mTodo->dtDue().time(); | 202 | QTime t = mTodo->dtDue().time(); |
203 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 203 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
204 | setSortKey(4,keyt); | 204 | setSortKey(4,keyt); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 207 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
208 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 208 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
209 | 209 | ||
210 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 210 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
211 | if (mTodo->percentComplete()<100) { | 211 | if (mTodo->percentComplete()<100) { |
212 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 212 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
213 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 213 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
214 | } | 214 | } |
215 | else { | 215 | else { |
216 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 216 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
217 | else setSortKey(2,QString::number(99)); | 217 | else setSortKey(2,QString::number(99)); |
218 | } | 218 | } |
219 | QListViewItem * myChild = firstChild(); | 219 | QListViewItem * myChild = firstChild(); |
220 | KOTodoViewItem *item; | 220 | KOTodoViewItem *item; |
221 | while( myChild ) { | 221 | while( myChild ) { |
222 | item = static_cast<KOTodoViewItem*>(myChild); | 222 | item = static_cast<KOTodoViewItem*>(myChild); |
223 | item->stateChange(state); | 223 | item->stateChange(state); |
224 | myChild = myChild->nextSibling(); | 224 | myChild = myChild->nextSibling(); |
225 | } | 225 | } |
226 | mTodoView->modified(true); | 226 | mTodoView->modified(true); |
227 | mTodoView->setTodoModified( mTodo ); | 227 | mTodoView->setTodoModified( mTodo ); |
228 | setMyPixmap(); | 228 | setMyPixmap(); |
229 | } | 229 | } |
230 | 230 | ||
231 | bool KOTodoViewItem::isAlternate() | 231 | bool KOTodoViewItem::isAlternate() |
232 | { | 232 | { |
233 | #ifndef KORG_NOLVALTERNATION | 233 | #ifndef KORG_NOLVALTERNATION |
234 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 234 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
235 | if (lv && lv->alternateBackground().isValid()) | 235 | if (lv && lv->alternateBackground().isValid()) |
236 | { | 236 | { |
237 | KOTodoViewItem *above = 0; | 237 | KOTodoViewItem *above = 0; |
238 | above = dynamic_cast<KOTodoViewItem *>(itemAbove()); | 238 | above = dynamic_cast<KOTodoViewItem *>(itemAbove()); |
239 | m_known = above ? above->m_known : true; | 239 | m_known = above ? above->m_known : true; |
240 | if (m_known) | 240 | if (m_known) |
241 | { | 241 | { |
242 | m_odd = above ? !above->m_odd : false; | 242 | m_odd = above ? !above->m_odd : false; |
243 | } | 243 | } |
244 | else | 244 | else |
245 | { | 245 | { |
246 | KOTodoViewItem *item; | 246 | KOTodoViewItem *item; |
247 | bool previous = true; | 247 | bool previous = true; |
248 | if (QListViewItem::parent()) | 248 | if (QListViewItem::parent()) |
249 | { | 249 | { |
250 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); | 250 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); |
251 | if (item) | 251 | if (item) |
252 | previous = item->m_odd; | 252 | previous = item->m_odd; |
253 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); | 253 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); |
254 | } | 254 | } |
255 | else | 255 | else |
256 | { | 256 | { |
257 | item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); | 257 | item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); |
258 | } | 258 | } |
259 | 259 | ||
260 | while(item) | 260 | while(item) |
261 | { | 261 | { |
262 | item->m_odd = previous = !previous; | 262 | item->m_odd = previous = !previous; |
263 | item->m_known = true; | 263 | item->m_known = true; |
264 | item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); | 264 | item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | return m_odd; | 267 | return m_odd; |
268 | } | 268 | } |
269 | return false; | 269 | return false; |
270 | #else | 270 | #else |
271 | return false; | 271 | return false; |
272 | #endif | 272 | #endif |
273 | } | 273 | } |
274 | 274 | ||
275 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 275 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
276 | { | 276 | { |
277 | QColorGroup _cg = cg; | 277 | QColorGroup _cg = cg; |
278 | QColorGroup::ColorRole role; | 278 | QColorGroup::ColorRole role; |
279 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) | 279 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) |
280 | role = QColorGroup::Text; | 280 | role = QColorGroup::Text; |
281 | else | 281 | else |
282 | role = QColorGroup::Base; | 282 | role = QColorGroup::Base; |
283 | //#ifndef KORG_NOLVALTERNATION | 283 | //#ifndef KORG_NOLVALTERNATION |
284 | // if (isAlternate()) | 284 | // if (isAlternate()) |
285 | // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); | 285 | // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); |
286 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; | 286 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; |
287 | QColor colorToSet; | 287 | QColor colorToSet; |
288 | if ( setColor ) { | 288 | if ( setColor ) { |
289 | QStringList categories = mTodo->categories(); | 289 | QStringList categories = mTodo->categories(); |
290 | QString cat = categories.first(); | 290 | QString cat = categories.first(); |
291 | if ( !cat.isEmpty()) { | 291 | if ( !cat.isEmpty()) { |
292 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); | 292 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); |
293 | } else | 293 | } else |
294 | setColor = false; | 294 | setColor = false; |
295 | } | 295 | } |
296 | if (mTodo->hasDueDate()) { | 296 | if (mTodo->hasDueDate()) { |
297 | if (mTodo->dtDue().date()==QDate::currentDate() && | 297 | if (mTodo->dtDue().date()==QDate::currentDate() && |
298 | !mTodo->isCompleted()) { | 298 | !mTodo->isCompleted()) { |
299 | //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); | 299 | //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); |
300 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; | 300 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; |
301 | setColor = true; | 301 | setColor = true; |
302 | } | 302 | } |
303 | if (mTodo->dtDue().date() < QDate::currentDate() && | 303 | if (mTodo->dtDue().date() < QDate::currentDate() && |
304 | !mTodo->isCompleted()) { | 304 | !mTodo->isCompleted()) { |
305 | //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor); | 305 | //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor); |
306 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; | 306 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; |
307 | setColor = true; | 307 | setColor = true; |
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | if ( setColor ) { | 311 | if ( setColor ) { |
312 | _cg.setColor(role,colorToSet ); | 312 | _cg.setColor(role,colorToSet ); |
313 | if ( role == QColorGroup::Base) { | 313 | if ( role == QColorGroup::Base) { |
314 | int rgb = colorToSet.red(); | 314 | int rgb = colorToSet.red(); |
315 | rgb += colorToSet.blue()/2; | 315 | rgb += colorToSet.blue()/2; |
316 | rgb += colorToSet.green(); | 316 | rgb += colorToSet.green(); |
317 | if ( rgb < 200 ) | 317 | if ( rgb < 200 ) |
318 | _cg.setColor(QColorGroup::Text,Qt::white ); | 318 | _cg.setColor(QColorGroup::Text,Qt::white ); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | //#endif | 321 | //#endif |
322 | if ( column > 0 ){ | 322 | if ( column > 0 ){ |
323 | if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { | 323 | if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { |
324 | p->save(); | 324 | p->save(); |
325 | int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); | 325 | int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); |
326 | 326 | ||
327 | p->fillRect( 0, 0, width, height(), _cg.base() ); // background | 327 | p->fillRect( 0, 0, width, height(), _cg.base() ); // background |
328 | // p->setPen(Qt::black ); //border | 328 | // p->setPen(Qt::black ); //border |
329 | // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling | 329 | // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling |
330 | QColor fc = KOPrefs::instance()->mHighlightColor; | 330 | QColor fc = KOPrefs::instance()->mHighlightColor; |
331 | if ( mTodo->percentComplete() == 100 ) | 331 | if ( mTodo->percentComplete() == 100 ) |
332 | fc = darkGreen; | 332 | fc = darkGreen; |
333 | p->drawRect( 2, 2, width-4, height()-4); | 333 | p->drawRect( 2, 2, width-4, height()-4); |
334 | p->fillRect( 3, 3, progress, height()-6, | 334 | p->fillRect( 3, 3, progress, height()-6, |
335 | fc ); | 335 | fc ); |
336 | p->restore(); | 336 | p->restore(); |
337 | } else { | 337 | } else { |
338 | QCheckListItem::paintCell(p, _cg, column, width, alignment); | 338 | QCheckListItem::paintCell(p, _cg, column, width, alignment); |
339 | } | 339 | } |
340 | return; | 340 | return; |
341 | } | 341 | } |
342 | 342 | ||
343 | int align = alignment; | 343 | int align = alignment; |
344 | 344 | ||
345 | if ( !p ) | 345 | if ( !p ) |
346 | return; | 346 | return; |
347 | 347 | ||
348 | p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); | 348 | p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); |
349 | 349 | ||
350 | QListView *lv = listView(); | 350 | QListView *lv = listView(); |
351 | if ( !lv ) | 351 | if ( !lv ) |
352 | return; | 352 | return; |
353 | int marg = 2;//lv->itemMargin(); | 353 | int marg = 2;//lv->itemMargin(); |
354 | int r = 0; | 354 | int r = 0; |
355 | QCheckListItem::Type myType = QCheckListItem::CheckBox; | 355 | QCheckListItem::Type myType = QCheckListItem::CheckBox; |
356 | int BoxSize = 20; | 356 | int BoxSize = 20; |
357 | int boxOffset = 2; | 357 | int boxOffset = 2; |
358 | int xOffset = 2; | 358 | int xOffset = 2; |
359 | if (qApp->desktop()->width() < 300 ) { | 359 | if (qApp->desktop()->width() < 300 ) { |
360 | BoxSize = 14; | 360 | BoxSize = 14; |
361 | boxOffset = -1; | 361 | boxOffset = -1; |
362 | xOffset = 1; | 362 | xOffset = 1; |
363 | // marg = 0; | 363 | // marg = 0; |
364 | } | 364 | } |
365 | if ( height() < BoxSize ) { | 365 | if ( height() < BoxSize ) { |
366 | boxOffset = boxOffset - ((BoxSize - height())/2) ; | 366 | boxOffset = boxOffset - ((BoxSize - height())/2) ; |
367 | // qDebug("boxOffset %d height %d", boxOffset, height() ); | 367 | // qDebug("boxOffset %d height %d", boxOffset, height() ); |
368 | BoxSize = height(); | 368 | BoxSize = height(); |
369 | 369 | ||
370 | } | 370 | } |
371 | //bool winStyle = lv->style() == WindowsStyle; | 371 | //bool winStyle = lv->style() == WindowsStyle; |
372 | 372 | ||
373 | int lineStart = 5; | 373 | int lineStart = 5; |
374 | if ( myType == Controller ) { | 374 | if ( myType == Controller ) { |
375 | if ( !pixmap( 0 ) ) | 375 | if ( !pixmap( 0 ) ) |
376 | r += BoxSize + 4; | 376 | r += BoxSize + 4; |
377 | } else { | 377 | } else { |
378 | ASSERT( lv ); //### | 378 | ASSERT( lv ); //### |
379 | //QFontMetrics fm( lv->font() ); | 379 | //QFontMetrics fm( lv->font() ); |
380 | //int d = fm.height(); | 380 | //int d = fm.height(); |
381 | int x = 0; | 381 | int x = 0; |
382 | int y = (height() - BoxSize) / 2; | 382 | int y = (height() - BoxSize) / 2; |
383 | //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); | 383 | //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); |
384 | if ( myType == CheckBox ) { | 384 | if ( myType == CheckBox ) { |
385 | if ( isEnabled() ) | 385 | if ( isEnabled() ) |
386 | p->setPen( QPen( _cg.text(), 1 ) ); | 386 | p->setPen( QPen( _cg.text(), 1 ) ); |
387 | else | 387 | else |
388 | p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); | 388 | p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); |
389 | p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); | 389 | p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); |
390 | lineStart = x+marg; | 390 | lineStart = x+marg; |
391 | ///////////////////// | 391 | ///////////////////// |
392 | x++; | 392 | x++; |
393 | y++; | 393 | y++; |
394 | if ( isOn() ) { | 394 | if ( isOn() ) { |
395 | QPointArray a( 7*2 ); | 395 | QPointArray a( 7*2 ); |
396 | int i, xx, yy; | 396 | int i, xx, yy; |
397 | xx = x+xOffset+marg+(boxOffset/2); | 397 | xx = x+xOffset+marg+(boxOffset/2); |
398 | yy = y+5+boxOffset; | 398 | yy = y+5+boxOffset; |
399 | for ( i=0; i<3; i++ ) { | 399 | for ( i=0; i<3; i++ ) { |
400 | a.setPoint( 2*i, xx, yy ); | 400 | a.setPoint( 2*i, xx, yy ); |
401 | a.setPoint( 2*i+1, xx, yy+2 ); | 401 | a.setPoint( 2*i+1, xx, yy+2 ); |
402 | // qDebug(" "); | 402 | // qDebug(" "); |
403 | xx++; yy++; | 403 | xx++; yy++; |
404 | } | 404 | } |
405 | yy -= 2; | 405 | yy -= 2; |
406 | for ( i=3; i<7; i++ ) { | 406 | for ( i=3; i<7; i++ ) { |
407 | a.setPoint( 2*i, xx, yy ); | 407 | a.setPoint( 2*i, xx, yy ); |
408 | a.setPoint( 2*i+1, xx, yy+2 ); | 408 | a.setPoint( 2*i+1, xx, yy+2 ); |
409 | xx++; yy--; | 409 | xx++; yy--; |
410 | } | 410 | } |
411 | p->setPen( darkGreen ); | 411 | p->setPen( darkGreen ); |
412 | p->drawLineSegments( a ); | 412 | p->drawLineSegments( a ); |
413 | } | 413 | } |
414 | //////////////////////// | 414 | //////////////////////// |
415 | } | 415 | } |
416 | r += BoxSize + 4; | 416 | r += BoxSize + 4; |
417 | } | 417 | } |
418 | 418 | ||
419 | p->translate( r, 0 ); | 419 | p->translate( r, 0 ); |
420 | p->setPen( QPen( _cg.text() ) ); | 420 | p->setPen( QPen( _cg.text() ) ); |
421 | QListViewItem::paintCell( p, _cg, column, width - r, align ); | 421 | QListViewItem::paintCell( p, _cg, column, width - r, align ); |
422 | if ( mTodo->cancelled () ) { | 422 | if ( mTodo->cancelled () ) { |
423 | p->setPen( black ); | 423 | p->setPen( black ); |
424 | QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); | 424 | QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); |
425 | int wid = br.width() +lineStart; | 425 | int wid = br.width() +lineStart; |
426 | if ( wid > width-3 ) | 426 | if ( wid > width-3 ) |
427 | wid = width-3; | 427 | wid = width-3; |
428 | p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); | 428 | p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); |
429 | 429 | ||
430 | } | 430 | } |
431 | 431 | ||
432 | } | 432 | } |