author | zautrix <zautrix> | 2005-01-18 09:54:32 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-18 09:54:32 (UTC) |
commit | f973a8310cc378cc86d96bfce3f08f06725a2b7d (patch) (unidiff) | |
tree | d5ebdc5193972a99d5c5cbd7957894a41dcd5d67 | |
parent | 2d6776d79732f6771885a549de5c37f9e75f7641 (diff) | |
download | kdepimpi-f973a8310cc378cc86d96bfce3f08f06725a2b7d.zip kdepimpi-f973a8310cc378cc86d96bfce3f08f06725a2b7d.tar.gz kdepimpi-f973a8310cc378cc86d96bfce3f08f06725a2b7d.tar.bz2 |
fix
-rw-r--r-- | korganizer/calendarview.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index da1edea..9c10ba6 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1743,1550 +1743,1552 @@ bool CalendarView::saveCalendar( QString filename ) | |||
1743 | mViewManager->currentView()->flushView(); | 1743 | mViewManager->currentView()->flushView(); |
1744 | 1744 | ||
1745 | 1745 | ||
1746 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1746 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1747 | mStorage->setSaveFormat( new ICalFormat() ); | 1747 | mStorage->setSaveFormat( new ICalFormat() ); |
1748 | mStorage->setFileName( filename ); | 1748 | mStorage->setFileName( filename ); |
1749 | bool success; | 1749 | bool success; |
1750 | success = mStorage->save(); | 1750 | success = mStorage->save(); |
1751 | if ( !success ) { | 1751 | if ( !success ) { |
1752 | return false; | 1752 | return false; |
1753 | } | 1753 | } |
1754 | if ( filename == MainWindow::defaultFileName() ) { | 1754 | if ( filename == MainWindow::defaultFileName() ) { |
1755 | setLoadedFileVersion( lfv ); | 1755 | setLoadedFileVersion( lfv ); |
1756 | watchSavedFile(); | 1756 | watchSavedFile(); |
1757 | } | 1757 | } |
1758 | return true; | 1758 | return true; |
1759 | } | 1759 | } |
1760 | 1760 | ||
1761 | void CalendarView::closeCalendar() | 1761 | void CalendarView::closeCalendar() |
1762 | { | 1762 | { |
1763 | 1763 | ||
1764 | // child windows no longer valid | 1764 | // child windows no longer valid |
1765 | emit closingDown(); | 1765 | emit closingDown(); |
1766 | 1766 | ||
1767 | mCalendar->close(); | 1767 | mCalendar->close(); |
1768 | setModified(false); | 1768 | setModified(false); |
1769 | updateView(); | 1769 | updateView(); |
1770 | } | 1770 | } |
1771 | 1771 | ||
1772 | void CalendarView::archiveCalendar() | 1772 | void CalendarView::archiveCalendar() |
1773 | { | 1773 | { |
1774 | mDialogManager->showArchiveDialog(); | 1774 | mDialogManager->showArchiveDialog(); |
1775 | } | 1775 | } |
1776 | 1776 | ||
1777 | 1777 | ||
1778 | void CalendarView::readSettings() | 1778 | void CalendarView::readSettings() |
1779 | { | 1779 | { |
1780 | 1780 | ||
1781 | 1781 | ||
1782 | // mViewManager->showAgendaView(); | 1782 | // mViewManager->showAgendaView(); |
1783 | QString str; | 1783 | QString str; |
1784 | //qDebug("CalendarView::readSettings() "); | 1784 | //qDebug("CalendarView::readSettings() "); |
1785 | // read settings from the KConfig, supplying reasonable | 1785 | // read settings from the KConfig, supplying reasonable |
1786 | // defaults where none are to be found | 1786 | // defaults where none are to be found |
1787 | KConfig *config = KOGlobals::config(); | 1787 | KConfig *config = KOGlobals::config(); |
1788 | #ifndef KORG_NOSPLITTER | 1788 | #ifndef KORG_NOSPLITTER |
1789 | config->setGroup("KOrganizer Geometry"); | 1789 | config->setGroup("KOrganizer Geometry"); |
1790 | 1790 | ||
1791 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1791 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1792 | if (sizes.count() != 2) { | 1792 | if (sizes.count() != 2) { |
1793 | sizes << mDateNavigator->minimumSizeHint().width(); | 1793 | sizes << mDateNavigator->minimumSizeHint().width(); |
1794 | sizes << 300; | 1794 | sizes << 300; |
1795 | } | 1795 | } |
1796 | mPanner->setSizes(sizes); | 1796 | mPanner->setSizes(sizes); |
1797 | 1797 | ||
1798 | sizes = config->readIntListEntry("Separator2"); | 1798 | sizes = config->readIntListEntry("Separator2"); |
1799 | if ( ( mResourceView && sizes.count() == 4 ) || | 1799 | if ( ( mResourceView && sizes.count() == 4 ) || |
1800 | ( !mResourceView && sizes.count() == 3 ) ) { | 1800 | ( !mResourceView && sizes.count() == 3 ) ) { |
1801 | mLeftSplitter->setSizes(sizes); | 1801 | mLeftSplitter->setSizes(sizes); |
1802 | } | 1802 | } |
1803 | #endif | 1803 | #endif |
1804 | globalFlagBlockAgenda = 1; | 1804 | globalFlagBlockAgenda = 1; |
1805 | mViewManager->showAgendaView(); | 1805 | mViewManager->showAgendaView(); |
1806 | //mViewManager->readSettings( config ); | 1806 | //mViewManager->readSettings( config ); |
1807 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1807 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1808 | readFilterSettings(config); | 1808 | readFilterSettings(config); |
1809 | config->setGroup( "Views" ); | 1809 | config->setGroup( "Views" ); |
1810 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1810 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1811 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1811 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1812 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1812 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1813 | else mNavigator->selectDates( dateCount ); | 1813 | else mNavigator->selectDates( dateCount ); |
1814 | // mViewManager->readSettings( config ); | 1814 | // mViewManager->readSettings( config ); |
1815 | updateConfig(); | 1815 | updateConfig(); |
1816 | globalFlagBlockAgenda = 2; | 1816 | globalFlagBlockAgenda = 2; |
1817 | mViewManager->readSettings( config ); | 1817 | mViewManager->readSettings( config ); |
1818 | #ifdef DESKTOP_VERSION | 1818 | #ifdef DESKTOP_VERSION |
1819 | config->setGroup("WidgetLayout"); | 1819 | config->setGroup("WidgetLayout"); |
1820 | QStringList list; | 1820 | QStringList list; |
1821 | list = config->readListEntry("MainLayout"); | 1821 | list = config->readListEntry("MainLayout"); |
1822 | int x,y,w,h; | 1822 | int x,y,w,h; |
1823 | if ( ! list.isEmpty() ) { | 1823 | if ( ! list.isEmpty() ) { |
1824 | x = list[0].toInt(); | 1824 | x = list[0].toInt(); |
1825 | y = list[1].toInt(); | 1825 | y = list[1].toInt(); |
1826 | w = list[2].toInt(); | 1826 | w = list[2].toInt(); |
1827 | h = list[3].toInt(); | 1827 | h = list[3].toInt(); |
1828 | topLevelWidget()->setGeometry(x,y,w,h); | 1828 | topLevelWidget()->setGeometry(x,y,w,h); |
1829 | 1829 | ||
1830 | } else { | 1830 | } else { |
1831 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1831 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1832 | } | 1832 | } |
1833 | list = config->readListEntry("EditEventLayout"); | 1833 | list = config->readListEntry("EditEventLayout"); |
1834 | if ( ! list.isEmpty() ) { | 1834 | if ( ! list.isEmpty() ) { |
1835 | x = list[0].toInt(); | 1835 | x = list[0].toInt(); |
1836 | y = list[1].toInt(); | 1836 | y = list[1].toInt(); |
1837 | w = list[2].toInt(); | 1837 | w = list[2].toInt(); |
1838 | h = list[3].toInt(); | 1838 | h = list[3].toInt(); |
1839 | mEventEditor->setGeometry(x,y,w,h); | 1839 | mEventEditor->setGeometry(x,y,w,h); |
1840 | 1840 | ||
1841 | } | 1841 | } |
1842 | list = config->readListEntry("EditTodoLayout"); | 1842 | list = config->readListEntry("EditTodoLayout"); |
1843 | if ( ! list.isEmpty() ) { | 1843 | if ( ! list.isEmpty() ) { |
1844 | x = list[0].toInt(); | 1844 | x = list[0].toInt(); |
1845 | y = list[1].toInt(); | 1845 | y = list[1].toInt(); |
1846 | w = list[2].toInt(); | 1846 | w = list[2].toInt(); |
1847 | h = list[3].toInt(); | 1847 | h = list[3].toInt(); |
1848 | mTodoEditor->setGeometry(x,y,w,h); | 1848 | mTodoEditor->setGeometry(x,y,w,h); |
1849 | 1849 | ||
1850 | } | 1850 | } |
1851 | list = config->readListEntry("ViewerLayout"); | 1851 | list = config->readListEntry("ViewerLayout"); |
1852 | if ( ! list.isEmpty() ) { | 1852 | if ( ! list.isEmpty() ) { |
1853 | x = list[0].toInt(); | 1853 | x = list[0].toInt(); |
1854 | y = list[1].toInt(); | 1854 | y = list[1].toInt(); |
1855 | w = list[2].toInt(); | 1855 | w = list[2].toInt(); |
1856 | h = list[3].toInt(); | 1856 | h = list[3].toInt(); |
1857 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1857 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1858 | } | 1858 | } |
1859 | #endif | 1859 | #endif |
1860 | 1860 | ||
1861 | } | 1861 | } |
1862 | 1862 | ||
1863 | 1863 | ||
1864 | void CalendarView::writeSettings() | 1864 | void CalendarView::writeSettings() |
1865 | { | 1865 | { |
1866 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1866 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1867 | 1867 | ||
1868 | KConfig *config = KOGlobals::config(); | 1868 | KConfig *config = KOGlobals::config(); |
1869 | 1869 | ||
1870 | #ifndef KORG_NOSPLITTER | 1870 | #ifndef KORG_NOSPLITTER |
1871 | config->setGroup("KOrganizer Geometry"); | 1871 | config->setGroup("KOrganizer Geometry"); |
1872 | 1872 | ||
1873 | QValueList<int> list = mPanner->sizes(); | 1873 | QValueList<int> list = mPanner->sizes(); |
1874 | config->writeEntry("Separator1",list); | 1874 | config->writeEntry("Separator1",list); |
1875 | 1875 | ||
1876 | list = mLeftSplitter->sizes(); | 1876 | list = mLeftSplitter->sizes(); |
1877 | config->writeEntry("Separator2",list); | 1877 | config->writeEntry("Separator2",list); |
1878 | #endif | 1878 | #endif |
1879 | 1879 | ||
1880 | mViewManager->writeSettings( config ); | 1880 | mViewManager->writeSettings( config ); |
1881 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1881 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1882 | mDialogManager->writeSettings( config ); | 1882 | mDialogManager->writeSettings( config ); |
1883 | //KOPrefs::instance()->usrWriteConfig(); | 1883 | //KOPrefs::instance()->usrWriteConfig(); |
1884 | KOPrefs::instance()->writeConfig(); | 1884 | KOPrefs::instance()->writeConfig(); |
1885 | 1885 | ||
1886 | writeFilterSettings(config); | 1886 | writeFilterSettings(config); |
1887 | 1887 | ||
1888 | config->setGroup( "Views" ); | 1888 | config->setGroup( "Views" ); |
1889 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1889 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1890 | 1890 | ||
1891 | #ifdef DESKTOP_VERSION | 1891 | #ifdef DESKTOP_VERSION |
1892 | config->setGroup("WidgetLayout"); | 1892 | config->setGroup("WidgetLayout"); |
1893 | QStringList list ;//= config->readListEntry("MainLayout"); | 1893 | QStringList list ;//= config->readListEntry("MainLayout"); |
1894 | int x,y,w,h; | 1894 | int x,y,w,h; |
1895 | QWidget* wid; | 1895 | QWidget* wid; |
1896 | wid = topLevelWidget(); | 1896 | wid = topLevelWidget(); |
1897 | x = wid->geometry().x(); | 1897 | x = wid->geometry().x(); |
1898 | y = wid->geometry().y(); | 1898 | y = wid->geometry().y(); |
1899 | w = wid->width(); | 1899 | w = wid->width(); |
1900 | h = wid->height(); | 1900 | h = wid->height(); |
1901 | list.clear(); | 1901 | list.clear(); |
1902 | list << QString::number( x ); | 1902 | list << QString::number( x ); |
1903 | list << QString::number( y ); | 1903 | list << QString::number( y ); |
1904 | list << QString::number( w ); | 1904 | list << QString::number( w ); |
1905 | list << QString::number( h ); | 1905 | list << QString::number( h ); |
1906 | config->writeEntry("MainLayout",list ); | 1906 | config->writeEntry("MainLayout",list ); |
1907 | 1907 | ||
1908 | wid = mEventEditor; | 1908 | wid = mEventEditor; |
1909 | x = wid->geometry().x(); | 1909 | x = wid->geometry().x(); |
1910 | y = wid->geometry().y(); | 1910 | y = wid->geometry().y(); |
1911 | w = wid->width(); | 1911 | w = wid->width(); |
1912 | h = wid->height(); | 1912 | h = wid->height(); |
1913 | list.clear(); | 1913 | list.clear(); |
1914 | list << QString::number( x ); | 1914 | list << QString::number( x ); |
1915 | list << QString::number( y ); | 1915 | list << QString::number( y ); |
1916 | list << QString::number( w ); | 1916 | list << QString::number( w ); |
1917 | list << QString::number( h ); | 1917 | list << QString::number( h ); |
1918 | config->writeEntry("EditEventLayout",list ); | 1918 | config->writeEntry("EditEventLayout",list ); |
1919 | 1919 | ||
1920 | wid = mTodoEditor; | 1920 | wid = mTodoEditor; |
1921 | x = wid->geometry().x(); | 1921 | x = wid->geometry().x(); |
1922 | y = wid->geometry().y(); | 1922 | y = wid->geometry().y(); |
1923 | w = wid->width(); | 1923 | w = wid->width(); |
1924 | h = wid->height(); | 1924 | h = wid->height(); |
1925 | list.clear(); | 1925 | list.clear(); |
1926 | list << QString::number( x ); | 1926 | list << QString::number( x ); |
1927 | list << QString::number( y ); | 1927 | list << QString::number( y ); |
1928 | list << QString::number( w ); | 1928 | list << QString::number( w ); |
1929 | list << QString::number( h ); | 1929 | list << QString::number( h ); |
1930 | config->writeEntry("EditTodoLayout",list ); | 1930 | config->writeEntry("EditTodoLayout",list ); |
1931 | wid = getEventViewerDialog(); | 1931 | wid = getEventViewerDialog(); |
1932 | x = wid->geometry().x(); | 1932 | x = wid->geometry().x(); |
1933 | y = wid->geometry().y(); | 1933 | y = wid->geometry().y(); |
1934 | w = wid->width(); | 1934 | w = wid->width(); |
1935 | h = wid->height(); | 1935 | h = wid->height(); |
1936 | list.clear(); | 1936 | list.clear(); |
1937 | list << QString::number( x ); | 1937 | list << QString::number( x ); |
1938 | list << QString::number( y ); | 1938 | list << QString::number( y ); |
1939 | list << QString::number( w ); | 1939 | list << QString::number( w ); |
1940 | list << QString::number( h ); | 1940 | list << QString::number( h ); |
1941 | config->writeEntry("ViewerLayout",list ); | 1941 | config->writeEntry("ViewerLayout",list ); |
1942 | wid = mDialogManager->getSearchDialog(); | 1942 | wid = mDialogManager->getSearchDialog(); |
1943 | if ( wid ) { | 1943 | if ( wid ) { |
1944 | x = wid->geometry().x(); | 1944 | x = wid->geometry().x(); |
1945 | y = wid->geometry().y(); | 1945 | y = wid->geometry().y(); |
1946 | w = wid->width(); | 1946 | w = wid->width(); |
1947 | h = wid->height(); | 1947 | h = wid->height(); |
1948 | list.clear(); | 1948 | list.clear(); |
1949 | list << QString::number( x ); | 1949 | list << QString::number( x ); |
1950 | list << QString::number( y ); | 1950 | list << QString::number( y ); |
1951 | list << QString::number( w ); | 1951 | list << QString::number( w ); |
1952 | list << QString::number( h ); | 1952 | list << QString::number( h ); |
1953 | config->writeEntry("SearchLayout",list ); | 1953 | config->writeEntry("SearchLayout",list ); |
1954 | } | 1954 | } |
1955 | #endif | 1955 | #endif |
1956 | 1956 | ||
1957 | 1957 | ||
1958 | config->sync(); | 1958 | config->sync(); |
1959 | } | 1959 | } |
1960 | 1960 | ||
1961 | void CalendarView::readFilterSettings(KConfig *config) | 1961 | void CalendarView::readFilterSettings(KConfig *config) |
1962 | { | 1962 | { |
1963 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1963 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1964 | 1964 | ||
1965 | mFilters.clear(); | 1965 | mFilters.clear(); |
1966 | 1966 | ||
1967 | config->setGroup("General"); | 1967 | config->setGroup("General"); |
1968 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1968 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1969 | 1969 | ||
1970 | QStringList::ConstIterator it = filterList.begin(); | 1970 | QStringList::ConstIterator it = filterList.begin(); |
1971 | QStringList::ConstIterator end = filterList.end(); | 1971 | QStringList::ConstIterator end = filterList.end(); |
1972 | while(it != end) { | 1972 | while(it != end) { |
1973 | // kdDebug() << " filter: " << (*it) << endl; | 1973 | // kdDebug() << " filter: " << (*it) << endl; |
1974 | 1974 | ||
1975 | CalFilter *filter; | 1975 | CalFilter *filter; |
1976 | filter = new CalFilter(*it); | 1976 | filter = new CalFilter(*it); |
1977 | config->setGroup("Filter_" + (*it)); | 1977 | config->setGroup("Filter_" + (*it)); |
1978 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1978 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1979 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1979 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1980 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1980 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1981 | mFilters.append(filter); | 1981 | mFilters.append(filter); |
1982 | 1982 | ||
1983 | ++it; | 1983 | ++it; |
1984 | } | 1984 | } |
1985 | 1985 | ||
1986 | if (mFilters.count() == 0) { | 1986 | if (mFilters.count() == 0) { |
1987 | CalFilter *filter = new CalFilter(i18n("Default")); | 1987 | CalFilter *filter = new CalFilter(i18n("Default")); |
1988 | mFilters.append(filter); | 1988 | mFilters.append(filter); |
1989 | } | 1989 | } |
1990 | mFilterView->updateFilters(); | 1990 | mFilterView->updateFilters(); |
1991 | config->setGroup("FilterView"); | 1991 | config->setGroup("FilterView"); |
1992 | 1992 | ||
1993 | mFilterView->blockSignals(true); | 1993 | mFilterView->blockSignals(true); |
1994 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1994 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1995 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1995 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1996 | mFilterView->blockSignals(false); | 1996 | mFilterView->blockSignals(false); |
1997 | // We do it manually to avoid it being done twice by the above calls | 1997 | // We do it manually to avoid it being done twice by the above calls |
1998 | updateFilter(); | 1998 | updateFilter(); |
1999 | } | 1999 | } |
2000 | 2000 | ||
2001 | void CalendarView::writeFilterSettings(KConfig *config) | 2001 | void CalendarView::writeFilterSettings(KConfig *config) |
2002 | { | 2002 | { |
2003 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2003 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2004 | 2004 | ||
2005 | QStringList filterList; | 2005 | QStringList filterList; |
2006 | 2006 | ||
2007 | CalFilter *filter = mFilters.first(); | 2007 | CalFilter *filter = mFilters.first(); |
2008 | while(filter) { | 2008 | while(filter) { |
2009 | // kdDebug() << " fn: " << filter->name() << endl; | 2009 | // kdDebug() << " fn: " << filter->name() << endl; |
2010 | filterList << filter->name(); | 2010 | filterList << filter->name(); |
2011 | config->setGroup("Filter_" + filter->name()); | 2011 | config->setGroup("Filter_" + filter->name()); |
2012 | config->writeEntry("Criteria",filter->criteria()); | 2012 | config->writeEntry("Criteria",filter->criteria()); |
2013 | config->writeEntry("CategoryList",filter->categoryList()); | 2013 | config->writeEntry("CategoryList",filter->categoryList()); |
2014 | filter = mFilters.next(); | 2014 | filter = mFilters.next(); |
2015 | } | 2015 | } |
2016 | config->setGroup("General"); | 2016 | config->setGroup("General"); |
2017 | config->writeEntry("CalendarFilters",filterList); | 2017 | config->writeEntry("CalendarFilters",filterList); |
2018 | 2018 | ||
2019 | config->setGroup("FilterView"); | 2019 | config->setGroup("FilterView"); |
2020 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2020 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2021 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2021 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2022 | } | 2022 | } |
2023 | 2023 | ||
2024 | 2024 | ||
2025 | void CalendarView::goToday() | 2025 | void CalendarView::goToday() |
2026 | { | 2026 | { |
2027 | if ( mViewManager->currentView()->isMonthView() ) | 2027 | if ( mViewManager->currentView()->isMonthView() ) |
2028 | mNavigator->selectTodayMonth(); | 2028 | mNavigator->selectTodayMonth(); |
2029 | else | 2029 | else |
2030 | mNavigator->selectToday(); | 2030 | mNavigator->selectToday(); |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | void CalendarView::goNext() | 2033 | void CalendarView::goNext() |
2034 | { | 2034 | { |
2035 | mNavigator->selectNext(); | 2035 | mNavigator->selectNext(); |
2036 | } | 2036 | } |
2037 | 2037 | ||
2038 | void CalendarView::goPrevious() | 2038 | void CalendarView::goPrevious() |
2039 | { | 2039 | { |
2040 | mNavigator->selectPrevious(); | 2040 | mNavigator->selectPrevious(); |
2041 | } | 2041 | } |
2042 | void CalendarView::goNextMonth() | 2042 | void CalendarView::goNextMonth() |
2043 | { | 2043 | { |
2044 | mNavigator->selectNextMonth(); | 2044 | mNavigator->selectNextMonth(); |
2045 | } | 2045 | } |
2046 | 2046 | ||
2047 | void CalendarView::goPreviousMonth() | 2047 | void CalendarView::goPreviousMonth() |
2048 | { | 2048 | { |
2049 | mNavigator->selectPreviousMonth(); | 2049 | mNavigator->selectPreviousMonth(); |
2050 | } | 2050 | } |
2051 | void CalendarView::writeLocale() | 2051 | void CalendarView::writeLocale() |
2052 | { | 2052 | { |
2053 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2053 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2054 | #if 0 | 2054 | #if 0 |
2055 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2055 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2056 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2056 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2057 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2057 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2058 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2058 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2059 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2059 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2060 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2060 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2061 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2061 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2062 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2062 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2063 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2063 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2064 | KOPrefs::instance()->mDaylightsavingStart, | 2064 | KOPrefs::instance()->mDaylightsavingStart, |
2065 | KOPrefs::instance()->mDaylightsavingEnd ); | 2065 | KOPrefs::instance()->mDaylightsavingEnd ); |
2066 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2066 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2067 | #endif | 2067 | #endif |
2068 | } | 2068 | } |
2069 | void CalendarView::updateConfig() | 2069 | void CalendarView::updateConfig() |
2070 | { | 2070 | { |
2071 | writeLocale(); | 2071 | writeLocale(); |
2072 | if ( KOPrefs::instance()->mUseAppColors ) | 2072 | if ( KOPrefs::instance()->mUseAppColors ) |
2073 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2073 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2074 | emit configChanged(); | 2074 | emit configChanged(); |
2075 | mTodoList->updateConfig(); | 2075 | mTodoList->updateConfig(); |
2076 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2076 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2077 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2077 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2078 | // To make the "fill window" configurations work | 2078 | // To make the "fill window" configurations work |
2079 | //mViewManager->raiseCurrentView(); | 2079 | //mViewManager->raiseCurrentView(); |
2080 | } | 2080 | } |
2081 | 2081 | ||
2082 | 2082 | ||
2083 | void CalendarView::eventChanged(Event *event) | 2083 | void CalendarView::eventChanged(Event *event) |
2084 | { | 2084 | { |
2085 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2085 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2086 | //updateUnmanagedViews(); | 2086 | //updateUnmanagedViews(); |
2087 | } | 2087 | } |
2088 | 2088 | ||
2089 | void CalendarView::eventAdded(Event *event) | 2089 | void CalendarView::eventAdded(Event *event) |
2090 | { | 2090 | { |
2091 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2091 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2092 | } | 2092 | } |
2093 | 2093 | ||
2094 | void CalendarView::eventToBeDeleted(Event *) | 2094 | void CalendarView::eventToBeDeleted(Event *) |
2095 | { | 2095 | { |
2096 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2096 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2097 | } | 2097 | } |
2098 | 2098 | ||
2099 | void CalendarView::eventDeleted() | 2099 | void CalendarView::eventDeleted() |
2100 | { | 2100 | { |
2101 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2101 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2102 | } | 2102 | } |
2103 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2103 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2104 | { | 2104 | { |
2105 | changeIncidenceDisplay((Incidence *)which, action); | 2105 | changeIncidenceDisplay((Incidence *)which, action); |
2106 | mDateNavigator->updateView(); //LR | 2106 | mDateNavigator->updateView(); //LR |
2107 | //mDialogManager->updateSearchDialog(); | 2107 | //mDialogManager->updateSearchDialog(); |
2108 | 2108 | ||
2109 | if (which) { | 2109 | if (which) { |
2110 | mViewManager->updateWNview(); | 2110 | mViewManager->updateWNview(); |
2111 | //mTodoList->updateView(); | 2111 | //mTodoList->updateView(); |
2112 | } | 2112 | } |
2113 | 2113 | ||
2114 | } | 2114 | } |
2115 | 2115 | ||
2116 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2116 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2117 | { | 2117 | { |
2118 | updateUnmanagedViews(); | 2118 | updateUnmanagedViews(); |
2119 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2119 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2120 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2120 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2121 | mCalendar->checkAlarmForIncidence( 0, true ); | 2121 | mCalendar->checkAlarmForIncidence( 0, true ); |
2122 | if ( mEventViewerDialog ) | 2122 | if ( mEventViewerDialog ) |
2123 | mEventViewerDialog->hide(); | 2123 | mEventViewerDialog->hide(); |
2124 | } | 2124 | } |
2125 | else | 2125 | else |
2126 | mCalendar->checkAlarmForIncidence( which , false ); | 2126 | mCalendar->checkAlarmForIncidence( which , false ); |
2127 | } | 2127 | } |
2128 | 2128 | ||
2129 | // most of the changeEventDisplays() right now just call the view's | 2129 | // most of the changeEventDisplays() right now just call the view's |
2130 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2130 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2131 | void CalendarView::changeEventDisplay(Event *which, int action) | 2131 | void CalendarView::changeEventDisplay(Event *which, int action) |
2132 | { | 2132 | { |
2133 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2133 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2134 | changeIncidenceDisplay((Incidence *)which, action); | 2134 | changeIncidenceDisplay((Incidence *)which, action); |
2135 | mDateNavigator->updateView(); | 2135 | mDateNavigator->updateView(); |
2136 | //mDialogManager->updateSearchDialog(); | 2136 | //mDialogManager->updateSearchDialog(); |
2137 | 2137 | ||
2138 | if (which) { | 2138 | if (which) { |
2139 | // If there is an event view visible update the display | 2139 | // If there is an event view visible update the display |
2140 | mViewManager->currentView()->changeEventDisplay(which,action); | 2140 | mViewManager->currentView()->changeEventDisplay(which,action); |
2141 | // TODO: check, if update needed | 2141 | // TODO: check, if update needed |
2142 | // if (which->getTodoStatus()) { | 2142 | // if (which->getTodoStatus()) { |
2143 | mTodoList->updateView(); | 2143 | mTodoList->updateView(); |
2144 | // } | 2144 | // } |
2145 | } else { | 2145 | } else { |
2146 | mViewManager->currentView()->updateView(); | 2146 | mViewManager->currentView()->updateView(); |
2147 | } | 2147 | } |
2148 | } | 2148 | } |
2149 | 2149 | ||
2150 | 2150 | ||
2151 | void CalendarView::updateTodoViews() | 2151 | void CalendarView::updateTodoViews() |
2152 | { | 2152 | { |
2153 | 2153 | ||
2154 | mTodoList->updateView(); | 2154 | mTodoList->updateView(); |
2155 | mViewManager->currentView()->updateView(); | 2155 | mViewManager->currentView()->updateView(); |
2156 | 2156 | ||
2157 | } | 2157 | } |
2158 | 2158 | ||
2159 | 2159 | ||
2160 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2160 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2161 | { | 2161 | { |
2162 | mTodoList->updateView(); | 2162 | mTodoList->updateView(); |
2163 | mViewManager->updateView(start, end); | 2163 | mViewManager->updateView(start, end); |
2164 | //mDateNavigator->updateView(); | 2164 | //mDateNavigator->updateView(); |
2165 | } | 2165 | } |
2166 | 2166 | ||
2167 | void CalendarView::updateView() | 2167 | void CalendarView::updateView() |
2168 | { | 2168 | { |
2169 | DateList tmpList = mNavigator->selectedDates(); | 2169 | DateList tmpList = mNavigator->selectedDates(); |
2170 | 2170 | ||
2171 | // We assume that the navigator only selects consecutive days. | 2171 | // We assume that the navigator only selects consecutive days. |
2172 | updateView( tmpList.first(), tmpList.last() ); | 2172 | updateView( tmpList.first(), tmpList.last() ); |
2173 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2173 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2174 | mTodoList->updateView(); | 2174 | mTodoList->updateView(); |
2175 | } | 2175 | } |
2176 | 2176 | ||
2177 | void CalendarView::updateUnmanagedViews() | 2177 | void CalendarView::updateUnmanagedViews() |
2178 | { | 2178 | { |
2179 | mDateNavigator->updateDayMatrix(); | 2179 | mDateNavigator->updateDayMatrix(); |
2180 | } | 2180 | } |
2181 | 2181 | ||
2182 | int CalendarView::msgItemDelete() | 2182 | int CalendarView::msgItemDelete() |
2183 | { | 2183 | { |
2184 | return KMessageBox::warningContinueCancel(this, | 2184 | return KMessageBox::warningContinueCancel(this, |
2185 | i18n("This item will be\npermanently deleted."), | 2185 | i18n("This item will be\npermanently deleted."), |
2186 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2186 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2187 | } | 2187 | } |
2188 | 2188 | ||
2189 | 2189 | ||
2190 | void CalendarView::edit_cut() | 2190 | void CalendarView::edit_cut() |
2191 | { | 2191 | { |
2192 | Event *anEvent=0; | 2192 | Event *anEvent=0; |
2193 | 2193 | ||
2194 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2194 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2195 | 2195 | ||
2196 | if (mViewManager->currentView()->isEventView()) { | 2196 | if (mViewManager->currentView()->isEventView()) { |
2197 | if ( incidence && incidence->type() == "Event" ) { | 2197 | if ( incidence && incidence->type() == "Event" ) { |
2198 | anEvent = static_cast<Event *>(incidence); | 2198 | anEvent = static_cast<Event *>(incidence); |
2199 | } | 2199 | } |
2200 | } | 2200 | } |
2201 | 2201 | ||
2202 | if (!anEvent) { | 2202 | if (!anEvent) { |
2203 | KNotifyClient::beep(); | 2203 | KNotifyClient::beep(); |
2204 | return; | 2204 | return; |
2205 | } | 2205 | } |
2206 | DndFactory factory( mCalendar ); | 2206 | DndFactory factory( mCalendar ); |
2207 | factory.cutEvent(anEvent); | 2207 | factory.cutEvent(anEvent); |
2208 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2208 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | void CalendarView::edit_copy() | 2211 | void CalendarView::edit_copy() |
2212 | { | 2212 | { |
2213 | Event *anEvent=0; | 2213 | Event *anEvent=0; |
2214 | 2214 | ||
2215 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2215 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2216 | 2216 | ||
2217 | if (mViewManager->currentView()->isEventView()) { | 2217 | if (mViewManager->currentView()->isEventView()) { |
2218 | if ( incidence && incidence->type() == "Event" ) { | 2218 | if ( incidence && incidence->type() == "Event" ) { |
2219 | anEvent = static_cast<Event *>(incidence); | 2219 | anEvent = static_cast<Event *>(incidence); |
2220 | } | 2220 | } |
2221 | } | 2221 | } |
2222 | 2222 | ||
2223 | if (!anEvent) { | 2223 | if (!anEvent) { |
2224 | KNotifyClient::beep(); | 2224 | KNotifyClient::beep(); |
2225 | return; | 2225 | return; |
2226 | } | 2226 | } |
2227 | DndFactory factory( mCalendar ); | 2227 | DndFactory factory( mCalendar ); |
2228 | factory.copyEvent(anEvent); | 2228 | factory.copyEvent(anEvent); |
2229 | } | 2229 | } |
2230 | 2230 | ||
2231 | void CalendarView::edit_paste() | 2231 | void CalendarView::edit_paste() |
2232 | { | 2232 | { |
2233 | QDate date = mNavigator->selectedDates().first(); | 2233 | QDate date = mNavigator->selectedDates().first(); |
2234 | 2234 | ||
2235 | DndFactory factory( mCalendar ); | 2235 | DndFactory factory( mCalendar ); |
2236 | Event *pastedEvent = factory.pasteEvent( date ); | 2236 | Event *pastedEvent = factory.pasteEvent( date ); |
2237 | 2237 | ||
2238 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2238 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | void CalendarView::edit_options() | 2241 | void CalendarView::edit_options() |
2242 | { | 2242 | { |
2243 | mDialogManager->showOptionsDialog(); | 2243 | mDialogManager->showOptionsDialog(); |
2244 | //writeSettings(); | 2244 | //writeSettings(); |
2245 | } | 2245 | } |
2246 | 2246 | ||
2247 | 2247 | ||
2248 | void CalendarView::slotSelectPickerDate( QDate d) | 2248 | void CalendarView::slotSelectPickerDate( QDate d) |
2249 | { | 2249 | { |
2250 | mDateFrame->hide(); | 2250 | mDateFrame->hide(); |
2251 | if ( mDatePickerMode == 1 ) { | 2251 | if ( mDatePickerMode == 1 ) { |
2252 | mNavigator->slotDaySelect( d ); | 2252 | mNavigator->slotDaySelect( d ); |
2253 | } else if ( mDatePickerMode == 2 ) { | 2253 | } else if ( mDatePickerMode == 2 ) { |
2254 | if ( mMoveIncidence->type() == "Todo" ) { | 2254 | if ( mMoveIncidence->type() == "Todo" ) { |
2255 | Todo * to = (Todo *) mMoveIncidence; | 2255 | Todo * to = (Todo *) mMoveIncidence; |
2256 | QTime tim; | 2256 | QTime tim; |
2257 | if ( to->hasDueDate() ) | 2257 | if ( to->hasDueDate() ) |
2258 | tim = to->dtDue().time(); | 2258 | tim = to->dtDue().time(); |
2259 | else { | 2259 | else { |
2260 | tim = QTime ( 0,0,0 ); | 2260 | tim = QTime ( 0,0,0 ); |
2261 | to->setFloats( true ); | 2261 | to->setFloats( true ); |
2262 | to->setHasDueDate( true ); | 2262 | to->setHasDueDate( true ); |
2263 | } | 2263 | } |
2264 | QDateTime dt ( d,tim ); | 2264 | QDateTime dt ( d,tim ); |
2265 | to->setDtDue( dt ); | 2265 | to->setDtDue( dt ); |
2266 | todoChanged( to ); | 2266 | todoChanged( to ); |
2267 | } else { | 2267 | } else { |
2268 | if ( mMoveIncidence->doesRecur() ) { | 2268 | if ( mMoveIncidence->doesRecur() ) { |
2269 | #if 0 | 2269 | #if 0 |
2270 | // PENDING implement this | 2270 | // PENDING implement this |
2271 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2271 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2272 | mCalendar()->addIncidence( newInc ); | 2272 | mCalendar()->addIncidence( newInc ); |
2273 | if ( mMoveIncidence->type() == "Todo" ) | 2273 | if ( mMoveIncidence->type() == "Todo" ) |
2274 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2274 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2275 | else | 2275 | else |
2276 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2276 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2277 | mMoveIncidence = newInc; | 2277 | mMoveIncidence = newInc; |
2278 | 2278 | ||
2279 | #endif | 2279 | #endif |
2280 | } | 2280 | } |
2281 | QTime tim = mMoveIncidence->dtStart().time(); | 2281 | QTime tim = mMoveIncidence->dtStart().time(); |
2282 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2282 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2283 | QDateTime dt ( d,tim ); | 2283 | QDateTime dt ( d,tim ); |
2284 | mMoveIncidence->setDtStart( dt ); | 2284 | mMoveIncidence->setDtStart( dt ); |
2285 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2285 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2286 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2286 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2287 | } | 2287 | } |
2288 | 2288 | ||
2289 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2289 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2290 | } | 2290 | } |
2291 | } | 2291 | } |
2292 | 2292 | ||
2293 | void CalendarView::removeCategories() | 2293 | void CalendarView::removeCategories() |
2294 | { | 2294 | { |
2295 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2295 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2296 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2296 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2297 | QStringList catIncList; | 2297 | QStringList catIncList; |
2298 | QStringList newCatList; | 2298 | QStringList newCatList; |
2299 | Incidence* inc = incList.first(); | 2299 | Incidence* inc = incList.first(); |
2300 | int i; | 2300 | int i; |
2301 | int count = 0; | 2301 | int count = 0; |
2302 | while ( inc ) { | 2302 | while ( inc ) { |
2303 | newCatList.clear(); | 2303 | newCatList.clear(); |
2304 | catIncList = inc->categories() ; | 2304 | catIncList = inc->categories() ; |
2305 | for( i = 0; i< catIncList.count(); ++i ) { | 2305 | for( i = 0; i< catIncList.count(); ++i ) { |
2306 | if ( catList.contains (catIncList[i])) | 2306 | if ( catList.contains (catIncList[i])) |
2307 | newCatList.append( catIncList[i] ); | 2307 | newCatList.append( catIncList[i] ); |
2308 | } | 2308 | } |
2309 | newCatList.sort(); | 2309 | newCatList.sort(); |
2310 | inc->setCategories( newCatList.join(",") ); | 2310 | inc->setCategories( newCatList.join(",") ); |
2311 | inc = incList.next(); | 2311 | inc = incList.next(); |
2312 | } | 2312 | } |
2313 | } | 2313 | } |
2314 | 2314 | ||
2315 | int CalendarView::addCategories() | 2315 | int CalendarView::addCategories() |
2316 | { | 2316 | { |
2317 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2317 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2318 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2318 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2319 | QStringList catIncList; | 2319 | QStringList catIncList; |
2320 | Incidence* inc = incList.first(); | 2320 | Incidence* inc = incList.first(); |
2321 | int i; | 2321 | int i; |
2322 | int count = 0; | 2322 | int count = 0; |
2323 | while ( inc ) { | 2323 | while ( inc ) { |
2324 | catIncList = inc->categories() ; | 2324 | catIncList = inc->categories() ; |
2325 | for( i = 0; i< catIncList.count(); ++i ) { | 2325 | for( i = 0; i< catIncList.count(); ++i ) { |
2326 | if ( !catList.contains (catIncList[i])) { | 2326 | if ( !catList.contains (catIncList[i])) { |
2327 | catList.append( catIncList[i] ); | 2327 | catList.append( catIncList[i] ); |
2328 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2328 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2329 | ++count; | 2329 | ++count; |
2330 | } | 2330 | } |
2331 | } | 2331 | } |
2332 | inc = incList.next(); | 2332 | inc = incList.next(); |
2333 | } | 2333 | } |
2334 | catList.sort(); | 2334 | catList.sort(); |
2335 | KOPrefs::instance()->mCustomCategories = catList; | 2335 | KOPrefs::instance()->mCustomCategories = catList; |
2336 | return count; | 2336 | return count; |
2337 | } | 2337 | } |
2338 | 2338 | ||
2339 | void CalendarView::manageCategories() | 2339 | void CalendarView::manageCategories() |
2340 | { | 2340 | { |
2341 | KOCatPrefs* cp = new KOCatPrefs(); | 2341 | KOCatPrefs* cp = new KOCatPrefs(); |
2342 | cp->show(); | 2342 | cp->show(); |
2343 | int w =cp->sizeHint().width() ; | 2343 | int w =cp->sizeHint().width() ; |
2344 | int h = cp->sizeHint().height() ; | 2344 | int h = cp->sizeHint().height() ; |
2345 | int dw = QApplication::desktop()->width(); | 2345 | int dw = QApplication::desktop()->width(); |
2346 | int dh = QApplication::desktop()->height(); | 2346 | int dh = QApplication::desktop()->height(); |
2347 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2347 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2348 | if ( !cp->exec() ) { | 2348 | if ( !cp->exec() ) { |
2349 | delete cp; | 2349 | delete cp; |
2350 | return; | 2350 | return; |
2351 | } | 2351 | } |
2352 | int count = 0; | 2352 | int count = 0; |
2353 | if ( cp->addCat() ) { | 2353 | if ( cp->addCat() ) { |
2354 | count = addCategories(); | 2354 | count = addCategories(); |
2355 | if ( count ) { | 2355 | if ( count ) { |
2356 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2356 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2357 | writeSettings(); | 2357 | writeSettings(); |
2358 | } else | 2358 | } else |
2359 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2359 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2360 | } else { | 2360 | } else { |
2361 | removeCategories(); | 2361 | removeCategories(); |
2362 | updateView(); | 2362 | updateView(); |
2363 | } | 2363 | } |
2364 | delete cp; | 2364 | delete cp; |
2365 | } | 2365 | } |
2366 | 2366 | ||
2367 | void CalendarView::beamIncidence(Incidence * Inc) | 2367 | void CalendarView::beamIncidence(Incidence * Inc) |
2368 | { | 2368 | { |
2369 | QPtrList<Incidence> delSel ; | 2369 | QPtrList<Incidence> delSel ; |
2370 | delSel.append(Inc); | 2370 | delSel.append(Inc); |
2371 | beamIncidenceList( delSel ); | 2371 | beamIncidenceList( delSel ); |
2372 | } | 2372 | } |
2373 | void CalendarView::beamCalendar() | 2373 | void CalendarView::beamCalendar() |
2374 | { | 2374 | { |
2375 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2375 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2376 | //qDebug("beamCalendar() "); | 2376 | //qDebug("beamCalendar() "); |
2377 | beamIncidenceList( delSel ); | 2377 | beamIncidenceList( delSel ); |
2378 | } | 2378 | } |
2379 | void CalendarView::beamFilteredCalendar() | 2379 | void CalendarView::beamFilteredCalendar() |
2380 | { | 2380 | { |
2381 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2381 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2382 | //qDebug("beamFilteredCalendar() "); | 2382 | //qDebug("beamFilteredCalendar() "); |
2383 | beamIncidenceList( delSel ); | 2383 | beamIncidenceList( delSel ); |
2384 | } | 2384 | } |
2385 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2385 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2386 | { | 2386 | { |
2387 | if ( beamDialog->exec () == QDialog::Rejected ) | 2387 | if ( beamDialog->exec () == QDialog::Rejected ) |
2388 | return; | 2388 | return; |
2389 | #ifdef DESKTOP_VERSION | 2389 | #ifdef DESKTOP_VERSION |
2390 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2390 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2391 | #else | 2391 | #else |
2392 | QString fn = "/tmp/kopibeamfile"; | 2392 | QString fn = "/tmp/kopibeamfile"; |
2393 | #endif | 2393 | #endif |
2394 | QString mes; | 2394 | QString mes; |
2395 | bool createbup = true; | 2395 | bool createbup = true; |
2396 | if ( createbup ) { | 2396 | if ( createbup ) { |
2397 | QString description = "\n"; | 2397 | QString description = "\n"; |
2398 | CalendarLocal* cal = new CalendarLocal(); | 2398 | CalendarLocal* cal = new CalendarLocal(); |
2399 | if ( beamDialog->beamLocal() ) | 2399 | if ( beamDialog->beamLocal() ) |
2400 | cal->setLocalTime(); | 2400 | cal->setLocalTime(); |
2401 | else | 2401 | else |
2402 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2402 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2403 | Incidence *incidence = delSel.first(); | 2403 | Incidence *incidence = delSel.first(); |
2404 | bool addText = false; | 2404 | bool addText = false; |
2405 | if ( delSel.count() < 10 ) | 2405 | if ( delSel.count() < 10 ) |
2406 | addText = true; | 2406 | addText = true; |
2407 | else { | 2407 | else { |
2408 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2408 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2409 | } | 2409 | } |
2410 | while ( incidence ) { | 2410 | while ( incidence ) { |
2411 | Incidence *in = incidence->clone(); | 2411 | Incidence *in = incidence->clone(); |
2412 | if ( ! in->summary().isEmpty() ) { | 2412 | if ( ! in->summary().isEmpty() ) { |
2413 | in->setDescription(""); | 2413 | in->setDescription(""); |
2414 | } else { | 2414 | } else { |
2415 | in->setSummary( in->description().left(20)); | 2415 | in->setSummary( in->description().left(20)); |
2416 | in->setDescription(""); | 2416 | in->setDescription(""); |
2417 | } | 2417 | } |
2418 | if ( addText ) | 2418 | if ( addText ) |
2419 | description += in->summary() + "\n"; | 2419 | description += in->summary() + "\n"; |
2420 | cal->addIncidence( in ); | 2420 | cal->addIncidence( in ); |
2421 | incidence = delSel.next(); | 2421 | incidence = delSel.next(); |
2422 | } | 2422 | } |
2423 | if ( beamDialog->beamVcal() ) { | 2423 | if ( beamDialog->beamVcal() ) { |
2424 | fn += ".vcs"; | 2424 | fn += ".vcs"; |
2425 | FileStorage storage( cal, fn, new VCalFormat ); | 2425 | FileStorage storage( cal, fn, new VCalFormat ); |
2426 | storage.save(); | 2426 | storage.save(); |
2427 | } else { | 2427 | } else { |
2428 | fn += ".ics"; | 2428 | fn += ".ics"; |
2429 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2429 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2430 | storage.save(); | 2430 | storage.save(); |
2431 | } | 2431 | } |
2432 | delete cal; | 2432 | delete cal; |
2433 | mes = i18n("KO/Pi: Ready for beaming"); | 2433 | mes = i18n("KO/Pi: Ready for beaming"); |
2434 | topLevelWidget()->setCaption(mes); | 2434 | topLevelWidget()->setCaption(mes); |
2435 | KApplication::convert2latin1( fn ); | 2435 | KApplication::convert2latin1( fn ); |
2436 | #ifndef DESKTOP_VERSION | 2436 | #ifndef DESKTOP_VERSION |
2437 | Ir *ir = new Ir( this ); | 2437 | Ir *ir = new Ir( this ); |
2438 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2438 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2439 | ir->send( fn, description, "text/x-vCalendar" ); | 2439 | ir->send( fn, description, "text/x-vCalendar" ); |
2440 | #endif | 2440 | #endif |
2441 | } | 2441 | } |
2442 | } | 2442 | } |
2443 | void CalendarView::beamDone( Ir *ir ) | 2443 | void CalendarView::beamDone( Ir *ir ) |
2444 | { | 2444 | { |
2445 | #ifndef DESKTOP_VERSION | 2445 | #ifndef DESKTOP_VERSION |
2446 | delete ir; | 2446 | delete ir; |
2447 | #endif | 2447 | #endif |
2448 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2448 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2449 | topLevelWidget()->raise(); | 2449 | topLevelWidget()->raise(); |
2450 | } | 2450 | } |
2451 | 2451 | ||
2452 | void CalendarView::moveIncidence(Incidence * inc ) | 2452 | void CalendarView::moveIncidence(Incidence * inc ) |
2453 | { | 2453 | { |
2454 | if ( !inc ) return; | 2454 | if ( !inc ) return; |
2455 | // qDebug("showDatePickerForIncidence( ) "); | 2455 | // qDebug("showDatePickerForIncidence( ) "); |
2456 | if ( mDateFrame->isVisible() ) | 2456 | if ( mDateFrame->isVisible() ) |
2457 | mDateFrame->hide(); | 2457 | mDateFrame->hide(); |
2458 | else { | 2458 | else { |
2459 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2459 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2460 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2460 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2461 | int dw = QApplication::desktop()->width(); | 2461 | int dw = QApplication::desktop()->width(); |
2462 | int dh = QApplication::desktop()->height(); | 2462 | int dh = QApplication::desktop()->height(); |
2463 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2463 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2464 | mDateFrame->show(); | 2464 | mDateFrame->show(); |
2465 | } | 2465 | } |
2466 | mDatePickerMode = 2; | 2466 | mDatePickerMode = 2; |
2467 | mMoveIncidence = inc ; | 2467 | mMoveIncidence = inc ; |
2468 | QDate da; | 2468 | QDate da; |
2469 | if ( mMoveIncidence->type() == "Todo" ) { | 2469 | if ( mMoveIncidence->type() == "Todo" ) { |
2470 | Todo * to = (Todo *) mMoveIncidence; | 2470 | Todo * to = (Todo *) mMoveIncidence; |
2471 | if ( to->hasDueDate() ) | 2471 | if ( to->hasDueDate() ) |
2472 | da = to->dtDue().date(); | 2472 | da = to->dtDue().date(); |
2473 | else | 2473 | else |
2474 | da = QDate::currentDate(); | 2474 | da = QDate::currentDate(); |
2475 | } else { | 2475 | } else { |
2476 | da = mMoveIncidence->dtStart().date(); | 2476 | da = mMoveIncidence->dtStart().date(); |
2477 | } | 2477 | } |
2478 | //PENDING set date for recurring incidence to date of recurrence | 2478 | //PENDING set date for recurring incidence to date of recurrence |
2479 | //mMoveIncidenceOldDate; | 2479 | //mMoveIncidenceOldDate; |
2480 | mDatePicker->setDate( da ); | 2480 | mDatePicker->setDate( da ); |
2481 | } | 2481 | } |
2482 | void CalendarView::showDatePicker( ) | 2482 | void CalendarView::showDatePicker( ) |
2483 | { | 2483 | { |
2484 | //qDebug("CalendarView::showDatePicker( ) "); | 2484 | //qDebug("CalendarView::showDatePicker( ) "); |
2485 | if ( mDateFrame->isVisible() ) | 2485 | if ( mDateFrame->isVisible() ) |
2486 | mDateFrame->hide(); | 2486 | mDateFrame->hide(); |
2487 | else { | 2487 | else { |
2488 | int w =mDatePicker->sizeHint().width() ; | 2488 | int w =mDatePicker->sizeHint().width() ; |
2489 | int h = mDatePicker->sizeHint().height() ; | 2489 | int h = mDatePicker->sizeHint().height() ; |
2490 | int dw = QApplication::desktop()->width(); | 2490 | int dw = QApplication::desktop()->width(); |
2491 | int dh = QApplication::desktop()->height(); | 2491 | int dh = QApplication::desktop()->height(); |
2492 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2492 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2493 | mDateFrame->show(); | 2493 | mDateFrame->show(); |
2494 | } | 2494 | } |
2495 | mDatePickerMode = 1; | 2495 | mDatePickerMode = 1; |
2496 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2496 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2497 | } | 2497 | } |
2498 | 2498 | ||
2499 | void CalendarView::showEventEditor() | 2499 | void CalendarView::showEventEditor() |
2500 | { | 2500 | { |
2501 | #ifdef DESKTOP_VERSION | 2501 | #ifdef DESKTOP_VERSION |
2502 | mEventEditor->show(); | 2502 | mEventEditor->show(); |
2503 | #else | 2503 | #else |
2504 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2504 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2505 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2505 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2506 | qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2506 | qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2507 | delete mEventEditor; | 2507 | delete mEventEditor; |
2508 | mEventEditor = mDialogManager->getEventEditor(); | 2508 | mEventEditor = mDialogManager->getEventEditor(); |
2509 | } | 2509 | } |
2510 | mEventEditor->showMaximized(); | 2510 | mEventEditor->showMaximized(); |
2511 | topLevelWidget()->setCaption( i18n("") ); | ||
2511 | #endif | 2512 | #endif |
2512 | } | 2513 | } |
2513 | void CalendarView::showTodoEditor() | 2514 | void CalendarView::showTodoEditor() |
2514 | { | 2515 | { |
2515 | #ifdef DESKTOP_VERSION | 2516 | #ifdef DESKTOP_VERSION |
2516 | mTodoEditor->show(); | 2517 | mTodoEditor->show(); |
2517 | #else | 2518 | #else |
2518 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2519 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2519 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2520 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2520 | qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2521 | qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2521 | delete mTodoEditor; | 2522 | delete mTodoEditor; |
2522 | mTodoEditor = mDialogManager->getTodoEditor(); | 2523 | mTodoEditor = mDialogManager->getTodoEditor(); |
2523 | } | 2524 | } |
2524 | mTodoEditor->showMaximized(); | 2525 | mTodoEditor->showMaximized(); |
2526 | topLevelWidget()->setCaption( i18n("") ); | ||
2525 | #endif | 2527 | #endif |
2526 | } | 2528 | } |
2527 | 2529 | ||
2528 | void CalendarView::cloneIncidence() | 2530 | void CalendarView::cloneIncidence() |
2529 | { | 2531 | { |
2530 | Incidence *incidence = currentSelection(); | 2532 | Incidence *incidence = currentSelection(); |
2531 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2533 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2532 | if ( incidence ) { | 2534 | if ( incidence ) { |
2533 | cloneIncidence(incidence); | 2535 | cloneIncidence(incidence); |
2534 | } | 2536 | } |
2535 | } | 2537 | } |
2536 | void CalendarView::moveIncidence() | 2538 | void CalendarView::moveIncidence() |
2537 | { | 2539 | { |
2538 | Incidence *incidence = currentSelection(); | 2540 | Incidence *incidence = currentSelection(); |
2539 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2541 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2540 | if ( incidence ) { | 2542 | if ( incidence ) { |
2541 | moveIncidence(incidence); | 2543 | moveIncidence(incidence); |
2542 | } | 2544 | } |
2543 | } | 2545 | } |
2544 | void CalendarView::beamIncidence() | 2546 | void CalendarView::beamIncidence() |
2545 | { | 2547 | { |
2546 | Incidence *incidence = currentSelection(); | 2548 | Incidence *incidence = currentSelection(); |
2547 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2549 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2548 | if ( incidence ) { | 2550 | if ( incidence ) { |
2549 | beamIncidence(incidence); | 2551 | beamIncidence(incidence); |
2550 | } | 2552 | } |
2551 | } | 2553 | } |
2552 | void CalendarView::toggleCancelIncidence() | 2554 | void CalendarView::toggleCancelIncidence() |
2553 | { | 2555 | { |
2554 | Incidence *incidence = currentSelection(); | 2556 | Incidence *incidence = currentSelection(); |
2555 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2557 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2556 | if ( incidence ) { | 2558 | if ( incidence ) { |
2557 | cancelIncidence(incidence); | 2559 | cancelIncidence(incidence); |
2558 | } | 2560 | } |
2559 | } | 2561 | } |
2560 | 2562 | ||
2561 | 2563 | ||
2562 | void CalendarView::cancelIncidence(Incidence * inc ) | 2564 | void CalendarView::cancelIncidence(Incidence * inc ) |
2563 | { | 2565 | { |
2564 | inc->setCancelled( ! inc->cancelled() ); | 2566 | inc->setCancelled( ! inc->cancelled() ); |
2565 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2567 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2566 | updateView(); | 2568 | updateView(); |
2567 | } | 2569 | } |
2568 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2570 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2569 | { | 2571 | { |
2570 | Incidence * newInc = orgInc->clone(); | 2572 | Incidence * newInc = orgInc->clone(); |
2571 | newInc->recreate(); | 2573 | newInc->recreate(); |
2572 | 2574 | ||
2573 | if ( newInc->type() == "Todo" ) { | 2575 | if ( newInc->type() == "Todo" ) { |
2574 | Todo* t = (Todo*) newInc; | 2576 | Todo* t = (Todo*) newInc; |
2575 | showTodoEditor(); | 2577 | showTodoEditor(); |
2576 | mTodoEditor->editTodo( t ); | 2578 | mTodoEditor->editTodo( t ); |
2577 | if ( mTodoEditor->exec() ) { | 2579 | if ( mTodoEditor->exec() ) { |
2578 | mCalendar->addTodo( t ); | 2580 | mCalendar->addTodo( t ); |
2579 | updateView(); | 2581 | updateView(); |
2580 | } else { | 2582 | } else { |
2581 | delete t; | 2583 | delete t; |
2582 | } | 2584 | } |
2583 | } | 2585 | } |
2584 | else { | 2586 | else { |
2585 | Event* e = (Event*) newInc; | 2587 | Event* e = (Event*) newInc; |
2586 | showEventEditor(); | 2588 | showEventEditor(); |
2587 | mEventEditor->editEvent( e ); | 2589 | mEventEditor->editEvent( e ); |
2588 | if ( mEventEditor->exec() ) { | 2590 | if ( mEventEditor->exec() ) { |
2589 | mCalendar->addEvent( e ); | 2591 | mCalendar->addEvent( e ); |
2590 | updateView(); | 2592 | updateView(); |
2591 | } else { | 2593 | } else { |
2592 | delete e; | 2594 | delete e; |
2593 | } | 2595 | } |
2594 | } | 2596 | } |
2595 | } | 2597 | } |
2596 | 2598 | ||
2597 | void CalendarView::newEvent() | 2599 | void CalendarView::newEvent() |
2598 | { | 2600 | { |
2599 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2601 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2600 | KOAgendaView *aView = mViewManager->agendaView(); | 2602 | KOAgendaView *aView = mViewManager->agendaView(); |
2601 | if (aView) { | 2603 | if (aView) { |
2602 | if (aView->selectionStart().isValid()) { | 2604 | if (aView->selectionStart().isValid()) { |
2603 | if (aView->selectedIsAllDay()) { | 2605 | if (aView->selectedIsAllDay()) { |
2604 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2606 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2605 | } else { | 2607 | } else { |
2606 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2608 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2607 | } | 2609 | } |
2608 | return; | 2610 | return; |
2609 | } | 2611 | } |
2610 | } | 2612 | } |
2611 | 2613 | ||
2612 | QDate date = mNavigator->selectedDates().first(); | 2614 | QDate date = mNavigator->selectedDates().first(); |
2613 | QDateTime current = QDateTime::currentDateTime(); | 2615 | QDateTime current = QDateTime::currentDateTime(); |
2614 | if ( date <= current.date() ) { | 2616 | if ( date <= current.date() ) { |
2615 | int hour = current.time().hour() +1; | 2617 | int hour = current.time().hour() +1; |
2616 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2618 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2617 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2619 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2618 | } else | 2620 | } else |
2619 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2621 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2620 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2622 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2621 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2623 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2622 | } | 2624 | } |
2623 | 2625 | ||
2624 | void CalendarView::newEvent(QDateTime fh) | 2626 | void CalendarView::newEvent(QDateTime fh) |
2625 | { | 2627 | { |
2626 | newEvent(fh, | 2628 | newEvent(fh, |
2627 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2629 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2628 | } | 2630 | } |
2629 | 2631 | ||
2630 | void CalendarView::newEvent(QDate dt) | 2632 | void CalendarView::newEvent(QDate dt) |
2631 | { | 2633 | { |
2632 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2634 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2633 | QDateTime(dt, QTime(0,0,0)), true); | 2635 | QDateTime(dt, QTime(0,0,0)), true); |
2634 | } | 2636 | } |
2635 | 2637 | ||
2636 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2638 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2637 | { | 2639 | { |
2638 | 2640 | ||
2639 | showEventEditor(); | 2641 | showEventEditor(); |
2640 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2642 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2641 | if ( mFilterView->filtersEnabled() ) { | 2643 | if ( mFilterView->filtersEnabled() ) { |
2642 | CalFilter *filter = mFilterView->selectedFilter(); | 2644 | CalFilter *filter = mFilterView->selectedFilter(); |
2643 | if (filter && filter->showCategories()) { | 2645 | if (filter && filter->showCategories()) { |
2644 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2646 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2645 | } | 2647 | } |
2646 | if ( filter ) | 2648 | if ( filter ) |
2647 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2649 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2648 | } | 2650 | } |
2649 | } | 2651 | } |
2650 | void CalendarView::todoAdded(Todo * t) | 2652 | void CalendarView::todoAdded(Todo * t) |
2651 | { | 2653 | { |
2652 | 2654 | ||
2653 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2655 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2654 | updateTodoViews(); | 2656 | updateTodoViews(); |
2655 | } | 2657 | } |
2656 | void CalendarView::todoChanged(Todo * t) | 2658 | void CalendarView::todoChanged(Todo * t) |
2657 | { | 2659 | { |
2658 | emit todoModified( t, 4 ); | 2660 | emit todoModified( t, 4 ); |
2659 | // updateTodoViews(); | 2661 | // updateTodoViews(); |
2660 | } | 2662 | } |
2661 | void CalendarView::todoToBeDeleted(Todo *) | 2663 | void CalendarView::todoToBeDeleted(Todo *) |
2662 | { | 2664 | { |
2663 | //qDebug("todoToBeDeleted(Todo *) "); | 2665 | //qDebug("todoToBeDeleted(Todo *) "); |
2664 | updateTodoViews(); | 2666 | updateTodoViews(); |
2665 | } | 2667 | } |
2666 | void CalendarView::todoDeleted() | 2668 | void CalendarView::todoDeleted() |
2667 | { | 2669 | { |
2668 | //qDebug(" todoDeleted()"); | 2670 | //qDebug(" todoDeleted()"); |
2669 | updateTodoViews(); | 2671 | updateTodoViews(); |
2670 | } | 2672 | } |
2671 | 2673 | ||
2672 | 2674 | ||
2673 | 2675 | ||
2674 | void CalendarView::newTodo() | 2676 | void CalendarView::newTodo() |
2675 | { | 2677 | { |
2676 | 2678 | ||
2677 | showTodoEditor(); | 2679 | showTodoEditor(); |
2678 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2680 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2679 | if ( mFilterView->filtersEnabled() ) { | 2681 | if ( mFilterView->filtersEnabled() ) { |
2680 | CalFilter *filter = mFilterView->selectedFilter(); | 2682 | CalFilter *filter = mFilterView->selectedFilter(); |
2681 | if (filter && filter->showCategories()) { | 2683 | if (filter && filter->showCategories()) { |
2682 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2684 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2683 | } | 2685 | } |
2684 | if ( filter ) | 2686 | if ( filter ) |
2685 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2687 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2686 | } | 2688 | } |
2687 | } | 2689 | } |
2688 | 2690 | ||
2689 | void CalendarView::newSubTodo() | 2691 | void CalendarView::newSubTodo() |
2690 | { | 2692 | { |
2691 | Todo *todo = selectedTodo(); | 2693 | Todo *todo = selectedTodo(); |
2692 | if ( todo ) newSubTodo( todo ); | 2694 | if ( todo ) newSubTodo( todo ); |
2693 | } | 2695 | } |
2694 | 2696 | ||
2695 | void CalendarView::newSubTodo(Todo *parentEvent) | 2697 | void CalendarView::newSubTodo(Todo *parentEvent) |
2696 | { | 2698 | { |
2697 | 2699 | ||
2698 | showTodoEditor(); | 2700 | showTodoEditor(); |
2699 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2701 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2700 | } | 2702 | } |
2701 | 2703 | ||
2702 | void CalendarView::newFloatingEvent() | 2704 | void CalendarView::newFloatingEvent() |
2703 | { | 2705 | { |
2704 | DateList tmpList = mNavigator->selectedDates(); | 2706 | DateList tmpList = mNavigator->selectedDates(); |
2705 | QDate date = tmpList.first(); | 2707 | QDate date = tmpList.first(); |
2706 | 2708 | ||
2707 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2709 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2708 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2710 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2709 | } | 2711 | } |
2710 | 2712 | ||
2711 | 2713 | ||
2712 | void CalendarView::editEvent( Event *event ) | 2714 | void CalendarView::editEvent( Event *event ) |
2713 | { | 2715 | { |
2714 | 2716 | ||
2715 | if ( !event ) return; | 2717 | if ( !event ) return; |
2716 | if ( event->isReadOnly() ) { | 2718 | if ( event->isReadOnly() ) { |
2717 | showEvent( event ); | 2719 | showEvent( event ); |
2718 | return; | 2720 | return; |
2719 | } | 2721 | } |
2720 | showEventEditor(); | 2722 | showEventEditor(); |
2721 | mEventEditor->editEvent( event , mFlagEditDescription); | 2723 | mEventEditor->editEvent( event , mFlagEditDescription); |
2722 | } | 2724 | } |
2723 | void CalendarView::editJournal( Journal *jour ) | 2725 | void CalendarView::editJournal( Journal *jour ) |
2724 | { | 2726 | { |
2725 | if ( !jour ) return; | 2727 | if ( !jour ) return; |
2726 | mDialogManager->hideSearchDialog(); | 2728 | mDialogManager->hideSearchDialog(); |
2727 | mViewManager->showJournalView(); | 2729 | mViewManager->showJournalView(); |
2728 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2730 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2729 | } | 2731 | } |
2730 | void CalendarView::editTodo( Todo *todo ) | 2732 | void CalendarView::editTodo( Todo *todo ) |
2731 | { | 2733 | { |
2732 | if ( !todo ) return; | 2734 | if ( !todo ) return; |
2733 | 2735 | ||
2734 | if ( todo->isReadOnly() ) { | 2736 | if ( todo->isReadOnly() ) { |
2735 | showTodo( todo ); | 2737 | showTodo( todo ); |
2736 | return; | 2738 | return; |
2737 | } | 2739 | } |
2738 | showTodoEditor(); | 2740 | showTodoEditor(); |
2739 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2741 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2740 | 2742 | ||
2741 | } | 2743 | } |
2742 | 2744 | ||
2743 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2745 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2744 | { | 2746 | { |
2745 | if ( !mEventViewerDialog ) { | 2747 | if ( !mEventViewerDialog ) { |
2746 | mEventViewerDialog = new KOEventViewerDialog(this); | 2748 | mEventViewerDialog = new KOEventViewerDialog(this); |
2747 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2749 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2748 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2750 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2749 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2751 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2750 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2752 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2751 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2753 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2752 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2754 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2753 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2755 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2754 | this, SLOT( todoChanged(Todo *) ) ); | 2756 | this, SLOT( todoChanged(Todo *) ) ); |
2755 | mEventViewerDialog->resize( 640, 480 ); | 2757 | mEventViewerDialog->resize( 640, 480 ); |
2756 | 2758 | ||
2757 | } | 2759 | } |
2758 | return mEventViewerDialog; | 2760 | return mEventViewerDialog; |
2759 | } | 2761 | } |
2760 | void CalendarView::showEvent(Event *event) | 2762 | void CalendarView::showEvent(Event *event) |
2761 | { | 2763 | { |
2762 | getEventViewerDialog()->setEvent(event); | 2764 | getEventViewerDialog()->setEvent(event); |
2763 | getEventViewerDialog()->showMe(); | 2765 | getEventViewerDialog()->showMe(); |
2764 | } | 2766 | } |
2765 | 2767 | ||
2766 | void CalendarView::showTodo(Todo *event) | 2768 | void CalendarView::showTodo(Todo *event) |
2767 | { | 2769 | { |
2768 | getEventViewerDialog()->setTodo(event); | 2770 | getEventViewerDialog()->setTodo(event); |
2769 | getEventViewerDialog()->showMe(); | 2771 | getEventViewerDialog()->showMe(); |
2770 | } | 2772 | } |
2771 | void CalendarView::showJournal( Journal *jour ) | 2773 | void CalendarView::showJournal( Journal *jour ) |
2772 | { | 2774 | { |
2773 | getEventViewerDialog()->setJournal(jour); | 2775 | getEventViewerDialog()->setJournal(jour); |
2774 | getEventViewerDialog()->showMe(); | 2776 | getEventViewerDialog()->showMe(); |
2775 | 2777 | ||
2776 | } | 2778 | } |
2777 | // void CalendarView::todoModified (Todo *event, int changed) | 2779 | // void CalendarView::todoModified (Todo *event, int changed) |
2778 | // { | 2780 | // { |
2779 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2781 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2780 | // // kdDebug() << "Todo modified and open" << endl; | 2782 | // // kdDebug() << "Todo modified and open" << endl; |
2781 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2783 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2782 | // // temp->modified (changed); | 2784 | // // temp->modified (changed); |
2783 | 2785 | ||
2784 | // // } | 2786 | // // } |
2785 | 2787 | ||
2786 | // mViewManager->updateView(); | 2788 | // mViewManager->updateView(); |
2787 | // } | 2789 | // } |
2788 | 2790 | ||
2789 | void CalendarView::appointment_show() | 2791 | void CalendarView::appointment_show() |
2790 | { | 2792 | { |
2791 | Event *anEvent = 0; | 2793 | Event *anEvent = 0; |
2792 | 2794 | ||
2793 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2795 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2794 | 2796 | ||
2795 | if (mViewManager->currentView()->isEventView()) { | 2797 | if (mViewManager->currentView()->isEventView()) { |
2796 | if ( incidence && incidence->type() == "Event" ) { | 2798 | if ( incidence && incidence->type() == "Event" ) { |
2797 | anEvent = static_cast<Event *>(incidence); | 2799 | anEvent = static_cast<Event *>(incidence); |
2798 | } | 2800 | } |
2799 | } | 2801 | } |
2800 | 2802 | ||
2801 | if (!anEvent) { | 2803 | if (!anEvent) { |
2802 | KNotifyClient::beep(); | 2804 | KNotifyClient::beep(); |
2803 | return; | 2805 | return; |
2804 | } | 2806 | } |
2805 | 2807 | ||
2806 | showEvent(anEvent); | 2808 | showEvent(anEvent); |
2807 | } | 2809 | } |
2808 | 2810 | ||
2809 | void CalendarView::appointment_edit() | 2811 | void CalendarView::appointment_edit() |
2810 | { | 2812 | { |
2811 | Event *anEvent = 0; | 2813 | Event *anEvent = 0; |
2812 | 2814 | ||
2813 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2815 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2814 | 2816 | ||
2815 | if (mViewManager->currentView()->isEventView()) { | 2817 | if (mViewManager->currentView()->isEventView()) { |
2816 | if ( incidence && incidence->type() == "Event" ) { | 2818 | if ( incidence && incidence->type() == "Event" ) { |
2817 | anEvent = static_cast<Event *>(incidence); | 2819 | anEvent = static_cast<Event *>(incidence); |
2818 | } | 2820 | } |
2819 | } | 2821 | } |
2820 | 2822 | ||
2821 | if (!anEvent) { | 2823 | if (!anEvent) { |
2822 | KNotifyClient::beep(); | 2824 | KNotifyClient::beep(); |
2823 | return; | 2825 | return; |
2824 | } | 2826 | } |
2825 | 2827 | ||
2826 | editEvent(anEvent); | 2828 | editEvent(anEvent); |
2827 | } | 2829 | } |
2828 | 2830 | ||
2829 | void CalendarView::appointment_delete() | 2831 | void CalendarView::appointment_delete() |
2830 | { | 2832 | { |
2831 | Event *anEvent = 0; | 2833 | Event *anEvent = 0; |
2832 | 2834 | ||
2833 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2835 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2834 | 2836 | ||
2835 | if (mViewManager->currentView()->isEventView()) { | 2837 | if (mViewManager->currentView()->isEventView()) { |
2836 | if ( incidence && incidence->type() == "Event" ) { | 2838 | if ( incidence && incidence->type() == "Event" ) { |
2837 | anEvent = static_cast<Event *>(incidence); | 2839 | anEvent = static_cast<Event *>(incidence); |
2838 | } | 2840 | } |
2839 | } | 2841 | } |
2840 | 2842 | ||
2841 | if (!anEvent) { | 2843 | if (!anEvent) { |
2842 | KNotifyClient::beep(); | 2844 | KNotifyClient::beep(); |
2843 | return; | 2845 | return; |
2844 | } | 2846 | } |
2845 | 2847 | ||
2846 | deleteEvent(anEvent); | 2848 | deleteEvent(anEvent); |
2847 | } | 2849 | } |
2848 | 2850 | ||
2849 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2851 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2850 | { | 2852 | { |
2851 | if (!sub) return; | 2853 | if (!sub) return; |
2852 | if (!parent) return; | 2854 | if (!parent) return; |
2853 | if ( sub->relatedTo() ) | 2855 | if ( sub->relatedTo() ) |
2854 | sub->relatedTo()->removeRelation(sub); | 2856 | sub->relatedTo()->removeRelation(sub); |
2855 | sub->setRelatedTo(parent); | 2857 | sub->setRelatedTo(parent); |
2856 | sub->setRelatedToUid(parent->uid()); | 2858 | sub->setRelatedToUid(parent->uid()); |
2857 | parent->addRelation(sub); | 2859 | parent->addRelation(sub); |
2858 | sub->updated(); | 2860 | sub->updated(); |
2859 | parent->updated(); | 2861 | parent->updated(); |
2860 | setModified(true); | 2862 | setModified(true); |
2861 | updateView(); | 2863 | updateView(); |
2862 | } | 2864 | } |
2863 | void CalendarView::todo_unsub(Todo *anTodo ) | 2865 | void CalendarView::todo_unsub(Todo *anTodo ) |
2864 | { | 2866 | { |
2865 | // Todo *anTodo = selectedTodo(); | 2867 | // Todo *anTodo = selectedTodo(); |
2866 | if (!anTodo) return; | 2868 | if (!anTodo) return; |
2867 | if (!anTodo->relatedTo()) return; | 2869 | if (!anTodo->relatedTo()) return; |
2868 | anTodo->relatedTo()->removeRelation(anTodo); | 2870 | anTodo->relatedTo()->removeRelation(anTodo); |
2869 | anTodo->setRelatedTo(0); | 2871 | anTodo->setRelatedTo(0); |
2870 | anTodo->updated(); | 2872 | anTodo->updated(); |
2871 | anTodo->setRelatedToUid(""); | 2873 | anTodo->setRelatedToUid(""); |
2872 | setModified(true); | 2874 | setModified(true); |
2873 | updateView(); | 2875 | updateView(); |
2874 | } | 2876 | } |
2875 | 2877 | ||
2876 | void CalendarView::deleteTodo(Todo *todo) | 2878 | void CalendarView::deleteTodo(Todo *todo) |
2877 | { | 2879 | { |
2878 | if (!todo) { | 2880 | if (!todo) { |
2879 | KNotifyClient::beep(); | 2881 | KNotifyClient::beep(); |
2880 | return; | 2882 | return; |
2881 | } | 2883 | } |
2882 | if (KOPrefs::instance()->mConfirm) { | 2884 | if (KOPrefs::instance()->mConfirm) { |
2883 | switch (msgItemDelete()) { | 2885 | switch (msgItemDelete()) { |
2884 | case KMessageBox::Continue: // OK | 2886 | case KMessageBox::Continue: // OK |
2885 | if (!todo->relations().isEmpty()) { | 2887 | if (!todo->relations().isEmpty()) { |
2886 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2888 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2887 | i18n("Delete To-Do")); | 2889 | i18n("Delete To-Do")); |
2888 | } else { | 2890 | } else { |
2889 | checkExternalId( todo ); | 2891 | checkExternalId( todo ); |
2890 | calendar()->deleteTodo(todo); | 2892 | calendar()->deleteTodo(todo); |
2891 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2893 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2892 | updateView(); | 2894 | updateView(); |
2893 | } | 2895 | } |
2894 | break; | 2896 | break; |
2895 | } // switch | 2897 | } // switch |
2896 | } else { | 2898 | } else { |
2897 | if (!todo->relations().isEmpty()) { | 2899 | if (!todo->relations().isEmpty()) { |
2898 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2900 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2899 | i18n("Delete To-Do")); | 2901 | i18n("Delete To-Do")); |
2900 | } else { | 2902 | } else { |
2901 | checkExternalId( todo ); | 2903 | checkExternalId( todo ); |
2902 | mCalendar->deleteTodo(todo); | 2904 | mCalendar->deleteTodo(todo); |
2903 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2905 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2904 | updateView(); | 2906 | updateView(); |
2905 | } | 2907 | } |
2906 | } | 2908 | } |
2907 | emit updateSearchDialog(); | 2909 | emit updateSearchDialog(); |
2908 | } | 2910 | } |
2909 | void CalendarView::deleteJournal(Journal *jour) | 2911 | void CalendarView::deleteJournal(Journal *jour) |
2910 | { | 2912 | { |
2911 | if (!jour) { | 2913 | if (!jour) { |
2912 | KNotifyClient::beep(); | 2914 | KNotifyClient::beep(); |
2913 | return; | 2915 | return; |
2914 | } | 2916 | } |
2915 | if (KOPrefs::instance()->mConfirm) { | 2917 | if (KOPrefs::instance()->mConfirm) { |
2916 | switch (msgItemDelete()) { | 2918 | switch (msgItemDelete()) { |
2917 | case KMessageBox::Continue: // OK | 2919 | case KMessageBox::Continue: // OK |
2918 | calendar()->deleteJournal(jour); | 2920 | calendar()->deleteJournal(jour); |
2919 | updateView(); | 2921 | updateView(); |
2920 | break; | 2922 | break; |
2921 | } // switch | 2923 | } // switch |
2922 | } else { | 2924 | } else { |
2923 | calendar()->deleteJournal(jour);; | 2925 | calendar()->deleteJournal(jour);; |
2924 | updateView(); | 2926 | updateView(); |
2925 | } | 2927 | } |
2926 | emit updateSearchDialog(); | 2928 | emit updateSearchDialog(); |
2927 | } | 2929 | } |
2928 | 2930 | ||
2929 | void CalendarView::deleteEvent(Event *anEvent) | 2931 | void CalendarView::deleteEvent(Event *anEvent) |
2930 | { | 2932 | { |
2931 | if (!anEvent) { | 2933 | if (!anEvent) { |
2932 | KNotifyClient::beep(); | 2934 | KNotifyClient::beep(); |
2933 | return; | 2935 | return; |
2934 | } | 2936 | } |
2935 | 2937 | ||
2936 | if (anEvent->recurrence()->doesRecur()) { | 2938 | if (anEvent->recurrence()->doesRecur()) { |
2937 | QDate itemDate = mViewManager->currentSelectionDate(); | 2939 | QDate itemDate = mViewManager->currentSelectionDate(); |
2938 | int km; | 2940 | int km; |
2939 | if (!itemDate.isValid()) { | 2941 | if (!itemDate.isValid()) { |
2940 | //kdDebug() << "Date Not Valid" << endl; | 2942 | //kdDebug() << "Date Not Valid" << endl; |
2941 | if (KOPrefs::instance()->mConfirm) { | 2943 | if (KOPrefs::instance()->mConfirm) { |
2942 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2944 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2943 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2945 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2944 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2946 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2945 | if ( km == KMessageBox::Continue ) | 2947 | if ( km == KMessageBox::Continue ) |
2946 | km = KMessageBox::No; // No = all below | 2948 | km = KMessageBox::No; // No = all below |
2947 | } else | 2949 | } else |
2948 | km = KMessageBox::No; | 2950 | km = KMessageBox::No; |
2949 | } else { | 2951 | } else { |
2950 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 2952 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2951 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2953 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2952 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2954 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2953 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2955 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2954 | i18n("All")); | 2956 | i18n("All")); |
2955 | } | 2957 | } |
2956 | switch(km) { | 2958 | switch(km) { |
2957 | 2959 | ||
2958 | case KMessageBox::No: // Continue // all | 2960 | case KMessageBox::No: // Continue // all |
2959 | //qDebug("KMessageBox::No "); | 2961 | //qDebug("KMessageBox::No "); |
2960 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2962 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2961 | schedule(Scheduler::Cancel,anEvent); | 2963 | schedule(Scheduler::Cancel,anEvent); |
2962 | 2964 | ||
2963 | checkExternalId( anEvent); | 2965 | checkExternalId( anEvent); |
2964 | mCalendar->deleteEvent(anEvent); | 2966 | mCalendar->deleteEvent(anEvent); |
2965 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2967 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2966 | break; | 2968 | break; |
2967 | 2969 | ||
2968 | // Disabled because it does not work | 2970 | // Disabled because it does not work |
2969 | //#if 0 | 2971 | //#if 0 |
2970 | case KMessageBox::Yes: // just this one | 2972 | case KMessageBox::Yes: // just this one |
2971 | //QDate qd = mNavigator->selectedDates().first(); | 2973 | //QDate qd = mNavigator->selectedDates().first(); |
2972 | //if (!qd.isValid()) { | 2974 | //if (!qd.isValid()) { |
2973 | // kdDebug() << "no date selected, or invalid date" << endl; | 2975 | // kdDebug() << "no date selected, or invalid date" << endl; |
2974 | // KNotifyClient::beep(); | 2976 | // KNotifyClient::beep(); |
2975 | // return; | 2977 | // return; |
2976 | //} | 2978 | //} |
2977 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2979 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2978 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2980 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2979 | anEvent->addExDate(itemDate); | 2981 | anEvent->addExDate(itemDate); |
2980 | int duration = anEvent->recurrence()->duration(); | 2982 | int duration = anEvent->recurrence()->duration(); |
2981 | if ( duration > 0 ) { | 2983 | if ( duration > 0 ) { |
2982 | anEvent->recurrence()->setDuration( duration - 1 ); | 2984 | anEvent->recurrence()->setDuration( duration - 1 ); |
2983 | } | 2985 | } |
2984 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2986 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2985 | } | 2987 | } |
2986 | break; | 2988 | break; |
2987 | //#endif | 2989 | //#endif |
2988 | } // switch | 2990 | } // switch |
2989 | } else { | 2991 | } else { |
2990 | if (KOPrefs::instance()->mConfirm) { | 2992 | if (KOPrefs::instance()->mConfirm) { |
2991 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2993 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2992 | i18n("\nAre you sure you want\nto delete this event?"), | 2994 | i18n("\nAre you sure you want\nto delete this event?"), |
2993 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2995 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2994 | case KMessageBox::Continue: // OK | 2996 | case KMessageBox::Continue: // OK |
2995 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2997 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2996 | schedule(Scheduler::Cancel,anEvent); | 2998 | schedule(Scheduler::Cancel,anEvent); |
2997 | checkExternalId( anEvent); | 2999 | checkExternalId( anEvent); |
2998 | mCalendar->deleteEvent(anEvent); | 3000 | mCalendar->deleteEvent(anEvent); |
2999 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3001 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3000 | break; | 3002 | break; |
3001 | } // switch | 3003 | } // switch |
3002 | } else { | 3004 | } else { |
3003 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3005 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3004 | schedule(Scheduler::Cancel,anEvent); | 3006 | schedule(Scheduler::Cancel,anEvent); |
3005 | checkExternalId( anEvent); | 3007 | checkExternalId( anEvent); |
3006 | mCalendar->deleteEvent(anEvent); | 3008 | mCalendar->deleteEvent(anEvent); |
3007 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3009 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3008 | } | 3010 | } |
3009 | } // if-else | 3011 | } // if-else |
3010 | emit updateSearchDialog(); | 3012 | emit updateSearchDialog(); |
3011 | } | 3013 | } |
3012 | 3014 | ||
3013 | bool CalendarView::deleteEvent(const QString &uid) | 3015 | bool CalendarView::deleteEvent(const QString &uid) |
3014 | { | 3016 | { |
3015 | Event *ev = mCalendar->event(uid); | 3017 | Event *ev = mCalendar->event(uid); |
3016 | if (ev) { | 3018 | if (ev) { |
3017 | deleteEvent(ev); | 3019 | deleteEvent(ev); |
3018 | return true; | 3020 | return true; |
3019 | } else { | 3021 | } else { |
3020 | return false; | 3022 | return false; |
3021 | } | 3023 | } |
3022 | } | 3024 | } |
3023 | 3025 | ||
3024 | /*****************************************************************************/ | 3026 | /*****************************************************************************/ |
3025 | 3027 | ||
3026 | void CalendarView::action_mail() | 3028 | void CalendarView::action_mail() |
3027 | { | 3029 | { |
3028 | #ifndef KORG_NOMAIL | 3030 | #ifndef KORG_NOMAIL |
3029 | KOMailClient mailClient; | 3031 | KOMailClient mailClient; |
3030 | 3032 | ||
3031 | Incidence *incidence = currentSelection(); | 3033 | Incidence *incidence = currentSelection(); |
3032 | 3034 | ||
3033 | if (!incidence) { | 3035 | if (!incidence) { |
3034 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3036 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3035 | return; | 3037 | return; |
3036 | } | 3038 | } |
3037 | if(incidence->attendeeCount() == 0 ) { | 3039 | if(incidence->attendeeCount() == 0 ) { |
3038 | KMessageBox::sorry(this, | 3040 | KMessageBox::sorry(this, |
3039 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3041 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3040 | return; | 3042 | return; |
3041 | } | 3043 | } |
3042 | 3044 | ||
3043 | CalendarLocal cal_tmp; | 3045 | CalendarLocal cal_tmp; |
3044 | Event *event = 0; | 3046 | Event *event = 0; |
3045 | Event *ev = 0; | 3047 | Event *ev = 0; |
3046 | if ( incidence && incidence->type() == "Event" ) { | 3048 | if ( incidence && incidence->type() == "Event" ) { |
3047 | event = static_cast<Event *>(incidence); | 3049 | event = static_cast<Event *>(incidence); |
3048 | ev = new Event(*event); | 3050 | ev = new Event(*event); |
3049 | cal_tmp.addEvent(ev); | 3051 | cal_tmp.addEvent(ev); |
3050 | } | 3052 | } |
3051 | ICalFormat mForm(); | 3053 | ICalFormat mForm(); |
3052 | QString attachment = mForm.toString( &cal_tmp ); | 3054 | QString attachment = mForm.toString( &cal_tmp ); |
3053 | if (ev) delete(ev); | 3055 | if (ev) delete(ev); |
3054 | 3056 | ||
3055 | mailClient.mailAttendees(currentSelection(), attachment); | 3057 | mailClient.mailAttendees(currentSelection(), attachment); |
3056 | 3058 | ||
3057 | #endif | 3059 | #endif |
3058 | 3060 | ||
3059 | #if 0 | 3061 | #if 0 |
3060 | Event *anEvent = 0; | 3062 | Event *anEvent = 0; |
3061 | if (mViewManager->currentView()->isEventView()) { | 3063 | if (mViewManager->currentView()->isEventView()) { |
3062 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3064 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3063 | } | 3065 | } |
3064 | 3066 | ||
3065 | if (!anEvent) { | 3067 | if (!anEvent) { |
3066 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3068 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3067 | return; | 3069 | return; |
3068 | } | 3070 | } |
3069 | if(anEvent->attendeeCount() == 0 ) { | 3071 | if(anEvent->attendeeCount() == 0 ) { |
3070 | KMessageBox::sorry(this, | 3072 | KMessageBox::sorry(this, |
3071 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3073 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3072 | return; | 3074 | return; |
3073 | } | 3075 | } |
3074 | 3076 | ||
3075 | mailobject.emailEvent(anEvent); | 3077 | mailobject.emailEvent(anEvent); |
3076 | #endif | 3078 | #endif |
3077 | } | 3079 | } |
3078 | 3080 | ||
3079 | 3081 | ||
3080 | void CalendarView::schedule_publish(Incidence *incidence) | 3082 | void CalendarView::schedule_publish(Incidence *incidence) |
3081 | { | 3083 | { |
3082 | Event *event = 0; | 3084 | Event *event = 0; |
3083 | Todo *todo = 0; | 3085 | Todo *todo = 0; |
3084 | 3086 | ||
3085 | if (incidence == 0) { | 3087 | if (incidence == 0) { |
3086 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3088 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3087 | if (incidence == 0) { | 3089 | if (incidence == 0) { |
3088 | incidence = mTodoList->selectedIncidences().first(); | 3090 | incidence = mTodoList->selectedIncidences().first(); |
3089 | } | 3091 | } |
3090 | } | 3092 | } |
3091 | if ( incidence && incidence->type() == "Event" ) { | 3093 | if ( incidence && incidence->type() == "Event" ) { |
3092 | event = static_cast<Event *>(incidence); | 3094 | event = static_cast<Event *>(incidence); |
3093 | } else { | 3095 | } else { |
3094 | if ( incidence && incidence->type() == "Todo" ) { | 3096 | if ( incidence && incidence->type() == "Todo" ) { |
3095 | todo = static_cast<Todo *>(incidence); | 3097 | todo = static_cast<Todo *>(incidence); |
3096 | } | 3098 | } |
3097 | } | 3099 | } |
3098 | 3100 | ||
3099 | if (!event && !todo) { | 3101 | if (!event && !todo) { |
3100 | KMessageBox::sorry(this,i18n("No event selected.")); | 3102 | KMessageBox::sorry(this,i18n("No event selected.")); |
3101 | return; | 3103 | return; |
3102 | } | 3104 | } |
3103 | 3105 | ||
3104 | PublishDialog *publishdlg = new PublishDialog(); | 3106 | PublishDialog *publishdlg = new PublishDialog(); |
3105 | if (incidence->attendeeCount()>0) { | 3107 | if (incidence->attendeeCount()>0) { |
3106 | QPtrList<Attendee> attendees = incidence->attendees(); | 3108 | QPtrList<Attendee> attendees = incidence->attendees(); |
3107 | attendees.first(); | 3109 | attendees.first(); |
3108 | while ( attendees.current()!=0 ) { | 3110 | while ( attendees.current()!=0 ) { |
3109 | publishdlg->addAttendee(attendees.current()); | 3111 | publishdlg->addAttendee(attendees.current()); |
3110 | attendees.next(); | 3112 | attendees.next(); |
3111 | } | 3113 | } |
3112 | } | 3114 | } |
3113 | bool send = true; | 3115 | bool send = true; |
3114 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3116 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3115 | if ( publishdlg->exec() != QDialog::Accepted ) | 3117 | if ( publishdlg->exec() != QDialog::Accepted ) |
3116 | send = false; | 3118 | send = false; |
3117 | } | 3119 | } |
3118 | if ( send ) { | 3120 | if ( send ) { |
3119 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3121 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3120 | if ( event ) { | 3122 | if ( event ) { |
3121 | Event *ev = new Event(*event); | 3123 | Event *ev = new Event(*event); |
3122 | ev->registerObserver(0); | 3124 | ev->registerObserver(0); |
3123 | ev->clearAttendees(); | 3125 | ev->clearAttendees(); |
3124 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3126 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3125 | delete(ev); | 3127 | delete(ev); |
3126 | } | 3128 | } |
3127 | } else { | 3129 | } else { |
3128 | if ( todo ) { | 3130 | if ( todo ) { |
3129 | Todo *ev = new Todo(*todo); | 3131 | Todo *ev = new Todo(*todo); |
3130 | ev->registerObserver(0); | 3132 | ev->registerObserver(0); |
3131 | ev->clearAttendees(); | 3133 | ev->clearAttendees(); |
3132 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3134 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3133 | delete(ev); | 3135 | delete(ev); |
3134 | } | 3136 | } |
3135 | } | 3137 | } |
3136 | } | 3138 | } |
3137 | } | 3139 | } |
3138 | delete publishdlg; | 3140 | delete publishdlg; |
3139 | } | 3141 | } |
3140 | 3142 | ||
3141 | void CalendarView::schedule_request(Incidence *incidence) | 3143 | void CalendarView::schedule_request(Incidence *incidence) |
3142 | { | 3144 | { |
3143 | schedule(Scheduler::Request,incidence); | 3145 | schedule(Scheduler::Request,incidence); |
3144 | } | 3146 | } |
3145 | 3147 | ||
3146 | void CalendarView::schedule_refresh(Incidence *incidence) | 3148 | void CalendarView::schedule_refresh(Incidence *incidence) |
3147 | { | 3149 | { |
3148 | schedule(Scheduler::Refresh,incidence); | 3150 | schedule(Scheduler::Refresh,incidence); |
3149 | } | 3151 | } |
3150 | 3152 | ||
3151 | void CalendarView::schedule_cancel(Incidence *incidence) | 3153 | void CalendarView::schedule_cancel(Incidence *incidence) |
3152 | { | 3154 | { |
3153 | schedule(Scheduler::Cancel,incidence); | 3155 | schedule(Scheduler::Cancel,incidence); |
3154 | } | 3156 | } |
3155 | 3157 | ||
3156 | void CalendarView::schedule_add(Incidence *incidence) | 3158 | void CalendarView::schedule_add(Incidence *incidence) |
3157 | { | 3159 | { |
3158 | schedule(Scheduler::Add,incidence); | 3160 | schedule(Scheduler::Add,incidence); |
3159 | } | 3161 | } |
3160 | 3162 | ||
3161 | void CalendarView::schedule_reply(Incidence *incidence) | 3163 | void CalendarView::schedule_reply(Incidence *incidence) |
3162 | { | 3164 | { |
3163 | schedule(Scheduler::Reply,incidence); | 3165 | schedule(Scheduler::Reply,incidence); |
3164 | } | 3166 | } |
3165 | 3167 | ||
3166 | void CalendarView::schedule_counter(Incidence *incidence) | 3168 | void CalendarView::schedule_counter(Incidence *incidence) |
3167 | { | 3169 | { |
3168 | schedule(Scheduler::Counter,incidence); | 3170 | schedule(Scheduler::Counter,incidence); |
3169 | } | 3171 | } |
3170 | 3172 | ||
3171 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3173 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3172 | { | 3174 | { |
3173 | schedule(Scheduler::Declinecounter,incidence); | 3175 | schedule(Scheduler::Declinecounter,incidence); |
3174 | } | 3176 | } |
3175 | 3177 | ||
3176 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3178 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3177 | { | 3179 | { |
3178 | QDateTime start = QDateTime::currentDateTime(); | 3180 | QDateTime start = QDateTime::currentDateTime(); |
3179 | QDateTime end = start.addDays(daysToPublish); | 3181 | QDateTime end = start.addDays(daysToPublish); |
3180 | 3182 | ||
3181 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3183 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3182 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3184 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3183 | 3185 | ||
3184 | 3186 | ||
3185 | PublishDialog *publishdlg = new PublishDialog(); | 3187 | PublishDialog *publishdlg = new PublishDialog(); |
3186 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3188 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3187 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3189 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3188 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3190 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3189 | delete(freebusy); | 3191 | delete(freebusy); |
3190 | } | 3192 | } |
3191 | } | 3193 | } |
3192 | delete publishdlg; | 3194 | delete publishdlg; |
3193 | } | 3195 | } |
3194 | 3196 | ||
3195 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3197 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3196 | { | 3198 | { |
3197 | Event *event = 0; | 3199 | Event *event = 0; |
3198 | Todo *todo = 0; | 3200 | Todo *todo = 0; |
3199 | 3201 | ||
3200 | if (incidence == 0) { | 3202 | if (incidence == 0) { |
3201 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3203 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3202 | if (incidence == 0) { | 3204 | if (incidence == 0) { |
3203 | incidence = mTodoList->selectedIncidences().first(); | 3205 | incidence = mTodoList->selectedIncidences().first(); |
3204 | } | 3206 | } |
3205 | } | 3207 | } |
3206 | if ( incidence && incidence->type() == "Event" ) { | 3208 | if ( incidence && incidence->type() == "Event" ) { |
3207 | event = static_cast<Event *>(incidence); | 3209 | event = static_cast<Event *>(incidence); |
3208 | } | 3210 | } |
3209 | if ( incidence && incidence->type() == "Todo" ) { | 3211 | if ( incidence && incidence->type() == "Todo" ) { |
3210 | todo = static_cast<Todo *>(incidence); | 3212 | todo = static_cast<Todo *>(incidence); |
3211 | } | 3213 | } |
3212 | 3214 | ||
3213 | if (!event && !todo) { | 3215 | if (!event && !todo) { |
3214 | KMessageBox::sorry(this,i18n("No event selected.")); | 3216 | KMessageBox::sorry(this,i18n("No event selected.")); |
3215 | return; | 3217 | return; |
3216 | } | 3218 | } |
3217 | 3219 | ||
3218 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3220 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3219 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3221 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3220 | return; | 3222 | return; |
3221 | } | 3223 | } |
3222 | 3224 | ||
3223 | Event *ev = 0; | 3225 | Event *ev = 0; |
3224 | if (event) ev = new Event(*event); | 3226 | if (event) ev = new Event(*event); |
3225 | Todo *to = 0; | 3227 | Todo *to = 0; |
3226 | if (todo) to = new Todo(*todo); | 3228 | if (todo) to = new Todo(*todo); |
3227 | 3229 | ||
3228 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3230 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3229 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3231 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3230 | if (!me) { | 3232 | if (!me) { |
3231 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3233 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3232 | return; | 3234 | return; |
3233 | } | 3235 | } |
3234 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3236 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3235 | StatusDialog *statdlg = new StatusDialog(this); | 3237 | StatusDialog *statdlg = new StatusDialog(this); |
3236 | if (!statdlg->exec()==QDialog::Accepted) return; | 3238 | if (!statdlg->exec()==QDialog::Accepted) return; |
3237 | me->setStatus( statdlg->status() ); | 3239 | me->setStatus( statdlg->status() ); |
3238 | delete(statdlg); | 3240 | delete(statdlg); |
3239 | } | 3241 | } |
3240 | Attendee *menew = new Attendee(*me); | 3242 | Attendee *menew = new Attendee(*me); |
3241 | if (ev) { | 3243 | if (ev) { |
3242 | ev->clearAttendees(); | 3244 | ev->clearAttendees(); |
3243 | ev->addAttendee(menew,false); | 3245 | ev->addAttendee(menew,false); |
3244 | } else { | 3246 | } else { |
3245 | if (to) { | 3247 | if (to) { |
3246 | todo->clearAttendees(); | 3248 | todo->clearAttendees(); |
3247 | todo->addAttendee(menew,false); | 3249 | todo->addAttendee(menew,false); |
3248 | } | 3250 | } |
3249 | } | 3251 | } |
3250 | } | 3252 | } |
3251 | 3253 | ||
3252 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3254 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3253 | if (ev) { | 3255 | if (ev) { |
3254 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3256 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3255 | } else { | 3257 | } else { |
3256 | if (to) { | 3258 | if (to) { |
3257 | if ( !dlg->addMessage(to,method) ) delete(to); | 3259 | if ( !dlg->addMessage(to,method) ) delete(to); |
3258 | } | 3260 | } |
3259 | } | 3261 | } |
3260 | } | 3262 | } |
3261 | 3263 | ||
3262 | void CalendarView::openAddressbook() | 3264 | void CalendarView::openAddressbook() |
3263 | { | 3265 | { |
3264 | KRun::runCommand("kaddressbook"); | 3266 | KRun::runCommand("kaddressbook"); |
3265 | } | 3267 | } |
3266 | 3268 | ||
3267 | void CalendarView::setModified(bool modified) | 3269 | void CalendarView::setModified(bool modified) |
3268 | { | 3270 | { |
3269 | if ( modified ) | 3271 | if ( modified ) |
3270 | emit signalmodified(); | 3272 | emit signalmodified(); |
3271 | if (mModified != modified) { | 3273 | if (mModified != modified) { |
3272 | mModified = modified; | 3274 | mModified = modified; |
3273 | emit modifiedChanged(mModified); | 3275 | emit modifiedChanged(mModified); |
3274 | } | 3276 | } |
3275 | } | 3277 | } |
3276 | 3278 | ||
3277 | bool CalendarView::isReadOnly() | 3279 | bool CalendarView::isReadOnly() |
3278 | { | 3280 | { |
3279 | return mReadOnly; | 3281 | return mReadOnly; |
3280 | } | 3282 | } |
3281 | 3283 | ||
3282 | void CalendarView::setReadOnly(bool readOnly) | 3284 | void CalendarView::setReadOnly(bool readOnly) |
3283 | { | 3285 | { |
3284 | if (mReadOnly != readOnly) { | 3286 | if (mReadOnly != readOnly) { |
3285 | mReadOnly = readOnly; | 3287 | mReadOnly = readOnly; |
3286 | emit readOnlyChanged(mReadOnly); | 3288 | emit readOnlyChanged(mReadOnly); |
3287 | } | 3289 | } |
3288 | } | 3290 | } |
3289 | 3291 | ||
3290 | bool CalendarView::isModified() | 3292 | bool CalendarView::isModified() |
3291 | { | 3293 | { |
3292 | return mModified; | 3294 | return mModified; |