-rw-r--r-- | korganizer/calendarview.cpp | 45 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/kofilterview.cpp | 18 | ||||
-rw-r--r-- | korganizer/koprefs.h | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 12 |
5 files changed, 68 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 6e60c56..b0be340 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1834,101 +1834,104 @@ void CalendarView::setSyncEventsReadOnly() | |||
1834 | { | 1834 | { |
1835 | Event * ev; | 1835 | Event * ev; |
1836 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1836 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1837 | ev = eL.first(); | 1837 | ev = eL.first(); |
1838 | while ( ev ) { | 1838 | while ( ev ) { |
1839 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1839 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1840 | ev->setReadOnly( true ); | 1840 | ev->setReadOnly( true ); |
1841 | ev = eL.next(); | 1841 | ev = eL.next(); |
1842 | } | 1842 | } |
1843 | } | 1843 | } |
1844 | 1844 | ||
1845 | bool CalendarView::loadCalendars() | 1845 | bool CalendarView::loadCalendars() |
1846 | { | 1846 | { |
1847 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1847 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1848 | KopiCalendarFile * cal = calendars.first(); | 1848 | KopiCalendarFile * cal = calendars.first(); |
1849 | mCalendar->setDefaultCalendar( 1 ); | 1849 | mCalendar->setDefaultCalendar( 1 ); |
1850 | openCalendar( MainWindow::defaultFileName(), false ); | 1850 | openCalendar( MainWindow::defaultFileName(), false ); |
1851 | cal = calendars.next(); | 1851 | cal = calendars.next(); |
1852 | while ( cal ) { | 1852 | while ( cal ) { |
1853 | addCalendar( cal ); | 1853 | addCalendar( cal ); |
1854 | cal = calendars.next(); | 1854 | cal = calendars.next(); |
1855 | } | 1855 | } |
1856 | restoreCalendarSettings(); | 1856 | restoreCalendarSettings(); |
1857 | mCalendar->reInitAlarmSettings(); | 1857 | mCalendar->reInitAlarmSettings(); |
1858 | setSyncEventsReadOnly(); | 1858 | setSyncEventsReadOnly(); |
1859 | updateUnmanagedViews(); | 1859 | updateUnmanagedViews(); |
1860 | updateView(); | 1860 | updateView(); |
1861 | } | 1861 | } |
1862 | bool CalendarView::restoreCalendarSettings() | 1862 | bool CalendarView::restoreCalendarSettings() |
1863 | { | 1863 | { |
1864 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1864 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1865 | KopiCalendarFile * cal = calendars.first(); | 1865 | KopiCalendarFile * cal = calendars.first(); |
1866 | while ( cal ) { | 1866 | while ( cal ) { |
1867 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 1867 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
1868 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 1868 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
1869 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 1869 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
1870 | if ( cal->isStandard ) | 1870 | if ( cal->isStandard ) |
1871 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 1871 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
1872 | cal = calendars.next(); | 1872 | cal = calendars.next(); |
1873 | } | 1873 | } |
1874 | } | 1874 | } |
1875 | void CalendarView::addCalendarId( int id ) | 1875 | void CalendarView::addCalendarId( int id ) |
1876 | { | 1876 | { |
1877 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 1877 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
1878 | addCalendar( cal ); | 1878 | addCalendar( cal ); |
1879 | } | 1879 | } |
1880 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 1880 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
1881 | { | 1881 | { |
1882 | 1882 | cal->mErrorOnLoad = false; | |
1883 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) | 1883 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
1884 | cal->mLoadDt = QDateTime::currentDateTime(); | ||
1884 | return true; | 1885 | return true; |
1886 | } | ||
1885 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); | 1887 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); |
1886 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); | 1888 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); |
1889 | cal->mErrorOnLoad = true; | ||
1887 | return false; | 1890 | return false; |
1888 | } | 1891 | } |
1889 | bool CalendarView::openCalendar(QString filename, bool merge) | 1892 | bool CalendarView::openCalendar(QString filename, bool merge) |
1890 | { | 1893 | { |
1891 | 1894 | ||
1892 | if (filename.isEmpty()) { | 1895 | if (filename.isEmpty()) { |
1893 | return false; | 1896 | return false; |
1894 | } | 1897 | } |
1895 | 1898 | ||
1896 | if (!QFile::exists(filename)) { | 1899 | if (!QFile::exists(filename)) { |
1897 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1900 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1898 | return false; | 1901 | return false; |
1899 | } | 1902 | } |
1900 | 1903 | ||
1901 | globalFlagBlockAgenda = 1; | 1904 | globalFlagBlockAgenda = 1; |
1902 | clearAllViews(); | 1905 | clearAllViews(); |
1903 | if (!merge) { | 1906 | if (!merge) { |
1904 | mViewManager->setDocumentId( filename ); | 1907 | mViewManager->setDocumentId( filename ); |
1905 | mCalendar->close(); | 1908 | mCalendar->close(); |
1906 | } | 1909 | } |
1907 | mStorage->setFileName( filename ); | 1910 | mStorage->setFileName( filename ); |
1908 | 1911 | ||
1909 | if ( mStorage->load() ) { | 1912 | if ( mStorage->load() ) { |
1910 | if ( merge ) ;//setModified( true ); | 1913 | if ( merge ) ;//setModified( true ); |
1911 | else { | 1914 | else { |
1912 | //setModified( true ); | 1915 | //setModified( true ); |
1913 | mViewManager->setDocumentId( filename ); | 1916 | mViewManager->setDocumentId( filename ); |
1914 | mDialogManager->setDocumentId( filename ); | 1917 | mDialogManager->setDocumentId( filename ); |
1915 | mTodoList->setDocumentId( filename ); | 1918 | mTodoList->setDocumentId( filename ); |
1916 | } | 1919 | } |
1917 | globalFlagBlockAgenda = 2; | 1920 | globalFlagBlockAgenda = 2; |
1918 | // if ( getLastSyncEvent() ) | 1921 | // if ( getLastSyncEvent() ) |
1919 | // getLastSyncEvent()->setReadOnly( true ); | 1922 | // getLastSyncEvent()->setReadOnly( true ); |
1920 | mCalendar->reInitAlarmSettings(); | 1923 | mCalendar->reInitAlarmSettings(); |
1921 | setSyncEventsReadOnly(); | 1924 | setSyncEventsReadOnly(); |
1922 | updateUnmanagedViews(); | 1925 | updateUnmanagedViews(); |
1923 | updateView(); | 1926 | updateView(); |
1924 | if ( filename != MainWindow::defaultFileName() ) { | 1927 | if ( filename != MainWindow::defaultFileName() ) { |
1925 | saveCalendar( MainWindow::defaultFileName() ); | 1928 | saveCalendar( MainWindow::defaultFileName() ); |
1926 | } else { | 1929 | } else { |
1927 | QFileInfo finf ( MainWindow::defaultFileName()); | 1930 | QFileInfo finf ( MainWindow::defaultFileName()); |
1928 | if ( finf.exists() ) { | 1931 | if ( finf.exists() ) { |
1929 | setLoadedFileVersion( finf.lastModified () ); | 1932 | setLoadedFileVersion( finf.lastModified () ); |
1930 | } | 1933 | } |
1931 | } | 1934 | } |
1932 | return true; | 1935 | return true; |
1933 | } else { | 1936 | } else { |
1934 | // while failing to load, the calendar object could | 1937 | // while failing to load, the calendar object could |
@@ -1938,142 +1941,168 @@ bool CalendarView::openCalendar(QString filename, bool merge) | |||
1938 | mViewManager->setDocumentId( filename ); | 1941 | mViewManager->setDocumentId( filename ); |
1939 | mDialogManager->setDocumentId( filename ); | 1942 | mDialogManager->setDocumentId( filename ); |
1940 | mTodoList->setDocumentId( filename ); | 1943 | mTodoList->setDocumentId( filename ); |
1941 | } | 1944 | } |
1942 | 1945 | ||
1943 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1946 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1944 | 1947 | ||
1945 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1948 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1946 | globalFlagBlockAgenda = 2; | 1949 | globalFlagBlockAgenda = 2; |
1947 | mCalendar->reInitAlarmSettings(); | 1950 | mCalendar->reInitAlarmSettings(); |
1948 | setSyncEventsReadOnly(); | 1951 | setSyncEventsReadOnly(); |
1949 | updateUnmanagedViews(); | 1952 | updateUnmanagedViews(); |
1950 | updateView(); | 1953 | updateView(); |
1951 | } | 1954 | } |
1952 | return false; | 1955 | return false; |
1953 | } | 1956 | } |
1954 | void CalendarView::showOpenError() | 1957 | void CalendarView::showOpenError() |
1955 | { | 1958 | { |
1956 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1959 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1957 | } | 1960 | } |
1958 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1961 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1959 | { | 1962 | { |
1960 | loadedFileVersion = dt; | 1963 | loadedFileVersion = dt; |
1961 | } | 1964 | } |
1962 | bool CalendarView::checkFileChanged(QString fn) | 1965 | bool CalendarView::checkFileChanged(QString fn) |
1963 | { | 1966 | { |
1964 | QFileInfo finf ( fn ); | 1967 | QFileInfo finf ( fn ); |
1965 | if ( !finf.exists() ) | 1968 | if ( !finf.exists() ) |
1966 | return true; | 1969 | return true; |
1967 | QDateTime dt = finf.lastModified (); | 1970 | QDateTime dt = finf.lastModified (); |
1968 | if ( dt <= loadedFileVersion ) | 1971 | if ( dt <= loadedFileVersion ) |
1969 | return false; | 1972 | return false; |
1970 | return true; | 1973 | return true; |
1971 | 1974 | ||
1972 | } | 1975 | } |
1973 | void CalendarView::watchSavedFile() | 1976 | void CalendarView::watchSavedFile() |
1974 | { | 1977 | { |
1975 | QFileInfo finf ( MainWindow::defaultFileName()); | 1978 | QFileInfo finf ( MainWindow::defaultFileName()); |
1976 | if ( !finf.exists() ) | 1979 | if ( !finf.exists() ) |
1977 | return; | 1980 | return; |
1978 | QDateTime dt = finf.lastModified (); | 1981 | QDateTime dt = finf.lastModified (); |
1979 | if ( dt < loadedFileVersion ) { | 1982 | if ( dt < loadedFileVersion ) { |
1980 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1983 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1981 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1984 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1982 | return; | 1985 | return; |
1983 | } | 1986 | } |
1984 | loadedFileVersion = dt; | 1987 | loadedFileVersion = dt; |
1985 | } | 1988 | } |
1986 | 1989 | bool CalendarView::checkAllFileVersions() | |
1990 | { | ||
1991 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | ||
1992 | KopiCalendarFile * cal = calendars.first(); | ||
1993 | mCalendar->setDefaultCalendar( 1 ); | ||
1994 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
1995 | if ( !checkFileVersion(MainWindow::defaultFileName())) | ||
1996 | return false; | ||
1997 | cal = calendars.next(); | ||
1998 | QDateTime storeTemp = loadedFileVersion; | ||
1999 | while ( cal ) { | ||
2000 | if ( !cal->mErrorOnLoad ) { | ||
2001 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | ||
2002 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
2003 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | ||
2004 | if ( !checkFileVersion(cal->mFileName )) { | ||
2005 | loadedFileVersion = storeTemp; | ||
2006 | updateView(); | ||
2007 | return false; | ||
2008 | } | ||
2009 | } | ||
2010 | cal = calendars.next(); | ||
2011 | } | ||
2012 | loadedFileVersion = storeTemp; | ||
2013 | updateView(); | ||
2014 | return true; | ||
2015 | } | ||
1987 | bool CalendarView::checkFileVersion(QString fn) | 2016 | bool CalendarView::checkFileVersion(QString fn) |
1988 | { | 2017 | { |
1989 | QFileInfo finf ( fn ); | 2018 | QFileInfo finf ( fn ); |
1990 | if ( !finf.exists() ) | 2019 | if ( !finf.exists() ) |
1991 | return true; | 2020 | return true; |
1992 | QDateTime dt = finf.lastModified (); | 2021 | QDateTime dt = finf.lastModified (); |
1993 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 2022 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1994 | //qDebug("file on disk version %s",dt.toString().latin1()); | 2023 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1995 | if ( dt <= loadedFileVersion ) | 2024 | if ( dt <= loadedFileVersion ) |
1996 | return true; | 2025 | return true; |
1997 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2026 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1998 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2027 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1999 | i18n("Sync+save")); | 2028 | i18n("Sync+save")); |
2000 | 2029 | ||
2001 | if ( km == KMessageBox::Cancel ) | 2030 | if ( km == KMessageBox::Cancel ) |
2002 | return false; | 2031 | return false; |
2003 | if ( km == KMessageBox::Yes ) | 2032 | if ( km == KMessageBox::Yes ) |
2004 | return true; | 2033 | return true; |
2005 | 2034 | ||
2006 | setSyncDevice("deleteaftersync" ); | 2035 | setSyncDevice("deleteaftersync" ); |
2007 | mSyncManager->mAskForPreferences = true; | 2036 | mSyncManager->mAskForPreferences = true; |
2008 | mSyncManager->mSyncAlgoPrefs = 3; | 2037 | mSyncManager->mSyncAlgoPrefs = 3; |
2009 | mSyncManager->mWriteBackFile = false; | 2038 | mSyncManager->mWriteBackFile = false; |
2010 | mSyncManager->mWriteBackExistingOnly = false; | 2039 | mSyncManager->mWriteBackExistingOnly = false; |
2011 | mSyncManager->mShowSyncSummary = false; | 2040 | mSyncManager->mShowSyncSummary = false; |
2012 | syncCalendar( fn, 3 ); | 2041 | syncCalendar( fn, 3 ); |
2013 | Event * e = getLastSyncEvent(); | 2042 | Event * e = getLastSyncEvent(); |
2014 | if ( e ) | 2043 | if ( e ) |
2015 | deleteEvent ( e ); | 2044 | mCalendar->deleteEvent( e ); |
2016 | updateView(); | ||
2017 | return true; | 2045 | return true; |
2018 | } | 2046 | } |
2019 | bool CalendarView::saveCalendars() | 2047 | bool CalendarView::saveCalendars() |
2020 | { | 2048 | { |
2021 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2049 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2022 | KopiCalendarFile * cal = calendars.first(); | 2050 | KopiCalendarFile * cal = calendars.first(); |
2023 | mCalendar->setDefaultCalendar( 1 ); | 2051 | mCalendar->setDefaultCalendar( 1 ); |
2024 | mCalendar->setDefaultCalendarEnabledOnly(); | 2052 | mCalendar->setDefaultCalendarEnabledOnly(); |
2025 | saveCalendar( MainWindow::defaultFileName() ); | 2053 | saveCalendar( MainWindow::defaultFileName() ); |
2026 | cal = calendars.next(); | 2054 | cal = calendars.next(); |
2027 | while ( cal ) { | 2055 | while ( cal ) { |
2028 | if ( !cal->isReadOnly ) { | 2056 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2029 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2057 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2030 | mCalendar->setDefaultCalendarEnabledOnly(); | 2058 | mCalendar->setDefaultCalendarEnabledOnly(); |
2031 | saveCalendar( cal->mFileName ); | 2059 | if ( saveCalendar( cal->mFileName ) ) |
2060 | cal->mLoadDt = QDateTime::currentDateTime(); | ||
2032 | } | 2061 | } |
2033 | cal = calendars.next(); | 2062 | cal = calendars.next(); |
2034 | } | 2063 | } |
2035 | restoreCalendarSettings(); | 2064 | restoreCalendarSettings(); |
2036 | } | 2065 | } |
2037 | bool CalendarView::saveCalendar( QString filename ) | 2066 | bool CalendarView::saveCalendar( QString filename ) |
2038 | { | 2067 | { |
2039 | 2068 | ||
2040 | // Store back all unsaved data into calendar object | 2069 | // Store back all unsaved data into calendar object |
2041 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2070 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2042 | if ( mViewManager->currentView() ) | 2071 | if ( mViewManager->currentView() ) |
2043 | mViewManager->currentView()->flushView(); | 2072 | mViewManager->currentView()->flushView(); |
2044 | 2073 | ||
2045 | 2074 | ||
2046 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2075 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2047 | mStorage->setSaveFormat( new ICalFormat() ); | 2076 | mStorage->setSaveFormat( new ICalFormat() ); |
2048 | mStorage->setFileName( filename ); | 2077 | mStorage->setFileName( filename ); |
2049 | bool success; | 2078 | bool success; |
2050 | success = mStorage->save(); | 2079 | success = mStorage->save(); |
2051 | if ( !success ) { | 2080 | if ( !success ) { |
2052 | return false; | 2081 | return false; |
2053 | } | 2082 | } |
2054 | if ( filename == MainWindow::defaultFileName() ) { | 2083 | if ( filename == MainWindow::defaultFileName() ) { |
2055 | setLoadedFileVersion( lfv ); | 2084 | setLoadedFileVersion( lfv ); |
2056 | watchSavedFile(); | 2085 | watchSavedFile(); |
2057 | } | 2086 | } |
2058 | return true; | 2087 | return true; |
2059 | } | 2088 | } |
2060 | 2089 | ||
2061 | void CalendarView::closeCalendar() | 2090 | void CalendarView::closeCalendar() |
2062 | { | 2091 | { |
2063 | 2092 | ||
2064 | // child windows no longer valid | 2093 | // child windows no longer valid |
2065 | clearAllViews(); | 2094 | clearAllViews(); |
2066 | emit closingDown(); | 2095 | emit closingDown(); |
2067 | 2096 | ||
2068 | mCalendar->close(); | 2097 | mCalendar->close(); |
2069 | setModified(false); | 2098 | setModified(false); |
2070 | updateView(); | 2099 | updateView(); |
2071 | } | 2100 | } |
2072 | 2101 | ||
2073 | void CalendarView::archiveCalendar() | 2102 | void CalendarView::archiveCalendar() |
2074 | { | 2103 | { |
2075 | mDialogManager->showArchiveDialog(); | 2104 | mDialogManager->showArchiveDialog(); |
2076 | } | 2105 | } |
2077 | 2106 | ||
2078 | 2107 | ||
2079 | void CalendarView::readSettings() | 2108 | void CalendarView::readSettings() |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index ec5b7ab..d836fee 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -465,96 +465,97 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
465 | 465 | ||
466 | void processIncidenceSelection( Incidence * ); | 466 | void processIncidenceSelection( Incidence * ); |
467 | 467 | ||
468 | void purgeCompleted(); | 468 | void purgeCompleted(); |
469 | bool removeCompletedSubTodos( Todo* ); | 469 | bool removeCompletedSubTodos( Todo* ); |
470 | void slotCalendarChanged(); | 470 | void slotCalendarChanged(); |
471 | bool importBday(); | 471 | bool importBday(); |
472 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 472 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
473 | bool importQtopia( const QString &categoriesFile, | 473 | bool importQtopia( const QString &categoriesFile, |
474 | const QString &datebookFile, | 474 | const QString &datebookFile, |
475 | const QString &tasklistFile ); | 475 | const QString &tasklistFile ); |
476 | void syncExternal( int mode ); | 476 | void syncExternal( int mode ); |
477 | void slotSelectPickerDate( QDate ) ; | 477 | void slotSelectPickerDate( QDate ) ; |
478 | void showDatePicker() ; | 478 | void showDatePicker() ; |
479 | void showDatePickerPopup() ; | 479 | void showDatePickerPopup() ; |
480 | void moveIncidence(Incidence *) ; | 480 | void moveIncidence(Incidence *) ; |
481 | void beamIncidence(Incidence *) ; | 481 | void beamIncidence(Incidence *) ; |
482 | void beamCalendar() ; | 482 | void beamCalendar() ; |
483 | void beamFilteredCalendar() ; | 483 | void beamFilteredCalendar() ; |
484 | void beamIncidenceList(QPtrList<Incidence>) ; | 484 | void beamIncidenceList(QPtrList<Incidence>) ; |
485 | void manageCategories(); | 485 | void manageCategories(); |
486 | int addCategories(); | 486 | int addCategories(); |
487 | void removeCategories(); | 487 | void removeCategories(); |
488 | void setSyncDevice( QString ); | 488 | void setSyncDevice( QString ); |
489 | void setSyncName( QString ); | 489 | void setSyncName( QString ); |
490 | void showDay( QDate ); | 490 | void showDay( QDate ); |
491 | void undo_delete(); | 491 | void undo_delete(); |
492 | protected slots: | 492 | protected slots: |
493 | void resetFocus(); | 493 | void resetFocus(); |
494 | void slotViewerClosed(); | 494 | void slotViewerClosed(); |
495 | void timerAlarm(); | 495 | void timerAlarm(); |
496 | void suspendAlarm(); | 496 | void suspendAlarm(); |
497 | void beamDone( Ir *ir ); | 497 | void beamDone( Ir *ir ); |
498 | /** Select a view or adapt the current view to display the specified dates. */ | 498 | /** Select a view or adapt the current view to display the specified dates. */ |
499 | void showDates( const KCal::DateList & ); | 499 | void showDates( const KCal::DateList & ); |
500 | void selectWeekNum ( int ); | 500 | void selectWeekNum ( int ); |
501 | 501 | ||
502 | public: | 502 | public: |
503 | // show a standard warning | 503 | // show a standard warning |
504 | // returns KMsgBox::yesNoCancel() | 504 | // returns KMsgBox::yesNoCancel() |
505 | int msgCalModified(); | 505 | int msgCalModified(); |
506 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 506 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
507 | 507 | ||
508 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 508 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
509 | virtual void removeSyncInfo( QString syncProfile); | 509 | virtual void removeSyncInfo( QString syncProfile); |
510 | void setSyncManager(KSyncManager* manager); | 510 | void setSyncManager(KSyncManager* manager); |
511 | void setLoadedFileVersion(QDateTime); | 511 | void setLoadedFileVersion(QDateTime); |
512 | bool checkFileVersion(QString fn); | 512 | bool checkFileVersion(QString fn); |
513 | bool checkAllFileVersions(); | ||
513 | bool checkFileChanged(QString fn); | 514 | bool checkFileChanged(QString fn); |
514 | Event* getLastSyncEvent(); | 515 | Event* getLastSyncEvent(); |
515 | /** Adapt navigation units correpsonding to step size of navigation of the | 516 | /** Adapt navigation units correpsonding to step size of navigation of the |
516 | * current view. | 517 | * current view. |
517 | */ | 518 | */ |
518 | void adaptNavigationUnits(); | 519 | void adaptNavigationUnits(); |
519 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 520 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
520 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 521 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
521 | //Attendee* getYourAttendee(Event *event); | 522 | //Attendee* getYourAttendee(Event *event); |
522 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 523 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
523 | protected: | 524 | protected: |
524 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 525 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
525 | 526 | ||
526 | // returns KMsgBox::OKCandel() | 527 | // returns KMsgBox::OKCandel() |
527 | int msgItemDelete(const QString name); | 528 | int msgItemDelete(const QString name); |
528 | void showEventEditor(); | 529 | void showEventEditor(); |
529 | void showTodoEditor(); | 530 | void showTodoEditor(); |
530 | void writeLocale(); | 531 | void writeLocale(); |
531 | Todo *selectedTodo(); | 532 | Todo *selectedTodo(); |
532 | 533 | ||
533 | private: | 534 | private: |
534 | QDateTime mNextAlarmDateTime; | 535 | QDateTime mNextAlarmDateTime; |
535 | bool mViewerCallerIsSearchDialog; | 536 | bool mViewerCallerIsSearchDialog; |
536 | bool mBlockShowDates; | 537 | bool mBlockShowDates; |
537 | KSyncManager* mSyncManager; | 538 | KSyncManager* mSyncManager; |
538 | AlarmDialog * mAlarmDialog; | 539 | AlarmDialog * mAlarmDialog; |
539 | QString mAlarmNotification; | 540 | QString mAlarmNotification; |
540 | QString mSuspendAlarmNotification; | 541 | QString mSuspendAlarmNotification; |
541 | QTimer* mSuspendTimer; | 542 | QTimer* mSuspendTimer; |
542 | QTimer* mAlarmTimer; | 543 | QTimer* mAlarmTimer; |
543 | QTimer* mRecheckAlarmTimer; | 544 | QTimer* mRecheckAlarmTimer; |
544 | void computeAlarm( QString ); | 545 | void computeAlarm( QString ); |
545 | void startAlarm( QString, QString ); | 546 | void startAlarm( QString, QString ); |
546 | void setSyncEventsReadOnly(); | 547 | void setSyncEventsReadOnly(); |
547 | 548 | ||
548 | QDateTime loadedFileVersion; | 549 | QDateTime loadedFileVersion; |
549 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 550 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
550 | void checkExternalId( Incidence * inc ); | 551 | void checkExternalId( Incidence * inc ); |
551 | int mGlobalSyncMode; | 552 | int mGlobalSyncMode; |
552 | QString mCurrentSyncDevice; | 553 | QString mCurrentSyncDevice; |
553 | QString mCurrentSyncName; | 554 | QString mCurrentSyncName; |
554 | KOBeamPrefs* beamDialog; | 555 | KOBeamPrefs* beamDialog; |
555 | void init(); | 556 | void init(); |
556 | int mDatePickerMode; | 557 | int mDatePickerMode; |
557 | bool mFlagEditDescription; | 558 | bool mFlagEditDescription; |
558 | QDateTime mLastCalendarSync; | 559 | QDateTime mLastCalendarSync; |
559 | void createPrinter(); | 560 | void createPrinter(); |
560 | 561 | ||
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index 361eec8..19d731f 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -186,179 +186,195 @@ void KOCalEditView::selectStdCal( int id, bool b ) | |||
186 | } | 186 | } |
187 | } | 187 | } |
188 | it = mStdandardB.next(); | 188 | it = mStdandardB.next(); |
189 | } | 189 | } |
190 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 190 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
191 | while ( kkf ) { | 191 | while ( kkf ) { |
192 | kkf->isStandard = false; | 192 | kkf->isStandard = false; |
193 | kkf = KOPrefs::instance()->mCalendars.next(); | 193 | kkf = KOPrefs::instance()->mCalendars.next(); |
194 | } | 194 | } |
195 | KOPrefs::instance()->getCalendar( id )->isStandard = true; | 195 | KOPrefs::instance()->getCalendar( id )->isStandard = true; |
196 | emit setCalendarDefault ( id ); | 196 | emit setCalendarDefault ( id ); |
197 | } | 197 | } |
198 | 198 | ||
199 | void KOCalEditView::selectCalAlarm(int id ,bool b ) | 199 | void KOCalEditView::selectCalAlarm(int id ,bool b ) |
200 | { | 200 | { |
201 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; | 201 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; |
202 | emit alarmEnabled ( id , b ); | 202 | emit alarmEnabled ( id , b ); |
203 | emit needsUpdate(); | 203 | emit needsUpdate(); |
204 | } | 204 | } |
205 | void KOCalEditView::selectReadOnly(int id ,bool b ) | 205 | void KOCalEditView::selectReadOnly(int id ,bool b ) |
206 | { | 206 | { |
207 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; | 207 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; |
208 | emit calendarReadonly ( id , b ); | 208 | emit calendarReadonly ( id , b ); |
209 | emit needsUpdate(); | 209 | emit needsUpdate(); |
210 | 210 | ||
211 | } | 211 | } |
212 | void KOCalEditView::setColor( const QColor& c, int id ) | 212 | void KOCalEditView::setColor( const QColor& c, int id ) |
213 | { | 213 | { |
214 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; | 214 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; |
215 | emit needsUpdate(); | 215 | emit needsUpdate(); |
216 | } | 216 | } |
217 | void KOCalEditView::deleteCal( int id ) | 217 | void KOCalEditView::deleteCal( int id ) |
218 | { | 218 | { |
219 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 219 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
220 | QString name = kkf->mName; | 220 | QString name = kkf->mName; |
221 | QString file = kkf->mFileName; | 221 | QString file = kkf->mFileName; |
222 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; | 222 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; |
223 | if ( kkf->isStandard ) | 223 | if ( kkf->isStandard ) |
224 | selectStdCal( 1, true ); | 224 | selectStdCal( 1, true ); |
225 | emit removeCalendar ( id ); | 225 | emit removeCalendar ( id ); |
226 | KOPrefs::instance()->mCalendars.remove ( kkf ); | 226 | KOPrefs::instance()->mCalendars.remove ( kkf ); |
227 | emit needsUpdate(); | 227 | emit needsUpdate(); |
228 | readConfig(); | 228 | readConfig(); |
229 | } | 229 | } |
230 | void KOCalEditView::infoCal( int id ) | 230 | void KOCalEditView::infoCal( int id ) |
231 | { | 231 | { |
232 | QString name = KOPrefs::instance()->getCalendar( id )->mName; | 232 | QString name = KOPrefs::instance()->getCalendar( id )->mName; |
233 | QString file = KOPrefs::instance()->getCalendar( id )->mFileName; | 233 | QString file = KOPrefs::instance()->getCalendar( id )->mFileName; |
234 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); | 234 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { |
235 | if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { | ||
236 | emit calendarAdded( id ); | ||
237 | readConfig(); | ||
238 | emit needsUpdate(); | ||
239 | } | ||
240 | } | ||
241 | else | ||
242 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); | ||
235 | } | 243 | } |
236 | void KOCalEditView::readConfig() | 244 | void KOCalEditView::readConfig() |
237 | { | 245 | { |
238 | 246 | ||
239 | mStdandardB.clear(); | 247 | mStdandardB.clear(); |
240 | mEnabledB.clear(); | 248 | mEnabledB.clear(); |
241 | mAlarmB.clear(); | 249 | mAlarmB.clear(); |
242 | mROB.clear(); | 250 | mROB.clear(); |
243 | 251 | ||
244 | if ( mw ) delete mw; | 252 | if ( mw ) delete mw; |
245 | mw = new QWidget ( this ); | 253 | mw = new QWidget ( this ); |
246 | ml->addWidget ( mw ); | 254 | ml->addWidget ( mw ); |
247 | 255 | ||
248 | mainLayout = new QGridLayout ( mw , 2, 8 ); | 256 | mainLayout = new QGridLayout ( mw , 2, 8 ); |
249 | //mainLayout->setSpacing( 3 ); | 257 | //mainLayout->setSpacing( 3 ); |
250 | QPushButton * addBut = new QPushButton ( mw ); | 258 | QPushButton * addBut = new QPushButton ( mw ); |
251 | mainLayout->addWidget( addBut,0,0 ); | 259 | mainLayout->addWidget( addBut,0,0 ); |
252 | addBut->setPixmap ( SmallIcon("plus")); | 260 | addBut->setPixmap ( SmallIcon("plus")); |
253 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); | 261 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); |
254 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 262 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
255 | 263 | ||
256 | addBut = new QPushButton ( mw ); | 264 | addBut = new QPushButton ( mw ); |
257 | mainLayout->addWidget( addBut,0,1 ); | 265 | mainLayout->addWidget( addBut,0,1 ); |
258 | addBut->setPixmap ( SmallIcon("eye")); | 266 | addBut->setPixmap ( SmallIcon("eye")); |
259 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); | 267 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); |
260 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 268 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
261 | 269 | ||
262 | QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw ); | 270 | QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw ); |
263 | mainLayout->addWidget( lab,0,2 ); | 271 | mainLayout->addWidget( lab,0,2 ); |
264 | 272 | ||
265 | addBut = new QPushButton ( mw ); | 273 | addBut = new QPushButton ( mw ); |
266 | mainLayout->addWidget( addBut,0,3 ); | 274 | mainLayout->addWidget( addBut,0,3 ); |
267 | addBut->setPixmap ( SmallIcon("bell")); | 275 | addBut->setPixmap ( SmallIcon("bell")); |
268 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); | 276 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); |
269 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 277 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
270 | 278 | ||
271 | addBut = new QPushButton ( mw ); | 279 | addBut = new QPushButton ( mw ); |
272 | mainLayout->addWidget( addBut,0,4 ); | 280 | mainLayout->addWidget( addBut,0,4 ); |
273 | addBut->setPixmap ( SmallIcon("pencil")); | 281 | addBut->setPixmap ( SmallIcon("pencil")); |
274 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); | 282 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); |
275 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 283 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
276 | 284 | ||
277 | lab = new QLabel ( i18n(" Color "), mw ); | 285 | lab = new QLabel ( i18n(" Color "), mw ); |
278 | mainLayout->addWidget( lab,0,5 ); | 286 | mainLayout->addWidget( lab,0,5 ); |
279 | #if 0 | 287 | #if 0 |
280 | addBut = new QPushButton ( mw ); | 288 | addBut = new QPushButton ( mw ); |
281 | mainLayout->addWidget( addBut,0,6 ); | 289 | mainLayout->addWidget( addBut,0,6 ); |
282 | addBut->setPixmap ( SmallIcon("minus")); | 290 | addBut->setPixmap ( SmallIcon("minus")); |
283 | connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); | 291 | connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); |
284 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 292 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
285 | #endif | 293 | #endif |
286 | 294 | ||
287 | 295 | ||
288 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 296 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
289 | int row = 1; | 297 | int row = 1; |
290 | while ( kkf ) { | 298 | while ( kkf ) { |
291 | 299 | ||
292 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); | 300 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); |
293 | mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); | 301 | mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); |
294 | cb->setChecked( kkf->isStandard ); | 302 | cb->setChecked( kkf->isStandard ); |
295 | cb->setNum( kkf->mCalNumber ); | 303 | cb->setNum( kkf->mCalNumber ); |
296 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); | 304 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); |
305 | if ( kkf->mErrorOnLoad ) | ||
306 | cb->setEnabled( false ); | ||
297 | cb = new KOCalCheckButton( mw ); | 307 | cb = new KOCalCheckButton( mw ); |
298 | mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb ); | 308 | mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb ); |
299 | cb->setChecked( kkf->isEnabled ); | 309 | cb->setChecked( kkf->isEnabled ); |
300 | cb->setNum( kkf->mCalNumber ); | 310 | cb->setNum( kkf->mCalNumber ); |
311 | if ( kkf->mErrorOnLoad ) | ||
312 | cb->setEnabled( false ); | ||
301 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); | 313 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); |
302 | KOCalButton* name = new KOCalButton( mw ); | 314 | KOCalButton* name = new KOCalButton( mw ); |
303 | name->setNum( kkf->mCalNumber ); | 315 | name->setNum( kkf->mCalNumber ); |
304 | name->setText( kkf->mName ); | 316 | name->setText( kkf->mName ); |
305 | mainLayout->addWidget( name,row,2 ); | 317 | mainLayout->addWidget( name,row,2 ); |
306 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); | 318 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); |
307 | cb = new KOCalCheckButton( mw ); | 319 | cb = new KOCalCheckButton( mw ); |
308 | mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb ); | 320 | mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb ); |
309 | cb->setChecked( kkf->isAlarmEnabled ); | 321 | cb->setChecked( kkf->isAlarmEnabled ); |
310 | cb->setNum( kkf->mCalNumber ); | 322 | cb->setNum( kkf->mCalNumber ); |
311 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); | 323 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); |
324 | if ( kkf->mErrorOnLoad ) | ||
325 | cb->setEnabled( false ); | ||
312 | cb = new KOCalCheckButton( mw ); | 326 | cb = new KOCalCheckButton( mw ); |
313 | mainLayout->addWidget( cb,row,4 );mROB.append( cb ); | 327 | mainLayout->addWidget( cb,row,4 );mROB.append( cb ); |
314 | cb->setChecked( kkf->isReadOnly ); | 328 | cb->setChecked( kkf->isReadOnly ); |
315 | cb->setNum( kkf->mCalNumber ); | 329 | cb->setNum( kkf->mCalNumber ); |
316 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); | 330 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); |
331 | if ( kkf->mErrorOnLoad ) | ||
332 | cb->setEnabled( false ); | ||
317 | KColorButton *colb = new KColorButton( mw ); | 333 | KColorButton *colb = new KColorButton( mw ); |
318 | mainLayout->addWidget( colb,row,5 ); | 334 | mainLayout->addWidget( colb,row,5 ); |
319 | colb->setID( kkf->mCalNumber ); | 335 | colb->setID( kkf->mCalNumber ); |
320 | colb->setColor( kkf->mDefaultColor ); | 336 | colb->setColor( kkf->mDefaultColor ); |
321 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); | 337 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); |
322 | if ( row > 1) { | 338 | if ( row > 1) { |
323 | KOCalButton* calb = new KOCalButton( mw ); | 339 | KOCalButton* calb = new KOCalButton( mw ); |
324 | mainLayout->addWidget( calb,row,6 ); | 340 | mainLayout->addWidget( calb,row,6 ); |
325 | calb->setNum( kkf->mCalNumber ); | 341 | calb->setNum( kkf->mCalNumber ); |
326 | calb->setPixmap ( SmallIcon("minus")); | 342 | calb->setPixmap ( SmallIcon("minus")); |
327 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); | 343 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); |
328 | int hei = calb->sizeHint().height(); | 344 | int hei = calb->sizeHint().height(); |
329 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); | 345 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); |
330 | } | 346 | } |
331 | ++row; | 347 | ++row; |
332 | kkf = KOPrefs::instance()->mCalendars.next(); | 348 | kkf = KOPrefs::instance()->mCalendars.next(); |
333 | } | 349 | } |
334 | lab = new QLabel ( "", mw ); | 350 | lab = new QLabel ( "", mw ); |
335 | mainLayout->addWidget( lab,row,0 ); | 351 | mainLayout->addWidget( lab,row,0 ); |
336 | mw->show(); | 352 | mw->show(); |
337 | 353 | ||
338 | } | 354 | } |
339 | void KOCalEditView::addCal() | 355 | void KOCalEditView::addCal() |
340 | { | 356 | { |
341 | qDebug("addcal "); | 357 | qDebug("addcal "); |
342 | KONewCalPrefs prefs ( this ); | 358 | KONewCalPrefs prefs ( this ); |
343 | if ( ! prefs.exec() ) | 359 | if ( ! prefs.exec() ) |
344 | return; | 360 | return; |
345 | QString name = prefs.calName(); | 361 | QString name = prefs.calName(); |
346 | QString file = prefs.calFileName(); | 362 | QString file = prefs.calFileName(); |
347 | QFileInfo fi ( file ); | 363 | QFileInfo fi ( file ); |
348 | if (!fi.exists() ) { | 364 | if (!fi.exists() ) { |
349 | KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!")); | 365 | KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!")); |
350 | return; | 366 | return; |
351 | } | 367 | } |
352 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); | 368 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); |
353 | kkf->mName = name; | 369 | kkf->mName = name; |
354 | kkf->mFileName = file; | 370 | kkf->mFileName = file; |
355 | emit calendarAdded( kkf->mCalNumber ); | 371 | emit calendarAdded( kkf->mCalNumber ); |
356 | readConfig(); | 372 | readConfig(); |
357 | emit needsUpdate(); | 373 | emit needsUpdate(); |
358 | } | 374 | } |
359 | void KOCalEditView::enableAll() | 375 | void KOCalEditView::enableAll() |
360 | { | 376 | { |
361 | toggleList( mEnabledB ); | 377 | toggleList( mEnabledB ); |
362 | } | 378 | } |
363 | void KOCalEditView::enableAlarm() | 379 | void KOCalEditView::enableAlarm() |
364 | { | 380 | { |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index f114d88..463fc33 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -11,105 +11,108 @@ | |||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | 26 | ||
27 | #include <libkdepim/kpimprefs.h> | 27 | #include <libkdepim/kpimprefs.h> |
28 | #include <qdict.h> | 28 | #include <qdict.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qobject.h> | 30 | #include <qobject.h> |
31 | 31 | ||
32 | class KConfig; | 32 | class KConfig; |
33 | class QFont; | 33 | class QFont; |
34 | class QColor; | 34 | class QColor; |
35 | class QStringList; | 35 | class QStringList; |
36 | 36 | ||
37 | #define VIEW_WN_VIEW 1 | 37 | #define VIEW_WN_VIEW 1 |
38 | #define VIEW_NX_VIEW 2 | 38 | #define VIEW_NX_VIEW 2 |
39 | #define VIEW_J_VIEW 3 | 39 | #define VIEW_J_VIEW 3 |
40 | #define VIEW_A_VIEW 4 | 40 | #define VIEW_A_VIEW 4 |
41 | #define VIEW_ML_VIEW 5 | 41 | #define VIEW_ML_VIEW 5 |
42 | #define VIEW_M_VIEW 6 | 42 | #define VIEW_M_VIEW 6 |
43 | #define VIEW_L_VIEW 7 | 43 | #define VIEW_L_VIEW 7 |
44 | #define VIEW_T_VIEW 8 | 44 | #define VIEW_T_VIEW 8 |
45 | 45 | ||
46 | class KopiCalendarFile : public QObject | 46 | class KopiCalendarFile : public QObject |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | KopiCalendarFile( ) : QObject( ) | 49 | KopiCalendarFile( ) : QObject( ) |
50 | { | 50 | { |
51 | isStandard = false; | 51 | isStandard = false; |
52 | isEnabled = true; | 52 | isEnabled = true; |
53 | isAlarmEnabled = true; | 53 | isAlarmEnabled = true; |
54 | isReadOnly = false; | 54 | isReadOnly = false; |
55 | mName = "Calendar"; | 55 | mName = "Calendar"; |
56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; | 56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; |
57 | mCalNumber = 0; | 57 | mCalNumber = 0; |
58 | mDefaultColor = Qt::red; | 58 | mDefaultColor = Qt::red; |
59 | mErrorOnLoad = false; | ||
59 | } | 60 | } |
60 | bool isStandard; | 61 | bool isStandard; |
61 | bool isEnabled; | 62 | bool isEnabled; |
62 | bool isAlarmEnabled; | 63 | bool isAlarmEnabled; |
63 | bool isReadOnly; | 64 | bool isReadOnly; |
65 | bool mErrorOnLoad; | ||
64 | QString mName; | 66 | QString mName; |
65 | QString mFileName; | 67 | QString mFileName; |
66 | int mCalNumber; | 68 | int mCalNumber; |
67 | QColor mDefaultColor; | 69 | QColor mDefaultColor; |
70 | QDateTime mLoadDt; | ||
68 | }; | 71 | }; |
69 | class KOPrefs : public KPimPrefs | 72 | class KOPrefs : public KPimPrefs |
70 | { | 73 | { |
71 | public: | 74 | public: |
72 | enum { FormatVCalendar, FormatICalendar }; | 75 | enum { FormatVCalendar, FormatICalendar }; |
73 | enum { MailClientKMail, MailClientSendmail }; | 76 | enum { MailClientKMail, MailClientSendmail }; |
74 | enum { IMIPDummy, IMIPKMail }; | 77 | enum { IMIPDummy, IMIPKMail }; |
75 | enum { IMIPOutbox, IMIPdirectsend }; | 78 | enum { IMIPOutbox, IMIPdirectsend }; |
76 | enum { neverAuto, addressbookAuto, selectedAuto }; | 79 | enum { neverAuto, addressbookAuto, selectedAuto }; |
77 | enum { standardDestination, askDestination }; | 80 | enum { standardDestination, askDestination }; |
78 | 81 | ||
79 | virtual ~KOPrefs(); | 82 | virtual ~KOPrefs(); |
80 | 83 | ||
81 | /** Get instance of KOPrefs. It is made sure that there is only one | 84 | /** Get instance of KOPrefs. It is made sure that there is only one |
82 | instance. */ | 85 | instance. */ |
83 | static KOPrefs *instance(); | 86 | static KOPrefs *instance(); |
84 | 87 | ||
85 | /** Set preferences to default values */ | 88 | /** Set preferences to default values */ |
86 | void usrSetDefaults(); | 89 | void usrSetDefaults(); |
87 | 90 | ||
88 | /** Read preferences from config file */ | 91 | /** Read preferences from config file */ |
89 | void usrReadConfig(); | 92 | void usrReadConfig(); |
90 | 93 | ||
91 | /** Write preferences to config file */ | 94 | /** Write preferences to config file */ |
92 | void usrWriteConfig(); | 95 | void usrWriteConfig(); |
93 | void setCategoryDefaults(); | 96 | void setCategoryDefaults(); |
94 | void setAllDefaults(); | 97 | void setAllDefaults(); |
95 | KopiCalendarFile * getNewCalendar(); | 98 | KopiCalendarFile * getNewCalendar(); |
96 | KopiCalendarFile * getCalendar( int ); | 99 | KopiCalendarFile * getCalendar( int ); |
97 | void deleteCalendar( int ); | 100 | void deleteCalendar( int ); |
98 | QColor defaultColor( int ) const; | 101 | QColor defaultColor( int ) const; |
99 | protected: | 102 | protected: |
100 | void setTimeZoneIdDefault(); | 103 | void setTimeZoneIdDefault(); |
101 | 104 | ||
102 | /** Fill empty mail fields with default values. */ | 105 | /** Fill empty mail fields with default values. */ |
103 | void fillMailDefaults(); | 106 | void fillMailDefaults(); |
104 | 107 | ||
105 | private: | 108 | private: |
106 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 109 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
107 | object. */ | 110 | object. */ |
108 | KOPrefs(); | 111 | KOPrefs(); |
109 | 112 | ||
110 | static KOPrefs *mInstance; | 113 | static KOPrefs *mInstance; |
111 | QStringList getDefaultList(); | 114 | QStringList getDefaultList(); |
112 | QStringList getLocationDefaultList(); | 115 | QStringList getLocationDefaultList(); |
113 | public: | 116 | public: |
114 | // preferences data | 117 | // preferences data |
115 | KConfig* getConfig(); | 118 | KConfig* getConfig(); |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index f05ada5..472a978 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1779,117 +1779,125 @@ void MainWindow::saveOnClose() | |||
1779 | else | 1779 | else |
1780 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1780 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1781 | 1781 | ||
1782 | if ( p->mToolBarHorN ) | 1782 | if ( p->mToolBarHorN ) |
1783 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1783 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1784 | else | 1784 | else |
1785 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1785 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1786 | if ( filterToolBar ) { | 1786 | if ( filterToolBar ) { |
1787 | if ( p->mToolBarHorF ) | 1787 | if ( p->mToolBarHorF ) |
1788 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1788 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1789 | else | 1789 | else |
1790 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1790 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
1791 | } | 1791 | } |
1792 | #endif | 1792 | #endif |
1793 | 1793 | ||
1794 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1794 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1795 | save(); | 1795 | save(); |
1796 | mView->writeSettings(); | 1796 | mView->writeSettings(); |
1797 | } | 1797 | } |
1798 | void MainWindow::slotModifiedChanged( bool changed ) | 1798 | void MainWindow::slotModifiedChanged( bool changed ) |
1799 | { | 1799 | { |
1800 | if ( mBlockAtStartup ) | 1800 | if ( mBlockAtStartup ) |
1801 | return; | 1801 | return; |
1802 | 1802 | ||
1803 | int msec; | 1803 | int msec; |
1804 | // we store the changes after 1 minute, | 1804 | // we store the changes after 1 minute, |
1805 | // and for safety reasons after 10 minutes again | 1805 | // and for safety reasons after 10 minutes again |
1806 | if ( !mSyncManager->blockSave() ) | 1806 | if ( !mSyncManager->blockSave() ) |
1807 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1807 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1808 | else | 1808 | else |
1809 | msec = 1000 * 600; | 1809 | msec = 1000 * 600; |
1810 | mSaveTimer.start( msec, true ); // 1 minute | 1810 | mSaveTimer.start( msec, true ); // 1 minute |
1811 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1811 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1812 | mCalendarModifiedFlag = true; | 1812 | mCalendarModifiedFlag = true; |
1813 | } | 1813 | } |
1814 | void MainWindow::saveStopTimer() | 1814 | void MainWindow::saveStopTimer() |
1815 | { | 1815 | { |
1816 | mSaveTimer.stop(); | 1816 | mSaveTimer.stop(); |
1817 | } | 1817 | } |
1818 | void MainWindow::save() | 1818 | void MainWindow::save() |
1819 | { | 1819 | { |
1820 | if ( !mCalendarModifiedFlag ) { | 1820 | if ( !mCalendarModifiedFlag ) { |
1821 | qDebug("KO: Calendar not modified. Nothing saved."); | 1821 | qDebug("KO: Calendar not modified. Nothing saved."); |
1822 | return; | 1822 | return; |
1823 | } | 1823 | } |
1824 | if ( mSyncManager->blockSave() ) | 1824 | if ( mSyncManager->blockSave() ) |
1825 | return; | 1825 | return; |
1826 | mSyncManager->setBlockSave(true); | 1826 | mSyncManager->setBlockSave(true); |
1827 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1827 | if ( mView->checkAllFileVersions() ) { |
1828 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 1828 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
1829 | QDate reference ( 2000,1,1); | 1829 | QDate reference ( 2000,1,1); |
1830 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 1830 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1831 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 1831 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
1832 | setCaption(i18n("Creating backup ... please wait ..." )); | 1832 | setCaption(i18n("Creating backup ... please wait ..." )); |
1833 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); | 1833 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); |
1834 | // we need the file path, the backup dir and the number of bups as param | 1834 | // we need the file path, the backup dir and the number of bups as param |
1835 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 1835 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
1836 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 1836 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
1837 | bupDir = KGlobalSettings::backupDataDir(); | 1837 | bupDir = KGlobalSettings::backupDataDir(); |
1838 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 1838 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
1839 | if ( retval == 0 ) { | 1839 | if ( retval == 0 ) { |
1840 | qDebug("KO: Backup cancelled. Will try again tomorrow "); | 1840 | qDebug("KO: Backup cancelled. Will try again tomorrow "); |
1841 | // retval == 0 : backup skipped for today, try again tomorrow | 1841 | // retval == 0 : backup skipped for today, try again tomorrow |
1842 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; | 1842 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; |
1843 | } else if ( retval == 1 ){ | 1843 | } else if ( retval == 1 ){ |
1844 | qDebug("KO: Backup created."); | 1844 | qDebug("KO: Backup created."); |
1845 | // backup ok | 1845 | // backup ok |
1846 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | ||
1847 | KopiCalendarFile * cal = calendars.first(); | ||
1848 | cal = calendars.next(); | ||
1849 | while ( cal ) { | ||
1850 | if ( !cal->mErrorOnLoad ) { | ||
1851 | int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | ||
1852 | } | ||
1853 | cal = calendars.next(); | ||
1854 | } | ||
1846 | KOPrefs::instance()->mLastBackupDate = daysTo; | 1855 | KOPrefs::instance()->mLastBackupDate = daysTo; |
1847 | |||
1848 | } else if ( retval == 2 ){ | 1856 | } else if ( retval == 2 ){ |
1849 | qDebug("KO: Backup globally cancelled."); | 1857 | qDebug("KO: Backup globally cancelled."); |
1850 | // backup globally cancelled | 1858 | // backup globally cancelled |
1851 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 1859 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
1852 | } | 1860 | } |
1853 | // retval == 3: do nothing, try again later | 1861 | // retval == 3: do nothing, try again later |
1854 | } | 1862 | } |
1855 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 1863 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
1856 | } | 1864 | } |
1857 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1865 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1858 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1866 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1859 | qDebug("KO: Start saving data to file!"); | 1867 | qDebug("KO: Start saving data to file!"); |
1860 | mView->saveCalendars(); | 1868 | mView->saveCalendars(); |
1861 | mCalendarModifiedFlag = false; | 1869 | mCalendarModifiedFlag = false; |
1862 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1870 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1863 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1871 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1864 | QString savemes; | 1872 | QString savemes; |
1865 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1873 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1866 | setCaption(savemes); | 1874 | setCaption(savemes); |
1867 | } else | 1875 | } else |
1868 | setCaption(i18n("Saving cancelled!")); | 1876 | setCaption(i18n("Saving cancelled!")); |
1869 | mSyncManager->setBlockSave( false ); | 1877 | mSyncManager->setBlockSave( false ); |
1870 | } | 1878 | } |
1871 | 1879 | ||
1872 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1880 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1873 | { | 1881 | { |
1874 | if ( !e->isAutoRepeat() ) { | 1882 | if ( !e->isAutoRepeat() ) { |
1875 | mFlagKeyPressed = false; | 1883 | mFlagKeyPressed = false; |
1876 | } | 1884 | } |
1877 | } | 1885 | } |
1878 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1886 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1879 | { | 1887 | { |
1880 | qApp->processEvents(); | 1888 | qApp->processEvents(); |
1881 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1889 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1882 | e->ignore(); | 1890 | e->ignore(); |
1883 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1891 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1884 | return; | 1892 | return; |
1885 | } | 1893 | } |
1886 | if (! e->isAutoRepeat() ) | 1894 | if (! e->isAutoRepeat() ) |
1887 | mFlagKeyPressed = true; | 1895 | mFlagKeyPressed = true; |
1888 | KOPrefs *p = KOPrefs::instance(); | 1896 | KOPrefs *p = KOPrefs::instance(); |
1889 | bool showSelectedDates = false; | 1897 | bool showSelectedDates = false; |
1890 | int size; | 1898 | int size; |
1891 | int pro = 0; | 1899 | int pro = 0; |
1892 | //qDebug("MainWindow::keyPressEvent "); | 1900 | //qDebug("MainWindow::keyPressEvent "); |
1893 | switch ( e->key() ) { | 1901 | switch ( e->key() ) { |
1894 | case Qt::Key_Right: | 1902 | case Qt::Key_Right: |
1895 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1903 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |