-rw-r--r-- | korganizer/calendarview.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index f8d752a..2321087 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1922,769 +1922,770 @@ void CalendarView::writeSettings() | |||
1922 | #endif | 1922 | #endif |
1923 | 1923 | ||
1924 | 1924 | ||
1925 | config->sync(); | 1925 | config->sync(); |
1926 | } | 1926 | } |
1927 | 1927 | ||
1928 | void CalendarView::readFilterSettings(KConfig *config) | 1928 | void CalendarView::readFilterSettings(KConfig *config) |
1929 | { | 1929 | { |
1930 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1930 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1931 | 1931 | ||
1932 | mFilters.clear(); | 1932 | mFilters.clear(); |
1933 | 1933 | ||
1934 | config->setGroup("General"); | 1934 | config->setGroup("General"); |
1935 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1935 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1936 | 1936 | ||
1937 | QStringList::ConstIterator it = filterList.begin(); | 1937 | QStringList::ConstIterator it = filterList.begin(); |
1938 | QStringList::ConstIterator end = filterList.end(); | 1938 | QStringList::ConstIterator end = filterList.end(); |
1939 | while(it != end) { | 1939 | while(it != end) { |
1940 | // kdDebug() << " filter: " << (*it) << endl; | 1940 | // kdDebug() << " filter: " << (*it) << endl; |
1941 | 1941 | ||
1942 | CalFilter *filter; | 1942 | CalFilter *filter; |
1943 | filter = new CalFilter(*it); | 1943 | filter = new CalFilter(*it); |
1944 | config->setGroup("Filter_" + (*it)); | 1944 | config->setGroup("Filter_" + (*it)); |
1945 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1945 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1946 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1946 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1947 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1947 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1948 | mFilters.append(filter); | 1948 | mFilters.append(filter); |
1949 | 1949 | ||
1950 | ++it; | 1950 | ++it; |
1951 | } | 1951 | } |
1952 | 1952 | ||
1953 | if (mFilters.count() == 0) { | 1953 | if (mFilters.count() == 0) { |
1954 | CalFilter *filter = new CalFilter(i18n("Default")); | 1954 | CalFilter *filter = new CalFilter(i18n("Default")); |
1955 | mFilters.append(filter); | 1955 | mFilters.append(filter); |
1956 | } | 1956 | } |
1957 | mFilterView->updateFilters(); | 1957 | mFilterView->updateFilters(); |
1958 | config->setGroup("FilterView"); | 1958 | config->setGroup("FilterView"); |
1959 | 1959 | ||
1960 | mFilterView->blockSignals(true); | 1960 | mFilterView->blockSignals(true); |
1961 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1961 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1962 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1962 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1963 | mFilterView->blockSignals(false); | 1963 | mFilterView->blockSignals(false); |
1964 | // We do it manually to avoid it being done twice by the above calls | 1964 | // We do it manually to avoid it being done twice by the above calls |
1965 | updateFilter(); | 1965 | updateFilter(); |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | void CalendarView::writeFilterSettings(KConfig *config) | 1968 | void CalendarView::writeFilterSettings(KConfig *config) |
1969 | { | 1969 | { |
1970 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1970 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1971 | 1971 | ||
1972 | QStringList filterList; | 1972 | QStringList filterList; |
1973 | 1973 | ||
1974 | CalFilter *filter = mFilters.first(); | 1974 | CalFilter *filter = mFilters.first(); |
1975 | while(filter) { | 1975 | while(filter) { |
1976 | // kdDebug() << " fn: " << filter->name() << endl; | 1976 | // kdDebug() << " fn: " << filter->name() << endl; |
1977 | filterList << filter->name(); | 1977 | filterList << filter->name(); |
1978 | config->setGroup("Filter_" + filter->name()); | 1978 | config->setGroup("Filter_" + filter->name()); |
1979 | config->writeEntry("Criteria",filter->criteria()); | 1979 | config->writeEntry("Criteria",filter->criteria()); |
1980 | config->writeEntry("CategoryList",filter->categoryList()); | 1980 | config->writeEntry("CategoryList",filter->categoryList()); |
1981 | filter = mFilters.next(); | 1981 | filter = mFilters.next(); |
1982 | } | 1982 | } |
1983 | config->setGroup("General"); | 1983 | config->setGroup("General"); |
1984 | config->writeEntry("CalendarFilters",filterList); | 1984 | config->writeEntry("CalendarFilters",filterList); |
1985 | 1985 | ||
1986 | config->setGroup("FilterView"); | 1986 | config->setGroup("FilterView"); |
1987 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1987 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1988 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1988 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1989 | } | 1989 | } |
1990 | 1990 | ||
1991 | 1991 | ||
1992 | void CalendarView::goToday() | 1992 | void CalendarView::goToday() |
1993 | { | 1993 | { |
1994 | mNavigator->selectToday(); | 1994 | mNavigator->selectToday(); |
1995 | } | 1995 | } |
1996 | 1996 | ||
1997 | void CalendarView::goNext() | 1997 | void CalendarView::goNext() |
1998 | { | 1998 | { |
1999 | mNavigator->selectNext(); | 1999 | mNavigator->selectNext(); |
2000 | } | 2000 | } |
2001 | 2001 | ||
2002 | void CalendarView::goPrevious() | 2002 | void CalendarView::goPrevious() |
2003 | { | 2003 | { |
2004 | mNavigator->selectPrevious(); | 2004 | mNavigator->selectPrevious(); |
2005 | } | 2005 | } |
2006 | void CalendarView::goNextMonth() | 2006 | void CalendarView::goNextMonth() |
2007 | { | 2007 | { |
2008 | mNavigator->selectNextMonth(); | 2008 | mNavigator->selectNextMonth(); |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | void CalendarView::goPreviousMonth() | 2011 | void CalendarView::goPreviousMonth() |
2012 | { | 2012 | { |
2013 | mNavigator->selectPreviousMonth(); | 2013 | mNavigator->selectPreviousMonth(); |
2014 | } | 2014 | } |
2015 | void CalendarView::writeLocale() | 2015 | void CalendarView::writeLocale() |
2016 | { | 2016 | { |
2017 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2017 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2018 | #if 0 | 2018 | #if 0 |
2019 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2019 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2020 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2020 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2021 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2021 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2022 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2022 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2023 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2023 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2024 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2024 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2025 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2025 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2026 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2026 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2027 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2027 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2028 | KOPrefs::instance()->mDaylightsavingStart, | 2028 | KOPrefs::instance()->mDaylightsavingStart, |
2029 | KOPrefs::instance()->mDaylightsavingEnd ); | 2029 | KOPrefs::instance()->mDaylightsavingEnd ); |
2030 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2030 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2031 | #endif | 2031 | #endif |
2032 | } | 2032 | } |
2033 | void CalendarView::updateConfig() | 2033 | void CalendarView::updateConfig() |
2034 | { | 2034 | { |
2035 | writeLocale(); | 2035 | writeLocale(); |
2036 | if ( KOPrefs::instance()->mUseAppColors ) | 2036 | if ( KOPrefs::instance()->mUseAppColors ) |
2037 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2037 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2038 | emit configChanged(); | 2038 | emit configChanged(); |
2039 | mTodoList->updateConfig(); | 2039 | mTodoList->updateConfig(); |
2040 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2040 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2041 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2041 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2042 | // To make the "fill window" configurations work | 2042 | // To make the "fill window" configurations work |
2043 | //mViewManager->raiseCurrentView(); | 2043 | //mViewManager->raiseCurrentView(); |
2044 | } | 2044 | } |
2045 | 2045 | ||
2046 | 2046 | ||
2047 | void CalendarView::eventChanged(Event *event) | 2047 | void CalendarView::eventChanged(Event *event) |
2048 | { | 2048 | { |
2049 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2049 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2050 | //updateUnmanagedViews(); | 2050 | //updateUnmanagedViews(); |
2051 | } | 2051 | } |
2052 | 2052 | ||
2053 | void CalendarView::eventAdded(Event *event) | 2053 | void CalendarView::eventAdded(Event *event) |
2054 | { | 2054 | { |
2055 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2055 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2056 | } | 2056 | } |
2057 | 2057 | ||
2058 | void CalendarView::eventToBeDeleted(Event *) | 2058 | void CalendarView::eventToBeDeleted(Event *) |
2059 | { | 2059 | { |
2060 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2060 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | void CalendarView::eventDeleted() | 2063 | void CalendarView::eventDeleted() |
2064 | { | 2064 | { |
2065 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2065 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2066 | } | 2066 | } |
2067 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2067 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2068 | { | 2068 | { |
2069 | changeIncidenceDisplay((Incidence *)which, action); | 2069 | changeIncidenceDisplay((Incidence *)which, action); |
2070 | mDateNavigator->updateView(); //LR | 2070 | mDateNavigator->updateView(); //LR |
2071 | //mDialogManager->updateSearchDialog(); | 2071 | //mDialogManager->updateSearchDialog(); |
2072 | 2072 | ||
2073 | if (which) { | 2073 | if (which) { |
2074 | mViewManager->updateWNview(); | 2074 | mViewManager->updateWNview(); |
2075 | //mTodoList->updateView(); | 2075 | //mTodoList->updateView(); |
2076 | } | 2076 | } |
2077 | 2077 | ||
2078 | } | 2078 | } |
2079 | 2079 | ||
2080 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2080 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2081 | { | 2081 | { |
2082 | updateUnmanagedViews(); | 2082 | updateUnmanagedViews(); |
2083 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2083 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2084 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2084 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2085 | mCalendar->checkAlarmForIncidence( 0, true ); | 2085 | mCalendar->checkAlarmForIncidence( 0, true ); |
2086 | if ( mEventViewerDialog ) | 2086 | if ( mEventViewerDialog ) |
2087 | mEventViewerDialog->hide(); | 2087 | mEventViewerDialog->hide(); |
2088 | } | 2088 | } |
2089 | else | 2089 | else |
2090 | mCalendar->checkAlarmForIncidence( which , false ); | 2090 | mCalendar->checkAlarmForIncidence( which , false ); |
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | // most of the changeEventDisplays() right now just call the view's | 2093 | // most of the changeEventDisplays() right now just call the view's |
2094 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2094 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2095 | void CalendarView::changeEventDisplay(Event *which, int action) | 2095 | void CalendarView::changeEventDisplay(Event *which, int action) |
2096 | { | 2096 | { |
2097 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2097 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2098 | changeIncidenceDisplay((Incidence *)which, action); | 2098 | changeIncidenceDisplay((Incidence *)which, action); |
2099 | mDateNavigator->updateView(); | 2099 | mDateNavigator->updateView(); |
2100 | //mDialogManager->updateSearchDialog(); | 2100 | //mDialogManager->updateSearchDialog(); |
2101 | 2101 | ||
2102 | if (which) { | 2102 | if (which) { |
2103 | // If there is an event view visible update the display | 2103 | // If there is an event view visible update the display |
2104 | mViewManager->currentView()->changeEventDisplay(which,action); | 2104 | mViewManager->currentView()->changeEventDisplay(which,action); |
2105 | // TODO: check, if update needed | 2105 | // TODO: check, if update needed |
2106 | // if (which->getTodoStatus()) { | 2106 | // if (which->getTodoStatus()) { |
2107 | mTodoList->updateView(); | 2107 | mTodoList->updateView(); |
2108 | // } | 2108 | // } |
2109 | } else { | 2109 | } else { |
2110 | mViewManager->currentView()->updateView(); | 2110 | mViewManager->currentView()->updateView(); |
2111 | } | 2111 | } |
2112 | } | 2112 | } |
2113 | 2113 | ||
2114 | 2114 | ||
2115 | void CalendarView::updateTodoViews() | 2115 | void CalendarView::updateTodoViews() |
2116 | { | 2116 | { |
2117 | 2117 | ||
2118 | mTodoList->updateView(); | 2118 | mTodoList->updateView(); |
2119 | mViewManager->currentView()->updateView(); | 2119 | mViewManager->currentView()->updateView(); |
2120 | 2120 | ||
2121 | } | 2121 | } |
2122 | 2122 | ||
2123 | 2123 | ||
2124 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2124 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2125 | { | 2125 | { |
2126 | mTodoList->updateView(); | 2126 | mTodoList->updateView(); |
2127 | mViewManager->updateView(start, end); | 2127 | mViewManager->updateView(start, end); |
2128 | //mDateNavigator->updateView(); | 2128 | //mDateNavigator->updateView(); |
2129 | } | 2129 | } |
2130 | 2130 | ||
2131 | void CalendarView::updateView() | 2131 | void CalendarView::updateView() |
2132 | { | 2132 | { |
2133 | DateList tmpList = mNavigator->selectedDates(); | 2133 | DateList tmpList = mNavigator->selectedDates(); |
2134 | 2134 | ||
2135 | // We assume that the navigator only selects consecutive days. | 2135 | // We assume that the navigator only selects consecutive days. |
2136 | updateView( tmpList.first(), tmpList.last() ); | 2136 | updateView( tmpList.first(), tmpList.last() ); |
2137 | } | 2137 | } |
2138 | 2138 | ||
2139 | void CalendarView::updateUnmanagedViews() | 2139 | void CalendarView::updateUnmanagedViews() |
2140 | { | 2140 | { |
2141 | mDateNavigator->updateDayMatrix(); | 2141 | mDateNavigator->updateDayMatrix(); |
2142 | } | 2142 | } |
2143 | 2143 | ||
2144 | int CalendarView::msgItemDelete() | 2144 | int CalendarView::msgItemDelete() |
2145 | { | 2145 | { |
2146 | return KMessageBox::warningContinueCancel(this, | 2146 | return KMessageBox::warningContinueCancel(this, |
2147 | i18n("This item will be\npermanently deleted."), | 2147 | i18n("This item will be\npermanently deleted."), |
2148 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2148 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2149 | } | 2149 | } |
2150 | 2150 | ||
2151 | 2151 | ||
2152 | void CalendarView::edit_cut() | 2152 | void CalendarView::edit_cut() |
2153 | { | 2153 | { |
2154 | Event *anEvent=0; | 2154 | Event *anEvent=0; |
2155 | 2155 | ||
2156 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2156 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2157 | 2157 | ||
2158 | if (mViewManager->currentView()->isEventView()) { | 2158 | if (mViewManager->currentView()->isEventView()) { |
2159 | if ( incidence && incidence->type() == "Event" ) { | 2159 | if ( incidence && incidence->type() == "Event" ) { |
2160 | anEvent = static_cast<Event *>(incidence); | 2160 | anEvent = static_cast<Event *>(incidence); |
2161 | } | 2161 | } |
2162 | } | 2162 | } |
2163 | 2163 | ||
2164 | if (!anEvent) { | 2164 | if (!anEvent) { |
2165 | KNotifyClient::beep(); | 2165 | KNotifyClient::beep(); |
2166 | return; | 2166 | return; |
2167 | } | 2167 | } |
2168 | DndFactory factory( mCalendar ); | 2168 | DndFactory factory( mCalendar ); |
2169 | factory.cutEvent(anEvent); | 2169 | factory.cutEvent(anEvent); |
2170 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2170 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | void CalendarView::edit_copy() | 2173 | void CalendarView::edit_copy() |
2174 | { | 2174 | { |
2175 | Event *anEvent=0; | 2175 | Event *anEvent=0; |
2176 | 2176 | ||
2177 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2177 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2178 | 2178 | ||
2179 | if (mViewManager->currentView()->isEventView()) { | 2179 | if (mViewManager->currentView()->isEventView()) { |
2180 | if ( incidence && incidence->type() == "Event" ) { | 2180 | if ( incidence && incidence->type() == "Event" ) { |
2181 | anEvent = static_cast<Event *>(incidence); | 2181 | anEvent = static_cast<Event *>(incidence); |
2182 | } | 2182 | } |
2183 | } | 2183 | } |
2184 | 2184 | ||
2185 | if (!anEvent) { | 2185 | if (!anEvent) { |
2186 | KNotifyClient::beep(); | 2186 | KNotifyClient::beep(); |
2187 | return; | 2187 | return; |
2188 | } | 2188 | } |
2189 | DndFactory factory( mCalendar ); | 2189 | DndFactory factory( mCalendar ); |
2190 | factory.copyEvent(anEvent); | 2190 | factory.copyEvent(anEvent); |
2191 | } | 2191 | } |
2192 | 2192 | ||
2193 | void CalendarView::edit_paste() | 2193 | void CalendarView::edit_paste() |
2194 | { | 2194 | { |
2195 | QDate date = mNavigator->selectedDates().first(); | 2195 | QDate date = mNavigator->selectedDates().first(); |
2196 | 2196 | ||
2197 | DndFactory factory( mCalendar ); | 2197 | DndFactory factory( mCalendar ); |
2198 | Event *pastedEvent = factory.pasteEvent( date ); | 2198 | Event *pastedEvent = factory.pasteEvent( date ); |
2199 | 2199 | ||
2200 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2200 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2201 | } | 2201 | } |
2202 | 2202 | ||
2203 | void CalendarView::edit_options() | 2203 | void CalendarView::edit_options() |
2204 | { | 2204 | { |
2205 | mDialogManager->showOptionsDialog(); | 2205 | mDialogManager->showOptionsDialog(); |
2206 | //writeSettings(); | 2206 | //writeSettings(); |
2207 | } | 2207 | } |
2208 | 2208 | ||
2209 | void CalendarView::slotSelectPickerDate( QDate d) | 2209 | void CalendarView::slotSelectPickerDate( QDate d) |
2210 | { | 2210 | { |
2211 | mDateFrame->hide(); | 2211 | mDateFrame->hide(); |
2212 | if ( mDatePickerMode == 1 ) { | 2212 | if ( mDatePickerMode == 1 ) { |
2213 | mNavigator->slotDaySelect( d ); | 2213 | mNavigator->slotDaySelect( d ); |
2214 | } else if ( mDatePickerMode == 2 ) { | 2214 | } else if ( mDatePickerMode == 2 ) { |
2215 | if ( mMoveIncidence->type() == "Todo" ) { | 2215 | if ( mMoveIncidence->type() == "Todo" ) { |
2216 | Todo * to = (Todo *) mMoveIncidence; | 2216 | Todo * to = (Todo *) mMoveIncidence; |
2217 | QTime tim; | 2217 | QTime tim; |
2218 | if ( to->hasDueDate() ) | 2218 | if ( to->hasDueDate() ) |
2219 | tim = to->dtDue().time(); | 2219 | tim = to->dtDue().time(); |
2220 | else { | 2220 | else { |
2221 | tim = QTime ( 0,0,0 ); | 2221 | tim = QTime ( 0,0,0 ); |
2222 | to->setFloats( true ); | 2222 | to->setFloats( true ); |
2223 | to->setHasDueDate( true ); | 2223 | to->setHasDueDate( true ); |
2224 | } | 2224 | } |
2225 | QDateTime dt ( d,tim ); | 2225 | QDateTime dt ( d,tim ); |
2226 | to->setDtDue( dt ); | 2226 | to->setDtDue( dt ); |
2227 | todoChanged( to ); | 2227 | todoChanged( to ); |
2228 | } else { | 2228 | } else { |
2229 | QTime tim = mMoveIncidence->dtStart().time(); | 2229 | QTime tim = mMoveIncidence->dtStart().time(); |
2230 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2230 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2231 | QDateTime dt ( d,tim ); | 2231 | QDateTime dt ( d,tim ); |
2232 | mMoveIncidence->setDtStart( dt ); | 2232 | mMoveIncidence->setDtStart( dt ); |
2233 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2233 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2234 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2234 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2235 | } | 2235 | } |
2236 | 2236 | ||
2237 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2237 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2238 | } | 2238 | } |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | void CalendarView::removeCategories() | 2241 | void CalendarView::removeCategories() |
2242 | { | 2242 | { |
2243 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2243 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2244 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2244 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2245 | QStringList catIncList; | 2245 | QStringList catIncList; |
2246 | QStringList newCatList; | 2246 | QStringList newCatList; |
2247 | Incidence* inc = incList.first(); | 2247 | Incidence* inc = incList.first(); |
2248 | int i; | 2248 | int i; |
2249 | int count = 0; | 2249 | int count = 0; |
2250 | while ( inc ) { | 2250 | while ( inc ) { |
2251 | newCatList.clear(); | 2251 | newCatList.clear(); |
2252 | catIncList = inc->categories() ; | 2252 | catIncList = inc->categories() ; |
2253 | for( i = 0; i< catIncList.count(); ++i ) { | 2253 | for( i = 0; i< catIncList.count(); ++i ) { |
2254 | if ( catList.contains (catIncList[i])) | 2254 | if ( catList.contains (catIncList[i])) |
2255 | newCatList.append( catIncList[i] ); | 2255 | newCatList.append( catIncList[i] ); |
2256 | } | 2256 | } |
2257 | newCatList.sort(); | 2257 | newCatList.sort(); |
2258 | inc->setCategories( newCatList.join(",") ); | 2258 | inc->setCategories( newCatList.join(",") ); |
2259 | inc = incList.next(); | 2259 | inc = incList.next(); |
2260 | } | 2260 | } |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | int CalendarView::addCategories() | 2263 | int CalendarView::addCategories() |
2264 | { | 2264 | { |
2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2267 | QStringList catIncList; | 2267 | QStringList catIncList; |
2268 | Incidence* inc = incList.first(); | 2268 | Incidence* inc = incList.first(); |
2269 | int i; | 2269 | int i; |
2270 | int count = 0; | 2270 | int count = 0; |
2271 | while ( inc ) { | 2271 | while ( inc ) { |
2272 | catIncList = inc->categories() ; | 2272 | catIncList = inc->categories() ; |
2273 | for( i = 0; i< catIncList.count(); ++i ) { | 2273 | for( i = 0; i< catIncList.count(); ++i ) { |
2274 | if ( !catList.contains (catIncList[i])) { | 2274 | if ( !catList.contains (catIncList[i])) { |
2275 | catList.append( catIncList[i] ); | 2275 | catList.append( catIncList[i] ); |
2276 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2276 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2277 | ++count; | 2277 | ++count; |
2278 | } | 2278 | } |
2279 | } | 2279 | } |
2280 | inc = incList.next(); | 2280 | inc = incList.next(); |
2281 | } | 2281 | } |
2282 | catList.sort(); | 2282 | catList.sort(); |
2283 | KOPrefs::instance()->mCustomCategories = catList; | 2283 | KOPrefs::instance()->mCustomCategories = catList; |
2284 | return count; | 2284 | return count; |
2285 | } | 2285 | } |
2286 | 2286 | ||
2287 | void CalendarView::manageCategories() | 2287 | void CalendarView::manageCategories() |
2288 | { | 2288 | { |
2289 | KOCatPrefs* cp = new KOCatPrefs(); | 2289 | KOCatPrefs* cp = new KOCatPrefs(); |
2290 | cp->show(); | 2290 | cp->show(); |
2291 | int w =cp->sizeHint().width() ; | 2291 | int w =cp->sizeHint().width() ; |
2292 | int h = cp->sizeHint().height() ; | 2292 | int h = cp->sizeHint().height() ; |
2293 | int dw = QApplication::desktop()->width(); | 2293 | int dw = QApplication::desktop()->width(); |
2294 | int dh = QApplication::desktop()->height(); | 2294 | int dh = QApplication::desktop()->height(); |
2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2296 | if ( !cp->exec() ) { | 2296 | if ( !cp->exec() ) { |
2297 | delete cp; | 2297 | delete cp; |
2298 | return; | 2298 | return; |
2299 | } | 2299 | } |
2300 | int count = 0; | 2300 | int count = 0; |
2301 | if ( cp->addCat() ) { | 2301 | if ( cp->addCat() ) { |
2302 | count = addCategories(); | 2302 | count = addCategories(); |
2303 | if ( count ) { | 2303 | if ( count ) { |
2304 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2304 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2305 | writeSettings(); | 2305 | writeSettings(); |
2306 | } | 2306 | } else |
2307 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | ||
2307 | } else { | 2308 | } else { |
2308 | removeCategories(); | 2309 | removeCategories(); |
2309 | updateView(); | 2310 | updateView(); |
2310 | } | 2311 | } |
2311 | delete cp; | 2312 | delete cp; |
2312 | } | 2313 | } |
2313 | 2314 | ||
2314 | void CalendarView::beamIncidence(Incidence * Inc) | 2315 | void CalendarView::beamIncidence(Incidence * Inc) |
2315 | { | 2316 | { |
2316 | QPtrList<Incidence> delSel ; | 2317 | QPtrList<Incidence> delSel ; |
2317 | delSel.append(Inc); | 2318 | delSel.append(Inc); |
2318 | beamIncidenceList( delSel ); | 2319 | beamIncidenceList( delSel ); |
2319 | } | 2320 | } |
2320 | void CalendarView::beamCalendar() | 2321 | void CalendarView::beamCalendar() |
2321 | { | 2322 | { |
2322 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2323 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2323 | //qDebug("beamCalendar() "); | 2324 | //qDebug("beamCalendar() "); |
2324 | beamIncidenceList( delSel ); | 2325 | beamIncidenceList( delSel ); |
2325 | } | 2326 | } |
2326 | void CalendarView::beamFilteredCalendar() | 2327 | void CalendarView::beamFilteredCalendar() |
2327 | { | 2328 | { |
2328 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2329 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2329 | //qDebug("beamFilteredCalendar() "); | 2330 | //qDebug("beamFilteredCalendar() "); |
2330 | beamIncidenceList( delSel ); | 2331 | beamIncidenceList( delSel ); |
2331 | } | 2332 | } |
2332 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2333 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2333 | { | 2334 | { |
2334 | if ( beamDialog->exec () == QDialog::Rejected ) | 2335 | if ( beamDialog->exec () == QDialog::Rejected ) |
2335 | return; | 2336 | return; |
2336 | #ifdef DESKTOP_VERSION | 2337 | #ifdef DESKTOP_VERSION |
2337 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2338 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2338 | #else | 2339 | #else |
2339 | QString fn = "/tmp/kopibeamfile"; | 2340 | QString fn = "/tmp/kopibeamfile"; |
2340 | #endif | 2341 | #endif |
2341 | QString mes; | 2342 | QString mes; |
2342 | bool createbup = true; | 2343 | bool createbup = true; |
2343 | if ( createbup ) { | 2344 | if ( createbup ) { |
2344 | QString description = "\n"; | 2345 | QString description = "\n"; |
2345 | CalendarLocal* cal = new CalendarLocal(); | 2346 | CalendarLocal* cal = new CalendarLocal(); |
2346 | if ( beamDialog->beamLocal() ) | 2347 | if ( beamDialog->beamLocal() ) |
2347 | cal->setLocalTime(); | 2348 | cal->setLocalTime(); |
2348 | else | 2349 | else |
2349 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2350 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2350 | Incidence *incidence = delSel.first(); | 2351 | Incidence *incidence = delSel.first(); |
2351 | bool addText = false; | 2352 | bool addText = false; |
2352 | if ( delSel.count() < 10 ) | 2353 | if ( delSel.count() < 10 ) |
2353 | addText = true; | 2354 | addText = true; |
2354 | else { | 2355 | else { |
2355 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2356 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2356 | } | 2357 | } |
2357 | while ( incidence ) { | 2358 | while ( incidence ) { |
2358 | Incidence *in = incidence->clone(); | 2359 | Incidence *in = incidence->clone(); |
2359 | if ( ! in->summary().isEmpty() ) { | 2360 | if ( ! in->summary().isEmpty() ) { |
2360 | in->setDescription(""); | 2361 | in->setDescription(""); |
2361 | } else { | 2362 | } else { |
2362 | in->setSummary( in->description().left(20)); | 2363 | in->setSummary( in->description().left(20)); |
2363 | in->setDescription(""); | 2364 | in->setDescription(""); |
2364 | } | 2365 | } |
2365 | if ( addText ) | 2366 | if ( addText ) |
2366 | description += in->summary() + "\n"; | 2367 | description += in->summary() + "\n"; |
2367 | cal->addIncidence( in ); | 2368 | cal->addIncidence( in ); |
2368 | incidence = delSel.next(); | 2369 | incidence = delSel.next(); |
2369 | } | 2370 | } |
2370 | if ( beamDialog->beamVcal() ) { | 2371 | if ( beamDialog->beamVcal() ) { |
2371 | fn += ".vcs"; | 2372 | fn += ".vcs"; |
2372 | FileStorage storage( cal, fn, new VCalFormat ); | 2373 | FileStorage storage( cal, fn, new VCalFormat ); |
2373 | storage.save(); | 2374 | storage.save(); |
2374 | } else { | 2375 | } else { |
2375 | fn += ".ics"; | 2376 | fn += ".ics"; |
2376 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2377 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2377 | storage.save(); | 2378 | storage.save(); |
2378 | } | 2379 | } |
2379 | delete cal; | 2380 | delete cal; |
2380 | mes = i18n("KO/Pi: Ready for beaming"); | 2381 | mes = i18n("KO/Pi: Ready for beaming"); |
2381 | topLevelWidget()->setCaption(mes); | 2382 | topLevelWidget()->setCaption(mes); |
2382 | KApplication::convert2latin1( fn ); | 2383 | KApplication::convert2latin1( fn ); |
2383 | #ifndef DESKTOP_VERSION | 2384 | #ifndef DESKTOP_VERSION |
2384 | Ir *ir = new Ir( this ); | 2385 | Ir *ir = new Ir( this ); |
2385 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2386 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2386 | ir->send( fn, description, "text/x-vCalendar" ); | 2387 | ir->send( fn, description, "text/x-vCalendar" ); |
2387 | #endif | 2388 | #endif |
2388 | } | 2389 | } |
2389 | } | 2390 | } |
2390 | void CalendarView::beamDone( Ir *ir ) | 2391 | void CalendarView::beamDone( Ir *ir ) |
2391 | { | 2392 | { |
2392 | #ifndef DESKTOP_VERSION | 2393 | #ifndef DESKTOP_VERSION |
2393 | delete ir; | 2394 | delete ir; |
2394 | #endif | 2395 | #endif |
2395 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2396 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2396 | topLevelWidget()->raise(); | 2397 | topLevelWidget()->raise(); |
2397 | } | 2398 | } |
2398 | 2399 | ||
2399 | void CalendarView::moveIncidence(Incidence * inc ) | 2400 | void CalendarView::moveIncidence(Incidence * inc ) |
2400 | { | 2401 | { |
2401 | if ( !inc ) return; | 2402 | if ( !inc ) return; |
2402 | // qDebug("showDatePickerForIncidence( ) "); | 2403 | // qDebug("showDatePickerForIncidence( ) "); |
2403 | if ( mDateFrame->isVisible() ) | 2404 | if ( mDateFrame->isVisible() ) |
2404 | mDateFrame->hide(); | 2405 | mDateFrame->hide(); |
2405 | else { | 2406 | else { |
2406 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2407 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2407 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2408 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2408 | int dw = QApplication::desktop()->width(); | 2409 | int dw = QApplication::desktop()->width(); |
2409 | int dh = QApplication::desktop()->height(); | 2410 | int dh = QApplication::desktop()->height(); |
2410 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2411 | mDateFrame->show(); | 2412 | mDateFrame->show(); |
2412 | } | 2413 | } |
2413 | mDatePickerMode = 2; | 2414 | mDatePickerMode = 2; |
2414 | mMoveIncidence = inc ; | 2415 | mMoveIncidence = inc ; |
2415 | QDate da; | 2416 | QDate da; |
2416 | if ( mMoveIncidence->type() == "Todo" ) { | 2417 | if ( mMoveIncidence->type() == "Todo" ) { |
2417 | Todo * to = (Todo *) mMoveIncidence; | 2418 | Todo * to = (Todo *) mMoveIncidence; |
2418 | if ( to->hasDueDate() ) | 2419 | if ( to->hasDueDate() ) |
2419 | da = to->dtDue().date(); | 2420 | da = to->dtDue().date(); |
2420 | else | 2421 | else |
2421 | da = QDate::currentDate(); | 2422 | da = QDate::currentDate(); |
2422 | } else { | 2423 | } else { |
2423 | da = mMoveIncidence->dtStart().date(); | 2424 | da = mMoveIncidence->dtStart().date(); |
2424 | } | 2425 | } |
2425 | mDatePicker->setDate( da ); | 2426 | mDatePicker->setDate( da ); |
2426 | } | 2427 | } |
2427 | void CalendarView::showDatePicker( ) | 2428 | void CalendarView::showDatePicker( ) |
2428 | { | 2429 | { |
2429 | //qDebug("CalendarView::showDatePicker( ) "); | 2430 | //qDebug("CalendarView::showDatePicker( ) "); |
2430 | if ( mDateFrame->isVisible() ) | 2431 | if ( mDateFrame->isVisible() ) |
2431 | mDateFrame->hide(); | 2432 | mDateFrame->hide(); |
2432 | else { | 2433 | else { |
2433 | int w =mDatePicker->sizeHint().width() ; | 2434 | int w =mDatePicker->sizeHint().width() ; |
2434 | int h = mDatePicker->sizeHint().height() ; | 2435 | int h = mDatePicker->sizeHint().height() ; |
2435 | int dw = QApplication::desktop()->width(); | 2436 | int dw = QApplication::desktop()->width(); |
2436 | int dh = QApplication::desktop()->height(); | 2437 | int dh = QApplication::desktop()->height(); |
2437 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2438 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2438 | mDateFrame->show(); | 2439 | mDateFrame->show(); |
2439 | } | 2440 | } |
2440 | mDatePickerMode = 1; | 2441 | mDatePickerMode = 1; |
2441 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2442 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2442 | } | 2443 | } |
2443 | 2444 | ||
2444 | void CalendarView::showEventEditor() | 2445 | void CalendarView::showEventEditor() |
2445 | { | 2446 | { |
2446 | #ifdef DESKTOP_VERSION | 2447 | #ifdef DESKTOP_VERSION |
2447 | mEventEditor->show(); | 2448 | mEventEditor->show(); |
2448 | #else | 2449 | #else |
2449 | mEventEditor->showMaximized(); | 2450 | mEventEditor->showMaximized(); |
2450 | #endif | 2451 | #endif |
2451 | } | 2452 | } |
2452 | void CalendarView::showTodoEditor() | 2453 | void CalendarView::showTodoEditor() |
2453 | { | 2454 | { |
2454 | #ifdef DESKTOP_VERSION | 2455 | #ifdef DESKTOP_VERSION |
2455 | mTodoEditor->show(); | 2456 | mTodoEditor->show(); |
2456 | #else | 2457 | #else |
2457 | mTodoEditor->showMaximized(); | 2458 | mTodoEditor->showMaximized(); |
2458 | #endif | 2459 | #endif |
2459 | } | 2460 | } |
2460 | 2461 | ||
2461 | void CalendarView::cloneIncidence() | 2462 | void CalendarView::cloneIncidence() |
2462 | { | 2463 | { |
2463 | Incidence *incidence = currentSelection(); | 2464 | Incidence *incidence = currentSelection(); |
2464 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2465 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2465 | if ( incidence ) { | 2466 | if ( incidence ) { |
2466 | cloneIncidence(incidence); | 2467 | cloneIncidence(incidence); |
2467 | } | 2468 | } |
2468 | } | 2469 | } |
2469 | void CalendarView::moveIncidence() | 2470 | void CalendarView::moveIncidence() |
2470 | { | 2471 | { |
2471 | Incidence *incidence = currentSelection(); | 2472 | Incidence *incidence = currentSelection(); |
2472 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2473 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2473 | if ( incidence ) { | 2474 | if ( incidence ) { |
2474 | moveIncidence(incidence); | 2475 | moveIncidence(incidence); |
2475 | } | 2476 | } |
2476 | } | 2477 | } |
2477 | void CalendarView::beamIncidence() | 2478 | void CalendarView::beamIncidence() |
2478 | { | 2479 | { |
2479 | Incidence *incidence = currentSelection(); | 2480 | Incidence *incidence = currentSelection(); |
2480 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2481 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2481 | if ( incidence ) { | 2482 | if ( incidence ) { |
2482 | beamIncidence(incidence); | 2483 | beamIncidence(incidence); |
2483 | } | 2484 | } |
2484 | } | 2485 | } |
2485 | void CalendarView::toggleCancelIncidence() | 2486 | void CalendarView::toggleCancelIncidence() |
2486 | { | 2487 | { |
2487 | Incidence *incidence = currentSelection(); | 2488 | Incidence *incidence = currentSelection(); |
2488 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2489 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2489 | if ( incidence ) { | 2490 | if ( incidence ) { |
2490 | cancelIncidence(incidence); | 2491 | cancelIncidence(incidence); |
2491 | } | 2492 | } |
2492 | } | 2493 | } |
2493 | 2494 | ||
2494 | 2495 | ||
2495 | void CalendarView::cancelIncidence(Incidence * inc ) | 2496 | void CalendarView::cancelIncidence(Incidence * inc ) |
2496 | { | 2497 | { |
2497 | inc->setCancelled( ! inc->cancelled() ); | 2498 | inc->setCancelled( ! inc->cancelled() ); |
2498 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2499 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2499 | updateView(); | 2500 | updateView(); |
2500 | } | 2501 | } |
2501 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2502 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2502 | { | 2503 | { |
2503 | Incidence * newInc = orgInc->clone(); | 2504 | Incidence * newInc = orgInc->clone(); |
2504 | newInc->recreate(); | 2505 | newInc->recreate(); |
2505 | 2506 | ||
2506 | if ( newInc->type() == "Todo" ) { | 2507 | if ( newInc->type() == "Todo" ) { |
2507 | Todo* t = (Todo*) newInc; | 2508 | Todo* t = (Todo*) newInc; |
2508 | mTodoEditor->editTodo( t ); | 2509 | mTodoEditor->editTodo( t ); |
2509 | showTodoEditor(); | 2510 | showTodoEditor(); |
2510 | if ( mTodoEditor->exec() ) { | 2511 | if ( mTodoEditor->exec() ) { |
2511 | mCalendar->addTodo( t ); | 2512 | mCalendar->addTodo( t ); |
2512 | updateView(); | 2513 | updateView(); |
2513 | } else { | 2514 | } else { |
2514 | delete t; | 2515 | delete t; |
2515 | } | 2516 | } |
2516 | } | 2517 | } |
2517 | else { | 2518 | else { |
2518 | Event* e = (Event*) newInc; | 2519 | Event* e = (Event*) newInc; |
2519 | mEventEditor->editEvent( e ); | 2520 | mEventEditor->editEvent( e ); |
2520 | showEventEditor(); | 2521 | showEventEditor(); |
2521 | if ( mEventEditor->exec() ) { | 2522 | if ( mEventEditor->exec() ) { |
2522 | mCalendar->addEvent( e ); | 2523 | mCalendar->addEvent( e ); |
2523 | updateView(); | 2524 | updateView(); |
2524 | } else { | 2525 | } else { |
2525 | delete e; | 2526 | delete e; |
2526 | } | 2527 | } |
2527 | } | 2528 | } |
2528 | } | 2529 | } |
2529 | 2530 | ||
2530 | void CalendarView::newEvent() | 2531 | void CalendarView::newEvent() |
2531 | { | 2532 | { |
2532 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2533 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2533 | KOAgendaView *aView = mViewManager->agendaView(); | 2534 | KOAgendaView *aView = mViewManager->agendaView(); |
2534 | if (aView) { | 2535 | if (aView) { |
2535 | if (aView->selectionStart().isValid()) { | 2536 | if (aView->selectionStart().isValid()) { |
2536 | if (aView->selectedIsAllDay()) { | 2537 | if (aView->selectedIsAllDay()) { |
2537 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2538 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2538 | } else { | 2539 | } else { |
2539 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2540 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2540 | } | 2541 | } |
2541 | return; | 2542 | return; |
2542 | } | 2543 | } |
2543 | } | 2544 | } |
2544 | 2545 | ||
2545 | QDate date = mNavigator->selectedDates().first(); | 2546 | QDate date = mNavigator->selectedDates().first(); |
2546 | QDateTime current = QDateTime::currentDateTime(); | 2547 | QDateTime current = QDateTime::currentDateTime(); |
2547 | if ( date <= current.date() ) { | 2548 | if ( date <= current.date() ) { |
2548 | int hour = current.time().hour() +1; | 2549 | int hour = current.time().hour() +1; |
2549 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2550 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2550 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2551 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2551 | } else | 2552 | } else |
2552 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2553 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2553 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2554 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2554 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2555 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2555 | } | 2556 | } |
2556 | 2557 | ||
2557 | void CalendarView::newEvent(QDateTime fh) | 2558 | void CalendarView::newEvent(QDateTime fh) |
2558 | { | 2559 | { |
2559 | newEvent(fh, | 2560 | newEvent(fh, |
2560 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2561 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2561 | } | 2562 | } |
2562 | 2563 | ||
2563 | void CalendarView::newEvent(QDate dt) | 2564 | void CalendarView::newEvent(QDate dt) |
2564 | { | 2565 | { |
2565 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2566 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2566 | QDateTime(dt, QTime(0,0,0)), true); | 2567 | QDateTime(dt, QTime(0,0,0)), true); |
2567 | } | 2568 | } |
2568 | 2569 | ||
2569 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2570 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2570 | { | 2571 | { |
2571 | 2572 | ||
2572 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2573 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2573 | if ( mFilterView->filtersEnabled() ) { | 2574 | if ( mFilterView->filtersEnabled() ) { |
2574 | CalFilter *filter = mFilterView->selectedFilter(); | 2575 | CalFilter *filter = mFilterView->selectedFilter(); |
2575 | if (filter && filter->showCategories()) { | 2576 | if (filter && filter->showCategories()) { |
2576 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2577 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2577 | } | 2578 | } |
2578 | if ( filter ) | 2579 | if ( filter ) |
2579 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2580 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2580 | } | 2581 | } |
2581 | showEventEditor(); | 2582 | showEventEditor(); |
2582 | } | 2583 | } |
2583 | void CalendarView::todoAdded(Todo * t) | 2584 | void CalendarView::todoAdded(Todo * t) |
2584 | { | 2585 | { |
2585 | 2586 | ||
2586 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2587 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2587 | updateTodoViews(); | 2588 | updateTodoViews(); |
2588 | } | 2589 | } |
2589 | void CalendarView::todoChanged(Todo * t) | 2590 | void CalendarView::todoChanged(Todo * t) |
2590 | { | 2591 | { |
2591 | emit todoModified( t, 4 ); | 2592 | emit todoModified( t, 4 ); |
2592 | // updateTodoViews(); | 2593 | // updateTodoViews(); |
2593 | } | 2594 | } |
2594 | void CalendarView::todoToBeDeleted(Todo *) | 2595 | void CalendarView::todoToBeDeleted(Todo *) |
2595 | { | 2596 | { |
2596 | //qDebug("todoToBeDeleted(Todo *) "); | 2597 | //qDebug("todoToBeDeleted(Todo *) "); |
2597 | updateTodoViews(); | 2598 | updateTodoViews(); |
2598 | } | 2599 | } |
2599 | void CalendarView::todoDeleted() | 2600 | void CalendarView::todoDeleted() |
2600 | { | 2601 | { |
2601 | //qDebug(" todoDeleted()"); | 2602 | //qDebug(" todoDeleted()"); |
2602 | updateTodoViews(); | 2603 | updateTodoViews(); |
2603 | } | 2604 | } |
2604 | 2605 | ||
2605 | 2606 | ||
2606 | 2607 | ||
2607 | void CalendarView::newTodo() | 2608 | void CalendarView::newTodo() |
2608 | { | 2609 | { |
2609 | 2610 | ||
2610 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2611 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2611 | if ( mFilterView->filtersEnabled() ) { | 2612 | if ( mFilterView->filtersEnabled() ) { |
2612 | CalFilter *filter = mFilterView->selectedFilter(); | 2613 | CalFilter *filter = mFilterView->selectedFilter(); |
2613 | if (filter && filter->showCategories()) { | 2614 | if (filter && filter->showCategories()) { |
2614 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2615 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2615 | } | 2616 | } |
2616 | if ( filter ) | 2617 | if ( filter ) |
2617 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2618 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2618 | } | 2619 | } |
2619 | showTodoEditor(); | 2620 | showTodoEditor(); |
2620 | } | 2621 | } |
2621 | 2622 | ||
2622 | void CalendarView::newSubTodo() | 2623 | void CalendarView::newSubTodo() |
2623 | { | 2624 | { |
2624 | Todo *todo = selectedTodo(); | 2625 | Todo *todo = selectedTodo(); |
2625 | if ( todo ) newSubTodo( todo ); | 2626 | if ( todo ) newSubTodo( todo ); |
2626 | } | 2627 | } |
2627 | 2628 | ||
2628 | void CalendarView::newSubTodo(Todo *parentEvent) | 2629 | void CalendarView::newSubTodo(Todo *parentEvent) |
2629 | { | 2630 | { |
2630 | 2631 | ||
2631 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2632 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2632 | showTodoEditor(); | 2633 | showTodoEditor(); |
2633 | } | 2634 | } |
2634 | 2635 | ||
2635 | void CalendarView::newFloatingEvent() | 2636 | void CalendarView::newFloatingEvent() |
2636 | { | 2637 | { |
2637 | DateList tmpList = mNavigator->selectedDates(); | 2638 | DateList tmpList = mNavigator->selectedDates(); |
2638 | QDate date = tmpList.first(); | 2639 | QDate date = tmpList.first(); |
2639 | 2640 | ||
2640 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2641 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2641 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2642 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2642 | } | 2643 | } |
2643 | 2644 | ||
2644 | 2645 | ||
2645 | void CalendarView::editEvent( Event *event ) | 2646 | void CalendarView::editEvent( Event *event ) |
2646 | { | 2647 | { |
2647 | 2648 | ||
2648 | if ( !event ) return; | 2649 | if ( !event ) return; |
2649 | if ( event->isReadOnly() ) { | 2650 | if ( event->isReadOnly() ) { |
2650 | showEvent( event ); | 2651 | showEvent( event ); |
2651 | return; | 2652 | return; |
2652 | } | 2653 | } |
2653 | mEventEditor->editEvent( event , mFlagEditDescription); | 2654 | mEventEditor->editEvent( event , mFlagEditDescription); |
2654 | showEventEditor(); | 2655 | showEventEditor(); |
2655 | } | 2656 | } |
2656 | void CalendarView::editJournal( Journal *jour ) | 2657 | void CalendarView::editJournal( Journal *jour ) |
2657 | { | 2658 | { |
2658 | if ( !jour ) return; | 2659 | if ( !jour ) return; |
2659 | mDialogManager->hideSearchDialog(); | 2660 | mDialogManager->hideSearchDialog(); |
2660 | mViewManager->showJournalView(); | 2661 | mViewManager->showJournalView(); |
2661 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2662 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2662 | } | 2663 | } |
2663 | void CalendarView::editTodo( Todo *todo ) | 2664 | void CalendarView::editTodo( Todo *todo ) |
2664 | { | 2665 | { |
2665 | if ( !todo ) return; | 2666 | if ( !todo ) return; |
2666 | 2667 | ||
2667 | if ( todo->isReadOnly() ) { | 2668 | if ( todo->isReadOnly() ) { |
2668 | showTodo( todo ); | 2669 | showTodo( todo ); |
2669 | return; | 2670 | return; |
2670 | } | 2671 | } |
2671 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2672 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2672 | showTodoEditor(); | 2673 | showTodoEditor(); |
2673 | 2674 | ||
2674 | } | 2675 | } |
2675 | 2676 | ||
2676 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2677 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2677 | { | 2678 | { |
2678 | if ( !mEventViewerDialog ) { | 2679 | if ( !mEventViewerDialog ) { |
2679 | mEventViewerDialog = new KOEventViewerDialog(this); | 2680 | mEventViewerDialog = new KOEventViewerDialog(this); |
2680 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2681 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2681 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2682 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2682 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2683 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2683 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2684 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2684 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2685 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2685 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2686 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2686 | mEventViewerDialog->resize( 640, 480 ); | 2687 | mEventViewerDialog->resize( 640, 480 ); |
2687 | 2688 | ||
2688 | } | 2689 | } |
2689 | return mEventViewerDialog; | 2690 | return mEventViewerDialog; |
2690 | } | 2691 | } |