-rw-r--r-- | korganizer/calendarview.cpp | 14 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 4 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 3 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | korganizer/searchdialog.cpp | 4 |
5 files changed, 24 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 4b3f806..558fc55 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1902,1536 +1902,1545 @@ bool CalendarView::importQtopia( const QString &categories, | |||
1902 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1902 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1903 | bool syncOK = false; | 1903 | bool syncOK = false; |
1904 | QtopiaFormat qtopiaFormat; | 1904 | QtopiaFormat qtopiaFormat; |
1905 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1905 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1906 | bool loadOk = true; | 1906 | bool loadOk = true; |
1907 | if ( !categories.isEmpty() ) | 1907 | if ( !categories.isEmpty() ) |
1908 | loadOk = qtopiaFormat.load( calendar, categories ); | 1908 | loadOk = qtopiaFormat.load( calendar, categories ); |
1909 | if ( loadOk && !datebook.isEmpty() ) | 1909 | if ( loadOk && !datebook.isEmpty() ) |
1910 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1910 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1911 | if ( loadOk && !todolist.isEmpty() ) | 1911 | if ( loadOk && !todolist.isEmpty() ) |
1912 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1912 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1913 | 1913 | ||
1914 | if ( loadOk ) { | 1914 | if ( loadOk ) { |
1915 | getEventViewerDialog()->setSyncMode( true ); | 1915 | getEventViewerDialog()->setSyncMode( true ); |
1916 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1916 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1917 | getEventViewerDialog()->setSyncMode( false ); | 1917 | getEventViewerDialog()->setSyncMode( false ); |
1918 | qApp->processEvents(); | 1918 | qApp->processEvents(); |
1919 | if ( syncOK ) { | 1919 | if ( syncOK ) { |
1920 | if ( mSyncManager->mWriteBackFile ) | 1920 | if ( mSyncManager->mWriteBackFile ) |
1921 | { | 1921 | { |
1922 | // write back XML file | 1922 | // write back XML file |
1923 | 1923 | ||
1924 | } | 1924 | } |
1925 | setModified( true ); | 1925 | setModified( true ); |
1926 | } | 1926 | } |
1927 | } else { | 1927 | } else { |
1928 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1928 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1929 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1929 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1930 | question, i18n("Ok")) ; | 1930 | question, i18n("Ok")) ; |
1931 | } | 1931 | } |
1932 | delete calendar; | 1932 | delete calendar; |
1933 | updateView(); | 1933 | updateView(); |
1934 | return syncOK; | 1934 | return syncOK; |
1935 | 1935 | ||
1936 | 1936 | ||
1937 | #endif | 1937 | #endif |
1938 | 1938 | ||
1939 | } | 1939 | } |
1940 | 1940 | ||
1941 | void CalendarView::setSyncEventsReadOnly() | 1941 | void CalendarView::setSyncEventsReadOnly() |
1942 | { | 1942 | { |
1943 | mCalendar->setSyncEventsReadOnly(); | 1943 | mCalendar->setSyncEventsReadOnly(); |
1944 | } | 1944 | } |
1945 | 1945 | ||
1946 | bool CalendarView::loadCalendars() | 1946 | bool CalendarView::loadCalendars() |
1947 | { | 1947 | { |
1948 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1948 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1949 | KopiCalendarFile * cal = calendars.first(); | 1949 | KopiCalendarFile * cal = calendars.first(); |
1950 | mCalendar->setDefaultCalendar( 1 ); | 1950 | mCalendar->setDefaultCalendar( 1 ); |
1951 | openCalendar( MainWindow::defaultFileName(), false ); | 1951 | openCalendar( MainWindow::defaultFileName(), false ); |
1952 | cal = calendars.next(); | 1952 | cal = calendars.next(); |
1953 | while ( cal ) { | 1953 | while ( cal ) { |
1954 | addCalendar( cal ); | 1954 | addCalendar( cal ); |
1955 | cal = calendars.next(); | 1955 | cal = calendars.next(); |
1956 | } | 1956 | } |
1957 | restoreCalendarSettings(); | 1957 | restoreCalendarSettings(); |
1958 | return true; | 1958 | return true; |
1959 | } | 1959 | } |
1960 | bool CalendarView::restoreCalendarSettings() | 1960 | bool CalendarView::restoreCalendarSettings() |
1961 | { | 1961 | { |
1962 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1962 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1963 | KopiCalendarFile * cal = calendars.first(); | 1963 | KopiCalendarFile * cal = calendars.first(); |
1964 | while ( cal ) { | 1964 | while ( cal ) { |
1965 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 1965 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
1966 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 1966 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
1967 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 1967 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
1968 | if ( cal->isStandard ) | 1968 | if ( cal->isStandard ) |
1969 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 1969 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
1970 | cal = calendars.next(); | 1970 | cal = calendars.next(); |
1971 | } | 1971 | } |
1972 | setSyncEventsReadOnly(); | 1972 | setSyncEventsReadOnly(); |
1973 | mCalendar->reInitAlarmSettings(); | 1973 | mCalendar->reInitAlarmSettings(); |
1974 | updateUnmanagedViews(); | 1974 | updateUnmanagedViews(); |
1975 | updateView(); | 1975 | updateView(); |
1976 | return true; | 1976 | return true; |
1977 | } | 1977 | } |
1978 | void CalendarView::addCalendarId( int id ) | 1978 | void CalendarView::addCalendarId( int id ) |
1979 | { | 1979 | { |
1980 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 1980 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
1981 | if ( cal ) | 1981 | if ( cal ) |
1982 | addCalendar( cal ); | 1982 | addCalendar( cal ); |
1983 | } | 1983 | } |
1984 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 1984 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
1985 | { | 1985 | { |
1986 | cal->mErrorOnLoad = false; | 1986 | cal->mErrorOnLoad = false; |
1987 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 1987 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
1988 | cal->mLoadDt = QDateTime::currentDateTime(); | 1988 | cal->mLoadDt = QDateTime::currentDateTime(); |
1989 | return true; | 1989 | return true; |
1990 | } | 1990 | } |
1991 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 1991 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
1992 | cal->mErrorOnLoad = true; | 1992 | cal->mErrorOnLoad = true; |
1993 | return false; | 1993 | return false; |
1994 | } | 1994 | } |
1995 | bool CalendarView::openCalendar(QString filename, bool merge) | 1995 | bool CalendarView::openCalendar(QString filename, bool merge) |
1996 | { | 1996 | { |
1997 | 1997 | ||
1998 | if (filename.isEmpty()) { | 1998 | if (filename.isEmpty()) { |
1999 | return false; | 1999 | return false; |
2000 | } | 2000 | } |
2001 | 2001 | ||
2002 | if (!QFile::exists(filename)) { | 2002 | if (!QFile::exists(filename)) { |
2003 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2003 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2004 | return false; | 2004 | return false; |
2005 | } | 2005 | } |
2006 | 2006 | ||
2007 | globalFlagBlockAgenda = 1; | 2007 | globalFlagBlockAgenda = 1; |
2008 | clearAllViews(); | 2008 | clearAllViews(); |
2009 | if (!merge) { | 2009 | if (!merge) { |
2010 | mViewManager->setDocumentId( filename ); | 2010 | mViewManager->setDocumentId( filename ); |
2011 | mCalendar->close(); | 2011 | mCalendar->close(); |
2012 | } | 2012 | } |
2013 | mStorage->setFileName( filename ); | 2013 | mStorage->setFileName( filename ); |
2014 | 2014 | ||
2015 | if ( mStorage->load() ) { | 2015 | if ( mStorage->load() ) { |
2016 | if ( merge ) ;//setModified( true ); | 2016 | if ( merge ) ;//setModified( true ); |
2017 | else { | 2017 | else { |
2018 | //setModified( true ); | 2018 | //setModified( true ); |
2019 | mViewManager->setDocumentId( filename ); | 2019 | mViewManager->setDocumentId( filename ); |
2020 | mDialogManager->setDocumentId( filename ); | 2020 | mDialogManager->setDocumentId( filename ); |
2021 | mTodoList->setDocumentId( filename ); | 2021 | mTodoList->setDocumentId( filename ); |
2022 | } | 2022 | } |
2023 | globalFlagBlockAgenda = 2; | 2023 | globalFlagBlockAgenda = 2; |
2024 | // if ( getLastSyncEvent() ) | 2024 | // if ( getLastSyncEvent() ) |
2025 | // getLastSyncEvent()->setReadOnly( true ); | 2025 | // getLastSyncEvent()->setReadOnly( true ); |
2026 | mCalendar->reInitAlarmSettings(); | 2026 | mCalendar->reInitAlarmSettings(); |
2027 | setSyncEventsReadOnly(); | 2027 | setSyncEventsReadOnly(); |
2028 | updateUnmanagedViews(); | 2028 | updateUnmanagedViews(); |
2029 | updateView(); | 2029 | updateView(); |
2030 | if ( filename != MainWindow::defaultFileName() ) { | 2030 | if ( filename != MainWindow::defaultFileName() ) { |
2031 | saveCalendar( MainWindow::defaultFileName() ); | 2031 | saveCalendar( MainWindow::defaultFileName() ); |
2032 | } else { | 2032 | } else { |
2033 | QFileInfo finf ( MainWindow::defaultFileName()); | 2033 | QFileInfo finf ( MainWindow::defaultFileName()); |
2034 | if ( finf.exists() ) { | 2034 | if ( finf.exists() ) { |
2035 | setLoadedFileVersion( finf.lastModified () ); | 2035 | setLoadedFileVersion( finf.lastModified () ); |
2036 | } | 2036 | } |
2037 | } | 2037 | } |
2038 | return true; | 2038 | return true; |
2039 | } else { | 2039 | } else { |
2040 | // while failing to load, the calendar object could | 2040 | // while failing to load, the calendar object could |
2041 | // have become partially populated. Clear it out. | 2041 | // have become partially populated. Clear it out. |
2042 | if ( !merge ) { | 2042 | if ( !merge ) { |
2043 | mCalendar->close(); | 2043 | mCalendar->close(); |
2044 | mViewManager->setDocumentId( filename ); | 2044 | mViewManager->setDocumentId( filename ); |
2045 | mDialogManager->setDocumentId( filename ); | 2045 | mDialogManager->setDocumentId( filename ); |
2046 | mTodoList->setDocumentId( filename ); | 2046 | mTodoList->setDocumentId( filename ); |
2047 | } | 2047 | } |
2048 | 2048 | ||
2049 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2049 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2050 | 2050 | ||
2051 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2051 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2052 | globalFlagBlockAgenda = 2; | 2052 | globalFlagBlockAgenda = 2; |
2053 | mCalendar->reInitAlarmSettings(); | 2053 | mCalendar->reInitAlarmSettings(); |
2054 | setSyncEventsReadOnly(); | 2054 | setSyncEventsReadOnly(); |
2055 | updateUnmanagedViews(); | 2055 | updateUnmanagedViews(); |
2056 | updateView(); | 2056 | updateView(); |
2057 | } | 2057 | } |
2058 | return false; | 2058 | return false; |
2059 | } | 2059 | } |
2060 | void CalendarView::showOpenError() | 2060 | void CalendarView::showOpenError() |
2061 | { | 2061 | { |
2062 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2062 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2063 | } | 2063 | } |
2064 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2064 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2065 | { | 2065 | { |
2066 | loadedFileVersion = dt; | 2066 | loadedFileVersion = dt; |
2067 | } | 2067 | } |
2068 | bool CalendarView::checkFileChanged(QString fn) | 2068 | bool CalendarView::checkFileChanged(QString fn) |
2069 | { | 2069 | { |
2070 | QFileInfo finf ( fn ); | 2070 | QFileInfo finf ( fn ); |
2071 | if ( !finf.exists() ) | 2071 | if ( !finf.exists() ) |
2072 | return true; | 2072 | return true; |
2073 | QDateTime dt = finf.lastModified (); | 2073 | QDateTime dt = finf.lastModified (); |
2074 | if ( dt <= loadedFileVersion ) | 2074 | if ( dt <= loadedFileVersion ) |
2075 | return false; | 2075 | return false; |
2076 | return true; | 2076 | return true; |
2077 | 2077 | ||
2078 | } | 2078 | } |
2079 | void CalendarView::watchSavedFile() | 2079 | void CalendarView::watchSavedFile() |
2080 | { | 2080 | { |
2081 | QFileInfo finf ( MainWindow::defaultFileName()); | 2081 | QFileInfo finf ( MainWindow::defaultFileName()); |
2082 | if ( !finf.exists() ) | 2082 | if ( !finf.exists() ) |
2083 | return; | 2083 | return; |
2084 | QDateTime dt = finf.lastModified (); | 2084 | QDateTime dt = finf.lastModified (); |
2085 | if ( dt < loadedFileVersion ) { | 2085 | if ( dt < loadedFileVersion ) { |
2086 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2086 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2087 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2087 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2088 | return; | 2088 | return; |
2089 | } | 2089 | } |
2090 | loadedFileVersion = dt; | 2090 | loadedFileVersion = dt; |
2091 | } | 2091 | } |
2092 | bool CalendarView::checkAllFileVersions() | 2092 | bool CalendarView::checkAllFileVersions() |
2093 | { | 2093 | { |
2094 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2094 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2095 | KopiCalendarFile * cal = calendars.first(); | 2095 | KopiCalendarFile * cal = calendars.first(); |
2096 | mCalendar->setDefaultCalendar( 1 ); | 2096 | mCalendar->setDefaultCalendar( 1 ); |
2097 | mCalendar->setDefaultCalendarEnabledOnly(); | 2097 | mCalendar->setDefaultCalendarEnabledOnly(); |
2098 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2098 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2099 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2099 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2100 | restoreCalendarSettings(); | 2100 | restoreCalendarSettings(); |
2101 | return false; | 2101 | return false; |
2102 | } | 2102 | } |
2103 | } | 2103 | } |
2104 | cal = calendars.next(); | 2104 | cal = calendars.next(); |
2105 | QDateTime storeTemp = loadedFileVersion; | 2105 | QDateTime storeTemp = loadedFileVersion; |
2106 | while ( cal ) { | 2106 | while ( cal ) { |
2107 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2107 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2108 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2108 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2109 | mCalendar->setDefaultCalendarEnabledOnly(); | 2109 | mCalendar->setDefaultCalendarEnabledOnly(); |
2110 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2110 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2111 | if ( !checkFileVersion(cal->mFileName )) { | 2111 | if ( !checkFileVersion(cal->mFileName )) { |
2112 | loadedFileVersion = storeTemp; | 2112 | loadedFileVersion = storeTemp; |
2113 | restoreCalendarSettings(); | 2113 | restoreCalendarSettings(); |
2114 | return false; | 2114 | return false; |
2115 | } | 2115 | } |
2116 | } | 2116 | } |
2117 | cal = calendars.next(); | 2117 | cal = calendars.next(); |
2118 | } | 2118 | } |
2119 | loadedFileVersion = storeTemp; | 2119 | loadedFileVersion = storeTemp; |
2120 | return true; | 2120 | return true; |
2121 | } | 2121 | } |
2122 | bool CalendarView::checkFileVersion(QString fn) | 2122 | bool CalendarView::checkFileVersion(QString fn) |
2123 | { | 2123 | { |
2124 | QFileInfo finf ( fn ); | 2124 | QFileInfo finf ( fn ); |
2125 | if ( !finf.exists() ) | 2125 | if ( !finf.exists() ) |
2126 | return true; | 2126 | return true; |
2127 | QDateTime dt = finf.lastModified (); | 2127 | QDateTime dt = finf.lastModified (); |
2128 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2128 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2129 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2129 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2130 | if ( dt <= loadedFileVersion ) | 2130 | if ( dt <= loadedFileVersion ) |
2131 | return true; | 2131 | return true; |
2132 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non 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(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2132 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non 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(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2133 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2133 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2134 | i18n("Sync+save")); | 2134 | i18n("Sync+save")); |
2135 | 2135 | ||
2136 | if ( km == KMessageBox::Cancel ) | 2136 | if ( km == KMessageBox::Cancel ) |
2137 | return false; | 2137 | return false; |
2138 | if ( km == KMessageBox::Yes ) | 2138 | if ( km == KMessageBox::Yes ) |
2139 | return true; | 2139 | return true; |
2140 | 2140 | ||
2141 | setSyncDevice("deleteaftersync" ); | 2141 | setSyncDevice("deleteaftersync" ); |
2142 | mSyncManager->mAskForPreferences = true; | 2142 | mSyncManager->mAskForPreferences = true; |
2143 | mSyncManager->mSyncAlgoPrefs = 3; | 2143 | mSyncManager->mSyncAlgoPrefs = 3; |
2144 | mSyncManager->mWriteBackFile = false; | 2144 | mSyncManager->mWriteBackFile = false; |
2145 | mSyncManager->mWriteBackExistingOnly = false; | 2145 | mSyncManager->mWriteBackExistingOnly = false; |
2146 | mSyncManager->mShowSyncSummary = false; | 2146 | mSyncManager->mShowSyncSummary = false; |
2147 | syncCalendar( fn, 3 ); | 2147 | syncCalendar( fn, 3 ); |
2148 | Event * e = getLastSyncEvent(); | 2148 | Event * e = getLastSyncEvent(); |
2149 | if ( e ) | 2149 | if ( e ) |
2150 | mCalendar->deleteEvent( e ); | 2150 | mCalendar->deleteEvent( e ); |
2151 | return true; | 2151 | return true; |
2152 | } | 2152 | } |
2153 | bool CalendarView::saveCalendars() | 2153 | bool CalendarView::saveCalendars() |
2154 | { | 2154 | { |
2155 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2155 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2156 | KopiCalendarFile * cal = calendars.first(); | 2156 | KopiCalendarFile * cal = calendars.first(); |
2157 | mCalendar->setDefaultCalendar( 1 ); | 2157 | mCalendar->setDefaultCalendar( 1 ); |
2158 | mCalendar->setDefaultCalendarEnabledOnly(); | 2158 | mCalendar->setDefaultCalendarEnabledOnly(); |
2159 | saveCalendar( MainWindow::defaultFileName() ); | 2159 | saveCalendar( MainWindow::defaultFileName() ); |
2160 | cal = calendars.next(); | 2160 | cal = calendars.next(); |
2161 | while ( cal ) { | 2161 | while ( cal ) { |
2162 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2162 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2163 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2163 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2164 | mCalendar->setDefaultCalendarEnabledOnly(); | 2164 | mCalendar->setDefaultCalendarEnabledOnly(); |
2165 | if ( saveCalendar( cal->mFileName ) ) | 2165 | if ( saveCalendar( cal->mFileName ) ) |
2166 | cal->mLoadDt = QDateTime::currentDateTime(); | 2166 | cal->mLoadDt = QDateTime::currentDateTime(); |
2167 | } | 2167 | } |
2168 | cal = calendars.next(); | 2168 | cal = calendars.next(); |
2169 | } | 2169 | } |
2170 | restoreCalendarSettings(); | 2170 | restoreCalendarSettings(); |
2171 | return true; | 2171 | return true; |
2172 | } | 2172 | } |
2173 | bool CalendarView::saveCalendar( QString filename ) | 2173 | bool CalendarView::saveCalendar( QString filename ) |
2174 | { | 2174 | { |
2175 | 2175 | ||
2176 | // Store back all unsaved data into calendar object | 2176 | // Store back all unsaved data into calendar object |
2177 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2177 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2178 | if ( mViewManager->currentView() ) | 2178 | if ( mViewManager->currentView() ) |
2179 | mViewManager->currentView()->flushView(); | 2179 | mViewManager->currentView()->flushView(); |
2180 | 2180 | ||
2181 | 2181 | ||
2182 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2182 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2183 | mStorage->setSaveFormat( new ICalFormat() ); | 2183 | mStorage->setSaveFormat( new ICalFormat() ); |
2184 | mStorage->setFileName( filename ); | 2184 | mStorage->setFileName( filename ); |
2185 | bool success; | 2185 | bool success; |
2186 | success = mStorage->save(); | 2186 | success = mStorage->save(); |
2187 | if ( !success ) { | 2187 | if ( !success ) { |
2188 | return false; | 2188 | return false; |
2189 | } | 2189 | } |
2190 | if ( filename == MainWindow::defaultFileName() ) { | 2190 | if ( filename == MainWindow::defaultFileName() ) { |
2191 | setLoadedFileVersion( lfv ); | 2191 | setLoadedFileVersion( lfv ); |
2192 | watchSavedFile(); | 2192 | watchSavedFile(); |
2193 | } | 2193 | } |
2194 | return true; | 2194 | return true; |
2195 | } | 2195 | } |
2196 | 2196 | ||
2197 | void CalendarView::closeCalendar() | 2197 | void CalendarView::closeCalendar() |
2198 | { | 2198 | { |
2199 | 2199 | ||
2200 | // child windows no longer valid | 2200 | // child windows no longer valid |
2201 | clearAllViews(); | 2201 | clearAllViews(); |
2202 | emit closingDown(); | 2202 | emit closingDown(); |
2203 | 2203 | ||
2204 | mCalendar->close(); | 2204 | mCalendar->close(); |
2205 | setModified(false); | 2205 | setModified(false); |
2206 | updateView(); | 2206 | updateView(); |
2207 | } | 2207 | } |
2208 | 2208 | ||
2209 | void CalendarView::archiveCalendar() | 2209 | void CalendarView::archiveCalendar() |
2210 | { | 2210 | { |
2211 | mDialogManager->showArchiveDialog(); | 2211 | mDialogManager->showArchiveDialog(); |
2212 | } | 2212 | } |
2213 | 2213 | ||
2214 | 2214 | ||
2215 | void CalendarView::readSettings() | 2215 | void CalendarView::readSettings() |
2216 | { | 2216 | { |
2217 | 2217 | ||
2218 | 2218 | ||
2219 | // mViewManager->showAgendaView(); | 2219 | // mViewManager->showAgendaView(); |
2220 | QString str; | 2220 | QString str; |
2221 | //qDebug("CalendarView::readSettings() "); | 2221 | //qDebug("CalendarView::readSettings() "); |
2222 | // read settings from the KConfig, supplying reasonable | 2222 | // read settings from the KConfig, supplying reasonable |
2223 | // defaults where none are to be found | 2223 | // defaults where none are to be found |
2224 | KConfig *config = KOGlobals::config(); | 2224 | KConfig *config = KOGlobals::config(); |
2225 | #ifndef KORG_NOSPLITTER | 2225 | #ifndef KORG_NOSPLITTER |
2226 | config->setGroup("KOrganizer Geometry"); | 2226 | config->setGroup("KOrganizer Geometry"); |
2227 | 2227 | ||
2228 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2228 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2229 | if (sizes.count() != 2) { | 2229 | if (sizes.count() != 2) { |
2230 | sizes << mDateNavigator->minimumSizeHint().width(); | 2230 | sizes << mDateNavigator->minimumSizeHint().width(); |
2231 | sizes << 300; | 2231 | sizes << 300; |
2232 | } | 2232 | } |
2233 | mPanner->setSizes(sizes); | 2233 | mPanner->setSizes(sizes); |
2234 | 2234 | ||
2235 | sizes = config->readIntListEntry("Separator2"); | 2235 | sizes = config->readIntListEntry("Separator2"); |
2236 | if ( ( mResourceView && sizes.count() == 4 ) || | 2236 | if ( ( mResourceView && sizes.count() == 4 ) || |
2237 | ( !mResourceView && sizes.count() == 3 ) ) { | 2237 | ( !mResourceView && sizes.count() == 3 ) ) { |
2238 | mLeftSplitter->setSizes(sizes); | 2238 | mLeftSplitter->setSizes(sizes); |
2239 | } | 2239 | } |
2240 | #endif | 2240 | #endif |
2241 | globalFlagBlockAgenda = 1; | 2241 | globalFlagBlockAgenda = 1; |
2242 | mViewManager->showAgendaView(); | 2242 | mViewManager->showAgendaView(); |
2243 | //mViewManager->readSettings( config ); | 2243 | //mViewManager->readSettings( config ); |
2244 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2244 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2245 | readFilterSettings(config); | 2245 | readFilterSettings(config); |
2246 | 2246 | ||
2247 | #ifdef DESKTOP_VERSION | 2247 | #ifdef DESKTOP_VERSION |
2248 | config->setGroup("WidgetLayout"); | 2248 | config->setGroup("WidgetLayout"); |
2249 | QStringList list; | 2249 | QStringList list; |
2250 | list = config->readListEntry("MainLayout"); | 2250 | list = config->readListEntry("MainLayout"); |
2251 | int x,y,w,h; | 2251 | int x,y,w,h; |
2252 | if ( ! list.isEmpty() ) { | 2252 | if ( ! list.isEmpty() ) { |
2253 | x = list[0].toInt(); | 2253 | x = list[0].toInt(); |
2254 | y = list[1].toInt(); | 2254 | y = list[1].toInt(); |
2255 | w = list[2].toInt(); | 2255 | w = list[2].toInt(); |
2256 | h = list[3].toInt(); | 2256 | h = list[3].toInt(); |
2257 | KApplication::testCoords( &x,&y,&w,&h ); | 2257 | KApplication::testCoords( &x,&y,&w,&h ); |
2258 | topLevelWidget()->setGeometry(x,y,w,h); | 2258 | topLevelWidget()->setGeometry(x,y,w,h); |
2259 | 2259 | ||
2260 | } else { | 2260 | } else { |
2261 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2261 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2262 | } | 2262 | } |
2263 | list = config->readListEntry("EditEventLayout"); | 2263 | list = config->readListEntry("EditEventLayout"); |
2264 | if ( ! list.isEmpty() ) { | 2264 | if ( ! list.isEmpty() ) { |
2265 | x = list[0].toInt(); | 2265 | x = list[0].toInt(); |
2266 | y = list[1].toInt(); | 2266 | y = list[1].toInt(); |
2267 | w = list[2].toInt(); | 2267 | w = list[2].toInt(); |
2268 | h = list[3].toInt(); | 2268 | h = list[3].toInt(); |
2269 | KApplication::testCoords( &x,&y,&w,&h ); | 2269 | KApplication::testCoords( &x,&y,&w,&h ); |
2270 | mEventEditor->setGeometry(x,y,w,h); | 2270 | mEventEditor->setGeometry(x,y,w,h); |
2271 | 2271 | ||
2272 | } | 2272 | } |
2273 | list = config->readListEntry("EditTodoLayout"); | 2273 | list = config->readListEntry("EditTodoLayout"); |
2274 | if ( ! list.isEmpty() ) { | 2274 | if ( ! list.isEmpty() ) { |
2275 | x = list[0].toInt(); | 2275 | x = list[0].toInt(); |
2276 | y = list[1].toInt(); | 2276 | y = list[1].toInt(); |
2277 | w = list[2].toInt(); | 2277 | w = list[2].toInt(); |
2278 | h = list[3].toInt(); | 2278 | h = list[3].toInt(); |
2279 | KApplication::testCoords( &x,&y,&w,&h ); | 2279 | KApplication::testCoords( &x,&y,&w,&h ); |
2280 | mTodoEditor->setGeometry(x,y,w,h); | 2280 | mTodoEditor->setGeometry(x,y,w,h); |
2281 | 2281 | ||
2282 | } | 2282 | } |
2283 | list = config->readListEntry("ViewerLayout"); | 2283 | list = config->readListEntry("ViewerLayout"); |
2284 | if ( ! list.isEmpty() ) { | 2284 | if ( ! list.isEmpty() ) { |
2285 | x = list[0].toInt(); | 2285 | x = list[0].toInt(); |
2286 | y = list[1].toInt(); | 2286 | y = list[1].toInt(); |
2287 | w = list[2].toInt(); | 2287 | w = list[2].toInt(); |
2288 | h = list[3].toInt(); | 2288 | h = list[3].toInt(); |
2289 | KApplication::testCoords( &x,&y,&w,&h ); | 2289 | KApplication::testCoords( &x,&y,&w,&h ); |
2290 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2290 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2291 | } | 2291 | } |
2292 | #endif | 2292 | #endif |
2293 | config->setGroup( "Views" ); | 2293 | config->setGroup( "Views" ); |
2294 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2294 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2295 | 2295 | ||
2296 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2296 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2297 | 2297 | ||
2298 | int resetval = 0; | 2298 | int resetval = 0; |
2299 | int maxVal = 0; | 2299 | int maxVal = 0; |
2300 | if (sizes.count() != 3) { | 2300 | if (sizes.count() != 3) { |
2301 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2301 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2302 | resetval = mDateNavigator->sizeHint().width()+2; | 2302 | resetval = mDateNavigator->sizeHint().width()+2; |
2303 | } else { | 2303 | } else { |
2304 | resetval = mDateNavigator->sizeHint().height()+2; | 2304 | resetval = mDateNavigator->sizeHint().height()+2; |
2305 | } | 2305 | } |
2306 | } | 2306 | } |
2307 | if ( resetval ) { | 2307 | if ( resetval ) { |
2308 | sizes.clear(); | 2308 | sizes.clear(); |
2309 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2309 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2310 | maxVal = QApplication::desktop()->width() -10; | 2310 | maxVal = QApplication::desktop()->width() -10; |
2311 | } else { | 2311 | } else { |
2312 | maxVal = QApplication::desktop()->height()-10; | 2312 | maxVal = QApplication::desktop()->height()-10; |
2313 | } | 2313 | } |
2314 | sizes << resetval; | 2314 | sizes << resetval; |
2315 | if ( maxVal < resetval + resetval) | 2315 | if ( maxVal < resetval + resetval) |
2316 | resetval = maxVal - resetval; | 2316 | resetval = maxVal - resetval; |
2317 | sizes << resetval; | 2317 | sizes << resetval; |
2318 | sizes << 100; | 2318 | sizes << 100; |
2319 | } | 2319 | } |
2320 | mLeftFrame->setSizes(sizes); | 2320 | mLeftFrame->setSizes(sizes); |
2321 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2321 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2322 | resetval = 0; | 2322 | resetval = 0; |
2323 | maxVal = 0; | 2323 | maxVal = 0; |
2324 | if (sizes.count() != 2) { | 2324 | if (sizes.count() != 2) { |
2325 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2325 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2326 | resetval = mDateNavigator->sizeHint().width()+2; | 2326 | resetval = mDateNavigator->sizeHint().width()+2; |
2327 | } else { | 2327 | } else { |
2328 | resetval = mDateNavigator->sizeHint().height()+2; | 2328 | resetval = mDateNavigator->sizeHint().height()+2; |
2329 | } | 2329 | } |
2330 | } | 2330 | } |
2331 | if ( resetval ) { | 2331 | if ( resetval ) { |
2332 | sizes.clear(); | 2332 | sizes.clear(); |
2333 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2333 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2334 | maxVal = QApplication::desktop()->width() -10; | 2334 | maxVal = QApplication::desktop()->width() -10; |
2335 | } else { | 2335 | } else { |
2336 | maxVal = QApplication::desktop()->height()-10; | 2336 | maxVal = QApplication::desktop()->height()-10; |
2337 | } | 2337 | } |
2338 | sizes << resetval; | 2338 | sizes << resetval; |
2339 | if ( maxVal < resetval + resetval) | 2339 | if ( maxVal < resetval + resetval) |
2340 | resetval = maxVal - resetval; | 2340 | resetval = maxVal - resetval; |
2341 | sizes << resetval; | 2341 | sizes << resetval; |
2342 | } | 2342 | } |
2343 | mMainFrame->setSizes(sizes); | 2343 | mMainFrame->setSizes(sizes); |
2344 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2344 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2345 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2345 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2346 | else mNavigator->selectDates( dateCount ); | 2346 | else mNavigator->selectDates( dateCount ); |
2347 | // mViewManager->readSettings( config ); | 2347 | // mViewManager->readSettings( config ); |
2348 | updateConfig(); | 2348 | updateConfig(); |
2349 | globalFlagBlockAgenda = 2; | 2349 | globalFlagBlockAgenda = 2; |
2350 | mViewManager->readSettings( config ); | 2350 | mViewManager->readSettings( config ); |
2351 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2351 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2352 | } | 2352 | } |
2353 | 2353 | ||
2354 | void CalendarView::checkSuspendAlarm() | 2354 | void CalendarView::checkSuspendAlarm() |
2355 | { | 2355 | { |
2356 | if ( mSuspendTimer->isActive() ) { | 2356 | if ( mSuspendTimer->isActive() ) { |
2357 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2357 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2358 | } | 2358 | } |
2359 | } | 2359 | } |
2360 | void CalendarView::writeSettings() | 2360 | void CalendarView::writeSettings() |
2361 | { | 2361 | { |
2362 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2362 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2363 | 2363 | ||
2364 | KConfig *config = KOGlobals::config(); | 2364 | KConfig *config = KOGlobals::config(); |
2365 | 2365 | ||
2366 | mViewManager->writeSettings( config ); | 2366 | mViewManager->writeSettings( config ); |
2367 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2367 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2368 | mDialogManager->writeSettings( config ); | 2368 | mDialogManager->writeSettings( config ); |
2369 | //KOPrefs::instance()->usrWriteConfig(); | 2369 | //KOPrefs::instance()->usrWriteConfig(); |
2370 | KOPrefs::instance()->writeConfig(); | 2370 | KOPrefs::instance()->writeConfig(); |
2371 | 2371 | ||
2372 | writeFilterSettings(config); | 2372 | writeFilterSettings(config); |
2373 | config->setGroup( "AppRun" ); | 2373 | config->setGroup( "AppRun" ); |
2374 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2374 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2375 | int days = dt.daysTo( QDate::currentDate() ); | 2375 | int days = dt.daysTo( QDate::currentDate() ); |
2376 | dt = dt.addDays( days ); | 2376 | dt = dt.addDays( days ); |
2377 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2377 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2378 | config->writeEntry( "LatestProgramStopDays", days ); | 2378 | config->writeEntry( "LatestProgramStopDays", days ); |
2379 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2379 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2380 | //qDebug("KO: Writing stop time: %d ", secs); | 2380 | //qDebug("KO: Writing stop time: %d ", secs); |
2381 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2381 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2382 | //QDateTime latest = dt.addSecs ( secs ); | 2382 | //QDateTime latest = dt.addSecs ( secs ); |
2383 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2383 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2384 | config->setGroup( "Views" ); | 2384 | config->setGroup( "Views" ); |
2385 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2385 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2386 | 2386 | ||
2387 | #if 0 | 2387 | #if 0 |
2388 | qDebug("********************* "); | 2388 | qDebug("********************* "); |
2389 | qDebug("Testcode secsto "); | 2389 | qDebug("Testcode secsto "); |
2390 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2390 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2391 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2391 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2392 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2392 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2393 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2393 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2394 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2394 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2395 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2395 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2396 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2396 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2397 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2397 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2398 | qDebug("********************* testcode end"); | 2398 | qDebug("********************* testcode end"); |
2399 | 2399 | ||
2400 | #endif | 2400 | #endif |
2401 | 2401 | ||
2402 | QValueList<int> listINT = mLeftFrame->sizes(); | 2402 | QValueList<int> listINT = mLeftFrame->sizes(); |
2403 | config->writeEntry("Left Splitter Frame",listINT); | 2403 | config->writeEntry("Left Splitter Frame",listINT); |
2404 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2404 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2405 | config->writeEntry("Main Splitter Frame",listINT2); | 2405 | config->writeEntry("Main Splitter Frame",listINT2); |
2406 | #ifdef DESKTOP_VERSION | 2406 | #ifdef DESKTOP_VERSION |
2407 | config->setGroup("WidgetLayout"); | 2407 | config->setGroup("WidgetLayout"); |
2408 | QStringList list ;//= config->readListEntry("MainLayout"); | 2408 | QStringList list ;//= config->readListEntry("MainLayout"); |
2409 | int x,y,w,h; | 2409 | int x,y,w,h; |
2410 | QWidget* wid; | 2410 | QWidget* wid; |
2411 | wid = topLevelWidget(); | 2411 | wid = topLevelWidget(); |
2412 | x = wid->geometry().x(); | 2412 | x = wid->geometry().x(); |
2413 | y = wid->geometry().y(); | 2413 | y = wid->geometry().y(); |
2414 | w = wid->width(); | 2414 | w = wid->width(); |
2415 | h = wid->height(); | 2415 | h = wid->height(); |
2416 | list.clear(); | 2416 | list.clear(); |
2417 | list << QString::number( x ); | 2417 | list << QString::number( x ); |
2418 | list << QString::number( y ); | 2418 | list << QString::number( y ); |
2419 | list << QString::number( w ); | 2419 | list << QString::number( w ); |
2420 | list << QString::number( h ); | 2420 | list << QString::number( h ); |
2421 | config->writeEntry("MainLayout",list ); | 2421 | config->writeEntry("MainLayout",list ); |
2422 | 2422 | ||
2423 | wid = mEventEditor; | 2423 | wid = mEventEditor; |
2424 | x = wid->geometry().x(); | 2424 | x = wid->geometry().x(); |
2425 | y = wid->geometry().y(); | 2425 | y = wid->geometry().y(); |
2426 | w = wid->width(); | 2426 | w = wid->width(); |
2427 | h = wid->height(); | 2427 | h = wid->height(); |
2428 | list.clear(); | 2428 | list.clear(); |
2429 | list << QString::number( x ); | 2429 | list << QString::number( x ); |
2430 | list << QString::number( y ); | 2430 | list << QString::number( y ); |
2431 | list << QString::number( w ); | 2431 | list << QString::number( w ); |
2432 | list << QString::number( h ); | 2432 | list << QString::number( h ); |
2433 | config->writeEntry("EditEventLayout",list ); | 2433 | config->writeEntry("EditEventLayout",list ); |
2434 | 2434 | ||
2435 | wid = mTodoEditor; | 2435 | wid = mTodoEditor; |
2436 | x = wid->geometry().x(); | 2436 | x = wid->geometry().x(); |
2437 | y = wid->geometry().y(); | 2437 | y = wid->geometry().y(); |
2438 | w = wid->width(); | 2438 | w = wid->width(); |
2439 | h = wid->height(); | 2439 | h = wid->height(); |
2440 | list.clear(); | 2440 | list.clear(); |
2441 | list << QString::number( x ); | 2441 | list << QString::number( x ); |
2442 | list << QString::number( y ); | 2442 | list << QString::number( y ); |
2443 | list << QString::number( w ); | 2443 | list << QString::number( w ); |
2444 | list << QString::number( h ); | 2444 | list << QString::number( h ); |
2445 | config->writeEntry("EditTodoLayout",list ); | 2445 | config->writeEntry("EditTodoLayout",list ); |
2446 | wid = getEventViewerDialog(); | 2446 | wid = getEventViewerDialog(); |
2447 | x = wid->geometry().x(); | 2447 | x = wid->geometry().x(); |
2448 | y = wid->geometry().y(); | 2448 | y = wid->geometry().y(); |
2449 | w = wid->width(); | 2449 | w = wid->width(); |
2450 | h = wid->height(); | 2450 | h = wid->height(); |
2451 | list.clear(); | 2451 | list.clear(); |
2452 | list << QString::number( x ); | 2452 | list << QString::number( x ); |
2453 | list << QString::number( y ); | 2453 | list << QString::number( y ); |
2454 | list << QString::number( w ); | 2454 | list << QString::number( w ); |
2455 | list << QString::number( h ); | 2455 | list << QString::number( h ); |
2456 | config->writeEntry("ViewerLayout",list ); | 2456 | config->writeEntry("ViewerLayout",list ); |
2457 | wid = mDialogManager->getSearchDialog(); | 2457 | wid = mDialogManager->getSearchDialog(); |
2458 | if ( wid ) { | 2458 | if ( wid ) { |
2459 | x = wid->geometry().x(); | 2459 | x = wid->geometry().x(); |
2460 | y = wid->geometry().y(); | 2460 | y = wid->geometry().y(); |
2461 | w = wid->width(); | 2461 | w = wid->width(); |
2462 | h = wid->height(); | 2462 | h = wid->height(); |
2463 | list.clear(); | 2463 | list.clear(); |
2464 | list << QString::number( x ); | 2464 | list << QString::number( x ); |
2465 | list << QString::number( y ); | 2465 | list << QString::number( y ); |
2466 | list << QString::number( w ); | 2466 | list << QString::number( w ); |
2467 | list << QString::number( h ); | 2467 | list << QString::number( h ); |
2468 | config->writeEntry("SearchLayout",list ); | 2468 | config->writeEntry("SearchLayout",list ); |
2469 | } | 2469 | } |
2470 | #endif | 2470 | #endif |
2471 | 2471 | ||
2472 | 2472 | ||
2473 | config->sync(); | 2473 | config->sync(); |
2474 | } | 2474 | } |
2475 | 2475 | ||
2476 | void CalendarView::readFilterSettings(KConfig *config) | 2476 | void CalendarView::readFilterSettings(KConfig *config) |
2477 | { | 2477 | { |
2478 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2478 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2479 | 2479 | ||
2480 | mFilters.clear(); | 2480 | mFilters.clear(); |
2481 | 2481 | ||
2482 | config->setGroup("General"); | 2482 | config->setGroup("General"); |
2483 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2483 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2484 | 2484 | ||
2485 | QStringList::ConstIterator it = filterList.begin(); | 2485 | QStringList::ConstIterator it = filterList.begin(); |
2486 | QStringList::ConstIterator end = filterList.end(); | 2486 | QStringList::ConstIterator end = filterList.end(); |
2487 | while(it != end) { | 2487 | while(it != end) { |
2488 | // kdDebug() << " filter: " << (*it) << endl; | 2488 | // kdDebug() << " filter: " << (*it) << endl; |
2489 | 2489 | ||
2490 | CalFilter *filter; | 2490 | CalFilter *filter; |
2491 | filter = new CalFilter(*it); | 2491 | filter = new CalFilter(*it); |
2492 | config->setGroup("Filter_" + (*it).utf8()); | 2492 | config->setGroup("Filter_" + (*it).utf8()); |
2493 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2493 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2494 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2494 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2495 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2495 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2496 | mFilters.append(filter); | 2496 | mFilters.append(filter); |
2497 | 2497 | ||
2498 | ++it; | 2498 | ++it; |
2499 | } | 2499 | } |
2500 | 2500 | ||
2501 | if (mFilters.count() == 0) { | 2501 | if (mFilters.count() == 0) { |
2502 | CalFilter *filter = new CalFilter(i18n("Default")); | 2502 | CalFilter *filter = new CalFilter(i18n("Default")); |
2503 | mFilters.append(filter); | 2503 | mFilters.append(filter); |
2504 | } | 2504 | } |
2505 | mFilterView->updateFilters(); | 2505 | mFilterView->updateFilters(); |
2506 | config->setGroup("FilterView"); | 2506 | config->setGroup("FilterView"); |
2507 | 2507 | ||
2508 | mFilterView->blockSignals(true); | 2508 | mFilterView->blockSignals(true); |
2509 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2509 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2510 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2510 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2511 | mFilterView->blockSignals(false); | 2511 | mFilterView->blockSignals(false); |
2512 | // We do it manually to avoid it being done twice by the above calls | 2512 | // We do it manually to avoid it being done twice by the above calls |
2513 | updateFilter(); | 2513 | updateFilter(); |
2514 | } | 2514 | } |
2515 | 2515 | ||
2516 | void CalendarView::writeFilterSettings(KConfig *config) | 2516 | void CalendarView::writeFilterSettings(KConfig *config) |
2517 | { | 2517 | { |
2518 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2518 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2519 | 2519 | ||
2520 | QStringList filterList; | 2520 | QStringList filterList; |
2521 | 2521 | ||
2522 | CalFilter *filter = mFilters.first(); | 2522 | CalFilter *filter = mFilters.first(); |
2523 | while(filter) { | 2523 | while(filter) { |
2524 | // kdDebug() << " fn: " << filter->name() << endl; | 2524 | // kdDebug() << " fn: " << filter->name() << endl; |
2525 | filterList << filter->name(); | 2525 | filterList << filter->name(); |
2526 | config->setGroup("Filter_" + filter->name().utf8()); | 2526 | config->setGroup("Filter_" + filter->name().utf8()); |
2527 | config->writeEntry("Criteria",filter->criteria()); | 2527 | config->writeEntry("Criteria",filter->criteria()); |
2528 | config->writeEntry("CategoryList",filter->categoryList()); | 2528 | config->writeEntry("CategoryList",filter->categoryList()); |
2529 | filter = mFilters.next(); | 2529 | filter = mFilters.next(); |
2530 | } | 2530 | } |
2531 | config->setGroup("General"); | 2531 | config->setGroup("General"); |
2532 | config->writeEntry("CalendarFilters",filterList); | 2532 | config->writeEntry("CalendarFilters",filterList); |
2533 | 2533 | ||
2534 | config->setGroup("FilterView"); | 2534 | config->setGroup("FilterView"); |
2535 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2535 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2536 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2536 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2537 | } | 2537 | } |
2538 | 2538 | ||
2539 | 2539 | ||
2540 | void CalendarView::goToday() | 2540 | void CalendarView::goToday() |
2541 | { | 2541 | { |
2542 | if ( mViewManager->currentView()->isMonthView() ) | 2542 | if ( mViewManager->currentView()->isMonthView() ) |
2543 | mNavigator->selectTodayMonth(); | 2543 | mNavigator->selectTodayMonth(); |
2544 | else | 2544 | else |
2545 | mNavigator->selectToday(); | 2545 | mNavigator->selectToday(); |
2546 | } | 2546 | } |
2547 | 2547 | ||
2548 | void CalendarView::goNext() | 2548 | void CalendarView::goNext() |
2549 | { | 2549 | { |
2550 | mNavigator->selectNext(); | 2550 | mNavigator->selectNext(); |
2551 | } | 2551 | } |
2552 | 2552 | ||
2553 | void CalendarView::goPrevious() | 2553 | void CalendarView::goPrevious() |
2554 | { | 2554 | { |
2555 | mNavigator->selectPrevious(); | 2555 | mNavigator->selectPrevious(); |
2556 | } | 2556 | } |
2557 | void CalendarView::goNextMonth() | 2557 | void CalendarView::goNextMonth() |
2558 | { | 2558 | { |
2559 | mNavigator->selectNextMonth(); | 2559 | mNavigator->selectNextMonth(); |
2560 | } | 2560 | } |
2561 | 2561 | ||
2562 | void CalendarView::goPreviousMonth() | 2562 | void CalendarView::goPreviousMonth() |
2563 | { | 2563 | { |
2564 | mNavigator->selectPreviousMonth(); | 2564 | mNavigator->selectPreviousMonth(); |
2565 | } | 2565 | } |
2566 | 2566 | ||
2567 | void CalendarView::updateConfig() | 2567 | void CalendarView::updateConfig() |
2568 | { | 2568 | { |
2569 | if ( KOPrefs::instance()->mUseAppColors ) | 2569 | if ( KOPrefs::instance()->mUseAppColors ) |
2570 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2570 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2571 | emit configChanged(); | 2571 | emit configChanged(); |
2572 | mTodoList->updateConfig(); | 2572 | mTodoList->updateConfig(); |
2573 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2573 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2574 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2574 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2575 | // To make the "fill window" configurations work | 2575 | // To make the "fill window" configurations work |
2576 | //mViewManager->raiseCurrentView(); | 2576 | //mViewManager->raiseCurrentView(); |
2577 | } | 2577 | } |
2578 | 2578 | ||
2579 | 2579 | ||
2580 | void CalendarView::eventChanged(Event *event) | 2580 | void CalendarView::eventChanged(Event *event) |
2581 | { | 2581 | { |
2582 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2582 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2583 | //updateUnmanagedViews(); | 2583 | //updateUnmanagedViews(); |
2584 | } | 2584 | } |
2585 | 2585 | ||
2586 | void CalendarView::eventAdded(Event *event) | 2586 | void CalendarView::eventAdded(Event *event) |
2587 | { | 2587 | { |
2588 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2588 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2589 | } | 2589 | } |
2590 | 2590 | ||
2591 | void CalendarView::eventToBeDeleted(Event *) | 2591 | void CalendarView::eventToBeDeleted(Event *) |
2592 | { | 2592 | { |
2593 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2593 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2594 | } | 2594 | } |
2595 | 2595 | ||
2596 | void CalendarView::eventDeleted() | 2596 | void CalendarView::eventDeleted() |
2597 | { | 2597 | { |
2598 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2598 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2599 | } | 2599 | } |
2600 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2600 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2601 | { | 2601 | { |
2602 | changeIncidenceDisplay((Incidence *)which, action); | 2602 | changeIncidenceDisplay((Incidence *)which, action); |
2603 | mDateNavigator->updateView(); //LR | 2603 | mDateNavigator->updateView(); //LR |
2604 | //mDialogManager->updateSearchDialog(); | 2604 | //mDialogManager->updateSearchDialog(); |
2605 | 2605 | ||
2606 | if (which) { | 2606 | if (which) { |
2607 | mViewManager->updateWNview(); | 2607 | mViewManager->updateWNview(); |
2608 | //mTodoList->updateView(); | 2608 | //mTodoList->updateView(); |
2609 | } | 2609 | } |
2610 | 2610 | ||
2611 | } | 2611 | } |
2612 | 2612 | ||
2613 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2613 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2614 | { | 2614 | { |
2615 | updateUnmanagedViews(); | 2615 | updateUnmanagedViews(); |
2616 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2616 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2617 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2617 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2618 | mCalendar->checkAlarmForIncidence( 0, true ); | 2618 | mCalendar->checkAlarmForIncidence( 0, true ); |
2619 | if ( mEventViewerDialog ) | 2619 | if ( mEventViewerDialog ) |
2620 | mEventViewerDialog->hide(); | 2620 | mEventViewerDialog->hide(); |
2621 | } | 2621 | } |
2622 | else | 2622 | else |
2623 | mCalendar->checkAlarmForIncidence( which , false ); | 2623 | mCalendar->checkAlarmForIncidence( which , false ); |
2624 | } | 2624 | } |
2625 | 2625 | ||
2626 | // most of the changeEventDisplays() right now just call the view's | 2626 | // most of the changeEventDisplays() right now just call the view's |
2627 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2627 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2628 | void CalendarView::changeEventDisplay(Event *which, int action) | 2628 | void CalendarView::changeEventDisplay(Event *which, int action) |
2629 | { | 2629 | { |
2630 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2630 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2631 | changeIncidenceDisplay((Incidence *)which, action); | 2631 | changeIncidenceDisplay((Incidence *)which, action); |
2632 | mDateNavigator->updateView(); | 2632 | mDateNavigator->updateView(); |
2633 | //mDialogManager->updateSearchDialog(); | 2633 | //mDialogManager->updateSearchDialog(); |
2634 | 2634 | ||
2635 | if (which) { | 2635 | if (which) { |
2636 | // If there is an event view visible update the display | 2636 | // If there is an event view visible update the display |
2637 | mViewManager->currentView()->changeEventDisplay(which,action); | 2637 | mViewManager->currentView()->changeEventDisplay(which,action); |
2638 | // TODO: check, if update needed | 2638 | // TODO: check, if update needed |
2639 | // if (which->getTodoStatus()) { | 2639 | // if (which->getTodoStatus()) { |
2640 | mTodoList->updateView(); | 2640 | mTodoList->updateView(); |
2641 | // } | 2641 | // } |
2642 | } else { | 2642 | } else { |
2643 | mViewManager->currentView()->updateView(); | 2643 | mViewManager->currentView()->updateView(); |
2644 | } | 2644 | } |
2645 | } | 2645 | } |
2646 | 2646 | ||
2647 | 2647 | ||
2648 | void CalendarView::updateTodoViews() | 2648 | void CalendarView::updateTodoViews() |
2649 | { | 2649 | { |
2650 | mTodoList->updateView(); | 2650 | mTodoList->updateView(); |
2651 | mViewManager->currentView()->updateView(); | 2651 | mViewManager->currentView()->updateView(); |
2652 | 2652 | ||
2653 | } | 2653 | } |
2654 | 2654 | ||
2655 | 2655 | ||
2656 | 2656 | ||
2657 | void CalendarView::clearAllViews() | 2657 | void CalendarView::clearAllViews() |
2658 | { | 2658 | { |
2659 | mTodoList->clearList(); | 2659 | mTodoList->clearList(); |
2660 | mViewManager->clearAllViews(); | 2660 | mViewManager->clearAllViews(); |
2661 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2661 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2662 | if ( sd ) { | 2662 | if ( sd ) { |
2663 | KOListView* kol = sd->listview(); | 2663 | KOListView* kol = sd->listview(); |
2664 | if ( kol ) | 2664 | if ( kol ) |
2665 | kol->clearList(); | 2665 | kol->clearList(); |
2666 | } | 2666 | } |
2667 | } | 2667 | } |
2668 | void CalendarView::updateView() | 2668 | void CalendarView::updateView() |
2669 | { | 2669 | { |
2670 | static bool clearallviews = false; | ||
2671 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | ||
2672 | if ( clearallviews ) { | ||
2673 | clearAllViews(); | ||
2674 | clearallviews = false; | ||
2675 | } | ||
2676 | return; | ||
2677 | } | ||
2678 | clearallviews = true; | ||
2670 | DateList tmpList = mNavigator->selectedDates(); | 2679 | DateList tmpList = mNavigator->selectedDates(); |
2671 | 2680 | ||
2672 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2681 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2673 | mTodoList->updateView(); | 2682 | mTodoList->updateView(); |
2674 | // We assume that the navigator only selects consecutive days. | 2683 | // We assume that the navigator only selects consecutive days. |
2675 | updateView( tmpList.first(), tmpList.last() ); | 2684 | updateView( tmpList.first(), tmpList.last() ); |
2676 | } | 2685 | } |
2677 | 2686 | ||
2678 | void CalendarView::updateUnmanagedViews() | 2687 | void CalendarView::updateUnmanagedViews() |
2679 | { | 2688 | { |
2680 | mDateNavigator->updateDayMatrix(); | 2689 | mDateNavigator->updateDayMatrix(); |
2681 | } | 2690 | } |
2682 | 2691 | ||
2683 | int CalendarView::msgItemDelete(const QString name) | 2692 | int CalendarView::msgItemDelete(const QString name) |
2684 | { | 2693 | { |
2685 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2694 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2686 | i18n("This item will be\npermanently deleted."), | 2695 | i18n("This item will be\npermanently deleted."), |
2687 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2696 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2688 | } | 2697 | } |
2689 | 2698 | ||
2690 | 2699 | ||
2691 | void CalendarView::edit_cut() | 2700 | void CalendarView::edit_cut() |
2692 | { | 2701 | { |
2693 | Event *anEvent=0; | 2702 | Event *anEvent=0; |
2694 | 2703 | ||
2695 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2704 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2696 | 2705 | ||
2697 | if (mViewManager->currentView()->isEventView()) { | 2706 | if (mViewManager->currentView()->isEventView()) { |
2698 | if ( incidence && incidence->typeID() == eventID ) { | 2707 | if ( incidence && incidence->typeID() == eventID ) { |
2699 | anEvent = static_cast<Event *>(incidence); | 2708 | anEvent = static_cast<Event *>(incidence); |
2700 | } | 2709 | } |
2701 | } | 2710 | } |
2702 | 2711 | ||
2703 | if (!anEvent) { | 2712 | if (!anEvent) { |
2704 | KNotifyClient::beep(); | 2713 | KNotifyClient::beep(); |
2705 | return; | 2714 | return; |
2706 | } | 2715 | } |
2707 | DndFactory factory( mCalendar ); | 2716 | DndFactory factory( mCalendar ); |
2708 | factory.cutIncidence(anEvent); | 2717 | factory.cutIncidence(anEvent); |
2709 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2718 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2710 | } | 2719 | } |
2711 | 2720 | ||
2712 | void CalendarView::edit_copy() | 2721 | void CalendarView::edit_copy() |
2713 | { | 2722 | { |
2714 | Event *anEvent=0; | 2723 | Event *anEvent=0; |
2715 | 2724 | ||
2716 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2725 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2717 | 2726 | ||
2718 | if (mViewManager->currentView()->isEventView()) { | 2727 | if (mViewManager->currentView()->isEventView()) { |
2719 | if ( incidence && incidence->typeID() == eventID ) { | 2728 | if ( incidence && incidence->typeID() == eventID ) { |
2720 | anEvent = static_cast<Event *>(incidence); | 2729 | anEvent = static_cast<Event *>(incidence); |
2721 | } | 2730 | } |
2722 | } | 2731 | } |
2723 | 2732 | ||
2724 | if (!anEvent) { | 2733 | if (!anEvent) { |
2725 | KNotifyClient::beep(); | 2734 | KNotifyClient::beep(); |
2726 | return; | 2735 | return; |
2727 | } | 2736 | } |
2728 | DndFactory factory( mCalendar ); | 2737 | DndFactory factory( mCalendar ); |
2729 | factory.copyIncidence(anEvent); | 2738 | factory.copyIncidence(anEvent); |
2730 | } | 2739 | } |
2731 | 2740 | ||
2732 | void CalendarView::edit_paste() | 2741 | void CalendarView::edit_paste() |
2733 | { | 2742 | { |
2734 | QDate date = mNavigator->selectedDates().first(); | 2743 | QDate date = mNavigator->selectedDates().first(); |
2735 | 2744 | ||
2736 | DndFactory factory( mCalendar ); | 2745 | DndFactory factory( mCalendar ); |
2737 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2746 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2738 | 2747 | ||
2739 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2748 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2740 | } | 2749 | } |
2741 | void CalendarView::edit_global_options() | 2750 | void CalendarView::edit_global_options() |
2742 | { | 2751 | { |
2743 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2752 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2744 | emit save(); | 2753 | emit save(); |
2745 | emit saveStopTimer(); | 2754 | emit saveStopTimer(); |
2746 | mDialogManager->showGlobalOptionsDialog(); | 2755 | mDialogManager->showGlobalOptionsDialog(); |
2747 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2756 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2748 | emit saveStopTimer(); | 2757 | emit saveStopTimer(); |
2749 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2758 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2750 | i18n("Timezone settings"),i18n("Reload"))) { | 2759 | i18n("Timezone settings"),i18n("Reload"))) { |
2751 | qDebug("KO: TZ reload cancelled "); | 2760 | qDebug("KO: TZ reload cancelled "); |
2752 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2761 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2753 | return; | 2762 | return; |
2754 | } | 2763 | } |
2755 | qDebug("KO: Timezone change "); | 2764 | qDebug("KO: Timezone change "); |
2756 | loadCalendars(); | 2765 | loadCalendars(); |
2757 | setModified(true); | 2766 | setModified(true); |
2758 | } | 2767 | } |
2759 | else | 2768 | else |
2760 | qDebug("KO: No tz change "); | 2769 | qDebug("KO: No tz change "); |
2761 | } | 2770 | } |
2762 | void CalendarView::edit_options() | 2771 | void CalendarView::edit_options() |
2763 | { | 2772 | { |
2764 | mDialogManager->showOptionsDialog(); | 2773 | mDialogManager->showOptionsDialog(); |
2765 | } | 2774 | } |
2766 | 2775 | ||
2767 | 2776 | ||
2768 | void CalendarView::slotSelectPickerDate( QDate d) | 2777 | void CalendarView::slotSelectPickerDate( QDate d) |
2769 | { | 2778 | { |
2770 | mDateFrame->hide(); | 2779 | mDateFrame->hide(); |
2771 | if ( mDatePickerMode == 1 ) { | 2780 | if ( mDatePickerMode == 1 ) { |
2772 | mNavigator->slotDaySelect( d ); | 2781 | mNavigator->slotDaySelect( d ); |
2773 | } else if ( mDatePickerMode == 2 ) { | 2782 | } else if ( mDatePickerMode == 2 ) { |
2774 | if ( mMoveIncidence->typeID() == todoID ) { | 2783 | if ( mMoveIncidence->typeID() == todoID ) { |
2775 | Todo * to = (Todo *) mMoveIncidence; | 2784 | Todo * to = (Todo *) mMoveIncidence; |
2776 | QTime tim; | 2785 | QTime tim; |
2777 | int len = 0; | 2786 | int len = 0; |
2778 | if ( to->hasStartDate() && to->hasDueDate() ) | 2787 | if ( to->hasStartDate() && to->hasDueDate() ) |
2779 | len = to->dtStart().secsTo( to->dtDue()); | 2788 | len = to->dtStart().secsTo( to->dtDue()); |
2780 | if ( to->hasDueDate() ) | 2789 | if ( to->hasDueDate() ) |
2781 | tim = to->dtDue().time(); | 2790 | tim = to->dtDue().time(); |
2782 | else { | 2791 | else { |
2783 | tim = QTime ( 0,0,0 ); | 2792 | tim = QTime ( 0,0,0 ); |
2784 | to->setFloats( true ); | 2793 | to->setFloats( true ); |
2785 | to->setHasDueDate( true ); | 2794 | to->setHasDueDate( true ); |
2786 | } | 2795 | } |
2787 | QDateTime dt ( d,tim ); | 2796 | QDateTime dt ( d,tim ); |
2788 | to->setDtDue( dt ); | 2797 | to->setDtDue( dt ); |
2789 | 2798 | ||
2790 | if ( to->hasStartDate() ) { | 2799 | if ( to->hasStartDate() ) { |
2791 | if ( len>0 ) | 2800 | if ( len>0 ) |
2792 | to->setDtStart(to->dtDue().addSecs( -len )); | 2801 | to->setDtStart(to->dtDue().addSecs( -len )); |
2793 | else | 2802 | else |
2794 | if (to->dtStart() > to->dtDue() ) | 2803 | if (to->dtStart() > to->dtDue() ) |
2795 | to->setDtStart(to->dtDue().addDays( -3 )); | 2804 | to->setDtStart(to->dtDue().addDays( -3 )); |
2796 | } | 2805 | } |
2797 | 2806 | ||
2798 | todoChanged( to ); | 2807 | todoChanged( to ); |
2799 | } else { | 2808 | } else { |
2800 | if ( mMoveIncidence->doesRecur() ) { | 2809 | if ( mMoveIncidence->doesRecur() ) { |
2801 | #if 0 | 2810 | #if 0 |
2802 | // PENDING implement this | 2811 | // PENDING implement this |
2803 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2812 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2804 | mCalendar()->addIncidence( newInc ); | 2813 | mCalendar()->addIncidence( newInc ); |
2805 | if ( mMoveIncidence->typeID() == todoID ) | 2814 | if ( mMoveIncidence->typeID() == todoID ) |
2806 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2815 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2807 | else | 2816 | else |
2808 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2817 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2809 | mMoveIncidence = newInc; | 2818 | mMoveIncidence = newInc; |
2810 | 2819 | ||
2811 | #endif | 2820 | #endif |
2812 | } | 2821 | } |
2813 | QTime tim = mMoveIncidence->dtStart().time(); | 2822 | QTime tim = mMoveIncidence->dtStart().time(); |
2814 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2823 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2815 | QDateTime dt ( d,tim ); | 2824 | QDateTime dt ( d,tim ); |
2816 | mMoveIncidence->setDtStart( dt ); | 2825 | mMoveIncidence->setDtStart( dt ); |
2817 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2826 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2818 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2827 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2819 | } | 2828 | } |
2820 | 2829 | ||
2821 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2830 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2822 | } | 2831 | } |
2823 | } | 2832 | } |
2824 | 2833 | ||
2825 | void CalendarView::removeCategories() | 2834 | void CalendarView::removeCategories() |
2826 | { | 2835 | { |
2827 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2836 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2828 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2837 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2829 | QStringList catIncList; | 2838 | QStringList catIncList; |
2830 | QStringList newCatList; | 2839 | QStringList newCatList; |
2831 | Incidence* inc = incList.first(); | 2840 | Incidence* inc = incList.first(); |
2832 | uint i; | 2841 | uint i; |
2833 | while ( inc ) { | 2842 | while ( inc ) { |
2834 | newCatList.clear(); | 2843 | newCatList.clear(); |
2835 | catIncList = inc->categories() ; | 2844 | catIncList = inc->categories() ; |
2836 | for( i = 0; i< catIncList.count(); ++i ) { | 2845 | for( i = 0; i< catIncList.count(); ++i ) { |
2837 | if ( catList.contains (catIncList[i])) | 2846 | if ( catList.contains (catIncList[i])) |
2838 | newCatList.append( catIncList[i] ); | 2847 | newCatList.append( catIncList[i] ); |
2839 | } | 2848 | } |
2840 | newCatList.sort(); | 2849 | newCatList.sort(); |
2841 | inc->setCategories( newCatList.join(",") ); | 2850 | inc->setCategories( newCatList.join(",") ); |
2842 | inc = incList.next(); | 2851 | inc = incList.next(); |
2843 | } | 2852 | } |
2844 | } | 2853 | } |
2845 | 2854 | ||
2846 | int CalendarView::addCategories() | 2855 | int CalendarView::addCategories() |
2847 | { | 2856 | { |
2848 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2857 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2849 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2858 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2850 | QStringList catIncList; | 2859 | QStringList catIncList; |
2851 | Incidence* inc = incList.first(); | 2860 | Incidence* inc = incList.first(); |
2852 | uint i; | 2861 | uint i; |
2853 | int count = 0; | 2862 | int count = 0; |
2854 | while ( inc ) { | 2863 | while ( inc ) { |
2855 | catIncList = inc->categories() ; | 2864 | catIncList = inc->categories() ; |
2856 | for( i = 0; i< catIncList.count(); ++i ) { | 2865 | for( i = 0; i< catIncList.count(); ++i ) { |
2857 | if ( !catList.contains (catIncList[i])) { | 2866 | if ( !catList.contains (catIncList[i])) { |
2858 | catList.append( catIncList[i] ); | 2867 | catList.append( catIncList[i] ); |
2859 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2868 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2860 | ++count; | 2869 | ++count; |
2861 | } | 2870 | } |
2862 | } | 2871 | } |
2863 | inc = incList.next(); | 2872 | inc = incList.next(); |
2864 | } | 2873 | } |
2865 | catList.sort(); | 2874 | catList.sort(); |
2866 | KOPrefs::instance()->mCustomCategories = catList; | 2875 | KOPrefs::instance()->mCustomCategories = catList; |
2867 | return count; | 2876 | return count; |
2868 | } | 2877 | } |
2869 | 2878 | ||
2870 | void CalendarView::editCategories() | 2879 | void CalendarView::editCategories() |
2871 | { | 2880 | { |
2872 | qDebug("CalendarView::editCategories() "); | 2881 | qDebug("CalendarView::editCategories() "); |
2873 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 2882 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
2874 | ced.exec(); | 2883 | ced.exec(); |
2875 | } | 2884 | } |
2876 | void CalendarView::manageCategories() | 2885 | void CalendarView::manageCategories() |
2877 | { | 2886 | { |
2878 | KOCatPrefs* cp = new KOCatPrefs(); | 2887 | KOCatPrefs* cp = new KOCatPrefs(); |
2879 | cp->show(); | 2888 | cp->show(); |
2880 | int w =cp->sizeHint().width() ; | 2889 | int w =cp->sizeHint().width() ; |
2881 | int h = cp->sizeHint().height() ; | 2890 | int h = cp->sizeHint().height() ; |
2882 | int dw = QApplication::desktop()->width(); | 2891 | int dw = QApplication::desktop()->width(); |
2883 | int dh = QApplication::desktop()->height(); | 2892 | int dh = QApplication::desktop()->height(); |
2884 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2893 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2885 | if ( !cp->exec() ) { | 2894 | if ( !cp->exec() ) { |
2886 | delete cp; | 2895 | delete cp; |
2887 | return; | 2896 | return; |
2888 | } | 2897 | } |
2889 | int count = 0; | 2898 | int count = 0; |
2890 | if ( cp->addCat() ) { | 2899 | if ( cp->addCat() ) { |
2891 | count = addCategories(); | 2900 | count = addCategories(); |
2892 | if ( count ) { | 2901 | if ( count ) { |
2893 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2902 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2894 | writeSettings(); | 2903 | writeSettings(); |
2895 | } else | 2904 | } else |
2896 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2905 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2897 | } else { | 2906 | } else { |
2898 | removeCategories(); | 2907 | removeCategories(); |
2899 | updateView(); | 2908 | updateView(); |
2900 | } | 2909 | } |
2901 | delete cp; | 2910 | delete cp; |
2902 | } | 2911 | } |
2903 | 2912 | ||
2904 | void CalendarView::beamIncidence(Incidence * Inc) | 2913 | void CalendarView::beamIncidence(Incidence * Inc) |
2905 | { | 2914 | { |
2906 | QPtrList<Incidence> delSel ; | 2915 | QPtrList<Incidence> delSel ; |
2907 | delSel.append(Inc); | 2916 | delSel.append(Inc); |
2908 | beamIncidenceList( delSel ); | 2917 | beamIncidenceList( delSel ); |
2909 | } | 2918 | } |
2910 | void CalendarView::beamCalendar() | 2919 | void CalendarView::beamCalendar() |
2911 | { | 2920 | { |
2912 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2921 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2913 | //qDebug("beamCalendar() "); | 2922 | //qDebug("beamCalendar() "); |
2914 | beamIncidenceList( delSel ); | 2923 | beamIncidenceList( delSel ); |
2915 | } | 2924 | } |
2916 | void CalendarView::beamFilteredCalendar() | 2925 | void CalendarView::beamFilteredCalendar() |
2917 | { | 2926 | { |
2918 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2927 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2919 | //qDebug("beamFilteredCalendar() "); | 2928 | //qDebug("beamFilteredCalendar() "); |
2920 | beamIncidenceList( delSel ); | 2929 | beamIncidenceList( delSel ); |
2921 | } | 2930 | } |
2922 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2931 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2923 | { | 2932 | { |
2924 | 2933 | ||
2925 | KOBeamPrefs beamDialog; | 2934 | KOBeamPrefs beamDialog; |
2926 | if ( beamDialog.exec () == QDialog::Rejected ) | 2935 | if ( beamDialog.exec () == QDialog::Rejected ) |
2927 | return; | 2936 | return; |
2928 | #ifdef DESKTOP_VERSION | 2937 | #ifdef DESKTOP_VERSION |
2929 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2938 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2930 | #else | 2939 | #else |
2931 | QString fn = "/tmp/kopibeamfile"; | 2940 | QString fn = "/tmp/kopibeamfile"; |
2932 | #endif | 2941 | #endif |
2933 | QString mes; | 2942 | QString mes; |
2934 | bool createbup = true; | 2943 | bool createbup = true; |
2935 | if ( createbup ) { | 2944 | if ( createbup ) { |
2936 | QString description = "\n"; | 2945 | QString description = "\n"; |
2937 | CalendarLocal* cal = new CalendarLocal(); | 2946 | CalendarLocal* cal = new CalendarLocal(); |
2938 | if ( beamDialog.beamLocal() ) | 2947 | if ( beamDialog.beamLocal() ) |
2939 | cal->setLocalTime(); | 2948 | cal->setLocalTime(); |
2940 | else | 2949 | else |
2941 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2950 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2942 | Incidence *incidence = delSel.first(); | 2951 | Incidence *incidence = delSel.first(); |
2943 | bool addText = false; | 2952 | bool addText = false; |
2944 | if ( delSel.count() < 10 ) | 2953 | if ( delSel.count() < 10 ) |
2945 | addText = true; | 2954 | addText = true; |
2946 | else { | 2955 | else { |
2947 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2956 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2948 | } | 2957 | } |
2949 | while ( incidence ) { | 2958 | while ( incidence ) { |
2950 | Incidence *in = incidence->clone(); | 2959 | Incidence *in = incidence->clone(); |
2951 | if ( ! in->summary().isEmpty() ) { | 2960 | if ( ! in->summary().isEmpty() ) { |
2952 | in->setDescription(""); | 2961 | in->setDescription(""); |
2953 | } else { | 2962 | } else { |
2954 | in->setSummary( in->description().left(20)); | 2963 | in->setSummary( in->description().left(20)); |
2955 | in->setDescription(""); | 2964 | in->setDescription(""); |
2956 | } | 2965 | } |
2957 | if ( addText ) | 2966 | if ( addText ) |
2958 | description += in->summary() + "\n"; | 2967 | description += in->summary() + "\n"; |
2959 | cal->addIncidence( in ); | 2968 | cal->addIncidence( in ); |
2960 | incidence = delSel.next(); | 2969 | incidence = delSel.next(); |
2961 | } | 2970 | } |
2962 | if ( beamDialog.beamVcal() ) { | 2971 | if ( beamDialog.beamVcal() ) { |
2963 | fn += ".vcs"; | 2972 | fn += ".vcs"; |
2964 | FileStorage storage( cal, fn, new VCalFormat ); | 2973 | FileStorage storage( cal, fn, new VCalFormat ); |
2965 | storage.save(); | 2974 | storage.save(); |
2966 | } else { | 2975 | } else { |
2967 | fn += ".ics"; | 2976 | fn += ".ics"; |
2968 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2977 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2969 | storage.save(); | 2978 | storage.save(); |
2970 | } | 2979 | } |
2971 | delete cal; | 2980 | delete cal; |
2972 | mes = i18n("KO/Pi: Ready for beaming"); | 2981 | mes = i18n("KO/Pi: Ready for beaming"); |
2973 | topLevelWidget()->setCaption(mes); | 2982 | topLevelWidget()->setCaption(mes); |
2974 | KApplication::convert2latin1( fn ); | 2983 | KApplication::convert2latin1( fn ); |
2975 | #ifndef DESKTOP_VERSION | 2984 | #ifndef DESKTOP_VERSION |
2976 | Ir *ir = new Ir( this ); | 2985 | Ir *ir = new Ir( this ); |
2977 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2986 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2978 | ir->send( fn, description, "text/x-vCalendar" ); | 2987 | ir->send( fn, description, "text/x-vCalendar" ); |
2979 | #endif | 2988 | #endif |
2980 | } | 2989 | } |
2981 | } | 2990 | } |
2982 | 2991 | ||
2983 | #ifndef DESKTOP_VERSION | 2992 | #ifndef DESKTOP_VERSION |
2984 | void CalendarView::beamDone( Ir *ir ) | 2993 | void CalendarView::beamDone( Ir *ir ) |
2985 | { | 2994 | { |
2986 | delete ir; | 2995 | delete ir; |
2987 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2996 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2988 | topLevelWidget()->raise(); | 2997 | topLevelWidget()->raise(); |
2989 | } | 2998 | } |
2990 | #else | 2999 | #else |
2991 | void CalendarView::beamDone( Ir *){;} | 3000 | void CalendarView::beamDone( Ir *){;} |
2992 | #endif | 3001 | #endif |
2993 | void CalendarView::moveIncidence(Incidence * inc ) | 3002 | void CalendarView::moveIncidence(Incidence * inc ) |
2994 | { | 3003 | { |
2995 | if ( !inc ) return; | 3004 | if ( !inc ) return; |
2996 | showDatePickerPopup(); | 3005 | showDatePickerPopup(); |
2997 | mDatePickerMode = 2; | 3006 | mDatePickerMode = 2; |
2998 | mMoveIncidence = inc ; | 3007 | mMoveIncidence = inc ; |
2999 | QDate da; | 3008 | QDate da; |
3000 | if ( mMoveIncidence->typeID() == todoID ) { | 3009 | if ( mMoveIncidence->typeID() == todoID ) { |
3001 | Todo * to = (Todo *) mMoveIncidence; | 3010 | Todo * to = (Todo *) mMoveIncidence; |
3002 | if ( to->hasDueDate() ) | 3011 | if ( to->hasDueDate() ) |
3003 | da = to->dtDue().date(); | 3012 | da = to->dtDue().date(); |
3004 | else | 3013 | else |
3005 | da = QDate::currentDate(); | 3014 | da = QDate::currentDate(); |
3006 | } else { | 3015 | } else { |
3007 | da = mMoveIncidence->dtStart().date(); | 3016 | da = mMoveIncidence->dtStart().date(); |
3008 | } | 3017 | } |
3009 | //PENDING set date for recurring incidence to date of recurrence | 3018 | //PENDING set date for recurring incidence to date of recurrence |
3010 | //mMoveIncidenceOldDate; | 3019 | //mMoveIncidenceOldDate; |
3011 | mDatePicker->setDate( da ); | 3020 | mDatePicker->setDate( da ); |
3012 | } | 3021 | } |
3013 | void CalendarView::showDatePickerPopup() | 3022 | void CalendarView::showDatePickerPopup() |
3014 | { | 3023 | { |
3015 | if ( mDateFrame->isVisible() ) | 3024 | if ( mDateFrame->isVisible() ) |
3016 | mDateFrame->hide(); | 3025 | mDateFrame->hide(); |
3017 | else { | 3026 | else { |
3018 | int offX = 0, offY = 0; | 3027 | int offX = 0, offY = 0; |
3019 | #ifdef DESKTOP_VERSION | 3028 | #ifdef DESKTOP_VERSION |
3020 | int w =mDatePicker->sizeHint().width() ; | 3029 | int w =mDatePicker->sizeHint().width() ; |
3021 | int h = mDatePicker->sizeHint().height() ; | 3030 | int h = mDatePicker->sizeHint().height() ; |
3022 | int dw = topLevelWidget()->width(); | 3031 | int dw = topLevelWidget()->width(); |
3023 | int dh = topLevelWidget()->height(); | 3032 | int dh = topLevelWidget()->height(); |
3024 | offX = topLevelWidget()->x(); | 3033 | offX = topLevelWidget()->x(); |
3025 | offY = topLevelWidget()->y(); | 3034 | offY = topLevelWidget()->y(); |
3026 | #else | 3035 | #else |
3027 | int w =mDatePicker->sizeHint().width() ; | 3036 | int w =mDatePicker->sizeHint().width() ; |
3028 | int h = mDatePicker->sizeHint().height() ; | 3037 | int h = mDatePicker->sizeHint().height() ; |
3029 | int dw = QApplication::desktop()->width(); | 3038 | int dw = QApplication::desktop()->width(); |
3030 | int dh = QApplication::desktop()->height(); | 3039 | int dh = QApplication::desktop()->height(); |
3031 | #endif | 3040 | #endif |
3032 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3041 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3033 | mDateFrame->show(); | 3042 | mDateFrame->show(); |
3034 | } | 3043 | } |
3035 | } | 3044 | } |
3036 | void CalendarView::showDatePicker( ) | 3045 | void CalendarView::showDatePicker( ) |
3037 | { | 3046 | { |
3038 | showDatePickerPopup(); | 3047 | showDatePickerPopup(); |
3039 | mDatePickerMode = 1; | 3048 | mDatePickerMode = 1; |
3040 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3049 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3041 | } | 3050 | } |
3042 | 3051 | ||
3043 | void CalendarView::showEventEditor() | 3052 | void CalendarView::showEventEditor() |
3044 | { | 3053 | { |
3045 | #ifdef DESKTOP_VERSION | 3054 | #ifdef DESKTOP_VERSION |
3046 | int x,y,w,h; | 3055 | int x,y,w,h; |
3047 | x = mEventEditor->geometry().x(); | 3056 | x = mEventEditor->geometry().x(); |
3048 | y = mEventEditor->geometry().y(); | 3057 | y = mEventEditor->geometry().y(); |
3049 | w = mEventEditor->width(); | 3058 | w = mEventEditor->width(); |
3050 | h = mEventEditor->height(); | 3059 | h = mEventEditor->height(); |
3051 | mEventEditor->show(); | 3060 | mEventEditor->show(); |
3052 | mEventEditor->setGeometry(x,y,w,h); | 3061 | mEventEditor->setGeometry(x,y,w,h); |
3053 | #else | 3062 | #else |
3054 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3063 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3055 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3064 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3056 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3065 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3057 | qApp->processEvents(); | 3066 | qApp->processEvents(); |
3058 | delete mEventEditor; | 3067 | delete mEventEditor; |
3059 | mEventEditor = mDialogManager->getEventEditor(); | 3068 | mEventEditor = mDialogManager->getEventEditor(); |
3060 | topLevelWidget()->setCaption( i18n("") ); | 3069 | topLevelWidget()->setCaption( i18n("") ); |
3061 | } | 3070 | } |
3062 | mEventEditor->showMaximized(); | 3071 | mEventEditor->showMaximized(); |
3063 | #endif | 3072 | #endif |
3064 | } | 3073 | } |
3065 | void CalendarView::showTodoEditor() | 3074 | void CalendarView::showTodoEditor() |
3066 | { | 3075 | { |
3067 | #ifdef DESKTOP_VERSION | 3076 | #ifdef DESKTOP_VERSION |
3068 | int x,y,w,h; | 3077 | int x,y,w,h; |
3069 | x = mTodoEditor->geometry().x(); | 3078 | x = mTodoEditor->geometry().x(); |
3070 | y = mTodoEditor->geometry().y(); | 3079 | y = mTodoEditor->geometry().y(); |
3071 | w = mTodoEditor->width(); | 3080 | w = mTodoEditor->width(); |
3072 | h = mTodoEditor->height(); | 3081 | h = mTodoEditor->height(); |
3073 | mTodoEditor->show(); | 3082 | mTodoEditor->show(); |
3074 | mTodoEditor->setGeometry(x,y,w,h); | 3083 | mTodoEditor->setGeometry(x,y,w,h); |
3075 | #else | 3084 | #else |
3076 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3085 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3077 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3086 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3078 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3087 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3079 | qApp->processEvents(); | 3088 | qApp->processEvents(); |
3080 | delete mTodoEditor; | 3089 | delete mTodoEditor; |
3081 | mTodoEditor = mDialogManager->getTodoEditor(); | 3090 | mTodoEditor = mDialogManager->getTodoEditor(); |
3082 | topLevelWidget()->setCaption( i18n("") ); | 3091 | topLevelWidget()->setCaption( i18n("") ); |
3083 | } | 3092 | } |
3084 | mTodoEditor->showMaximized(); | 3093 | mTodoEditor->showMaximized(); |
3085 | #endif | 3094 | #endif |
3086 | } | 3095 | } |
3087 | 3096 | ||
3088 | void CalendarView::cloneIncidence() | 3097 | void CalendarView::cloneIncidence() |
3089 | { | 3098 | { |
3090 | Incidence *incidence = currentSelection(); | 3099 | Incidence *incidence = currentSelection(); |
3091 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3100 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3092 | if ( incidence ) { | 3101 | if ( incidence ) { |
3093 | cloneIncidence(incidence); | 3102 | cloneIncidence(incidence); |
3094 | } | 3103 | } |
3095 | } | 3104 | } |
3096 | void CalendarView::moveIncidence() | 3105 | void CalendarView::moveIncidence() |
3097 | { | 3106 | { |
3098 | Incidence *incidence = currentSelection(); | 3107 | Incidence *incidence = currentSelection(); |
3099 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3108 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3100 | if ( incidence ) { | 3109 | if ( incidence ) { |
3101 | moveIncidence(incidence); | 3110 | moveIncidence(incidence); |
3102 | } | 3111 | } |
3103 | } | 3112 | } |
3104 | void CalendarView::beamIncidence() | 3113 | void CalendarView::beamIncidence() |
3105 | { | 3114 | { |
3106 | Incidence *incidence = currentSelection(); | 3115 | Incidence *incidence = currentSelection(); |
3107 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3116 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3108 | if ( incidence ) { | 3117 | if ( incidence ) { |
3109 | beamIncidence(incidence); | 3118 | beamIncidence(incidence); |
3110 | } | 3119 | } |
3111 | } | 3120 | } |
3112 | void CalendarView::toggleCancelIncidence() | 3121 | void CalendarView::toggleCancelIncidence() |
3113 | { | 3122 | { |
3114 | Incidence *incidence = currentSelection(); | 3123 | Incidence *incidence = currentSelection(); |
3115 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3124 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3116 | if ( incidence ) { | 3125 | if ( incidence ) { |
3117 | cancelIncidence(incidence); | 3126 | cancelIncidence(incidence); |
3118 | } | 3127 | } |
3119 | } | 3128 | } |
3120 | 3129 | ||
3121 | 3130 | ||
3122 | void CalendarView::cancelIncidence(Incidence * inc ) | 3131 | void CalendarView::cancelIncidence(Incidence * inc ) |
3123 | { | 3132 | { |
3124 | inc->setCancelled( ! inc->cancelled() ); | 3133 | inc->setCancelled( ! inc->cancelled() ); |
3125 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3134 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3126 | updateView(); | 3135 | updateView(); |
3127 | } | 3136 | } |
3128 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3137 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3129 | { | 3138 | { |
3130 | Incidence * newInc = orgInc->clone(); | 3139 | Incidence * newInc = orgInc->clone(); |
3131 | newInc->recreate(); | 3140 | newInc->recreate(); |
3132 | 3141 | ||
3133 | if ( newInc->typeID() == todoID ) { | 3142 | if ( newInc->typeID() == todoID ) { |
3134 | Todo* t = (Todo*) newInc; | 3143 | Todo* t = (Todo*) newInc; |
3135 | bool cloneSub = false; | 3144 | bool cloneSub = false; |
3136 | if ( orgInc->relations().count() ) { | 3145 | if ( orgInc->relations().count() ) { |
3137 | int result = KMessageBox::warningYesNoCancel(this, | 3146 | int result = KMessageBox::warningYesNoCancel(this, |
3138 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), | 3147 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), |
3139 | i18n("Todo has subtodos"), | 3148 | i18n("Todo has subtodos"), |
3140 | i18n("Yes"), | 3149 | i18n("Yes"), |
3141 | i18n("No")); | 3150 | i18n("No")); |
3142 | 3151 | ||
3143 | if ( result == KMessageBox::Cancel ) { | 3152 | if ( result == KMessageBox::Cancel ) { |
3144 | delete t; | 3153 | delete t; |
3145 | return; | 3154 | return; |
3146 | } | 3155 | } |
3147 | if (result == KMessageBox::Yes) cloneSub = true; | 3156 | if (result == KMessageBox::Yes) cloneSub = true; |
3148 | } | 3157 | } |
3149 | showTodoEditor(); | 3158 | showTodoEditor(); |
3150 | mTodoEditor->editTodo( t ); | 3159 | mTodoEditor->editTodo( t ); |
3151 | if ( mTodoEditor->exec() ) { | 3160 | if ( mTodoEditor->exec() ) { |
3152 | if ( cloneSub ) { | 3161 | if ( cloneSub ) { |
3153 | orgInc->cloneRelations( t ); | 3162 | orgInc->cloneRelations( t ); |
3154 | mCalendar->addIncidenceBranch( t ); | 3163 | mCalendar->addIncidenceBranch( t ); |
3155 | updateView(); | 3164 | updateView(); |
3156 | 3165 | ||
3157 | } else { | 3166 | } else { |
3158 | mCalendar->addTodo( t ); | 3167 | mCalendar->addTodo( t ); |
3159 | updateView(); | 3168 | updateView(); |
3160 | } | 3169 | } |
3161 | } else { | 3170 | } else { |
3162 | delete t; | 3171 | delete t; |
3163 | } | 3172 | } |
3164 | } | 3173 | } |
3165 | else { | 3174 | else { |
3166 | Event* e = (Event*) newInc; | 3175 | Event* e = (Event*) newInc; |
3167 | showEventEditor(); | 3176 | showEventEditor(); |
3168 | mEventEditor->editEvent( e ); | 3177 | mEventEditor->editEvent( e ); |
3169 | if ( mEventEditor->exec() ) { | 3178 | if ( mEventEditor->exec() ) { |
3170 | mCalendar->addEvent( e ); | 3179 | mCalendar->addEvent( e ); |
3171 | updateView(); | 3180 | updateView(); |
3172 | } else { | 3181 | } else { |
3173 | delete e; | 3182 | delete e; |
3174 | } | 3183 | } |
3175 | } | 3184 | } |
3176 | setActiveWindow(); | 3185 | setActiveWindow(); |
3177 | } | 3186 | } |
3178 | 3187 | ||
3179 | void CalendarView::newEvent() | 3188 | void CalendarView::newEvent() |
3180 | { | 3189 | { |
3181 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3190 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3182 | KOAgendaView *aView = mViewManager->agendaView(); | 3191 | KOAgendaView *aView = mViewManager->agendaView(); |
3183 | if (aView) { | 3192 | if (aView) { |
3184 | if (aView->selectionStart().isValid()) { | 3193 | if (aView->selectionStart().isValid()) { |
3185 | if (aView->selectedIsAllDay()) { | 3194 | if (aView->selectedIsAllDay()) { |
3186 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3195 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3187 | } else { | 3196 | } else { |
3188 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3197 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3189 | } | 3198 | } |
3190 | return; | 3199 | return; |
3191 | } | 3200 | } |
3192 | } | 3201 | } |
3193 | 3202 | ||
3194 | QDate date = mNavigator->selectedDates().first(); | 3203 | QDate date = mNavigator->selectedDates().first(); |
3195 | QDateTime current = QDateTime::currentDateTime(); | 3204 | QDateTime current = QDateTime::currentDateTime(); |
3196 | if ( date <= current.date() ) { | 3205 | if ( date <= current.date() ) { |
3197 | int hour = current.time().hour() +1; | 3206 | int hour = current.time().hour() +1; |
3198 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3207 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3199 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3208 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3200 | } else | 3209 | } else |
3201 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3210 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3202 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3211 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3203 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3212 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3204 | } | 3213 | } |
3205 | 3214 | ||
3206 | void CalendarView::newEvent(QDateTime fh) | 3215 | void CalendarView::newEvent(QDateTime fh) |
3207 | { | 3216 | { |
3208 | newEvent(fh, | 3217 | newEvent(fh, |
3209 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3218 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3210 | } | 3219 | } |
3211 | 3220 | ||
3212 | void CalendarView::newEvent(QDate dt) | 3221 | void CalendarView::newEvent(QDate dt) |
3213 | { | 3222 | { |
3214 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3223 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3215 | QDateTime(dt, QTime(0,0,0)), true); | 3224 | QDateTime(dt, QTime(0,0,0)), true); |
3216 | } | 3225 | } |
3217 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3226 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3218 | { | 3227 | { |
3219 | newEvent(fromHint, toHint, false); | 3228 | newEvent(fromHint, toHint, false); |
3220 | } | 3229 | } |
3221 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3230 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3222 | { | 3231 | { |
3223 | 3232 | ||
3224 | showEventEditor(); | 3233 | showEventEditor(); |
3225 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3234 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3226 | if ( mFilterView->filtersEnabled() ) { | 3235 | if ( mFilterView->filtersEnabled() ) { |
3227 | CalFilter *filter = mFilterView->selectedFilter(); | 3236 | CalFilter *filter = mFilterView->selectedFilter(); |
3228 | if (filter && filter->showCategories()) { | 3237 | if (filter && filter->showCategories()) { |
3229 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3238 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3230 | } | 3239 | } |
3231 | if ( filter ) | 3240 | if ( filter ) |
3232 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3241 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3233 | } | 3242 | } |
3234 | mEventEditor->exec(); | 3243 | mEventEditor->exec(); |
3235 | setActiveWindow(); | 3244 | setActiveWindow(); |
3236 | } | 3245 | } |
3237 | void CalendarView::todoAdded(Todo * t) | 3246 | void CalendarView::todoAdded(Todo * t) |
3238 | { | 3247 | { |
3239 | 3248 | ||
3240 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3249 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3241 | updateTodoViews(); | 3250 | updateTodoViews(); |
3242 | } | 3251 | } |
3243 | void CalendarView::todoChanged(Todo * t) | 3252 | void CalendarView::todoChanged(Todo * t) |
3244 | { | 3253 | { |
3245 | emit todoModified( t, 4 ); | 3254 | emit todoModified( t, 4 ); |
3246 | // updateTodoViews(); | 3255 | // updateTodoViews(); |
3247 | } | 3256 | } |
3248 | void CalendarView::todoToBeDeleted(Todo *) | 3257 | void CalendarView::todoToBeDeleted(Todo *) |
3249 | { | 3258 | { |
3250 | //qDebug("todoToBeDeleted(Todo *) "); | 3259 | //qDebug("todoToBeDeleted(Todo *) "); |
3251 | updateTodoViews(); | 3260 | updateTodoViews(); |
3252 | } | 3261 | } |
3253 | void CalendarView::todoDeleted() | 3262 | void CalendarView::todoDeleted() |
3254 | { | 3263 | { |
3255 | //qDebug(" todoDeleted()"); | 3264 | //qDebug(" todoDeleted()"); |
3256 | updateTodoViews(); | 3265 | updateTodoViews(); |
3257 | } | 3266 | } |
3258 | 3267 | ||
3259 | 3268 | ||
3260 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3269 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3261 | { | 3270 | { |
3262 | showTodoEditor(); | 3271 | showTodoEditor(); |
3263 | mTodoEditor->newTodo(dt,0,allday); | 3272 | mTodoEditor->newTodo(dt,0,allday); |
3264 | if ( mFilterView->filtersEnabled() ) { | 3273 | if ( mFilterView->filtersEnabled() ) { |
3265 | CalFilter *filter = mFilterView->selectedFilter(); | 3274 | CalFilter *filter = mFilterView->selectedFilter(); |
3266 | if (filter && filter->showCategories()) { | 3275 | if (filter && filter->showCategories()) { |
3267 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3276 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3268 | } | 3277 | } |
3269 | if ( filter ) | 3278 | if ( filter ) |
3270 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3279 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3271 | } | 3280 | } |
3272 | mTodoEditor->exec(); | 3281 | mTodoEditor->exec(); |
3273 | setActiveWindow(); | 3282 | setActiveWindow(); |
3274 | } | 3283 | } |
3275 | 3284 | ||
3276 | void CalendarView::newTodo() | 3285 | void CalendarView::newTodo() |
3277 | { | 3286 | { |
3278 | newTodoDateTime( QDateTime(),true ); | 3287 | newTodoDateTime( QDateTime(),true ); |
3279 | } | 3288 | } |
3280 | 3289 | ||
3281 | void CalendarView::newSubTodo() | 3290 | void CalendarView::newSubTodo() |
3282 | { | 3291 | { |
3283 | Todo *todo = selectedTodo(); | 3292 | Todo *todo = selectedTodo(); |
3284 | if ( todo ) newSubTodo( todo ); | 3293 | if ( todo ) newSubTodo( todo ); |
3285 | } | 3294 | } |
3286 | 3295 | ||
3287 | void CalendarView::newSubTodo(Todo *parentEvent) | 3296 | void CalendarView::newSubTodo(Todo *parentEvent) |
3288 | { | 3297 | { |
3289 | 3298 | ||
3290 | showTodoEditor(); | 3299 | showTodoEditor(); |
3291 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3300 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3292 | mTodoEditor->exec(); | 3301 | mTodoEditor->exec(); |
3293 | setActiveWindow(); | 3302 | setActiveWindow(); |
3294 | } | 3303 | } |
3295 | 3304 | ||
3296 | void CalendarView::newFloatingEvent() | 3305 | void CalendarView::newFloatingEvent() |
3297 | { | 3306 | { |
3298 | DateList tmpList = mNavigator->selectedDates(); | 3307 | DateList tmpList = mNavigator->selectedDates(); |
3299 | QDate date = tmpList.first(); | 3308 | QDate date = tmpList.first(); |
3300 | 3309 | ||
3301 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3310 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3302 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3311 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3303 | } | 3312 | } |
3304 | 3313 | ||
3305 | 3314 | ||
3306 | void CalendarView::editEvent( Event *event ) | 3315 | void CalendarView::editEvent( Event *event ) |
3307 | { | 3316 | { |
3308 | 3317 | ||
3309 | if ( !event ) return; | 3318 | if ( !event ) return; |
3310 | if ( event->isReadOnly() ) { | 3319 | if ( event->isReadOnly() ) { |
3311 | showEvent( event ); | 3320 | showEvent( event ); |
3312 | return; | 3321 | return; |
3313 | } | 3322 | } |
3314 | showEventEditor(); | 3323 | showEventEditor(); |
3315 | mEventEditor->editEvent( event , mFlagEditDescription); | 3324 | mEventEditor->editEvent( event , mFlagEditDescription); |
3316 | mEventEditor->exec(); | 3325 | mEventEditor->exec(); |
3317 | setActiveWindow(); | 3326 | setActiveWindow(); |
3318 | 3327 | ||
3319 | } | 3328 | } |
3320 | void CalendarView::editJournal( Journal *jour ) | 3329 | void CalendarView::editJournal( Journal *jour ) |
3321 | { | 3330 | { |
3322 | if ( !jour ) return; | 3331 | if ( !jour ) return; |
3323 | mDialogManager->hideSearchDialog(); | 3332 | mDialogManager->hideSearchDialog(); |
3324 | mViewManager->showJournalView(); | 3333 | mViewManager->showJournalView(); |
3325 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3334 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3326 | } | 3335 | } |
3327 | void CalendarView::editTodo( Todo *todo ) | 3336 | void CalendarView::editTodo( Todo *todo ) |
3328 | { | 3337 | { |
3329 | if ( !todo ) return; | 3338 | if ( !todo ) return; |
3330 | 3339 | ||
3331 | if ( todo->isReadOnly() ) { | 3340 | if ( todo->isReadOnly() ) { |
3332 | showTodo( todo ); | 3341 | showTodo( todo ); |
3333 | return; | 3342 | return; |
3334 | } | 3343 | } |
3335 | showTodoEditor(); | 3344 | showTodoEditor(); |
3336 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3345 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3337 | mTodoEditor->exec(); | 3346 | mTodoEditor->exec(); |
3338 | setActiveWindow(); | 3347 | setActiveWindow(); |
3339 | 3348 | ||
3340 | } | 3349 | } |
3341 | 3350 | ||
3342 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3351 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3343 | { | 3352 | { |
3344 | if ( !mEventViewerDialog ) { | 3353 | if ( !mEventViewerDialog ) { |
3345 | mEventViewerDialog = new KOEventViewerDialog(0); | 3354 | mEventViewerDialog = new KOEventViewerDialog(0); |
3346 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3355 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3347 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3356 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3348 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3357 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3349 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3358 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3350 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3359 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3351 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3360 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3352 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3361 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3353 | this, SLOT( slotViewerClosed() ) ); | 3362 | this, SLOT( slotViewerClosed() ) ); |
3354 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3363 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3355 | this, SLOT( todoChanged(Todo *) ) ); | 3364 | this, SLOT( todoChanged(Todo *) ) ); |
3356 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3365 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3357 | mEventViewerDialog->resize( 640, 480 ); | 3366 | mEventViewerDialog->resize( 640, 480 ); |
3358 | 3367 | ||
3359 | } | 3368 | } |
3360 | return mEventViewerDialog; | 3369 | return mEventViewerDialog; |
3361 | } | 3370 | } |
3362 | void CalendarView::showEvent(Event *event) | 3371 | void CalendarView::showEvent(Event *event) |
3363 | { | 3372 | { |
3364 | getEventViewerDialog()->setEvent(event); | 3373 | getEventViewerDialog()->setEvent(event); |
3365 | getEventViewerDialog()->showMe(); | 3374 | getEventViewerDialog()->showMe(); |
3366 | } | 3375 | } |
3367 | 3376 | ||
3368 | void CalendarView::showTodo(Todo *event) | 3377 | void CalendarView::showTodo(Todo *event) |
3369 | { | 3378 | { |
3370 | getEventViewerDialog()->setTodo(event); | 3379 | getEventViewerDialog()->setTodo(event); |
3371 | getEventViewerDialog()->showMe(); | 3380 | getEventViewerDialog()->showMe(); |
3372 | } | 3381 | } |
3373 | void CalendarView::showJournal( Journal *jour ) | 3382 | void CalendarView::showJournal( Journal *jour ) |
3374 | { | 3383 | { |
3375 | getEventViewerDialog()->setJournal(jour); | 3384 | getEventViewerDialog()->setJournal(jour); |
3376 | getEventViewerDialog()->showMe(); | 3385 | getEventViewerDialog()->showMe(); |
3377 | 3386 | ||
3378 | } | 3387 | } |
3379 | // void CalendarView::todoModified (Todo *event, int changed) | 3388 | // void CalendarView::todoModified (Todo *event, int changed) |
3380 | // { | 3389 | // { |
3381 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3390 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3382 | // // kdDebug() << "Todo modified and open" << endl; | 3391 | // // kdDebug() << "Todo modified and open" << endl; |
3383 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3392 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3384 | // // temp->modified (changed); | 3393 | // // temp->modified (changed); |
3385 | 3394 | ||
3386 | // // } | 3395 | // // } |
3387 | 3396 | ||
3388 | // mViewManager->updateView(); | 3397 | // mViewManager->updateView(); |
3389 | // } | 3398 | // } |
3390 | 3399 | ||
3391 | void CalendarView::appointment_show() | 3400 | void CalendarView::appointment_show() |
3392 | { | 3401 | { |
3393 | Event *anEvent = 0; | 3402 | Event *anEvent = 0; |
3394 | 3403 | ||
3395 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3404 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3396 | 3405 | ||
3397 | if (mViewManager->currentView()->isEventView()) { | 3406 | if (mViewManager->currentView()->isEventView()) { |
3398 | if ( incidence && incidence->typeID() == eventID ) { | 3407 | if ( incidence && incidence->typeID() == eventID ) { |
3399 | anEvent = static_cast<Event *>(incidence); | 3408 | anEvent = static_cast<Event *>(incidence); |
3400 | } | 3409 | } |
3401 | } | 3410 | } |
3402 | 3411 | ||
3403 | if (!anEvent) { | 3412 | if (!anEvent) { |
3404 | KNotifyClient::beep(); | 3413 | KNotifyClient::beep(); |
3405 | return; | 3414 | return; |
3406 | } | 3415 | } |
3407 | 3416 | ||
3408 | showEvent(anEvent); | 3417 | showEvent(anEvent); |
3409 | } | 3418 | } |
3410 | 3419 | ||
3411 | void CalendarView::appointment_edit() | 3420 | void CalendarView::appointment_edit() |
3412 | { | 3421 | { |
3413 | Event *anEvent = 0; | 3422 | Event *anEvent = 0; |
3414 | 3423 | ||
3415 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3424 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3416 | 3425 | ||
3417 | if (mViewManager->currentView()->isEventView()) { | 3426 | if (mViewManager->currentView()->isEventView()) { |
3418 | if ( incidence && incidence->typeID() == eventID ) { | 3427 | if ( incidence && incidence->typeID() == eventID ) { |
3419 | anEvent = static_cast<Event *>(incidence); | 3428 | anEvent = static_cast<Event *>(incidence); |
3420 | } | 3429 | } |
3421 | } | 3430 | } |
3422 | 3431 | ||
3423 | if (!anEvent) { | 3432 | if (!anEvent) { |
3424 | KNotifyClient::beep(); | 3433 | KNotifyClient::beep(); |
3425 | return; | 3434 | return; |
3426 | } | 3435 | } |
3427 | 3436 | ||
3428 | editEvent(anEvent); | 3437 | editEvent(anEvent); |
3429 | } | 3438 | } |
3430 | 3439 | ||
3431 | void CalendarView::appointment_delete() | 3440 | void CalendarView::appointment_delete() |
3432 | { | 3441 | { |
3433 | Event *anEvent = 0; | 3442 | Event *anEvent = 0; |
3434 | 3443 | ||
3435 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3444 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3436 | 3445 | ||
3437 | if (mViewManager->currentView()->isEventView()) { | 3446 | if (mViewManager->currentView()->isEventView()) { |
@@ -3646,971 +3655,976 @@ void CalendarView::action_mail() | |||
3646 | if (ev) delete(ev); | 3655 | if (ev) delete(ev); |
3647 | 3656 | ||
3648 | mailClient.mailAttendees(currentSelection(), attachment); | 3657 | mailClient.mailAttendees(currentSelection(), attachment); |
3649 | 3658 | ||
3650 | #endif | 3659 | #endif |
3651 | 3660 | ||
3652 | #if 0 | 3661 | #if 0 |
3653 | Event *anEvent = 0; | 3662 | Event *anEvent = 0; |
3654 | if (mViewManager->currentView()->isEventView()) { | 3663 | if (mViewManager->currentView()->isEventView()) { |
3655 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3664 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3656 | } | 3665 | } |
3657 | 3666 | ||
3658 | if (!anEvent) { | 3667 | if (!anEvent) { |
3659 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3668 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3660 | return; | 3669 | return; |
3661 | } | 3670 | } |
3662 | if(anEvent->attendeeCount() == 0 ) { | 3671 | if(anEvent->attendeeCount() == 0 ) { |
3663 | KMessageBox::sorry(this, | 3672 | KMessageBox::sorry(this, |
3664 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3673 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3665 | return; | 3674 | return; |
3666 | } | 3675 | } |
3667 | 3676 | ||
3668 | mailobject.emailEvent(anEvent); | 3677 | mailobject.emailEvent(anEvent); |
3669 | #endif | 3678 | #endif |
3670 | } | 3679 | } |
3671 | 3680 | ||
3672 | 3681 | ||
3673 | void CalendarView::schedule_publish(Incidence *incidence) | 3682 | void CalendarView::schedule_publish(Incidence *incidence) |
3674 | { | 3683 | { |
3675 | Event *event = 0; | 3684 | Event *event = 0; |
3676 | Todo *todo = 0; | 3685 | Todo *todo = 0; |
3677 | 3686 | ||
3678 | if (incidence == 0) { | 3687 | if (incidence == 0) { |
3679 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3688 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3680 | if (incidence == 0) { | 3689 | if (incidence == 0) { |
3681 | incidence = mTodoList->selectedIncidences().first(); | 3690 | incidence = mTodoList->selectedIncidences().first(); |
3682 | } | 3691 | } |
3683 | } | 3692 | } |
3684 | if ( incidence && incidence->typeID() == eventID ) { | 3693 | if ( incidence && incidence->typeID() == eventID ) { |
3685 | event = static_cast<Event *>(incidence); | 3694 | event = static_cast<Event *>(incidence); |
3686 | } else { | 3695 | } else { |
3687 | if ( incidence && incidence->typeID() == todoID ) { | 3696 | if ( incidence && incidence->typeID() == todoID ) { |
3688 | todo = static_cast<Todo *>(incidence); | 3697 | todo = static_cast<Todo *>(incidence); |
3689 | } | 3698 | } |
3690 | } | 3699 | } |
3691 | 3700 | ||
3692 | if (!event && !todo) { | 3701 | if (!event && !todo) { |
3693 | KMessageBox::sorry(this,i18n("No event selected.")); | 3702 | KMessageBox::sorry(this,i18n("No event selected.")); |
3694 | return; | 3703 | return; |
3695 | } | 3704 | } |
3696 | 3705 | ||
3697 | PublishDialog *publishdlg = new PublishDialog(); | 3706 | PublishDialog *publishdlg = new PublishDialog(); |
3698 | if (incidence->attendeeCount()>0) { | 3707 | if (incidence->attendeeCount()>0) { |
3699 | QPtrList<Attendee> attendees = incidence->attendees(); | 3708 | QPtrList<Attendee> attendees = incidence->attendees(); |
3700 | attendees.first(); | 3709 | attendees.first(); |
3701 | while ( attendees.current()!=0 ) { | 3710 | while ( attendees.current()!=0 ) { |
3702 | publishdlg->addAttendee(attendees.current()); | 3711 | publishdlg->addAttendee(attendees.current()); |
3703 | attendees.next(); | 3712 | attendees.next(); |
3704 | } | 3713 | } |
3705 | } | 3714 | } |
3706 | bool send = true; | 3715 | bool send = true; |
3707 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3716 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3708 | if ( publishdlg->exec() != QDialog::Accepted ) | 3717 | if ( publishdlg->exec() != QDialog::Accepted ) |
3709 | send = false; | 3718 | send = false; |
3710 | } | 3719 | } |
3711 | if ( send ) { | 3720 | if ( send ) { |
3712 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3721 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3713 | if ( event ) { | 3722 | if ( event ) { |
3714 | Event *ev = new Event(*event); | 3723 | Event *ev = new Event(*event); |
3715 | ev->registerObserver(0); | 3724 | ev->registerObserver(0); |
3716 | ev->clearAttendees(); | 3725 | ev->clearAttendees(); |
3717 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3726 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3718 | delete(ev); | 3727 | delete(ev); |
3719 | } | 3728 | } |
3720 | } else { | 3729 | } else { |
3721 | if ( todo ) { | 3730 | if ( todo ) { |
3722 | Todo *ev = new Todo(*todo); | 3731 | Todo *ev = new Todo(*todo); |
3723 | ev->registerObserver(0); | 3732 | ev->registerObserver(0); |
3724 | ev->clearAttendees(); | 3733 | ev->clearAttendees(); |
3725 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3734 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3726 | delete(ev); | 3735 | delete(ev); |
3727 | } | 3736 | } |
3728 | } | 3737 | } |
3729 | } | 3738 | } |
3730 | } | 3739 | } |
3731 | delete publishdlg; | 3740 | delete publishdlg; |
3732 | } | 3741 | } |
3733 | 3742 | ||
3734 | void CalendarView::schedule_request(Incidence *incidence) | 3743 | void CalendarView::schedule_request(Incidence *incidence) |
3735 | { | 3744 | { |
3736 | schedule(Scheduler::Request,incidence); | 3745 | schedule(Scheduler::Request,incidence); |
3737 | } | 3746 | } |
3738 | 3747 | ||
3739 | void CalendarView::schedule_refresh(Incidence *incidence) | 3748 | void CalendarView::schedule_refresh(Incidence *incidence) |
3740 | { | 3749 | { |
3741 | schedule(Scheduler::Refresh,incidence); | 3750 | schedule(Scheduler::Refresh,incidence); |
3742 | } | 3751 | } |
3743 | 3752 | ||
3744 | void CalendarView::schedule_cancel(Incidence *incidence) | 3753 | void CalendarView::schedule_cancel(Incidence *incidence) |
3745 | { | 3754 | { |
3746 | schedule(Scheduler::Cancel,incidence); | 3755 | schedule(Scheduler::Cancel,incidence); |
3747 | } | 3756 | } |
3748 | 3757 | ||
3749 | void CalendarView::schedule_add(Incidence *incidence) | 3758 | void CalendarView::schedule_add(Incidence *incidence) |
3750 | { | 3759 | { |
3751 | schedule(Scheduler::Add,incidence); | 3760 | schedule(Scheduler::Add,incidence); |
3752 | } | 3761 | } |
3753 | 3762 | ||
3754 | void CalendarView::schedule_reply(Incidence *incidence) | 3763 | void CalendarView::schedule_reply(Incidence *incidence) |
3755 | { | 3764 | { |
3756 | schedule(Scheduler::Reply,incidence); | 3765 | schedule(Scheduler::Reply,incidence); |
3757 | } | 3766 | } |
3758 | 3767 | ||
3759 | void CalendarView::schedule_counter(Incidence *incidence) | 3768 | void CalendarView::schedule_counter(Incidence *incidence) |
3760 | { | 3769 | { |
3761 | schedule(Scheduler::Counter,incidence); | 3770 | schedule(Scheduler::Counter,incidence); |
3762 | } | 3771 | } |
3763 | 3772 | ||
3764 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3773 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3765 | { | 3774 | { |
3766 | schedule(Scheduler::Declinecounter,incidence); | 3775 | schedule(Scheduler::Declinecounter,incidence); |
3767 | } | 3776 | } |
3768 | 3777 | ||
3769 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3778 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3770 | { | 3779 | { |
3771 | QDateTime start = QDateTime::currentDateTime(); | 3780 | QDateTime start = QDateTime::currentDateTime(); |
3772 | QDateTime end = start.addDays(daysToPublish); | 3781 | QDateTime end = start.addDays(daysToPublish); |
3773 | 3782 | ||
3774 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3783 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3775 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3784 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3776 | 3785 | ||
3777 | 3786 | ||
3778 | PublishDialog *publishdlg = new PublishDialog(); | 3787 | PublishDialog *publishdlg = new PublishDialog(); |
3779 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3788 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3780 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3789 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3781 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3790 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3782 | delete(freebusy); | 3791 | delete(freebusy); |
3783 | } | 3792 | } |
3784 | } | 3793 | } |
3785 | delete publishdlg; | 3794 | delete publishdlg; |
3786 | } | 3795 | } |
3787 | 3796 | ||
3788 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3797 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3789 | { | 3798 | { |
3790 | Event *event = 0; | 3799 | Event *event = 0; |
3791 | Todo *todo = 0; | 3800 | Todo *todo = 0; |
3792 | 3801 | ||
3793 | if (incidence == 0) { | 3802 | if (incidence == 0) { |
3794 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3803 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3795 | if (incidence == 0) { | 3804 | if (incidence == 0) { |
3796 | incidence = mTodoList->selectedIncidences().first(); | 3805 | incidence = mTodoList->selectedIncidences().first(); |
3797 | } | 3806 | } |
3798 | } | 3807 | } |
3799 | if ( incidence && incidence->typeID() == eventID ) { | 3808 | if ( incidence && incidence->typeID() == eventID ) { |
3800 | event = static_cast<Event *>(incidence); | 3809 | event = static_cast<Event *>(incidence); |
3801 | } | 3810 | } |
3802 | if ( incidence && incidence->typeID() == todoID ) { | 3811 | if ( incidence && incidence->typeID() == todoID ) { |
3803 | todo = static_cast<Todo *>(incidence); | 3812 | todo = static_cast<Todo *>(incidence); |
3804 | } | 3813 | } |
3805 | 3814 | ||
3806 | if (!event && !todo) { | 3815 | if (!event && !todo) { |
3807 | KMessageBox::sorry(this,i18n("No event selected.")); | 3816 | KMessageBox::sorry(this,i18n("No event selected.")); |
3808 | return; | 3817 | return; |
3809 | } | 3818 | } |
3810 | 3819 | ||
3811 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3820 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3812 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3821 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3813 | return; | 3822 | return; |
3814 | } | 3823 | } |
3815 | 3824 | ||
3816 | Event *ev = 0; | 3825 | Event *ev = 0; |
3817 | if (event) ev = new Event(*event); | 3826 | if (event) ev = new Event(*event); |
3818 | Todo *to = 0; | 3827 | Todo *to = 0; |
3819 | if (todo) to = new Todo(*todo); | 3828 | if (todo) to = new Todo(*todo); |
3820 | 3829 | ||
3821 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3830 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3822 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3831 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3823 | if (!me) { | 3832 | if (!me) { |
3824 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3833 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3825 | return; | 3834 | return; |
3826 | } | 3835 | } |
3827 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3836 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3828 | StatusDialog *statdlg = new StatusDialog(this); | 3837 | StatusDialog *statdlg = new StatusDialog(this); |
3829 | if (!statdlg->exec()==QDialog::Accepted) return; | 3838 | if (!statdlg->exec()==QDialog::Accepted) return; |
3830 | me->setStatus( statdlg->status() ); | 3839 | me->setStatus( statdlg->status() ); |
3831 | delete(statdlg); | 3840 | delete(statdlg); |
3832 | } | 3841 | } |
3833 | Attendee *menew = new Attendee(*me); | 3842 | Attendee *menew = new Attendee(*me); |
3834 | if (ev) { | 3843 | if (ev) { |
3835 | ev->clearAttendees(); | 3844 | ev->clearAttendees(); |
3836 | ev->addAttendee(menew,false); | 3845 | ev->addAttendee(menew,false); |
3837 | } else { | 3846 | } else { |
3838 | if (to) { | 3847 | if (to) { |
3839 | todo->clearAttendees(); | 3848 | todo->clearAttendees(); |
3840 | todo->addAttendee(menew,false); | 3849 | todo->addAttendee(menew,false); |
3841 | } | 3850 | } |
3842 | } | 3851 | } |
3843 | } | 3852 | } |
3844 | 3853 | ||
3845 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3854 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3846 | if (ev) { | 3855 | if (ev) { |
3847 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3856 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3848 | } else { | 3857 | } else { |
3849 | if (to) { | 3858 | if (to) { |
3850 | if ( !dlg->addMessage(to,method) ) delete(to); | 3859 | if ( !dlg->addMessage(to,method) ) delete(to); |
3851 | } | 3860 | } |
3852 | } | 3861 | } |
3853 | } | 3862 | } |
3854 | 3863 | ||
3855 | void CalendarView::openAddressbook() | 3864 | void CalendarView::openAddressbook() |
3856 | { | 3865 | { |
3857 | KRun::runCommand("kaddressbook"); | 3866 | KRun::runCommand("kaddressbook"); |
3858 | } | 3867 | } |
3859 | 3868 | ||
3860 | void CalendarView::setModified(bool modified) | 3869 | void CalendarView::setModified(bool modified) |
3861 | { | 3870 | { |
3862 | if ( modified ) | 3871 | if ( modified ) |
3863 | emit signalmodified(); | 3872 | emit signalmodified(); |
3864 | if (mModified != modified) { | 3873 | if (mModified != modified) { |
3865 | mModified = modified; | 3874 | mModified = modified; |
3866 | emit modifiedChanged(mModified); | 3875 | emit modifiedChanged(mModified); |
3867 | } | 3876 | } |
3868 | } | 3877 | } |
3869 | 3878 | ||
3870 | bool CalendarView::isReadOnly() | 3879 | bool CalendarView::isReadOnly() |
3871 | { | 3880 | { |
3872 | return mReadOnly; | 3881 | return mReadOnly; |
3873 | } | 3882 | } |
3874 | 3883 | ||
3875 | void CalendarView::setReadOnly(bool readOnly) | 3884 | void CalendarView::setReadOnly(bool readOnly) |
3876 | { | 3885 | { |
3877 | if (mReadOnly != readOnly) { | 3886 | if (mReadOnly != readOnly) { |
3878 | mReadOnly = readOnly; | 3887 | mReadOnly = readOnly; |
3879 | emit readOnlyChanged(mReadOnly); | 3888 | emit readOnlyChanged(mReadOnly); |
3880 | } | 3889 | } |
3881 | } | 3890 | } |
3882 | 3891 | ||
3883 | bool CalendarView::isModified() | 3892 | bool CalendarView::isModified() |
3884 | { | 3893 | { |
3885 | return mModified; | 3894 | return mModified; |
3886 | } | 3895 | } |
3887 | void CalendarView::slotprintSelInc() | 3896 | void CalendarView::slotprintSelInc() |
3888 | { | 3897 | { |
3889 | if ( currentSelection() == 0 ) { | 3898 | if ( currentSelection() == 0 ) { |
3890 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 3899 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
3891 | return; | 3900 | return; |
3892 | } | 3901 | } |
3893 | showIncidence(); | 3902 | showIncidence(); |
3894 | getEventViewerDialog()->print(); | 3903 | getEventViewerDialog()->print(); |
3895 | 3904 | ||
3896 | } | 3905 | } |
3897 | void CalendarView::printSetup() | 3906 | void CalendarView::printSetup() |
3898 | { | 3907 | { |
3899 | #ifndef KORG_NOPRINTER | 3908 | #ifndef KORG_NOPRINTER |
3900 | createPrinter(); | 3909 | createPrinter(); |
3901 | 3910 | ||
3902 | mCalPrinter->setupPrinter(); | 3911 | mCalPrinter->setupPrinter(); |
3903 | #endif | 3912 | #endif |
3904 | } | 3913 | } |
3905 | 3914 | ||
3906 | void CalendarView::print() | 3915 | void CalendarView::print() |
3907 | { | 3916 | { |
3908 | #ifndef KORG_NOPRINTER | 3917 | #ifndef KORG_NOPRINTER |
3909 | createPrinter(); | 3918 | createPrinter(); |
3910 | 3919 | ||
3911 | DateList tmpDateList = mNavigator->selectedDates(); | 3920 | DateList tmpDateList = mNavigator->selectedDates(); |
3912 | mCalPrinter->print(CalPrinter::Month, | 3921 | mCalPrinter->print(CalPrinter::Month, |
3913 | tmpDateList.first(), tmpDateList.last()); | 3922 | tmpDateList.first(), tmpDateList.last()); |
3914 | #endif | 3923 | #endif |
3915 | } | 3924 | } |
3916 | 3925 | ||
3917 | void CalendarView::printPreview() | 3926 | void CalendarView::printPreview() |
3918 | { | 3927 | { |
3919 | #ifndef KORG_NOPRINTER | 3928 | #ifndef KORG_NOPRINTER |
3920 | kdDebug() << "CalendarView::printPreview()" << endl; | 3929 | kdDebug() << "CalendarView::printPreview()" << endl; |
3921 | 3930 | ||
3922 | createPrinter(); | 3931 | createPrinter(); |
3923 | 3932 | ||
3924 | DateList tmpDateList = mNavigator->selectedDates(); | 3933 | DateList tmpDateList = mNavigator->selectedDates(); |
3925 | 3934 | ||
3926 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3935 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3927 | tmpDateList.last()); | 3936 | tmpDateList.last()); |
3928 | #endif | 3937 | #endif |
3929 | } | 3938 | } |
3930 | 3939 | ||
3931 | void CalendarView::exportICalendar() | 3940 | void CalendarView::exportICalendar() |
3932 | { | 3941 | { |
3933 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3942 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3934 | 3943 | ||
3935 | // Force correct extension | 3944 | // Force correct extension |
3936 | if (filename.right(4) != ".ics") filename += ".ics"; | 3945 | if (filename.right(4) != ".ics") filename += ".ics"; |
3937 | 3946 | ||
3938 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3947 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3939 | storage.save(); | 3948 | storage.save(); |
3940 | } | 3949 | } |
3941 | 3950 | ||
3942 | bool CalendarView::exportVCalendar( QString filename ) | 3951 | bool CalendarView::exportVCalendar( QString filename ) |
3943 | { | 3952 | { |
3944 | if (mCalendar->journals().count() > 0) { | 3953 | if (mCalendar->journals().count() > 0) { |
3945 | int result = KMessageBox::warningContinueCancel(this, | 3954 | int result = KMessageBox::warningContinueCancel(this, |
3946 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3955 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3947 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3956 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3948 | true); | 3957 | true); |
3949 | if (result != KMessageBox::Continue) return false; | 3958 | if (result != KMessageBox::Continue) return false; |
3950 | } | 3959 | } |
3951 | 3960 | ||
3952 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3961 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3953 | 3962 | ||
3954 | // Force correct extension | 3963 | // Force correct extension |
3955 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3964 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3956 | 3965 | ||
3957 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3966 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3958 | return storage.save(); | 3967 | return storage.save(); |
3959 | 3968 | ||
3960 | } | 3969 | } |
3961 | 3970 | ||
3962 | void CalendarView::eventUpdated(Incidence *) | 3971 | void CalendarView::eventUpdated(Incidence *) |
3963 | { | 3972 | { |
3964 | setModified(); | 3973 | setModified(); |
3965 | // Don't call updateView here. The code, which has caused the update of the | 3974 | // Don't call updateView here. The code, which has caused the update of the |
3966 | // event is responsible for updating the view. | 3975 | // event is responsible for updating the view. |
3967 | // updateView(); | 3976 | // updateView(); |
3968 | } | 3977 | } |
3969 | 3978 | ||
3970 | void CalendarView::adaptNavigationUnits() | 3979 | void CalendarView::adaptNavigationUnits() |
3971 | { | 3980 | { |
3972 | if (mViewManager->currentView()->isEventView()) { | 3981 | if (mViewManager->currentView()->isEventView()) { |
3973 | int days = mViewManager->currentView()->currentDateCount(); | 3982 | int days = mViewManager->currentView()->currentDateCount(); |
3974 | if (days == 1) { | 3983 | if (days == 1) { |
3975 | emit changeNavStringPrev(i18n("&Previous Day")); | 3984 | emit changeNavStringPrev(i18n("&Previous Day")); |
3976 | emit changeNavStringNext(i18n("&Next Day")); | 3985 | emit changeNavStringNext(i18n("&Next Day")); |
3977 | } else { | 3986 | } else { |
3978 | emit changeNavStringPrev(i18n("&Previous Week")); | 3987 | emit changeNavStringPrev(i18n("&Previous Week")); |
3979 | emit changeNavStringNext(i18n("&Next Week")); | 3988 | emit changeNavStringNext(i18n("&Next Week")); |
3980 | } | 3989 | } |
3981 | } | 3990 | } |
3982 | } | 3991 | } |
3983 | 3992 | ||
3984 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3993 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3985 | { | 3994 | { |
3986 | if ( incidence ) mTodoList->clearSelection(); | 3995 | if ( incidence ) mTodoList->clearSelection(); |
3987 | processIncidenceSelection( incidence ); | 3996 | processIncidenceSelection( incidence ); |
3988 | } | 3997 | } |
3989 | 3998 | ||
3990 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3999 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3991 | { | 4000 | { |
3992 | if ( incidence && mViewManager->currentView() ) { | 4001 | if ( incidence && mViewManager->currentView() ) { |
3993 | mViewManager->currentView()->clearSelection(); | 4002 | mViewManager->currentView()->clearSelection(); |
3994 | } | 4003 | } |
3995 | processIncidenceSelection( incidence ); | 4004 | processIncidenceSelection( incidence ); |
3996 | } | 4005 | } |
3997 | 4006 | ||
3998 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4007 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3999 | { | 4008 | { |
4000 | emit incidenceSelected( incidence ); | 4009 | emit incidenceSelected( incidence ); |
4001 | if ( incidence == mSelectedIncidence ) return; | 4010 | if ( incidence == mSelectedIncidence ) return; |
4002 | mSelectedIncidence = incidence; | 4011 | mSelectedIncidence = incidence; |
4003 | 4012 | ||
4004 | if ( incidence && incidence->typeID() == eventID ) { | 4013 | if ( incidence && incidence->typeID() == eventID ) { |
4005 | Event *event = static_cast<Event *>( incidence ); | 4014 | Event *event = static_cast<Event *>( incidence ); |
4006 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4015 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4007 | emit organizerEventsSelected( true ); | 4016 | emit organizerEventsSelected( true ); |
4008 | } else { | 4017 | } else { |
4009 | emit organizerEventsSelected(false); | 4018 | emit organizerEventsSelected(false); |
4010 | } | 4019 | } |
4011 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4020 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4012 | KOPrefs::instance()->email() ) ) { | 4021 | KOPrefs::instance()->email() ) ) { |
4013 | emit groupEventsSelected( true ); | 4022 | emit groupEventsSelected( true ); |
4014 | } else { | 4023 | } else { |
4015 | emit groupEventsSelected(false); | 4024 | emit groupEventsSelected(false); |
4016 | } | 4025 | } |
4017 | return; | 4026 | return; |
4018 | } else { | 4027 | } else { |
4019 | if ( incidence && incidence->typeID() == todoID ) { | 4028 | if ( incidence && incidence->typeID() == todoID ) { |
4020 | emit todoSelected( true ); | 4029 | emit todoSelected( true ); |
4021 | Todo *event = static_cast<Todo *>( incidence ); | 4030 | Todo *event = static_cast<Todo *>( incidence ); |
4022 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4031 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4023 | emit organizerEventsSelected( true ); | 4032 | emit organizerEventsSelected( true ); |
4024 | } else { | 4033 | } else { |
4025 | emit organizerEventsSelected(false); | 4034 | emit organizerEventsSelected(false); |
4026 | } | 4035 | } |
4027 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4036 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4028 | KOPrefs::instance()->email() ) ) { | 4037 | KOPrefs::instance()->email() ) ) { |
4029 | emit groupEventsSelected( true ); | 4038 | emit groupEventsSelected( true ); |
4030 | } else { | 4039 | } else { |
4031 | emit groupEventsSelected(false); | 4040 | emit groupEventsSelected(false); |
4032 | } | 4041 | } |
4033 | return; | 4042 | return; |
4034 | } else { | 4043 | } else { |
4035 | emit todoSelected( false ); | 4044 | emit todoSelected( false ); |
4036 | emit organizerEventsSelected(false); | 4045 | emit organizerEventsSelected(false); |
4037 | emit groupEventsSelected(false); | 4046 | emit groupEventsSelected(false); |
4038 | } | 4047 | } |
4039 | return; | 4048 | return; |
4040 | } | 4049 | } |
4041 | 4050 | ||
4042 | /* if ( incidence && incidence->typeID() == todoID ) { | 4051 | /* if ( incidence && incidence->typeID() == todoID ) { |
4043 | emit todoSelected( true ); | 4052 | emit todoSelected( true ); |
4044 | } else { | 4053 | } else { |
4045 | emit todoSelected( false ); | 4054 | emit todoSelected( false ); |
4046 | }*/ | 4055 | }*/ |
4047 | } | 4056 | } |
4048 | 4057 | ||
4049 | 4058 | ||
4050 | void CalendarView::checkClipboard() | 4059 | void CalendarView::checkClipboard() |
4051 | { | 4060 | { |
4052 | #ifndef KORG_NODND | 4061 | #ifndef KORG_NODND |
4053 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4062 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4054 | emit pasteEnabled(true); | 4063 | emit pasteEnabled(true); |
4055 | } else { | 4064 | } else { |
4056 | emit pasteEnabled(false); | 4065 | emit pasteEnabled(false); |
4057 | } | 4066 | } |
4058 | #endif | 4067 | #endif |
4059 | } | 4068 | } |
4060 | 4069 | ||
4061 | void CalendarView::showDates(const DateList &selectedDates) | 4070 | void CalendarView::showDates(const DateList &selectedDates) |
4062 | { | 4071 | { |
4063 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4072 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4064 | 4073 | ||
4065 | 4074 | ||
4066 | if ( !mBlockShowDates ) { | 4075 | if ( !mBlockShowDates ) { |
4067 | if ( mViewManager->currentView() ) { | 4076 | if ( mViewManager->currentView() ) { |
4068 | updateView( selectedDates.first(), selectedDates.last() ); | 4077 | updateView( selectedDates.first(), selectedDates.last() ); |
4069 | } else { | 4078 | } else { |
4070 | mViewManager->showAgendaView(); | 4079 | mViewManager->showAgendaView(); |
4071 | } | 4080 | } |
4072 | } | 4081 | } |
4073 | 4082 | ||
4074 | QDate date = selectedDates.first(); | 4083 | QDate date = selectedDates.first(); |
4075 | if ( ! date.isValid() ) { | 4084 | if ( ! date.isValid() ) { |
4076 | topLevelWidget()->setCaption(""); | 4085 | topLevelWidget()->setCaption(""); |
4077 | return; | 4086 | return; |
4078 | } | 4087 | } |
4079 | 4088 | ||
4080 | QString selDates; | 4089 | QString selDates; |
4081 | selDates = KGlobal::locale()->formatDate( date, true); | 4090 | selDates = KGlobal::locale()->formatDate( date, true); |
4082 | if (selectedDates.first() < selectedDates.last() ) | 4091 | if (selectedDates.first() < selectedDates.last() ) |
4083 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4092 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4084 | else { | 4093 | else { |
4085 | QString addString; | 4094 | QString addString; |
4086 | if ( date == QDateTime::currentDateTime().date() ) | 4095 | if ( date == QDateTime::currentDateTime().date() ) |
4087 | addString = i18n("Today"); | 4096 | addString = i18n("Today"); |
4088 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4097 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4089 | addString = i18n("Tomorrow"); | 4098 | addString = i18n("Tomorrow"); |
4090 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4099 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4091 | addString = i18n("Yesterday"); | 4100 | addString = i18n("Yesterday"); |
4092 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4101 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4093 | addString = i18n("Day before yesterday"); | 4102 | addString = i18n("Day before yesterday"); |
4094 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4103 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4095 | addString = i18n("Day after tomorrow"); | 4104 | addString = i18n("Day after tomorrow"); |
4096 | if ( !addString.isEmpty() ) { | 4105 | if ( !addString.isEmpty() ) { |
4097 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4106 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4098 | return; | 4107 | return; |
4099 | } | 4108 | } |
4100 | } | 4109 | } |
4101 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4110 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4102 | 4111 | ||
4103 | } | 4112 | } |
4104 | 4113 | ||
4105 | QPtrList<CalFilter> CalendarView::filters() | 4114 | QPtrList<CalFilter> CalendarView::filters() |
4106 | { | 4115 | { |
4107 | return mFilters; | 4116 | return mFilters; |
4108 | 4117 | ||
4109 | } | 4118 | } |
4110 | void CalendarView::editFilters() | 4119 | void CalendarView::editFilters() |
4111 | { | 4120 | { |
4112 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4121 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4113 | 4122 | ||
4114 | CalFilter *filter = mFilters.first(); | 4123 | CalFilter *filter = mFilters.first(); |
4115 | while(filter) { | 4124 | while(filter) { |
4116 | filter = mFilters.next(); | 4125 | filter = mFilters.next(); |
4117 | } | 4126 | } |
4118 | 4127 | ||
4119 | mDialogManager->showFilterEditDialog(&mFilters); | 4128 | mDialogManager->showFilterEditDialog(&mFilters); |
4120 | updateFilter(); | 4129 | updateFilter(); |
4121 | } | 4130 | } |
4122 | void CalendarView::toggleFilter() | 4131 | void CalendarView::toggleFilter() |
4123 | { | 4132 | { |
4124 | if ( mLeftFrame->isHidden() ) { | 4133 | if ( mLeftFrame->isHidden() ) { |
4125 | toggleExpand(); | 4134 | toggleExpand(); |
4126 | showFilter( true ); | 4135 | showFilter( true ); |
4127 | } else | 4136 | } else |
4128 | showFilter(! mCalEditView->isVisible()); | 4137 | showFilter(! mCalEditView->isVisible()); |
4129 | } | 4138 | } |
4130 | 4139 | ||
4131 | KOFilterView *CalendarView::filterView() | 4140 | KOFilterView *CalendarView::filterView() |
4132 | { | 4141 | { |
4133 | return mFilterView; | 4142 | return mFilterView; |
4134 | } | 4143 | } |
4135 | void CalendarView::selectFilter( int fil ) | 4144 | void CalendarView::selectFilter( int fil ) |
4136 | { | 4145 | { |
4137 | mFilterView->setSelectedFilter( fil ); | 4146 | mFilterView->setSelectedFilter( fil ); |
4138 | updateUnmanagedViews(); | 4147 | updateUnmanagedViews(); |
4139 | } | 4148 | } |
4140 | void CalendarView::showFilter(bool visible) | 4149 | void CalendarView::showFilter(bool visible) |
4141 | { | 4150 | { |
4142 | #if 1 | 4151 | #if 1 |
4143 | if (visible) { | 4152 | if (visible) { |
4144 | mCalEditView->readConfig(); | 4153 | mCalEditView->readConfig(); |
4145 | mCalEditView->show(); | 4154 | mCalEditView->show(); |
4146 | QValueList<int> sizes; | 4155 | QValueList<int> sizes; |
4147 | sizes = mLeftFrame->sizes(); | 4156 | sizes = mLeftFrame->sizes(); |
4148 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4157 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4149 | sizes.clear(); | 4158 | sizes.clear(); |
4150 | sizes << 100; | 4159 | sizes << 100; |
4151 | sizes << 0; | 4160 | sizes << 0; |
4152 | sizes << 0; | 4161 | sizes << 0; |
4153 | sizes << 100; | 4162 | sizes << 100; |
4154 | mLeftFrame->setSizes(sizes); | 4163 | mLeftFrame->setSizes(sizes); |
4155 | } | 4164 | } |
4156 | #if 0 | 4165 | #if 0 |
4157 | sizes = mLeftFrame->sizes(); | 4166 | sizes = mLeftFrame->sizes(); |
4158 | int ccc = 0; | 4167 | int ccc = 0; |
4159 | while ( ccc < sizes.count()) { | 4168 | while ( ccc < sizes.count()) { |
4160 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4169 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4161 | ++ccc; | 4170 | ++ccc; |
4162 | } | 4171 | } |
4163 | #endif | 4172 | #endif |
4164 | 4173 | ||
4165 | } | 4174 | } |
4166 | else { | 4175 | else { |
4167 | mCalEditView->hide(); | 4176 | mCalEditView->hide(); |
4168 | } | 4177 | } |
4169 | #else | 4178 | #else |
4170 | if (visible) mFilterView->show(); | 4179 | if (visible) mFilterView->show(); |
4171 | else mFilterView->hide(); | 4180 | else mFilterView->hide(); |
4172 | #endif | 4181 | #endif |
4173 | } | 4182 | } |
4174 | void CalendarView::toggleFilerEnabled( ) | 4183 | void CalendarView::toggleFilerEnabled( ) |
4175 | { | 4184 | { |
4176 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4185 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4177 | if ( !mFilterView->filtersEnabled() ) | 4186 | if ( !mFilterView->filtersEnabled() ) |
4178 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4187 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4179 | updateUnmanagedViews(); | 4188 | updateUnmanagedViews(); |
4180 | 4189 | ||
4181 | } | 4190 | } |
4182 | void CalendarView::updateFilter() | 4191 | void CalendarView::updateFilter() |
4183 | { | 4192 | { |
4184 | CalFilter *filter = mFilterView->selectedFilter(); | 4193 | CalFilter *filter = mFilterView->selectedFilter(); |
4185 | if (filter) { | 4194 | if (filter) { |
4186 | QString mess; | 4195 | QString mess; |
4187 | if (mFilterView->filtersEnabled()) { | 4196 | if (mFilterView->filtersEnabled()) { |
4188 | mess = i18n("Filter selected: ")+filter->name(); | 4197 | mess = i18n("Filter selected: ")+filter->name(); |
4189 | filter->setEnabled(true); | 4198 | filter->setEnabled(true); |
4190 | } | 4199 | } |
4191 | else filter->setEnabled(false); | 4200 | else filter->setEnabled(false); |
4192 | mCalendar->setFilter(filter); | 4201 | mCalendar->setFilter(filter); |
4193 | updateView(); | 4202 | updateView(); |
4194 | if ( !mess.isEmpty() ) | 4203 | if ( !mess.isEmpty() ) |
4195 | topLevelWidget()->setCaption( mess ); | 4204 | topLevelWidget()->setCaption( mess ); |
4196 | 4205 | ||
4197 | } | 4206 | } |
4198 | emit filtersUpdated(); | 4207 | emit filtersUpdated(); |
4199 | } | 4208 | } |
4200 | 4209 | ||
4201 | void CalendarView::filterEdited() | 4210 | void CalendarView::filterEdited() |
4202 | { | 4211 | { |
4203 | mFilterView->updateFilters(); | 4212 | mFilterView->updateFilters(); |
4204 | updateFilter(); | 4213 | updateFilter(); |
4205 | writeSettings(); | 4214 | writeSettings(); |
4206 | } | 4215 | } |
4207 | 4216 | ||
4208 | 4217 | ||
4209 | void CalendarView::takeOverEvent() | 4218 | void CalendarView::takeOverEvent() |
4210 | { | 4219 | { |
4211 | Incidence *incidence = currentSelection(); | 4220 | Incidence *incidence = currentSelection(); |
4212 | 4221 | ||
4213 | if (!incidence) return; | 4222 | if (!incidence) return; |
4214 | 4223 | ||
4215 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4224 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4216 | incidence->recreate(); | 4225 | incidence->recreate(); |
4217 | incidence->setReadOnly(false); | 4226 | incidence->setReadOnly(false); |
4218 | 4227 | ||
4219 | updateView(); | 4228 | updateView(); |
4220 | } | 4229 | } |
4221 | 4230 | ||
4222 | void CalendarView::takeOverCalendar() | 4231 | void CalendarView::takeOverCalendar() |
4223 | { | 4232 | { |
4224 | // TODO: Create Calendar::allIncidences() function and use it here | 4233 | // TODO: Create Calendar::allIncidences() function and use it here |
4225 | 4234 | ||
4226 | clearAllViews(); | 4235 | clearAllViews(); |
4227 | QPtrList<Event> events = mCalendar->events(); | 4236 | QPtrList<Event> events = mCalendar->events(); |
4228 | for(uint i=0; i<events.count(); ++i) { | 4237 | for(uint i=0; i<events.count(); ++i) { |
4229 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4238 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4230 | events.at(i)->recreate(); | 4239 | events.at(i)->recreate(); |
4231 | events.at(i)->setReadOnly(false); | 4240 | events.at(i)->setReadOnly(false); |
4232 | } | 4241 | } |
4233 | 4242 | ||
4234 | QPtrList<Todo> todos = mCalendar->todos(); | 4243 | QPtrList<Todo> todos = mCalendar->todos(); |
4235 | for(uint i=0; i<todos.count(); ++i) { | 4244 | for(uint i=0; i<todos.count(); ++i) { |
4236 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4245 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4237 | todos.at(i)->recreate(); | 4246 | todos.at(i)->recreate(); |
4238 | todos.at(i)->setReadOnly(false); | 4247 | todos.at(i)->setReadOnly(false); |
4239 | } | 4248 | } |
4240 | 4249 | ||
4241 | QPtrList<Journal> journals = mCalendar->journals(); | 4250 | QPtrList<Journal> journals = mCalendar->journals(); |
4242 | for(uint i=0; i<journals.count(); ++i) { | 4251 | for(uint i=0; i<journals.count(); ++i) { |
4243 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4252 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4244 | journals.at(i)->recreate(); | 4253 | journals.at(i)->recreate(); |
4245 | journals.at(i)->setReadOnly(false); | 4254 | journals.at(i)->setReadOnly(false); |
4246 | } | 4255 | } |
4247 | 4256 | ||
4248 | updateView(); | 4257 | updateView(); |
4249 | } | 4258 | } |
4250 | 4259 | ||
4251 | void CalendarView::showIntro() | 4260 | void CalendarView::showIntro() |
4252 | { | 4261 | { |
4253 | kdDebug() << "To be implemented." << endl; | 4262 | kdDebug() << "To be implemented." << endl; |
4254 | } | 4263 | } |
4255 | 4264 | ||
4256 | QWidgetStack *CalendarView::viewStack() | 4265 | QWidgetStack *CalendarView::viewStack() |
4257 | { | 4266 | { |
4258 | return mRightFrame; | 4267 | return mRightFrame; |
4259 | } | 4268 | } |
4260 | 4269 | ||
4261 | QWidget *CalendarView::leftFrame() | 4270 | QWidget *CalendarView::leftFrame() |
4262 | { | 4271 | { |
4263 | return ( QWidget *)mLeftFrame; | 4272 | return ( QWidget *)mLeftFrame; |
4264 | } | 4273 | } |
4265 | 4274 | ||
4266 | DateNavigator *CalendarView::dateNavigator() | 4275 | DateNavigator *CalendarView::dateNavigator() |
4267 | { | 4276 | { |
4268 | return mNavigator; | 4277 | return mNavigator; |
4269 | } | 4278 | } |
4270 | 4279 | ||
4271 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4280 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4272 | { | 4281 | { |
4273 | return mDateNavigator->navigatorView(); | 4282 | return mDateNavigator->navigatorView(); |
4274 | } | 4283 | } |
4275 | void CalendarView::toggleDateNavigatorWidget() | 4284 | void CalendarView::toggleDateNavigatorWidget() |
4276 | { | 4285 | { |
4277 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4286 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4278 | 4287 | ||
4279 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4288 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4280 | mDateNavigator->hide(); | 4289 | mDateNavigator->hide(); |
4281 | else | 4290 | else |
4282 | mDateNavigator->show(); | 4291 | mDateNavigator->show(); |
4283 | } | 4292 | } |
4284 | void CalendarView::addView(KOrg::BaseView *view) | 4293 | void CalendarView::addView(KOrg::BaseView *view) |
4285 | { | 4294 | { |
4286 | mViewManager->addView(view); | 4295 | mViewManager->addView(view); |
4287 | } | 4296 | } |
4288 | 4297 | ||
4289 | void CalendarView::showView(KOrg::BaseView *view) | 4298 | void CalendarView::showView(KOrg::BaseView *view) |
4290 | { | 4299 | { |
4291 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4300 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4292 | } | 4301 | } |
4293 | 4302 | ||
4294 | Incidence *CalendarView::currentSelection() | 4303 | Incidence *CalendarView::currentSelection() |
4295 | { | 4304 | { |
4296 | return mViewManager->currentSelection(); | 4305 | return mViewManager->currentSelection(); |
4297 | } | 4306 | } |
4298 | void CalendarView::toggleAllDaySize() | 4307 | void CalendarView::toggleAllDaySize() |
4299 | { | 4308 | { |
4300 | /* | 4309 | /* |
4301 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4310 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4302 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4311 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4303 | else | 4312 | else |
4304 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4313 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4305 | */ | 4314 | */ |
4306 | viewManager()->agendaView()->toggleAllDay(); | 4315 | viewManager()->agendaView()->toggleAllDay(); |
4307 | } | 4316 | } |
4308 | void CalendarView::toggleExpand() | 4317 | void CalendarView::toggleExpand() |
4309 | { | 4318 | { |
4310 | // if ( mLeftFrame->isHidden() ) { | 4319 | // if ( mLeftFrame->isHidden() ) { |
4311 | // mLeftFrame->show(); | 4320 | // mLeftFrame->show(); |
4312 | // emit calendarViewExpanded( false ); | 4321 | // emit calendarViewExpanded( false ); |
4313 | // } else { | 4322 | // } else { |
4314 | // mLeftFrame->hide(); | 4323 | // mLeftFrame->hide(); |
4315 | // emit calendarViewExpanded( true ); | 4324 | // emit calendarViewExpanded( true ); |
4316 | // } | 4325 | // } |
4317 | //qDebug(" CalendarView::toggleExpand()"); | 4326 | //qDebug(" CalendarView::toggleExpand()"); |
4318 | globalFlagBlockAgenda = 1; | 4327 | globalFlagBlockAgenda = 1; |
4319 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4328 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4320 | globalFlagBlockAgenda = 5; | 4329 | globalFlagBlockAgenda = 5; |
4321 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4330 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4322 | //mViewManager->showView( 0, true ); | 4331 | //mViewManager->showView( 0, true ); |
4323 | } | 4332 | } |
4324 | 4333 | ||
4325 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4334 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4326 | { | 4335 | { |
4327 | setModified( modified ); | 4336 | setModified( modified ); |
4328 | } | 4337 | } |
4329 | 4338 | ||
4330 | Todo *CalendarView::selectedTodo() | 4339 | Todo *CalendarView::selectedTodo() |
4331 | { | 4340 | { |
4332 | Incidence *incidence = currentSelection(); | 4341 | Incidence *incidence = currentSelection(); |
4333 | if ( incidence && incidence->typeID() == todoID ) { | 4342 | if ( incidence && incidence->typeID() == todoID ) { |
4334 | return static_cast<Todo *>( incidence ); | 4343 | return static_cast<Todo *>( incidence ); |
4335 | } | 4344 | } |
4336 | 4345 | ||
4337 | incidence = mTodoList->selectedIncidences().first(); | 4346 | incidence = mTodoList->selectedIncidences().first(); |
4338 | if ( incidence && incidence->typeID() == todoID ) { | 4347 | if ( incidence && incidence->typeID() == todoID ) { |
4339 | return static_cast<Todo *>( incidence ); | 4348 | return static_cast<Todo *>( incidence ); |
4340 | } | 4349 | } |
4341 | 4350 | ||
4342 | return 0; | 4351 | return 0; |
4343 | } | 4352 | } |
4344 | 4353 | ||
4345 | void CalendarView::showIncidence() | 4354 | void CalendarView::showIncidence() |
4346 | { | 4355 | { |
4347 | mViewerCallerIsSearchDialog = false; | 4356 | mViewerCallerIsSearchDialog = false; |
4348 | Incidence *incidence = currentSelection(); | 4357 | Incidence *incidence = currentSelection(); |
4349 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4358 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4350 | if ( incidence ) { | 4359 | if ( incidence ) { |
4351 | ShowIncidenceVisitor v; | 4360 | ShowIncidenceVisitor v; |
4352 | v.act( incidence, this ); | 4361 | v.act( incidence, this ); |
4353 | } | 4362 | } |
4354 | } | 4363 | } |
4355 | void CalendarView::editIncidenceDescription() | 4364 | void CalendarView::editIncidenceDescription() |
4356 | { | 4365 | { |
4357 | mFlagEditDescription = true; | 4366 | mFlagEditDescription = true; |
4358 | editIncidence(); | 4367 | editIncidence(); |
4359 | mFlagEditDescription = false; | 4368 | mFlagEditDescription = false; |
4360 | } | 4369 | } |
4361 | void CalendarView::editIncidence() | 4370 | void CalendarView::editIncidence() |
4362 | { | 4371 | { |
4363 | // qDebug("editIncidence() "); | 4372 | // qDebug("editIncidence() "); |
4364 | Incidence *incidence = currentSelection(); | 4373 | Incidence *incidence = currentSelection(); |
4365 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4374 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4366 | if ( incidence ) { | 4375 | if ( incidence ) { |
4367 | EditIncidenceVisitor v; | 4376 | EditIncidenceVisitor v; |
4368 | v.act( incidence, this ); | 4377 | v.act( incidence, this ); |
4369 | } | 4378 | } |
4370 | } | 4379 | } |
4371 | 4380 | ||
4372 | void CalendarView::deleteIncidence() | 4381 | void CalendarView::deleteIncidence() |
4373 | { | 4382 | { |
4374 | Incidence *incidence = currentSelection(); | 4383 | Incidence *incidence = currentSelection(); |
4375 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4384 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4376 | if ( incidence ) { | 4385 | if ( incidence ) { |
4377 | deleteIncidence(incidence); | 4386 | deleteIncidence(incidence); |
4378 | } | 4387 | } |
4379 | } | 4388 | } |
4380 | void CalendarView::showIncidence(QString uid) | 4389 | void CalendarView::showIncidence(QString uid) |
4381 | { | 4390 | { |
4382 | Incidence *inc = mCalendar->incidence( uid ); | 4391 | Incidence *inc = mCalendar->incidence( uid ); |
4383 | if ( inc ) | 4392 | if ( inc ) |
4384 | showIncidence( inc ); | 4393 | showIncidence( inc ); |
4385 | } | 4394 | } |
4386 | void CalendarView::showIncidence(Incidence *incidence) | 4395 | void CalendarView::showIncidence(Incidence *incidence) |
4387 | { | 4396 | { |
4388 | mViewerCallerIsSearchDialog = false; | 4397 | mViewerCallerIsSearchDialog = false; |
4389 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4398 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4390 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4399 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4391 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4400 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4392 | mViewerCallerIsSearchDialog = true; | 4401 | mViewerCallerIsSearchDialog = true; |
4393 | } | 4402 | } |
4394 | } | 4403 | } |
4395 | if ( incidence ) { | 4404 | if ( incidence ) { |
4396 | ShowIncidenceVisitor v; | 4405 | ShowIncidenceVisitor v; |
4397 | v.act( incidence, this ); | 4406 | v.act( incidence, this ); |
4398 | } | 4407 | } |
4399 | } | 4408 | } |
4400 | 4409 | ||
4401 | void CalendarView::editIncidence(Incidence *incidence) | 4410 | void CalendarView::editIncidence(Incidence *incidence) |
4402 | { | 4411 | { |
4403 | if ( incidence ) { | 4412 | if ( incidence ) { |
4404 | 4413 | ||
4405 | EditIncidenceVisitor v; | 4414 | EditIncidenceVisitor v; |
4406 | v.act( incidence, this ); | 4415 | v.act( incidence, this ); |
4407 | 4416 | ||
4408 | } | 4417 | } |
4409 | } | 4418 | } |
4410 | 4419 | ||
4411 | void CalendarView::deleteIncidence(Incidence *incidence) | 4420 | void CalendarView::deleteIncidence(Incidence *incidence) |
4412 | { | 4421 | { |
4413 | //qDebug(" CalendarView::deleteIncidence "); | 4422 | //qDebug(" CalendarView::deleteIncidence "); |
4423 | if ( incidence == 0 ) { | ||
4424 | updateView(); | ||
4425 | emit updateSearchDialog(); | ||
4426 | return; | ||
4427 | } | ||
4414 | if ( incidence ) { | 4428 | if ( incidence ) { |
4415 | DeleteIncidenceVisitor v; | 4429 | DeleteIncidenceVisitor v; |
4416 | v.act( incidence, this ); | 4430 | v.act( incidence, this ); |
4417 | } | 4431 | } |
4418 | } | 4432 | } |
4419 | 4433 | ||
4420 | 4434 | ||
4421 | void CalendarView::lookForOutgoingMessages() | 4435 | void CalendarView::lookForOutgoingMessages() |
4422 | { | 4436 | { |
4423 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4437 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4424 | ogd->loadMessages(); | 4438 | ogd->loadMessages(); |
4425 | } | 4439 | } |
4426 | 4440 | ||
4427 | void CalendarView::lookForIncomingMessages() | 4441 | void CalendarView::lookForIncomingMessages() |
4428 | { | 4442 | { |
4429 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4443 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4430 | icd->retrieve(); | 4444 | icd->retrieve(); |
4431 | } | 4445 | } |
4432 | 4446 | ||
4433 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4447 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4434 | { | 4448 | { |
4435 | bool deleteTodo = true; | 4449 | bool deleteTodo = true; |
4436 | QPtrList<Incidence> subTodos; | 4450 | QPtrList<Incidence> subTodos; |
4437 | Incidence *aTodo; | 4451 | Incidence *aTodo; |
4438 | subTodos = t->relations(); | 4452 | subTodos = t->relations(); |
4439 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4453 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4440 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4454 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4441 | deleteTodo = false; | 4455 | deleteTodo = false; |
4442 | } | 4456 | } |
4443 | if ( deleteTodo ) { | 4457 | if ( deleteTodo ) { |
4444 | if ( t->isCompleted() && !t->doesRecur()) { | 4458 | if ( t->isCompleted() && !t->doesRecur()) { |
4445 | checkExternalId( t ); | 4459 | checkExternalId( t ); |
4446 | mCalendar->deleteTodo( t ); | 4460 | mCalendar->deleteTodo( t ); |
4447 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4461 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4448 | } | 4462 | } |
4449 | else | 4463 | else |
4450 | deleteTodo = false; | 4464 | deleteTodo = false; |
4451 | } | 4465 | } |
4452 | return deleteTodo; | 4466 | return deleteTodo; |
4453 | 4467 | ||
4454 | } | 4468 | } |
4455 | void CalendarView::purgeCompleted() | 4469 | void CalendarView::purgeCompleted() |
4456 | { | 4470 | { |
4457 | int result = KMessageBox::warningContinueCancel(this, | 4471 | int result = KMessageBox::warningContinueCancel(this, |
4458 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4472 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4459 | 4473 | ||
4460 | if (result == KMessageBox::Continue) { | 4474 | if (result == KMessageBox::Continue) { |
4461 | 4475 | ||
4462 | QPtrList<Todo> todoCal; | 4476 | QPtrList<Todo> todoCal; |
4463 | QPtrList<Todo> rootTodos; | 4477 | QPtrList<Todo> rootTodos; |
4464 | //QPtrList<Incidence> rel; | 4478 | //QPtrList<Incidence> rel; |
4465 | Todo *aTodo; | 4479 | Todo *aTodo; |
4466 | todoCal = calendar()->todos(); | 4480 | todoCal = calendar()->todos(); |
4467 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4481 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4468 | if ( !aTodo->relatedTo() ) | 4482 | if ( !aTodo->relatedTo() ) |
4469 | rootTodos.append( aTodo ); | 4483 | rootTodos.append( aTodo ); |
4470 | } | 4484 | } |
4471 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4485 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4472 | removeCompletedSubTodos( aTodo ); | 4486 | removeCompletedSubTodos( aTodo ); |
4473 | } | 4487 | } |
4474 | 4488 | ||
4475 | updateView(); | 4489 | updateView(); |
4476 | } | 4490 | } |
4477 | } | 4491 | } |
4478 | 4492 | ||
4479 | void CalendarView::slotCalendarChanged() | 4493 | void CalendarView::slotCalendarChanged() |
4480 | { | 4494 | { |
4481 | ; | 4495 | ; |
4482 | } | 4496 | } |
4483 | 4497 | ||
4484 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4498 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4485 | { | 4499 | { |
4486 | //qDebug(" alendarView::keyPressEvent "); | 4500 | //qDebug(" alendarView::keyPressEvent "); |
4487 | e->ignore(); | 4501 | e->ignore(); |
4488 | } | 4502 | } |
4489 | 4503 | ||
4490 | 4504 | ||
4491 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4505 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4492 | { | 4506 | { |
4493 | 4507 | ||
4494 | if ( manager != mSyncManager) | 4508 | if ( manager != mSyncManager) |
4495 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 4509 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
4496 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4510 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4497 | qDebug("KO: SyncKDE request detected!"); | 4511 | qDebug("KO: SyncKDE request detected!"); |
4498 | } | 4512 | } |
4499 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4513 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4500 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4514 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4501 | return syncCalendar( filename, mode ); | 4515 | return syncCalendar( filename, mode ); |
4502 | } | 4516 | } |
4503 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4517 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4504 | { | 4518 | { |
4505 | //mSyncManager = manager; | 4519 | //mSyncManager = manager; |
4506 | if ( manager != mSyncManager) | 4520 | if ( manager != mSyncManager) |
4507 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 4521 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
4508 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4522 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4509 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4523 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4510 | if ( resource == "sharp" ) | 4524 | if ( resource == "sharp" ) |
4511 | syncExternal( 0 ); | 4525 | syncExternal( 0 ); |
4512 | if ( resource == "phone" ) | 4526 | if ( resource == "phone" ) |
4513 | syncExternal( 1 ); | 4527 | syncExternal( 1 ); |
4514 | // pending setmodified | 4528 | // pending setmodified |
4515 | return true; | 4529 | return true; |
4516 | } | 4530 | } |
4517 | void CalendarView::setSyncManager(KSyncManager* manager) | 4531 | void CalendarView::setSyncManager(KSyncManager* manager) |
4518 | { | 4532 | { |
4519 | mSyncManager = manager; | 4533 | mSyncManager = manager; |
4520 | } | 4534 | } |
4521 | 4535 | ||
4522 | void CalendarView::removeSyncInfo( QString syncProfile) | 4536 | void CalendarView::removeSyncInfo( QString syncProfile) |
4523 | { | 4537 | { |
4524 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4538 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4525 | mCalendar->removeSyncInfo( syncProfile ); | 4539 | mCalendar->removeSyncInfo( syncProfile ); |
4526 | 4540 | ||
4527 | } | 4541 | } |
4528 | 4542 | ||
4529 | void CalendarView::undo_delete() | 4543 | void CalendarView::undo_delete() |
4530 | { | 4544 | { |
4531 | //qDebug("undo_delete() "); | 4545 | //qDebug("undo_delete() "); |
4532 | Incidence* undo = mCalendar->undoIncidence(); | 4546 | Incidence* undo = mCalendar->undoIncidence(); |
4533 | if ( !undo ) { | 4547 | if ( !undo ) { |
4534 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4548 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4535 | i18n("KO/Pi")); | 4549 | i18n("KO/Pi")); |
4536 | return; | 4550 | return; |
4537 | } | 4551 | } |
4538 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 4552 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
4539 | i18n("\nAre you sure you want\nto restore this?"), | 4553 | i18n("\nAre you sure you want\nto restore this?"), |
4540 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4554 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4541 | mCalendar->undoDeleteIncidence(); | 4555 | mCalendar->undoDeleteIncidence(); |
4542 | updateView(); | 4556 | updateView(); |
4543 | } | 4557 | } |
4544 | } | 4558 | } |
4545 | 4559 | ||
4546 | void CalendarView::slotViewerClosed() | 4560 | void CalendarView::slotViewerClosed() |
4547 | { | 4561 | { |
4548 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4562 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4549 | } | 4563 | } |
4550 | 4564 | ||
4551 | void CalendarView::resetFocus() | 4565 | void CalendarView::resetFocus() |
4552 | { | 4566 | { |
4553 | if ( mViewerCallerIsSearchDialog ) { | 4567 | if ( mViewerCallerIsSearchDialog ) { |
4554 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4568 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4555 | mDialogManager->getSearchDialog()->raise(); | 4569 | mDialogManager->getSearchDialog()->raise(); |
4556 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4570 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4557 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4571 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4558 | } else | 4572 | } else |
4559 | mViewerCallerIsSearchDialog = false; | 4573 | mViewerCallerIsSearchDialog = false; |
4560 | } | 4574 | } |
4561 | if ( !mViewerCallerIsSearchDialog ) { | 4575 | if ( !mViewerCallerIsSearchDialog ) { |
4562 | //mViewManager->currentView()->setFocus(); | 4576 | //mViewManager->currentView()->setFocus(); |
4563 | //qDebug("sssssssssssssssset focus "); | 4577 | //qDebug("sssssssssssssssset focus "); |
4564 | topLevelWidget()->raise(); | 4578 | topLevelWidget()->raise(); |
4565 | setActiveWindow(); | 4579 | setActiveWindow(); |
4566 | //setFocus(); | 4580 | //setFocus(); |
4567 | } | 4581 | } |
4568 | mViewerCallerIsSearchDialog = false; | 4582 | mViewerCallerIsSearchDialog = false; |
4569 | } | 4583 | } |
4570 | 4584 | ||
4571 | void CalendarView::showNextAlarms() | 4585 | void CalendarView::showNextAlarms() |
4572 | { | 4586 | { |
4573 | QString message; | 4587 | QString message; |
4574 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4588 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4575 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4589 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4576 | QString sum = mCalendar->nextSummary(); | 4590 | QString sum = mCalendar->nextSummary(); |
4577 | QDateTime nextA = mNextAlarmDateTime; | 4591 | QDateTime nextA = mNextAlarmDateTime; |
4578 | QDateTime cur = QDateTime::currentDateTime(); | 4592 | QDateTime cur = QDateTime::currentDateTime(); |
4579 | int secs = cur.secsTo( nextA ); | 4593 | int secs = cur.secsTo( nextA ); |
4580 | int min = secs /60; | 4594 | int min = secs /60; |
4581 | int hours = min /60; | 4595 | int hours = min /60; |
4582 | min = min % 60; | 4596 | min = min % 60; |
4583 | int days = hours /24; | 4597 | int days = hours /24; |
4584 | hours = hours % 24; | 4598 | hours = hours % 24; |
4585 | 4599 | ||
4586 | //message = i18n("The next alarm is in:\n"); | 4600 | //message = i18n("The next alarm is in:\n"); |
4587 | if ( days > 1 ) | 4601 | if ( days > 1 ) |
4588 | message += i18n("%1 days\n").arg( days ); | 4602 | message += i18n("%1 days\n").arg( days ); |
4589 | else if ( days == 1 ) | 4603 | else if ( days == 1 ) |
4590 | message += i18n("1 day\n"); | 4604 | message += i18n("1 day\n"); |
4591 | if ( hours > 1 ) | 4605 | if ( hours > 1 ) |
4592 | message += i18n("%1 hours\n").arg( hours ); | 4606 | message += i18n("%1 hours\n").arg( hours ); |
4593 | else if ( hours == 1 ) | 4607 | else if ( hours == 1 ) |
4594 | message += i18n("1 hour\n"); | 4608 | message += i18n("1 hour\n"); |
4595 | if ( min > 1 ) | 4609 | if ( min > 1 ) |
4596 | message += i18n("%1 minutes\n").arg( min ); | 4610 | message += i18n("%1 minutes\n").arg( min ); |
4597 | else if ( min == 1 ) | 4611 | else if ( min == 1 ) |
4598 | message += i18n("1 minute\n"); | 4612 | message += i18n("1 minute\n"); |
4599 | if ( message.isEmpty() ) | 4613 | if ( message.isEmpty() ) |
4600 | message = i18n("The next alarm is in\nless than one minute!"); | 4614 | message = i18n("The next alarm is in\nless than one minute!"); |
4601 | else | 4615 | else |
4602 | message = i18n("The next alarm is in:\n") + message; | 4616 | message = i18n("The next alarm is in:\n") + message; |
4603 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4617 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4604 | } else { | 4618 | } else { |
4605 | message = i18n("There is no next alarm."); | 4619 | message = i18n("There is no next alarm."); |
4606 | 4620 | ||
4607 | } | 4621 | } |
4608 | #ifdef DESKTOP_VERSION | 4622 | #ifdef DESKTOP_VERSION |
4609 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4623 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4610 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4624 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4611 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4625 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4612 | } | 4626 | } |
4613 | 4627 | ||
4614 | #endif | 4628 | #endif |
4615 | KMessageBox::information( this, message); | 4629 | KMessageBox::information( this, message); |
4616 | } | 4630 | } |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 25e599d..5690bdb 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -100,1346 +100,1348 @@ bool ListItemVisitor::visit(Event *e) | |||
100 | bool ok = false; | 100 | bool ok = false; |
101 | QString start, end; | 101 | QString start, end; |
102 | QDate ds, de; | 102 | QDate ds, de; |
103 | if ( e->doesRecur() ) { | 103 | if ( e->doesRecur() ) { |
104 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 104 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
105 | if ( ok ) { | 105 | if ( ok ) { |
106 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 106 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
107 | start = KGlobal::locale()->formatDate(ds,true); | 107 | start = KGlobal::locale()->formatDate(ds,true); |
108 | de = ds.addDays( days); | 108 | de = ds.addDays( days); |
109 | end = KGlobal::locale()->formatDate(de,true); | 109 | end = KGlobal::locale()->formatDate(de,true); |
110 | } | 110 | } |
111 | 111 | ||
112 | } | 112 | } |
113 | if ( ! ok ) { | 113 | if ( ! ok ) { |
114 | start =e->dtStartDateStr(); | 114 | start =e->dtStartDateStr(); |
115 | end = e->dtEndDateStr(); | 115 | end = e->dtEndDateStr(); |
116 | ds = e->dtStart().date(); | 116 | ds = e->dtStart().date(); |
117 | de = e->dtEnd().date(); | 117 | de = e->dtEnd().date(); |
118 | } | 118 | } |
119 | mItem->setText(0,e->summary()); | 119 | mItem->setText(0,e->summary()); |
120 | mItem->setText(1,start); | 120 | mItem->setText(1,start); |
121 | if ( e->doesFloat() ) | 121 | if ( e->doesFloat() ) |
122 | mItem->setText(2,"---"); | 122 | mItem->setText(2,"---"); |
123 | else | 123 | else |
124 | mItem->setText(2,e->dtStartTimeStr()); | 124 | mItem->setText(2,e->dtStartTimeStr()); |
125 | mItem->setText(3,end); | 125 | mItem->setText(3,end); |
126 | if ( e->doesFloat() ) | 126 | if ( e->doesFloat() ) |
127 | mItem->setText(4,"---"); | 127 | mItem->setText(4,"---"); |
128 | else | 128 | else |
129 | mItem->setText(4,e->dtEndTimeStr()); | 129 | mItem->setText(4,e->dtEndTimeStr()); |
130 | if ( e->isAlarmEnabled() ) { | 130 | if ( e->isAlarmEnabled() ) { |
131 | mItem->setText(5,e->alarms().first()->offsetText() ); | 131 | mItem->setText(5,e->alarms().first()->offsetText() ); |
132 | } else { | 132 | } else { |
133 | mItem->setText(5, i18n("No")); | 133 | mItem->setText(5, i18n("No")); |
134 | } | 134 | } |
135 | mItem->setText(6, e->recurrence()->recurrenceText()); | 135 | mItem->setText(6, e->recurrence()->recurrenceText()); |
136 | if( ! e->doesRecur() ) | 136 | if( ! e->doesRecur() ) |
137 | mItem->setSortKey( 6, "-" ); | 137 | mItem->setSortKey( 6, "-" ); |
138 | mItem->setText(7,"---"); | 138 | mItem->setText(7,"---"); |
139 | mItem->setText(8,"---"); | 139 | mItem->setText(8,"---"); |
140 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 140 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
141 | mItem->setText(10,e->categoriesStr()); | 141 | mItem->setText(10,e->categoriesStr()); |
142 | mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); | 142 | mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); |
143 | mItem->setText(12, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); | 143 | mItem->setText(12, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); |
144 | 144 | ||
145 | QString key; | 145 | QString key; |
146 | QDate d = e->lastModified().date(); | 146 | QDate d = e->lastModified().date(); |
147 | QTime t = e->lastModified().time(); | 147 | QTime t = e->lastModified().time(); |
148 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); | 148 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); |
149 | mItem->setSortKey(12,key); | 149 | mItem->setSortKey(12,key); |
150 | t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 150 | t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
151 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); | 151 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); |
152 | mItem->setSortKey(1,key); | 152 | mItem->setSortKey(1,key); |
153 | 153 | ||
154 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 154 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
155 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); | 155 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); |
156 | mItem->setSortKey(3,key); | 156 | mItem->setSortKey(3,key); |
157 | return true; | 157 | return true; |
158 | } | 158 | } |
159 | 159 | ||
160 | bool ListItemVisitor::visit(Todo *t) | 160 | bool ListItemVisitor::visit(Todo *t) |
161 | { | 161 | { |
162 | mItem->setText(0,t->summary()); | 162 | mItem->setText(0,t->summary()); |
163 | if ( t->isCompleted() ) { | 163 | if ( t->isCompleted() ) { |
164 | mItem->setSortKey(0,"99"+ t->summary().left(10)); | 164 | mItem->setSortKey(0,"99"+ t->summary().left(10)); |
165 | } else | 165 | } else |
166 | mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10)); | 166 | mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10)); |
167 | mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); | 167 | mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); |
168 | if (t->hasStartDate()) { | 168 | if (t->hasStartDate()) { |
169 | mItem->setText(1,t->dtStartDateStr()); | 169 | mItem->setText(1,t->dtStartDateStr()); |
170 | if (t->doesFloat()) { | 170 | if (t->doesFloat()) { |
171 | mItem->setText(2,"---"); | 171 | mItem->setText(2,"---"); |
172 | } else { | 172 | } else { |
173 | mItem->setText(2,t->dtStartTimeStr()); | 173 | mItem->setText(2,t->dtStartTimeStr()); |
174 | } | 174 | } |
175 | } else { | 175 | } else { |
176 | mItem->setText(1,"---"); | 176 | mItem->setText(1,"---"); |
177 | mItem->setText(2,"---"); | 177 | mItem->setText(2,"---"); |
178 | } | 178 | } |
179 | mItem->setText(3,"---"); | 179 | mItem->setText(3,"---"); |
180 | mItem->setText(4,"---"); | 180 | mItem->setText(4,"---"); |
181 | if ( t->isAlarmEnabled() ) { | 181 | if ( t->isAlarmEnabled() ) { |
182 | mItem->setText(5,t->alarms().first()->offsetText() ); | 182 | mItem->setText(5,t->alarms().first()->offsetText() ); |
183 | } else { | 183 | } else { |
184 | mItem->setText(5, i18n("No")); | 184 | mItem->setText(5, i18n("No")); |
185 | } | 185 | } |
186 | mItem->setText(6, t->recurrence()->recurrenceText()); | 186 | mItem->setText(6, t->recurrence()->recurrenceText()); |
187 | if( ! t->doesRecur() ) | 187 | if( ! t->doesRecur() ) |
188 | mItem->setSortKey( 6, "-" ); | 188 | mItem->setSortKey( 6, "-" ); |
189 | if (t->hasDueDate()) { | 189 | if (t->hasDueDate()) { |
190 | mItem->setText(7,t->dtDueDateStr()); | 190 | mItem->setText(7,t->dtDueDateStr()); |
191 | if (t->doesFloat()) { | 191 | if (t->doesFloat()) { |
192 | mItem->setText(8,"---"); | 192 | mItem->setText(8,"---"); |
193 | } else { | 193 | } else { |
194 | mItem->setText(8,t->dtDueTimeStr()); | 194 | mItem->setText(8,t->dtDueTimeStr()); |
195 | } | 195 | } |
196 | } else { | 196 | } else { |
197 | mItem->setText(7,"---"); | 197 | mItem->setText(7,"---"); |
198 | mItem->setText(8,"---"); | 198 | mItem->setText(8,"---"); |
199 | } | 199 | } |
200 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 200 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
201 | mItem->setText(10,t->categoriesStr()); | 201 | mItem->setText(10,t->categoriesStr()); |
202 | mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); | 202 | mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); |
203 | mItem->setText(12, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); | 203 | mItem->setText(12, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); |
204 | QString key; | 204 | QString key; |
205 | QDate d = t->lastModified().date(); | 205 | QDate d = t->lastModified().date(); |
206 | QTime tm = t->lastModified().time(); | 206 | QTime tm = t->lastModified().time(); |
207 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); | 207 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); |
208 | mItem->setSortKey(12,key); | 208 | mItem->setSortKey(12,key); |
209 | if (t->hasDueDate()) { | 209 | if (t->hasDueDate()) { |
210 | d = t->dtDue().date(); | 210 | d = t->dtDue().date(); |
211 | tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 211 | tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
212 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 212 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
213 | mItem->setSortKey(7,key); | 213 | mItem->setSortKey(7,key); |
214 | } | 214 | } |
215 | if ( t->hasStartDate() ) { | 215 | if ( t->hasStartDate() ) { |
216 | d = t->dtStart().date(); | 216 | d = t->dtStart().date(); |
217 | tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 217 | tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
218 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 218 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
219 | mItem->setSortKey(1,key); | 219 | mItem->setSortKey(1,key); |
220 | } | 220 | } |
221 | return true; | 221 | return true; |
222 | } | 222 | } |
223 | 223 | ||
224 | bool ListItemVisitor::visit(Journal * j) | 224 | bool ListItemVisitor::visit(Journal * j) |
225 | { | 225 | { |
226 | 226 | ||
227 | QString des; | 227 | QString des; |
228 | if ( !j->summary().isEmpty() ) { | 228 | if ( !j->summary().isEmpty() ) { |
229 | des = j->summary(); | 229 | des = j->summary(); |
230 | } else { | 230 | } else { |
231 | des = j->description().left(30); | 231 | des = j->description().left(30); |
232 | des = des.simplifyWhiteSpace (); | 232 | des = des.simplifyWhiteSpace (); |
233 | des.replace (QRegExp ("\\n"),"" ); | 233 | des.replace (QRegExp ("\\n"),"" ); |
234 | des.replace (QRegExp ("\\r"),"" ); | 234 | des.replace (QRegExp ("\\r"),"" ); |
235 | } | 235 | } |
236 | mItem->setText(0,i18n("Journal: ")+des.left(25)); | 236 | mItem->setText(0,i18n("Journal: ")+des.left(25)); |
237 | mItem->setText(1,j->dtStartDateStr()); | 237 | mItem->setText(1,j->dtStartDateStr()); |
238 | mItem->setText(2,"---"); | 238 | mItem->setText(2,"---"); |
239 | mItem->setText(3,"---"); | 239 | mItem->setText(3,"---"); |
240 | mItem->setText(4,"---"); | 240 | mItem->setText(4,"---"); |
241 | mItem->setText(5,"---"); | 241 | mItem->setText(5,"---"); |
242 | mItem->setText(6,"---"); | 242 | mItem->setText(6,"---"); |
243 | mItem->setText(7,j->dtStartDateStr()); | 243 | mItem->setText(7,j->dtStartDateStr()); |
244 | mItem->setText(8,"---"); | 244 | mItem->setText(8,"---"); |
245 | mItem->setText(9,"---"); | 245 | mItem->setText(9,"---"); |
246 | mItem->setText(10,j->categoriesStr()); | 246 | mItem->setText(10,j->categoriesStr()); |
247 | mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); | 247 | mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); |
248 | mItem->setText(12, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); | 248 | mItem->setText(12, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); |
249 | 249 | ||
250 | QString key; | 250 | QString key; |
251 | QDate d = j->lastModified().date(); | 251 | QDate d = j->lastModified().date(); |
252 | QTime tm = j->lastModified().time(); | 252 | QTime tm = j->lastModified().time(); |
253 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); | 253 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); |
254 | mItem->setSortKey(12,key); | 254 | mItem->setSortKey(12,key); |
255 | d = j->dtStart().date(); | 255 | d = j->dtStart().date(); |
256 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 256 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
257 | mItem->setSortKey(1,key); | 257 | mItem->setSortKey(1,key); |
258 | mItem->setSortKey(7,key); | 258 | mItem->setSortKey(7,key); |
259 | 259 | ||
260 | return true; | 260 | return true; |
261 | } | 261 | } |
262 | 262 | ||
263 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 263 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
264 | const char *name) | 264 | const char *name) |
265 | : KOEventView(calendar, parent, name) | 265 | : KOEventView(calendar, parent, name) |
266 | { | 266 | { |
267 | 267 | ||
268 | mActiveItem = 0; | 268 | mActiveItem = 0; |
269 | mForceShowCompletedTodos = false; | 269 | mForceShowCompletedTodos = false; |
270 | mListView = new KOListViewListView(this); | 270 | mListView = new KOListViewListView(this); |
271 | mListView->addColumn(i18n("Summary")); | 271 | mListView->addColumn(i18n("Summary")); |
272 | mListView->addColumn(i18n("Start Date")); | 272 | mListView->addColumn(i18n("Start Date")); |
273 | mListView->addColumn(i18n("Start Time")); | 273 | mListView->addColumn(i18n("Start Time")); |
274 | mListView->addColumn(i18n("End Date")); | 274 | mListView->addColumn(i18n("End Date")); |
275 | mListView->addColumn(i18n("End Time")); | 275 | mListView->addColumn(i18n("End Time")); |
276 | mListView->addColumn(i18n("Alarm")); // alarm set? | 276 | mListView->addColumn(i18n("Alarm")); // alarm set? |
277 | mListView->addColumn(i18n("Recurs")); // recurs? | 277 | mListView->addColumn(i18n("Recurs")); // recurs? |
278 | mListView->addColumn(i18n("Due Date")); | 278 | mListView->addColumn(i18n("Due Date")); |
279 | mListView->addColumn(i18n("Due Time")); | 279 | mListView->addColumn(i18n("Due Time")); |
280 | mListView->addColumn(i18n("Cancelled")); | 280 | mListView->addColumn(i18n("Cancelled")); |
281 | mListView->addColumn(i18n("Categories")); | 281 | mListView->addColumn(i18n("Categories")); |
282 | mListView->addColumn(i18n("Calendar")); | 282 | mListView->addColumn(i18n("Calendar")); |
283 | mListView->addColumn(i18n("Last Modified")); | 283 | mListView->addColumn(i18n("Last Modified")); |
284 | 284 | ||
285 | mListView->setColumnAlignment(0,AlignLeft); | 285 | mListView->setColumnAlignment(0,AlignLeft); |
286 | mListView->setColumnAlignment(1,AlignLeft); | 286 | mListView->setColumnAlignment(1,AlignLeft); |
287 | mListView->setColumnAlignment(2,AlignHCenter); | 287 | mListView->setColumnAlignment(2,AlignHCenter); |
288 | mListView->setColumnAlignment(3,AlignLeft); | 288 | mListView->setColumnAlignment(3,AlignLeft); |
289 | mListView->setColumnAlignment(4,AlignHCenter); | 289 | mListView->setColumnAlignment(4,AlignHCenter); |
290 | mListView->setColumnAlignment(5,AlignLeft); | 290 | mListView->setColumnAlignment(5,AlignLeft); |
291 | mListView->setColumnAlignment(6,AlignLeft); | 291 | mListView->setColumnAlignment(6,AlignLeft); |
292 | mListView->setColumnAlignment(7,AlignLeft); | 292 | mListView->setColumnAlignment(7,AlignLeft); |
293 | mListView->setColumnAlignment(8,AlignLeft); | 293 | mListView->setColumnAlignment(8,AlignLeft); |
294 | mListView->setColumnAlignment(9,AlignLeft); | 294 | mListView->setColumnAlignment(9,AlignLeft); |
295 | mListView->setColumnAlignment(10,AlignLeft); | 295 | mListView->setColumnAlignment(10,AlignLeft); |
296 | mListView->setColumnAlignment(11,AlignLeft); | 296 | mListView->setColumnAlignment(11,AlignLeft); |
297 | mListView->setColumnAlignment(12,AlignLeft); | 297 | mListView->setColumnAlignment(12,AlignLeft); |
298 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); | 298 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); |
299 | 299 | ||
300 | int iii = 0; | 300 | int iii = 0; |
301 | for ( iii = 0; iii< 13 ; ++iii ) | 301 | for ( iii = 0; iii< 13 ; ++iii ) |
302 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 302 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
303 | 303 | ||
304 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 304 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
305 | layoutTop->addWidget(mListView); | 305 | layoutTop->addWidget(mListView); |
306 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 306 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
307 | mPopupMenu = eventPopup(); | 307 | mPopupMenu = eventPopup(); |
308 | QPopupMenu* selPopup = new QPopupMenu ( this ); | 308 | QPopupMenu* selPopup = new QPopupMenu ( this ); |
309 | mPopupMenu->insertSeparator(); | 309 | mPopupMenu->insertSeparator(); |
310 | 310 | ||
311 | selPopup->insertItem(i18n("All"),this, | 311 | selPopup->insertItem(i18n("All"),this, |
312 | SLOT(allSelection())); | 312 | SLOT(allSelection())); |
313 | selPopup->insertItem(i18n("None"),this, | 313 | selPopup->insertItem(i18n("None"),this, |
314 | SLOT(clearSelection())); | 314 | SLOT(clearSelection())); |
315 | selPopup->insertItem(i18n("Delete selected..."),this, | 315 | selPopup->insertItem(i18n("Delete selected..."),this, |
316 | SLOT(deleteAll())); | 316 | SLOT(deleteAll())); |
317 | mPopupMenu->insertItem(i18n("Selection"), selPopup ); | 317 | mPopupMenu->insertItem(i18n("Selection"), selPopup ); |
318 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 318 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
319 | i18n("Hide all selected"),this, | 319 | i18n("Hide all selected"),this, |
320 | SLOT(hideAll()),true); | 320 | SLOT(hideAll()),true); |
321 | 321 | ||
322 | selPopup->insertSeparator(); | 322 | selPopup->insertSeparator(); |
323 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 323 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
324 | selPopup->insertItem( i18n("Export"), exportPO ); | 324 | selPopup->insertItem( i18n("Export"), exportPO ); |
325 | #ifdef DESKTOP_VERSION | 325 | #ifdef DESKTOP_VERSION |
326 | mPopupMenu->insertSeparator(); | 326 | mPopupMenu->insertSeparator(); |
327 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 327 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
328 | i18n("Print complete list..."),this, | 328 | i18n("Print complete list..."),this, |
329 | SLOT(printList()),true); | 329 | SLOT(printList()),true); |
330 | #endif | 330 | #endif |
331 | mCalPopup = new QPopupMenu ( this ); | 331 | mCalPopup = new QPopupMenu ( this ); |
332 | selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); | 332 | selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); |
333 | 333 | ||
334 | selPopup->insertItem(i18n("Set categories")+"...",this, | 334 | selPopup->insertItem(i18n("Set categories")+"...",this, |
335 | SLOT(setCat()) ); | 335 | SLOT(setCat()) ); |
336 | selPopup->insertItem( i18n("Set alarm..."),this, | 336 | selPopup->insertItem( i18n("Set alarm..."),this, |
337 | SLOT(setAlarm())); | 337 | SLOT(setAlarm())); |
338 | #if 0 | 338 | #if 0 |
339 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 339 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
340 | i18n("Set categories")+"...",this, | 340 | i18n("Set categories")+"...",this, |
341 | SLOT(setCat()),true); | 341 | SLOT(setCat()),true); |
342 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 342 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
343 | i18n("Set alarm..."),this, | 343 | i18n("Set alarm..."),this, |
344 | SLOT(setAlarm()),true); | 344 | SLOT(setAlarm()),true); |
345 | #endif | 345 | #endif |
346 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, | 346 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, |
347 | SLOT( populateCalPopup() )); | 347 | SLOT( populateCalPopup() )); |
348 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, | 348 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, |
349 | SLOT( setCalendar( int ) )); | 349 | SLOT( setCalendar( int ) )); |
350 | QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, | 350 | QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, |
351 | SLOT( catChanged( Incidence * ) )); | 351 | SLOT( catChanged( Incidence * ) )); |
352 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 352 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
353 | SLOT(saveToFile())); | 353 | SLOT(saveToFile())); |
354 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 354 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
355 | SLOT(saveToFileVCS())); | 355 | SLOT(saveToFileVCS())); |
356 | exportPO->insertItem( i18n("Journal/Details..."),this, | 356 | exportPO->insertItem( i18n("Journal/Details..."),this, |
357 | SLOT(saveDescriptionToFile())); | 357 | SLOT(saveDescriptionToFile())); |
358 | // mPopupMenu->insertSeparator(); | 358 | // mPopupMenu->insertSeparator(); |
359 | // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 359 | // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
360 | // i18n("Add Categ. to selected..."),this, | 360 | // i18n("Add Categ. to selected..."),this, |
361 | // SLOT(addCat()),true); | 361 | // SLOT(addCat()),true); |
362 | //mPopupMenu->insertSeparator(); | 362 | //mPopupMenu->insertSeparator(); |
363 | #ifndef DESKTOP_VERSION | 363 | #ifndef DESKTOP_VERSION |
364 | selPopup->insertSeparator(); | 364 | selPopup->insertSeparator(); |
365 | selPopup->insertItem( i18n("Beam via IR..."),this, | 365 | selPopup->insertItem( i18n("Beam via IR..."),this, |
366 | SLOT(beamSelected())); | 366 | SLOT(beamSelected())); |
367 | #if 0 | 367 | #if 0 |
368 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 368 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
369 | i18n("Beam via IR"),this, | 369 | i18n("Beam via IR"),this, |
370 | SLOT(beamSelected()),true); | 370 | SLOT(beamSelected()),true); |
371 | #endif | 371 | #endif |
372 | #endif | 372 | #endif |
373 | /* | 373 | /* |
374 | mPopupMenu = new QPopupMenu; | 374 | mPopupMenu = new QPopupMenu; |
375 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 375 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
376 | SLOT (editEvent())); | 376 | SLOT (editEvent())); |
377 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 377 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
378 | SLOT (deleteEvent())); | 378 | SLOT (deleteEvent())); |
379 | mPopupMenu->insertSeparator(); | 379 | mPopupMenu->insertSeparator(); |
380 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 380 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
381 | SLOT(showDates())); | 381 | SLOT(showDates())); |
382 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 382 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
383 | SLOT(hideDates())); | 383 | SLOT(hideDates())); |
384 | */ | 384 | */ |
385 | QObject::connect(mListView,SIGNAL( newEvent()), | 385 | QObject::connect(mListView,SIGNAL( newEvent()), |
386 | this,SIGNAL(signalNewEvent())); | 386 | this,SIGNAL(signalNewEvent())); |
387 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 387 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
388 | this,SLOT(defaultItemAction(QListViewItem *))); | 388 | this,SLOT(defaultItemAction(QListViewItem *))); |
389 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, | 389 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, |
390 | const QPoint &, int )), | 390 | const QPoint &, int )), |
391 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 391 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
392 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 392 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
393 | SLOT(processSelectionChange(QListViewItem *))); | 393 | SLOT(processSelectionChange(QListViewItem *))); |
394 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 394 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
395 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 395 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
396 | 396 | ||
397 | readSettings(KOGlobals::config(),"KOListView Layout"); | 397 | readSettings(KOGlobals::config(),"KOListView Layout"); |
398 | } | 398 | } |
399 | 399 | ||
400 | KOListView::~KOListView() | 400 | KOListView::~KOListView() |
401 | { | 401 | { |
402 | delete mPopupMenu; | 402 | delete mPopupMenu; |
403 | #if QT_VERSION >= 0x030000 | 403 | #if QT_VERSION >= 0x030000 |
404 | 404 | ||
405 | #else | 405 | #else |
406 | delete mKOListViewWhatsThis; | 406 | delete mKOListViewWhatsThis; |
407 | #endif | 407 | #endif |
408 | } | 408 | } |
409 | 409 | ||
410 | void KOListView::catChanged( Incidence* inc) | 410 | void KOListView::catChanged( Incidence* inc) |
411 | { | 411 | { |
412 | KOListViewItem* item = getItemForEvent(inc); | 412 | KOListViewItem* item = getItemForEvent(inc); |
413 | if (item) { | 413 | if (item) { |
414 | ListItemVisitor v(item, mStartDate ); | 414 | ListItemVisitor v(item, mStartDate ); |
415 | inc->accept(v); | 415 | inc->accept(v); |
416 | } | 416 | } |
417 | } | 417 | } |
418 | QString KOListView::getWhatsThisText(QPoint p) | 418 | QString KOListView::getWhatsThisText(QPoint p) |
419 | { | 419 | { |
420 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 420 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
421 | if ( item ) | 421 | if ( item ) |
422 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 422 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
423 | KOPrefs::instance()->mWTshowDetails, | 423 | KOPrefs::instance()->mWTshowDetails, |
424 | KOPrefs::instance()->mWTshowCreated, | 424 | KOPrefs::instance()->mWTshowCreated, |
425 | KOPrefs::instance()->mWTshowChanged); | 425 | KOPrefs::instance()->mWTshowChanged); |
426 | return i18n("That is the list view" ); | 426 | return i18n("That is the list view" ); |
427 | 427 | ||
428 | } | 428 | } |
429 | 429 | ||
430 | void KOListView::setCalendar( int c ) | 430 | void KOListView::setCalendar( int c ) |
431 | { | 431 | { |
432 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 432 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
433 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), | 433 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), |
434 | i18n("Continue"), i18n("Cancel"), 0, | 434 | i18n("Continue"), i18n("Cancel"), 0, |
435 | 0, 1 ); | 435 | 0, 1 ); |
436 | if ( result != 0 ) { | 436 | if ( result != 0 ) { |
437 | return; | 437 | return; |
438 | } | 438 | } |
439 | 439 | ||
440 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 440 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
441 | int icount = delSel.count(); | 441 | int icount = delSel.count(); |
442 | if ( icount ) { | 442 | if ( icount ) { |
443 | Incidence *incidence = delSel.first(); | 443 | Incidence *incidence = delSel.first(); |
444 | while ( incidence ) { | 444 | while ( incidence ) { |
445 | incidence->setCalID( c ); | 445 | incidence->setCalID( c ); |
446 | KOListViewItem * item = getItemForEvent( incidence ); | 446 | KOListViewItem * item = getItemForEvent( incidence ); |
447 | if ( item ) { | 447 | if ( item ) { |
448 | ListItemVisitor v(item, mStartDate ); | 448 | ListItemVisitor v(item, mStartDate ); |
449 | incidence->accept(v); | 449 | incidence->accept(v); |
450 | } | 450 | } |
451 | incidence = delSel.next(); | 451 | incidence = delSel.next(); |
452 | } | 452 | } |
453 | } | 453 | } |
454 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 454 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
455 | KopiCalendarFile * cal = calendars.first(); | 455 | KopiCalendarFile * cal = calendars.first(); |
456 | while ( cal ) { | 456 | while ( cal ) { |
457 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 457 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
458 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 458 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
459 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 459 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
460 | if ( cal->isStandard ) | 460 | if ( cal->isStandard ) |
461 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 461 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
462 | cal = calendars.next(); | 462 | cal = calendars.next(); |
463 | } | 463 | } |
464 | mCalendar->setSyncEventsReadOnly(); | 464 | mCalendar->setSyncEventsReadOnly(); |
465 | mCalendar->reInitAlarmSettings(); | 465 | mCalendar->reInitAlarmSettings(); |
466 | 466 | ||
467 | } | 467 | } |
468 | void KOListView::populateCalPopup() | 468 | void KOListView::populateCalPopup() |
469 | { | 469 | { |
470 | mCalPopup->clear(); | 470 | mCalPopup->clear(); |
471 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 471 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
472 | while ( kkf ) { | 472 | while ( kkf ) { |
473 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); | 473 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); |
474 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | 474 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) |
475 | mCalPopup->setItemEnabled( index, false ); | 475 | mCalPopup->setItemEnabled( index, false ); |
476 | kkf = KOPrefs::instance()->mCalendars.next(); | 476 | kkf = KOPrefs::instance()->mCalendars.next(); |
477 | } | 477 | } |
478 | } | 478 | } |
479 | void KOListView::updateList() | 479 | void KOListView::updateList() |
480 | { | 480 | { |
481 | // qDebug(" KOListView::updateList() "); | 481 | // qDebug(" KOListView::updateList() "); |
482 | 482 | ||
483 | } | 483 | } |
484 | 484 | ||
485 | void KOListView::clearList() | 485 | void KOListView::clearList() |
486 | { | 486 | { |
487 | clear (); | 487 | clear (); |
488 | } | 488 | } |
489 | 489 | ||
490 | void KOListView::setCat() | 490 | void KOListView::setCat() |
491 | { | 491 | { |
492 | 492 | ||
493 | bool set = true; | 493 | bool set = true; |
494 | int result = KMessageBox::warningYesNoCancel(this, | 494 | int result = KMessageBox::warningYesNoCancel(this, |
495 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), | 495 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), |
496 | i18n("Set categories"), | 496 | i18n("Set categories"), |
497 | i18n("Add"), | 497 | i18n("Add"), |
498 | i18n("Reset")); | 498 | i18n("Reset")); |
499 | if (result == KMessageBox::Cancel) return; | 499 | if (result == KMessageBox::Cancel) return; |
500 | if (result == KMessageBox::Yes) set = false; | 500 | if (result == KMessageBox::Yes) set = false; |
501 | setCategories( set ); | 501 | setCategories( set ); |
502 | } | 502 | } |
503 | 503 | ||
504 | void KOListView::setAlarm() | 504 | void KOListView::setAlarm() |
505 | { | 505 | { |
506 | KOAlarmPrefs kap( this); | 506 | KOAlarmPrefs kap( this); |
507 | if ( !kap.exec() ) | 507 | if ( !kap.exec() ) |
508 | return; | 508 | return; |
509 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos | 509 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos |
510 | Incidence* inc = delSel.first(); | 510 | Incidence* inc = delSel.first(); |
511 | int count = 0; | 511 | int count = 0; |
512 | while ( inc ) { | 512 | while ( inc ) { |
513 | ++count; | 513 | ++count; |
514 | if (kap.mAlarmButton->isChecked()) { | 514 | if (kap.mAlarmButton->isChecked()) { |
515 | if (inc->alarms().count() == 0) | 515 | if (inc->alarms().count() == 0) |
516 | inc->newAlarm(); | 516 | inc->newAlarm(); |
517 | QPtrList<Alarm> alarms = inc->alarms(); | 517 | QPtrList<Alarm> alarms = inc->alarms(); |
518 | Alarm *alarm; | 518 | Alarm *alarm; |
519 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 519 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
520 | alarm->setEnabled(true); | 520 | alarm->setEnabled(true); |
521 | int j = kap.mAlarmTimeEdit->value()* -60; | 521 | int j = kap.mAlarmTimeEdit->value()* -60; |
522 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 522 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
523 | j = j * 60; | 523 | j = j * 60; |
524 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 524 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
525 | j = j * (60 * 24); | 525 | j = j * (60 * 24); |
526 | alarm->setStartOffset( j ); | 526 | alarm->setStartOffset( j ); |
527 | 527 | ||
528 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | 528 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
529 | alarm->setProcedureAlarm(kap.mAlarmProgram); | 529 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
530 | } | 530 | } |
531 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | 531 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
532 | alarm->setAudioAlarm(kap.mAlarmSound); | 532 | alarm->setAudioAlarm(kap.mAlarmSound); |
533 | else | 533 | else |
534 | alarm->setType(Alarm::Invalid); | 534 | alarm->setType(Alarm::Invalid); |
535 | //alarm->setAudioAlarm("default"); | 535 | //alarm->setAudioAlarm("default"); |
536 | // TODO: Deal with multiple alarms | 536 | // TODO: Deal with multiple alarms |
537 | break; // For now, stop after the first alarm | 537 | break; // For now, stop after the first alarm |
538 | } | 538 | } |
539 | } else { | 539 | } else { |
540 | Alarm* alarm = inc->alarms().first(); | 540 | Alarm* alarm = inc->alarms().first(); |
541 | if ( alarm ) { | 541 | if ( alarm ) { |
542 | alarm->setEnabled(false); | 542 | alarm->setEnabled(false); |
543 | alarm->setType(Alarm::Invalid); | 543 | alarm->setType(Alarm::Invalid); |
544 | } | 544 | } |
545 | } | 545 | } |
546 | KOListViewItem* item = getItemForEvent(inc); | 546 | KOListViewItem* item = getItemForEvent(inc); |
547 | if (item) { | 547 | if (item) { |
548 | ListItemVisitor v(item, mStartDate ); | 548 | ListItemVisitor v(item, mStartDate ); |
549 | inc->accept(v); | 549 | inc->accept(v); |
550 | } | 550 | } |
551 | inc = delSel.next(); | 551 | inc = delSel.next(); |
552 | } | 552 | } |
553 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); | 553 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); |
554 | qDebug("KO: Set alarm for %d items", count); | 554 | qDebug("KO: Set alarm for %d items", count); |
555 | calendar()->reInitAlarmSettings(); | 555 | calendar()->reInitAlarmSettings(); |
556 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 556 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
557 | } | 557 | } |
558 | void KOListView::setCategories( bool removeOld ) | 558 | void KOListView::setCategories( bool removeOld ) |
559 | { | 559 | { |
560 | 560 | ||
561 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 561 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
562 | csd->setColorEnabled(); | 562 | csd->setColorEnabled(); |
563 | if (! csd->exec()) { | 563 | if (! csd->exec()) { |
564 | delete csd; | 564 | delete csd; |
565 | return; | 565 | return; |
566 | } | 566 | } |
567 | QStringList catList = csd->selectedCategories(); | 567 | QStringList catList = csd->selectedCategories(); |
568 | delete csd; | 568 | delete csd; |
569 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 569 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
570 | Incidence* inc = delSel.first(); | 570 | Incidence* inc = delSel.first(); |
571 | while ( inc ) { | 571 | while ( inc ) { |
572 | if ( removeOld ) { | 572 | if ( removeOld ) { |
573 | inc->setCategories( catList, false ); | 573 | inc->setCategories( catList, false ); |
574 | } else { | 574 | } else { |
575 | inc->addCategories( catList, false ); | 575 | inc->addCategories( catList, false ); |
576 | } | 576 | } |
577 | KOListViewItem* item = getItemForEvent(inc); | 577 | KOListViewItem* item = getItemForEvent(inc); |
578 | if (item) { | 578 | if (item) { |
579 | ListItemVisitor v(item, mStartDate ); | 579 | ListItemVisitor v(item, mStartDate ); |
580 | inc->accept(v); | 580 | inc->accept(v); |
581 | } | 581 | } |
582 | inc = delSel.next(); | 582 | inc = delSel.next(); |
583 | } | 583 | } |
584 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 584 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
585 | } | 585 | } |
586 | 586 | ||
587 | void KOListView::beamSelected() | 587 | void KOListView::beamSelected() |
588 | { | 588 | { |
589 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 589 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
590 | if ( delSel.count() ) | 590 | if ( delSel.count() ) |
591 | emit beamIncidenceList( delSel ); | 591 | emit beamIncidenceList( delSel ); |
592 | } | 592 | } |
593 | 593 | ||
594 | void KOListView::saveDescriptionToFile() | 594 | void KOListView::saveDescriptionToFile() |
595 | { | 595 | { |
596 | 596 | ||
597 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 597 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
598 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 598 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
599 | i18n("Continue"), i18n("Cancel"), 0, | 599 | i18n("Continue"), i18n("Cancel"), 0, |
600 | 0, 1 ); | 600 | 0, 1 ); |
601 | if ( result != 0 ) { | 601 | if ( result != 0 ) { |
602 | return; | 602 | return; |
603 | } | 603 | } |
604 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 604 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
605 | int icount = delSel.count(); | 605 | int icount = delSel.count(); |
606 | if ( icount ) { | 606 | if ( icount ) { |
607 | QString fn = KOPrefs::instance()->mLastSaveFile; | 607 | QString fn = KOPrefs::instance()->mLastSaveFile; |
608 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 608 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
609 | 609 | ||
610 | if ( fn == "" ) | 610 | if ( fn == "" ) |
611 | return; | 611 | return; |
612 | QFileInfo info; | 612 | QFileInfo info; |
613 | info.setFile( fn ); | 613 | info.setFile( fn ); |
614 | QString mes; | 614 | QString mes; |
615 | bool createbup = true; | 615 | bool createbup = true; |
616 | if ( info. exists() ) { | 616 | if ( info. exists() ) { |
617 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 617 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
618 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 618 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
619 | i18n("Overwrite!"), i18n("Cancel"), 0, | 619 | i18n("Overwrite!"), i18n("Cancel"), 0, |
620 | 0, 1 ); | 620 | 0, 1 ); |
621 | if ( result != 0 ) { | 621 | if ( result != 0 ) { |
622 | createbup = false; | 622 | createbup = false; |
623 | } | 623 | } |
624 | } | 624 | } |
625 | if ( createbup ) { | 625 | if ( createbup ) { |
626 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 626 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
627 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 627 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
628 | Incidence *incidence = delSel.first(); | 628 | Incidence *incidence = delSel.first(); |
629 | icount = 0; | 629 | icount = 0; |
630 | while ( incidence ) { | 630 | while ( incidence ) { |
631 | if ( incidence->typeID() == journalID ) { | 631 | if ( incidence->typeID() == journalID ) { |
632 | text += "\n************************************\n"; | 632 | text += "\n************************************\n"; |
633 | if ( !incidence->summary().isEmpty() ) | 633 | if ( !incidence->summary().isEmpty() ) |
634 | text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); | 634 | text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); |
635 | else | 635 | else |
636 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 636 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
637 | if ( !incidence->location().isEmpty() ) | 637 | if ( !incidence->location().isEmpty() ) |
638 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; | 638 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; |
639 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 639 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
640 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 640 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
641 | ++icount; | 641 | ++icount; |
642 | 642 | ||
643 | } else { | 643 | } else { |
644 | if ( !incidence->description().isEmpty() ) { | 644 | if ( !incidence->description().isEmpty() ) { |
645 | text += "\n************************************\n"; | 645 | text += "\n************************************\n"; |
646 | if ( incidence->typeID() == todoID ) | 646 | if ( incidence->typeID() == todoID ) |
647 | text += i18n("To-Do: "); | 647 | text += i18n("To-Do: "); |
648 | text += incidence->summary(); | 648 | text += incidence->summary(); |
649 | if ( !incidence->location().isEmpty() ) | 649 | if ( !incidence->location().isEmpty() ) |
650 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; | 650 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; |
651 | if ( incidence->hasStartDate() ) | 651 | if ( incidence->hasStartDate() ) |
652 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 652 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
653 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 653 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
654 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 654 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
655 | ++icount; | 655 | ++icount; |
656 | 656 | ||
657 | } | 657 | } |
658 | } | 658 | } |
659 | incidence = delSel.next(); | 659 | incidence = delSel.next(); |
660 | } | 660 | } |
661 | QFile file( fn ); | 661 | QFile file( fn ); |
662 | if (!file.open( IO_WriteOnly ) ) { | 662 | if (!file.open( IO_WriteOnly ) ) { |
663 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 663 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
664 | return; | 664 | return; |
665 | } | 665 | } |
666 | QTextStream ts( &file ); | 666 | QTextStream ts( &file ); |
667 | ts << text; | 667 | ts << text; |
668 | file.close(); | 668 | file.close(); |
669 | //qDebug("%s ", text.latin1()); | 669 | //qDebug("%s ", text.latin1()); |
670 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 670 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
671 | KOPrefs::instance()->mLastSaveFile = fn; | 671 | KOPrefs::instance()->mLastSaveFile = fn; |
672 | topLevelWidget()->setCaption(mes); | 672 | topLevelWidget()->setCaption(mes); |
673 | } | 673 | } |
674 | } | 674 | } |
675 | } | 675 | } |
676 | void KOListView::saveToFileVCS() | 676 | void KOListView::saveToFileVCS() |
677 | { | 677 | { |
678 | writeToFile( false ); | 678 | writeToFile( false ); |
679 | } | 679 | } |
680 | void KOListView::saveToFile() | 680 | void KOListView::saveToFile() |
681 | { | 681 | { |
682 | writeToFile( true ); | 682 | writeToFile( true ); |
683 | } | 683 | } |
684 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) | 684 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) |
685 | { | 685 | { |
686 | QPtrList<Incidence> delSel ; | 686 | QPtrList<Incidence> delSel ; |
687 | bool addSubTodos = false; | 687 | bool addSubTodos = false; |
688 | bool askSubTodos = true; | 688 | bool askSubTodos = true; |
689 | QListViewItem *item = mListView->firstChild (); | 689 | QListViewItem *item = mListView->firstChild (); |
690 | while ( item ) { | 690 | while ( item ) { |
691 | if ( item->isSelected() ) { | 691 | if ( item->isSelected() ) { |
692 | Incidence* inc = ((KOListViewItem *)item)->data(); | 692 | Incidence* inc = ((KOListViewItem *)item)->data(); |
693 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { | 693 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { |
694 | if ( (inc->typeID() == todoID && includeTodos) || | 694 | if ( (inc->typeID() == todoID && includeTodos) || |
695 | (inc->typeID() == eventID && includeEvents) || | 695 | (inc->typeID() == eventID && includeEvents) || |
696 | (inc->typeID() == journalID && includeJournals) ) { | 696 | (inc->typeID() == journalID && includeJournals) ) { |
697 | if ( inc->typeID() == todoID && onlyDueTodos ) { | 697 | if ( inc->typeID() == todoID && onlyDueTodos ) { |
698 | if ( ((Todo*)inc)->hasDueDate() ) | 698 | if ( ((Todo*)inc)->hasDueDate() ) |
699 | delSel.append( inc ); | 699 | delSel.append( inc ); |
700 | } else | 700 | } else |
701 | delSel.append( inc ); | 701 | delSel.append( inc ); |
702 | 702 | ||
703 | } | 703 | } |
704 | } | 704 | } |
705 | if ( inc->typeID() == todoID ) { | 705 | if ( inc->typeID() == todoID ) { |
706 | Todo * todo = (Todo*) inc; | 706 | Todo * todo = (Todo*) inc; |
707 | if ( todo->relations().count() ) { | 707 | if ( todo->relations().count() ) { |
708 | if ( askSubTodos ) { | 708 | if ( askSubTodos ) { |
709 | int result = KMessageBox::warningYesNoCancel(this, | 709 | int result = KMessageBox::warningYesNoCancel(this, |
710 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), | 710 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), |
711 | i18n("Todo has subtodos"), | 711 | i18n("Todo has subtodos"), |
712 | i18n("Yes"), | 712 | i18n("Yes"), |
713 | i18n("No")); | 713 | i18n("No")); |
714 | if ( result == KMessageBox::Cancel ) { | 714 | if ( result == KMessageBox::Cancel ) { |
715 | delSel.clear(); | 715 | delSel.clear(); |
716 | return delSel; | 716 | return delSel; |
717 | } | 717 | } |
718 | if (result == KMessageBox::Yes) | 718 | if (result == KMessageBox::Yes) |
719 | addSubTodos = true; | 719 | addSubTodos = true; |
720 | askSubTodos = false; | 720 | askSubTodos = false; |
721 | } | 721 | } |
722 | if ( addSubTodos ) { | 722 | if ( addSubTodos ) { |
723 | QPtrList<Incidence> tempSel ; | 723 | QPtrList<Incidence> tempSel ; |
724 | inc->addRelationsToList( &tempSel ); | 724 | inc->addRelationsToList( &tempSel ); |
725 | Incidence* tempinc = tempSel.first(); | 725 | Incidence* tempinc = tempSel.first(); |
726 | while ( tempinc ) { | 726 | while ( tempinc ) { |
727 | if ( delSel.findRef( tempinc ) == -1 ) { | 727 | if ( delSel.findRef( tempinc ) == -1 ) { |
728 | if ( tempinc->typeID() == todoID && onlyDueTodos ) { | 728 | if ( tempinc->typeID() == todoID && onlyDueTodos ) { |
729 | if ( ((Todo*)tempinc)->hasDueDate() ) | 729 | if ( ((Todo*)tempinc)->hasDueDate() ) |
730 | delSel.append( tempinc ); | 730 | delSel.append( tempinc ); |
731 | } else | 731 | } else |
732 | delSel.append( tempinc ); | 732 | delSel.append( tempinc ); |
733 | } | 733 | } |
734 | tempinc = tempSel.next(); | 734 | tempinc = tempSel.next(); |
735 | } | 735 | } |
736 | } | 736 | } |
737 | } | 737 | } |
738 | } | 738 | } |
739 | } | 739 | } |
740 | item = item->nextSibling(); | 740 | item = item->nextSibling(); |
741 | } | 741 | } |
742 | return delSel; | 742 | return delSel; |
743 | } | 743 | } |
744 | 744 | ||
745 | void KOListView::writeToFile( bool iCal ) | 745 | void KOListView::writeToFile( bool iCal ) |
746 | { | 746 | { |
747 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 747 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
748 | if ( !iCal ) { | 748 | if ( !iCal ) { |
749 | bool journal = false; | 749 | bool journal = false; |
750 | Incidence *incidence = delSel.first(); | 750 | Incidence *incidence = delSel.first(); |
751 | while ( incidence ) { | 751 | while ( incidence ) { |
752 | if ( incidence->typeID() == journalID ) { | 752 | if ( incidence->typeID() == journalID ) { |
753 | journal = true; | 753 | journal = true; |
754 | break; | 754 | break; |
755 | } | 755 | } |
756 | incidence = delSel.next(); | 756 | incidence = delSel.next(); |
757 | } | 757 | } |
758 | if ( journal ) { | 758 | if ( journal ) { |
759 | int result = KMessageBox::warningContinueCancel(this, | 759 | int result = KMessageBox::warningContinueCancel(this, |
760 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 760 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
761 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 761 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
762 | true); | 762 | true); |
763 | if (result != KMessageBox::Continue) return; | 763 | if (result != KMessageBox::Continue) return; |
764 | } | 764 | } |
765 | } | 765 | } |
766 | if ( delSel.count() ) { | 766 | if ( delSel.count() ) { |
767 | QString fn = KOPrefs::instance()->mLastSaveFile; | 767 | QString fn = KOPrefs::instance()->mLastSaveFile; |
768 | QString extension; | 768 | QString extension; |
769 | if ( iCal ) { | 769 | if ( iCal ) { |
770 | if ( fn.right( 4 ).lower() == ".vcs" ) { | 770 | if ( fn.right( 4 ).lower() == ".vcs" ) { |
771 | fn = fn.left( fn.length() -3) + "ics"; | 771 | fn = fn.left( fn.length() -3) + "ics"; |
772 | } | 772 | } |
773 | } else { | 773 | } else { |
774 | if ( fn.right( 4 ).lower() == ".ics" ) { | 774 | if ( fn.right( 4 ).lower() == ".ics" ) { |
775 | fn = fn.left( fn.length() -3) + "vcs"; | 775 | fn = fn.left( fn.length() -3) + "vcs"; |
776 | } | 776 | } |
777 | } | 777 | } |
778 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 778 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
779 | 779 | ||
780 | if ( fn == "" ) | 780 | if ( fn == "" ) |
781 | return; | 781 | return; |
782 | QFileInfo info; | 782 | QFileInfo info; |
783 | info.setFile( fn ); | 783 | info.setFile( fn ); |
784 | QString mes; | 784 | QString mes; |
785 | bool createbup = true; | 785 | bool createbup = true; |
786 | if ( info. exists() ) { | 786 | if ( info. exists() ) { |
787 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 787 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
788 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 788 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
789 | i18n("Overwrite!"), i18n("Cancel"), 0, | 789 | i18n("Overwrite!"), i18n("Cancel"), 0, |
790 | 0, 1 ); | 790 | 0, 1 ); |
791 | if ( result != 0 ) { | 791 | if ( result != 0 ) { |
792 | createbup = false; | 792 | createbup = false; |
793 | } | 793 | } |
794 | } | 794 | } |
795 | if ( createbup ) { | 795 | if ( createbup ) { |
796 | CalendarLocal cal; | 796 | CalendarLocal cal; |
797 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 797 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
798 | Incidence *incidence = delSel.first(); | 798 | Incidence *incidence = delSel.first(); |
799 | while ( incidence ) { | 799 | while ( incidence ) { |
800 | cal.addIncidence( incidence->clone() ); | 800 | cal.addIncidence( incidence->clone() ); |
801 | incidence = delSel.next(); | 801 | incidence = delSel.next(); |
802 | } | 802 | } |
803 | if ( iCal ) { | 803 | if ( iCal ) { |
804 | ICalFormat format; | 804 | ICalFormat format; |
805 | format.save( &cal, fn ); | 805 | format.save( &cal, fn ); |
806 | } else { | 806 | } else { |
807 | 807 | ||
808 | VCalFormat format; | 808 | VCalFormat format; |
809 | format.save( &cal, fn ); | 809 | format.save( &cal, fn ); |
810 | } | 810 | } |
811 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 811 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
812 | KOPrefs::instance()->mLastSaveFile = fn; | 812 | KOPrefs::instance()->mLastSaveFile = fn; |
813 | topLevelWidget()->setCaption(mes); | 813 | topLevelWidget()->setCaption(mes); |
814 | } | 814 | } |
815 | } | 815 | } |
816 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 816 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
817 | } | 817 | } |
818 | void KOListView::hideAll() | 818 | void KOListView::hideAll() |
819 | { | 819 | { |
820 | QPtrList<QListViewItem> delSel ; | 820 | QPtrList<QListViewItem> delSel ; |
821 | QListViewItem *item = mListView->firstChild (); | 821 | QListViewItem *item = mListView->firstChild (); |
822 | while ( item ) { | 822 | while ( item ) { |
823 | if ( item->isSelected() ) { | 823 | if ( item->isSelected() ) { |
824 | delSel.append(item); | 824 | delSel.append(item); |
825 | } | 825 | } |
826 | item = item->nextSibling(); | 826 | item = item->nextSibling(); |
827 | } | 827 | } |
828 | item = delSel.first() ; | 828 | item = delSel.first() ; |
829 | while ( item ) { | 829 | while ( item ) { |
830 | QListViewItem * del = item; | 830 | QListViewItem * del = item; |
831 | item = delSel.next(); | 831 | item = delSel.next(); |
832 | delete del; | 832 | delete del; |
833 | } | 833 | } |
834 | } | 834 | } |
835 | void KOListView::printList() | 835 | void KOListView::printList() |
836 | { | 836 | { |
837 | mListView->printList(); | 837 | mListView->printList(); |
838 | } | 838 | } |
839 | void KOListView::deleteAll() | 839 | void KOListView::deleteAll() |
840 | { | 840 | { |
841 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; | 841 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; |
842 | if ( delSel.count() ) { | 842 | if ( delSel.count() ) { |
843 | int icount = delSel.count(); | 843 | int icount = delSel.count(); |
844 | Incidence *incidence = delSel.first(); | 844 | Incidence *incidence = delSel.first(); |
845 | Incidence *toDelete; | 845 | Incidence *toDelete; |
846 | KOPrefs *p = KOPrefs::instance(); | 846 | KOPrefs *p = KOPrefs::instance(); |
847 | bool confirm = p->mConfirm; | 847 | bool confirm = p->mConfirm; |
848 | QString mess; | 848 | QString mess; |
849 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 849 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
850 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 850 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
851 | p->mConfirm = false; | 851 | p->mConfirm = false; |
852 | int delCounter = 0; | 852 | int delCounter = 0; |
853 | QDialog dia ( this, "p-dialog", true ); | 853 | QDialog dia ( this, "p-dialog", true ); |
854 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 854 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
855 | QVBoxLayout lay( &dia ); | 855 | QVBoxLayout lay( &dia ); |
856 | lay.setMargin(7); | 856 | lay.setMargin(7); |
857 | lay.setSpacing(7); | 857 | lay.setSpacing(7); |
858 | lay.addWidget( &lab); | 858 | lay.addWidget( &lab); |
859 | QProgressBar bar( icount, &dia ); | 859 | QProgressBar bar( icount, &dia ); |
860 | lay.addWidget( &bar); | 860 | lay.addWidget( &bar); |
861 | int w = 220; | 861 | int w = 220; |
862 | int h = 50; | 862 | int h = 50; |
863 | int dw = QApplication::desktop()->width(); | 863 | int dw = QApplication::desktop()->width(); |
864 | int dh = QApplication::desktop()->height(); | 864 | int dh = QApplication::desktop()->height(); |
865 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 865 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
866 | //dia.resize( 240,50 ); | 866 | //dia.resize( 240,50 ); |
867 | dia.show(); | 867 | dia.show(); |
868 | 868 | KOPrefs::instance()->mGlobalUpdateDisabled = true; | |
869 | while ( incidence ) { | 869 | while ( incidence ) { |
870 | bar.setProgress( delCounter ); | 870 | bar.setProgress( delCounter ); |
871 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); | 871 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); |
872 | dia.setCaption( mess ); | 872 | dia.setCaption( mess ); |
873 | qApp->processEvents(); | 873 | qApp->processEvents(); |
874 | toDelete = (incidence); | 874 | toDelete = (incidence); |
875 | incidence = delSel.next(); | 875 | incidence = delSel.next(); |
876 | emit deleteIncidenceSignal(toDelete ); | 876 | emit deleteIncidenceSignal(toDelete ); |
877 | if ( dia.result() != 0 ) | 877 | if ( dia.result() != 0 ) |
878 | break; | 878 | break; |
879 | 879 | ||
880 | } | 880 | } |
881 | KOPrefs::instance()->mGlobalUpdateDisabled = false; | ||
882 | emit deleteIncidenceSignal( 0 ); | ||
881 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); | 883 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); |
882 | topLevelWidget ()->setCaption( mess ); | 884 | topLevelWidget ()->setCaption( mess ); |
883 | p->mConfirm = confirm; | 885 | p->mConfirm = confirm; |
884 | } | 886 | } |
885 | } | 887 | } |
886 | 888 | ||
887 | 889 | ||
888 | } | 890 | } |
889 | int KOListView::maxDatesHint() | 891 | int KOListView::maxDatesHint() |
890 | { | 892 | { |
891 | return 0; | 893 | return 0; |
892 | } | 894 | } |
893 | 895 | ||
894 | int KOListView::currentDateCount() | 896 | int KOListView::currentDateCount() |
895 | { | 897 | { |
896 | return 0; | 898 | return 0; |
897 | } | 899 | } |
898 | 900 | ||
899 | QPtrList<Incidence> KOListView::selectedIncidences() | 901 | QPtrList<Incidence> KOListView::selectedIncidences() |
900 | { | 902 | { |
901 | QPtrList<Incidence> eventList; | 903 | QPtrList<Incidence> eventList; |
902 | QListViewItem *item = mListView->firstChild (); | 904 | QListViewItem *item = mListView->firstChild (); |
903 | while ( item ) { | 905 | while ( item ) { |
904 | if ( item->isSelected() ) { | 906 | if ( item->isSelected() ) { |
905 | eventList.append(((KOListViewItem *)item)->data()); | 907 | eventList.append(((KOListViewItem *)item)->data()); |
906 | } | 908 | } |
907 | 909 | ||
908 | item = item->nextSibling(); | 910 | item = item->nextSibling(); |
909 | } | 911 | } |
910 | 912 | ||
911 | // // QListViewItem *item = mListView->selectedItem(); | 913 | // // QListViewItem *item = mListView->selectedItem(); |
912 | //if (item) eventList.append(((KOListViewItem *)item)->data()); | 914 | //if (item) eventList.append(((KOListViewItem *)item)->data()); |
913 | 915 | ||
914 | return eventList; | 916 | return eventList; |
915 | } | 917 | } |
916 | 918 | ||
917 | DateList KOListView::selectedDates() | 919 | DateList KOListView::selectedDates() |
918 | { | 920 | { |
919 | DateList eventList; | 921 | DateList eventList; |
920 | return eventList; | 922 | return eventList; |
921 | } | 923 | } |
922 | 924 | ||
923 | void KOListView::showDates(bool show) | 925 | void KOListView::showDates(bool show) |
924 | { | 926 | { |
925 | // Shouldn't we set it to a value greater 0? When showDates is called with | 927 | // Shouldn't we set it to a value greater 0? When showDates is called with |
926 | // show == true at first, then the columnwidths are set to zero. | 928 | // show == true at first, then the columnwidths are set to zero. |
927 | static int oldColWidth1 = 0; | 929 | static int oldColWidth1 = 0; |
928 | static int oldColWidth3 = 0; | 930 | static int oldColWidth3 = 0; |
929 | 931 | ||
930 | if (!show) { | 932 | if (!show) { |
931 | oldColWidth1 = mListView->columnWidth(1); | 933 | oldColWidth1 = mListView->columnWidth(1); |
932 | oldColWidth3 = mListView->columnWidth(3); | 934 | oldColWidth3 = mListView->columnWidth(3); |
933 | mListView->setColumnWidth(1, 0); | 935 | mListView->setColumnWidth(1, 0); |
934 | mListView->setColumnWidth(3, 0); | 936 | mListView->setColumnWidth(3, 0); |
935 | } else { | 937 | } else { |
936 | mListView->setColumnWidth(1, oldColWidth1); | 938 | mListView->setColumnWidth(1, oldColWidth1); |
937 | mListView->setColumnWidth(3, oldColWidth3); | 939 | mListView->setColumnWidth(3, oldColWidth3); |
938 | } | 940 | } |
939 | mListView->repaint(); | 941 | mListView->repaint(); |
940 | } | 942 | } |
941 | 943 | ||
942 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 944 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
943 | const QDate &td) | 945 | const QDate &td) |
944 | { | 946 | { |
945 | #ifndef KORG_NOPRINTER | 947 | #ifndef KORG_NOPRINTER |
946 | calPrinter->preview(CalPrinter::Day, fd, td); | 948 | calPrinter->preview(CalPrinter::Day, fd, td); |
947 | #endif | 949 | #endif |
948 | } | 950 | } |
949 | 951 | ||
950 | void KOListView::showDates() | 952 | void KOListView::showDates() |
951 | { | 953 | { |
952 | showDates(true); | 954 | showDates(true); |
953 | } | 955 | } |
954 | 956 | ||
955 | void KOListView::hideDates() | 957 | void KOListView::hideDates() |
956 | { | 958 | { |
957 | showDates(false); | 959 | showDates(false); |
958 | } | 960 | } |
959 | 961 | ||
960 | void KOListView::resetFocus() | 962 | void KOListView::resetFocus() |
961 | { | 963 | { |
962 | topLevelWidget()->setActiveWindow(); | 964 | topLevelWidget()->setActiveWindow(); |
963 | topLevelWidget()->raise(); | 965 | topLevelWidget()->raise(); |
964 | mListView->setFocus(); | 966 | mListView->setFocus(); |
965 | } | 967 | } |
966 | void KOListView::updateView() | 968 | void KOListView::updateView() |
967 | { | 969 | { |
968 | mListView->setFocus(); | 970 | mListView->setFocus(); |
969 | if ( mListView->firstChild () ) | 971 | if ( mListView->firstChild () ) |
970 | mListView->setCurrentItem( mListView->firstChild () ); | 972 | mListView->setCurrentItem( mListView->firstChild () ); |
971 | } | 973 | } |
972 | void KOListView::updateConfig() | 974 | void KOListView::updateConfig() |
973 | { | 975 | { |
974 | 976 | ||
975 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 977 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
976 | updateView(); | 978 | updateView(); |
977 | 979 | ||
978 | } | 980 | } |
979 | void KOListView::setStartDate(const QDate &start) | 981 | void KOListView::setStartDate(const QDate &start) |
980 | { | 982 | { |
981 | mStartDate = start; | 983 | mStartDate = start; |
982 | } | 984 | } |
983 | 985 | ||
984 | void KOListView::showDates(const QDate &start, const QDate &end) | 986 | void KOListView::showDates(const QDate &start, const QDate &end) |
985 | { | 987 | { |
986 | clear(); | 988 | clear(); |
987 | mStartDate = start; | 989 | mStartDate = start; |
988 | QDate date = start; | 990 | QDate date = start; |
989 | while( date <= end ) { | 991 | while( date <= end ) { |
990 | addEvents(calendar()->events(date)); | 992 | addEvents(calendar()->events(date)); |
991 | addTodos(calendar()->todos(date)); | 993 | addTodos(calendar()->todos(date)); |
992 | addJournals( calendar()->journals4Date(date) ); | 994 | addJournals( calendar()->journals4Date(date) ); |
993 | date = date.addDays( 1 ); | 995 | date = date.addDays( 1 ); |
994 | } | 996 | } |
995 | emit incidenceSelected( 0 ); | 997 | emit incidenceSelected( 0 ); |
996 | updateView(); | 998 | updateView(); |
997 | 999 | ||
998 | } | 1000 | } |
999 | 1001 | ||
1000 | void KOListView::addEvents(QPtrList<Event> eventList) | 1002 | void KOListView::addEvents(QPtrList<Event> eventList) |
1001 | { | 1003 | { |
1002 | 1004 | ||
1003 | Event *ev; | 1005 | Event *ev; |
1004 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 1006 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
1005 | addIncidence(ev); | 1007 | addIncidence(ev); |
1006 | } | 1008 | } |
1007 | if ( !mListView->currentItem() ){ | 1009 | if ( !mListView->currentItem() ){ |
1008 | updateView(); | 1010 | updateView(); |
1009 | } | 1011 | } |
1010 | } | 1012 | } |
1011 | 1013 | ||
1012 | void KOListView::addTodos(QPtrList<Todo> eventList) | 1014 | void KOListView::addTodos(QPtrList<Todo> eventList) |
1013 | { | 1015 | { |
1014 | Todo *ev; | 1016 | Todo *ev; |
1015 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 1017 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
1016 | addIncidence(ev); | 1018 | addIncidence(ev); |
1017 | } | 1019 | } |
1018 | if ( !mListView->currentItem() ){ | 1020 | if ( !mListView->currentItem() ){ |
1019 | updateView(); | 1021 | updateView(); |
1020 | } | 1022 | } |
1021 | } | 1023 | } |
1022 | void KOListView::addJournals(QPtrList<Journal> eventList) | 1024 | void KOListView::addJournals(QPtrList<Journal> eventList) |
1023 | { | 1025 | { |
1024 | Journal *ev; | 1026 | Journal *ev; |
1025 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 1027 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
1026 | addIncidence(ev); | 1028 | addIncidence(ev); |
1027 | } | 1029 | } |
1028 | if ( !mListView->currentItem() ){ | 1030 | if ( !mListView->currentItem() ){ |
1029 | updateView(); | 1031 | updateView(); |
1030 | } | 1032 | } |
1031 | } | 1033 | } |
1032 | 1034 | ||
1033 | void KOListView::showCompletedTodos() | 1035 | void KOListView::showCompletedTodos() |
1034 | { | 1036 | { |
1035 | mForceShowCompletedTodos = true; | 1037 | mForceShowCompletedTodos = true; |
1036 | } | 1038 | } |
1037 | void KOListView::addIncidence(Incidence *incidence) | 1039 | void KOListView::addIncidence(Incidence *incidence) |
1038 | { | 1040 | { |
1039 | if ( mUidDict.find( incidence->uid() ) ) return; | 1041 | if ( mUidDict.find( incidence->uid() ) ) return; |
1040 | 1042 | ||
1041 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 1043 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
1042 | if ( incidence->typeID() == todoID ) { | 1044 | if ( incidence->typeID() == todoID ) { |
1043 | if ( ! mForceShowCompletedTodos ) { | 1045 | if ( ! mForceShowCompletedTodos ) { |
1044 | if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) | 1046 | if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) |
1045 | return; | 1047 | return; |
1046 | } | 1048 | } |
1047 | } | 1049 | } |
1048 | mUidDict.insert( incidence->uid(), incidence ); | 1050 | mUidDict.insert( incidence->uid(), incidence ); |
1049 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 1051 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
1050 | ListItemVisitor v(item, mStartDate ); | 1052 | ListItemVisitor v(item, mStartDate ); |
1051 | if (incidence->accept(v)) { | 1053 | if (incidence->accept(v)) { |
1052 | return; | 1054 | return; |
1053 | } | 1055 | } |
1054 | else delete item; | 1056 | else delete item; |
1055 | } | 1057 | } |
1056 | 1058 | ||
1057 | void KOListView::showEvents(QPtrList<Event> eventList) | 1059 | void KOListView::showEvents(QPtrList<Event> eventList) |
1058 | { | 1060 | { |
1059 | clear(); | 1061 | clear(); |
1060 | 1062 | ||
1061 | addEvents(eventList); | 1063 | addEvents(eventList); |
1062 | 1064 | ||
1063 | // After new creation of list view no events are selected. | 1065 | // After new creation of list view no events are selected. |
1064 | emit incidenceSelected( 0 ); | 1066 | emit incidenceSelected( 0 ); |
1065 | } | 1067 | } |
1066 | int KOListView::count() | 1068 | int KOListView::count() |
1067 | { | 1069 | { |
1068 | return mListView->childCount(); | 1070 | return mListView->childCount(); |
1069 | } | 1071 | } |
1070 | 1072 | ||
1071 | void KOListView::changeEventDisplay(Event *event, int action) | 1073 | void KOListView::changeEventDisplay(Event *event, int action) |
1072 | { | 1074 | { |
1073 | KOListViewItem *item; | 1075 | KOListViewItem *item; |
1074 | 1076 | ||
1075 | switch(action) { | 1077 | switch(action) { |
1076 | case KOGlobals::EVENTADDED: | 1078 | case KOGlobals::EVENTADDED: |
1077 | addIncidence( event ); | 1079 | addIncidence( event ); |
1078 | break; | 1080 | break; |
1079 | case KOGlobals::EVENTEDITED: | 1081 | case KOGlobals::EVENTEDITED: |
1080 | item = getItemForEvent(event); | 1082 | item = getItemForEvent(event); |
1081 | if (item) { | 1083 | if (item) { |
1082 | ListItemVisitor v(item, mStartDate ); | 1084 | ListItemVisitor v(item, mStartDate ); |
1083 | ((Incidence*)event)->accept(v); | 1085 | ((Incidence*)event)->accept(v); |
1084 | } | 1086 | } |
1085 | break; | 1087 | break; |
1086 | case KOGlobals::EVENTDELETED: | 1088 | case KOGlobals::EVENTDELETED: |
1087 | item = getItemForEvent(event); | 1089 | item = getItemForEvent(event); |
1088 | if (item) { | 1090 | if (item) { |
1089 | mUidDict.remove( event->uid() ); | 1091 | mUidDict.remove( event->uid() ); |
1090 | delete item; | 1092 | delete item; |
1091 | } | 1093 | } |
1092 | break; | 1094 | break; |
1093 | default: | 1095 | default: |
1094 | ; | 1096 | ; |
1095 | } | 1097 | } |
1096 | } | 1098 | } |
1097 | 1099 | ||
1098 | KOListViewItem *KOListView::getItemForEvent(Incidence *event) | 1100 | KOListViewItem *KOListView::getItemForEvent(Incidence *event) |
1099 | { | 1101 | { |
1100 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 1102 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
1101 | while (item) { | 1103 | while (item) { |
1102 | if (item->data() == event) return item; | 1104 | if (item->data() == event) return item; |
1103 | item = (KOListViewItem *)item->nextSibling(); | 1105 | item = (KOListViewItem *)item->nextSibling(); |
1104 | } | 1106 | } |
1105 | return 0; | 1107 | return 0; |
1106 | } | 1108 | } |
1107 | 1109 | ||
1108 | void KOListView::defaultItemAction(QListViewItem *i) | 1110 | void KOListView::defaultItemAction(QListViewItem *i) |
1109 | { | 1111 | { |
1110 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 1112 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
1111 | if ( item ) defaultAction( item->data() ); | 1113 | if ( item ) defaultAction( item->data() ); |
1112 | 1114 | ||
1113 | } | 1115 | } |
1114 | 1116 | ||
1115 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 1117 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
1116 | { | 1118 | { |
1117 | mActiveItem = (KOListViewItem *)item; | 1119 | mActiveItem = (KOListViewItem *)item; |
1118 | if (mActiveItem) { | 1120 | if (mActiveItem) { |
1119 | Incidence *incidence = mActiveItem->data(); | 1121 | Incidence *incidence = mActiveItem->data(); |
1120 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); | 1122 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); |
1121 | mPopupMenu->showIncidencePopup(incidence); | 1123 | mPopupMenu->showIncidencePopup(incidence); |
1122 | 1124 | ||
1123 | /* | 1125 | /* |
1124 | if ( incidence && incidence->type() == "Event" ) { | 1126 | if ( incidence && incidence->type() == "Event" ) { |
1125 | Event *event = static_cast<Event *>( incidence ); | 1127 | Event *event = static_cast<Event *>( incidence ); |
1126 | mPopupMenu->showEventPopup(event); | 1128 | mPopupMenu->showEventPopup(event); |
1127 | } | 1129 | } |
1128 | */ | 1130 | */ |
1129 | } | 1131 | } |
1130 | } | 1132 | } |
1131 | 1133 | ||
1132 | void KOListView::readSettings(KConfig *config, QString setting) | 1134 | void KOListView::readSettings(KConfig *config, QString setting) |
1133 | { | 1135 | { |
1134 | // qDebug("KOListView::readSettings "); | 1136 | // qDebug("KOListView::readSettings "); |
1135 | mListView->restoreLayout(config,setting); | 1137 | mListView->restoreLayout(config,setting); |
1136 | } | 1138 | } |
1137 | 1139 | ||
1138 | void KOListView::writeSettings(KConfig *config, QString setting) | 1140 | void KOListView::writeSettings(KConfig *config, QString setting) |
1139 | { | 1141 | { |
1140 | // qDebug("KOListView::writeSettings "); | 1142 | // qDebug("KOListView::writeSettings "); |
1141 | mListView->saveLayout(config, setting); | 1143 | mListView->saveLayout(config, setting); |
1142 | } | 1144 | } |
1143 | 1145 | ||
1144 | void KOListView::processSelectionChange(QListViewItem *) | 1146 | void KOListView::processSelectionChange(QListViewItem *) |
1145 | { | 1147 | { |
1146 | 1148 | ||
1147 | KOListViewItem *item = | 1149 | KOListViewItem *item = |
1148 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 1150 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
1149 | 1151 | ||
1150 | if ( !item ) { | 1152 | if ( !item ) { |
1151 | emit incidenceSelected( 0 ); | 1153 | emit incidenceSelected( 0 ); |
1152 | } else { | 1154 | } else { |
1153 | emit incidenceSelected( item->data() ); | 1155 | emit incidenceSelected( item->data() ); |
1154 | } | 1156 | } |
1155 | } | 1157 | } |
1156 | 1158 | ||
1157 | void KOListView::clearSelection() | 1159 | void KOListView::clearSelection() |
1158 | { | 1160 | { |
1159 | mListView->selectAll( false ); | 1161 | mListView->selectAll( false ); |
1160 | } | 1162 | } |
1161 | void KOListView::allSelection() | 1163 | void KOListView::allSelection() |
1162 | { | 1164 | { |
1163 | mListView->selectAll( true ); | 1165 | mListView->selectAll( true ); |
1164 | } | 1166 | } |
1165 | 1167 | ||
1166 | void KOListView::clear() | 1168 | void KOListView::clear() |
1167 | { | 1169 | { |
1168 | mListView->clear(); | 1170 | mListView->clear(); |
1169 | mUidDict.clear(); | 1171 | mUidDict.clear(); |
1170 | } | 1172 | } |
1171 | 1173 | ||
1172 | Incidence* KOListView::currentItem() | 1174 | Incidence* KOListView::currentItem() |
1173 | { | 1175 | { |
1174 | if ( mListView->currentItem() ) | 1176 | if ( mListView->currentItem() ) |
1175 | return ((KOListViewItem*) mListView->currentItem())->data(); | 1177 | return ((KOListViewItem*) mListView->currentItem())->data(); |
1176 | return 0; | 1178 | return 0; |
1177 | } | 1179 | } |
1178 | void KOListView::keyPressEvent ( QKeyEvent *e) | 1180 | void KOListView::keyPressEvent ( QKeyEvent *e) |
1179 | { | 1181 | { |
1180 | 1182 | ||
1181 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { | 1183 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { |
1182 | deleteAll(); | 1184 | deleteAll(); |
1183 | return; | 1185 | return; |
1184 | } | 1186 | } |
1185 | 1187 | ||
1186 | e->ignore(); | 1188 | e->ignore(); |
1187 | } | 1189 | } |
1188 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 1190 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) |
1189 | { | 1191 | { |
1190 | 1192 | ||
1191 | switch ( e->key() ) { | 1193 | switch ( e->key() ) { |
1192 | case Qt::Key_Down: | 1194 | case Qt::Key_Down: |
1193 | if ( e->state() == ShiftButton ) { | 1195 | if ( e->state() == ShiftButton ) { |
1194 | QListViewItem* cn = currentItem(); | 1196 | QListViewItem* cn = currentItem(); |
1195 | if ( !cn ) | 1197 | if ( !cn ) |
1196 | cn = firstChild(); | 1198 | cn = firstChild(); |
1197 | if ( !cn ) | 1199 | if ( !cn ) |
1198 | return; | 1200 | return; |
1199 | while ( cn->nextSibling() ) | 1201 | while ( cn->nextSibling() ) |
1200 | cn = cn->nextSibling(); | 1202 | cn = cn->nextSibling(); |
1201 | setCurrentItem ( cn ); | 1203 | setCurrentItem ( cn ); |
1202 | ensureItemVisible ( cn ); | 1204 | ensureItemVisible ( cn ); |
1203 | 1205 | ||
1204 | e->accept(); | 1206 | e->accept(); |
1205 | return; | 1207 | return; |
1206 | } | 1208 | } |
1207 | if ( e->state() == ControlButton ) { | 1209 | if ( e->state() == ControlButton ) { |
1208 | int count = childCount (); | 1210 | int count = childCount (); |
1209 | int jump = count / 5; | 1211 | int jump = count / 5; |
1210 | QListViewItem* cn; | 1212 | QListViewItem* cn; |
1211 | cn = currentItem(); | 1213 | cn = currentItem(); |
1212 | if ( ! cn ) | 1214 | if ( ! cn ) |
1213 | return; | 1215 | return; |
1214 | if ( jump == 0 ) | 1216 | if ( jump == 0 ) |
1215 | jump = 1; | 1217 | jump = 1; |
1216 | while ( jump && cn->nextSibling() ) { | 1218 | while ( jump && cn->nextSibling() ) { |
1217 | cn = cn->nextSibling(); | 1219 | cn = cn->nextSibling(); |
1218 | --jump; | 1220 | --jump; |
1219 | } | 1221 | } |
1220 | setCurrentItem ( cn ); | 1222 | setCurrentItem ( cn ); |
1221 | ensureItemVisible ( cn ); | 1223 | ensureItemVisible ( cn ); |
1222 | 1224 | ||
1223 | } else | 1225 | } else |
1224 | QListView::keyPressEvent ( e ) ; | 1226 | QListView::keyPressEvent ( e ) ; |
1225 | e->accept(); | 1227 | e->accept(); |
1226 | break; | 1228 | break; |
1227 | 1229 | ||
1228 | case Qt::Key_Up: | 1230 | case Qt::Key_Up: |
1229 | if ( e->state() == ShiftButton ) { | 1231 | if ( e->state() == ShiftButton ) { |
1230 | QListViewItem* cn = firstChild(); | 1232 | QListViewItem* cn = firstChild(); |
1231 | if ( cn ) { | 1233 | if ( cn ) { |
1232 | setCurrentItem ( cn ); | 1234 | setCurrentItem ( cn ); |
1233 | ensureItemVisible ( cn ); | 1235 | ensureItemVisible ( cn ); |
1234 | } | 1236 | } |
1235 | e->accept(); | 1237 | e->accept(); |
1236 | return; | 1238 | return; |
1237 | } | 1239 | } |
1238 | if ( e->state() == ControlButton ) { | 1240 | if ( e->state() == ControlButton ) { |
1239 | int count = childCount (); | 1241 | int count = childCount (); |
1240 | int jump = count / 5; | 1242 | int jump = count / 5; |
1241 | QListViewItem* cn; | 1243 | QListViewItem* cn; |
1242 | cn = currentItem(); | 1244 | cn = currentItem(); |
1243 | if ( ! cn ) | 1245 | if ( ! cn ) |
1244 | return; | 1246 | return; |
1245 | if ( jump == 0 ) | 1247 | if ( jump == 0 ) |
1246 | jump = 1; | 1248 | jump = 1; |
1247 | while ( jump && cn->itemAbove ()) { | 1249 | while ( jump && cn->itemAbove ()) { |
1248 | cn = cn->itemAbove (); | 1250 | cn = cn->itemAbove (); |
1249 | --jump; | 1251 | --jump; |
1250 | } | 1252 | } |
1251 | setCurrentItem ( cn ); | 1253 | setCurrentItem ( cn ); |
1252 | ensureItemVisible ( cn ); | 1254 | ensureItemVisible ( cn ); |
1253 | } else | 1255 | } else |
1254 | QListView::keyPressEvent ( e ) ; | 1256 | QListView::keyPressEvent ( e ) ; |
1255 | e->accept(); | 1257 | e->accept(); |
1256 | break; | 1258 | break; |
1257 | case Qt::Key_I: { | 1259 | case Qt::Key_I: { |
1258 | QListViewItem* cn; | 1260 | QListViewItem* cn; |
1259 | cn = currentItem(); | 1261 | cn = currentItem(); |
1260 | if ( cn ) { | 1262 | if ( cn ) { |
1261 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1263 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1262 | if ( ci ){ | 1264 | if ( ci ){ |
1263 | //emit showIncidence( ci->data()); | 1265 | //emit showIncidence( ci->data()); |
1264 | cn = cn->nextSibling(); | 1266 | cn = cn->nextSibling(); |
1265 | if ( cn ) { | 1267 | if ( cn ) { |
1266 | setCurrentItem ( cn ); | 1268 | setCurrentItem ( cn ); |
1267 | ensureItemVisible ( cn ); | 1269 | ensureItemVisible ( cn ); |
1268 | } | 1270 | } |
1269 | emit showIncidence( ci->data()); | 1271 | emit showIncidence( ci->data()); |
1270 | } | 1272 | } |
1271 | } | 1273 | } |
1272 | e->accept(); | 1274 | e->accept(); |
1273 | } | 1275 | } |
1274 | break; | 1276 | break; |
1275 | case Qt::Key_Return: | 1277 | case Qt::Key_Return: |
1276 | case Qt::Key_Enter: | 1278 | case Qt::Key_Enter: |
1277 | { | 1279 | { |
1278 | QListViewItem* cn; | 1280 | QListViewItem* cn; |
1279 | cn = currentItem(); | 1281 | cn = currentItem(); |
1280 | if ( cn ) { | 1282 | if ( cn ) { |
1281 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1283 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1282 | if ( ci ){ | 1284 | if ( ci ){ |
1283 | if ( e->state() == ShiftButton ) | 1285 | if ( e->state() == ShiftButton ) |
1284 | ci->setSelected( false ); | 1286 | ci->setSelected( false ); |
1285 | else | 1287 | else |
1286 | ci->setSelected( true ); | 1288 | ci->setSelected( true ); |
1287 | cn = cn->nextSibling(); | 1289 | cn = cn->nextSibling(); |
1288 | if ( cn ) { | 1290 | if ( cn ) { |
1289 | setCurrentItem ( cn ); | 1291 | setCurrentItem ( cn ); |
1290 | ensureItemVisible ( cn ); | 1292 | ensureItemVisible ( cn ); |
1291 | } | 1293 | } |
1292 | } | 1294 | } |
1293 | } | 1295 | } |
1294 | e->accept(); | 1296 | e->accept(); |
1295 | } | 1297 | } |
1296 | break; | 1298 | break; |
1297 | default: | 1299 | default: |
1298 | e->ignore(); | 1300 | e->ignore(); |
1299 | } | 1301 | } |
1300 | } | 1302 | } |
1301 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1303 | KOListViewListView::KOListViewListView(KOListView * lv ) |
1302 | : KListView( lv, "kolistlistview", false ) | 1304 | : KListView( lv, "kolistlistview", false ) |
1303 | { | 1305 | { |
1304 | mYMousePos = 0; | 1306 | mYMousePos = 0; |
1305 | mPopupTimer = new QTimer(this); | 1307 | mPopupTimer = new QTimer(this); |
1306 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 1308 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
1307 | #ifndef DESKTOP_VERSION | 1309 | #ifndef DESKTOP_VERSION |
1308 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 1310 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
1309 | #endif | 1311 | #endif |
1310 | setSelectionMode( QListView::Multi ); | 1312 | setSelectionMode( QListView::Multi ); |
1311 | setMultiSelection( true); | 1313 | setMultiSelection( true); |
1312 | } | 1314 | } |
1313 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) | 1315 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) |
1314 | { | 1316 | { |
1315 | QListViewItem *qitem = firstChild (); | 1317 | QListViewItem *qitem = firstChild (); |
1316 | while ( qitem ) { | 1318 | while ( qitem ) { |
1317 | if ( qitem->isSelected() && item != qitem ) | 1319 | if ( qitem->isSelected() && item != qitem ) |
1318 | return true; | 1320 | return true; |
1319 | qitem = qitem->nextSibling(); | 1321 | qitem = qitem->nextSibling(); |
1320 | } | 1322 | } |
1321 | return false; | 1323 | return false; |
1322 | } | 1324 | } |
1323 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1325 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1324 | { | 1326 | { |
1325 | if (!e) return; | 1327 | if (!e) return; |
1326 | QPoint vp = contentsToViewport(e->pos()); | 1328 | QPoint vp = contentsToViewport(e->pos()); |
1327 | QListViewItem *item = itemAt(vp); | 1329 | QListViewItem *item = itemAt(vp); |
1328 | if (!item) { | 1330 | if (!item) { |
1329 | emit newEvent(); | 1331 | emit newEvent(); |
1330 | return; | 1332 | return; |
1331 | } | 1333 | } |
1332 | KListView::contentsMouseDoubleClickEvent(e); | 1334 | KListView::contentsMouseDoubleClickEvent(e); |
1333 | } | 1335 | } |
1334 | #if 0 | 1336 | #if 0 |
1335 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1337 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1336 | { | 1338 | { |
1337 | //qDebug("contentsMousePressEvent++++ "); | 1339 | //qDebug("contentsMousePressEvent++++ "); |
1338 | KListView::contentsMousePressEvent( e ); | 1340 | KListView::contentsMousePressEvent( e ); |
1339 | if ( e->button() == RightButton ) { | 1341 | if ( e->button() == RightButton ) { |
1340 | QListViewItem* ci = currentItem(); | 1342 | QListViewItem* ci = currentItem(); |
1341 | clearSelection () ; | 1343 | clearSelection () ; |
1342 | if ( ci ) | 1344 | if ( ci ) |
1343 | ci->setSelected( true ); | 1345 | ci->setSelected( true ); |
1344 | } | 1346 | } |
1345 | } | 1347 | } |
1346 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1348 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1347 | { | 1349 | { |
1348 | KListView::contentsMouseReleaseEvent(e); | 1350 | KListView::contentsMouseReleaseEvent(e); |
1349 | } | 1351 | } |
1350 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1352 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1351 | { | 1353 | { |
1352 | KListView::contentsMouseMoveEvent(e); | 1354 | KListView::contentsMouseMoveEvent(e); |
1353 | } | 1355 | } |
1354 | #endif | 1356 | #endif |
1355 | void KOListViewListView::popupMenu() | 1357 | void KOListViewListView::popupMenu() |
1356 | { | 1358 | { |
1357 | mPopupTimer->stop(); | 1359 | mPopupTimer->stop(); |
1358 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); | 1360 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); |
1359 | QApplication::postEvent( this->viewport(), e ); | 1361 | QApplication::postEvent( this->viewport(), e ); |
1360 | 1362 | ||
1361 | } | 1363 | } |
1362 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1364 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1363 | { | 1365 | { |
1364 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); | 1366 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); |
1365 | mYMousePos = mapToGlobal( (e->pos())).y(); | 1367 | mYMousePos = mapToGlobal( (e->pos())).y(); |
1366 | if ( e->button() == LeftButton ) { | 1368 | if ( e->button() == LeftButton ) { |
1367 | mPopupTimer->start( 600 ); | 1369 | mPopupTimer->start( 600 ); |
1368 | mEventPos = contentsToViewport(e->pos()); | 1370 | mEventPos = contentsToViewport(e->pos()); |
1369 | mEventGlobalPos = e->globalPos(); | 1371 | mEventGlobalPos = e->globalPos(); |
1370 | } | 1372 | } |
1371 | KListView::contentsMousePressEvent( e ); | 1373 | KListView::contentsMousePressEvent( e ); |
1372 | if ( e->button() == RightButton ) { | 1374 | if ( e->button() == RightButton ) { |
1373 | QListViewItem* ci = currentItem(); | 1375 | QListViewItem* ci = currentItem(); |
1374 | //clearSelection(); | 1376 | //clearSelection(); |
1375 | if ( ci ) | 1377 | if ( ci ) |
1376 | ci->setSelected( true ); | 1378 | ci->setSelected( true ); |
1377 | } | 1379 | } |
1378 | } | 1380 | } |
1379 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1381 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1380 | { | 1382 | { |
1381 | mPopupTimer->stop(); | 1383 | mPopupTimer->stop(); |
1382 | KListView::contentsMouseReleaseEvent(e); | 1384 | KListView::contentsMouseReleaseEvent(e); |
1383 | } | 1385 | } |
1384 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1386 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1385 | { | 1387 | { |
1386 | // qDebug("contentsMouseMoveEv....... "); | 1388 | // qDebug("contentsMouseMoveEv....... "); |
1387 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); | 1389 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); |
1388 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); | 1390 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); |
1389 | if ( diff < 0 ) diff = -diff; | 1391 | if ( diff < 0 ) diff = -diff; |
1390 | if ( diff > 15 ) | 1392 | if ( diff > 15 ) |
1391 | mPopupTimer->stop(); | 1393 | mPopupTimer->stop(); |
1392 | else { | 1394 | else { |
1393 | mEventPos = contentsToViewport(e->pos()); | 1395 | mEventPos = contentsToViewport(e->pos()); |
1394 | mEventGlobalPos = e->globalPos(); | 1396 | mEventGlobalPos = e->globalPos(); |
1395 | } | 1397 | } |
1396 | KListView::contentsMouseMoveEvent(e); | 1398 | KListView::contentsMouseMoveEvent(e); |
1397 | } | 1399 | } |
1398 | 1400 | ||
1399 | #define protected public | 1401 | #define protected public |
1400 | #include <qheader.h> | 1402 | #include <qheader.h> |
1401 | #undef protected | 1403 | #undef protected |
1402 | void KOListViewListView::printList() | 1404 | void KOListViewListView::printList() |
1403 | { | 1405 | { |
1404 | #ifdef DESKTOP_VERSION | 1406 | #ifdef DESKTOP_VERSION |
1405 | KOPrintPrefs pp ( this ); | 1407 | KOPrintPrefs pp ( this ); |
1406 | if (!pp.exec() ) | 1408 | if (!pp.exec() ) |
1407 | return; | 1409 | return; |
1408 | int scaleval = pp.printMode() ; | 1410 | int scaleval = pp.printMode() ; |
1409 | 1411 | ||
1410 | QPrinter printer; | 1412 | QPrinter printer; |
1411 | if (!printer.setup() ) | 1413 | if (!printer.setup() ) |
1412 | return; | 1414 | return; |
1413 | clearSelection (); | 1415 | clearSelection (); |
1414 | QPainter p; | 1416 | QPainter p; |
1415 | p.begin ( &printer ); | 1417 | p.begin ( &printer ); |
1416 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 1418 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
1417 | float dx, dy; | 1419 | float dx, dy; |
1418 | int wid = (m.width() * 9)/10; | 1420 | int wid = (m.width() * 9)/10; |
1419 | dx = (float) wid/(float)contentsWidth (); | 1421 | dx = (float) wid/(float)contentsWidth (); |
1420 | dy = (float)(m.height()) / (float)contentsHeight (); | 1422 | dy = (float)(m.height()) / (float)contentsHeight (); |
1421 | float scale; | 1423 | float scale; |
1422 | // scale to fit the width or height of the paper | 1424 | // scale to fit the width or height of the paper |
1423 | if ( dx < dy ) | 1425 | if ( dx < dy ) |
1424 | scale = dx; | 1426 | scale = dx; |
1425 | else | 1427 | else |
1426 | scale = dy; | 1428 | scale = dy; |
1427 | 1429 | ||
1428 | p.translate( m.width()/10,m.width()/10 ); | 1430 | p.translate( m.width()/10,m.width()/10 ); |
1429 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 1431 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
1430 | p.scale( scale, scale ); | 1432 | p.scale( scale, scale ); |
1431 | } | 1433 | } |
1432 | 1434 | ||
1433 | int cou = header()->count(); | 1435 | int cou = header()->count(); |
1434 | int iii; | 1436 | int iii; |
1435 | QRect rect ( 0,0,0, header()->height()); | 1437 | QRect rect ( 0,0,0, header()->height()); |
1436 | for ( iii = 0; iii < cou; ++iii ) { | 1438 | for ( iii = 0; iii < cou; ++iii ) { |
1437 | rect.setLeft ( header()->sectionPos( iii ) ); | 1439 | rect.setLeft ( header()->sectionPos( iii ) ); |
1438 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); | 1440 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); |
1439 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); | 1441 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); |
1440 | } | 1442 | } |
1441 | p.translate( 0, header()->height()); | 1443 | p.translate( 0, header()->height()); |
1442 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); | 1444 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); |
1443 | p.end(); | 1445 | p.end(); |
1444 | #endif | 1446 | #endif |
1445 | } | 1447 | } |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 138028d..a63297e 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,623 +1,624 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kglobalsettings.h> | 39 | #include <kglobalsettings.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kemailsettings.h> | 43 | #include <kemailsettings.h> |
44 | #include <kstaticdeleter.h> | 44 | #include <kstaticdeleter.h> |
45 | #include <libkdepim/kpimglobalprefs.h> | 45 | #include <libkdepim/kpimglobalprefs.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "mainwindow.h" | 48 | #include "mainwindow.h" |
49 | 49 | ||
50 | KOPrefs *KOPrefs::mInstance = 0; | 50 | KOPrefs *KOPrefs::mInstance = 0; |
51 | static KStaticDeleter<KOPrefs> insd; | 51 | static KStaticDeleter<KOPrefs> insd; |
52 | 52 | ||
53 | KOPrefs::KOPrefs() : | 53 | KOPrefs::KOPrefs() : |
54 | KPimPrefs("korganizerrc") | 54 | KPimPrefs("korganizerrc") |
55 | { | 55 | { |
56 | mGlobalUpdateDisabled = false; | ||
56 | mCategoryColors.setAutoDelete(true); | 57 | mCategoryColors.setAutoDelete(true); |
57 | fillMailDefaults(); | 58 | fillMailDefaults(); |
58 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 59 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
59 | QColor defaultHolidayColor = QColor(255,0,0); | 60 | QColor defaultHolidayColor = QColor(255,0,0); |
60 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 61 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
61 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 62 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
62 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 63 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
63 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 64 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
64 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 65 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
65 | QColor defaultTodoRunColor = QColor(99,194,30); | 66 | QColor defaultTodoRunColor = QColor(99,194,30); |
66 | KPrefs::setCurrentGroup("General"); | 67 | KPrefs::setCurrentGroup("General"); |
67 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 68 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
68 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 69 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
69 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 70 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
70 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 71 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
71 | addItemBool("ShowIconList",&mShowIconList,true); | 72 | addItemBool("ShowIconList",&mShowIconList,true); |
72 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 73 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
73 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 74 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
74 | addItemBool("ShowIconDay6",&mShowIconDay6,true); | 75 | addItemBool("ShowIconDay6",&mShowIconDay6,true); |
75 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 76 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
76 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 77 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
77 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 78 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
78 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 79 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
79 | addItemBool("ShowIconBack",&mShowIconBack,true); | 80 | addItemBool("ShowIconBack",&mShowIconBack,true); |
80 | addItemBool("ShowIconToday",&mShowIconToday,true); | 81 | addItemBool("ShowIconToday",&mShowIconToday,true); |
81 | addItemBool("ShowIconForward",&mShowIconForward,true); | 82 | addItemBool("ShowIconForward",&mShowIconForward,true); |
82 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 83 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
83 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); | 84 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); |
84 | addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); | 85 | addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); |
85 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 86 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
86 | addItemBool("ShowIconNext",&mShowIconNext,true); | 87 | addItemBool("ShowIconNext",&mShowIconNext,true); |
87 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 88 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
88 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 89 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
89 | addItemBool("ShowIconFilter",&mShowIconFilter,false); | 90 | addItemBool("ShowIconFilter",&mShowIconFilter,false); |
90 | addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); | 91 | addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); |
91 | 92 | ||
92 | bool addIcons = false; | 93 | bool addIcons = false; |
93 | #ifdef DESKTOP_VERSION | 94 | #ifdef DESKTOP_VERSION |
94 | addIcons = true; | 95 | addIcons = true; |
95 | #endif | 96 | #endif |
96 | addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); | 97 | addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); |
97 | addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); | 98 | addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); |
98 | addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); | 99 | addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); |
99 | addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); | 100 | addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); |
100 | 101 | ||
101 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); | 102 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); |
102 | 103 | ||
103 | addItemBool("AskForQuit",&mAskForQuit,false); | 104 | addItemBool("AskForQuit",&mAskForQuit,false); |
104 | 105 | ||
105 | #ifndef DESKTOP_VERSION | 106 | #ifndef DESKTOP_VERSION |
106 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 107 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
107 | #else | 108 | #else |
108 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 109 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
109 | #endif | 110 | #endif |
110 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 111 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
111 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 112 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
112 | addItemBool("ToolBarHorV",&mToolBarHorV, true ); | 113 | addItemBool("ToolBarHorV",&mToolBarHorV, true ); |
113 | addItemBool("ToolBarUpV",&mToolBarUpV, false ); | 114 | addItemBool("ToolBarUpV",&mToolBarUpV, false ); |
114 | addItemBool("ToolBarHorN",&mToolBarHorN, true ); | 115 | addItemBool("ToolBarHorN",&mToolBarHorN, true ); |
115 | addItemBool("ToolBarUpN",&mToolBarUpN, false ); | 116 | addItemBool("ToolBarUpN",&mToolBarUpN, false ); |
116 | addItemBool("ToolBarHorF",&mToolBarHorF, true ); | 117 | addItemBool("ToolBarHorF",&mToolBarHorF, true ); |
117 | addItemBool("ToolBarUpF",&mToolBarUpF, false ); | 118 | addItemBool("ToolBarUpF",&mToolBarUpF, false ); |
118 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 119 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
119 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 120 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
120 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 121 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
121 | 122 | ||
122 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 123 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
123 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); | 124 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); |
124 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); | 125 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); |
125 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); | 126 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); |
126 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 127 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
127 | addItemInt("AllDay Size",&mAllDaySize,28); | 128 | addItemInt("AllDay Size",&mAllDaySize,28); |
128 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 129 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
129 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 130 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
130 | 131 | ||
131 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 132 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
132 | addItemStringList("EventSummary User",&mEventSummaryUser); | 133 | addItemStringList("EventSummary User",&mEventSummaryUser); |
133 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 134 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
134 | addItemStringList("JournalSummary User",&mJournalSummaryUser); | 135 | addItemStringList("JournalSummary User",&mJournalSummaryUser); |
135 | 136 | ||
136 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 137 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
137 | addItemBool("Enable Project View",&mEnableProjectView,false); | 138 | addItemBool("Enable Project View",&mEnableProjectView,false); |
138 | addItemBool("Auto Save",&mAutoSave,false); | 139 | addItemBool("Auto Save",&mAutoSave,false); |
139 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 140 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
140 | addItemBool("Confirm Deletes",&mConfirm,true); | 141 | addItemBool("Confirm Deletes",&mConfirm,true); |
141 | addItemString("Archive File",&mArchiveFile); | 142 | addItemString("Archive File",&mArchiveFile); |
142 | addItemString("Html Export File",&mHtmlExportFile, | 143 | addItemString("Html Export File",&mHtmlExportFile, |
143 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 144 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
144 | addItemBool("Html With Save",&mHtmlWithSave,false); | 145 | addItemBool("Html With Save",&mHtmlWithSave,false); |
145 | 146 | ||
146 | KPrefs::setCurrentGroup("Personal Settings"); | 147 | KPrefs::setCurrentGroup("Personal Settings"); |
147 | 148 | ||
148 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 149 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
149 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 150 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
150 | addItemBool("Bcc",&mBcc,false); | 151 | addItemBool("Bcc",&mBcc,false); |
151 | 152 | ||
152 | KPrefs::setCurrentGroup("Time & Date"); | 153 | KPrefs::setCurrentGroup("Time & Date"); |
153 | 154 | ||
154 | 155 | ||
155 | addItemInt("Default Start Time",&mStartTime,10); | 156 | addItemInt("Default Start Time",&mStartTime,10); |
156 | addItemInt("Default Duration",&mDefaultDuration,2); | 157 | addItemInt("Default Duration",&mDefaultDuration,2); |
157 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 158 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
158 | KPrefs::setCurrentGroup("AlarmSettings"); | 159 | KPrefs::setCurrentGroup("AlarmSettings"); |
159 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 160 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
160 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 161 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
161 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 162 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
162 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 163 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
163 | 164 | ||
164 | 165 | ||
165 | KPrefs::setCurrentGroup("Calendar"); | 166 | KPrefs::setCurrentGroup("Calendar"); |
166 | 167 | ||
167 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 168 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
168 | 169 | ||
169 | KPrefs::setCurrentGroup("Fonts"); | 170 | KPrefs::setCurrentGroup("Fonts"); |
170 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 171 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
171 | QFont fon = KGlobalSettings::generalFont(); | 172 | QFont fon = KGlobalSettings::generalFont(); |
172 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); | 173 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); |
173 | addItemFont("MonthView Font",&mMonthViewFont,fon); | 174 | addItemFont("MonthView Font",&mMonthViewFont,fon); |
174 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); | 175 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); |
175 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); | 176 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); |
176 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); | 177 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); |
177 | addItemFont("TodoView Font",&mTodoViewFont,fon); | 178 | addItemFont("TodoView Font",&mTodoViewFont,fon); |
178 | addItemFont("ListView Font",&mListViewFont,fon); | 179 | addItemFont("ListView Font",&mListViewFont,fon); |
179 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); | 180 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); |
180 | addItemFont("EditBox Font",&mEditBoxFont,fon); | 181 | addItemFont("EditBox Font",&mEditBoxFont,fon); |
181 | addItemFont("JournalView Font",&mJornalViewFont,fon); | 182 | addItemFont("JournalView Font",&mJornalViewFont,fon); |
182 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); | 183 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); |
183 | addItemFont("EventView Font",&mEventViewFont,fon); | 184 | addItemFont("EventView Font",&mEventViewFont,fon); |
184 | 185 | ||
185 | KPrefs::setCurrentGroup("RemoteSyncing"); | 186 | KPrefs::setCurrentGroup("RemoteSyncing"); |
186 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 187 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
187 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 188 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
188 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 189 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
189 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 190 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
190 | 191 | ||
191 | #ifdef _WIN32_ | 192 | #ifdef _WIN32_ |
192 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 193 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
193 | #else | 194 | #else |
194 | QString hdp= locateLocal("data","korganizer")+"/"; | 195 | QString hdp= locateLocal("data","korganizer")+"/"; |
195 | #endif | 196 | #endif |
196 | 197 | ||
197 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 198 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
198 | 199 | ||
199 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 200 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
200 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 201 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
201 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 202 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
202 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 203 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
203 | 204 | ||
204 | 205 | ||
205 | KPrefs::setCurrentGroup("Locale"); | 206 | KPrefs::setCurrentGroup("Locale"); |
206 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 207 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
207 | 208 | ||
208 | 209 | ||
209 | KPrefs::setCurrentGroup("Colors"); | 210 | KPrefs::setCurrentGroup("Colors"); |
210 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 211 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
211 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 212 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
212 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 213 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
213 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); | 214 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); |
214 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 215 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
215 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 216 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
216 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 217 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
217 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 218 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
218 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); | 219 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); |
219 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 220 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
220 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 221 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
221 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 222 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
222 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 223 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
223 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 224 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
224 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); | 225 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); |
225 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 226 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
226 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 227 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
227 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 228 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
228 | addItemBool("UseAppColors",&mUseAppColors,false); | 229 | addItemBool("UseAppColors",&mUseAppColors,false); |
229 | 230 | ||
230 | 231 | ||
231 | 232 | ||
232 | KPrefs::setCurrentGroup("Views"); | 233 | KPrefs::setCurrentGroup("Views"); |
233 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); | 234 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); |
234 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); | 235 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); |
235 | addItemInt("Hour Size",&mHourSize,8); | 236 | addItemInt("Hour Size",&mHourSize,8); |
236 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 237 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
237 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 238 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
238 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 239 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
239 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 240 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
240 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 241 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
241 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 242 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
242 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); | 243 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); |
243 | #ifdef DESKTOP_VERION | 244 | #ifdef DESKTOP_VERION |
244 | addItemBool("Enable ToolTips",&mEnableToolTips,true); | 245 | addItemBool("Enable ToolTips",&mEnableToolTips,true); |
245 | #else | 246 | #else |
246 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 247 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
247 | #endif | 248 | #endif |
248 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 249 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
249 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 250 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
250 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 251 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
251 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 252 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
252 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); | 253 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); |
253 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 254 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
254 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 255 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
255 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 256 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
256 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 257 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
257 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; | 258 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; |
258 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); | 259 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); |
259 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 260 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
260 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 261 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
261 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 262 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
262 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 263 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
263 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 264 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
264 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); | 265 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); |
265 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); | 266 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); |
266 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 267 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
267 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 268 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
268 | #ifdef DESKTOP_VERSION | 269 | #ifdef DESKTOP_VERSION |
269 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 270 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
270 | #else | 271 | #else |
271 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 272 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
272 | #endif | 273 | #endif |
273 | addItemInt("Day Begins",&mDayBegins,7); | 274 | addItemInt("Day Begins",&mDayBegins,7); |
274 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 275 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
275 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 276 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
276 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 277 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
277 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 278 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
278 | 279 | ||
279 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 280 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
280 | addItemBool("Full View Month",&mFullViewMonth,true); | 281 | addItemBool("Full View Month",&mFullViewMonth,true); |
281 | addItemBool("Full View Todo",&mFullViewTodo,true); | 282 | addItemBool("Full View Todo",&mFullViewTodo,true); |
282 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 283 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
283 | 284 | ||
284 | addItemInt("Next X Days",&mNextXDays,3); | 285 | addItemInt("Next X Days",&mNextXDays,3); |
285 | 286 | ||
286 | KPrefs::setCurrentGroup("Printer"); | 287 | KPrefs::setCurrentGroup("Printer"); |
287 | 288 | ||
288 | KPrefs::setCurrentGroup("Layout"); | 289 | KPrefs::setCurrentGroup("Layout"); |
289 | 290 | ||
290 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 291 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
291 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 292 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
292 | 293 | ||
293 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 294 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
294 | 295 | ||
295 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 296 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
296 | 297 | ||
297 | KPrefs::setCurrentGroup("Group Scheduling"); | 298 | KPrefs::setCurrentGroup("Group Scheduling"); |
298 | 299 | ||
299 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 300 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
300 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 301 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
301 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 302 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
302 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 303 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
303 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 304 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
304 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 305 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
305 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 306 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
306 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 307 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
307 | 308 | ||
308 | KPrefs::setCurrentGroup( "Editors" ); | 309 | KPrefs::setCurrentGroup( "Editors" ); |
309 | 310 | ||
310 | addItemStringList( "EventTemplates", &mEventTemplates ); | 311 | addItemStringList( "EventTemplates", &mEventTemplates ); |
311 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 312 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
312 | 313 | ||
313 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 314 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
314 | 315 | ||
315 | KPrefs::setCurrentGroup( "ViewOptions" ); | 316 | KPrefs::setCurrentGroup( "ViewOptions" ); |
316 | addItemBool("EVshowDetails",&mEVshowDetails,true); | 317 | addItemBool("EVshowDetails",&mEVshowDetails,true); |
317 | addItemBool("EVshowCreated",&mEVshowCreated,true); | 318 | addItemBool("EVshowCreated",&mEVshowCreated,true); |
318 | addItemBool("EVshowChanged",&mEVshowChanged,true); | 319 | addItemBool("EVshowChanged",&mEVshowChanged,true); |
319 | addItemBool("WTshowDetails",&mWTshowDetails,false); | 320 | addItemBool("WTshowDetails",&mWTshowDetails,false); |
320 | addItemBool("WTshowCreated",&mWTshowCreated,false); | 321 | addItemBool("WTshowCreated",&mWTshowCreated,false); |
321 | addItemBool("WTshowChanged",&mWTshowChanged,false); | 322 | addItemBool("WTshowChanged",&mWTshowChanged,false); |
322 | mCalendars.setAutoDelete( true ); | 323 | mCalendars.setAutoDelete( true ); |
323 | } | 324 | } |
324 | 325 | ||
325 | 326 | ||
326 | KOPrefs::~KOPrefs() | 327 | KOPrefs::~KOPrefs() |
327 | { | 328 | { |
328 | if (mInstance == this) | 329 | if (mInstance == this) |
329 | mInstance = insd.setObject(0); | 330 | mInstance = insd.setObject(0); |
330 | mCalendars.setAutoDelete( true ); | 331 | mCalendars.setAutoDelete( true ); |
331 | mCalendars.clear(); | 332 | mCalendars.clear(); |
332 | //qDebug("KOPrefs::~KOPrefs() "); | 333 | //qDebug("KOPrefs::~KOPrefs() "); |
333 | } | 334 | } |
334 | 335 | ||
335 | 336 | ||
336 | KOPrefs *KOPrefs::instance() | 337 | KOPrefs *KOPrefs::instance() |
337 | { | 338 | { |
338 | if (!mInstance) { | 339 | if (!mInstance) { |
339 | mInstance = insd.setObject(new KOPrefs()); | 340 | mInstance = insd.setObject(new KOPrefs()); |
340 | mInstance->readConfig(); | 341 | mInstance->readConfig(); |
341 | } | 342 | } |
342 | 343 | ||
343 | return mInstance; | 344 | return mInstance; |
344 | } | 345 | } |
345 | 346 | ||
346 | void KOPrefs::usrSetDefaults() | 347 | void KOPrefs::usrSetDefaults() |
347 | { | 348 | { |
348 | 349 | ||
349 | } | 350 | } |
350 | 351 | ||
351 | void KOPrefs::fillMailDefaults() | 352 | void KOPrefs::fillMailDefaults() |
352 | { | 353 | { |
353 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 354 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
354 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 355 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
355 | } | 356 | } |
356 | 357 | ||
357 | void KOPrefs::setTimeZoneIdDefault() | 358 | void KOPrefs::setTimeZoneIdDefault() |
358 | { | 359 | { |
359 | ; | 360 | ; |
360 | } | 361 | } |
361 | 362 | ||
362 | void KOPrefs::setAllDefaults() | 363 | void KOPrefs::setAllDefaults() |
363 | { | 364 | { |
364 | setCategoryDefaults(); | 365 | setCategoryDefaults(); |
365 | mEventSummaryUser = getDefaultList() ; | 366 | mEventSummaryUser = getDefaultList() ; |
366 | mTodoSummaryUser = getDefaultList() ; | 367 | mTodoSummaryUser = getDefaultList() ; |
367 | mJournalSummaryUser = getDefaultList() ; | 368 | mJournalSummaryUser = getDefaultList() ; |
368 | mLocationDefaults = getLocationDefaultList(); | 369 | mLocationDefaults = getLocationDefaultList(); |
369 | } | 370 | } |
370 | 371 | ||
371 | void KOPrefs::setCategoryDefaults() | 372 | void KOPrefs::setCategoryDefaults() |
372 | { | 373 | { |
373 | mCustomCategories.clear(); | 374 | mCustomCategories.clear(); |
374 | mCustomCategories = getDefaultList(); | 375 | mCustomCategories = getDefaultList(); |
375 | 376 | ||
376 | QStringList::Iterator it; | 377 | QStringList::Iterator it; |
377 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 378 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
378 | setCategoryColor(*it,mDefaultCategoryColor); | 379 | setCategoryColor(*it,mDefaultCategoryColor); |
379 | } | 380 | } |
380 | } | 381 | } |
381 | QStringList KOPrefs::getLocationDefaultList() | 382 | QStringList KOPrefs::getLocationDefaultList() |
382 | { | 383 | { |
383 | QStringList retval ; | 384 | QStringList retval ; |
384 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 385 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
385 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") | 386 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") |
386 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 387 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
387 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 388 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
388 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 389 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
389 | 390 | ||
390 | retval.sort(); | 391 | retval.sort(); |
391 | return retval; | 392 | return retval; |
392 | } | 393 | } |
393 | QStringList KOPrefs::getDefaultList() | 394 | QStringList KOPrefs::getDefaultList() |
394 | { | 395 | { |
395 | QStringList retval ; | 396 | QStringList retval ; |
396 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") | 397 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") |
397 | << i18n("Break") | 398 | << i18n("Break") |
398 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") | 399 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") |
399 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") | 400 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") |
400 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") | 401 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") |
401 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") | 402 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") |
402 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") | 403 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") |
403 | << i18n("Vacation") ; | 404 | << i18n("Vacation") ; |
404 | retval.sort(); | 405 | retval.sort(); |
405 | //qDebug("cat %s ", retval.join("-").latin1()); | 406 | //qDebug("cat %s ", retval.join("-").latin1()); |
406 | return retval; | 407 | return retval; |
407 | } | 408 | } |
408 | // << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") | 409 | // << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") |
409 | void KOPrefs::usrReadConfig() | 410 | void KOPrefs::usrReadConfig() |
410 | { | 411 | { |
411 | config()->setGroup("General"); | 412 | config()->setGroup("General"); |
412 | 413 | ||
413 | //qDebug("KOPrefs::usrReadConfig() "); | 414 | //qDebug("KOPrefs::usrReadConfig() "); |
414 | mCustomCategories = config()->readListEntry("Custom Categories"); | 415 | mCustomCategories = config()->readListEntry("Custom Categories"); |
415 | mOldLoadedLanguage = mOldLanguage ; | 416 | mOldLoadedLanguage = mOldLanguage ; |
416 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 417 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
417 | if (mLocationDefaults.isEmpty()) { | 418 | if (mLocationDefaults.isEmpty()) { |
418 | mLocationDefaults = getLocationDefaultList(); | 419 | mLocationDefaults = getLocationDefaultList(); |
419 | } | 420 | } |
420 | 421 | ||
421 | if (mEventSummaryUser.isEmpty()) { | 422 | if (mEventSummaryUser.isEmpty()) { |
422 | mEventSummaryUser = getDefaultList() ; | 423 | mEventSummaryUser = getDefaultList() ; |
423 | } | 424 | } |
424 | if (mTodoSummaryUser.isEmpty()) { | 425 | if (mTodoSummaryUser.isEmpty()) { |
425 | mTodoSummaryUser = getDefaultList() ; | 426 | mTodoSummaryUser = getDefaultList() ; |
426 | } | 427 | } |
427 | 428 | ||
428 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 429 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
429 | 430 | ||
430 | config()->setGroup("Personal Settings"); | 431 | config()->setGroup("Personal Settings"); |
431 | mName = config()->readEntry("user_name",""); | 432 | mName = config()->readEntry("user_name",""); |
432 | mEmail = config()->readEntry("user_email",""); | 433 | mEmail = config()->readEntry("user_email",""); |
433 | fillMailDefaults(); | 434 | fillMailDefaults(); |
434 | 435 | ||
435 | config()->setGroup("Category Colors"); | 436 | config()->setGroup("Category Colors"); |
436 | QStringList::Iterator it; | 437 | QStringList::Iterator it; |
437 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 438 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
438 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 439 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
439 | 440 | ||
440 | } | 441 | } |
441 | KConfig fc (locateLocal("config","kopicalendarrc")); | 442 | KConfig fc (locateLocal("config","kopicalendarrc")); |
442 | fc.setGroup("CC"); | 443 | fc.setGroup("CC"); |
443 | int numCals = fc.readNumEntry("NumberCalendars",0 ); | 444 | int numCals = fc.readNumEntry("NumberCalendars",0 ); |
444 | mNextAvailableCalendar = 1; | 445 | mNextAvailableCalendar = 1; |
445 | if ( numCals == 0 ) { | 446 | if ( numCals == 0 ) { |
446 | KopiCalendarFile *kkf = getNewCalendar(); | 447 | KopiCalendarFile *kkf = getNewCalendar(); |
447 | kkf->isStandard = true; | 448 | kkf->isStandard = true; |
448 | kkf->mName = i18n("Standard"); | 449 | kkf->mName = i18n("Standard"); |
449 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | 450 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); |
450 | } | 451 | } |
451 | while ( mNextAvailableCalendar <= numCals ) { | 452 | while ( mNextAvailableCalendar <= numCals ) { |
452 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); | 453 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); |
453 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); | 454 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); |
454 | KopiCalendarFile *kkf = getNewCalendar(); | 455 | KopiCalendarFile *kkf = getNewCalendar(); |
455 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); | 456 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); |
456 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); | 457 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); |
457 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); | 458 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); |
458 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); | 459 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); |
459 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); | 460 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); |
460 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); | 461 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); |
461 | kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); | 462 | kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); |
462 | kkf->mSavedFileName = fc.readEntry( prefix+"_SavedFileName", kkf->mFileName); | 463 | kkf->mSavedFileName = fc.readEntry( prefix+"_SavedFileName", kkf->mFileName); |
463 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); | 464 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); |
464 | if ( kkf->mCalNumber == 1 ) { | 465 | if ( kkf->mCalNumber == 1 ) { |
465 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | 466 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); |
466 | } | 467 | } |
467 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); | 468 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); |
468 | if ( kkf->mName == i18n("Birthdays") ) { | 469 | if ( kkf->mName == i18n("Birthdays") ) { |
469 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); | 470 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); |
470 | } | 471 | } |
471 | if ( kkf->isRelative ) | 472 | if ( kkf->isRelative ) |
472 | kkf->mFileName = KGlobalSettings::calendarDir() + kkf->mSavedFileName; | 473 | kkf->mFileName = KGlobalSettings::calendarDir() + kkf->mSavedFileName; |
473 | } | 474 | } |
474 | 475 | ||
475 | KPimPrefs::usrReadConfig(); | 476 | KPimPrefs::usrReadConfig(); |
476 | } | 477 | } |
477 | 478 | ||
478 | KopiCalendarFile * KOPrefs::getCalendar( int num ) | 479 | KopiCalendarFile * KOPrefs::getCalendar( int num ) |
479 | { | 480 | { |
480 | return mDefCalColors[num-1]; | 481 | return mDefCalColors[num-1]; |
481 | } | 482 | } |
482 | 483 | ||
483 | KopiCalendarFile * KOPrefs::getNewCalendar() | 484 | KopiCalendarFile * KOPrefs::getNewCalendar() |
484 | { | 485 | { |
485 | KopiCalendarFile * kkf = new KopiCalendarFile(); | 486 | KopiCalendarFile * kkf = new KopiCalendarFile(); |
486 | kkf->mCalNumber = mNextAvailableCalendar; | 487 | kkf->mCalNumber = mNextAvailableCalendar; |
487 | mDefCalColors.resize( mNextAvailableCalendar ); | 488 | mDefCalColors.resize( mNextAvailableCalendar ); |
488 | mDefCalColors[mNextAvailableCalendar-1] = kkf; | 489 | mDefCalColors[mNextAvailableCalendar-1] = kkf; |
489 | ++mNextAvailableCalendar; | 490 | ++mNextAvailableCalendar; |
490 | kkf->mDefaultColor = mEventColor; | 491 | kkf->mDefaultColor = mEventColor; |
491 | kkf->mName = i18n("New Calendar"); | 492 | kkf->mName = i18n("New Calendar"); |
492 | mCalendars.append( kkf ); | 493 | mCalendars.append( kkf ); |
493 | return kkf; | 494 | return kkf; |
494 | } | 495 | } |
495 | void KOPrefs::deleteCalendar( int num ) | 496 | void KOPrefs::deleteCalendar( int num ) |
496 | { | 497 | { |
497 | KopiCalendarFile * kkf = mCalendars.first(); | 498 | KopiCalendarFile * kkf = mCalendars.first(); |
498 | while ( kkf ) { | 499 | while ( kkf ) { |
499 | if ( kkf->mCalNumber == num ) { | 500 | if ( kkf->mCalNumber == num ) { |
500 | qDebug("KOPrefs::deleteCalendar %d ", num ); | 501 | qDebug("KOPrefs::deleteCalendar %d ", num ); |
501 | mCalendars.remove( kkf ); | 502 | mCalendars.remove( kkf ); |
502 | delete kkf; | 503 | delete kkf; |
503 | return; | 504 | return; |
504 | } | 505 | } |
505 | kkf = mCalendars.next(); | 506 | kkf = mCalendars.next(); |
506 | } | 507 | } |
507 | } | 508 | } |
508 | int KOPrefs::getCalendarID( const QString & name ) | 509 | int KOPrefs::getCalendarID( const QString & name ) |
509 | { | 510 | { |
510 | KopiCalendarFile * kkf = mCalendars.first(); | 511 | KopiCalendarFile * kkf = mCalendars.first(); |
511 | while ( kkf ) { | 512 | while ( kkf ) { |
512 | if ( name == kkf->mName) | 513 | if ( name == kkf->mName) |
513 | return kkf->mCalNumber; | 514 | return kkf->mCalNumber; |
514 | kkf = mCalendars.next(); | 515 | kkf = mCalendars.next(); |
515 | } | 516 | } |
516 | return 1; | 517 | return 1; |
517 | } | 518 | } |
518 | QString KOPrefs::calName( int calNum) const | 519 | QString KOPrefs::calName( int calNum) const |
519 | { | 520 | { |
520 | return (mDefCalColors[calNum-1])->mName; | 521 | return (mDefCalColors[calNum-1])->mName; |
521 | } | 522 | } |
522 | QColor KOPrefs::defaultColor( int calNum ) const | 523 | QColor KOPrefs::defaultColor( int calNum ) const |
523 | { | 524 | { |
524 | if ( calNum == 1 ) return mEventColor; | 525 | if ( calNum == 1 ) return mEventColor; |
525 | return (mDefCalColors[calNum-1])->mDefaultColor; | 526 | return (mDefCalColors[calNum-1])->mDefaultColor; |
526 | } | 527 | } |
527 | void KOPrefs::usrWriteConfig() | 528 | void KOPrefs::usrWriteConfig() |
528 | { | 529 | { |
529 | config()->setGroup("General"); | 530 | config()->setGroup("General"); |
530 | config()->writeEntry("Custom Categories",mCustomCategories); | 531 | config()->writeEntry("Custom Categories",mCustomCategories); |
531 | 532 | ||
532 | config()->setGroup("Personal Settings"); | 533 | config()->setGroup("Personal Settings"); |
533 | config()->writeEntry("user_name",mName); | 534 | config()->writeEntry("user_name",mName); |
534 | config()->writeEntry("user_email",mEmail); | 535 | config()->writeEntry("user_email",mEmail); |
535 | 536 | ||
536 | config()->setGroup("Category Colors"); | 537 | config()->setGroup("Category Colors"); |
537 | QDictIterator<QColor> it(mCategoryColors); | 538 | QDictIterator<QColor> it(mCategoryColors); |
538 | while (it.current()) { | 539 | while (it.current()) { |
539 | config()->writeEntry(it.currentKey(),*(it.current())); | 540 | config()->writeEntry(it.currentKey(),*(it.current())); |
540 | ++it; | 541 | ++it; |
541 | } | 542 | } |
542 | KConfig fc (locateLocal("config","kopicalendarrc")); | 543 | KConfig fc (locateLocal("config","kopicalendarrc")); |
543 | fc.setGroup("CC"); | 544 | fc.setGroup("CC"); |
544 | fc.deleteGroup( "CC"); | 545 | fc.deleteGroup( "CC"); |
545 | fc.setGroup("CC"); | 546 | fc.setGroup("CC"); |
546 | fc.writeEntry("NumberCalendars",mCalendars.count()); | 547 | fc.writeEntry("NumberCalendars",mCalendars.count()); |
547 | int numCal = 1; | 548 | int numCal = 1; |
548 | int writeCal = 0; | 549 | int writeCal = 0; |
549 | while ( numCal < mNextAvailableCalendar ) { | 550 | while ( numCal < mNextAvailableCalendar ) { |
550 | KopiCalendarFile * kkf = mCalendars.first(); | 551 | KopiCalendarFile * kkf = mCalendars.first(); |
551 | while ( kkf ) { | 552 | while ( kkf ) { |
552 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); | 553 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); |
553 | if ( kkf->mCalNumber == numCal ) { | 554 | if ( kkf->mCalNumber == numCal ) { |
554 | ++writeCal; | 555 | ++writeCal; |
555 | //qDebug("Write calendar %d %d ", numCal , writeCal); | 556 | //qDebug("Write calendar %d %d ", numCal , writeCal); |
556 | QString prefix = "Cal_" + QString::number( writeCal ); | 557 | QString prefix = "Cal_" + QString::number( writeCal ); |
557 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); | 558 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); |
558 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); | 559 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); |
559 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); | 560 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); |
560 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); | 561 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); |
561 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); | 562 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); |
562 | fc.writeEntry( prefix+"_Name", kkf->mName); | 563 | fc.writeEntry( prefix+"_Name", kkf->mName); |
563 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); | 564 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); |
564 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); | 565 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); |
565 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); | 566 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); |
566 | } | 567 | } |
567 | kkf = mCalendars.next(); | 568 | kkf = mCalendars.next(); |
568 | } | 569 | } |
569 | ++numCal; | 570 | ++numCal; |
570 | } | 571 | } |
571 | fc.sync(); | 572 | fc.sync(); |
572 | KPimPrefs::usrWriteConfig(); | 573 | KPimPrefs::usrWriteConfig(); |
573 | } | 574 | } |
574 | 575 | ||
575 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 576 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
576 | { | 577 | { |
577 | mCategoryColors.replace(cat,new QColor(color)); | 578 | mCategoryColors.replace(cat,new QColor(color)); |
578 | } | 579 | } |
579 | 580 | ||
580 | QColor *KOPrefs::categoryColor(QString cat) | 581 | QColor *KOPrefs::categoryColor(QString cat) |
581 | { | 582 | { |
582 | QColor *color = 0; | 583 | QColor *color = 0; |
583 | 584 | ||
584 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 585 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
585 | 586 | ||
586 | if (color) return color; | 587 | if (color) return color; |
587 | else return &mDefaultCategoryColor; | 588 | else return &mDefaultCategoryColor; |
588 | } | 589 | } |
589 | 590 | ||
590 | void KOPrefs::setFullName(const QString &name) | 591 | void KOPrefs::setFullName(const QString &name) |
591 | { | 592 | { |
592 | mName = name; | 593 | mName = name; |
593 | } | 594 | } |
594 | 595 | ||
595 | void KOPrefs::setEmail(const QString &email) | 596 | void KOPrefs::setEmail(const QString &email) |
596 | { | 597 | { |
597 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 598 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
598 | mEmail = email; | 599 | mEmail = email; |
599 | } | 600 | } |
600 | 601 | ||
601 | QString KOPrefs::fullName() | 602 | QString KOPrefs::fullName() |
602 | { | 603 | { |
603 | if (mEmailControlCenter) { | 604 | if (mEmailControlCenter) { |
604 | KEMailSettings settings; | 605 | KEMailSettings settings; |
605 | return settings.getSetting(KEMailSettings::RealName); | 606 | return settings.getSetting(KEMailSettings::RealName); |
606 | } else { | 607 | } else { |
607 | return mName; | 608 | return mName; |
608 | } | 609 | } |
609 | } | 610 | } |
610 | 611 | ||
611 | QString KOPrefs::email() | 612 | QString KOPrefs::email() |
612 | { | 613 | { |
613 | if (mEmailControlCenter) { | 614 | if (mEmailControlCenter) { |
614 | KEMailSettings settings; | 615 | KEMailSettings settings; |
615 | return settings.getSetting(KEMailSettings::EmailAddress); | 616 | return settings.getSetting(KEMailSettings::EmailAddress); |
616 | } else { | 617 | } else { |
617 | return mEmail; | 618 | return mEmail; |
618 | } | 619 | } |
619 | } | 620 | } |
620 | KConfig* KOPrefs::getConfig() | 621 | KConfig* KOPrefs::getConfig() |
621 | { | 622 | { |
622 | return config(); | 623 | return config(); |
623 | } | 624 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 0779e27..392360d 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,362 +1,363 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #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 | mSavedFileName = "icalfile.ics"; | 57 | mSavedFileName = "icalfile.ics"; |
58 | mCalNumber = 0; | 58 | mCalNumber = 0; |
59 | mDefaultColor = Qt::red; | 59 | mDefaultColor = Qt::red; |
60 | mErrorOnLoad = false; | 60 | mErrorOnLoad = false; |
61 | isRelative = false; | 61 | isRelative = false; |
62 | } | 62 | } |
63 | bool isStandard; | 63 | bool isStandard; |
64 | bool isEnabled; | 64 | bool isEnabled; |
65 | bool isAlarmEnabled; | 65 | bool isAlarmEnabled; |
66 | bool isReadOnly; | 66 | bool isReadOnly; |
67 | bool mErrorOnLoad; | 67 | bool mErrorOnLoad; |
68 | QString mName; | 68 | QString mName; |
69 | QString mFileName; | 69 | QString mFileName; |
70 | QString mSavedFileName; | 70 | QString mSavedFileName; |
71 | bool isRelative; | 71 | bool isRelative; |
72 | int mCalNumber; | 72 | int mCalNumber; |
73 | QColor mDefaultColor; | 73 | QColor mDefaultColor; |
74 | QDateTime mLoadDt; | 74 | QDateTime mLoadDt; |
75 | }; | 75 | }; |
76 | class KOPrefs : public KPimPrefs | 76 | class KOPrefs : public KPimPrefs |
77 | { | 77 | { |
78 | public: | 78 | public: |
79 | enum { FormatVCalendar, FormatICalendar }; | 79 | enum { FormatVCalendar, FormatICalendar }; |
80 | enum { MailClientKMail, MailClientSendmail }; | 80 | enum { MailClientKMail, MailClientSendmail }; |
81 | enum { IMIPDummy, IMIPKMail }; | 81 | enum { IMIPDummy, IMIPKMail }; |
82 | enum { IMIPOutbox, IMIPdirectsend }; | 82 | enum { IMIPOutbox, IMIPdirectsend }; |
83 | enum { neverAuto, addressbookAuto, selectedAuto }; | 83 | enum { neverAuto, addressbookAuto, selectedAuto }; |
84 | enum { standardDestination, askDestination }; | 84 | enum { standardDestination, askDestination }; |
85 | 85 | ||
86 | virtual ~KOPrefs(); | 86 | virtual ~KOPrefs(); |
87 | 87 | ||
88 | /** Get instance of KOPrefs. It is made sure that there is only one | 88 | /** Get instance of KOPrefs. It is made sure that there is only one |
89 | instance. */ | 89 | instance. */ |
90 | static KOPrefs *instance(); | 90 | static KOPrefs *instance(); |
91 | 91 | ||
92 | /** Set preferences to default values */ | 92 | /** Set preferences to default values */ |
93 | void usrSetDefaults(); | 93 | void usrSetDefaults(); |
94 | 94 | ||
95 | /** Read preferences from config file */ | 95 | /** Read preferences from config file */ |
96 | void usrReadConfig(); | 96 | void usrReadConfig(); |
97 | 97 | ||
98 | /** Write preferences to config file */ | 98 | /** Write preferences to config file */ |
99 | void usrWriteConfig(); | 99 | void usrWriteConfig(); |
100 | void setCategoryDefaults(); | 100 | void setCategoryDefaults(); |
101 | void setAllDefaults(); | 101 | void setAllDefaults(); |
102 | KopiCalendarFile * getNewCalendar(); | 102 | KopiCalendarFile * getNewCalendar(); |
103 | KopiCalendarFile * getCalendar( int ); | 103 | KopiCalendarFile * getCalendar( int ); |
104 | void deleteCalendar( int ); | 104 | void deleteCalendar( int ); |
105 | QColor defaultColor( int ) const; | 105 | QColor defaultColor( int ) const; |
106 | QString calName( int ) const; | 106 | QString calName( int ) const; |
107 | int getCalendarID( const QString & name ); | 107 | int getCalendarID( const QString & name ); |
108 | protected: | 108 | protected: |
109 | void setTimeZoneIdDefault(); | 109 | void setTimeZoneIdDefault(); |
110 | 110 | ||
111 | /** Fill empty mail fields with default values. */ | 111 | /** Fill empty mail fields with default values. */ |
112 | void fillMailDefaults(); | 112 | void fillMailDefaults(); |
113 | 113 | ||
114 | private: | 114 | private: |
115 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 115 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
116 | object. */ | 116 | object. */ |
117 | KOPrefs(); | 117 | KOPrefs(); |
118 | 118 | ||
119 | static KOPrefs *mInstance; | 119 | static KOPrefs *mInstance; |
120 | QStringList getDefaultList(); | 120 | QStringList getDefaultList(); |
121 | QStringList getLocationDefaultList(); | 121 | QStringList getLocationDefaultList(); |
122 | public: | 122 | public: |
123 | // preferences data | 123 | // preferences data |
124 | KConfig* getConfig(); | 124 | KConfig* getConfig(); |
125 | void setFullName(const QString &); | 125 | void setFullName(const QString &); |
126 | QString fullName(); | 126 | QString fullName(); |
127 | void setEmail(const QString &); | 127 | void setEmail(const QString &); |
128 | QString email(); | 128 | QString email(); |
129 | 129 | ||
130 | QString mAdditional; | 130 | QString mAdditional; |
131 | 131 | ||
132 | bool mEmailControlCenter; | 132 | bool mEmailControlCenter; |
133 | 133 | ||
134 | bool mBcc; | 134 | bool mBcc; |
135 | bool mAutoSave; | 135 | bool mAutoSave; |
136 | int mAutoSaveInterval; | 136 | int mAutoSaveInterval; |
137 | bool mConfirm; | 137 | bool mConfirm; |
138 | 138 | ||
139 | bool mEnableGroupScheduling; | 139 | bool mEnableGroupScheduling; |
140 | bool mEnableProjectView; | 140 | bool mEnableProjectView; |
141 | 141 | ||
142 | int mDefaultFormat; | 142 | int mDefaultFormat; |
143 | int mMailClient; | 143 | int mMailClient; |
144 | 144 | ||
145 | int mStartTime; | 145 | int mStartTime; |
146 | int mDefaultDuration; | 146 | int mDefaultDuration; |
147 | int mAlarmTime; | 147 | int mAlarmTime; |
148 | 148 | ||
149 | int mWorkingHoursStart; | 149 | int mWorkingHoursStart; |
150 | int mWorkingHoursEnd; | 150 | int mWorkingHoursEnd; |
151 | bool mExcludeHolidays; | 151 | bool mExcludeHolidays; |
152 | bool mExcludeSaturdays; | 152 | bool mExcludeSaturdays; |
153 | bool mMarcusBainsShowSeconds; | 153 | bool mMarcusBainsShowSeconds; |
154 | 154 | ||
155 | QFont mTimeBarFont; | 155 | QFont mTimeBarFont; |
156 | QFont mMonthViewFont; | 156 | QFont mMonthViewFont; |
157 | QFont mAgendaViewFont; | 157 | QFont mAgendaViewFont; |
158 | QFont mMarcusBainsFont; | 158 | QFont mMarcusBainsFont; |
159 | QFont mTimeLabelsFont; | 159 | QFont mTimeLabelsFont; |
160 | QFont mTodoViewFont; | 160 | QFont mTodoViewFont; |
161 | QFont mListViewFont; | 161 | QFont mListViewFont; |
162 | QFont mDateNavigatorFont; | 162 | QFont mDateNavigatorFont; |
163 | QFont mEditBoxFont; | 163 | QFont mEditBoxFont; |
164 | QFont mJornalViewFont; | 164 | QFont mJornalViewFont; |
165 | QFont mWhatsNextFont; | 165 | QFont mWhatsNextFont; |
166 | QFont mEventViewFont; | 166 | QFont mEventViewFont; |
167 | 167 | ||
168 | 168 | ||
169 | 169 | ||
170 | 170 | ||
171 | QColor mHolidayColor; | 171 | QColor mHolidayColor; |
172 | QColor mHighlightColor; | 172 | QColor mHighlightColor; |
173 | QColor mEventColor; | 173 | QColor mEventColor; |
174 | QColor mTodoDoneColor; | 174 | QColor mTodoDoneColor; |
175 | QColor mAgendaBgColor; | 175 | QColor mAgendaBgColor; |
176 | QColor mWorkingHoursColor; | 176 | QColor mWorkingHoursColor; |
177 | QColor mTodoDueTodayColor; | 177 | QColor mTodoDueTodayColor; |
178 | QColor mTodoOverdueColor; | 178 | QColor mTodoOverdueColor; |
179 | QColor mTodoRunColor; | 179 | QColor mTodoRunColor; |
180 | QColor mMonthViewEvenColor; | 180 | QColor mMonthViewEvenColor; |
181 | QColor mMonthViewOddColor; | 181 | QColor mMonthViewOddColor; |
182 | QColor mMonthViewHolidayColor; | 182 | QColor mMonthViewHolidayColor; |
183 | bool mMonthViewUsesDayColors; | 183 | bool mMonthViewUsesDayColors; |
184 | bool mMonthViewSatSunTog; | 184 | bool mMonthViewSatSunTog; |
185 | bool mMonthViewWeek; | 185 | bool mMonthViewWeek; |
186 | QColor mAppColor1; | 186 | QColor mAppColor1; |
187 | QColor mAppColor2; | 187 | QColor mAppColor2; |
188 | bool mUseAppColors; | 188 | bool mUseAppColors; |
189 | 189 | ||
190 | int mDayBegins; | 190 | int mDayBegins; |
191 | int mHourSize; | 191 | int mHourSize; |
192 | int mAllDaySize; | 192 | int mAllDaySize; |
193 | bool mShowFullMenu; | 193 | bool mShowFullMenu; |
194 | bool mDailyRecur; | 194 | bool mDailyRecur; |
195 | bool mWeeklyRecur; | 195 | bool mWeeklyRecur; |
196 | bool mMonthDailyRecur; | 196 | bool mMonthDailyRecur; |
197 | bool mMonthWeeklyRecur; | 197 | bool mMonthWeeklyRecur; |
198 | bool mMonthShowIcons; | 198 | bool mMonthShowIcons; |
199 | bool mMonthShowTimes; | 199 | bool mMonthShowTimes; |
200 | bool mMonthShowShort; | 200 | bool mMonthShowShort; |
201 | bool mEnableToolTips; | 201 | bool mEnableToolTips; |
202 | bool mEnableMonthScroll; | 202 | bool mEnableMonthScroll; |
203 | bool mFullViewMonth; | 203 | bool mFullViewMonth; |
204 | bool mMonthViewUsesCategoryColor; | 204 | bool mMonthViewUsesCategoryColor; |
205 | bool mFullViewTodo; | 205 | bool mFullViewTodo; |
206 | bool mShowCompletedTodo; | 206 | bool mShowCompletedTodo; |
207 | bool mMarcusBainsEnabled; | 207 | bool mMarcusBainsEnabled; |
208 | int mNextXDays; | 208 | int mNextXDays; |
209 | int mWhatsNextDays; | 209 | int mWhatsNextDays; |
210 | int mWhatsNextPrios; | 210 | int mWhatsNextPrios; |
211 | bool mEnableQuickTodo; | 211 | bool mEnableQuickTodo; |
212 | 212 | ||
213 | bool mCompactDialogs; | 213 | bool mCompactDialogs; |
214 | bool mVerticalScreen; | 214 | bool mVerticalScreen; |
215 | 215 | ||
216 | bool mShowIconNewTodo; | 216 | bool mShowIconNewTodo; |
217 | bool mShowIconNewEvent; | 217 | bool mShowIconNewEvent; |
218 | bool mShowIconSearch; | 218 | bool mShowIconSearch; |
219 | bool mShowIconList; | 219 | bool mShowIconList; |
220 | bool mShowIconDay1; | 220 | bool mShowIconDay1; |
221 | bool mShowIconDay5; | 221 | bool mShowIconDay5; |
222 | bool mShowIconDay6; | 222 | bool mShowIconDay6; |
223 | bool mShowIconDay7; | 223 | bool mShowIconDay7; |
224 | bool mShowIconMonth; | 224 | bool mShowIconMonth; |
225 | bool mShowIconTodoview; | 225 | bool mShowIconTodoview; |
226 | bool mShowIconBackFast; | 226 | bool mShowIconBackFast; |
227 | bool mShowIconBack; | 227 | bool mShowIconBack; |
228 | bool mShowIconToday; | 228 | bool mShowIconToday; |
229 | bool mShowIconForward; | 229 | bool mShowIconForward; |
230 | bool mShowIconForwardFast; | 230 | bool mShowIconForwardFast; |
231 | bool mShowIconWhatsThis; | 231 | bool mShowIconWhatsThis; |
232 | bool mShowIconWeekNum; | 232 | bool mShowIconWeekNum; |
233 | bool mShowIconNextDays; | 233 | bool mShowIconNextDays; |
234 | bool mShowIconNext; | 234 | bool mShowIconNext; |
235 | bool mShowIconJournal; | 235 | bool mShowIconJournal; |
236 | bool mShowIconFilter; | 236 | bool mShowIconFilter; |
237 | bool mShowIconOnetoolbar; | 237 | bool mShowIconOnetoolbar; |
238 | bool mShowIconNavigator; | 238 | bool mShowIconNavigator; |
239 | bool mShowIconAllday; | 239 | bool mShowIconAllday; |
240 | bool mShowIconFilterview; | 240 | bool mShowIconFilterview; |
241 | bool mShowIconToggleFull; | 241 | bool mShowIconToggleFull; |
242 | 242 | ||
243 | bool mShowIconStretch; | 243 | bool mShowIconStretch; |
244 | 244 | ||
245 | bool mToolBarHor; | 245 | bool mToolBarHor; |
246 | bool mToolBarUp; | 246 | bool mToolBarUp; |
247 | bool mToolBarHorV; | 247 | bool mToolBarHorV; |
248 | bool mToolBarUpV; | 248 | bool mToolBarUpV; |
249 | bool mToolBarHorN; | 249 | bool mToolBarHorN; |
250 | bool mToolBarUpN; | 250 | bool mToolBarUpN; |
251 | bool mToolBarHorF; | 251 | bool mToolBarHorF; |
252 | bool mToolBarUpF; | 252 | bool mToolBarUpF; |
253 | bool mToolBarMiniIcons; | 253 | bool mToolBarMiniIcons; |
254 | 254 | ||
255 | bool mAskForQuit; | 255 | bool mAskForQuit; |
256 | bool mUsePassWd; | 256 | bool mUsePassWd; |
257 | bool mShowSyncEvents; | 257 | bool mShowSyncEvents; |
258 | bool mShowTodoInAgenda; | 258 | bool mShowTodoInAgenda; |
259 | bool mShowCompletedTodoInAgenda; | 259 | bool mShowCompletedTodoInAgenda; |
260 | bool mShowTimeInAgenda; | 260 | bool mShowTimeInAgenda; |
261 | bool mHideNonStartedTodos; | 261 | bool mHideNonStartedTodos; |
262 | 262 | ||
263 | bool mBlockPopupMenu; | 263 | bool mBlockPopupMenu; |
264 | 264 | ||
265 | int mLastSyncTime; | 265 | int mLastSyncTime; |
266 | void setCategoryColor(QString cat,const QColor & color); | 266 | void setCategoryColor(QString cat,const QColor & color); |
267 | QColor *categoryColor(QString cat); | 267 | QColor *categoryColor(QString cat); |
268 | 268 | ||
269 | QString mArchiveFile; | 269 | QString mArchiveFile; |
270 | QString mHtmlExportFile; | 270 | QString mHtmlExportFile; |
271 | bool mHtmlWithSave; | 271 | bool mHtmlWithSave; |
272 | 272 | ||
273 | QStringList mSelectedPlugins; | 273 | QStringList mSelectedPlugins; |
274 | 274 | ||
275 | QString mLastImportFile; | 275 | QString mLastImportFile; |
276 | QString mLastVcalFile; | 276 | QString mLastVcalFile; |
277 | QString mLastSaveFile; | 277 | QString mLastSaveFile; |
278 | QString mLastLoadFile; | 278 | QString mLastLoadFile; |
279 | 279 | ||
280 | 280 | ||
281 | QString mDefaultAlarmFile; | 281 | QString mDefaultAlarmFile; |
282 | int mIMIPScheduler; | 282 | int mIMIPScheduler; |
283 | int mIMIPSend; | 283 | int mIMIPSend; |
284 | QStringList mAdditionalMails; | 284 | QStringList mAdditionalMails; |
285 | int mIMIPAutoRefresh; | 285 | int mIMIPAutoRefresh; |
286 | int mIMIPAutoInsertReply; | 286 | int mIMIPAutoInsertReply; |
287 | int mIMIPAutoInsertRequest; | 287 | int mIMIPAutoInsertRequest; |
288 | int mIMIPAutoFreeBusy; | 288 | int mIMIPAutoFreeBusy; |
289 | int mIMIPAutoFreeBusyReply; | 289 | int mIMIPAutoFreeBusyReply; |
290 | 290 | ||
291 | QStringList mTodoTemplates; | 291 | QStringList mTodoTemplates; |
292 | QStringList mEventTemplates; | 292 | QStringList mEventTemplates; |
293 | 293 | ||
294 | int mDestination; | 294 | int mDestination; |
295 | 295 | ||
296 | 296 | ||
297 | bool mEditOnDoubleClick; | 297 | bool mEditOnDoubleClick; |
298 | bool mViewChangeHoldFullscreen; | 298 | bool mViewChangeHoldFullscreen; |
299 | bool mViewChangeHoldNonFullscreen; | 299 | bool mViewChangeHoldNonFullscreen; |
300 | bool mCenterOnCurrentTime; | 300 | bool mCenterOnCurrentTime; |
301 | bool mSetTimeToDayStartAt; | 301 | bool mSetTimeToDayStartAt; |
302 | bool mHighlightCurrentDay; | 302 | bool mHighlightCurrentDay; |
303 | bool mUseHighlightLightColor; | 303 | bool mUseHighlightLightColor; |
304 | bool mListViewMonthTimespan; | 304 | bool mListViewMonthTimespan; |
305 | bool mWNViewShowsParents; | 305 | bool mWNViewShowsParents; |
306 | bool mWNViewShowsPast; | 306 | bool mWNViewShowsPast; |
307 | bool mWNViewShowLocation; | 307 | bool mWNViewShowLocation; |
308 | bool mTodoViewShowsPercentage; | 308 | bool mTodoViewShowsPercentage; |
309 | bool mTodoViewUsesCatColors; | 309 | bool mTodoViewUsesCatColors; |
310 | bool mMonthViewUsesBigFont; | 310 | bool mMonthViewUsesBigFont; |
311 | bool mTodoViewUsesSmallFont; | 311 | bool mTodoViewUsesSmallFont; |
312 | bool mTodoViewUsesForegroundColor; | 312 | bool mTodoViewUsesForegroundColor; |
313 | bool mMonthViewUsesForegroundColor; | 313 | bool mMonthViewUsesForegroundColor; |
314 | 314 | ||
315 | bool mHightlightDateTimeEdit; | 315 | bool mHightlightDateTimeEdit; |
316 | bool mShortDateInViewer; | 316 | bool mShortDateInViewer; |
317 | 317 | ||
318 | bool mShowDateNavigator; | 318 | bool mShowDateNavigator; |
319 | 319 | ||
320 | QStringList mLocationDefaults; | 320 | QStringList mLocationDefaults; |
321 | QStringList mEventSummaryUser; | 321 | QStringList mEventSummaryUser; |
322 | QStringList mTodoSummaryUser; | 322 | QStringList mTodoSummaryUser; |
323 | QStringList mJournalSummaryUser; | 323 | QStringList mJournalSummaryUser; |
324 | 324 | ||
325 | bool mUseInternalAlarmNotification; | 325 | bool mUseInternalAlarmNotification; |
326 | int mAlarmPlayBeeps; | 326 | int mAlarmPlayBeeps; |
327 | int mAlarmSuspendTime; | 327 | int mAlarmSuspendTime; |
328 | int mAlarmSuspendCount; | 328 | int mAlarmSuspendCount; |
329 | int mAlarmBeepInterval; | 329 | int mAlarmBeepInterval; |
330 | int mOldLanguage; | 330 | int mOldLanguage; |
331 | int mOldLoadedLanguage; | 331 | int mOldLoadedLanguage; |
332 | 332 | ||
333 | 333 | ||
334 | QString mActiveSyncPort; | 334 | QString mActiveSyncPort; |
335 | QString mActiveSyncIP; | 335 | QString mActiveSyncIP; |
336 | 336 | ||
337 | // settings for eventviewer | 337 | // settings for eventviewer |
338 | bool mEVshowDetails; | 338 | bool mEVshowDetails; |
339 | bool mEVshowCreated; | 339 | bool mEVshowCreated; |
340 | bool mEVshowChanged; | 340 | bool mEVshowChanged; |
341 | bool mWTshowDetails; | 341 | bool mWTshowDetails; |
342 | bool mWTshowCreated; | 342 | bool mWTshowCreated; |
343 | bool mWTshowChanged; | 343 | bool mWTshowChanged; |
344 | 344 | ||
345 | int mCurrentDisplayedView; | 345 | int mCurrentDisplayedView; |
346 | QPtrList<KopiCalendarFile> mCalendars; | 346 | QPtrList<KopiCalendarFile> mCalendars; |
347 | int mNextAvailableCalendar; | 347 | int mNextAvailableCalendar; |
348 | bool mGlobalUpdateDisabled; | ||
348 | 349 | ||
349 | private: | 350 | private: |
350 | QDict<QColor> mCategoryColors; | 351 | QDict<QColor> mCategoryColors; |
351 | QArray<KopiCalendarFile*> mDefCalColors; | 352 | QArray<KopiCalendarFile*> mDefCalColors; |
352 | QColor mDefaultCategoryColor; | 353 | QColor mDefaultCategoryColor; |
353 | 354 | ||
354 | QFont mDefaultTimeBarFont; | 355 | QFont mDefaultTimeBarFont; |
355 | QFont mDefaultViewFont; | 356 | QFont mDefaultViewFont; |
356 | QFont mDefaultMonthViewFont; | 357 | QFont mDefaultMonthViewFont; |
357 | 358 | ||
358 | QString mName; | 359 | QString mName; |
359 | QString mEmail; | 360 | QString mEmail; |
360 | }; | 361 | }; |
361 | 362 | ||
362 | #endif | 363 | #endif |
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index 2e32ac2..9cfdc35 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp | |||
@@ -1,620 +1,624 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qcheckbox.h> | 26 | #include <qcheckbox.h> |
27 | #include <qgroupbox.h> | 27 | #include <qgroupbox.h> |
28 | #include <qapplication.h> | 28 | #include <qapplication.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlistview.h> | 30 | #include <qlistview.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qhbuttongroup.h> | 34 | #include <qhbuttongroup.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kmessagebox.h> | 36 | #include <kmessagebox.h> |
37 | 37 | ||
38 | #include <libkdepim/kdateedit.h> | 38 | #include <libkdepim/kdateedit.h> |
39 | 39 | ||
40 | #include "koglobals.h" | 40 | #include "koglobals.h" |
41 | #include "koprefs.h" | 41 | #include "koprefs.h" |
42 | #include "klineedit.h" | 42 | #include "klineedit.h" |
43 | 43 | ||
44 | #include "calendarview.h" | 44 | #include "calendarview.h" |
45 | #include "koviewmanager.h" | 45 | #include "koviewmanager.h" |
46 | #include "searchdialog.h" | 46 | #include "searchdialog.h" |
47 | 47 | ||
48 | SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) | 48 | SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) |
49 | : QVBox( 0 ) | 49 | : QVBox( 0 ) |
50 | 50 | ||
51 | { | 51 | { |
52 | mCalendar = calendar; | 52 | mCalendar = calendar; |
53 | QFrame *topFrame = new QFrame( this ) ;//plainPage(); | 53 | QFrame *topFrame = new QFrame( this ) ;//plainPage(); |
54 | QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); | 54 | QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); |
55 | 55 | ||
56 | // Search expression | 56 | // Search expression |
57 | QHBoxLayout *subLayout = new QHBoxLayout(); | 57 | QHBoxLayout *subLayout = new QHBoxLayout(); |
58 | layout->addLayout(subLayout); | 58 | layout->addLayout(subLayout); |
59 | /* | 59 | /* |
60 | searchLabel = new QLabel(topFrame); | 60 | searchLabel = new QLabel(topFrame); |
61 | searchLabel->setText(i18n("Search for:")); | 61 | searchLabel->setText(i18n("Search for:")); |
62 | subLayout->addWidget(searchLabel); | 62 | subLayout->addWidget(searchLabel); |
63 | */ | 63 | */ |
64 | QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); | 64 | QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); |
65 | //OkButton->setDefault( true ); | 65 | //OkButton->setDefault( true ); |
66 | connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); | 66 | connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); |
67 | subLayout->addWidget(OkButton); | 67 | subLayout->addWidget(OkButton); |
68 | searchEdit = new KLineEdit(topFrame); | 68 | searchEdit = new KLineEdit(topFrame); |
69 | subLayout->addWidget(searchEdit); | 69 | subLayout->addWidget(searchEdit); |
70 | 70 | ||
71 | mAddItems = new QRadioButton( "+ ", topFrame ); | 71 | mAddItems = new QRadioButton( "+ ", topFrame ); |
72 | mSubItems = new QRadioButton( "- ", topFrame ); | 72 | mSubItems = new QRadioButton( "- ", topFrame ); |
73 | mRefineItems = new QRadioButton( "< ", topFrame ); | 73 | mRefineItems = new QRadioButton( "< ", topFrame ); |
74 | subLayout->addWidget( mAddItems ); | 74 | subLayout->addWidget( mAddItems ); |
75 | subLayout->addWidget( mSubItems ); | 75 | subLayout->addWidget( mSubItems ); |
76 | subLayout->addWidget( mRefineItems ); | 76 | subLayout->addWidget( mRefineItems ); |
77 | QFont fo ( mAddItems->font() ); | 77 | QFont fo ( mAddItems->font() ); |
78 | fo.setBold( true ); | 78 | fo.setBold( true ); |
79 | fo.setPointSize( fo.pointSize() + 2 ); | 79 | fo.setPointSize( fo.pointSize() + 2 ); |
80 | mAddItems->setFont( fo ); | 80 | mAddItems->setFont( fo ); |
81 | mSubItems->setFont( fo ); | 81 | mSubItems->setFont( fo ); |
82 | mRefineItems->setFont( fo ); | 82 | mRefineItems->setFont( fo ); |
83 | connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool ))); | 83 | connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool ))); |
84 | connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool ))); | 84 | connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool ))); |
85 | connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool ))); | 85 | connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool ))); |
86 | 86 | ||
87 | QPushButton *togButton = new QPushButton( "", topFrame ); | 87 | QPushButton *togButton = new QPushButton( "", topFrame ); |
88 | subLayout->addWidget(togButton); | 88 | subLayout->addWidget(togButton); |
89 | connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); | 89 | connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); |
90 | togButton->setPixmap(SmallIcon("1updownarrow")); | 90 | togButton->setPixmap(SmallIcon("1updownarrow")); |
91 | togButton->setMinimumWidth( togButton->sizeHint().height() ); | 91 | togButton->setMinimumWidth( togButton->sizeHint().height() ); |
92 | 92 | ||
93 | searchEdit->setText("*"); // Find all events by default | 93 | searchEdit->setText("*"); // Find all events by default |
94 | searchEdit->setFocus(); | 94 | searchEdit->setFocus(); |
95 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); | 95 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); |
96 | connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); | 96 | connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); |
97 | // Subjects to search | 97 | // Subjects to search |
98 | // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), | 98 | // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), |
99 | // topFrame); | 99 | // topFrame); |
100 | 100 | ||
101 | incidenceGroup = new QHBox( topFrame ); | 101 | incidenceGroup = new QHBox( topFrame ); |
102 | layout->addWidget(incidenceGroup); | 102 | layout->addWidget(incidenceGroup); |
103 | 103 | ||
104 | mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); | 104 | mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); |
105 | //mSearchEvent->setChecked(true); | 105 | //mSearchEvent->setChecked(true); |
106 | mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); | 106 | mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); |
107 | mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); | 107 | mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); |
108 | 108 | ||
109 | subjectGroup = new QHBox( topFrame ); | 109 | subjectGroup = new QHBox( topFrame ); |
110 | layout->addWidget(subjectGroup); | 110 | layout->addWidget(subjectGroup); |
111 | 111 | ||
112 | mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); | 112 | mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); |
113 | mSummaryCheck->setChecked(true); | 113 | mSummaryCheck->setChecked(true); |
114 | mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); | 114 | mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); |
115 | mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); | 115 | mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); |
116 | 116 | ||
117 | attendeeGroup = new QHBox( topFrame ); | 117 | attendeeGroup = new QHBox( topFrame ); |
118 | layout->addWidget(attendeeGroup ); | 118 | layout->addWidget(attendeeGroup ); |
119 | new QLabel( i18n("Attendee:"),attendeeGroup ); | 119 | new QLabel( i18n("Attendee:"),attendeeGroup ); |
120 | mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); | 120 | mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); |
121 | mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); | 121 | mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); |
122 | // Date range | 122 | // Date range |
123 | // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), | 123 | // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), |
124 | // topFrame); | 124 | // topFrame); |
125 | // layout->addWidget(rangeGroup); | 125 | // layout->addWidget(rangeGroup); |
126 | 126 | ||
127 | QWidget *rangeWidget = new QWidget(topFrame); | 127 | QWidget *rangeWidget = new QWidget(topFrame); |
128 | int space = KDialog::spacingHint(); | 128 | int space = KDialog::spacingHint(); |
129 | if ( QApplication::desktop()->width() <= 240 ) space = 1; | 129 | if ( QApplication::desktop()->width() <= 240 ) space = 1; |
130 | QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,space); | 130 | QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,space); |
131 | rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); | 131 | rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); |
132 | mStartDate = new KDateEdit(rangeWidget); | 132 | mStartDate = new KDateEdit(rangeWidget); |
133 | rangeLayout->addWidget(mStartDate); | 133 | rangeLayout->addWidget(mStartDate); |
134 | rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); | 134 | rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); |
135 | mEndDate = new KDateEdit(rangeWidget); | 135 | mEndDate = new KDateEdit(rangeWidget); |
136 | mEndDate->setDate(QDate::currentDate().addDays(365)); | 136 | mEndDate->setDate(QDate::currentDate().addDays(365)); |
137 | rangeLayout->addWidget(mEndDate); | 137 | rangeLayout->addWidget(mEndDate); |
138 | QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); | 138 | QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); |
139 | rangeLayout->addWidget( (QWidget*)wt ); | 139 | rangeLayout->addWidget( (QWidget*)wt ); |
140 | layout->addWidget(rangeWidget); | 140 | layout->addWidget(rangeWidget); |
141 | // Results list view | 141 | // Results list view |
142 | listView = new KOListView(mCalendar,topFrame); | 142 | listView = new KOListView(mCalendar,topFrame); |
143 | layout->addWidget(listView); | 143 | layout->addWidget(listView); |
144 | listView->showCompletedTodos(); | 144 | listView->showCompletedTodos(); |
145 | //layout->setStretchFactor( listView, 333 ); | 145 | //layout->setStretchFactor( listView, 333 ); |
146 | //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); | 146 | //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); |
147 | //listView->setMaximumHeight( 50 ); | 147 | //listView->setMaximumHeight( 50 ); |
148 | listView->readSettings(KOGlobals::config(),"SearchListView Layout"); | 148 | listView->readSettings(KOGlobals::config(),"SearchListView Layout"); |
149 | connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); | 149 | connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); |
150 | 150 | ||
151 | setCaption( i18n("KO/Pi Find: ")); | 151 | setCaption( i18n("KO/Pi Find: ")); |
152 | #ifdef DESKTOP_VERSION | 152 | #ifdef DESKTOP_VERSION |
153 | OkButton = new QPushButton( i18n("Close"), this ); | 153 | OkButton = new QPushButton( i18n("Close"), this ); |
154 | connect(OkButton,SIGNAL(clicked()),SLOT(hide())); | 154 | connect(OkButton,SIGNAL(clicked()),SLOT(hide())); |
155 | #endif | 155 | #endif |
156 | } | 156 | } |
157 | 157 | ||
158 | SearchDialog::~SearchDialog() | 158 | SearchDialog::~SearchDialog() |
159 | { | 159 | { |
160 | 160 | ||
161 | } | 161 | } |
162 | void SearchDialog::slot_add( bool b ) | 162 | void SearchDialog::slot_add( bool b ) |
163 | { | 163 | { |
164 | if ( b ) { | 164 | if ( b ) { |
165 | if ( mSubItems->isOn() ) mSubItems->toggle(); | 165 | if ( mSubItems->isOn() ) mSubItems->toggle(); |
166 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); | 166 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); |
167 | setCaption( i18n("Matching items will be added to list")); | 167 | setCaption( i18n("Matching items will be added to list")); |
168 | } else | 168 | } else |
169 | setCaption( i18n("List will be cleared before search")); | 169 | setCaption( i18n("List will be cleared before search")); |
170 | } | 170 | } |
171 | void SearchDialog::slot_sub( bool b) | 171 | void SearchDialog::slot_sub( bool b) |
172 | { | 172 | { |
173 | if ( b ) { | 173 | if ( b ) { |
174 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); | 174 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); |
175 | if ( mAddItems->isOn() ) mAddItems->toggle(); | 175 | if ( mAddItems->isOn() ) mAddItems->toggle(); |
176 | setCaption( i18n("Matching items will be removed from list")); | 176 | setCaption( i18n("Matching items will be removed from list")); |
177 | } else | 177 | } else |
178 | setCaption( i18n("List will be cleared before search")); | 178 | setCaption( i18n("List will be cleared before search")); |
179 | } | 179 | } |
180 | void SearchDialog::slot_refine( bool b) | 180 | void SearchDialog::slot_refine( bool b) |
181 | { | 181 | { |
182 | if ( b ) { | 182 | if ( b ) { |
183 | if ( mSubItems->isOn() ) mSubItems->toggle(); | 183 | if ( mSubItems->isOn() ) mSubItems->toggle(); |
184 | if ( mAddItems->isOn() ) mAddItems->toggle(); | 184 | if ( mAddItems->isOn() ) mAddItems->toggle(); |
185 | setCaption( i18n("Search on displayed list only")); | 185 | setCaption( i18n("Search on displayed list only")); |
186 | } else | 186 | } else |
187 | setCaption( i18n("List will be cleared before search")); | 187 | setCaption( i18n("List will be cleared before search")); |
188 | } | 188 | } |
189 | void SearchDialog::toggleCheckboxes() | 189 | void SearchDialog::toggleCheckboxes() |
190 | { | 190 | { |
191 | if ( incidenceGroup->isVisible() ) { | 191 | if ( incidenceGroup->isVisible() ) { |
192 | incidenceGroup->hide() ; | 192 | incidenceGroup->hide() ; |
193 | subjectGroup->hide() ; | 193 | subjectGroup->hide() ; |
194 | attendeeGroup->hide() ; | 194 | attendeeGroup->hide() ; |
195 | } else { | 195 | } else { |
196 | incidenceGroup->show() ; | 196 | incidenceGroup->show() ; |
197 | subjectGroup->show() ; | 197 | subjectGroup->show() ; |
198 | attendeeGroup->show() ; | 198 | attendeeGroup->show() ; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | void SearchDialog::raiseAndSelect() | 201 | void SearchDialog::raiseAndSelect() |
202 | { | 202 | { |
203 | 203 | ||
204 | static int currentState = 0; | 204 | static int currentState = 0; |
205 | 205 | ||
206 | if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) | 206 | if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) |
207 | currentState = 0; | 207 | currentState = 0; |
208 | int newState = 0; | 208 | int newState = 0; |
209 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 209 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
210 | newState = VIEW_J_VIEW; | 210 | newState = VIEW_J_VIEW; |
211 | } | 211 | } |
212 | else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 212 | else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
213 | newState = VIEW_T_VIEW; | 213 | newState = VIEW_T_VIEW; |
214 | } | 214 | } |
215 | else { | 215 | else { |
216 | newState = VIEW_A_VIEW; | 216 | newState = VIEW_A_VIEW; |
217 | } | 217 | } |
218 | if ( newState != currentState ) { | 218 | if ( newState != currentState ) { |
219 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 219 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
220 | if ( ! mSearchJournal->isChecked() ) { | 220 | if ( ! mSearchJournal->isChecked() ) { |
221 | mSearchJournal->setChecked( true ); | 221 | mSearchJournal->setChecked( true ); |
222 | mSearchTodo->setChecked( false ); | 222 | mSearchTodo->setChecked( false ); |
223 | mSearchEvent->setChecked( false ); | 223 | mSearchEvent->setChecked( false ); |
224 | mSummaryCheck->setChecked( true ); | 224 | mSummaryCheck->setChecked( true ); |
225 | mDescriptionCheck->setChecked( true ); | 225 | mDescriptionCheck->setChecked( true ); |
226 | 226 | ||
227 | } | 227 | } |
228 | } | 228 | } |
229 | else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 229 | else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
230 | if ( ! mSearchTodo->isChecked() ) { | 230 | if ( ! mSearchTodo->isChecked() ) { |
231 | mSearchTodo->setChecked( true ); | 231 | mSearchTodo->setChecked( true ); |
232 | mSearchJournal->setChecked( false ); | 232 | mSearchJournal->setChecked( false ); |
233 | mSearchEvent->setChecked( false ); | 233 | mSearchEvent->setChecked( false ); |
234 | } | 234 | } |
235 | } | 235 | } |
236 | else { | 236 | else { |
237 | if ( ! mSearchEvent->isChecked() ) { | 237 | if ( ! mSearchEvent->isChecked() ) { |
238 | mSearchEvent->setChecked( true ); | 238 | mSearchEvent->setChecked( true ); |
239 | mSearchJournal->setChecked( false ); | 239 | mSearchJournal->setChecked( false ); |
240 | mSearchTodo->setChecked( false ); | 240 | mSearchTodo->setChecked( false ); |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | currentState = newState; | 244 | currentState = newState; |
245 | raise(); | 245 | raise(); |
246 | } | 246 | } |
247 | void SearchDialog::setFocusToList() | 247 | void SearchDialog::setFocusToList() |
248 | { | 248 | { |
249 | listView->resetFocus(); | 249 | listView->resetFocus(); |
250 | } | 250 | } |
251 | void SearchDialog::accept() | 251 | void SearchDialog::accept() |
252 | { | 252 | { |
253 | doSearch(); | 253 | doSearch(); |
254 | } | 254 | } |
255 | void SearchDialog::updateList() | 255 | void SearchDialog::updateList() |
256 | { | 256 | { |
257 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | ||
258 | listView->clear(); | ||
259 | return; | ||
260 | } | ||
257 | //listView->updateList(); | 261 | //listView->updateList(); |
258 | if ( isVisible() ) { | 262 | if ( isVisible() ) { |
259 | updateView(); | 263 | updateView(); |
260 | //qDebug("SearchDialog::updated "); | 264 | //qDebug("SearchDialog::updated "); |
261 | } | 265 | } |
262 | else { | 266 | else { |
263 | listView->clear(); | 267 | listView->clear(); |
264 | //qDebug("SearchDialog::cleared "); | 268 | //qDebug("SearchDialog::cleared "); |
265 | 269 | ||
266 | } | 270 | } |
267 | } | 271 | } |
268 | void SearchDialog::searchTextChanged( const QString &_text ) | 272 | void SearchDialog::searchTextChanged( const QString &_text ) |
269 | { | 273 | { |
270 | #if 0 | 274 | #if 0 |
271 | enableButton( KDialogBase::User1, !_text.isEmpty() ); | 275 | enableButton( KDialogBase::User1, !_text.isEmpty() ); |
272 | #endif | 276 | #endif |
273 | } | 277 | } |
274 | 278 | ||
275 | void SearchDialog::doSearch() | 279 | void SearchDialog::doSearch() |
276 | { | 280 | { |
277 | QRegExp re; | 281 | QRegExp re; |
278 | re.setWildcard(true); // most people understand these better. | 282 | re.setWildcard(true); // most people understand these better. |
279 | re.setCaseSensitive(false); | 283 | re.setCaseSensitive(false); |
280 | QString st = searchEdit->text(); | 284 | QString st = searchEdit->text(); |
281 | if ( st.right(1) != "*") | 285 | if ( st.right(1) != "*") |
282 | st += "*"; | 286 | st += "*"; |
283 | re.setPattern(st); | 287 | re.setPattern(st); |
284 | if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { | 288 | if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { |
285 | KMessageBox::sorry(this, | 289 | KMessageBox::sorry(this, |
286 | i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); | 290 | i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); |
287 | return; | 291 | return; |
288 | } | 292 | } |
289 | if (!re.isValid() ) { | 293 | if (!re.isValid() ) { |
290 | KMessageBox::sorry(this, | 294 | KMessageBox::sorry(this, |
291 | i18n("Invalid search expression,\ncannot perform " | 295 | i18n("Invalid search expression,\ncannot perform " |
292 | "the search.\nPlease enter a search expression\n" | 296 | "the search.\nPlease enter a search expression\n" |
293 | "using the wildcard characters\n '*' and '?'" | 297 | "using the wildcard characters\n '*' and '?'" |
294 | "where needed.")); | 298 | "where needed.")); |
295 | return; | 299 | return; |
296 | } | 300 | } |
297 | search(re); | 301 | search(re); |
298 | listView->setStartDate( mStartDate->date() ); | 302 | listView->setStartDate( mStartDate->date() ); |
299 | listView->showEvents(mMatchedEvents); | 303 | listView->showEvents(mMatchedEvents); |
300 | listView->addTodos(mMatchedTodos); | 304 | listView->addTodos(mMatchedTodos); |
301 | listView->addJournals(mMatchedJournals); | 305 | listView->addJournals(mMatchedJournals); |
302 | if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { | 306 | if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { |
303 | setCaption(i18n("No items found. Use '*' and '?' where needed.")); | 307 | setCaption(i18n("No items found. Use '*' and '?' where needed.")); |
304 | } else { | 308 | } else { |
305 | QString mess; | 309 | QString mess; |
306 | mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); | 310 | mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); |
307 | setCaption( i18n("KO/Pi Find: ") + mess); | 311 | setCaption( i18n("KO/Pi Find: ") + mess); |
308 | 312 | ||
309 | } | 313 | } |
310 | searchEdit->setFocus(); | 314 | searchEdit->setFocus(); |
311 | } | 315 | } |
312 | void SearchDialog::updateConfig() | 316 | void SearchDialog::updateConfig() |
313 | { | 317 | { |
314 | listView->updateConfig(); | 318 | listView->updateConfig(); |
315 | } | 319 | } |
316 | void SearchDialog::updateView() | 320 | void SearchDialog::updateView() |
317 | { | 321 | { |
318 | //qDebug("SearchDialog::updateView() %d ", isVisible()); | 322 | //qDebug("SearchDialog::updateView() %d ", isVisible()); |
319 | QRegExp re; | 323 | QRegExp re; |
320 | re.setWildcard(true); // most people understand these better. | 324 | re.setWildcard(true); // most people understand these better. |
321 | re.setCaseSensitive(false); | 325 | re.setCaseSensitive(false); |
322 | QString st = searchEdit->text(); | 326 | QString st = searchEdit->text(); |
323 | if ( st.right(1) != "*") | 327 | if ( st.right(1) != "*") |
324 | st += "*"; | 328 | st += "*"; |
325 | re.setPattern(st); | 329 | re.setPattern(st); |
326 | mMatchedEvents.clear(); | 330 | mMatchedEvents.clear(); |
327 | mMatchedTodos.clear(); | 331 | mMatchedTodos.clear(); |
328 | mMatchedJournals.clear(); | 332 | mMatchedJournals.clear(); |
329 | if (re.isValid()) { | 333 | if (re.isValid()) { |
330 | search(re); | 334 | search(re); |
331 | } | 335 | } |
332 | listView->setStartDate( mStartDate->date() ); | 336 | listView->setStartDate( mStartDate->date() ); |
333 | listView->showEvents(mMatchedEvents); | 337 | listView->showEvents(mMatchedEvents); |
334 | listView->addTodos(mMatchedTodos); | 338 | listView->addTodos(mMatchedTodos); |
335 | listView->addJournals(mMatchedJournals); | 339 | listView->addJournals(mMatchedJournals); |
336 | } | 340 | } |
337 | 341 | ||
338 | void SearchDialog::search(const QRegExp &re) | 342 | void SearchDialog::search(const QRegExp &re) |
339 | { | 343 | { |
340 | QPtrList<Event> events; | 344 | QPtrList<Event> events; |
341 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { | 345 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { |
342 | if ( mRefineItems->isChecked() ) events = mMatchedEvents; | 346 | if ( mRefineItems->isChecked() ) events = mMatchedEvents; |
343 | mMatchedEvents.clear(); | 347 | mMatchedEvents.clear(); |
344 | } | 348 | } |
345 | if ( mSearchEvent->isChecked() ) { | 349 | if ( mSearchEvent->isChecked() ) { |
346 | if ( !mRefineItems->isChecked() ) | 350 | if ( !mRefineItems->isChecked() ) |
347 | events = mCalendar->events( mStartDate->date(), | 351 | events = mCalendar->events( mStartDate->date(), |
348 | mEndDate->date(), | 352 | mEndDate->date(), |
349 | false /*mInclusiveCheck->isChecked()*/ ); | 353 | false /*mInclusiveCheck->isChecked()*/ ); |
350 | 354 | ||
351 | 355 | ||
352 | Event *ev; | 356 | Event *ev; |
353 | for(ev=events.first();ev;ev=events.next()) { | 357 | for(ev=events.first();ev;ev=events.next()) { |
354 | if (mSummaryCheck->isChecked()) { | 358 | if (mSummaryCheck->isChecked()) { |
355 | #if QT_VERSION >= 0x030000 | 359 | #if QT_VERSION >= 0x030000 |
356 | if (re.search(ev->summary()) != -1) | 360 | if (re.search(ev->summary()) != -1) |
357 | #else | 361 | #else |
358 | if (re.match(ev->summary()) != -1) | 362 | if (re.match(ev->summary()) != -1) |
359 | #endif | 363 | #endif |
360 | { | 364 | { |
361 | if ( mSubItems->isChecked() ) | 365 | if ( mSubItems->isChecked() ) |
362 | mMatchedEvents.remove(ev); | 366 | mMatchedEvents.remove(ev); |
363 | else { | 367 | else { |
364 | if ( !mMatchedEvents.contains( ev ) ) | 368 | if ( !mMatchedEvents.contains( ev ) ) |
365 | mMatchedEvents.append(ev); | 369 | mMatchedEvents.append(ev); |
366 | } | 370 | } |
367 | continue; | 371 | continue; |
368 | } | 372 | } |
369 | #if QT_VERSION >= 0x030000 | 373 | #if QT_VERSION >= 0x030000 |
370 | if (re.search(ev->location()) != -1) | 374 | if (re.search(ev->location()) != -1) |
371 | #else | 375 | #else |
372 | if (re.match(ev->location()) != -1) | 376 | if (re.match(ev->location()) != -1) |
373 | #endif | 377 | #endif |
374 | { | 378 | { |
375 | if ( mSubItems->isChecked() ) | 379 | if ( mSubItems->isChecked() ) |
376 | mMatchedEvents.remove(ev); | 380 | mMatchedEvents.remove(ev); |
377 | else{ | 381 | else{ |
378 | if ( !mMatchedEvents.contains( ev ) ) | 382 | if ( !mMatchedEvents.contains( ev ) ) |
379 | mMatchedEvents.append(ev); | 383 | mMatchedEvents.append(ev); |
380 | } | 384 | } |
381 | continue; | 385 | continue; |
382 | } | 386 | } |
383 | } | 387 | } |
384 | if (mDescriptionCheck->isChecked()) { | 388 | if (mDescriptionCheck->isChecked()) { |
385 | #if QT_VERSION >= 0x030000 | 389 | #if QT_VERSION >= 0x030000 |
386 | if (re.search(ev->description()) != -1) | 390 | if (re.search(ev->description()) != -1) |
387 | #else | 391 | #else |
388 | if (re.match(ev->description()) != -1) | 392 | if (re.match(ev->description()) != -1) |
389 | #endif | 393 | #endif |
390 | { | 394 | { |
391 | if ( mSubItems->isChecked() ) | 395 | if ( mSubItems->isChecked() ) |
392 | mMatchedEvents.remove(ev); | 396 | mMatchedEvents.remove(ev); |
393 | else{ | 397 | else{ |
394 | if ( !mMatchedEvents.contains( ev ) ) | 398 | if ( !mMatchedEvents.contains( ev ) ) |
395 | mMatchedEvents.append(ev); | 399 | mMatchedEvents.append(ev); |
396 | } | 400 | } |
397 | continue; | 401 | continue; |
398 | } | 402 | } |
399 | } | 403 | } |
400 | if (mCategoryCheck->isChecked()) { | 404 | if (mCategoryCheck->isChecked()) { |
401 | #if QT_VERSION >= 0x030000 | 405 | #if QT_VERSION >= 0x030000 |
402 | if (re.search(ev->categoriesStr()) != -1) | 406 | if (re.search(ev->categoriesStr()) != -1) |
403 | #else | 407 | #else |
404 | if (re.match(ev->categoriesStr()) != -1) | 408 | if (re.match(ev->categoriesStr()) != -1) |
405 | #endif | 409 | #endif |
406 | { | 410 | { |
407 | 411 | ||
408 | if ( mSubItems->isChecked() ) | 412 | if ( mSubItems->isChecked() ) |
409 | mMatchedEvents.remove(ev); | 413 | mMatchedEvents.remove(ev); |
410 | else{ | 414 | else{ |
411 | if ( !mMatchedEvents.contains( ev ) ) | 415 | if ( !mMatchedEvents.contains( ev ) ) |
412 | mMatchedEvents.append(ev); | 416 | mMatchedEvents.append(ev); |
413 | } | 417 | } |
414 | continue; | 418 | continue; |
415 | } | 419 | } |
416 | } | 420 | } |
417 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { | 421 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { |
418 | QPtrList<Attendee> tmpAList = ev->attendees(); | 422 | QPtrList<Attendee> tmpAList = ev->attendees(); |
419 | Attendee *a; | 423 | Attendee *a; |
420 | for (a = tmpAList.first(); a; a = tmpAList.next()) { | 424 | for (a = tmpAList.first(); a; a = tmpAList.next()) { |
421 | if (mSearchAName->isChecked()) { | 425 | if (mSearchAName->isChecked()) { |
422 | #if QT_VERSION >= 0x030000 | 426 | #if QT_VERSION >= 0x030000 |
423 | if (re.search(a->name()) != -1) | 427 | if (re.search(a->name()) != -1) |
424 | #else | 428 | #else |
425 | if (re.match(a->name()) != -1) | 429 | if (re.match(a->name()) != -1) |
426 | #endif | 430 | #endif |
427 | { | 431 | { |
428 | if ( mSubItems->isChecked() ) | 432 | if ( mSubItems->isChecked() ) |
429 | mMatchedEvents.remove(ev); | 433 | mMatchedEvents.remove(ev); |
430 | else{ | 434 | else{ |
431 | if ( !mMatchedEvents.contains( ev ) ) | 435 | if ( !mMatchedEvents.contains( ev ) ) |
432 | mMatchedEvents.append(ev); | 436 | mMatchedEvents.append(ev); |
433 | } | 437 | } |
434 | break; | 438 | break; |
435 | } | 439 | } |
436 | } | 440 | } |
437 | if (mSearchAEmail->isChecked()) { | 441 | if (mSearchAEmail->isChecked()) { |
438 | #if QT_VERSION >= 0x030000 | 442 | #if QT_VERSION >= 0x030000 |
439 | if (re.search(a->email()) != -1) | 443 | if (re.search(a->email()) != -1) |
440 | #else | 444 | #else |
441 | if (re.match(a->email()) != -1) | 445 | if (re.match(a->email()) != -1) |
442 | #endif | 446 | #endif |
443 | { | 447 | { |
444 | if ( mSubItems->isChecked() ) | 448 | if ( mSubItems->isChecked() ) |
445 | mMatchedEvents.remove(ev); | 449 | mMatchedEvents.remove(ev); |
446 | else{ | 450 | else{ |
447 | if ( !mMatchedEvents.contains( ev ) ) | 451 | if ( !mMatchedEvents.contains( ev ) ) |
448 | mMatchedEvents.append(ev); | 452 | mMatchedEvents.append(ev); |
449 | } | 453 | } |
450 | break; | 454 | break; |
451 | } | 455 | } |
452 | } | 456 | } |
453 | } | 457 | } |
454 | } | 458 | } |
455 | } | 459 | } |
456 | } | 460 | } |
457 | QPtrList<Todo> todos; | 461 | QPtrList<Todo> todos; |
458 | 462 | ||
459 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { | 463 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { |
460 | if ( mRefineItems->isChecked() ) todos = mMatchedTodos ; | 464 | if ( mRefineItems->isChecked() ) todos = mMatchedTodos ; |
461 | mMatchedTodos.clear(); | 465 | mMatchedTodos.clear(); |
462 | } | 466 | } |
463 | 467 | ||
464 | if ( mSearchTodo->isChecked() ) { | 468 | if ( mSearchTodo->isChecked() ) { |
465 | if ( !mRefineItems->isChecked() ) todos = mCalendar->todos( ); | 469 | if ( !mRefineItems->isChecked() ) todos = mCalendar->todos( ); |
466 | Todo *tod; | 470 | Todo *tod; |
467 | for(tod=todos.first();tod;tod=todos.next()) { | 471 | for(tod=todos.first();tod;tod=todos.next()) { |
468 | if (mSummaryCheck->isChecked()) { | 472 | if (mSummaryCheck->isChecked()) { |
469 | #if QT_VERSION >= 0x030000 | 473 | #if QT_VERSION >= 0x030000 |
470 | if (re.search(tod->summary()) != -1) | 474 | if (re.search(tod->summary()) != -1) |
471 | #else | 475 | #else |
472 | if (re.match(tod->summary()) != -1) | 476 | if (re.match(tod->summary()) != -1) |
473 | #endif | 477 | #endif |
474 | { | 478 | { |
475 | if ( mSubItems->isChecked() ) | 479 | if ( mSubItems->isChecked() ) |
476 | mMatchedTodos.remove(tod); | 480 | mMatchedTodos.remove(tod); |
477 | else if (!mMatchedTodos.contains( tod )) | 481 | else if (!mMatchedTodos.contains( tod )) |
478 | mMatchedTodos.append(tod); | 482 | mMatchedTodos.append(tod); |
479 | continue; | 483 | continue; |
480 | } | 484 | } |
481 | } | 485 | } |
482 | if (mDescriptionCheck->isChecked()) { | 486 | if (mDescriptionCheck->isChecked()) { |
483 | #if QT_VERSION >= 0x030000 | 487 | #if QT_VERSION >= 0x030000 |
484 | if (re.search(tod->description()) != -1) | 488 | if (re.search(tod->description()) != -1) |
485 | #else | 489 | #else |
486 | if (re.match(tod->description()) != -1) | 490 | if (re.match(tod->description()) != -1) |
487 | #endif | 491 | #endif |
488 | { | 492 | { |
489 | if ( mSubItems->isChecked() ) | 493 | if ( mSubItems->isChecked() ) |
490 | mMatchedTodos.remove(tod); | 494 | mMatchedTodos.remove(tod); |
491 | else if (!mMatchedTodos.contains( tod )) | 495 | else if (!mMatchedTodos.contains( tod )) |
492 | mMatchedTodos.append(tod); | 496 | mMatchedTodos.append(tod); |
493 | continue; | 497 | continue; |
494 | } | 498 | } |
495 | } | 499 | } |
496 | if (mCategoryCheck->isChecked()) { | 500 | if (mCategoryCheck->isChecked()) { |
497 | #if QT_VERSION >= 0x030000 | 501 | #if QT_VERSION >= 0x030000 |
498 | if (re.search(tod->categoriesStr()) != -1) | 502 | if (re.search(tod->categoriesStr()) != -1) |
499 | #else | 503 | #else |
500 | if (re.match(tod->categoriesStr()) != -1) | 504 | if (re.match(tod->categoriesStr()) != -1) |
501 | #endif | 505 | #endif |
502 | { | 506 | { |
503 | if ( mSubItems->isChecked() ) | 507 | if ( mSubItems->isChecked() ) |
504 | mMatchedTodos.remove(tod); | 508 | mMatchedTodos.remove(tod); |
505 | else if (!mMatchedTodos.contains( tod )) | 509 | else if (!mMatchedTodos.contains( tod )) |
506 | mMatchedTodos.append(tod); | 510 | mMatchedTodos.append(tod); |
507 | continue; | 511 | continue; |
508 | } | 512 | } |
509 | } | 513 | } |
510 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { | 514 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { |
511 | QPtrList<Attendee> tmpAList = tod->attendees(); | 515 | QPtrList<Attendee> tmpAList = tod->attendees(); |
512 | Attendee *a; | 516 | Attendee *a; |
513 | for (a = tmpAList.first(); a; a = tmpAList.next()) { | 517 | for (a = tmpAList.first(); a; a = tmpAList.next()) { |
514 | if (mSearchAName->isChecked()) { | 518 | if (mSearchAName->isChecked()) { |
515 | #if QT_VERSION >= 0x030000 | 519 | #if QT_VERSION >= 0x030000 |
516 | if (re.search(a->name()) != -1) | 520 | if (re.search(a->name()) != -1) |
517 | #else | 521 | #else |
518 | if (re.match(a->name()) != -1) | 522 | if (re.match(a->name()) != -1) |
519 | #endif | 523 | #endif |
520 | { | 524 | { |
521 | if ( mSubItems->isChecked() ) | 525 | if ( mSubItems->isChecked() ) |
522 | mMatchedTodos.remove(tod); | 526 | mMatchedTodos.remove(tod); |
523 | else if (!mMatchedTodos.contains( tod )) | 527 | else if (!mMatchedTodos.contains( tod )) |
524 | mMatchedTodos.append(tod); | 528 | mMatchedTodos.append(tod); |
525 | break; | 529 | break; |
526 | } | 530 | } |
527 | } | 531 | } |
528 | if (mSearchAEmail->isChecked()) { | 532 | if (mSearchAEmail->isChecked()) { |
529 | #if QT_VERSION >= 0x030000 | 533 | #if QT_VERSION >= 0x030000 |
530 | if (re.search(a->email()) != -1) | 534 | if (re.search(a->email()) != -1) |
531 | #else | 535 | #else |
532 | if (re.match(a->email()) != -1) | 536 | if (re.match(a->email()) != -1) |
533 | #endif | 537 | #endif |
534 | { | 538 | { |
535 | if ( mSubItems->isChecked() ) | 539 | if ( mSubItems->isChecked() ) |
536 | mMatchedTodos.remove(tod); | 540 | mMatchedTodos.remove(tod); |
537 | else if (!mMatchedTodos.contains( tod )) | 541 | else if (!mMatchedTodos.contains( tod )) |
538 | mMatchedTodos.append(tod); | 542 | mMatchedTodos.append(tod); |
539 | break; | 543 | break; |
540 | } | 544 | } |
541 | } | 545 | } |
542 | } | 546 | } |
543 | } | 547 | } |
544 | } | 548 | } |
545 | } | 549 | } |
546 | 550 | ||
547 | QPtrList<Journal> journals; | 551 | QPtrList<Journal> journals; |
548 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { | 552 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { |
549 | if ( mRefineItems->isChecked() ) journals = mMatchedJournals ; | 553 | if ( mRefineItems->isChecked() ) journals = mMatchedJournals ; |
550 | mMatchedJournals.clear(); | 554 | mMatchedJournals.clear(); |
551 | } | 555 | } |
552 | if (mSearchJournal->isChecked() ) { | 556 | if (mSearchJournal->isChecked() ) { |
553 | if ( ! mRefineItems->isChecked() ) journals = mCalendar->journals(); | 557 | if ( ! mRefineItems->isChecked() ) journals = mCalendar->journals(); |
554 | Journal* journ; | 558 | Journal* journ; |
555 | 559 | ||
556 | for(journ=journals.first();journ;journ=journals.next()) { | 560 | for(journ=journals.first();journ;journ=journals.next()) { |
557 | if ( journ->dtStart().date() <= mEndDate->date() | 561 | if ( journ->dtStart().date() <= mEndDate->date() |
558 | &&journ->dtStart().date() >= mStartDate->date()) { | 562 | &&journ->dtStart().date() >= mStartDate->date()) { |
559 | if (mDescriptionCheck->isChecked()) { | 563 | if (mDescriptionCheck->isChecked()) { |
560 | #if QT_VERSION >= 0x030000 | 564 | #if QT_VERSION >= 0x030000 |
561 | if (re.search(journ->description()) != -1) | 565 | if (re.search(journ->description()) != -1) |
562 | #else | 566 | #else |
563 | if (re.match(journ->description()) != -1) | 567 | if (re.match(journ->description()) != -1) |
564 | #endif | 568 | #endif |
565 | { | 569 | { |
566 | if ( mSubItems->isChecked() ) | 570 | if ( mSubItems->isChecked() ) |
567 | mMatchedJournals.remove(journ); | 571 | mMatchedJournals.remove(journ); |
568 | else if (!mMatchedJournals.contains( journ )) | 572 | else if (!mMatchedJournals.contains( journ )) |
569 | mMatchedJournals.append(journ); | 573 | mMatchedJournals.append(journ); |
570 | continue; | 574 | continue; |
571 | } | 575 | } |
572 | } | 576 | } |
573 | if (mSummaryCheck->isChecked()) { | 577 | if (mSummaryCheck->isChecked()) { |
574 | #if QT_VERSION >= 0x030000 | 578 | #if QT_VERSION >= 0x030000 |
575 | if (re.search(journ->summary()) != -1) | 579 | if (re.search(journ->summary()) != -1) |
576 | #else | 580 | #else |
577 | if (re.match(journ->summary()) != -1) | 581 | if (re.match(journ->summary()) != -1) |
578 | #endif | 582 | #endif |
579 | { | 583 | { |
580 | if ( mSubItems->isChecked() ) | 584 | if ( mSubItems->isChecked() ) |
581 | mMatchedJournals.remove(journ); | 585 | mMatchedJournals.remove(journ); |
582 | else if (!mMatchedJournals.contains( journ )) | 586 | else if (!mMatchedJournals.contains( journ )) |
583 | mMatchedJournals.append(journ); | 587 | mMatchedJournals.append(journ); |
584 | continue; | 588 | continue; |
585 | } | 589 | } |
586 | } | 590 | } |
587 | } | 591 | } |
588 | } | 592 | } |
589 | } | 593 | } |
590 | if ( mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() < 1 ) { | 594 | if ( mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() < 1 ) { |
591 | qDebug("count %d ", mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() ); | 595 | qDebug("count %d ", mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() ); |
592 | if ( mRefineItems->isChecked() ) | 596 | if ( mRefineItems->isChecked() ) |
593 | mRefineItems->setChecked( false ); | 597 | mRefineItems->setChecked( false ); |
594 | else if ( mSubItems->isChecked() ) | 598 | else if ( mSubItems->isChecked() ) |
595 | mSubItems->setChecked( false ); | 599 | mSubItems->setChecked( false ); |
596 | } | 600 | } |
597 | } | 601 | } |
598 | 602 | ||
599 | void SearchDialog::keyPressEvent ( QKeyEvent *e) | 603 | void SearchDialog::keyPressEvent ( QKeyEvent *e) |
600 | { | 604 | { |
601 | switch ( e->key() ) { | 605 | switch ( e->key() ) { |
602 | case Qt::Key_Escape: | 606 | case Qt::Key_Escape: |
603 | close(); | 607 | close(); |
604 | break; | 608 | break; |
605 | case Qt::Key_F: | 609 | case Qt::Key_F: |
606 | if ( e->state() == Qt::ControlButton ) { | 610 | if ( e->state() == Qt::ControlButton ) { |
607 | 611 | ||
608 | } | 612 | } |
609 | break; | 613 | break; |
610 | case Qt::Key_Return: | 614 | case Qt::Key_Return: |
611 | case Qt::Key_Enter: | 615 | case Qt::Key_Enter: |
612 | doSearch(); | 616 | doSearch(); |
613 | break; | 617 | break; |
614 | 618 | ||
615 | default: | 619 | default: |
616 | e->ignore(); | 620 | e->ignore(); |
617 | } | 621 | } |
618 | } | 622 | } |
619 | 623 | ||
620 | //mMatchedJournals; | 624 | //mMatchedJournals; |