-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 2 | ||||
-rw-r--r-- | korganizer/kotodoeditor.cpp | 5 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 62 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 7 |
5 files changed, 73 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index e7b6755..0c39590 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1951,1537 +1951,1537 @@ void CalendarView::writeSettings() | |||
1951 | config->writeEntry("ViewerLayout",list ); | 1951 | config->writeEntry("ViewerLayout",list ); |
1952 | wid = mDialogManager->getSearchDialog(); | 1952 | wid = mDialogManager->getSearchDialog(); |
1953 | if ( wid ) { | 1953 | if ( wid ) { |
1954 | x = wid->geometry().x(); | 1954 | x = wid->geometry().x(); |
1955 | y = wid->geometry().y(); | 1955 | y = wid->geometry().y(); |
1956 | w = wid->width(); | 1956 | w = wid->width(); |
1957 | h = wid->height(); | 1957 | h = wid->height(); |
1958 | list.clear(); | 1958 | list.clear(); |
1959 | list << QString::number( x ); | 1959 | list << QString::number( x ); |
1960 | list << QString::number( y ); | 1960 | list << QString::number( y ); |
1961 | list << QString::number( w ); | 1961 | list << QString::number( w ); |
1962 | list << QString::number( h ); | 1962 | list << QString::number( h ); |
1963 | config->writeEntry("SearchLayout",list ); | 1963 | config->writeEntry("SearchLayout",list ); |
1964 | } | 1964 | } |
1965 | #endif | 1965 | #endif |
1966 | 1966 | ||
1967 | 1967 | ||
1968 | config->sync(); | 1968 | config->sync(); |
1969 | } | 1969 | } |
1970 | 1970 | ||
1971 | void CalendarView::readFilterSettings(KConfig *config) | 1971 | void CalendarView::readFilterSettings(KConfig *config) |
1972 | { | 1972 | { |
1973 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1973 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1974 | 1974 | ||
1975 | mFilters.clear(); | 1975 | mFilters.clear(); |
1976 | 1976 | ||
1977 | config->setGroup("General"); | 1977 | config->setGroup("General"); |
1978 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1978 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1979 | 1979 | ||
1980 | QStringList::ConstIterator it = filterList.begin(); | 1980 | QStringList::ConstIterator it = filterList.begin(); |
1981 | QStringList::ConstIterator end = filterList.end(); | 1981 | QStringList::ConstIterator end = filterList.end(); |
1982 | while(it != end) { | 1982 | while(it != end) { |
1983 | // kdDebug() << " filter: " << (*it) << endl; | 1983 | // kdDebug() << " filter: " << (*it) << endl; |
1984 | 1984 | ||
1985 | CalFilter *filter; | 1985 | CalFilter *filter; |
1986 | filter = new CalFilter(*it); | 1986 | filter = new CalFilter(*it); |
1987 | config->setGroup("Filter_" + (*it)); | 1987 | config->setGroup("Filter_" + (*it)); |
1988 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1988 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1989 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1989 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1990 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1990 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1991 | mFilters.append(filter); | 1991 | mFilters.append(filter); |
1992 | 1992 | ||
1993 | ++it; | 1993 | ++it; |
1994 | } | 1994 | } |
1995 | 1995 | ||
1996 | if (mFilters.count() == 0) { | 1996 | if (mFilters.count() == 0) { |
1997 | CalFilter *filter = new CalFilter(i18n("Default")); | 1997 | CalFilter *filter = new CalFilter(i18n("Default")); |
1998 | mFilters.append(filter); | 1998 | mFilters.append(filter); |
1999 | } | 1999 | } |
2000 | mFilterView->updateFilters(); | 2000 | mFilterView->updateFilters(); |
2001 | config->setGroup("FilterView"); | 2001 | config->setGroup("FilterView"); |
2002 | 2002 | ||
2003 | mFilterView->blockSignals(true); | 2003 | mFilterView->blockSignals(true); |
2004 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2004 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2005 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2005 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2006 | mFilterView->blockSignals(false); | 2006 | mFilterView->blockSignals(false); |
2007 | // We do it manually to avoid it being done twice by the above calls | 2007 | // We do it manually to avoid it being done twice by the above calls |
2008 | updateFilter(); | 2008 | updateFilter(); |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | void CalendarView::writeFilterSettings(KConfig *config) | 2011 | void CalendarView::writeFilterSettings(KConfig *config) |
2012 | { | 2012 | { |
2013 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2013 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2014 | 2014 | ||
2015 | QStringList filterList; | 2015 | QStringList filterList; |
2016 | 2016 | ||
2017 | CalFilter *filter = mFilters.first(); | 2017 | CalFilter *filter = mFilters.first(); |
2018 | while(filter) { | 2018 | while(filter) { |
2019 | // kdDebug() << " fn: " << filter->name() << endl; | 2019 | // kdDebug() << " fn: " << filter->name() << endl; |
2020 | filterList << filter->name(); | 2020 | filterList << filter->name(); |
2021 | config->setGroup("Filter_" + filter->name()); | 2021 | config->setGroup("Filter_" + filter->name()); |
2022 | config->writeEntry("Criteria",filter->criteria()); | 2022 | config->writeEntry("Criteria",filter->criteria()); |
2023 | config->writeEntry("CategoryList",filter->categoryList()); | 2023 | config->writeEntry("CategoryList",filter->categoryList()); |
2024 | filter = mFilters.next(); | 2024 | filter = mFilters.next(); |
2025 | } | 2025 | } |
2026 | config->setGroup("General"); | 2026 | config->setGroup("General"); |
2027 | config->writeEntry("CalendarFilters",filterList); | 2027 | config->writeEntry("CalendarFilters",filterList); |
2028 | 2028 | ||
2029 | config->setGroup("FilterView"); | 2029 | config->setGroup("FilterView"); |
2030 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2030 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2031 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2031 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2032 | } | 2032 | } |
2033 | 2033 | ||
2034 | 2034 | ||
2035 | void CalendarView::goToday() | 2035 | void CalendarView::goToday() |
2036 | { | 2036 | { |
2037 | if ( mViewManager->currentView()->isMonthView() ) | 2037 | if ( mViewManager->currentView()->isMonthView() ) |
2038 | mNavigator->selectTodayMonth(); | 2038 | mNavigator->selectTodayMonth(); |
2039 | else | 2039 | else |
2040 | mNavigator->selectToday(); | 2040 | mNavigator->selectToday(); |
2041 | } | 2041 | } |
2042 | 2042 | ||
2043 | void CalendarView::goNext() | 2043 | void CalendarView::goNext() |
2044 | { | 2044 | { |
2045 | mNavigator->selectNext(); | 2045 | mNavigator->selectNext(); |
2046 | } | 2046 | } |
2047 | 2047 | ||
2048 | void CalendarView::goPrevious() | 2048 | void CalendarView::goPrevious() |
2049 | { | 2049 | { |
2050 | mNavigator->selectPrevious(); | 2050 | mNavigator->selectPrevious(); |
2051 | } | 2051 | } |
2052 | void CalendarView::goNextMonth() | 2052 | void CalendarView::goNextMonth() |
2053 | { | 2053 | { |
2054 | mNavigator->selectNextMonth(); | 2054 | mNavigator->selectNextMonth(); |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | void CalendarView::goPreviousMonth() | 2057 | void CalendarView::goPreviousMonth() |
2058 | { | 2058 | { |
2059 | mNavigator->selectPreviousMonth(); | 2059 | mNavigator->selectPreviousMonth(); |
2060 | } | 2060 | } |
2061 | void CalendarView::writeLocale() | 2061 | void CalendarView::writeLocale() |
2062 | { | 2062 | { |
2063 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2063 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2064 | #if 0 | 2064 | #if 0 |
2065 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2065 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2066 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2066 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2067 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2067 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2068 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2068 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2069 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2069 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2070 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2070 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2071 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2071 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2072 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2072 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2073 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2073 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2074 | KOPrefs::instance()->mDaylightsavingStart, | 2074 | KOPrefs::instance()->mDaylightsavingStart, |
2075 | KOPrefs::instance()->mDaylightsavingEnd ); | 2075 | KOPrefs::instance()->mDaylightsavingEnd ); |
2076 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2076 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2077 | #endif | 2077 | #endif |
2078 | } | 2078 | } |
2079 | void CalendarView::updateConfig() | 2079 | void CalendarView::updateConfig() |
2080 | { | 2080 | { |
2081 | writeLocale(); | 2081 | writeLocale(); |
2082 | if ( KOPrefs::instance()->mUseAppColors ) | 2082 | if ( KOPrefs::instance()->mUseAppColors ) |
2083 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2083 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2084 | emit configChanged(); | 2084 | emit configChanged(); |
2085 | mTodoList->updateConfig(); | 2085 | mTodoList->updateConfig(); |
2086 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2086 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2087 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2087 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2088 | // To make the "fill window" configurations work | 2088 | // To make the "fill window" configurations work |
2089 | //mViewManager->raiseCurrentView(); | 2089 | //mViewManager->raiseCurrentView(); |
2090 | } | 2090 | } |
2091 | 2091 | ||
2092 | 2092 | ||
2093 | void CalendarView::eventChanged(Event *event) | 2093 | void CalendarView::eventChanged(Event *event) |
2094 | { | 2094 | { |
2095 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2095 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2096 | //updateUnmanagedViews(); | 2096 | //updateUnmanagedViews(); |
2097 | } | 2097 | } |
2098 | 2098 | ||
2099 | void CalendarView::eventAdded(Event *event) | 2099 | void CalendarView::eventAdded(Event *event) |
2100 | { | 2100 | { |
2101 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2101 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2102 | } | 2102 | } |
2103 | 2103 | ||
2104 | void CalendarView::eventToBeDeleted(Event *) | 2104 | void CalendarView::eventToBeDeleted(Event *) |
2105 | { | 2105 | { |
2106 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2106 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | void CalendarView::eventDeleted() | 2109 | void CalendarView::eventDeleted() |
2110 | { | 2110 | { |
2111 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2111 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2112 | } | 2112 | } |
2113 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2113 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2114 | { | 2114 | { |
2115 | changeIncidenceDisplay((Incidence *)which, action); | 2115 | changeIncidenceDisplay((Incidence *)which, action); |
2116 | mDateNavigator->updateView(); //LR | 2116 | mDateNavigator->updateView(); //LR |
2117 | //mDialogManager->updateSearchDialog(); | 2117 | //mDialogManager->updateSearchDialog(); |
2118 | 2118 | ||
2119 | if (which) { | 2119 | if (which) { |
2120 | mViewManager->updateWNview(); | 2120 | mViewManager->updateWNview(); |
2121 | //mTodoList->updateView(); | 2121 | //mTodoList->updateView(); |
2122 | } | 2122 | } |
2123 | 2123 | ||
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2126 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2127 | { | 2127 | { |
2128 | updateUnmanagedViews(); | 2128 | updateUnmanagedViews(); |
2129 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2129 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2130 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2130 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2131 | mCalendar->checkAlarmForIncidence( 0, true ); | 2131 | mCalendar->checkAlarmForIncidence( 0, true ); |
2132 | if ( mEventViewerDialog ) | 2132 | if ( mEventViewerDialog ) |
2133 | mEventViewerDialog->hide(); | 2133 | mEventViewerDialog->hide(); |
2134 | } | 2134 | } |
2135 | else | 2135 | else |
2136 | mCalendar->checkAlarmForIncidence( which , false ); | 2136 | mCalendar->checkAlarmForIncidence( which , false ); |
2137 | } | 2137 | } |
2138 | 2138 | ||
2139 | // most of the changeEventDisplays() right now just call the view's | 2139 | // most of the changeEventDisplays() right now just call the view's |
2140 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2140 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2141 | void CalendarView::changeEventDisplay(Event *which, int action) | 2141 | void CalendarView::changeEventDisplay(Event *which, int action) |
2142 | { | 2142 | { |
2143 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2143 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2144 | changeIncidenceDisplay((Incidence *)which, action); | 2144 | changeIncidenceDisplay((Incidence *)which, action); |
2145 | mDateNavigator->updateView(); | 2145 | mDateNavigator->updateView(); |
2146 | //mDialogManager->updateSearchDialog(); | 2146 | //mDialogManager->updateSearchDialog(); |
2147 | 2147 | ||
2148 | if (which) { | 2148 | if (which) { |
2149 | // If there is an event view visible update the display | 2149 | // If there is an event view visible update the display |
2150 | mViewManager->currentView()->changeEventDisplay(which,action); | 2150 | mViewManager->currentView()->changeEventDisplay(which,action); |
2151 | // TODO: check, if update needed | 2151 | // TODO: check, if update needed |
2152 | // if (which->getTodoStatus()) { | 2152 | // if (which->getTodoStatus()) { |
2153 | mTodoList->updateView(); | 2153 | mTodoList->updateView(); |
2154 | // } | 2154 | // } |
2155 | } else { | 2155 | } else { |
2156 | mViewManager->currentView()->updateView(); | 2156 | mViewManager->currentView()->updateView(); |
2157 | } | 2157 | } |
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | 2160 | ||
2161 | void CalendarView::updateTodoViews() | 2161 | void CalendarView::updateTodoViews() |
2162 | { | 2162 | { |
2163 | 2163 | ||
2164 | mTodoList->updateView(); | 2164 | mTodoList->updateView(); |
2165 | mViewManager->currentView()->updateView(); | 2165 | mViewManager->currentView()->updateView(); |
2166 | 2166 | ||
2167 | } | 2167 | } |
2168 | 2168 | ||
2169 | 2169 | ||
2170 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2170 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2171 | { | 2171 | { |
2172 | mTodoList->updateView(); | 2172 | mTodoList->updateView(); |
2173 | mViewManager->updateView(start, end); | 2173 | mViewManager->updateView(start, end); |
2174 | //mDateNavigator->updateView(); | 2174 | //mDateNavigator->updateView(); |
2175 | } | 2175 | } |
2176 | 2176 | ||
2177 | void CalendarView::updateView() | 2177 | void CalendarView::updateView() |
2178 | { | 2178 | { |
2179 | DateList tmpList = mNavigator->selectedDates(); | 2179 | DateList tmpList = mNavigator->selectedDates(); |
2180 | 2180 | ||
2181 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2181 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2182 | mTodoList->updateView(); | 2182 | mTodoList->updateView(); |
2183 | // We assume that the navigator only selects consecutive days. | 2183 | // We assume that the navigator only selects consecutive days. |
2184 | updateView( tmpList.first(), tmpList.last() ); | 2184 | updateView( tmpList.first(), tmpList.last() ); |
2185 | } | 2185 | } |
2186 | 2186 | ||
2187 | void CalendarView::updateUnmanagedViews() | 2187 | void CalendarView::updateUnmanagedViews() |
2188 | { | 2188 | { |
2189 | mDateNavigator->updateDayMatrix(); | 2189 | mDateNavigator->updateDayMatrix(); |
2190 | } | 2190 | } |
2191 | 2191 | ||
2192 | int CalendarView::msgItemDelete(const QString name) | 2192 | int CalendarView::msgItemDelete(const QString name) |
2193 | { | 2193 | { |
2194 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2194 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2195 | i18n("This item will be\npermanently deleted."), | 2195 | i18n("This item will be\npermanently deleted."), |
2196 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2196 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2197 | } | 2197 | } |
2198 | 2198 | ||
2199 | 2199 | ||
2200 | void CalendarView::edit_cut() | 2200 | void CalendarView::edit_cut() |
2201 | { | 2201 | { |
2202 | Event *anEvent=0; | 2202 | Event *anEvent=0; |
2203 | 2203 | ||
2204 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2204 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2205 | 2205 | ||
2206 | if (mViewManager->currentView()->isEventView()) { | 2206 | if (mViewManager->currentView()->isEventView()) { |
2207 | if ( incidence && incidence->type() == "Event" ) { | 2207 | if ( incidence && incidence->type() == "Event" ) { |
2208 | anEvent = static_cast<Event *>(incidence); | 2208 | anEvent = static_cast<Event *>(incidence); |
2209 | } | 2209 | } |
2210 | } | 2210 | } |
2211 | 2211 | ||
2212 | if (!anEvent) { | 2212 | if (!anEvent) { |
2213 | KNotifyClient::beep(); | 2213 | KNotifyClient::beep(); |
2214 | return; | 2214 | return; |
2215 | } | 2215 | } |
2216 | DndFactory factory( mCalendar ); | 2216 | DndFactory factory( mCalendar ); |
2217 | factory.cutEvent(anEvent); | 2217 | factory.cutEvent(anEvent); |
2218 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2218 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2219 | } | 2219 | } |
2220 | 2220 | ||
2221 | void CalendarView::edit_copy() | 2221 | void CalendarView::edit_copy() |
2222 | { | 2222 | { |
2223 | Event *anEvent=0; | 2223 | Event *anEvent=0; |
2224 | 2224 | ||
2225 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2225 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2226 | 2226 | ||
2227 | if (mViewManager->currentView()->isEventView()) { | 2227 | if (mViewManager->currentView()->isEventView()) { |
2228 | if ( incidence && incidence->type() == "Event" ) { | 2228 | if ( incidence && incidence->type() == "Event" ) { |
2229 | anEvent = static_cast<Event *>(incidence); | 2229 | anEvent = static_cast<Event *>(incidence); |
2230 | } | 2230 | } |
2231 | } | 2231 | } |
2232 | 2232 | ||
2233 | if (!anEvent) { | 2233 | if (!anEvent) { |
2234 | KNotifyClient::beep(); | 2234 | KNotifyClient::beep(); |
2235 | return; | 2235 | return; |
2236 | } | 2236 | } |
2237 | DndFactory factory( mCalendar ); | 2237 | DndFactory factory( mCalendar ); |
2238 | factory.copyEvent(anEvent); | 2238 | factory.copyEvent(anEvent); |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | void CalendarView::edit_paste() | 2241 | void CalendarView::edit_paste() |
2242 | { | 2242 | { |
2243 | QDate date = mNavigator->selectedDates().first(); | 2243 | QDate date = mNavigator->selectedDates().first(); |
2244 | 2244 | ||
2245 | DndFactory factory( mCalendar ); | 2245 | DndFactory factory( mCalendar ); |
2246 | Event *pastedEvent = factory.pasteEvent( date ); | 2246 | Event *pastedEvent = factory.pasteEvent( date ); |
2247 | 2247 | ||
2248 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2248 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2249 | } | 2249 | } |
2250 | 2250 | ||
2251 | void CalendarView::edit_options() | 2251 | void CalendarView::edit_options() |
2252 | { | 2252 | { |
2253 | mDialogManager->showOptionsDialog(); | 2253 | mDialogManager->showOptionsDialog(); |
2254 | //writeSettings(); | 2254 | //writeSettings(); |
2255 | } | 2255 | } |
2256 | 2256 | ||
2257 | 2257 | ||
2258 | void CalendarView::slotSelectPickerDate( QDate d) | 2258 | void CalendarView::slotSelectPickerDate( QDate d) |
2259 | { | 2259 | { |
2260 | mDateFrame->hide(); | 2260 | mDateFrame->hide(); |
2261 | if ( mDatePickerMode == 1 ) { | 2261 | if ( mDatePickerMode == 1 ) { |
2262 | mNavigator->slotDaySelect( d ); | 2262 | mNavigator->slotDaySelect( d ); |
2263 | } else if ( mDatePickerMode == 2 ) { | 2263 | } else if ( mDatePickerMode == 2 ) { |
2264 | if ( mMoveIncidence->type() == "Todo" ) { | 2264 | if ( mMoveIncidence->type() == "Todo" ) { |
2265 | Todo * to = (Todo *) mMoveIncidence; | 2265 | Todo * to = (Todo *) mMoveIncidence; |
2266 | QTime tim; | 2266 | QTime tim; |
2267 | if ( to->hasDueDate() ) | 2267 | if ( to->hasDueDate() ) |
2268 | tim = to->dtDue().time(); | 2268 | tim = to->dtDue().time(); |
2269 | else { | 2269 | else { |
2270 | tim = QTime ( 0,0,0 ); | 2270 | tim = QTime ( 0,0,0 ); |
2271 | to->setFloats( true ); | 2271 | to->setFloats( true ); |
2272 | to->setHasDueDate( true ); | 2272 | to->setHasDueDate( true ); |
2273 | } | 2273 | } |
2274 | QDateTime dt ( d,tim ); | 2274 | QDateTime dt ( d,tim ); |
2275 | to->setDtDue( dt ); | 2275 | to->setDtDue( dt ); |
2276 | todoChanged( to ); | 2276 | todoChanged( to ); |
2277 | } else { | 2277 | } else { |
2278 | if ( mMoveIncidence->doesRecur() ) { | 2278 | if ( mMoveIncidence->doesRecur() ) { |
2279 | #if 0 | 2279 | #if 0 |
2280 | // PENDING implement this | 2280 | // PENDING implement this |
2281 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2281 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2282 | mCalendar()->addIncidence( newInc ); | 2282 | mCalendar()->addIncidence( newInc ); |
2283 | if ( mMoveIncidence->type() == "Todo" ) | 2283 | if ( mMoveIncidence->type() == "Todo" ) |
2284 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2284 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2285 | else | 2285 | else |
2286 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2286 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2287 | mMoveIncidence = newInc; | 2287 | mMoveIncidence = newInc; |
2288 | 2288 | ||
2289 | #endif | 2289 | #endif |
2290 | } | 2290 | } |
2291 | QTime tim = mMoveIncidence->dtStart().time(); | 2291 | QTime tim = mMoveIncidence->dtStart().time(); |
2292 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2292 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2293 | QDateTime dt ( d,tim ); | 2293 | QDateTime dt ( d,tim ); |
2294 | mMoveIncidence->setDtStart( dt ); | 2294 | mMoveIncidence->setDtStart( dt ); |
2295 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2295 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2296 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2296 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2297 | } | 2297 | } |
2298 | 2298 | ||
2299 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2299 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2300 | } | 2300 | } |
2301 | } | 2301 | } |
2302 | 2302 | ||
2303 | void CalendarView::removeCategories() | 2303 | void CalendarView::removeCategories() |
2304 | { | 2304 | { |
2305 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2305 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2306 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2306 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2307 | QStringList catIncList; | 2307 | QStringList catIncList; |
2308 | QStringList newCatList; | 2308 | QStringList newCatList; |
2309 | Incidence* inc = incList.first(); | 2309 | Incidence* inc = incList.first(); |
2310 | int i; | 2310 | int i; |
2311 | int count = 0; | 2311 | int count = 0; |
2312 | while ( inc ) { | 2312 | while ( inc ) { |
2313 | newCatList.clear(); | 2313 | newCatList.clear(); |
2314 | catIncList = inc->categories() ; | 2314 | catIncList = inc->categories() ; |
2315 | for( i = 0; i< catIncList.count(); ++i ) { | 2315 | for( i = 0; i< catIncList.count(); ++i ) { |
2316 | if ( catList.contains (catIncList[i])) | 2316 | if ( catList.contains (catIncList[i])) |
2317 | newCatList.append( catIncList[i] ); | 2317 | newCatList.append( catIncList[i] ); |
2318 | } | 2318 | } |
2319 | newCatList.sort(); | 2319 | newCatList.sort(); |
2320 | inc->setCategories( newCatList.join(",") ); | 2320 | inc->setCategories( newCatList.join(",") ); |
2321 | inc = incList.next(); | 2321 | inc = incList.next(); |
2322 | } | 2322 | } |
2323 | } | 2323 | } |
2324 | 2324 | ||
2325 | int CalendarView::addCategories() | 2325 | int CalendarView::addCategories() |
2326 | { | 2326 | { |
2327 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2327 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2328 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2328 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2329 | QStringList catIncList; | 2329 | QStringList catIncList; |
2330 | Incidence* inc = incList.first(); | 2330 | Incidence* inc = incList.first(); |
2331 | int i; | 2331 | int i; |
2332 | int count = 0; | 2332 | int count = 0; |
2333 | while ( inc ) { | 2333 | while ( inc ) { |
2334 | catIncList = inc->categories() ; | 2334 | catIncList = inc->categories() ; |
2335 | for( i = 0; i< catIncList.count(); ++i ) { | 2335 | for( i = 0; i< catIncList.count(); ++i ) { |
2336 | if ( !catList.contains (catIncList[i])) { | 2336 | if ( !catList.contains (catIncList[i])) { |
2337 | catList.append( catIncList[i] ); | 2337 | catList.append( catIncList[i] ); |
2338 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2338 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2339 | ++count; | 2339 | ++count; |
2340 | } | 2340 | } |
2341 | } | 2341 | } |
2342 | inc = incList.next(); | 2342 | inc = incList.next(); |
2343 | } | 2343 | } |
2344 | catList.sort(); | 2344 | catList.sort(); |
2345 | KOPrefs::instance()->mCustomCategories = catList; | 2345 | KOPrefs::instance()->mCustomCategories = catList; |
2346 | return count; | 2346 | return count; |
2347 | } | 2347 | } |
2348 | 2348 | ||
2349 | void CalendarView::manageCategories() | 2349 | void CalendarView::manageCategories() |
2350 | { | 2350 | { |
2351 | KOCatPrefs* cp = new KOCatPrefs(); | 2351 | KOCatPrefs* cp = new KOCatPrefs(); |
2352 | cp->show(); | 2352 | cp->show(); |
2353 | int w =cp->sizeHint().width() ; | 2353 | int w =cp->sizeHint().width() ; |
2354 | int h = cp->sizeHint().height() ; | 2354 | int h = cp->sizeHint().height() ; |
2355 | int dw = QApplication::desktop()->width(); | 2355 | int dw = QApplication::desktop()->width(); |
2356 | int dh = QApplication::desktop()->height(); | 2356 | int dh = QApplication::desktop()->height(); |
2357 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2357 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2358 | if ( !cp->exec() ) { | 2358 | if ( !cp->exec() ) { |
2359 | delete cp; | 2359 | delete cp; |
2360 | return; | 2360 | return; |
2361 | } | 2361 | } |
2362 | int count = 0; | 2362 | int count = 0; |
2363 | if ( cp->addCat() ) { | 2363 | if ( cp->addCat() ) { |
2364 | count = addCategories(); | 2364 | count = addCategories(); |
2365 | if ( count ) { | 2365 | if ( count ) { |
2366 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2366 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2367 | writeSettings(); | 2367 | writeSettings(); |
2368 | } else | 2368 | } else |
2369 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2369 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2370 | } else { | 2370 | } else { |
2371 | removeCategories(); | 2371 | removeCategories(); |
2372 | updateView(); | 2372 | updateView(); |
2373 | } | 2373 | } |
2374 | delete cp; | 2374 | delete cp; |
2375 | } | 2375 | } |
2376 | 2376 | ||
2377 | void CalendarView::beamIncidence(Incidence * Inc) | 2377 | void CalendarView::beamIncidence(Incidence * Inc) |
2378 | { | 2378 | { |
2379 | QPtrList<Incidence> delSel ; | 2379 | QPtrList<Incidence> delSel ; |
2380 | delSel.append(Inc); | 2380 | delSel.append(Inc); |
2381 | beamIncidenceList( delSel ); | 2381 | beamIncidenceList( delSel ); |
2382 | } | 2382 | } |
2383 | void CalendarView::beamCalendar() | 2383 | void CalendarView::beamCalendar() |
2384 | { | 2384 | { |
2385 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2385 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2386 | //qDebug("beamCalendar() "); | 2386 | //qDebug("beamCalendar() "); |
2387 | beamIncidenceList( delSel ); | 2387 | beamIncidenceList( delSel ); |
2388 | } | 2388 | } |
2389 | void CalendarView::beamFilteredCalendar() | 2389 | void CalendarView::beamFilteredCalendar() |
2390 | { | 2390 | { |
2391 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2391 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2392 | //qDebug("beamFilteredCalendar() "); | 2392 | //qDebug("beamFilteredCalendar() "); |
2393 | beamIncidenceList( delSel ); | 2393 | beamIncidenceList( delSel ); |
2394 | } | 2394 | } |
2395 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2395 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2396 | { | 2396 | { |
2397 | if ( beamDialog->exec () == QDialog::Rejected ) | 2397 | if ( beamDialog->exec () == QDialog::Rejected ) |
2398 | return; | 2398 | return; |
2399 | #ifdef DESKTOP_VERSION | 2399 | #ifdef DESKTOP_VERSION |
2400 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2400 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2401 | #else | 2401 | #else |
2402 | QString fn = "/tmp/kopibeamfile"; | 2402 | QString fn = "/tmp/kopibeamfile"; |
2403 | #endif | 2403 | #endif |
2404 | QString mes; | 2404 | QString mes; |
2405 | bool createbup = true; | 2405 | bool createbup = true; |
2406 | if ( createbup ) { | 2406 | if ( createbup ) { |
2407 | QString description = "\n"; | 2407 | QString description = "\n"; |
2408 | CalendarLocal* cal = new CalendarLocal(); | 2408 | CalendarLocal* cal = new CalendarLocal(); |
2409 | if ( beamDialog->beamLocal() ) | 2409 | if ( beamDialog->beamLocal() ) |
2410 | cal->setLocalTime(); | 2410 | cal->setLocalTime(); |
2411 | else | 2411 | else |
2412 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2412 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2413 | Incidence *incidence = delSel.first(); | 2413 | Incidence *incidence = delSel.first(); |
2414 | bool addText = false; | 2414 | bool addText = false; |
2415 | if ( delSel.count() < 10 ) | 2415 | if ( delSel.count() < 10 ) |
2416 | addText = true; | 2416 | addText = true; |
2417 | else { | 2417 | else { |
2418 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2418 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2419 | } | 2419 | } |
2420 | while ( incidence ) { | 2420 | while ( incidence ) { |
2421 | Incidence *in = incidence->clone(); | 2421 | Incidence *in = incidence->clone(); |
2422 | if ( ! in->summary().isEmpty() ) { | 2422 | if ( ! in->summary().isEmpty() ) { |
2423 | in->setDescription(""); | 2423 | in->setDescription(""); |
2424 | } else { | 2424 | } else { |
2425 | in->setSummary( in->description().left(20)); | 2425 | in->setSummary( in->description().left(20)); |
2426 | in->setDescription(""); | 2426 | in->setDescription(""); |
2427 | } | 2427 | } |
2428 | if ( addText ) | 2428 | if ( addText ) |
2429 | description += in->summary() + "\n"; | 2429 | description += in->summary() + "\n"; |
2430 | cal->addIncidence( in ); | 2430 | cal->addIncidence( in ); |
2431 | incidence = delSel.next(); | 2431 | incidence = delSel.next(); |
2432 | } | 2432 | } |
2433 | if ( beamDialog->beamVcal() ) { | 2433 | if ( beamDialog->beamVcal() ) { |
2434 | fn += ".vcs"; | 2434 | fn += ".vcs"; |
2435 | FileStorage storage( cal, fn, new VCalFormat ); | 2435 | FileStorage storage( cal, fn, new VCalFormat ); |
2436 | storage.save(); | 2436 | storage.save(); |
2437 | } else { | 2437 | } else { |
2438 | fn += ".ics"; | 2438 | fn += ".ics"; |
2439 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2439 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2440 | storage.save(); | 2440 | storage.save(); |
2441 | } | 2441 | } |
2442 | delete cal; | 2442 | delete cal; |
2443 | mes = i18n("KO/Pi: Ready for beaming"); | 2443 | mes = i18n("KO/Pi: Ready for beaming"); |
2444 | topLevelWidget()->setCaption(mes); | 2444 | topLevelWidget()->setCaption(mes); |
2445 | KApplication::convert2latin1( fn ); | 2445 | KApplication::convert2latin1( fn ); |
2446 | #ifndef DESKTOP_VERSION | 2446 | #ifndef DESKTOP_VERSION |
2447 | Ir *ir = new Ir( this ); | 2447 | Ir *ir = new Ir( this ); |
2448 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2448 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2449 | ir->send( fn, description, "text/x-vCalendar" ); | 2449 | ir->send( fn, description, "text/x-vCalendar" ); |
2450 | #endif | 2450 | #endif |
2451 | } | 2451 | } |
2452 | } | 2452 | } |
2453 | void CalendarView::beamDone( Ir *ir ) | 2453 | void CalendarView::beamDone( Ir *ir ) |
2454 | { | 2454 | { |
2455 | #ifndef DESKTOP_VERSION | 2455 | #ifndef DESKTOP_VERSION |
2456 | delete ir; | 2456 | delete ir; |
2457 | #endif | 2457 | #endif |
2458 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2458 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2459 | topLevelWidget()->raise(); | 2459 | topLevelWidget()->raise(); |
2460 | } | 2460 | } |
2461 | 2461 | ||
2462 | void CalendarView::moveIncidence(Incidence * inc ) | 2462 | void CalendarView::moveIncidence(Incidence * inc ) |
2463 | { | 2463 | { |
2464 | if ( !inc ) return; | 2464 | if ( !inc ) return; |
2465 | // qDebug("showDatePickerForIncidence( ) "); | 2465 | // qDebug("showDatePickerForIncidence( ) "); |
2466 | if ( mDateFrame->isVisible() ) | 2466 | if ( mDateFrame->isVisible() ) |
2467 | mDateFrame->hide(); | 2467 | mDateFrame->hide(); |
2468 | else { | 2468 | else { |
2469 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2469 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2470 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2470 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2471 | int dw = QApplication::desktop()->width(); | 2471 | int dw = QApplication::desktop()->width(); |
2472 | int dh = QApplication::desktop()->height(); | 2472 | int dh = QApplication::desktop()->height(); |
2473 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2473 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2474 | mDateFrame->show(); | 2474 | mDateFrame->show(); |
2475 | } | 2475 | } |
2476 | mDatePickerMode = 2; | 2476 | mDatePickerMode = 2; |
2477 | mMoveIncidence = inc ; | 2477 | mMoveIncidence = inc ; |
2478 | QDate da; | 2478 | QDate da; |
2479 | if ( mMoveIncidence->type() == "Todo" ) { | 2479 | if ( mMoveIncidence->type() == "Todo" ) { |
2480 | Todo * to = (Todo *) mMoveIncidence; | 2480 | Todo * to = (Todo *) mMoveIncidence; |
2481 | if ( to->hasDueDate() ) | 2481 | if ( to->hasDueDate() ) |
2482 | da = to->dtDue().date(); | 2482 | da = to->dtDue().date(); |
2483 | else | 2483 | else |
2484 | da = QDate::currentDate(); | 2484 | da = QDate::currentDate(); |
2485 | } else { | 2485 | } else { |
2486 | da = mMoveIncidence->dtStart().date(); | 2486 | da = mMoveIncidence->dtStart().date(); |
2487 | } | 2487 | } |
2488 | //PENDING set date for recurring incidence to date of recurrence | 2488 | //PENDING set date for recurring incidence to date of recurrence |
2489 | //mMoveIncidenceOldDate; | 2489 | //mMoveIncidenceOldDate; |
2490 | mDatePicker->setDate( da ); | 2490 | mDatePicker->setDate( da ); |
2491 | } | 2491 | } |
2492 | void CalendarView::showDatePicker( ) | 2492 | void CalendarView::showDatePicker( ) |
2493 | { | 2493 | { |
2494 | //qDebug("CalendarView::showDatePicker( ) "); | 2494 | //qDebug("CalendarView::showDatePicker( ) "); |
2495 | if ( mDateFrame->isVisible() ) | 2495 | if ( mDateFrame->isVisible() ) |
2496 | mDateFrame->hide(); | 2496 | mDateFrame->hide(); |
2497 | else { | 2497 | else { |
2498 | int w =mDatePicker->sizeHint().width() ; | 2498 | int w =mDatePicker->sizeHint().width() ; |
2499 | int h = mDatePicker->sizeHint().height() ; | 2499 | int h = mDatePicker->sizeHint().height() ; |
2500 | int dw = QApplication::desktop()->width(); | 2500 | int dw = QApplication::desktop()->width(); |
2501 | int dh = QApplication::desktop()->height(); | 2501 | int dh = QApplication::desktop()->height(); |
2502 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2502 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2503 | mDateFrame->show(); | 2503 | mDateFrame->show(); |
2504 | } | 2504 | } |
2505 | mDatePickerMode = 1; | 2505 | mDatePickerMode = 1; |
2506 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2506 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2507 | } | 2507 | } |
2508 | 2508 | ||
2509 | void CalendarView::showEventEditor() | 2509 | void CalendarView::showEventEditor() |
2510 | { | 2510 | { |
2511 | #ifdef DESKTOP_VERSION | 2511 | #ifdef DESKTOP_VERSION |
2512 | mEventEditor->show(); | 2512 | mEventEditor->show(); |
2513 | #else | 2513 | #else |
2514 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2514 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2515 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2515 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2516 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2516 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2517 | qApp->processEvents(); | 2517 | qApp->processEvents(); |
2518 | delete mEventEditor; | 2518 | delete mEventEditor; |
2519 | mEventEditor = mDialogManager->getEventEditor(); | 2519 | mEventEditor = mDialogManager->getEventEditor(); |
2520 | topLevelWidget()->setCaption( i18n("") ); | 2520 | topLevelWidget()->setCaption( i18n("") ); |
2521 | } | 2521 | } |
2522 | mEventEditor->showMaximized(); | 2522 | mEventEditor->showMaximized(); |
2523 | #endif | 2523 | #endif |
2524 | } | 2524 | } |
2525 | void CalendarView::showTodoEditor() | 2525 | void CalendarView::showTodoEditor() |
2526 | { | 2526 | { |
2527 | #ifdef DESKTOP_VERSION | 2527 | #ifdef DESKTOP_VERSION |
2528 | mTodoEditor->show(); | 2528 | mTodoEditor->show(); |
2529 | #else | 2529 | #else |
2530 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2530 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2531 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2531 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2532 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2532 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2533 | qApp->processEvents(); | 2533 | qApp->processEvents(); |
2534 | delete mTodoEditor; | 2534 | delete mTodoEditor; |
2535 | mTodoEditor = mDialogManager->getTodoEditor(); | 2535 | mTodoEditor = mDialogManager->getTodoEditor(); |
2536 | topLevelWidget()->setCaption( i18n("") ); | 2536 | topLevelWidget()->setCaption( i18n("") ); |
2537 | } | 2537 | } |
2538 | mTodoEditor->showMaximized(); | 2538 | mTodoEditor->showMaximized(); |
2539 | #endif | 2539 | #endif |
2540 | } | 2540 | } |
2541 | 2541 | ||
2542 | void CalendarView::cloneIncidence() | 2542 | void CalendarView::cloneIncidence() |
2543 | { | 2543 | { |
2544 | Incidence *incidence = currentSelection(); | 2544 | Incidence *incidence = currentSelection(); |
2545 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2545 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2546 | if ( incidence ) { | 2546 | if ( incidence ) { |
2547 | cloneIncidence(incidence); | 2547 | cloneIncidence(incidence); |
2548 | } | 2548 | } |
2549 | } | 2549 | } |
2550 | void CalendarView::moveIncidence() | 2550 | void CalendarView::moveIncidence() |
2551 | { | 2551 | { |
2552 | Incidence *incidence = currentSelection(); | 2552 | Incidence *incidence = currentSelection(); |
2553 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2553 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2554 | if ( incidence ) { | 2554 | if ( incidence ) { |
2555 | moveIncidence(incidence); | 2555 | moveIncidence(incidence); |
2556 | } | 2556 | } |
2557 | } | 2557 | } |
2558 | void CalendarView::beamIncidence() | 2558 | void CalendarView::beamIncidence() |
2559 | { | 2559 | { |
2560 | Incidence *incidence = currentSelection(); | 2560 | Incidence *incidence = currentSelection(); |
2561 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2561 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2562 | if ( incidence ) { | 2562 | if ( incidence ) { |
2563 | beamIncidence(incidence); | 2563 | beamIncidence(incidence); |
2564 | } | 2564 | } |
2565 | } | 2565 | } |
2566 | void CalendarView::toggleCancelIncidence() | 2566 | void CalendarView::toggleCancelIncidence() |
2567 | { | 2567 | { |
2568 | Incidence *incidence = currentSelection(); | 2568 | Incidence *incidence = currentSelection(); |
2569 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2569 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2570 | if ( incidence ) { | 2570 | if ( incidence ) { |
2571 | cancelIncidence(incidence); | 2571 | cancelIncidence(incidence); |
2572 | } | 2572 | } |
2573 | } | 2573 | } |
2574 | 2574 | ||
2575 | 2575 | ||
2576 | void CalendarView::cancelIncidence(Incidence * inc ) | 2576 | void CalendarView::cancelIncidence(Incidence * inc ) |
2577 | { | 2577 | { |
2578 | inc->setCancelled( ! inc->cancelled() ); | 2578 | inc->setCancelled( ! inc->cancelled() ); |
2579 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2579 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2580 | updateView(); | 2580 | updateView(); |
2581 | } | 2581 | } |
2582 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2582 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2583 | { | 2583 | { |
2584 | Incidence * newInc = orgInc->clone(); | 2584 | Incidence * newInc = orgInc->clone(); |
2585 | newInc->recreate(); | 2585 | newInc->recreate(); |
2586 | 2586 | ||
2587 | if ( newInc->type() == "Todo" ) { | 2587 | if ( newInc->type() == "Todo" ) { |
2588 | Todo* t = (Todo*) newInc; | 2588 | Todo* t = (Todo*) newInc; |
2589 | showTodoEditor(); | 2589 | showTodoEditor(); |
2590 | mTodoEditor->editTodo( t ); | 2590 | mTodoEditor->editTodo( t ); |
2591 | if ( mTodoEditor->exec() ) { | 2591 | if ( mTodoEditor->exec() ) { |
2592 | mCalendar->addTodo( t ); | 2592 | mCalendar->addTodo( t ); |
2593 | updateView(); | 2593 | updateView(); |
2594 | } else { | 2594 | } else { |
2595 | delete t; | 2595 | delete t; |
2596 | } | 2596 | } |
2597 | } | 2597 | } |
2598 | else { | 2598 | else { |
2599 | Event* e = (Event*) newInc; | 2599 | Event* e = (Event*) newInc; |
2600 | showEventEditor(); | 2600 | showEventEditor(); |
2601 | mEventEditor->editEvent( e ); | 2601 | mEventEditor->editEvent( e ); |
2602 | if ( mEventEditor->exec() ) { | 2602 | if ( mEventEditor->exec() ) { |
2603 | mCalendar->addEvent( e ); | 2603 | mCalendar->addEvent( e ); |
2604 | updateView(); | 2604 | updateView(); |
2605 | } else { | 2605 | } else { |
2606 | delete e; | 2606 | delete e; |
2607 | } | 2607 | } |
2608 | } | 2608 | } |
2609 | } | 2609 | } |
2610 | 2610 | ||
2611 | void CalendarView::newEvent() | 2611 | void CalendarView::newEvent() |
2612 | { | 2612 | { |
2613 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2613 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2614 | KOAgendaView *aView = mViewManager->agendaView(); | 2614 | KOAgendaView *aView = mViewManager->agendaView(); |
2615 | if (aView) { | 2615 | if (aView) { |
2616 | if (aView->selectionStart().isValid()) { | 2616 | if (aView->selectionStart().isValid()) { |
2617 | if (aView->selectedIsAllDay()) { | 2617 | if (aView->selectedIsAllDay()) { |
2618 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2618 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2619 | } else { | 2619 | } else { |
2620 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2620 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2621 | } | 2621 | } |
2622 | return; | 2622 | return; |
2623 | } | 2623 | } |
2624 | } | 2624 | } |
2625 | 2625 | ||
2626 | QDate date = mNavigator->selectedDates().first(); | 2626 | QDate date = mNavigator->selectedDates().first(); |
2627 | QDateTime current = QDateTime::currentDateTime(); | 2627 | QDateTime current = QDateTime::currentDateTime(); |
2628 | if ( date <= current.date() ) { | 2628 | if ( date <= current.date() ) { |
2629 | int hour = current.time().hour() +1; | 2629 | int hour = current.time().hour() +1; |
2630 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2630 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2631 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2631 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2632 | } else | 2632 | } else |
2633 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2633 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2634 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2634 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2635 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2635 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2636 | } | 2636 | } |
2637 | 2637 | ||
2638 | void CalendarView::newEvent(QDateTime fh) | 2638 | void CalendarView::newEvent(QDateTime fh) |
2639 | { | 2639 | { |
2640 | newEvent(fh, | 2640 | newEvent(fh, |
2641 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2641 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2642 | } | 2642 | } |
2643 | 2643 | ||
2644 | void CalendarView::newEvent(QDate dt) | 2644 | void CalendarView::newEvent(QDate dt) |
2645 | { | 2645 | { |
2646 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2646 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2647 | QDateTime(dt, QTime(0,0,0)), true); | 2647 | QDateTime(dt, QTime(0,0,0)), true); |
2648 | } | 2648 | } |
2649 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2649 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2650 | { | 2650 | { |
2651 | newEvent(fromHint, toHint, false); | 2651 | newEvent(fromHint, toHint, false); |
2652 | } | 2652 | } |
2653 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2653 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2654 | { | 2654 | { |
2655 | 2655 | ||
2656 | showEventEditor(); | 2656 | showEventEditor(); |
2657 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2657 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2658 | if ( mFilterView->filtersEnabled() ) { | 2658 | if ( mFilterView->filtersEnabled() ) { |
2659 | CalFilter *filter = mFilterView->selectedFilter(); | 2659 | CalFilter *filter = mFilterView->selectedFilter(); |
2660 | if (filter && filter->showCategories()) { | 2660 | if (filter && filter->showCategories()) { |
2661 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2661 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2662 | } | 2662 | } |
2663 | if ( filter ) | 2663 | if ( filter ) |
2664 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2664 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2665 | } | 2665 | } |
2666 | } | 2666 | } |
2667 | void CalendarView::todoAdded(Todo * t) | 2667 | void CalendarView::todoAdded(Todo * t) |
2668 | { | 2668 | { |
2669 | 2669 | ||
2670 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2670 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2671 | updateTodoViews(); | 2671 | updateTodoViews(); |
2672 | } | 2672 | } |
2673 | void CalendarView::todoChanged(Todo * t) | 2673 | void CalendarView::todoChanged(Todo * t) |
2674 | { | 2674 | { |
2675 | emit todoModified( t, 4 ); | 2675 | emit todoModified( t, 4 ); |
2676 | // updateTodoViews(); | 2676 | // updateTodoViews(); |
2677 | } | 2677 | } |
2678 | void CalendarView::todoToBeDeleted(Todo *) | 2678 | void CalendarView::todoToBeDeleted(Todo *) |
2679 | { | 2679 | { |
2680 | //qDebug("todoToBeDeleted(Todo *) "); | 2680 | //qDebug("todoToBeDeleted(Todo *) "); |
2681 | updateTodoViews(); | 2681 | updateTodoViews(); |
2682 | } | 2682 | } |
2683 | void CalendarView::todoDeleted() | 2683 | void CalendarView::todoDeleted() |
2684 | { | 2684 | { |
2685 | //qDebug(" todoDeleted()"); | 2685 | //qDebug(" todoDeleted()"); |
2686 | updateTodoViews(); | 2686 | updateTodoViews(); |
2687 | } | 2687 | } |
2688 | 2688 | ||
2689 | 2689 | ||
2690 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2690 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2691 | { | 2691 | { |
2692 | showTodoEditor(); | 2692 | showTodoEditor(); |
2693 | mTodoEditor->newTodo(dt,0,allday); | 2693 | mTodoEditor->newTodo(dt,0,allday); |
2694 | if ( mFilterView->filtersEnabled() ) { | 2694 | if ( mFilterView->filtersEnabled() ) { |
2695 | CalFilter *filter = mFilterView->selectedFilter(); | 2695 | CalFilter *filter = mFilterView->selectedFilter(); |
2696 | if (filter && filter->showCategories()) { | 2696 | if (filter && filter->showCategories()) { |
2697 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2697 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2698 | } | 2698 | } |
2699 | if ( filter ) | 2699 | if ( filter ) |
2700 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2700 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2701 | } | 2701 | } |
2702 | } | 2702 | } |
2703 | 2703 | ||
2704 | void CalendarView::newTodo() | 2704 | void CalendarView::newTodo() |
2705 | { | 2705 | { |
2706 | newTodoDateTime( QDateTime(),true ); | 2706 | newTodoDateTime( QDateTime(),true ); |
2707 | } | 2707 | } |
2708 | 2708 | ||
2709 | void CalendarView::newSubTodo() | 2709 | void CalendarView::newSubTodo() |
2710 | { | 2710 | { |
2711 | Todo *todo = selectedTodo(); | 2711 | Todo *todo = selectedTodo(); |
2712 | if ( todo ) newSubTodo( todo ); | 2712 | if ( todo ) newSubTodo( todo ); |
2713 | } | 2713 | } |
2714 | 2714 | ||
2715 | void CalendarView::newSubTodo(Todo *parentEvent) | 2715 | void CalendarView::newSubTodo(Todo *parentEvent) |
2716 | { | 2716 | { |
2717 | 2717 | ||
2718 | showTodoEditor(); | 2718 | showTodoEditor(); |
2719 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2719 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2720 | } | 2720 | } |
2721 | 2721 | ||
2722 | void CalendarView::newFloatingEvent() | 2722 | void CalendarView::newFloatingEvent() |
2723 | { | 2723 | { |
2724 | DateList tmpList = mNavigator->selectedDates(); | 2724 | DateList tmpList = mNavigator->selectedDates(); |
2725 | QDate date = tmpList.first(); | 2725 | QDate date = tmpList.first(); |
2726 | 2726 | ||
2727 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2727 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2728 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2728 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2729 | } | 2729 | } |
2730 | 2730 | ||
2731 | 2731 | ||
2732 | void CalendarView::editEvent( Event *event ) | 2732 | void CalendarView::editEvent( Event *event ) |
2733 | { | 2733 | { |
2734 | 2734 | ||
2735 | if ( !event ) return; | 2735 | if ( !event ) return; |
2736 | if ( event->isReadOnly() ) { | 2736 | if ( event->isReadOnly() ) { |
2737 | showEvent( event ); | 2737 | showEvent( event ); |
2738 | return; | 2738 | return; |
2739 | } | 2739 | } |
2740 | showEventEditor(); | 2740 | showEventEditor(); |
2741 | mEventEditor->editEvent( event , mFlagEditDescription); | 2741 | mEventEditor->editEvent( event , mFlagEditDescription); |
2742 | } | 2742 | } |
2743 | void CalendarView::editJournal( Journal *jour ) | 2743 | void CalendarView::editJournal( Journal *jour ) |
2744 | { | 2744 | { |
2745 | if ( !jour ) return; | 2745 | if ( !jour ) return; |
2746 | mDialogManager->hideSearchDialog(); | 2746 | mDialogManager->hideSearchDialog(); |
2747 | mViewManager->showJournalView(); | 2747 | mViewManager->showJournalView(); |
2748 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2748 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2749 | } | 2749 | } |
2750 | void CalendarView::editTodo( Todo *todo ) | 2750 | void CalendarView::editTodo( Todo *todo ) |
2751 | { | 2751 | { |
2752 | if ( !todo ) return; | 2752 | if ( !todo ) return; |
2753 | 2753 | ||
2754 | if ( todo->isReadOnly() ) { | 2754 | if ( todo->isReadOnly() ) { |
2755 | showTodo( todo ); | 2755 | showTodo( todo ); |
2756 | return; | 2756 | return; |
2757 | } | 2757 | } |
2758 | showTodoEditor(); | 2758 | showTodoEditor(); |
2759 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2759 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2760 | 2760 | ||
2761 | } | 2761 | } |
2762 | 2762 | ||
2763 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2763 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2764 | { | 2764 | { |
2765 | if ( !mEventViewerDialog ) { | 2765 | if ( !mEventViewerDialog ) { |
2766 | mEventViewerDialog = new KOEventViewerDialog(this); | 2766 | mEventViewerDialog = new KOEventViewerDialog(this); |
2767 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2767 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2768 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2768 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2769 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2769 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2770 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2770 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2771 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2771 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2772 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2772 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2773 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2773 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2774 | this, SLOT( todoChanged(Todo *) ) ); | 2774 | this, SLOT( todoChanged(Todo *) ) ); |
2775 | mEventViewerDialog->resize( 640, 480 ); | 2775 | mEventViewerDialog->resize( 640, 480 ); |
2776 | 2776 | ||
2777 | } | 2777 | } |
2778 | return mEventViewerDialog; | 2778 | return mEventViewerDialog; |
2779 | } | 2779 | } |
2780 | void CalendarView::showEvent(Event *event) | 2780 | void CalendarView::showEvent(Event *event) |
2781 | { | 2781 | { |
2782 | getEventViewerDialog()->setEvent(event); | 2782 | getEventViewerDialog()->setEvent(event); |
2783 | getEventViewerDialog()->showMe(); | 2783 | getEventViewerDialog()->showMe(); |
2784 | } | 2784 | } |
2785 | 2785 | ||
2786 | void CalendarView::showTodo(Todo *event) | 2786 | void CalendarView::showTodo(Todo *event) |
2787 | { | 2787 | { |
2788 | getEventViewerDialog()->setTodo(event); | 2788 | getEventViewerDialog()->setTodo(event); |
2789 | getEventViewerDialog()->showMe(); | 2789 | getEventViewerDialog()->showMe(); |
2790 | } | 2790 | } |
2791 | void CalendarView::showJournal( Journal *jour ) | 2791 | void CalendarView::showJournal( Journal *jour ) |
2792 | { | 2792 | { |
2793 | getEventViewerDialog()->setJournal(jour); | 2793 | getEventViewerDialog()->setJournal(jour); |
2794 | getEventViewerDialog()->showMe(); | 2794 | getEventViewerDialog()->showMe(); |
2795 | 2795 | ||
2796 | } | 2796 | } |
2797 | // void CalendarView::todoModified (Todo *event, int changed) | 2797 | // void CalendarView::todoModified (Todo *event, int changed) |
2798 | // { | 2798 | // { |
2799 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2799 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2800 | // // kdDebug() << "Todo modified and open" << endl; | 2800 | // // kdDebug() << "Todo modified and open" << endl; |
2801 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2801 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2802 | // // temp->modified (changed); | 2802 | // // temp->modified (changed); |
2803 | 2803 | ||
2804 | // // } | 2804 | // // } |
2805 | 2805 | ||
2806 | // mViewManager->updateView(); | 2806 | // mViewManager->updateView(); |
2807 | // } | 2807 | // } |
2808 | 2808 | ||
2809 | void CalendarView::appointment_show() | 2809 | void CalendarView::appointment_show() |
2810 | { | 2810 | { |
2811 | Event *anEvent = 0; | 2811 | Event *anEvent = 0; |
2812 | 2812 | ||
2813 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2813 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2814 | 2814 | ||
2815 | if (mViewManager->currentView()->isEventView()) { | 2815 | if (mViewManager->currentView()->isEventView()) { |
2816 | if ( incidence && incidence->type() == "Event" ) { | 2816 | if ( incidence && incidence->type() == "Event" ) { |
2817 | anEvent = static_cast<Event *>(incidence); | 2817 | anEvent = static_cast<Event *>(incidence); |
2818 | } | 2818 | } |
2819 | } | 2819 | } |
2820 | 2820 | ||
2821 | if (!anEvent) { | 2821 | if (!anEvent) { |
2822 | KNotifyClient::beep(); | 2822 | KNotifyClient::beep(); |
2823 | return; | 2823 | return; |
2824 | } | 2824 | } |
2825 | 2825 | ||
2826 | showEvent(anEvent); | 2826 | showEvent(anEvent); |
2827 | } | 2827 | } |
2828 | 2828 | ||
2829 | void CalendarView::appointment_edit() | 2829 | void CalendarView::appointment_edit() |
2830 | { | 2830 | { |
2831 | Event *anEvent = 0; | 2831 | Event *anEvent = 0; |
2832 | 2832 | ||
2833 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2833 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2834 | 2834 | ||
2835 | if (mViewManager->currentView()->isEventView()) { | 2835 | if (mViewManager->currentView()->isEventView()) { |
2836 | if ( incidence && incidence->type() == "Event" ) { | 2836 | if ( incidence && incidence->type() == "Event" ) { |
2837 | anEvent = static_cast<Event *>(incidence); | 2837 | anEvent = static_cast<Event *>(incidence); |
2838 | } | 2838 | } |
2839 | } | 2839 | } |
2840 | 2840 | ||
2841 | if (!anEvent) { | 2841 | if (!anEvent) { |
2842 | KNotifyClient::beep(); | 2842 | KNotifyClient::beep(); |
2843 | return; | 2843 | return; |
2844 | } | 2844 | } |
2845 | 2845 | ||
2846 | editEvent(anEvent); | 2846 | editEvent(anEvent); |
2847 | } | 2847 | } |
2848 | 2848 | ||
2849 | void CalendarView::appointment_delete() | 2849 | void CalendarView::appointment_delete() |
2850 | { | 2850 | { |
2851 | Event *anEvent = 0; | 2851 | Event *anEvent = 0; |
2852 | 2852 | ||
2853 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2853 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2854 | 2854 | ||
2855 | if (mViewManager->currentView()->isEventView()) { | 2855 | if (mViewManager->currentView()->isEventView()) { |
2856 | if ( incidence && incidence->type() == "Event" ) { | 2856 | if ( incidence && incidence->type() == "Event" ) { |
2857 | anEvent = static_cast<Event *>(incidence); | 2857 | anEvent = static_cast<Event *>(incidence); |
2858 | } | 2858 | } |
2859 | } | 2859 | } |
2860 | 2860 | ||
2861 | if (!anEvent) { | 2861 | if (!anEvent) { |
2862 | KNotifyClient::beep(); | 2862 | KNotifyClient::beep(); |
2863 | return; | 2863 | return; |
2864 | } | 2864 | } |
2865 | 2865 | ||
2866 | deleteEvent(anEvent); | 2866 | deleteEvent(anEvent); |
2867 | } | 2867 | } |
2868 | 2868 | ||
2869 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2869 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2870 | { | 2870 | { |
2871 | if (!sub) return; | 2871 | if (!sub) return; |
2872 | if (!parent) return; | 2872 | if (!parent) return; |
2873 | if ( sub->relatedTo() ) | 2873 | if ( sub->relatedTo() ) |
2874 | sub->relatedTo()->removeRelation(sub); | 2874 | sub->relatedTo()->removeRelation(sub); |
2875 | sub->setRelatedTo(parent); | 2875 | sub->setRelatedTo(parent); |
2876 | sub->setRelatedToUid(parent->uid()); | 2876 | sub->setRelatedToUid(parent->uid()); |
2877 | parent->addRelation(sub); | 2877 | parent->addRelation(sub); |
2878 | sub->updated(); | 2878 | sub->updated(); |
2879 | parent->updated(); | 2879 | parent->updated(); |
2880 | setModified(true); | 2880 | setModified(true); |
2881 | updateView(); | 2881 | updateView(); |
2882 | } | 2882 | } |
2883 | void CalendarView::todo_unsub(Todo *anTodo ) | 2883 | void CalendarView::todo_unsub(Todo *anTodo ) |
2884 | { | 2884 | { |
2885 | // Todo *anTodo = selectedTodo(); | 2885 | // Todo *anTodo = selectedTodo(); |
2886 | if (!anTodo) return; | 2886 | if (!anTodo) return; |
2887 | if (!anTodo->relatedTo()) return; | 2887 | if (!anTodo->relatedTo()) return; |
2888 | anTodo->relatedTo()->removeRelation(anTodo); | 2888 | anTodo->relatedTo()->removeRelation(anTodo); |
2889 | anTodo->setRelatedTo(0); | 2889 | anTodo->setRelatedTo(0); |
2890 | anTodo->updated(); | 2890 | anTodo->updated(); |
2891 | anTodo->setRelatedToUid(""); | 2891 | anTodo->setRelatedToUid(""); |
2892 | setModified(true); | 2892 | setModified(true); |
2893 | updateView(); | 2893 | updateView(); |
2894 | } | 2894 | } |
2895 | 2895 | ||
2896 | void CalendarView::deleteTodo(Todo *todo) | 2896 | void CalendarView::deleteTodo(Todo *todo) |
2897 | { | 2897 | { |
2898 | if (!todo) { | 2898 | if (!todo) { |
2899 | KNotifyClient::beep(); | 2899 | KNotifyClient::beep(); |
2900 | return; | 2900 | return; |
2901 | } | 2901 | } |
2902 | if (KOPrefs::instance()->mConfirm) { | 2902 | if (KOPrefs::instance()->mConfirm) { |
2903 | QString text = todo->summary().left(20); | 2903 | QString text = todo->summary().left(20); |
2904 | if (!todo->relations().isEmpty()) { | 2904 | if (!todo->relations().isEmpty()) { |
2905 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 2905 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
2906 | 2906 | ||
2907 | } | 2907 | } |
2908 | switch (msgItemDelete(text)) { | 2908 | switch (msgItemDelete(text)) { |
2909 | case KMessageBox::Continue: // OK | 2909 | case KMessageBox::Continue: // OK |
2910 | bool deleteT = false; | 2910 | bool deleteT = false; |
2911 | if (!todo->relations().isEmpty()) { | 2911 | if (!todo->relations().isEmpty()) { |
2912 | deleteT = removeCompletedSubTodos( todo ); | 2912 | deleteT = removeCompletedSubTodos( todo ); |
2913 | } | 2913 | } |
2914 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 2914 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
2915 | if ( !deleteT ) { | 2915 | if ( !deleteT ) { |
2916 | checkExternalId( todo ); | 2916 | checkExternalId( todo ); |
2917 | calendar()->deleteTodo(todo); | 2917 | calendar()->deleteTodo(todo); |
2918 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2918 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2919 | updateView(); | 2919 | updateView(); |
2920 | } | 2920 | } |
2921 | break; | 2921 | break; |
2922 | } // switch | 2922 | } // switch |
2923 | } else { | 2923 | } else { |
2924 | checkExternalId( todo ); | 2924 | checkExternalId( todo ); |
2925 | mCalendar->deleteTodo(todo); | 2925 | mCalendar->deleteTodo(todo); |
2926 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2926 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2927 | updateView(); | 2927 | updateView(); |
2928 | } | 2928 | } |
2929 | 2929 | ||
2930 | emit updateSearchDialog(); | 2930 | emit updateSearchDialog(); |
2931 | } | 2931 | } |
2932 | void CalendarView::deleteJournal(Journal *jour) | 2932 | void CalendarView::deleteJournal(Journal *jour) |
2933 | { | 2933 | { |
2934 | if (!jour) { | 2934 | if (!jour) { |
2935 | KNotifyClient::beep(); | 2935 | KNotifyClient::beep(); |
2936 | return; | 2936 | return; |
2937 | } | 2937 | } |
2938 | if (KOPrefs::instance()->mConfirm) { | 2938 | if (KOPrefs::instance()->mConfirm) { |
2939 | switch (msgItemDelete( jour->description().left(20))) { | 2939 | switch (msgItemDelete( jour->description().left(20))) { |
2940 | case KMessageBox::Continue: // OK | 2940 | case KMessageBox::Continue: // OK |
2941 | calendar()->deleteJournal(jour); | 2941 | calendar()->deleteJournal(jour); |
2942 | updateView(); | 2942 | updateView(); |
2943 | break; | 2943 | break; |
2944 | } // switch | 2944 | } // switch |
2945 | } else { | 2945 | } else { |
2946 | calendar()->deleteJournal(jour);; | 2946 | calendar()->deleteJournal(jour);; |
2947 | updateView(); | 2947 | updateView(); |
2948 | } | 2948 | } |
2949 | emit updateSearchDialog(); | 2949 | emit updateSearchDialog(); |
2950 | } | 2950 | } |
2951 | 2951 | ||
2952 | void CalendarView::deleteEvent(Event *anEvent) | 2952 | void CalendarView::deleteEvent(Event *anEvent) |
2953 | { | 2953 | { |
2954 | if (!anEvent) { | 2954 | if (!anEvent) { |
2955 | KNotifyClient::beep(); | 2955 | KNotifyClient::beep(); |
2956 | return; | 2956 | return; |
2957 | } | 2957 | } |
2958 | 2958 | ||
2959 | if (anEvent->recurrence()->doesRecur()) { | 2959 | if (anEvent->recurrence()->doesRecur()) { |
2960 | QDate itemDate = mViewManager->currentSelectionDate(); | 2960 | QDate itemDate = mViewManager->currentSelectionDate(); |
2961 | int km; | 2961 | int km; |
2962 | if (!itemDate.isValid()) { | 2962 | if (!itemDate.isValid()) { |
2963 | //kdDebug() << "Date Not Valid" << endl; | 2963 | //kdDebug() << "Date Not Valid" << endl; |
2964 | if (KOPrefs::instance()->mConfirm) { | 2964 | if (KOPrefs::instance()->mConfirm) { |
2965 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2965 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2966 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2966 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2967 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2967 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2968 | if ( km == KMessageBox::Continue ) | 2968 | if ( km == KMessageBox::Continue ) |
2969 | km = KMessageBox::No; // No = all below | 2969 | km = KMessageBox::No; // No = all below |
2970 | } else | 2970 | } else |
2971 | km = KMessageBox::No; | 2971 | km = KMessageBox::No; |
2972 | } else { | 2972 | } else { |
2973 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 2973 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2974 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2974 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2975 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2975 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2976 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2976 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2977 | i18n("All")); | 2977 | i18n("All")); |
2978 | } | 2978 | } |
2979 | switch(km) { | 2979 | switch(km) { |
2980 | 2980 | ||
2981 | case KMessageBox::No: // Continue // all | 2981 | case KMessageBox::No: // Continue // all |
2982 | //qDebug("KMessageBox::No "); | 2982 | //qDebug("KMessageBox::No "); |
2983 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2983 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2984 | schedule(Scheduler::Cancel,anEvent); | 2984 | schedule(Scheduler::Cancel,anEvent); |
2985 | 2985 | ||
2986 | checkExternalId( anEvent); | 2986 | checkExternalId( anEvent); |
2987 | mCalendar->deleteEvent(anEvent); | 2987 | mCalendar->deleteEvent(anEvent); |
2988 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2988 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2989 | break; | 2989 | break; |
2990 | 2990 | ||
2991 | // Disabled because it does not work | 2991 | // Disabled because it does not work |
2992 | //#if 0 | 2992 | //#if 0 |
2993 | case KMessageBox::Yes: // just this one | 2993 | case KMessageBox::Yes: // just this one |
2994 | //QDate qd = mNavigator->selectedDates().first(); | 2994 | //QDate qd = mNavigator->selectedDates().first(); |
2995 | //if (!qd.isValid()) { | 2995 | //if (!qd.isValid()) { |
2996 | // kdDebug() << "no date selected, or invalid date" << endl; | 2996 | // kdDebug() << "no date selected, or invalid date" << endl; |
2997 | // KNotifyClient::beep(); | 2997 | // KNotifyClient::beep(); |
2998 | // return; | 2998 | // return; |
2999 | //} | 2999 | //} |
3000 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3000 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3001 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3001 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3002 | anEvent->addExDate(itemDate); | 3002 | anEvent->addExDate(itemDate); |
3003 | int duration = anEvent->recurrence()->duration(); | 3003 | int duration = anEvent->recurrence()->duration(); |
3004 | if ( duration > 0 ) { | 3004 | if ( duration > 0 ) { |
3005 | anEvent->recurrence()->setDuration( duration - 1 ); | 3005 | anEvent->recurrence()->setDuration( duration - 1 ); |
3006 | } | 3006 | } |
3007 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3007 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3008 | } | 3008 | } |
3009 | break; | 3009 | break; |
3010 | //#endif | 3010 | //#endif |
3011 | } // switch | 3011 | } // switch |
3012 | } else { | 3012 | } else { |
3013 | if (KOPrefs::instance()->mConfirm) { | 3013 | if (KOPrefs::instance()->mConfirm) { |
3014 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3014 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3015 | i18n("\nAre you sure you want\nto delete this event?"), | 3015 | i18n("\nAre you sure you want\nto delete this event?"), |
3016 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3016 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3017 | case KMessageBox::Continue: // OK | 3017 | case KMessageBox::Continue: // OK |
3018 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3018 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3019 | schedule(Scheduler::Cancel,anEvent); | 3019 | schedule(Scheduler::Cancel,anEvent); |
3020 | checkExternalId( anEvent); | 3020 | checkExternalId( anEvent); |
3021 | mCalendar->deleteEvent(anEvent); | 3021 | mCalendar->deleteEvent(anEvent); |
3022 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3022 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3023 | break; | 3023 | break; |
3024 | } // switch | 3024 | } // switch |
3025 | } else { | 3025 | } else { |
3026 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3026 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3027 | schedule(Scheduler::Cancel,anEvent); | 3027 | schedule(Scheduler::Cancel,anEvent); |
3028 | checkExternalId( anEvent); | 3028 | checkExternalId( anEvent); |
3029 | mCalendar->deleteEvent(anEvent); | 3029 | mCalendar->deleteEvent(anEvent); |
3030 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3030 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3031 | } | 3031 | } |
3032 | } // if-else | 3032 | } // if-else |
3033 | emit updateSearchDialog(); | 3033 | emit updateSearchDialog(); |
3034 | } | 3034 | } |
3035 | 3035 | ||
3036 | bool CalendarView::deleteEvent(const QString &uid) | 3036 | bool CalendarView::deleteEvent(const QString &uid) |
3037 | { | 3037 | { |
3038 | Event *ev = mCalendar->event(uid); | 3038 | Event *ev = mCalendar->event(uid); |
3039 | if (ev) { | 3039 | if (ev) { |
3040 | deleteEvent(ev); | 3040 | deleteEvent(ev); |
3041 | return true; | 3041 | return true; |
3042 | } else { | 3042 | } else { |
3043 | return false; | 3043 | return false; |
3044 | } | 3044 | } |
3045 | } | 3045 | } |
3046 | 3046 | ||
3047 | /*****************************************************************************/ | 3047 | /*****************************************************************************/ |
3048 | 3048 | ||
3049 | void CalendarView::action_mail() | 3049 | void CalendarView::action_mail() |
3050 | { | 3050 | { |
3051 | #ifndef KORG_NOMAIL | 3051 | #ifndef KORG_NOMAIL |
3052 | KOMailClient mailClient; | 3052 | KOMailClient mailClient; |
3053 | 3053 | ||
3054 | Incidence *incidence = currentSelection(); | 3054 | Incidence *incidence = currentSelection(); |
3055 | 3055 | ||
3056 | if (!incidence) { | 3056 | if (!incidence) { |
3057 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3057 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3058 | return; | 3058 | return; |
3059 | } | 3059 | } |
3060 | if(incidence->attendeeCount() == 0 ) { | 3060 | if(incidence->attendeeCount() == 0 ) { |
3061 | KMessageBox::sorry(this, | 3061 | KMessageBox::sorry(this, |
3062 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3062 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3063 | return; | 3063 | return; |
3064 | } | 3064 | } |
3065 | 3065 | ||
3066 | CalendarLocal cal_tmp; | 3066 | CalendarLocal cal_tmp; |
3067 | Event *event = 0; | 3067 | Event *event = 0; |
3068 | Event *ev = 0; | 3068 | Event *ev = 0; |
3069 | if ( incidence && incidence->type() == "Event" ) { | 3069 | if ( incidence && incidence->type() == "Event" ) { |
3070 | event = static_cast<Event *>(incidence); | 3070 | event = static_cast<Event *>(incidence); |
3071 | ev = new Event(*event); | 3071 | ev = new Event(*event); |
3072 | cal_tmp.addEvent(ev); | 3072 | cal_tmp.addEvent(ev); |
3073 | } | 3073 | } |
3074 | ICalFormat mForm(); | 3074 | ICalFormat mForm(); |
3075 | QString attachment = mForm.toString( &cal_tmp ); | 3075 | QString attachment = mForm.toString( &cal_tmp ); |
3076 | if (ev) delete(ev); | 3076 | if (ev) delete(ev); |
3077 | 3077 | ||
3078 | mailClient.mailAttendees(currentSelection(), attachment); | 3078 | mailClient.mailAttendees(currentSelection(), attachment); |
3079 | 3079 | ||
3080 | #endif | 3080 | #endif |
3081 | 3081 | ||
3082 | #if 0 | 3082 | #if 0 |
3083 | Event *anEvent = 0; | 3083 | Event *anEvent = 0; |
3084 | if (mViewManager->currentView()->isEventView()) { | 3084 | if (mViewManager->currentView()->isEventView()) { |
3085 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3085 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3086 | } | 3086 | } |
3087 | 3087 | ||
3088 | if (!anEvent) { | 3088 | if (!anEvent) { |
3089 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3089 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3090 | return; | 3090 | return; |
3091 | } | 3091 | } |
3092 | if(anEvent->attendeeCount() == 0 ) { | 3092 | if(anEvent->attendeeCount() == 0 ) { |
3093 | KMessageBox::sorry(this, | 3093 | KMessageBox::sorry(this, |
3094 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3094 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3095 | return; | 3095 | return; |
3096 | } | 3096 | } |
3097 | 3097 | ||
3098 | mailobject.emailEvent(anEvent); | 3098 | mailobject.emailEvent(anEvent); |
3099 | #endif | 3099 | #endif |
3100 | } | 3100 | } |
3101 | 3101 | ||
3102 | 3102 | ||
3103 | void CalendarView::schedule_publish(Incidence *incidence) | 3103 | void CalendarView::schedule_publish(Incidence *incidence) |
3104 | { | 3104 | { |
3105 | Event *event = 0; | 3105 | Event *event = 0; |
3106 | Todo *todo = 0; | 3106 | Todo *todo = 0; |
3107 | 3107 | ||
3108 | if (incidence == 0) { | 3108 | if (incidence == 0) { |
3109 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3109 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3110 | if (incidence == 0) { | 3110 | if (incidence == 0) { |
3111 | incidence = mTodoList->selectedIncidences().first(); | 3111 | incidence = mTodoList->selectedIncidences().first(); |
3112 | } | 3112 | } |
3113 | } | 3113 | } |
3114 | if ( incidence && incidence->type() == "Event" ) { | 3114 | if ( incidence && incidence->type() == "Event" ) { |
3115 | event = static_cast<Event *>(incidence); | 3115 | event = static_cast<Event *>(incidence); |
3116 | } else { | 3116 | } else { |
3117 | if ( incidence && incidence->type() == "Todo" ) { | 3117 | if ( incidence && incidence->type() == "Todo" ) { |
3118 | todo = static_cast<Todo *>(incidence); | 3118 | todo = static_cast<Todo *>(incidence); |
3119 | } | 3119 | } |
3120 | } | 3120 | } |
3121 | 3121 | ||
3122 | if (!event && !todo) { | 3122 | if (!event && !todo) { |
3123 | KMessageBox::sorry(this,i18n("No event selected.")); | 3123 | KMessageBox::sorry(this,i18n("No event selected.")); |
3124 | return; | 3124 | return; |
3125 | } | 3125 | } |
3126 | 3126 | ||
3127 | PublishDialog *publishdlg = new PublishDialog(); | 3127 | PublishDialog *publishdlg = new PublishDialog(); |
3128 | if (incidence->attendeeCount()>0) { | 3128 | if (incidence->attendeeCount()>0) { |
3129 | QPtrList<Attendee> attendees = incidence->attendees(); | 3129 | QPtrList<Attendee> attendees = incidence->attendees(); |
3130 | attendees.first(); | 3130 | attendees.first(); |
3131 | while ( attendees.current()!=0 ) { | 3131 | while ( attendees.current()!=0 ) { |
3132 | publishdlg->addAttendee(attendees.current()); | 3132 | publishdlg->addAttendee(attendees.current()); |
3133 | attendees.next(); | 3133 | attendees.next(); |
3134 | } | 3134 | } |
3135 | } | 3135 | } |
3136 | bool send = true; | 3136 | bool send = true; |
3137 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3137 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3138 | if ( publishdlg->exec() != QDialog::Accepted ) | 3138 | if ( publishdlg->exec() != QDialog::Accepted ) |
3139 | send = false; | 3139 | send = false; |
3140 | } | 3140 | } |
3141 | if ( send ) { | 3141 | if ( send ) { |
3142 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3142 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3143 | if ( event ) { | 3143 | if ( event ) { |
3144 | Event *ev = new Event(*event); | 3144 | Event *ev = new Event(*event); |
3145 | ev->registerObserver(0); | 3145 | ev->registerObserver(0); |
3146 | ev->clearAttendees(); | 3146 | ev->clearAttendees(); |
3147 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3147 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3148 | delete(ev); | 3148 | delete(ev); |
3149 | } | 3149 | } |
3150 | } else { | 3150 | } else { |
3151 | if ( todo ) { | 3151 | if ( todo ) { |
3152 | Todo *ev = new Todo(*todo); | 3152 | Todo *ev = new Todo(*todo); |
3153 | ev->registerObserver(0); | 3153 | ev->registerObserver(0); |
3154 | ev->clearAttendees(); | 3154 | ev->clearAttendees(); |
3155 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3155 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3156 | delete(ev); | 3156 | delete(ev); |
3157 | } | 3157 | } |
3158 | } | 3158 | } |
3159 | } | 3159 | } |
3160 | } | 3160 | } |
3161 | delete publishdlg; | 3161 | delete publishdlg; |
3162 | } | 3162 | } |
3163 | 3163 | ||
3164 | void CalendarView::schedule_request(Incidence *incidence) | 3164 | void CalendarView::schedule_request(Incidence *incidence) |
3165 | { | 3165 | { |
3166 | schedule(Scheduler::Request,incidence); | 3166 | schedule(Scheduler::Request,incidence); |
3167 | } | 3167 | } |
3168 | 3168 | ||
3169 | void CalendarView::schedule_refresh(Incidence *incidence) | 3169 | void CalendarView::schedule_refresh(Incidence *incidence) |
3170 | { | 3170 | { |
3171 | schedule(Scheduler::Refresh,incidence); | 3171 | schedule(Scheduler::Refresh,incidence); |
3172 | } | 3172 | } |
3173 | 3173 | ||
3174 | void CalendarView::schedule_cancel(Incidence *incidence) | 3174 | void CalendarView::schedule_cancel(Incidence *incidence) |
3175 | { | 3175 | { |
3176 | schedule(Scheduler::Cancel,incidence); | 3176 | schedule(Scheduler::Cancel,incidence); |
3177 | } | 3177 | } |
3178 | 3178 | ||
3179 | void CalendarView::schedule_add(Incidence *incidence) | 3179 | void CalendarView::schedule_add(Incidence *incidence) |
3180 | { | 3180 | { |
3181 | schedule(Scheduler::Add,incidence); | 3181 | schedule(Scheduler::Add,incidence); |
3182 | } | 3182 | } |
3183 | 3183 | ||
3184 | void CalendarView::schedule_reply(Incidence *incidence) | 3184 | void CalendarView::schedule_reply(Incidence *incidence) |
3185 | { | 3185 | { |
3186 | schedule(Scheduler::Reply,incidence); | 3186 | schedule(Scheduler::Reply,incidence); |
3187 | } | 3187 | } |
3188 | 3188 | ||
3189 | void CalendarView::schedule_counter(Incidence *incidence) | 3189 | void CalendarView::schedule_counter(Incidence *incidence) |
3190 | { | 3190 | { |
3191 | schedule(Scheduler::Counter,incidence); | 3191 | schedule(Scheduler::Counter,incidence); |
3192 | } | 3192 | } |
3193 | 3193 | ||
3194 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3194 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3195 | { | 3195 | { |
3196 | schedule(Scheduler::Declinecounter,incidence); | 3196 | schedule(Scheduler::Declinecounter,incidence); |
3197 | } | 3197 | } |
3198 | 3198 | ||
3199 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3199 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3200 | { | 3200 | { |
3201 | QDateTime start = QDateTime::currentDateTime(); | 3201 | QDateTime start = QDateTime::currentDateTime(); |
3202 | QDateTime end = start.addDays(daysToPublish); | 3202 | QDateTime end = start.addDays(daysToPublish); |
3203 | 3203 | ||
3204 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3204 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3205 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3205 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3206 | 3206 | ||
3207 | 3207 | ||
3208 | PublishDialog *publishdlg = new PublishDialog(); | 3208 | PublishDialog *publishdlg = new PublishDialog(); |
3209 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3209 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3210 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3210 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3211 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3211 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3212 | delete(freebusy); | 3212 | delete(freebusy); |
3213 | } | 3213 | } |
3214 | } | 3214 | } |
3215 | delete publishdlg; | 3215 | delete publishdlg; |
3216 | } | 3216 | } |
3217 | 3217 | ||
3218 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3218 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3219 | { | 3219 | { |
3220 | Event *event = 0; | 3220 | Event *event = 0; |
3221 | Todo *todo = 0; | 3221 | Todo *todo = 0; |
3222 | 3222 | ||
3223 | if (incidence == 0) { | 3223 | if (incidence == 0) { |
3224 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3224 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3225 | if (incidence == 0) { | 3225 | if (incidence == 0) { |
3226 | incidence = mTodoList->selectedIncidences().first(); | 3226 | incidence = mTodoList->selectedIncidences().first(); |
3227 | } | 3227 | } |
3228 | } | 3228 | } |
3229 | if ( incidence && incidence->type() == "Event" ) { | 3229 | if ( incidence && incidence->type() == "Event" ) { |
3230 | event = static_cast<Event *>(incidence); | 3230 | event = static_cast<Event *>(incidence); |
3231 | } | 3231 | } |
3232 | if ( incidence && incidence->type() == "Todo" ) { | 3232 | if ( incidence && incidence->type() == "Todo" ) { |
3233 | todo = static_cast<Todo *>(incidence); | 3233 | todo = static_cast<Todo *>(incidence); |
3234 | } | 3234 | } |
3235 | 3235 | ||
3236 | if (!event && !todo) { | 3236 | if (!event && !todo) { |
3237 | KMessageBox::sorry(this,i18n("No event selected.")); | 3237 | KMessageBox::sorry(this,i18n("No event selected.")); |
3238 | return; | 3238 | return; |
3239 | } | 3239 | } |
3240 | 3240 | ||
3241 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3241 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3242 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3242 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3243 | return; | 3243 | return; |
3244 | } | 3244 | } |
3245 | 3245 | ||
3246 | Event *ev = 0; | 3246 | Event *ev = 0; |
3247 | if (event) ev = new Event(*event); | 3247 | if (event) ev = new Event(*event); |
3248 | Todo *to = 0; | 3248 | Todo *to = 0; |
3249 | if (todo) to = new Todo(*todo); | 3249 | if (todo) to = new Todo(*todo); |
3250 | 3250 | ||
3251 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3251 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3252 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3252 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3253 | if (!me) { | 3253 | if (!me) { |
3254 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3254 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3255 | return; | 3255 | return; |
3256 | } | 3256 | } |
3257 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3257 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3258 | StatusDialog *statdlg = new StatusDialog(this); | 3258 | StatusDialog *statdlg = new StatusDialog(this); |
3259 | if (!statdlg->exec()==QDialog::Accepted) return; | 3259 | if (!statdlg->exec()==QDialog::Accepted) return; |
3260 | me->setStatus( statdlg->status() ); | 3260 | me->setStatus( statdlg->status() ); |
3261 | delete(statdlg); | 3261 | delete(statdlg); |
3262 | } | 3262 | } |
3263 | Attendee *menew = new Attendee(*me); | 3263 | Attendee *menew = new Attendee(*me); |
3264 | if (ev) { | 3264 | if (ev) { |
3265 | ev->clearAttendees(); | 3265 | ev->clearAttendees(); |
3266 | ev->addAttendee(menew,false); | 3266 | ev->addAttendee(menew,false); |
3267 | } else { | 3267 | } else { |
3268 | if (to) { | 3268 | if (to) { |
3269 | todo->clearAttendees(); | 3269 | todo->clearAttendees(); |
3270 | todo->addAttendee(menew,false); | 3270 | todo->addAttendee(menew,false); |
3271 | } | 3271 | } |
3272 | } | 3272 | } |
3273 | } | 3273 | } |
3274 | 3274 | ||
3275 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3275 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3276 | if (ev) { | 3276 | if (ev) { |
3277 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3277 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3278 | } else { | 3278 | } else { |
3279 | if (to) { | 3279 | if (to) { |
3280 | if ( !dlg->addMessage(to,method) ) delete(to); | 3280 | if ( !dlg->addMessage(to,method) ) delete(to); |
3281 | } | 3281 | } |
3282 | } | 3282 | } |
3283 | } | 3283 | } |
3284 | 3284 | ||
3285 | void CalendarView::openAddressbook() | 3285 | void CalendarView::openAddressbook() |
3286 | { | 3286 | { |
3287 | KRun::runCommand("kaddressbook"); | 3287 | KRun::runCommand("kaddressbook"); |
3288 | } | 3288 | } |
3289 | 3289 | ||
3290 | void CalendarView::setModified(bool modified) | 3290 | void CalendarView::setModified(bool modified) |
3291 | { | 3291 | { |
3292 | if ( modified ) | 3292 | if ( modified ) |
3293 | emit signalmodified(); | 3293 | emit signalmodified(); |
3294 | if (mModified != modified) { | 3294 | if (mModified != modified) { |
3295 | mModified = modified; | 3295 | mModified = modified; |
3296 | emit modifiedChanged(mModified); | 3296 | emit modifiedChanged(mModified); |
3297 | } | 3297 | } |
3298 | } | 3298 | } |
3299 | 3299 | ||
3300 | bool CalendarView::isReadOnly() | 3300 | bool CalendarView::isReadOnly() |
3301 | { | 3301 | { |
3302 | return mReadOnly; | 3302 | return mReadOnly; |
3303 | } | 3303 | } |
3304 | 3304 | ||
3305 | void CalendarView::setReadOnly(bool readOnly) | 3305 | void CalendarView::setReadOnly(bool readOnly) |
3306 | { | 3306 | { |
3307 | if (mReadOnly != readOnly) { | 3307 | if (mReadOnly != readOnly) { |
3308 | mReadOnly = readOnly; | 3308 | mReadOnly = readOnly; |
3309 | emit readOnlyChanged(mReadOnly); | 3309 | emit readOnlyChanged(mReadOnly); |
3310 | } | 3310 | } |
3311 | } | 3311 | } |
3312 | 3312 | ||
3313 | bool CalendarView::isModified() | 3313 | bool CalendarView::isModified() |
3314 | { | 3314 | { |
3315 | return mModified; | 3315 | return mModified; |
3316 | } | 3316 | } |
3317 | 3317 | ||
3318 | void CalendarView::printSetup() | 3318 | void CalendarView::printSetup() |
3319 | { | 3319 | { |
3320 | #ifndef KORG_NOPRINTER | 3320 | #ifndef KORG_NOPRINTER |
3321 | createPrinter(); | 3321 | createPrinter(); |
3322 | 3322 | ||
3323 | mCalPrinter->setupPrinter(); | 3323 | mCalPrinter->setupPrinter(); |
3324 | #endif | 3324 | #endif |
3325 | } | 3325 | } |
3326 | 3326 | ||
3327 | void CalendarView::print() | 3327 | void CalendarView::print() |
3328 | { | 3328 | { |
3329 | #ifndef KORG_NOPRINTER | 3329 | #ifndef KORG_NOPRINTER |
3330 | createPrinter(); | 3330 | createPrinter(); |
3331 | 3331 | ||
3332 | DateList tmpDateList = mNavigator->selectedDates(); | 3332 | DateList tmpDateList = mNavigator->selectedDates(); |
3333 | mCalPrinter->print(CalPrinter::Month, | 3333 | mCalPrinter->print(CalPrinter::Month, |
3334 | tmpDateList.first(), tmpDateList.last()); | 3334 | tmpDateList.first(), tmpDateList.last()); |
3335 | #endif | 3335 | #endif |
3336 | } | 3336 | } |
3337 | 3337 | ||
3338 | void CalendarView::printPreview() | 3338 | void CalendarView::printPreview() |
3339 | { | 3339 | { |
3340 | #ifndef KORG_NOPRINTER | 3340 | #ifndef KORG_NOPRINTER |
3341 | kdDebug() << "CalendarView::printPreview()" << endl; | 3341 | kdDebug() << "CalendarView::printPreview()" << endl; |
3342 | 3342 | ||
3343 | createPrinter(); | 3343 | createPrinter(); |
3344 | 3344 | ||
3345 | DateList tmpDateList = mNavigator->selectedDates(); | 3345 | DateList tmpDateList = mNavigator->selectedDates(); |
3346 | 3346 | ||
3347 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3347 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3348 | tmpDateList.last()); | 3348 | tmpDateList.last()); |
3349 | #endif | 3349 | #endif |
3350 | } | 3350 | } |
3351 | 3351 | ||
3352 | void CalendarView::exportICalendar() | 3352 | void CalendarView::exportICalendar() |
3353 | { | 3353 | { |
3354 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3354 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3355 | 3355 | ||
3356 | // Force correct extension | 3356 | // Force correct extension |
3357 | if (filename.right(4) != ".ics") filename += ".ics"; | 3357 | if (filename.right(4) != ".ics") filename += ".ics"; |
3358 | 3358 | ||
3359 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3359 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3360 | storage.save(); | 3360 | storage.save(); |
3361 | } | 3361 | } |
3362 | 3362 | ||
3363 | bool CalendarView::exportVCalendar( QString filename ) | 3363 | bool CalendarView::exportVCalendar( QString filename ) |
3364 | { | 3364 | { |
3365 | if (mCalendar->journals().count() > 0) { | 3365 | if (mCalendar->journals().count() > 0) { |
3366 | int result = KMessageBox::warningContinueCancel(this, | 3366 | int result = KMessageBox::warningContinueCancel(this, |
3367 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3367 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3368 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3368 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3369 | true); | 3369 | true); |
3370 | if (result != KMessageBox::Continue) return false; | 3370 | if (result != KMessageBox::Continue) return false; |
3371 | } | 3371 | } |
3372 | 3372 | ||
3373 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3373 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3374 | 3374 | ||
3375 | // Force correct extension | 3375 | // Force correct extension |
3376 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3376 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3377 | 3377 | ||
3378 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3378 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3379 | return storage.save(); | 3379 | return storage.save(); |
3380 | 3380 | ||
3381 | } | 3381 | } |
3382 | 3382 | ||
3383 | void CalendarView::eventUpdated(Incidence *) | 3383 | void CalendarView::eventUpdated(Incidence *) |
3384 | { | 3384 | { |
3385 | setModified(); | 3385 | setModified(); |
3386 | // Don't call updateView here. The code, which has caused the update of the | 3386 | // Don't call updateView here. The code, which has caused the update of the |
3387 | // event is responsible for updating the view. | 3387 | // event is responsible for updating the view. |
3388 | // updateView(); | 3388 | // updateView(); |
3389 | } | 3389 | } |
3390 | 3390 | ||
3391 | void CalendarView::adaptNavigationUnits() | 3391 | void CalendarView::adaptNavigationUnits() |
3392 | { | 3392 | { |
3393 | if (mViewManager->currentView()->isEventView()) { | 3393 | if (mViewManager->currentView()->isEventView()) { |
3394 | int days = mViewManager->currentView()->currentDateCount(); | 3394 | int days = mViewManager->currentView()->currentDateCount(); |
3395 | if (days == 1) { | 3395 | if (days == 1) { |
3396 | emit changeNavStringPrev(i18n("&Previous Day")); | 3396 | emit changeNavStringPrev(i18n("&Previous Day")); |
3397 | emit changeNavStringNext(i18n("&Next Day")); | 3397 | emit changeNavStringNext(i18n("&Next Day")); |
3398 | } else { | 3398 | } else { |
3399 | emit changeNavStringPrev(i18n("&Previous Week")); | 3399 | emit changeNavStringPrev(i18n("&Previous Week")); |
3400 | emit changeNavStringNext(i18n("&Next Week")); | 3400 | emit changeNavStringNext(i18n("&Next Week")); |
3401 | } | 3401 | } |
3402 | } | 3402 | } |
3403 | } | 3403 | } |
3404 | 3404 | ||
3405 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3405 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3406 | { | 3406 | { |
3407 | if ( incidence ) mTodoList->clearSelection(); | 3407 | if ( incidence ) mTodoList->clearSelection(); |
3408 | processIncidenceSelection( incidence ); | 3408 | processIncidenceSelection( incidence ); |
3409 | } | 3409 | } |
3410 | 3410 | ||
3411 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3411 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3412 | { | 3412 | { |
3413 | if ( incidence && mViewManager->currentView() ) { | 3413 | if ( incidence && mViewManager->currentView() ) { |
3414 | mViewManager->currentView()->clearSelection(); | 3414 | mViewManager->currentView()->clearSelection(); |
3415 | } | 3415 | } |
3416 | processIncidenceSelection( incidence ); | 3416 | processIncidenceSelection( incidence ); |
3417 | } | 3417 | } |
3418 | 3418 | ||
3419 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3419 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3420 | { | 3420 | { |
3421 | if ( incidence == mSelectedIncidence ) return; | 3421 | if ( incidence == mSelectedIncidence ) return; |
3422 | 3422 | ||
3423 | mSelectedIncidence = incidence; | 3423 | mSelectedIncidence = incidence; |
3424 | 3424 | ||
3425 | emit incidenceSelected( mSelectedIncidence ); | 3425 | emit incidenceSelected( mSelectedIncidence ); |
3426 | 3426 | ||
3427 | if ( incidence && incidence->type() == "Event" ) { | 3427 | if ( incidence && incidence->type() == "Event" ) { |
3428 | Event *event = static_cast<Event *>( incidence ); | 3428 | Event *event = static_cast<Event *>( incidence ); |
3429 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3429 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3430 | emit organizerEventsSelected( true ); | 3430 | emit organizerEventsSelected( true ); |
3431 | } else { | 3431 | } else { |
3432 | emit organizerEventsSelected(false); | 3432 | emit organizerEventsSelected(false); |
3433 | } | 3433 | } |
3434 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3434 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3435 | KOPrefs::instance()->email() ) ) { | 3435 | KOPrefs::instance()->email() ) ) { |
3436 | emit groupEventsSelected( true ); | 3436 | emit groupEventsSelected( true ); |
3437 | } else { | 3437 | } else { |
3438 | emit groupEventsSelected(false); | 3438 | emit groupEventsSelected(false); |
3439 | } | 3439 | } |
3440 | return; | 3440 | return; |
3441 | } else { | 3441 | } else { |
3442 | if ( incidence && incidence->type() == "Todo" ) { | 3442 | if ( incidence && incidence->type() == "Todo" ) { |
3443 | emit todoSelected( true ); | 3443 | emit todoSelected( true ); |
3444 | Todo *event = static_cast<Todo *>( incidence ); | 3444 | Todo *event = static_cast<Todo *>( incidence ); |
3445 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3445 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3446 | emit organizerEventsSelected( true ); | 3446 | emit organizerEventsSelected( true ); |
3447 | } else { | 3447 | } else { |
3448 | emit organizerEventsSelected(false); | 3448 | emit organizerEventsSelected(false); |
3449 | } | 3449 | } |
3450 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3450 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3451 | KOPrefs::instance()->email() ) ) { | 3451 | KOPrefs::instance()->email() ) ) { |
3452 | emit groupEventsSelected( true ); | 3452 | emit groupEventsSelected( true ); |
3453 | } else { | 3453 | } else { |
3454 | emit groupEventsSelected(false); | 3454 | emit groupEventsSelected(false); |
3455 | } | 3455 | } |
3456 | return; | 3456 | return; |
3457 | } else { | 3457 | } else { |
3458 | emit todoSelected( false ); | 3458 | emit todoSelected( false ); |
3459 | emit organizerEventsSelected(false); | 3459 | emit organizerEventsSelected(false); |
3460 | emit groupEventsSelected(false); | 3460 | emit groupEventsSelected(false); |
3461 | } | 3461 | } |
3462 | return; | 3462 | return; |
3463 | } | 3463 | } |
3464 | 3464 | ||
3465 | /* if ( incidence && incidence->type() == "Todo" ) { | 3465 | /* if ( incidence && incidence->type() == "Todo" ) { |
3466 | emit todoSelected( true ); | 3466 | emit todoSelected( true ); |
3467 | } else { | 3467 | } else { |
3468 | emit todoSelected( false ); | 3468 | emit todoSelected( false ); |
3469 | }*/ | 3469 | }*/ |
3470 | } | 3470 | } |
3471 | 3471 | ||
3472 | 3472 | ||
3473 | void CalendarView::checkClipboard() | 3473 | void CalendarView::checkClipboard() |
3474 | { | 3474 | { |
3475 | #ifndef KORG_NODND | 3475 | #ifndef KORG_NODND |
3476 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3476 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3477 | emit pasteEnabled(true); | 3477 | emit pasteEnabled(true); |
3478 | } else { | 3478 | } else { |
3479 | emit pasteEnabled(false); | 3479 | emit pasteEnabled(false); |
3480 | } | 3480 | } |
3481 | #endif | 3481 | #endif |
3482 | } | 3482 | } |
3483 | 3483 | ||
3484 | void CalendarView::showDates(const DateList &selectedDates) | 3484 | void CalendarView::showDates(const DateList &selectedDates) |
3485 | { | 3485 | { |
3486 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3486 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3487 | 3487 | ||
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 0eeacb3..002234d 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,1209 +1,1209 @@ | |||
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 | Marcus Bains line. | 5 | Marcus Bains line. |
6 | Copyright (c) 2001 Ali Rahimi | 6 | Copyright (c) 2001 Ali Rahimi |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #define protected public | 28 | #define protected public |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #undef protected | 30 | #undef protected |
31 | #endif | 31 | #endif |
32 | #include <qintdict.h> | 32 | #include <qintdict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | 49 | ||
50 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | //////////////////////////////////////////////////////////////////////////// | 63 | //////////////////////////////////////////////////////////////////////////// |
64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
66 | { | 66 | { |
67 | setLineWidth(0); | 67 | setLineWidth(0); |
68 | setMargin(0); | 68 | setMargin(0); |
69 | setBackgroundColor(Qt::red); | 69 | setBackgroundColor(Qt::red); |
70 | minutes = new QTimer(this); | 70 | minutes = new QTimer(this); |
71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
72 | minutes->start(0, true); | 72 | minutes->start(0, true); |
73 | 73 | ||
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | delete minutes; | 88 | delete minutes; |
89 | } | 89 | } |
90 | 90 | ||
91 | int MarcusBains::todayColumn() | 91 | int MarcusBains::todayColumn() |
92 | { | 92 | { |
93 | QDate currentDate = QDate::currentDate(); | 93 | QDate currentDate = QDate::currentDate(); |
94 | 94 | ||
95 | DateList dateList = agenda->dateList(); | 95 | DateList dateList = agenda->dateList(); |
96 | DateList::ConstIterator it; | 96 | DateList::ConstIterator it; |
97 | int col = 0; | 97 | int col = 0; |
98 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 98 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
99 | if((*it) == currentDate) | 99 | if((*it) == currentDate) |
100 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
102 | ++col; | 102 | ++col; |
103 | } | 103 | } |
104 | 104 | ||
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
108 | { | 108 | { |
109 | updateLocation(); | 109 | updateLocation(); |
110 | } | 110 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 112 | { |
113 | 113 | ||
114 | QTime tim = QTime::currentTime(); | 114 | QTime tim = QTime::currentTime(); |
115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
116 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 116 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
117 | recalculate = true; | 117 | recalculate = true; |
118 | 118 | ||
119 | int mins = tim.hour()*60 + tim.minute(); | 119 | int mins = tim.hour()*60 + tim.minute(); |
120 | int minutesPerCell = 24 * 60 / agenda->rows(); | 120 | int minutesPerCell = 24 * 60 / agenda->rows(); |
121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
122 | int today = recalculate ? todayColumn() : oldToday; | 122 | int today = recalculate ? todayColumn() : oldToday; |
123 | int x = agenda->gridSpacingX()*today; | 123 | int x = agenda->gridSpacingX()*today; |
124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
125 | 125 | ||
126 | oldTime = tim; | 126 | oldTime = tim; |
127 | oldToday = today; | 127 | oldToday = today; |
128 | 128 | ||
129 | if(disabled || (today<0)) { | 129 | if(disabled || (today<0)) { |
130 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
131 | return; | 131 | return; |
132 | } else { | 132 | } else { |
133 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
134 | } | 134 | } |
135 | 135 | ||
136 | if(recalculate) | 136 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
139 | raise(); | 139 | raise(); |
140 | 140 | ||
141 | if(recalculate) | 141 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 144 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 146 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 147 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 148 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 149 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 150 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 151 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 153 | y-mTimeBox->height()); |
154 | 154 | ||
155 | mTimeBox->raise(); | 155 | mTimeBox->raise(); |
156 | //mTimeBox->setAutoMask(true); | 156 | //mTimeBox->setAutoMask(true); |
157 | minutes->start(5000,true); | 157 | minutes->start(5000,true); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////////////// |
162 | 162 | ||
163 | 163 | ||
164 | /* | 164 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 165 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 166 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 168 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 169 | QScrollView(parent,name,f) |
170 | { | 170 | { |
171 | 171 | ||
172 | 172 | ||
173 | mColumns = columns; | 173 | mColumns = columns; |
174 | mRows = rows; | 174 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 175 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 176 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 177 | #ifndef DESKTOP_VERSION |
178 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 178 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 179 | #endif |
180 | mHolidayMask = 0; | 180 | mHolidayMask = 0; |
181 | init(); | 181 | init(); |
182 | } | 182 | } |
183 | 183 | ||
184 | /* | 184 | /* |
185 | Create an agenda widget with columns columns and one row. This is used for | 185 | Create an agenda widget with columns columns and one row. This is used for |
186 | all-day events. | 186 | all-day events. |
187 | */ | 187 | */ |
188 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 188 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
189 | QScrollView(parent,name,f) | 189 | QScrollView(parent,name,f) |
190 | { | 190 | { |
191 | blockResize = false; | 191 | blockResize = false; |
192 | mColumns = columns; | 192 | mColumns = columns; |
193 | mRows = 1; | 193 | mRows = 1; |
194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
196 | mAllDayMode = true; | 196 | mAllDayMode = true; |
197 | #ifndef DESKTOP_VERSION | 197 | #ifndef DESKTOP_VERSION |
198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
199 | #endif | 199 | #endif |
200 | mHolidayMask = 0; | 200 | mHolidayMask = 0; |
201 | init(); | 201 | init(); |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | KOAgenda::~KOAgenda() | 205 | KOAgenda::~KOAgenda() |
206 | { | 206 | { |
207 | if(mMarcusBains) delete mMarcusBains; | 207 | if(mMarcusBains) delete mMarcusBains; |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 | ||
211 | Incidence *KOAgenda::selectedIncidence() const | 211 | Incidence *KOAgenda::selectedIncidence() const |
212 | { | 212 | { |
213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | QDate KOAgenda::selectedIncidenceDate() const | 217 | QDate KOAgenda::selectedIncidenceDate() const |
218 | { | 218 | { |
219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | void KOAgenda::init() | 223 | void KOAgenda::init() |
224 | { | 224 | { |
225 | mNewItemPopup = new QPopupMenu( this ); | 225 | mNewItemPopup = new QPopupMenu( this ); |
226 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 226 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
227 | QString pathString = ""; | 227 | QString pathString = ""; |
228 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 228 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
229 | if ( QApplication::desktop()->width() < 480 ) | 229 | if ( QApplication::desktop()->width() < 480 ) |
230 | pathString += "icons16/"; | 230 | pathString += "icons16/"; |
231 | } else | 231 | } else |
232 | pathString += "iconsmini/"; | 232 | pathString += "iconsmini/"; |
233 | 233 | ||
234 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 234 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
235 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 235 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
236 | mNewItemPopup->insertSeparator ( ); | 236 | mNewItemPopup->insertSeparator ( ); |
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); | 241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
243 | #ifndef _WIN32_ | 243 | #ifndef _WIN32_ |
244 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 244 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
245 | viewport()->setWFlags ( wflags); | 245 | viewport()->setWFlags ( wflags); |
246 | #endif | 246 | #endif |
247 | mGridSpacingX = 80; | 247 | mGridSpacingX = 80; |
248 | mResizeBorderWidth = 8; | 248 | mResizeBorderWidth = 8; |
249 | mScrollBorderWidth = 8; | 249 | mScrollBorderWidth = 8; |
250 | mScrollDelay = 30; | 250 | mScrollDelay = 30; |
251 | mScrollOffset = 10; | 251 | mScrollOffset = 10; |
252 | mPaintPixmap.resize( 20,20); | 252 | mPaintPixmap.resize( 20,20); |
253 | //enableClipper(true); | 253 | //enableClipper(true); |
254 | 254 | ||
255 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 255 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
256 | // effect. Has to be fixed. | 256 | // effect. Has to be fixed. |
257 | setFocusPolicy(WheelFocus); | 257 | setFocusPolicy(WheelFocus); |
258 | 258 | ||
259 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 259 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
260 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 260 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
261 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 261 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
262 | 262 | ||
263 | mStartCellX = 0; | 263 | mStartCellX = 0; |
264 | mStartCellY = 0; | 264 | mStartCellY = 0; |
265 | mCurrentCellX = 0; | 265 | mCurrentCellX = 0; |
266 | mCurrentCellY = 0; | 266 | mCurrentCellY = 0; |
267 | 267 | ||
268 | mSelectionCellX = 0; | 268 | mSelectionCellX = 0; |
269 | mSelectionYTop = 0; | 269 | mSelectionYTop = 0; |
270 | mSelectionHeight = 0; | 270 | mSelectionHeight = 0; |
271 | 271 | ||
272 | mOldLowerScrollValue = -1; | 272 | mOldLowerScrollValue = -1; |
273 | mOldUpperScrollValue = -1; | 273 | mOldUpperScrollValue = -1; |
274 | 274 | ||
275 | mClickedItem = 0; | 275 | mClickedItem = 0; |
276 | 276 | ||
277 | mActionItem = 0; | 277 | mActionItem = 0; |
278 | mActionType = NOP; | 278 | mActionType = NOP; |
279 | mItemMoved = false; | 279 | mItemMoved = false; |
280 | 280 | ||
281 | mSelectedItem = 0; | 281 | mSelectedItem = 0; |
282 | 282 | ||
283 | // mItems.setAutoDelete(true); | 283 | // mItems.setAutoDelete(true); |
284 | 284 | ||
285 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 285 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
286 | 286 | ||
287 | viewport()->update(); | 287 | viewport()->update(); |
288 | 288 | ||
289 | setMinimumSize(30, 1); | 289 | setMinimumSize(30, 1); |
290 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 290 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
291 | 291 | ||
292 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 292 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
293 | // controlled in a way that the contents horizontally always fits. Then it is | 293 | // controlled in a way that the contents horizontally always fits. Then it is |
294 | // not necessary to turn off the scrollbar. | 294 | // not necessary to turn off the scrollbar. |
295 | setHScrollBarMode(AlwaysOff); | 295 | setHScrollBarMode(AlwaysOff); |
296 | if ( ! mAllDayMode ) | 296 | if ( ! mAllDayMode ) |
297 | setVScrollBarMode(AlwaysOn); | 297 | setVScrollBarMode(AlwaysOn); |
298 | else | 298 | else |
299 | setVScrollBarMode(AlwaysOff); | 299 | setVScrollBarMode(AlwaysOff); |
300 | 300 | ||
301 | setStartHour(KOPrefs::instance()->mDayBegins); | 301 | setStartHour(KOPrefs::instance()->mDayBegins); |
302 | 302 | ||
303 | calculateWorkingHours(); | 303 | calculateWorkingHours(); |
304 | 304 | ||
305 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 305 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
306 | SLOT(checkScrollBoundaries(int))); | 306 | SLOT(checkScrollBoundaries(int))); |
307 | 307 | ||
308 | // Create the Marcus Bains line. | 308 | // Create the Marcus Bains line. |
309 | if(mAllDayMode) | 309 | if(mAllDayMode) |
310 | mMarcusBains = 0; | 310 | mMarcusBains = 0; |
311 | else { | 311 | else { |
312 | mMarcusBains = new MarcusBains(this); | 312 | mMarcusBains = new MarcusBains(this); |
313 | addChild(mMarcusBains); | 313 | addChild(mMarcusBains); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | void KOAgenda::clear() | 317 | void KOAgenda::clear() |
318 | { | 318 | { |
319 | KOAgendaItem *item; | 319 | KOAgendaItem *item; |
320 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 320 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
321 | mUnusedItems.append( item ); | 321 | mUnusedItems.append( item ); |
322 | //item->hide(); | 322 | //item->hide(); |
323 | } | 323 | } |
324 | mItems.clear(); | 324 | mItems.clear(); |
325 | mSelectedItem = 0; | 325 | mSelectedItem = 0; |
326 | clearSelection(); | 326 | clearSelection(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void KOAgenda::clearSelection() | 329 | void KOAgenda::clearSelection() |
330 | { | 330 | { |
331 | mSelectionCellX = 0; | 331 | mSelectionCellX = 0; |
332 | mSelectionYTop = 0; | 332 | mSelectionYTop = 0; |
333 | mSelectionHeight = 0; | 333 | mSelectionHeight = 0; |
334 | } | 334 | } |
335 | 335 | ||
336 | void KOAgenda::marcus_bains() | 336 | void KOAgenda::marcus_bains() |
337 | { | 337 | { |
338 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 338 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void KOAgenda::changeColumns(int columns) | 342 | void KOAgenda::changeColumns(int columns) |
343 | { | 343 | { |
344 | if (columns == 0) { | 344 | if (columns == 0) { |
345 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; | 345 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; |
346 | return; | 346 | return; |
347 | } | 347 | } |
348 | 348 | ||
349 | clear(); | 349 | clear(); |
350 | 350 | ||
351 | mColumns = columns; | 351 | mColumns = columns; |
352 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); | 352 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); |
353 | // init(); | 353 | // init(); |
354 | // update(); | 354 | // update(); |
355 | //qDebug("KOAgenda::changeColumns "); | 355 | //qDebug("KOAgenda::changeColumns "); |
356 | computeSizes(); | 356 | computeSizes(); |
357 | // QResizeEvent event( size(), size() ); | 357 | // QResizeEvent event( size(), size() ); |
358 | 358 | ||
359 | //QApplication::sendEvent( this, &event ); | 359 | //QApplication::sendEvent( this, &event ); |
360 | } | 360 | } |
361 | 361 | ||
362 | /* | 362 | /* |
363 | This is the eventFilter function, which gets all events from the KOAgendaItems | 363 | This is the eventFilter function, which gets all events from the KOAgendaItems |
364 | contained in the agenda. It has to handle moving and resizing for all items. | 364 | contained in the agenda. It has to handle moving and resizing for all items. |
365 | */ | 365 | */ |
366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
367 | { | 367 | { |
368 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 368 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
369 | switch(event->type()) { | 369 | switch(event->type()) { |
370 | case QEvent::MouseButtonPress: | 370 | case QEvent::MouseButtonPress: |
371 | case QEvent::MouseButtonDblClick: | 371 | case QEvent::MouseButtonDblClick: |
372 | case QEvent::MouseButtonRelease: | 372 | case QEvent::MouseButtonRelease: |
373 | case QEvent::MouseMove: | 373 | case QEvent::MouseMove: |
374 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 374 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
375 | 375 | ||
376 | case (QEvent::Leave): | 376 | case (QEvent::Leave): |
377 | if (!mActionItem) | 377 | if (!mActionItem) |
378 | setCursor(arrowCursor); | 378 | setCursor(arrowCursor); |
379 | return true; | 379 | return true; |
380 | 380 | ||
381 | default: | 381 | default: |
382 | return QScrollView::eventFilter(object,event); | 382 | return QScrollView::eventFilter(object,event); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
388 | { | 388 | { |
389 | //qDebug("KOAgenda::eventFilter_mous "); | 389 | //qDebug("KOAgenda::eventFilter_mous "); |
390 | QPoint viewportPos; | 390 | QPoint viewportPos; |
391 | if (object != viewport()) { | 391 | if (object != viewport()) { |
392 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 392 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
393 | } else { | 393 | } else { |
394 | viewportPos = me->pos(); | 394 | viewportPos = me->pos(); |
395 | } | 395 | } |
396 | static int startX = 0; | 396 | static int startX = 0; |
397 | static int startY = 0; | 397 | static int startY = 0; |
398 | static bool block = true; | 398 | static bool block = true; |
399 | switch (me->type()) { | 399 | switch (me->type()) { |
400 | case QEvent::MouseButtonPress: | 400 | case QEvent::MouseButtonPress: |
401 | //qDebug("QEvent::MouseButtonPress: "); | 401 | //qDebug("QEvent::MouseButtonPress: "); |
402 | // kdDebug() << "koagenda: filtered button press" << endl; | 402 | // kdDebug() << "koagenda: filtered button press" << endl; |
403 | if (object != viewport()) { | 403 | if (object != viewport()) { |
404 | if (me->button() == RightButton) { | 404 | if (me->button() == RightButton) { |
405 | 405 | ||
406 | mClickedItem = (KOAgendaItem *)object; | 406 | mClickedItem = (KOAgendaItem *)object; |
407 | if (mClickedItem) { | 407 | if (mClickedItem) { |
408 | selectItem(mClickedItem); | 408 | selectItem(mClickedItem); |
409 | // emit showIncidencePopupSignal(mClickedItem->incidence()); | 409 | // emit showIncidencePopupSignal(mClickedItem->incidence()); |
410 | } | 410 | } |
411 | //mItemPopup->popup(QCursor::pos()); | 411 | //mItemPopup->popup(QCursor::pos()); |
412 | } else { | 412 | } else { |
413 | mActionItem = (KOAgendaItem *)object; | 413 | mActionItem = (KOAgendaItem *)object; |
414 | if (mActionItem) { | 414 | if (mActionItem) { |
415 | if ( mSelectionHeight > 0 ) { | 415 | if ( mSelectionHeight > 0 ) { |
416 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 416 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
417 | int selectionYTop = mSelectionYTop; | 417 | int selectionYTop = mSelectionYTop; |
418 | int gridSpacingX = mGridSpacingX; | 418 | int gridSpacingX = mGridSpacingX; |
419 | int selectionHeight = mSelectionHeight; | 419 | int selectionHeight = mSelectionHeight; |
420 | clearSelection(); | 420 | clearSelection(); |
421 | repaintContents( selectionCellX, selectionYTop, | 421 | repaintContents( selectionCellX, selectionYTop, |
422 | gridSpacingX, selectionHeight,false ); | 422 | gridSpacingX, selectionHeight,false ); |
423 | } | 423 | } |
424 | selectItem(mActionItem); | 424 | selectItem(mActionItem); |
425 | Incidence *incidence = mActionItem->incidence(); | 425 | Incidence *incidence = mActionItem->incidence(); |
426 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 426 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
427 | mActionItem = 0; | 427 | mActionItem = 0; |
428 | } else { | 428 | } else { |
429 | startItemAction(viewportPos); | 429 | startItemAction(viewportPos); |
430 | startX = viewportPos.x(); | 430 | startX = viewportPos.x(); |
431 | startY = viewportPos.y(); | 431 | startY = viewportPos.y(); |
432 | block = true; | 432 | block = true; |
433 | } | 433 | } |
434 | } | 434 | } |
435 | } | 435 | } |
436 | } else { | 436 | } else { |
437 | selectItem(0); | 437 | selectItem(0); |
438 | mActionItem = 0; | 438 | mActionItem = 0; |
439 | if (me->button() == RightButton ) { | 439 | if (me->button() == RightButton ) { |
440 | blockNewEvent = true; | 440 | blockNewEvent = true; |
441 | qDebug("right "); | 441 | //qDebug("right "); |
442 | int x,y; | 442 | int x,y; |
443 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 443 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
444 | int gx,gy; | 444 | int gx,gy; |
445 | contentsToGrid(x,y,gx,gy); | 445 | contentsToGrid(x,y,gx,gy); |
446 | mStartCellX = gx; | 446 | mStartCellX = gx; |
447 | mStartCellY = gy; | 447 | mStartCellY = gy; |
448 | mCurrentCellX = gx; | 448 | mCurrentCellX = gx; |
449 | mCurrentCellY = gy; | 449 | mCurrentCellY = gy; |
450 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | 450 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); |
451 | 451 | ||
452 | } else { | 452 | } else { |
453 | blockNewEvent = false; | 453 | blockNewEvent = false; |
454 | setCursor(arrowCursor); | 454 | setCursor(arrowCursor); |
455 | startSelectAction(viewportPos); | 455 | startSelectAction(viewportPos); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | break; | 458 | break; |
459 | 459 | ||
460 | case QEvent::MouseButtonRelease: | 460 | case QEvent::MouseButtonRelease: |
461 | //qDebug("QEvent::MouseButtonRelease: "); | 461 | //qDebug("QEvent::MouseButtonRelease: "); |
462 | if (me->button() == RightButton && block ) { | 462 | if (me->button() == RightButton && block ) { |
463 | if (object != viewport()) { | 463 | if (object != viewport()) { |
464 | mClickedItem = (KOAgendaItem *)object; | 464 | mClickedItem = (KOAgendaItem *)object; |
465 | if (mActionItem ) { | 465 | if (mActionItem ) { |
466 | endItemAction(); | 466 | endItemAction(); |
467 | } | 467 | } |
468 | if (mClickedItem) { | 468 | if (mClickedItem) { |
469 | selectItem(mClickedItem); | 469 | selectItem(mClickedItem); |
470 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 470 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
471 | } | 471 | } |
472 | } | 472 | } |
473 | break; | 473 | break; |
474 | } | 474 | } |
475 | block = true; | 475 | block = true; |
476 | if (mActionItem) { | 476 | if (mActionItem) { |
477 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 477 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
478 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 478 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
479 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 479 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
480 | mScrollUpTimer.stop(); | 480 | mScrollUpTimer.stop(); |
481 | mScrollDownTimer.stop(); | 481 | mScrollDownTimer.stop(); |
482 | mActionItem->resetMove(); | 482 | mActionItem->resetMove(); |
483 | placeSubCells( mActionItem ); | 483 | placeSubCells( mActionItem ); |
484 | // emit startDragSignal( mActionItem->incidence() ); | 484 | // emit startDragSignal( mActionItem->incidence() ); |
485 | setCursor( arrowCursor ); | 485 | setCursor( arrowCursor ); |
486 | mActionItem = 0; | 486 | mActionItem = 0; |
487 | mActionType = NOP; | 487 | mActionType = NOP; |
488 | mItemMoved = 0; | 488 | mItemMoved = 0; |
489 | return true; | 489 | return true; |
490 | } | 490 | } |
491 | endItemAction(); | 491 | endItemAction(); |
492 | } else if ( mActionType == SELECT ) { | 492 | } else if ( mActionType == SELECT ) { |
493 | if (me->button() == RightButton ) { | 493 | if (me->button() == RightButton ) { |
494 | 494 | ||
495 | } else { | 495 | } else { |
496 | endSelectAction( !blockNewEvent ); | 496 | endSelectAction( !blockNewEvent ); |
497 | } | 497 | } |
498 | } | 498 | } |
499 | break; | 499 | break; |
500 | 500 | ||
501 | case QEvent::MouseMove: | 501 | case QEvent::MouseMove: |
502 | if (object != viewport()) { | 502 | if (object != viewport()) { |
503 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 503 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
504 | //qDebug("moveItem %d ",moveItem ); | 504 | //qDebug("moveItem %d ",moveItem ); |
505 | if (!moveItem->incidence()->isReadOnly() /*&& | 505 | if (!moveItem->incidence()->isReadOnly() /*&& |
506 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) | 506 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) |
507 | if (!mActionItem) | 507 | if (!mActionItem) |
508 | setNoActionCursor(moveItem,viewportPos); | 508 | setNoActionCursor(moveItem,viewportPos); |
509 | else { | 509 | else { |
510 | if ( block ) { | 510 | if ( block ) { |
511 | int dX, dY; | 511 | int dX, dY; |
512 | dX = startX - viewportPos.x(); | 512 | dX = startX - viewportPos.x(); |
513 | if ( dX < 0 ) | 513 | if ( dX < 0 ) |
514 | dX = -dX; | 514 | dX = -dX; |
515 | dY = viewportPos.y() - startY; | 515 | dY = viewportPos.y() - startY; |
516 | if ( dY < 0 ) | 516 | if ( dY < 0 ) |
517 | dY = -dY; | 517 | dY = -dY; |
518 | int diff = 30; | 518 | int diff = 30; |
519 | if ( QApplication::desktop()->width() < 480 ) | 519 | if ( QApplication::desktop()->width() < 480 ) |
520 | diff = 15; | 520 | diff = 15; |
521 | // qDebug(" %d %d ",dX, dY ); | 521 | // qDebug(" %d %d ",dX, dY ); |
522 | if ( dX > diff || dY > diff ) { | 522 | if ( dX > diff || dY > diff ) { |
523 | block = false; | 523 | block = false; |
524 | } | 524 | } |
525 | } | 525 | } |
526 | if ( !block ) | 526 | if ( !block ) |
527 | performItemAction(viewportPos); | 527 | performItemAction(viewportPos); |
528 | } | 528 | } |
529 | } else { | 529 | } else { |
530 | if ( mActionType == SELECT ) { | 530 | if ( mActionType == SELECT ) { |
531 | performSelectAction( viewportPos ); | 531 | performSelectAction( viewportPos ); |
532 | } | 532 | } |
533 | } | 533 | } |
534 | break; | 534 | break; |
535 | 535 | ||
536 | case QEvent::MouseButtonDblClick: | 536 | case QEvent::MouseButtonDblClick: |
537 | if (object == viewport()) { | 537 | if (object == viewport()) { |
538 | selectItem(0); | 538 | selectItem(0); |
539 | int x,y; | 539 | int x,y; |
540 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 540 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
541 | int gx,gy; | 541 | int gx,gy; |
542 | contentsToGrid(x,y,gx,gy); | 542 | contentsToGrid(x,y,gx,gy); |
543 | emit newEventSignal(gx,gy); | 543 | emit newEventSignal(gx,gy); |
544 | } else { | 544 | } else { |
545 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 545 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
546 | selectItem(doubleClickedItem); | 546 | selectItem(doubleClickedItem); |
547 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 547 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
548 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 548 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
549 | else | 549 | else |
550 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 550 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
551 | } | 551 | } |
552 | break; | 552 | break; |
553 | 553 | ||
554 | default: | 554 | default: |
555 | break; | 555 | break; |
556 | } | 556 | } |
557 | 557 | ||
558 | return true; | 558 | return true; |
559 | } | 559 | } |
560 | 560 | ||
561 | void KOAgenda::newItem( int item ) | 561 | void KOAgenda::newItem( int item ) |
562 | { | 562 | { |
563 | if ( item == 1 ) { //new event | 563 | if ( item == 1 ) { //new event |
564 | newEventSignal(mStartCellX ,mStartCellY ); | 564 | newEventSignal(mStartCellX ,mStartCellY ); |
565 | } else | 565 | } else |
566 | if ( item == 2 ) { //new event | 566 | if ( item == 2 ) { //new event |
567 | newTodoSignal(mStartCellX ,mStartCellY ); | 567 | newTodoSignal(mStartCellX ,mStartCellY ); |
568 | } else | 568 | } else |
569 | { | 569 | { |
570 | QDate day = mSelectedDates[mStartCellX]; | 570 | QDate day = mSelectedDates[mStartCellX]; |
571 | emit showDateView( item, day ); | 571 | emit showDateView( item, day ); |
572 | // 3Day view | 572 | // 3Day view |
573 | // 4Week view | 573 | // 4Week view |
574 | // 5Month view | 574 | // 5Month view |
575 | // 6Journal view | 575 | // 6Journal view |
576 | } | 576 | } |
577 | } | 577 | } |
578 | void KOAgenda::startSelectAction(QPoint viewportPos) | 578 | void KOAgenda::startSelectAction(QPoint viewportPos) |
579 | { | 579 | { |
580 | //emit newStartSelectSignal(); | 580 | //emit newStartSelectSignal(); |
581 | 581 | ||
582 | mActionType = SELECT; | 582 | mActionType = SELECT; |
583 | 583 | ||
584 | int x,y; | 584 | int x,y; |
585 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 585 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
586 | int gx,gy; | 586 | int gx,gy; |
587 | contentsToGrid(x,y,gx,gy); | 587 | contentsToGrid(x,y,gx,gy); |
588 | 588 | ||
589 | mStartCellX = gx; | 589 | mStartCellX = gx; |
590 | mStartCellY = gy; | 590 | mStartCellY = gy; |
591 | mCurrentCellX = gx; | 591 | mCurrentCellX = gx; |
592 | mCurrentCellY = gy; | 592 | mCurrentCellY = gy; |
593 | 593 | ||
594 | // Store coordinates of old selection | 594 | // Store coordinates of old selection |
595 | int selectionX = mSelectionCellX * mGridSpacingX; | 595 | int selectionX = mSelectionCellX * mGridSpacingX; |
596 | int selectionYTop = mSelectionYTop; | 596 | int selectionYTop = mSelectionYTop; |
597 | int selectionHeight = mSelectionHeight; | 597 | int selectionHeight = mSelectionHeight; |
598 | 598 | ||
599 | // Store new selection | 599 | // Store new selection |
600 | mSelectionCellX = gx; | 600 | mSelectionCellX = gx; |
601 | mSelectionYTop = gy * mGridSpacingY; | 601 | mSelectionYTop = gy * mGridSpacingY; |
602 | mSelectionHeight = mGridSpacingY; | 602 | mSelectionHeight = mGridSpacingY; |
603 | 603 | ||
604 | // Clear old selection | 604 | // Clear old selection |
605 | repaintContents( selectionX, selectionYTop, | 605 | repaintContents( selectionX, selectionYTop, |
606 | mGridSpacingX, selectionHeight,false ); | 606 | mGridSpacingX, selectionHeight,false ); |
607 | 607 | ||
608 | // Paint new selection | 608 | // Paint new selection |
609 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, | 609 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, |
610 | // mGridSpacingX, mSelectionHeight ); | 610 | // mGridSpacingX, mSelectionHeight ); |
611 | } | 611 | } |
612 | 612 | ||
613 | void KOAgenda::performSelectAction(QPoint viewportPos) | 613 | void KOAgenda::performSelectAction(QPoint viewportPos) |
614 | { | 614 | { |
615 | int x,y; | 615 | int x,y; |
616 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 616 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
617 | int gx,gy; | 617 | int gx,gy; |
618 | contentsToGrid(x,y,gx,gy); | 618 | contentsToGrid(x,y,gx,gy); |
619 | 619 | ||
620 | QPoint clipperPos = clipper()-> | 620 | QPoint clipperPos = clipper()-> |
621 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 621 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
622 | 622 | ||
623 | // Scroll if cursor was moved to upper or lower end of agenda. | 623 | // Scroll if cursor was moved to upper or lower end of agenda. |
624 | if (clipperPos.y() < mScrollBorderWidth) { | 624 | if (clipperPos.y() < mScrollBorderWidth) { |
625 | mScrollUpTimer.start(mScrollDelay); | 625 | mScrollUpTimer.start(mScrollDelay); |
626 | } else if (visibleHeight() - clipperPos.y() < | 626 | } else if (visibleHeight() - clipperPos.y() < |
627 | mScrollBorderWidth) { | 627 | mScrollBorderWidth) { |
628 | mScrollDownTimer.start(mScrollDelay); | 628 | mScrollDownTimer.start(mScrollDelay); |
629 | } else { | 629 | } else { |
630 | mScrollUpTimer.stop(); | 630 | mScrollUpTimer.stop(); |
631 | mScrollDownTimer.stop(); | 631 | mScrollDownTimer.stop(); |
632 | } | 632 | } |
633 | 633 | ||
634 | if ( gy > mCurrentCellY ) { | 634 | if ( gy > mCurrentCellY ) { |
635 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 635 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
636 | 636 | ||
637 | #if 0 | 637 | #if 0 |
638 | // FIXME: Repaint only the newly selected region | 638 | // FIXME: Repaint only the newly selected region |
639 | repaintContents( mSelectionCellX * mGridSpacingX, | 639 | repaintContents( mSelectionCellX * mGridSpacingX, |
640 | mCurrentCellY + mGridSpacingY, | 640 | mCurrentCellY + mGridSpacingY, |
641 | mGridSpacingX, | 641 | mGridSpacingX, |
642 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); | 642 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); |
643 | #else | 643 | #else |
644 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 644 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
645 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 645 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
646 | mGridSpacingX, mSelectionYTop, | 646 | mGridSpacingX, mSelectionYTop, |
647 | mGridSpacingX, mSelectionHeight , false); | 647 | mGridSpacingX, mSelectionHeight , false); |
648 | #endif | 648 | #endif |
649 | 649 | ||
650 | mCurrentCellY = gy; | 650 | mCurrentCellY = gy; |
651 | } else if ( gy < mCurrentCellY ) { | 651 | } else if ( gy < mCurrentCellY ) { |
652 | if ( gy >= mStartCellY ) { | 652 | if ( gy >= mStartCellY ) { |
653 | int selectionHeight = mSelectionHeight; | 653 | int selectionHeight = mSelectionHeight; |
654 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 654 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
655 | 655 | ||
656 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 656 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
657 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 657 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
658 | mGridSpacingX, mSelectionYTop, | 658 | mGridSpacingX, mSelectionYTop, |
659 | mGridSpacingX, selectionHeight,false ); | 659 | mGridSpacingX, selectionHeight,false ); |
660 | 660 | ||
661 | mCurrentCellY = gy; | 661 | mCurrentCellY = gy; |
662 | } else { | 662 | } else { |
663 | } | 663 | } |
664 | } | 664 | } |
665 | } | 665 | } |
666 | 666 | ||
667 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 667 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
668 | { | 668 | { |
669 | mActionType = NOP; | 669 | mActionType = NOP; |
670 | mScrollUpTimer.stop(); | 670 | mScrollUpTimer.stop(); |
671 | mScrollDownTimer.stop(); | 671 | mScrollDownTimer.stop(); |
672 | 672 | ||
673 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 673 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
674 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) | 674 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) |
675 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 675 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
676 | } | 676 | } |
677 | 677 | ||
678 | void KOAgenda::startItemAction(QPoint viewportPos) | 678 | void KOAgenda::startItemAction(QPoint viewportPos) |
679 | { | 679 | { |
680 | int x,y; | 680 | int x,y; |
681 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 681 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
682 | int gx,gy; | 682 | int gx,gy; |
683 | contentsToGrid(x,y,gx,gy); | 683 | contentsToGrid(x,y,gx,gy); |
684 | 684 | ||
685 | mStartCellX = gx; | 685 | mStartCellX = gx; |
686 | mStartCellY = gy; | 686 | mStartCellY = gy; |
687 | mCurrentCellX = gx; | 687 | mCurrentCellX = gx; |
688 | mCurrentCellY = gy; | 688 | mCurrentCellY = gy; |
689 | 689 | ||
690 | if (mAllDayMode) { | 690 | if (mAllDayMode) { |
691 | int gridDistanceX = (x - gx * mGridSpacingX); | 691 | int gridDistanceX = (x - gx * mGridSpacingX); |
692 | if (gridDistanceX < mResizeBorderWidth && | 692 | if (gridDistanceX < mResizeBorderWidth && |
693 | mActionItem->cellX() == mCurrentCellX) { | 693 | mActionItem->cellX() == mCurrentCellX) { |
694 | mActionType = RESIZELEFT; | 694 | mActionType = RESIZELEFT; |
695 | setCursor(sizeHorCursor); | 695 | setCursor(sizeHorCursor); |
696 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 696 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
697 | mActionItem->cellXWidth() == mCurrentCellX) { | 697 | mActionItem->cellXWidth() == mCurrentCellX) { |
698 | mActionType = RESIZERIGHT; | 698 | mActionType = RESIZERIGHT; |
699 | setCursor(sizeHorCursor); | 699 | setCursor(sizeHorCursor); |
700 | } else { | 700 | } else { |
701 | mActionType = MOVE; | 701 | mActionType = MOVE; |
702 | mActionItem->startMove(); | 702 | mActionItem->startMove(); |
703 | setCursor(sizeAllCursor); | 703 | setCursor(sizeAllCursor); |
704 | } | 704 | } |
705 | } else { | 705 | } else { |
706 | int gridDistanceY = (y - gy * mGridSpacingY); | 706 | int gridDistanceY = (y - gy * mGridSpacingY); |
707 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 707 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
708 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 708 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
709 | mActionItem->cellYTop() == mCurrentCellY && | 709 | mActionItem->cellYTop() == mCurrentCellY && |
710 | !mActionItem->firstMultiItem()) { | 710 | !mActionItem->firstMultiItem()) { |
711 | mActionType = RESIZETOP; | 711 | mActionType = RESIZETOP; |
712 | setCursor(sizeVerCursor); | 712 | setCursor(sizeVerCursor); |
713 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 713 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
714 | mActionItem->cellYBottom() == mCurrentCellY && | 714 | mActionItem->cellYBottom() == mCurrentCellY && |
715 | !mActionItem->lastMultiItem()) { | 715 | !mActionItem->lastMultiItem()) { |
716 | mActionType = RESIZEBOTTOM; | 716 | mActionType = RESIZEBOTTOM; |
717 | setCursor(sizeVerCursor); | 717 | setCursor(sizeVerCursor); |
718 | } else { | 718 | } else { |
719 | mActionType = MOVE; | 719 | mActionType = MOVE; |
720 | mActionItem->startMove(); | 720 | mActionItem->startMove(); |
721 | setCursor(sizeAllCursor); | 721 | setCursor(sizeAllCursor); |
722 | } | 722 | } |
723 | } | 723 | } |
724 | } | 724 | } |
725 | 725 | ||
726 | void KOAgenda::performItemAction(QPoint viewportPos) | 726 | void KOAgenda::performItemAction(QPoint viewportPos) |
727 | { | 727 | { |
728 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 728 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
729 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 729 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
730 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 730 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
731 | // point = clipper()->mapFromGlobal(point); | 731 | // point = clipper()->mapFromGlobal(point); |
732 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 732 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
733 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 733 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
734 | int x,y; | 734 | int x,y; |
735 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 735 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
736 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 736 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
737 | int gx,gy; | 737 | int gx,gy; |
738 | contentsToGrid(x,y,gx,gy); | 738 | contentsToGrid(x,y,gx,gy); |
739 | QPoint clipperPos = clipper()-> | 739 | QPoint clipperPos = clipper()-> |
740 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 740 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
741 | 741 | ||
742 | // Cursor left active agenda area. | 742 | // Cursor left active agenda area. |
743 | // This starts a drag. | 743 | // This starts a drag. |
744 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 744 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
745 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 745 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
746 | if ( mActionType == MOVE ) { | 746 | if ( mActionType == MOVE ) { |
747 | mScrollUpTimer.stop(); | 747 | mScrollUpTimer.stop(); |
748 | mScrollDownTimer.stop(); | 748 | mScrollDownTimer.stop(); |
749 | mActionItem->resetMove(); | 749 | mActionItem->resetMove(); |
750 | placeSubCells( mActionItem ); | 750 | placeSubCells( mActionItem ); |
751 | // emit startDragSignal( mActionItem->incidence() ); | 751 | // emit startDragSignal( mActionItem->incidence() ); |
752 | setCursor( arrowCursor ); | 752 | setCursor( arrowCursor ); |
753 | mActionItem = 0; | 753 | mActionItem = 0; |
754 | mActionType = NOP; | 754 | mActionType = NOP; |
755 | mItemMoved = 0; | 755 | mItemMoved = 0; |
756 | return; | 756 | return; |
757 | } | 757 | } |
758 | } else { | 758 | } else { |
759 | switch ( mActionType ) { | 759 | switch ( mActionType ) { |
760 | case MOVE: | 760 | case MOVE: |
761 | setCursor( sizeAllCursor ); | 761 | setCursor( sizeAllCursor ); |
762 | break; | 762 | break; |
763 | case RESIZETOP: | 763 | case RESIZETOP: |
764 | case RESIZEBOTTOM: | 764 | case RESIZEBOTTOM: |
765 | setCursor( sizeVerCursor ); | 765 | setCursor( sizeVerCursor ); |
766 | break; | 766 | break; |
767 | case RESIZELEFT: | 767 | case RESIZELEFT: |
768 | case RESIZERIGHT: | 768 | case RESIZERIGHT: |
769 | setCursor( sizeHorCursor ); | 769 | setCursor( sizeHorCursor ); |
770 | break; | 770 | break; |
771 | default: | 771 | default: |
772 | setCursor( arrowCursor ); | 772 | setCursor( arrowCursor ); |
773 | } | 773 | } |
774 | } | 774 | } |
775 | 775 | ||
776 | // Scroll if item was moved to upper or lower end of agenda. | 776 | // Scroll if item was moved to upper or lower end of agenda. |
777 | if (clipperPos.y() < mScrollBorderWidth) { | 777 | if (clipperPos.y() < mScrollBorderWidth) { |
778 | mScrollUpTimer.start(mScrollDelay); | 778 | mScrollUpTimer.start(mScrollDelay); |
779 | } else if (visibleHeight() - clipperPos.y() < | 779 | } else if (visibleHeight() - clipperPos.y() < |
780 | mScrollBorderWidth) { | 780 | mScrollBorderWidth) { |
781 | mScrollDownTimer.start(mScrollDelay); | 781 | mScrollDownTimer.start(mScrollDelay); |
782 | } else { | 782 | } else { |
783 | mScrollUpTimer.stop(); | 783 | mScrollUpTimer.stop(); |
784 | mScrollDownTimer.stop(); | 784 | mScrollDownTimer.stop(); |
785 | } | 785 | } |
786 | 786 | ||
787 | // Move or resize item if necessary | 787 | // Move or resize item if necessary |
788 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 788 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
789 | mItemMoved = true; | 789 | mItemMoved = true; |
790 | mActionItem->raise(); | 790 | mActionItem->raise(); |
791 | if (mActionType == MOVE) { | 791 | if (mActionType == MOVE) { |
792 | // Move all items belonging to a multi item | 792 | // Move all items belonging to a multi item |
793 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 793 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
794 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 794 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
795 | if (!moveItem) moveItem = mActionItem; | 795 | if (!moveItem) moveItem = mActionItem; |
796 | while (moveItem) { | 796 | while (moveItem) { |
797 | int dy; | 797 | int dy; |
798 | if (isMultiItem) dy = 0; | 798 | if (isMultiItem) dy = 0; |
799 | else dy = gy - mCurrentCellY; | 799 | else dy = gy - mCurrentCellY; |
800 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 800 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
801 | int x,y; | 801 | int x,y; |
802 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 802 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
803 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 803 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
804 | mGridSpacingY * moveItem->cellHeight()); | 804 | mGridSpacingY * moveItem->cellHeight()); |
805 | moveChild(moveItem,x,y); | 805 | moveChild(moveItem,x,y); |
806 | moveItem = moveItem->nextMultiItem(); | 806 | moveItem = moveItem->nextMultiItem(); |
807 | } | 807 | } |
808 | } else if (mActionType == RESIZETOP) { | 808 | } else if (mActionType == RESIZETOP) { |
809 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 809 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
810 | mActionItem->expandTop(gy - mCurrentCellY); | 810 | mActionItem->expandTop(gy - mCurrentCellY); |
811 | mActionItem->resize(mActionItem->width(), | 811 | mActionItem->resize(mActionItem->width(), |
812 | mGridSpacingY * mActionItem->cellHeight()); | 812 | mGridSpacingY * mActionItem->cellHeight()); |
813 | int x,y; | 813 | int x,y; |
814 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 814 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
815 | //moveChild(mActionItem,childX(mActionItem),y); | 815 | //moveChild(mActionItem,childX(mActionItem),y); |
816 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 816 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
817 | } | 817 | } |
818 | } else if (mActionType == RESIZEBOTTOM) { | 818 | } else if (mActionType == RESIZEBOTTOM) { |
819 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 819 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
820 | mActionItem->expandBottom(gy - mCurrentCellY); | 820 | mActionItem->expandBottom(gy - mCurrentCellY); |
821 | mActionItem->resize(mActionItem->width(), | 821 | mActionItem->resize(mActionItem->width(), |
822 | mGridSpacingY * mActionItem->cellHeight()); | 822 | mGridSpacingY * mActionItem->cellHeight()); |
823 | } | 823 | } |
824 | } else if (mActionType == RESIZELEFT) { | 824 | } else if (mActionType == RESIZELEFT) { |
825 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 825 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
826 | mActionItem->expandLeft(gx - mCurrentCellX); | 826 | mActionItem->expandLeft(gx - mCurrentCellX); |
827 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 827 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
828 | mActionItem->height()); | 828 | mActionItem->height()); |
829 | int x,y; | 829 | int x,y; |
830 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 830 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
831 | moveChild(mActionItem,x,childY(mActionItem)); | 831 | moveChild(mActionItem,x,childY(mActionItem)); |
832 | } | 832 | } |
833 | } else if (mActionType == RESIZERIGHT) { | 833 | } else if (mActionType == RESIZERIGHT) { |
834 | if (mCurrentCellX >= mActionItem->cellX()) { | 834 | if (mCurrentCellX >= mActionItem->cellX()) { |
835 | mActionItem->expandRight(gx - mCurrentCellX); | 835 | mActionItem->expandRight(gx - mCurrentCellX); |
836 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 836 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
837 | mActionItem->height()); | 837 | mActionItem->height()); |
838 | } | 838 | } |
839 | } | 839 | } |
840 | mCurrentCellX = gx; | 840 | mCurrentCellX = gx; |
841 | mCurrentCellY = gy; | 841 | mCurrentCellY = gy; |
842 | } | 842 | } |
843 | } | 843 | } |
844 | 844 | ||
845 | void KOAgenda::endItemAction() | 845 | void KOAgenda::endItemAction() |
846 | { | 846 | { |
847 | 847 | ||
848 | if ( mItemMoved ) { | 848 | if ( mItemMoved ) { |
849 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 849 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
850 | if ( !placeItem ) { | 850 | if ( !placeItem ) { |
851 | placeItem = mActionItem; | 851 | placeItem = mActionItem; |
852 | } | 852 | } |
853 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 853 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
854 | Incidence* oldInc = placeItem->incidence(); | 854 | Incidence* oldInc = placeItem->incidence(); |
855 | placeItem->recreateIncidence(); | 855 | placeItem->recreateIncidence(); |
856 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 856 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
857 | } | 857 | } |
858 | int type = mActionType; | 858 | int type = mActionType; |
859 | if ( mAllDayMode ) | 859 | if ( mAllDayMode ) |
860 | type = -1; | 860 | type = -1; |
861 | KOAgendaItem *modifiedItem = placeItem; | 861 | KOAgendaItem *modifiedItem = placeItem; |
862 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 862 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
863 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 863 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
864 | KOAgendaItem *item; | 864 | KOAgendaItem *item; |
865 | 865 | ||
866 | if ( placeItem->incidence()->type() == "Todo" ) { | 866 | if ( placeItem->incidence()->type() == "Todo" ) { |
867 | mSelectedItem = 0; | 867 | mSelectedItem = 0; |
868 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 868 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
869 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 869 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
870 | emit itemModified( modifiedItem, mActionType ); | 870 | emit itemModified( modifiedItem, mActionType ); |
871 | } | 871 | } |
872 | else { | 872 | else { |
873 | #if 0 | 873 | #if 0 |
874 | for ( item=oldconflictItems.first(); item != 0; | 874 | for ( item=oldconflictItems.first(); item != 0; |
875 | item=oldconflictItems.next() ) { | 875 | item=oldconflictItems.next() ) { |
876 | placeSubCells(item); | 876 | placeSubCells(item); |
877 | } | 877 | } |
878 | while ( placeItem ) { | 878 | while ( placeItem ) { |
879 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 879 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
880 | placeSubCells( placeItem ); | 880 | placeSubCells( placeItem ); |
881 | placeItem = placeItem->nextMultiItem(); | 881 | placeItem = placeItem->nextMultiItem(); |
882 | } | 882 | } |
883 | #endif | 883 | #endif |
884 | 884 | ||
885 | globalFlagBlockAgendaItemPaint = 1; | 885 | globalFlagBlockAgendaItemPaint = 1; |
886 | for ( item=oldconflictItems.first(); item != 0; | 886 | for ( item=oldconflictItems.first(); item != 0; |
887 | item=oldconflictItems.next() ) { | 887 | item=oldconflictItems.next() ) { |
888 | placeSubCells(item); | 888 | placeSubCells(item); |
889 | } | 889 | } |
890 | while ( placeItem ) { | 890 | while ( placeItem ) { |
891 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 891 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
892 | oldconflictItems = placeItem->conflictItems(); | 892 | oldconflictItems = placeItem->conflictItems(); |
893 | for ( item=oldconflictItems.first(); item != 0; | 893 | for ( item=oldconflictItems.first(); item != 0; |
894 | item=oldconflictItems.next() ) { | 894 | item=oldconflictItems.next() ) { |
895 | placeSubCells(item); | 895 | placeSubCells(item); |
896 | } | 896 | } |
897 | placeSubCells( placeItem ); | 897 | placeSubCells( placeItem ); |
898 | placeItem = placeItem->nextMultiItem(); | 898 | placeItem = placeItem->nextMultiItem(); |
899 | } | 899 | } |
900 | globalFlagBlockAgendaItemPaint = 0; | 900 | globalFlagBlockAgendaItemPaint = 0; |
901 | for ( item=oldconflictItems.first(); item != 0; | 901 | for ( item=oldconflictItems.first(); item != 0; |
902 | item=oldconflictItems.next() ) { | 902 | item=oldconflictItems.next() ) { |
903 | globalFlagBlockAgendaItemUpdate = 0; | 903 | globalFlagBlockAgendaItemUpdate = 0; |
904 | item->repaintMe(); | 904 | item->repaintMe(); |
905 | globalFlagBlockAgendaItemUpdate = 1; | 905 | globalFlagBlockAgendaItemUpdate = 1; |
906 | item->repaint( false ); | 906 | item->repaint( false ); |
907 | } | 907 | } |
908 | placeItem = modifiedItem; | 908 | placeItem = modifiedItem; |
909 | 909 | ||
910 | while ( placeItem ) { | 910 | while ( placeItem ) { |
911 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 911 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
912 | globalFlagBlockAgendaItemUpdate = 0; | 912 | globalFlagBlockAgendaItemUpdate = 0; |
913 | placeItem->repaintMe(); | 913 | placeItem->repaintMe(); |
914 | globalFlagBlockAgendaItemUpdate = 1; | 914 | globalFlagBlockAgendaItemUpdate = 1; |
915 | placeItem->repaint(false); | 915 | placeItem->repaint(false); |
916 | placeItem = placeItem->nextMultiItem(); | 916 | placeItem = placeItem->nextMultiItem(); |
917 | } | 917 | } |
918 | emit itemModified( modifiedItem, mActionType ); | 918 | emit itemModified( modifiedItem, mActionType ); |
919 | 919 | ||
920 | 920 | ||
921 | placeItem = modifiedItem; | 921 | placeItem = modifiedItem; |
922 | while ( placeItem ) { | 922 | while ( placeItem ) { |
923 | oldconflictItems = placeItem->conflictItems(); | 923 | oldconflictItems = placeItem->conflictItems(); |
924 | for ( item=oldconflictItems.first(); item != 0; | 924 | for ( item=oldconflictItems.first(); item != 0; |
925 | item=oldconflictItems.next() ) { | 925 | item=oldconflictItems.next() ) { |
926 | placeSubCells(item); | 926 | placeSubCells(item); |
927 | } | 927 | } |
928 | placeSubCells( placeItem ); | 928 | placeSubCells( placeItem ); |
929 | placeItem = placeItem->nextMultiItem(); | 929 | placeItem = placeItem->nextMultiItem(); |
930 | 930 | ||
931 | } | 931 | } |
932 | placeItem = modifiedItem; | 932 | placeItem = modifiedItem; |
933 | while ( placeItem ) { | 933 | while ( placeItem ) { |
934 | oldconflictItems = placeItem->conflictItems(); | 934 | oldconflictItems = placeItem->conflictItems(); |
935 | for ( item=oldconflictItems.first(); item != 0; | 935 | for ( item=oldconflictItems.first(); item != 0; |
936 | item=oldconflictItems.next() ) { | 936 | item=oldconflictItems.next() ) { |
937 | globalFlagBlockAgendaItemUpdate = 0; | 937 | globalFlagBlockAgendaItemUpdate = 0; |
938 | item->repaintMe(); | 938 | item->repaintMe(); |
939 | globalFlagBlockAgendaItemUpdate = 1; | 939 | globalFlagBlockAgendaItemUpdate = 1; |
940 | item->repaint(false); | 940 | item->repaint(false); |
941 | } | 941 | } |
942 | placeItem = placeItem->nextMultiItem(); | 942 | placeItem = placeItem->nextMultiItem(); |
943 | } | 943 | } |
944 | /* | 944 | /* |
945 | 945 | ||
946 | oldconflictItems = modifiedItem->conflictItems(); | 946 | oldconflictItems = modifiedItem->conflictItems(); |
947 | for ( item=oldconflictItems.first(); item != 0; | 947 | for ( item=oldconflictItems.first(); item != 0; |
948 | item=oldconflictItems.next() ) { | 948 | item=oldconflictItems.next() ) { |
949 | globalFlagBlockAgendaItemUpdate = 0; | 949 | globalFlagBlockAgendaItemUpdate = 0; |
950 | item->paintMe(false); | 950 | item->paintMe(false); |
951 | globalFlagBlockAgendaItemUpdate = 1; | 951 | globalFlagBlockAgendaItemUpdate = 1; |
952 | item->repaint(false); | 952 | item->repaint(false); |
953 | } | 953 | } |
954 | */ | 954 | */ |
955 | 955 | ||
956 | 956 | ||
957 | } | 957 | } |
958 | 958 | ||
959 | } | 959 | } |
960 | 960 | ||
961 | mScrollUpTimer.stop(); | 961 | mScrollUpTimer.stop(); |
962 | mScrollDownTimer.stop(); | 962 | mScrollDownTimer.stop(); |
963 | setCursor( arrowCursor ); | 963 | setCursor( arrowCursor ); |
964 | mActionItem = 0; | 964 | mActionItem = 0; |
965 | mActionType = NOP; | 965 | mActionType = NOP; |
966 | mItemMoved = 0; | 966 | mItemMoved = 0; |
967 | 967 | ||
968 | } | 968 | } |
969 | 969 | ||
970 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 970 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
971 | { | 971 | { |
972 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 972 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
973 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 973 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
974 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 974 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
975 | // point = clipper()->mapFromGlobal(point); | 975 | // point = clipper()->mapFromGlobal(point); |
976 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 976 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
977 | 977 | ||
978 | int x,y; | 978 | int x,y; |
979 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 979 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
980 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 980 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
981 | int gx,gy; | 981 | int gx,gy; |
982 | contentsToGrid(x,y,gx,gy); | 982 | contentsToGrid(x,y,gx,gy); |
983 | 983 | ||
984 | // Change cursor to resize cursor if appropriate | 984 | // Change cursor to resize cursor if appropriate |
985 | if (mAllDayMode) { | 985 | if (mAllDayMode) { |
986 | int gridDistanceX = (x - gx * mGridSpacingX); | 986 | int gridDistanceX = (x - gx * mGridSpacingX); |
987 | if (gridDistanceX < mResizeBorderWidth && | 987 | if (gridDistanceX < mResizeBorderWidth && |
988 | moveItem->cellX() == gx) { | 988 | moveItem->cellX() == gx) { |
989 | setCursor(sizeHorCursor); | 989 | setCursor(sizeHorCursor); |
990 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 990 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
991 | moveItem->cellXWidth() == gx) { | 991 | moveItem->cellXWidth() == gx) { |
992 | setCursor(sizeHorCursor); | 992 | setCursor(sizeHorCursor); |
993 | } else { | 993 | } else { |
994 | setCursor(arrowCursor); | 994 | setCursor(arrowCursor); |
995 | } | 995 | } |
996 | } else { | 996 | } else { |
997 | int gridDistanceY = (y - gy * mGridSpacingY); | 997 | int gridDistanceY = (y - gy * mGridSpacingY); |
998 | if (gridDistanceY < mResizeBorderWidth && | 998 | if (gridDistanceY < mResizeBorderWidth && |
999 | moveItem->cellYTop() == gy && | 999 | moveItem->cellYTop() == gy && |
1000 | !moveItem->firstMultiItem()) { | 1000 | !moveItem->firstMultiItem()) { |
1001 | setCursor(sizeVerCursor); | 1001 | setCursor(sizeVerCursor); |
1002 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1002 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1003 | moveItem->cellYBottom() == gy && | 1003 | moveItem->cellYBottom() == gy && |
1004 | !moveItem->lastMultiItem()) { | 1004 | !moveItem->lastMultiItem()) { |
1005 | setCursor(sizeVerCursor); | 1005 | setCursor(sizeVerCursor); |
1006 | } else { | 1006 | } else { |
1007 | setCursor(arrowCursor); | 1007 | setCursor(arrowCursor); |
1008 | } | 1008 | } |
1009 | } | 1009 | } |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | 1012 | ||
1013 | /* | 1013 | /* |
1014 | Place item in cell and take care that multiple items using the same cell do | 1014 | Place item in cell and take care that multiple items using the same cell do |
1015 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1015 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1016 | it can get in all cases. | 1016 | it can get in all cases. |
1017 | At the moment the method has a bug: When an item is placed only the sub cell | 1017 | At the moment the method has a bug: When an item is placed only the sub cell |
1018 | widths of the items are changed, which are within the Y region the item to | 1018 | widths of the items are changed, which are within the Y region the item to |
1019 | place spans. When the sub cell width change of one of this items affects a | 1019 | place spans. When the sub cell width change of one of this items affects a |
1020 | cell, where other items are, which do not overlap in Y with the item to place, | 1020 | cell, where other items are, which do not overlap in Y with the item to place, |
1021 | the display gets corrupted, although the corruption looks quite nice. | 1021 | the display gets corrupted, although the corruption looks quite nice. |
1022 | */ | 1022 | */ |
1023 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1023 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1024 | { | 1024 | { |
1025 | 1025 | ||
1026 | QPtrList<KOAgendaItem> conflictItems; | 1026 | QPtrList<KOAgendaItem> conflictItems; |
1027 | int maxSubCells = 0; | 1027 | int maxSubCells = 0; |
1028 | QIntDict<KOAgendaItem> subCellDict(5); | 1028 | QIntDict<KOAgendaItem> subCellDict(5); |
1029 | 1029 | ||
1030 | KOAgendaItem *item; | 1030 | KOAgendaItem *item; |
1031 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1031 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1032 | if (item != placeItem) { | 1032 | if (item != placeItem) { |
1033 | if (placeItem->cellX() <= item->cellXWidth() && | 1033 | if (placeItem->cellX() <= item->cellXWidth() && |
1034 | placeItem->cellXWidth() >= item->cellX()) { | 1034 | placeItem->cellXWidth() >= item->cellX()) { |
1035 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1035 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1036 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1036 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1037 | conflictItems.append(item); | 1037 | conflictItems.append(item); |
1038 | if (item->subCells() > maxSubCells) | 1038 | if (item->subCells() > maxSubCells) |
1039 | maxSubCells = item->subCells(); | 1039 | maxSubCells = item->subCells(); |
1040 | subCellDict.insert(item->subCell(),item); | 1040 | subCellDict.insert(item->subCell(),item); |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | } | 1043 | } |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | if (conflictItems.count() > 0) { | 1046 | if (conflictItems.count() > 0) { |
1047 | // Look for unused sub cell and insert item | 1047 | // Look for unused sub cell and insert item |
1048 | int i; | 1048 | int i; |
1049 | for(i=0;i<maxSubCells;++i) { | 1049 | for(i=0;i<maxSubCells;++i) { |
1050 | if (!subCellDict.find(i)) { | 1050 | if (!subCellDict.find(i)) { |
1051 | placeItem->setSubCell(i); | 1051 | placeItem->setSubCell(i); |
1052 | break; | 1052 | break; |
1053 | } | 1053 | } |
1054 | } | 1054 | } |
1055 | if (i == maxSubCells) { | 1055 | if (i == maxSubCells) { |
1056 | placeItem->setSubCell(maxSubCells); | 1056 | placeItem->setSubCell(maxSubCells); |
1057 | maxSubCells++; // add new item to number of sub cells | 1057 | maxSubCells++; // add new item to number of sub cells |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | // Prepare for sub cell geometry adjustment | 1060 | // Prepare for sub cell geometry adjustment |
1061 | int newSubCellWidth; | 1061 | int newSubCellWidth; |
1062 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1062 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1063 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1063 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1064 | conflictItems.append(placeItem); | 1064 | conflictItems.append(placeItem); |
1065 | 1065 | ||
1066 | 1066 | ||
1067 | // Adjust sub cell geometry of all items | 1067 | // Adjust sub cell geometry of all items |
1068 | for ( item=conflictItems.first(); item != 0; | 1068 | for ( item=conflictItems.first(); item != 0; |
1069 | item=conflictItems.next() ) { | 1069 | item=conflictItems.next() ) { |
1070 | item->setSubCells(maxSubCells); | 1070 | item->setSubCells(maxSubCells); |
1071 | if (mAllDayMode) { | 1071 | if (mAllDayMode) { |
1072 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1072 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1073 | } else { | 1073 | } else { |
1074 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1074 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1075 | } | 1075 | } |
1076 | int x,y; | 1076 | int x,y; |
1077 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1077 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1078 | if (mAllDayMode) { | 1078 | if (mAllDayMode) { |
1079 | y += item->subCell() * newSubCellWidth; | 1079 | y += item->subCell() * newSubCellWidth; |
1080 | } else { | 1080 | } else { |
1081 | x += item->subCell() * newSubCellWidth; | 1081 | x += item->subCell() * newSubCellWidth; |
1082 | } | 1082 | } |
1083 | moveChild(item,x,y); | 1083 | moveChild(item,x,y); |
1084 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1084 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1085 | //item->updateItem(); | 1085 | //item->updateItem(); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | } else { | 1088 | } else { |
1089 | placeItem->setSubCell(0); | 1089 | placeItem->setSubCell(0); |
1090 | placeItem->setSubCells(1); | 1090 | placeItem->setSubCells(1); |
1091 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1091 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1092 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1092 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1093 | int x,y; | 1093 | int x,y; |
1094 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1094 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1095 | moveChild(placeItem,x,y); | 1095 | moveChild(placeItem,x,y); |
1096 | } | 1096 | } |
1097 | placeItem->setConflictItems(conflictItems); | 1097 | placeItem->setConflictItems(conflictItems); |
1098 | // for ( item=conflictItems.first(); item != 0; | 1098 | // for ( item=conflictItems.first(); item != 0; |
1099 | // item=conflictItems.next() ) { | 1099 | // item=conflictItems.next() ) { |
1100 | // //item->updateItem(); | 1100 | // //item->updateItem(); |
1101 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1101 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1102 | // } | 1102 | // } |
1103 | // placeItem->updateItem(); | 1103 | // placeItem->updateItem(); |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1106 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1107 | { | 1107 | { |
1108 | if ( globalFlagBlockAgenda ) | 1108 | if ( globalFlagBlockAgenda ) |
1109 | return; | 1109 | return; |
1110 | //qDebug("KOAgenda::drawContents "); | 1110 | //qDebug("KOAgenda::drawContents "); |
1111 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1111 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1112 | ;//drawContentsToPainter(); | 1112 | ;//drawContentsToPainter(); |
1113 | 1113 | ||
1114 | QPaintDevice* pd = p->device(); | 1114 | QPaintDevice* pd = p->device(); |
1115 | p->end(); | 1115 | p->end(); |
1116 | int vx, vy; | 1116 | int vx, vy; |
1117 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1117 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1118 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1118 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1119 | mSelectionCellX * mGridSpacingX; | 1119 | mSelectionCellX * mGridSpacingX; |
1120 | contentsToViewport ( cx, cy, vx,vy); | 1120 | contentsToViewport ( cx, cy, vx,vy); |
1121 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1121 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1122 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1122 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1123 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1123 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1124 | 1124 | ||
1125 | if ( mSelectionHeight > 0 ) { | 1125 | if ( mSelectionHeight > 0 ) { |
1126 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1126 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1127 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1127 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1128 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1128 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1129 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1129 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1130 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1130 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | //qDebug("btbl "); | 1133 | //qDebug("btbl "); |
1134 | p->begin( pd ); | 1134 | p->begin( pd ); |
1135 | //qDebug("end "); | 1135 | //qDebug("end "); |
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | void KOAgenda::finishUpdate() | 1138 | void KOAgenda::finishUpdate() |
1139 | { | 1139 | { |
1140 | 1140 | ||
1141 | KOAgendaItem *item; | 1141 | KOAgendaItem *item; |
1142 | globalFlagBlockAgendaItemPaint = 1; | 1142 | globalFlagBlockAgendaItemPaint = 1; |
1143 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1143 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1144 | if ( !item->isVisible() ) | 1144 | if ( !item->isVisible() ) |
1145 | item->show(); | 1145 | item->show(); |
1146 | 1146 | ||
1147 | } | 1147 | } |
1148 | globalFlagBlockAgendaItemUpdate = 0; | 1148 | globalFlagBlockAgendaItemUpdate = 0; |
1149 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1149 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1150 | item->repaintMe( ); | 1150 | item->repaintMe( ); |
1151 | } | 1151 | } |
1152 | globalFlagBlockAgendaItemUpdate = 1; | 1152 | globalFlagBlockAgendaItemUpdate = 1; |
1153 | qApp->processEvents(); | 1153 | qApp->processEvents(); |
1154 | globalFlagBlockAgendaItemPaint = 0; | 1154 | globalFlagBlockAgendaItemPaint = 0; |
1155 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1155 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1156 | item->repaint( false ); | 1156 | item->repaint( false ); |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | /* | 1161 | /* |
1162 | Draw grid in the background of the agenda. | 1162 | Draw grid in the background of the agenda. |
1163 | */ | 1163 | */ |
1164 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1164 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1165 | { | 1165 | { |
1166 | 1166 | ||
1167 | 1167 | ||
1168 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1168 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1169 | return; | 1169 | return; |
1170 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1170 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1171 | return; | 1171 | return; |
1172 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1172 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1173 | if ( ch < 1 ) | 1173 | if ( ch < 1 ) |
1174 | ch = 1; | 1174 | ch = 1; |
1175 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1175 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1176 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1176 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1177 | } | 1177 | } |
1178 | mCurPixWid = contentsWidth(); | 1178 | mCurPixWid = contentsWidth(); |
1179 | mCurPixHei = ch; | 1179 | mCurPixHei = ch; |
1180 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1180 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1181 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1181 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1182 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1182 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1183 | } | 1183 | } |
1184 | mPixPainter.begin( &mPaintPixmap) ; | 1184 | mPixPainter.begin( &mPaintPixmap) ; |
1185 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1185 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1186 | QPainter * p ; | 1186 | QPainter * p ; |
1187 | if (paint == 0) { | 1187 | if (paint == 0) { |
1188 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1188 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1189 | p = &mPixPainter; | 1189 | p = &mPixPainter; |
1190 | } | 1190 | } |
1191 | else | 1191 | else |
1192 | p = paint ; | 1192 | p = paint ; |
1193 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1193 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1194 | 1194 | ||
1195 | //--cx;++cw; | 1195 | //--cx;++cw; |
1196 | int lGridSpacingY = mGridSpacingY*2; | 1196 | int lGridSpacingY = mGridSpacingY*2; |
1197 | int selDay; | 1197 | int selDay; |
1198 | if ( !backgroundOnly ) | 1198 | if ( !backgroundOnly ) |
1199 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1199 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1200 | { | 1200 | { |
1201 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1201 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1202 | int x1 = cx; | 1202 | int x1 = cx; |
1203 | int y1 = 0; | 1203 | int y1 = 0; |
1204 | if (y1 < cy) y1 = cy; | 1204 | if (y1 < cy) y1 = cy; |
1205 | int x2 = cx+cw-1; | 1205 | int x2 = cx+cw-1; |
1206 | int y2 = contentsHeight(); | 1206 | int y2 = contentsHeight(); |
1207 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1207 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1208 | if (x2 >= x1 && y2 >= y1) { | 1208 | if (x2 >= x1 && y2 >= y1) { |
1209 | int gxStart = selDay; | 1209 | int gxStart = selDay; |
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index abeb068..16c19a4 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -1,372 +1,375 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1997, 1998 Preston Brown | 3 | Copyright (c) 1997, 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 <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qhbox.h> | 29 | #include <qhbox.h> |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kfiledialog.h> | 36 | #include <kfiledialog.h> |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | 39 | ||
40 | #include <libkdepim/categoryselectdialog.h> | 40 | #include <libkdepim/categoryselectdialog.h> |
41 | #include <libkcal/calendarlocal.h> | 41 | #include <libkcal/calendarlocal.h> |
42 | #include <libkcal/calendarresources.h> | 42 | #include <libkcal/calendarresources.h> |
43 | #include <libkcal/resourcecalendar.h> | 43 | #include <libkcal/resourcecalendar.h> |
44 | #include <libkcal/icalformat.h> | 44 | #include <libkcal/icalformat.h> |
45 | #include <kresources/resourceselectdialog.h> | 45 | #include <kresources/resourceselectdialog.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "kotodoeditor.h" | 49 | #include "kotodoeditor.h" |
50 | extern int globalFlagBlockAgenda; | 50 | extern int globalFlagBlockAgenda; |
51 | 51 | ||
52 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : | 52 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : |
53 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) | 53 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) |
54 | { | 54 | { |
55 | mTodo = 0; | 55 | mTodo = 0; |
56 | mRelatedTodo = 0; | 56 | mRelatedTodo = 0; |
57 | findButton(User1)->hide(); | 57 | findButton(User1)->hide(); |
58 | init(); | 58 | init(); |
59 | } | 59 | } |
60 | 60 | ||
61 | KOTodoEditor::~KOTodoEditor() | 61 | KOTodoEditor::~KOTodoEditor() |
62 | { | 62 | { |
63 | emit dialogClose( mTodo ); | 63 | emit dialogClose( mTodo ); |
64 | } | 64 | } |
65 | 65 | ||
66 | void KOTodoEditor::init() | 66 | void KOTodoEditor::init() |
67 | { | 67 | { |
68 | setupGeneral(); | 68 | setupGeneral(); |
69 | setupAttendeesTab(); | 69 | setupAttendeesTab(); |
70 | } | 70 | } |
71 | void KOTodoEditor::setCategories( QString s ) | 71 | void KOTodoEditor::setCategories( QString s ) |
72 | { | 72 | { |
73 | mGeneral->setCategories(s); | 73 | mGeneral->setCategories(s); |
74 | } | 74 | } |
75 | void KOTodoEditor::setSecrecy( int sec ) | 75 | void KOTodoEditor::setSecrecy( int sec ) |
76 | { | 76 | { |
77 | mGeneral->setSecrecy( sec ); | 77 | mGeneral->setSecrecy( sec ); |
78 | } | 78 | } |
79 | void KOTodoEditor::reload() | 79 | void KOTodoEditor::reload() |
80 | { | 80 | { |
81 | if ( mTodo ) readTodo( mTodo ); | 81 | if ( mTodo ) readTodo( mTodo ); |
82 | } | 82 | } |
83 | 83 | ||
84 | void KOTodoEditor::setupGeneral() | 84 | void KOTodoEditor::setupGeneral() |
85 | { | 85 | { |
86 | mGeneral = new KOEditorGeneralTodo(this); | 86 | mGeneral = new KOEditorGeneralTodo(this); |
87 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 87 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
88 | 88 | ||
89 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 89 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
90 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), | 90 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), |
91 | // mGeneral,SLOT(setCategories(const QString &))); | 91 | // mGeneral,SLOT(setCategories(const QString &))); |
92 | 92 | ||
93 | if (KOPrefs::instance()->mCompactDialogs) { | 93 | if (KOPrefs::instance()->mCompactDialogs) { |
94 | QFrame *topFrame = addPage(i18n("General")); | 94 | QFrame *topFrame = addPage(i18n("General")); |
95 | 95 | ||
96 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 96 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
97 | if ( QApplication::desktop()->width() < 480 ) { | 97 | if ( QApplication::desktop()->width() < 480 ) { |
98 | topLayout->setMargin(1); | 98 | topLayout->setMargin(1); |
99 | topLayout->setSpacing(1); | 99 | topLayout->setSpacing(1); |
100 | } else { | 100 | } else { |
101 | topLayout->setMargin(marginHint()-1); | 101 | topLayout->setMargin(marginHint()-1); |
102 | topLayout->setSpacing(spacingHint()-1); | 102 | topLayout->setSpacing(spacingHint()-1); |
103 | } | 103 | } |
104 | mGeneral->initHeader(topFrame,topLayout); | 104 | mGeneral->initHeader(topFrame,topLayout); |
105 | mGeneral->initTime(topFrame,topLayout); | 105 | mGeneral->initTime(topFrame,topLayout); |
106 | mGeneral->initAlarm(topFrame,topLayout); | 106 | mGeneral->initAlarm(topFrame,topLayout); |
107 | mGeneral->enableAlarm( false ); | 107 | mGeneral->enableAlarm( false ); |
108 | 108 | ||
109 | 109 | ||
110 | QBoxLayout *priorityLayout; | 110 | QBoxLayout *priorityLayout; |
111 | if ( QApplication::desktop()->width() < 500 ) | 111 | if ( QApplication::desktop()->width() < 500 ) |
112 | priorityLayout = new QVBoxLayout( topLayout ); | 112 | priorityLayout = new QVBoxLayout( topLayout ); |
113 | else | 113 | else |
114 | priorityLayout = new QHBoxLayout( topLayout ); | 114 | priorityLayout = new QHBoxLayout( topLayout ); |
115 | QWidget* prioWidget = new QWidget (topFrame); | 115 | QWidget* prioWidget = new QWidget (topFrame); |
116 | priorityLayout->addWidget( prioWidget ); | 116 | priorityLayout->addWidget( prioWidget ); |
117 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); | 117 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); |
118 | 118 | ||
119 | 119 | ||
120 | QIconSet icon; | 120 | QIconSet icon; |
121 | if ( QApplication::desktop()->width() < 321 ) | 121 | if ( QApplication::desktop()->width() < 321 ) |
122 | icon = SmallIcon("fileexport16"); | 122 | icon = SmallIcon("fileexport16"); |
123 | else | 123 | else |
124 | icon = SmallIcon("fileexport"); | 124 | icon = SmallIcon("fileexport"); |
125 | QPushButton * saveTemplate = new QPushButton( prioWidget); | 125 | QPushButton * saveTemplate = new QPushButton( prioWidget); |
126 | saveTemplate->setIconSet (icon ) ; | 126 | saveTemplate->setIconSet (icon ) ; |
127 | int size = saveTemplate->sizeHint().height(); | 127 | int size = saveTemplate->sizeHint().height(); |
128 | saveTemplate->setFixedSize( size, size ); | 128 | saveTemplate->setFixedSize( size, size ); |
129 | if ( QApplication::desktop()->width() < 321 ) | 129 | if ( QApplication::desktop()->width() < 321 ) |
130 | icon = SmallIcon("fileimport16"); | 130 | icon = SmallIcon("fileimport16"); |
131 | else | 131 | else |
132 | icon = SmallIcon("fileimport"); | 132 | icon = SmallIcon("fileimport"); |
133 | QPushButton * loadTemplate = new QPushButton( prioWidget); | 133 | QPushButton * loadTemplate = new QPushButton( prioWidget); |
134 | loadTemplate->setIconSet (icon ) ; | 134 | loadTemplate->setIconSet (icon ) ; |
135 | loadTemplate->setFixedSize( size, size ); | 135 | loadTemplate->setFixedSize( size, size ); |
136 | 136 | ||
137 | priorityLayout2->addWidget(loadTemplate); | 137 | priorityLayout2->addWidget(loadTemplate); |
138 | priorityLayout2->addWidget(saveTemplate); | 138 | priorityLayout2->addWidget(saveTemplate); |
139 | mGeneral->initPriority(prioWidget,priorityLayout2); | 139 | mGeneral->initPriority(prioWidget,priorityLayout2); |
140 | mGeneral->initCategories( topFrame, priorityLayout ); | 140 | mGeneral->initCategories( topFrame, priorityLayout ); |
141 | topLayout->addStretch(1); | 141 | topLayout->addStretch(1); |
142 | 142 | ||
143 | QFrame *topFrame2 = addPage(i18n("Details")); | 143 | QFrame *topFrame2 = addPage(i18n("Details")); |
144 | 144 | ||
145 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 145 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
146 | topLayout2->setMargin(marginHint()); | 146 | topLayout2->setMargin(marginHint()); |
147 | topLayout2->setSpacing(spacingHint()); | 147 | topLayout2->setSpacing(spacingHint()); |
148 | 148 | ||
149 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); | 149 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); |
150 | mGeneral->initCompletion(topFrame2,completionLayout); | 150 | mGeneral->initCompletion(topFrame2,completionLayout); |
151 | 151 | ||
152 | 152 | ||
153 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 153 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
154 | mGeneral->initDescription(topFrame2,topLayout2); | 154 | mGeneral->initDescription(topFrame2,topLayout2); |
155 | 155 | ||
156 | // QHBox * hb = new QHBox ( topFrame2 ); | 156 | // QHBox * hb = new QHBox ( topFrame2 ); |
157 | // topLayout2->addWidget(hb); | 157 | // topLayout2->addWidget(hb); |
158 | // hb->setSpacing( 3 ); | 158 | // hb->setSpacing( 3 ); |
159 | 159 | ||
160 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 160 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
161 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 161 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
162 | 162 | ||
163 | } else { | 163 | } else { |
164 | QFrame *topFrame = addPage(i18n("General")); | 164 | QFrame *topFrame = addPage(i18n("General")); |
165 | 165 | ||
166 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 166 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
167 | topLayout->setSpacing(spacingHint()); | 167 | topLayout->setSpacing(spacingHint()); |
168 | 168 | ||
169 | mGeneral->initHeader(topFrame,topLayout); | 169 | mGeneral->initHeader(topFrame,topLayout); |
170 | mGeneral->initTime(topFrame,topLayout); | 170 | mGeneral->initTime(topFrame,topLayout); |
171 | mGeneral->initStatus(topFrame,topLayout); | 171 | mGeneral->initStatus(topFrame,topLayout); |
172 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 172 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
173 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 173 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
174 | mGeneral->initDescription(topFrame,topLayout); | 174 | mGeneral->initDescription(topFrame,topLayout); |
175 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 175 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); |
176 | mGeneral->initCategories( topFrame, detailsLayout ); | 176 | mGeneral->initCategories( topFrame, detailsLayout ); |
177 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 177 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
178 | } | 178 | } |
179 | mGeneral->finishSetup(); | 179 | mGeneral->finishSetup(); |
180 | 180 | ||
181 | } | 181 | } |
182 | 182 | ||
183 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | 183 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) |
184 | { | 184 | { |
185 | //init(); | 185 | //init(); |
186 | 186 | ||
187 | mTodo = todo; | 187 | mTodo = todo; |
188 | readTodo(mTodo); | 188 | readTodo(mTodo); |
189 | if ( editDescription ) { | 189 | if ( editDescription ) { |
190 | showPage( 1 ); | 190 | showPage( 1 ); |
191 | mGeneral->setFocusOn( 1 ); | 191 | mGeneral->setFocusOn( 1 ); |
192 | } else { | 192 | } else { |
193 | showPage( 0 ); | 193 | showPage( 0 ); |
194 | mGeneral->setFocusOn( 2 ); | 194 | mGeneral->setFocusOn( 2 ); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 198 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
199 | { | 199 | { |
200 | //init(); | 200 | //init(); |
201 | 201 | ||
202 | mTodo = 0; | 202 | mTodo = 0; |
203 | setDefaults(due,relatedTodo,allDay); | 203 | setDefaults(due,relatedTodo,allDay); |
204 | } | 204 | } |
205 | 205 | ||
206 | void KOTodoEditor::loadDefaults() | 206 | void KOTodoEditor::loadDefaults() |
207 | { | 207 | { |
208 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 208 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
209 | } | 209 | } |
210 | 210 | ||
211 | bool KOTodoEditor::processInput( bool emitTime ) | 211 | bool KOTodoEditor::processInput( bool emitTime ) |
212 | { | 212 | { |
213 | if (!validateInput()) return false; | 213 | if (!validateInput()) return false; |
214 | 214 | ||
215 | Todo *todo = 0; | 215 | Todo *todo = 0; |
216 | 216 | ||
217 | if (mTodo) todo = mTodo; | 217 | if (mTodo) todo = mTodo; |
218 | else { | 218 | else { |
219 | todo = new Todo; | 219 | todo = new Todo; |
220 | todo->setOrganizer(KOPrefs::instance()->email()); | 220 | todo->setOrganizer(KOPrefs::instance()->email()); |
221 | } | 221 | } |
222 | 222 | ||
223 | writeTodo(todo); | 223 | writeTodo(todo); |
224 | if ( emitTime ) { | 224 | if ( emitTime ) { |
225 | globalFlagBlockAgenda = 1; | 225 | globalFlagBlockAgenda = 1; |
226 | emit showAgendaView( false ); | 226 | emit showAgendaView( false ); |
227 | if ( todo->hasDueDate() ) | 227 | if ( todo->hasDueDate() ) |
228 | emit jumpToTime( todo->dtDue().date() ); | 228 | emit jumpToTime( todo->dtDue().date() ); |
229 | globalFlagBlockAgenda = 2; | 229 | globalFlagBlockAgenda = 2; |
230 | } | 230 | } |
231 | if (mTodo) { | 231 | if (mTodo) { |
232 | todo->setRevision(todo->revision()+1); | 232 | todo->setRevision(todo->revision()+1); |
233 | emit todoChanged(todo); | 233 | emit todoChanged(todo); |
234 | } else { | 234 | } else { |
235 | mCalendar->addTodo(todo); | 235 | mCalendar->addTodo(todo); |
236 | mTodo = todo; | 236 | mTodo = todo; |
237 | emit todoAdded(todo); | 237 | emit todoAdded(todo); |
238 | } | 238 | } |
239 | 239 | ||
240 | return true; | 240 | return true; |
241 | } | 241 | } |
242 | 242 | ||
243 | void KOTodoEditor::deleteTodo() | 243 | void KOTodoEditor::deleteTodo() |
244 | { | 244 | { |
245 | if (mTodo) { | 245 | if (mTodo) { |
246 | if (KOPrefs::instance()->mConfirm) { | 246 | if (KOPrefs::instance()->mConfirm) { |
247 | switch (msgItemDelete()) { | 247 | switch (msgItemDelete()) { |
248 | case KMessageBox::Continue: // OK | 248 | case KMessageBox::Continue: // OK |
249 | emit todoToBeDeleted(mTodo); | 249 | emit todoToBeDeleted(mTodo); |
250 | emit dialogClose(mTodo); | 250 | emit dialogClose(mTodo); |
251 | mCalendar->deleteTodo(mTodo); | 251 | mCalendar->deleteTodo(mTodo); |
252 | emit todoDeleted(); | 252 | emit todoDeleted(); |
253 | reject(); | 253 | reject(); |
254 | break; | 254 | break; |
255 | } | 255 | } |
256 | } | 256 | } |
257 | else { | 257 | else { |
258 | emit todoToBeDeleted(mTodo); | 258 | emit todoToBeDeleted(mTodo); |
259 | emit dialogClose(mTodo); | 259 | emit dialogClose(mTodo); |
260 | mCalendar->deleteTodo(mTodo); | 260 | mCalendar->deleteTodo(mTodo); |
261 | emit todoDeleted(); | 261 | emit todoDeleted(); |
262 | reject(); | 262 | reject(); |
263 | } | 263 | } |
264 | } else { | 264 | } else { |
265 | reject(); | 265 | reject(); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | 269 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) |
270 | { | 270 | { |
271 | mRelatedTodo = relatedEvent; | 271 | mRelatedTodo = relatedEvent; |
272 | 272 | ||
273 | mGeneral->setDefaults(due,allDay); | 273 | mGeneral->setDefaults(due,allDay); |
274 | mDetails->setDefaults(); | 274 | mDetails->setDefaults(); |
275 | showPage( 0 ); | 275 | showPage( 0 ); |
276 | if ( mRelatedTodo ) | 276 | if ( mRelatedTodo ) { |
277 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 277 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
278 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | ||
279 | |||
280 | } | ||
278 | mGeneral->setFocusOn( 2 ); | 281 | mGeneral->setFocusOn( 2 ); |
279 | } | 282 | } |
280 | 283 | ||
281 | void KOTodoEditor::readTodo(Todo *todo) | 284 | void KOTodoEditor::readTodo(Todo *todo) |
282 | { | 285 | { |
283 | mGeneral->readTodo(todo); | 286 | mGeneral->readTodo(todo); |
284 | mDetails->readEvent(todo); | 287 | mDetails->readEvent(todo); |
285 | mRelatedTodo = 0;//todo->relatedTo(); | 288 | mRelatedTodo = 0;//todo->relatedTo(); |
286 | // categories | 289 | // categories |
287 | // mCategoryDialog->setSelected(todo->categories()); | 290 | // mCategoryDialog->setSelected(todo->categories()); |
288 | 291 | ||
289 | // We should handle read-only events here. | 292 | // We should handle read-only events here. |
290 | } | 293 | } |
291 | 294 | ||
292 | void KOTodoEditor::writeTodo(Todo *event) | 295 | void KOTodoEditor::writeTodo(Todo *event) |
293 | { | 296 | { |
294 | mGeneral->writeTodo(event); | 297 | mGeneral->writeTodo(event); |
295 | mDetails->writeEvent(event); | 298 | mDetails->writeEvent(event); |
296 | 299 | ||
297 | // set related event, i.e. parent to-do in this case. | 300 | // set related event, i.e. parent to-do in this case. |
298 | if (mRelatedTodo) { | 301 | if (mRelatedTodo) { |
299 | event->setRelatedTo(mRelatedTodo); | 302 | event->setRelatedTo(mRelatedTodo); |
300 | } | 303 | } |
301 | } | 304 | } |
302 | 305 | ||
303 | bool KOTodoEditor::validateInput() | 306 | bool KOTodoEditor::validateInput() |
304 | { | 307 | { |
305 | if (!mGeneral->validateInput()) return false; | 308 | if (!mGeneral->validateInput()) return false; |
306 | if (!mDetails->validateInput()) return false; | 309 | if (!mDetails->validateInput()) return false; |
307 | return true; | 310 | return true; |
308 | } | 311 | } |
309 | 312 | ||
310 | int KOTodoEditor::msgItemDelete() | 313 | int KOTodoEditor::msgItemDelete() |
311 | { | 314 | { |
312 | return KMessageBox::warningContinueCancel(this, | 315 | return KMessageBox::warningContinueCancel(this, |
313 | i18n("This item will be permanently deleted."), | 316 | i18n("This item will be permanently deleted."), |
314 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 317 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
315 | } | 318 | } |
316 | 319 | ||
317 | void KOTodoEditor::modified (int modification) | 320 | void KOTodoEditor::modified (int modification) |
318 | { | 321 | { |
319 | if (modification == KOGlobals::CATEGORY_MODIFIED || | 322 | if (modification == KOGlobals::CATEGORY_MODIFIED || |
320 | KOGlobals::UNKNOWN_MODIFIED == modification ) | 323 | KOGlobals::UNKNOWN_MODIFIED == modification ) |
321 | // mCategoryDialog->setSelected (mTodo->categories ()); | 324 | // mCategoryDialog->setSelected (mTodo->categories ()); |
322 | mGeneral->modified (mTodo, modification); | 325 | mGeneral->modified (mTodo, modification); |
323 | 326 | ||
324 | } | 327 | } |
325 | 328 | ||
326 | void KOTodoEditor::slotLoadTemplate() | 329 | void KOTodoEditor::slotLoadTemplate() |
327 | { | 330 | { |
328 | 331 | ||
329 | QString fileName =locateLocal( "templates", "todos" ); | 332 | QString fileName =locateLocal( "templates", "todos" ); |
330 | QDir t_dir; | 333 | QDir t_dir; |
331 | if ( !t_dir.exists(fileName) ) | 334 | if ( !t_dir.exists(fileName) ) |
332 | t_dir.mkdir ( fileName ); | 335 | t_dir.mkdir ( fileName ); |
333 | fileName += "/todo"; | 336 | fileName += "/todo"; |
334 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); | 337 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); |
335 | if ( fileName.length() == 0 ) | 338 | if ( fileName.length() == 0 ) |
336 | return; | 339 | return; |
337 | CalendarLocal cal; | 340 | CalendarLocal cal; |
338 | ICalFormat format; | 341 | ICalFormat format; |
339 | if ( !format.load( &cal, fileName ) ) { | 342 | if ( !format.load( &cal, fileName ) ) { |
340 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 343 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
341 | .arg( fileName ) ); | 344 | .arg( fileName ) ); |
342 | return ; | 345 | return ; |
343 | } | 346 | } |
344 | QPtrList<Todo> todos = cal.todos(); | 347 | QPtrList<Todo> todos = cal.todos(); |
345 | Todo * todo = todos.first(); | 348 | Todo * todo = todos.first(); |
346 | if ( !todo ) { | 349 | if ( !todo ) { |
347 | KMessageBox::error( this, | 350 | KMessageBox::error( this, |
348 | i18n("Template does not\ncontain a valid Todo.")); | 351 | i18n("Template does not\ncontain a valid Todo.")); |
349 | } else { | 352 | } else { |
350 | readTodo( todo ); | 353 | readTodo( todo ); |
351 | } | 354 | } |
352 | 355 | ||
353 | } | 356 | } |
354 | 357 | ||
355 | void KOTodoEditor::slotSaveTemplate() | 358 | void KOTodoEditor::slotSaveTemplate() |
356 | { | 359 | { |
357 | QString fileName =locateLocal( "templates", "todos" ); | 360 | QString fileName =locateLocal( "templates", "todos" ); |
358 | QDir t_dir; | 361 | QDir t_dir; |
359 | if ( !t_dir.exists(fileName) ) | 362 | if ( !t_dir.exists(fileName) ) |
360 | t_dir.mkdir ( fileName ); | 363 | t_dir.mkdir ( fileName ); |
361 | fileName += "/todo"; | 364 | fileName += "/todo"; |
362 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); | 365 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); |
363 | if ( fileName.length() > 0 ) | 366 | if ( fileName.length() > 0 ) |
364 | saveTemplate( fileName ); | 367 | saveTemplate( fileName ); |
365 | } | 368 | } |
366 | 369 | ||
367 | void KOTodoEditor::saveTemplate( const QString &templateName ) | 370 | void KOTodoEditor::saveTemplate( const QString &templateName ) |
368 | { | 371 | { |
369 | Todo *todo = new Todo; | 372 | Todo *todo = new Todo; |
370 | writeTodo( todo ); | 373 | writeTodo( todo ); |
371 | saveAsTemplate( todo, templateName ); | 374 | saveAsTemplate( todo, templateName ); |
372 | } | 375 | } |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 30adb06..22486ba 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1152 +1,1212 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | 27 | ||
28 | #include <qvbox.h> | 28 | #include <qvbox.h> |
29 | #include <kdebug.h> | 29 | #include <kdebug.h> |
30 | #include "koprefs.h" | 30 | #include "koprefs.h" |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/vcaldrag.h> | 37 | #include <libkcal/vcaldrag.h> |
38 | #include <libkcal/calfilter.h> | 38 | #include <libkcal/calfilter.h> |
39 | #include <libkcal/dndfactory.h> | 39 | #include <libkcal/dndfactory.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | #include <kresources/resourceselectdialog.h> | 42 | #include <kresources/resourceselectdialog.h> |
43 | #ifndef DESKTOP_VERSION | 43 | #ifndef DESKTOP_VERSION |
44 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
45 | #else | 45 | #else |
46 | #include <qapplication.h> | 46 | #include <qapplication.h> |
47 | #endif | 47 | #endif |
48 | #ifndef KORG_NOPRINTER | 48 | #ifndef KORG_NOPRINTER |
49 | #include "calprinter.h" | 49 | #include "calprinter.h" |
50 | #endif | 50 | #endif |
51 | #include "docprefs.h" | 51 | #include "docprefs.h" |
52 | 52 | ||
53 | #include "kotodoview.h" | 53 | #include "kotodoview.h" |
54 | using namespace KOrg; | 54 | using namespace KOrg; |
55 | 55 | ||
56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
57 | const char *name) : | 57 | const char *name) : |
58 | KListView(parent,name) | 58 | KListView(parent,name) |
59 | { | 59 | { |
60 | mName = QString ( name ); | 60 | mName = QString ( name ); |
61 | mCalendar = calendar; | 61 | mCalendar = calendar; |
62 | #ifndef DESKTOP_VERSION | 62 | #ifndef DESKTOP_VERSION |
63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
64 | #endif | 64 | #endif |
65 | mOldCurrent = 0; | 65 | mOldCurrent = 0; |
66 | mMousePressed = false; | 66 | mMousePressed = false; |
67 | 67 | ||
68 | setAcceptDrops(true); | 68 | setAcceptDrops(true); |
69 | viewport()->setAcceptDrops(true); | 69 | viewport()->setAcceptDrops(true); |
70 | int size = 16; | 70 | int size = 16; |
71 | if (qApp->desktop()->width() < 300 ) | 71 | if (qApp->desktop()->width() < 300 ) |
72 | size = 12; | 72 | size = 12; |
73 | setTreeStepSize( size + 6 ); | 73 | setTreeStepSize( size + 6 ); |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
78 | { | 78 | { |
79 | #ifndef KORG_NODND | 79 | #ifndef KORG_NODND |
80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
82 | !QTextDrag::canDecode( e ) ) { | 82 | !QTextDrag::canDecode( e ) ) { |
83 | e->ignore(); | 83 | e->ignore(); |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | 86 | ||
87 | mOldCurrent = currentItem(); | 87 | mOldCurrent = currentItem(); |
88 | #endif | 88 | #endif |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
93 | { | 93 | { |
94 | #ifndef KORG_NODND | 94 | #ifndef KORG_NODND |
95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
96 | 96 | ||
97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
98 | !QTextDrag::canDecode( e ) ) { | 98 | !QTextDrag::canDecode( e ) ) { |
99 | e->ignore(); | 99 | e->ignore(); |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | 102 | ||
103 | e->accept(); | 103 | e->accept(); |
104 | #endif | 104 | #endif |
105 | } | 105 | } |
106 | 106 | ||
107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
108 | { | 108 | { |
109 | #ifndef KORG_NODND | 109 | #ifndef KORG_NODND |
110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
111 | 111 | ||
112 | setCurrentItem(mOldCurrent); | 112 | setCurrentItem(mOldCurrent); |
113 | setSelected(mOldCurrent,true); | 113 | setSelected(mOldCurrent,true); |
114 | #endif | 114 | #endif |
115 | } | 115 | } |
116 | 116 | ||
117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
118 | { | 118 | { |
119 | #ifndef KORG_NODND | 119 | #ifndef KORG_NODND |
120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
121 | 121 | ||
122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
123 | !QTextDrag::canDecode( e ) ) { | 123 | !QTextDrag::canDecode( e ) ) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | 127 | ||
128 | DndFactory factory( mCalendar ); | 128 | DndFactory factory( mCalendar ); |
129 | Todo *todo = factory.createDropTodo(e); | 129 | Todo *todo = factory.createDropTodo(e); |
130 | 130 | ||
131 | if (todo) { | 131 | if (todo) { |
132 | e->acceptAction(); | 132 | e->acceptAction(); |
133 | 133 | ||
134 | KOTodoViewItem *destination = | 134 | KOTodoViewItem *destination = |
135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
136 | Todo *destinationEvent = 0; | 136 | Todo *destinationEvent = 0; |
137 | if (destination) destinationEvent = destination->todo(); | 137 | if (destination) destinationEvent = destination->todo(); |
138 | 138 | ||
139 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 139 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
140 | 140 | ||
141 | if(existingTodo) { | 141 | if(existingTodo) { |
142 | // kdDebug() << "Drop existing Todo" << endl; | 142 | // kdDebug() << "Drop existing Todo" << endl; |
143 | Incidence *to = destinationEvent; | 143 | Incidence *to = destinationEvent; |
144 | while(to) { | 144 | while(to) { |
145 | if (to->uid() == todo->uid()) { | 145 | if (to->uid() == todo->uid()) { |
146 | KMessageBox::sorry(this, | 146 | KMessageBox::sorry(this, |
147 | i18n("Cannot move To-Do to itself or a child of itself"), | 147 | i18n("Cannot move To-Do to itself or a child of itself"), |
148 | i18n("Drop To-Do")); | 148 | i18n("Drop To-Do")); |
149 | delete todo; | 149 | delete todo; |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | to = to->relatedTo(); | 152 | to = to->relatedTo(); |
153 | } | 153 | } |
154 | existingTodo->setRelatedTo(destinationEvent); | 154 | existingTodo->setRelatedTo(destinationEvent); |
155 | emit todoDropped(todo); | 155 | emit todoDropped(todo); |
156 | delete todo; | 156 | delete todo; |
157 | } else { | 157 | } else { |
158 | // kdDebug() << "Drop new Todo" << endl; | 158 | // kdDebug() << "Drop new Todo" << endl; |
159 | todo->setRelatedTo(destinationEvent); | 159 | todo->setRelatedTo(destinationEvent); |
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | 161 | ||
162 | emit todoDropped(todo); | 162 | emit todoDropped(todo); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | else { | 165 | else { |
166 | QString text; | 166 | QString text; |
167 | if (QTextDrag::decode(e,text)) { | 167 | if (QTextDrag::decode(e,text)) { |
168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
170 | kdDebug() << "Dropped : " << text << endl; | 170 | kdDebug() << "Dropped : " << text << endl; |
171 | QStringList emails = QStringList::split(",",text); | 171 | QStringList emails = QStringList::split(",",text); |
172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
173 | kdDebug() << " Email: " << (*it) << endl; | 173 | kdDebug() << " Email: " << (*it) << endl; |
174 | int pos = (*it).find("<"); | 174 | int pos = (*it).find("<"); |
175 | QString name = (*it).left(pos); | 175 | QString name = (*it).left(pos); |
176 | QString email = (*it).mid(pos); | 176 | QString email = (*it).mid(pos); |
177 | if (!email.isEmpty() && todoi) { | 177 | if (!email.isEmpty() && todoi) { |
178 | todoi->todo()->addAttendee(new Attendee(name,email)); | 178 | todoi->todo()->addAttendee(new Attendee(name,email)); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | else { | 182 | else { |
183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; | 183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; |
184 | e->ignore(); | 184 | e->ignore(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | #endif | 187 | #endif |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
191 | { | 191 | { |
192 | QListView::contentsMousePressEvent(e); | 192 | QListView::contentsMousePressEvent(e); |
193 | #ifndef KORG_NODND | 193 | #ifndef KORG_NODND |
194 | QPoint p(contentsToViewport(e->pos())); | 194 | QPoint p(contentsToViewport(e->pos())); |
195 | QListViewItem *i = itemAt(p); | 195 | QListViewItem *i = itemAt(p); |
196 | if (i) { | 196 | if (i) { |
197 | // if the user clicked into the root decoration of the item, don't | 197 | // if the user clicked into the root decoration of the item, don't |
198 | // try to start a drag! | 198 | // try to start a drag! |
199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | 199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + |
200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
201 | itemMargin() || | 201 | itemMargin() || |
202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
203 | if (e->button()==Qt::LeftButton) { | 203 | if (e->button()==Qt::LeftButton) { |
204 | mPressPos = e->pos(); | 204 | mPressPos = e->pos(); |
205 | mMousePressed = true; | 205 | mMousePressed = true; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #endif | 209 | #endif |
210 | } | 210 | } |
211 | 211 | ||
212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
213 | { | 213 | { |
214 | 214 | ||
215 | #ifndef KORG_NODND | 215 | #ifndef KORG_NODND |
216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; | 216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; |
217 | QListView::contentsMouseMoveEvent(e); | 217 | QListView::contentsMouseMoveEvent(e); |
218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
219 | QApplication::startDragDistance()) { | 219 | QApplication::startDragDistance()) { |
220 | mMousePressed = false; | 220 | mMousePressed = false; |
221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
222 | if (item) { | 222 | if (item) { |
223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; | 223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; |
224 | DndFactory factory( mCalendar ); | 224 | DndFactory factory( mCalendar ); |
225 | ICalDrag *vd = factory.createDragTodo( | 225 | ICalDrag *vd = factory.createDragTodo( |
226 | ((KOTodoViewItem *)item)->todo(),viewport()); | 226 | ((KOTodoViewItem *)item)->todo(),viewport()); |
227 | if (vd->drag()) { | 227 | if (vd->drag()) { |
228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; | 228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; |
229 | } | 229 | } |
230 | /* | 230 | /* |
231 | QString source = fullPath(item); | 231 | QString source = fullPath(item); |
232 | if ( QFile::exists(source) ) { | 232 | if ( QFile::exists(source) ) { |
233 | QUriDrag* ud = new QUriDrag(viewport()); | 233 | QUriDrag* ud = new QUriDrag(viewport()); |
234 | ud->setFilenames( source ); | 234 | ud->setFilenames( source ); |
235 | if ( ud->drag() ) | 235 | if ( ud->drag() ) |
236 | QMessageBox::information( this, "Drag source", | 236 | QMessageBox::information( this, "Drag source", |
237 | QString("Delete ")+source, "Not implemented" ); | 237 | QString("Delete ")+source, "Not implemented" ); |
238 | */ | 238 | */ |
239 | } | 239 | } |
240 | } | 240 | } |
241 | #endif | 241 | #endif |
242 | } | 242 | } |
243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
244 | { | 244 | { |
245 | 245 | ||
246 | QListViewItem* cn; | 246 | QListViewItem* cn; |
247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
248 | cn = currentItem(); | 248 | cn = currentItem(); |
249 | if ( cn ) { | 249 | if ( cn ) { |
250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
251 | if ( ci ){ | 251 | if ( ci ){ |
252 | if ( e->state() == ShiftButton ) | 252 | if ( e->state() == ShiftButton ) |
253 | ci->setOn( false ); | 253 | ci->setOn( false ); |
254 | else | 254 | else |
255 | ci->setOn( true ); | 255 | ci->setOn( true ); |
256 | cn = cn->nextSibling(); | 256 | cn = cn->nextSibling(); |
257 | if ( cn ) { | 257 | if ( cn ) { |
258 | setCurrentItem ( cn ); | 258 | setCurrentItem ( cn ); |
259 | ensureItemVisible ( cn ); | 259 | ensureItemVisible ( cn ); |
260 | } | 260 | } |
261 | 261 | ||
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | // qDebug("KOTodoListView::keyPressEvent "); | 268 | // qDebug("KOTodoListView::keyPressEvent "); |
269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
270 | switch ( e->key() ) { | 270 | switch ( e->key() ) { |
271 | case Qt::Key_Down: | 271 | case Qt::Key_Down: |
272 | case Qt::Key_Up: | 272 | case Qt::Key_Up: |
273 | QListView::keyPressEvent ( e ); | 273 | QListView::keyPressEvent ( e ); |
274 | break; | 274 | break; |
275 | case Qt::Key_Left: | 275 | case Qt::Key_Left: |
276 | case Qt::Key_Right: | 276 | case Qt::Key_Right: |
277 | QListView::keyPressEvent ( e ); | 277 | QListView::keyPressEvent ( e ); |
278 | e->accept(); | 278 | e->accept(); |
279 | return; | 279 | return; |
280 | break; | 280 | break; |
281 | default: | 281 | default: |
282 | e->ignore(); | 282 | e->ignore(); |
283 | break; | 283 | break; |
284 | } | 284 | } |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | e->ignore(); | 287 | e->ignore(); |
288 | } | 288 | } |
289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
290 | { | 290 | { |
291 | QListView::contentsMouseReleaseEvent(e); | 291 | QListView::contentsMouseReleaseEvent(e); |
292 | mMousePressed = false; | 292 | mMousePressed = false; |
293 | } | 293 | } |
294 | 294 | ||
295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
296 | { | 296 | { |
297 | if (!e) return; | 297 | if (!e) return; |
298 | 298 | ||
299 | QPoint vp = contentsToViewport(e->pos()); | 299 | QPoint vp = contentsToViewport(e->pos()); |
300 | 300 | ||
301 | QListViewItem *item = itemAt(vp); | 301 | QListViewItem *item = itemAt(vp); |
302 | 302 | ||
303 | emit double_Clicked(item); | 303 | emit double_Clicked(item); |
304 | if (!item) return; | 304 | if (!item) return; |
305 | 305 | ||
306 | emit doubleClicked(item,vp,0); | 306 | emit doubleClicked(item,vp,0); |
307 | } | 307 | } |
308 | 308 | ||
309 | ///////////////////////////////////////////////////////////////////////////// | 309 | ///////////////////////////////////////////////////////////////////////////// |
310 | 310 | ||
311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
312 | QLineEdit(parent) | 312 | QLineEdit(parent) |
313 | { | 313 | { |
314 | setText(i18n("Click to add a new Todo")); | 314 | setText(i18n("Click to add a new Todo")); |
315 | } | 315 | } |
316 | 316 | ||
317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
318 | { | 318 | { |
319 | if ( text()==i18n("Click to add a new Todo") ) | 319 | if ( text()==i18n("Click to add a new Todo") ) |
320 | setText(""); | 320 | setText(""); |
321 | QLineEdit::focusInEvent(ev); | 321 | QLineEdit::focusInEvent(ev); |
322 | } | 322 | } |
323 | 323 | ||
324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
325 | { | 325 | { |
326 | setText(i18n("Click to add a new Todo")); | 326 | setText(i18n("Click to add a new Todo")); |
327 | QLineEdit::focusOutEvent(ev); | 327 | QLineEdit::focusOutEvent(ev); |
328 | } | 328 | } |
329 | 329 | ||
330 | ///////////////////////////////////////////////////////////////////////////// | 330 | ///////////////////////////////////////////////////////////////////////////// |
331 | 331 | ||
332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
333 | KOrg::BaseView(calendar,parent,name) | 333 | KOrg::BaseView(calendar,parent,name) |
334 | { | 334 | { |
335 | mNavigator = 0; | 335 | mNavigator = 0; |
336 | QBoxLayout *topLayout = new QVBoxLayout(this); | 336 | QBoxLayout *topLayout = new QVBoxLayout(this); |
337 | mName = QString ( name ); | 337 | mName = QString ( name ); |
338 | mBlockUpdate = false; | 338 | mBlockUpdate = false; |
339 | mQuickAdd = new KOQuickTodo(this); | 339 | mQuickAdd = new KOQuickTodo(this); |
340 | topLayout->addWidget(mQuickAdd); | 340 | topLayout->addWidget(mQuickAdd); |
341 | 341 | ||
342 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 342 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
343 | 343 | ||
344 | mTodoListView = new KOTodoListView(calendar,this, name ); | 344 | mTodoListView = new KOTodoListView(calendar,this, name ); |
345 | topLayout->addWidget(mTodoListView); | 345 | topLayout->addWidget(mTodoListView); |
346 | //mTodoListView->header()->setMaximumHeight(30); | 346 | //mTodoListView->header()->setMaximumHeight(30); |
347 | mTodoListView->setRootIsDecorated(true); | 347 | mTodoListView->setRootIsDecorated(true); |
348 | mTodoListView->setAllColumnsShowFocus(true); | 348 | mTodoListView->setAllColumnsShowFocus(true); |
349 | 349 | ||
350 | mTodoListView->setShowSortIndicator(true); | 350 | mTodoListView->setShowSortIndicator(true); |
351 | 351 | ||
352 | mTodoListView->addColumn(i18n("Todo")); | 352 | mTodoListView->addColumn(i18n("Todo")); |
353 | mTodoListView->addColumn(i18n("Prio")); | 353 | mTodoListView->addColumn(i18n("Prio")); |
354 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 354 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
355 | mTodoListView->addColumn(i18n("Complete")); | 355 | mTodoListView->addColumn(i18n("Complete")); |
356 | mTodoListView->setColumnAlignment(2,AlignCenter); | 356 | mTodoListView->setColumnAlignment(2,AlignCenter); |
357 | 357 | ||
358 | mTodoListView->addColumn(i18n("Due Date")); | 358 | mTodoListView->addColumn(i18n("Due Date")); |
359 | mTodoListView->setColumnAlignment(3,AlignLeft); | 359 | mTodoListView->setColumnAlignment(3,AlignLeft); |
360 | mTodoListView->addColumn(i18n("Due Time")); | 360 | mTodoListView->addColumn(i18n("Due Time")); |
361 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 361 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
362 | 362 | ||
363 | mTodoListView->addColumn(i18n("Start Date")); | 363 | mTodoListView->addColumn(i18n("Start Date")); |
364 | mTodoListView->setColumnAlignment(5,AlignLeft); | 364 | mTodoListView->setColumnAlignment(5,AlignLeft); |
365 | mTodoListView->addColumn(i18n("Start Time")); | 365 | mTodoListView->addColumn(i18n("Start Time")); |
366 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 366 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
367 | 367 | ||
368 | mTodoListView->addColumn(i18n("Cancelled")); | 368 | mTodoListView->addColumn(i18n("Cancelled")); |
369 | mTodoListView->addColumn(i18n("Categories")); | 369 | mTodoListView->addColumn(i18n("Categories")); |
370 | #if 0 | 370 | #if 0 |
371 | mTodoListView->addColumn(i18n("Sort Id")); | 371 | mTodoListView->addColumn(i18n("Sort Id")); |
372 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 372 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
373 | #endif | 373 | #endif |
374 | 374 | ||
375 | mTodoListView->setMinimumHeight( 60 ); | 375 | mTodoListView->setMinimumHeight( 60 ); |
376 | mTodoListView->setItemsRenameable( true ); | 376 | mTodoListView->setItemsRenameable( true ); |
377 | mTodoListView->setRenameable( 0 ); | 377 | mTodoListView->setRenameable( 0 ); |
378 | mTodoListView->setColumnWidth( 0, 120 ); | 378 | mTodoListView->setColumnWidth( 0, 120 ); |
379 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 379 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
380 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 380 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
381 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 381 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
382 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 382 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
383 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 383 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
384 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 384 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
385 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 385 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
386 | mTodoListView->setColumnWidthMode(7, QListView::Manual); | 386 | mTodoListView->setColumnWidthMode(7, QListView::Manual); |
387 | mTodoListView->setColumnWidthMode(8, QListView::Manual); | 387 | mTodoListView->setColumnWidthMode(8, QListView::Manual); |
388 | 388 | ||
389 | 389 | ||
390 | mPriorityPopupMenu = new QPopupMenu(this); | 390 | mPriorityPopupMenu = new QPopupMenu(this); |
391 | for (int i = 1; i <= 5; i++) { | 391 | for (int i = 1; i <= 5; i++) { |
392 | QString label = QString ("%1").arg (i); | 392 | QString label = QString ("%1").arg (i); |
393 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 393 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
394 | } | 394 | } |
395 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 395 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
396 | 396 | ||
397 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 397 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
398 | for (int i = 0; i <= 100; i+=20) { | 398 | for (int i = 0; i <= 100; i+=20) { |
399 | QString label = QString ("%1 %").arg (i); | 399 | QString label = QString ("%1 %").arg (i); |
400 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 400 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
401 | } | 401 | } |
402 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 402 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
403 | 403 | ||
404 | 404 | ||
405 | 405 | ||
406 | mItemPopupMenu = new QPopupMenu(this); | 406 | mItemPopupMenu = new QPopupMenu(this); |
407 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 407 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
408 | SLOT (showTodo())); | 408 | SLOT (showTodo())); |
409 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 409 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
410 | SLOT (editTodo())); | 410 | SLOT (editTodo())); |
411 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 411 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
412 | SLOT (deleteTodo())); | 412 | SLOT (deleteTodo())); |
413 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 413 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
414 | SLOT (cloneTodo())); | 414 | SLOT (cloneTodo())); |
415 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 415 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
416 | SLOT (moveTodo())); | 416 | SLOT (moveTodo())); |
417 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 417 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
418 | SLOT (beamTodo())); | 418 | SLOT (beamTodo())); |
419 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 419 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
420 | SLOT (cancelTodo())); | 420 | SLOT (cancelTodo())); |
421 | mItemPopupMenu->insertSeparator(); | 421 | mItemPopupMenu->insertSeparator(); |
422 | 422 | ||
423 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 423 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
424 | SLOT (newTodo())); | 424 | SLOT (newTodo())); |
425 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 425 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
426 | SLOT (newSubTodo())); | 426 | SLOT (newSubTodo())); |
427 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 427 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
428 | SLOT (unparentTodo()),0,21); | 428 | SLOT (unparentTodo()),0,21); |
429 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 429 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
430 | SLOT (reparentTodo()),0,22); | 430 | SLOT (reparentTodo()),0,22); |
431 | mItemPopupMenu->insertSeparator(); | 431 | mItemPopupMenu->insertSeparator(); |
432 | #if 0 | ||
432 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 433 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
433 | this, SLOT( purgeCompleted() ) ); | 434 | this, SLOT( purgeCompleted() ) ); |
434 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 435 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
435 | this, SLOT( toggleCompleted() ),0, 33 ); | 436 | this, SLOT( toggleCompleted() ),0, 33 ); |
436 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 437 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
437 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 438 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
438 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 439 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
439 | this, SLOT( toggleRunning() ),0, 35 ); | 440 | this, SLOT( toggleRunning() ),0, 35 ); |
440 | 441 | ||
442 | #endif | ||
441 | mPopupMenu = new QPopupMenu(this); | 443 | mPopupMenu = new QPopupMenu(this); |
442 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 444 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
443 | SLOT (newTodo()),0,1); | 445 | SLOT (newTodo()),0,1); |
444 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 446 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
445 | this, SLOT(purgeCompleted()),0,2); | 447 | this, SLOT(purgeCompleted()),0,2); |
446 | mPopupMenu->insertItem(i18n("Show Completed"), | 448 | mPopupMenu->insertItem(i18n("Show Completed"), |
447 | this, SLOT( toggleCompleted() ),0,3 ); | 449 | this, SLOT( toggleCompleted() ),0,3 ); |
448 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 450 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
449 | this, SLOT( toggleQuickTodo() ),0,4 ); | 451 | this, SLOT( toggleQuickTodo() ),0,4 ); |
450 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 452 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
451 | this, SLOT( toggleRunning() ),0,5 ); | 453 | this, SLOT( toggleRunning() ),0,5 ); |
454 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | ||
455 | this, SLOT( setAllOpen() ),0,6 ); | ||
456 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | ||
457 | this, SLOT( setAllClose() ),0,7 ); | ||
458 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | ||
459 | this, SLOT( setAllFlat() ),0,8 ); | ||
452 | mDocPrefs = new DocPrefs( name ); | 460 | mDocPrefs = new DocPrefs( name ); |
453 | 461 | ||
462 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | ||
454 | mPopupMenu->setCheckable( true ); | 463 | mPopupMenu->setCheckable( true ); |
455 | mItemPopupMenu->setCheckable( true ); | 464 | mItemPopupMenu->setCheckable( true ); |
456 | 465 | ||
457 | 466 | ||
458 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 467 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
459 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 468 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
460 | 469 | ||
461 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 470 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
462 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 471 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
463 | 472 | ||
464 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 473 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
465 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 474 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
466 | 475 | ||
467 | 476 | ||
468 | // Double clicking conflicts with opening/closing the subtree | 477 | // Double clicking conflicts with opening/closing the subtree |
469 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 478 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
470 | SLOT( editItem( QListViewItem *) ) ); | 479 | SLOT( editItem( QListViewItem *) ) ); |
471 | /* | 480 | /* |
472 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 481 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
473 | const QPoint &,int ) ), | 482 | const QPoint &,int ) ), |
474 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 483 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
475 | */ | 484 | */ |
476 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 485 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
477 | const QPoint &,int ) ), | 486 | const QPoint &,int ) ), |
478 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 487 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
479 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 488 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
480 | SLOT( itemClicked( QListViewItem * ) ) ); | 489 | SLOT( itemClicked( QListViewItem * ) ) ); |
481 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 490 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
482 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 491 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
483 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), | 492 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), |
484 | SLOT( updateView() ) ); | 493 | SLOT( updateView() ) ); |
485 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 494 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
486 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 495 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
487 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 496 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
488 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 497 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
489 | 498 | ||
490 | #if 0 | 499 | #if 0 |
491 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 500 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
492 | SLOT(selectionChanged(QListViewItem *))); | 501 | SLOT(selectionChanged(QListViewItem *))); |
493 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 502 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
494 | SLOT(selectionChanged(QListViewItem *))); | 503 | SLOT(selectionChanged(QListViewItem *))); |
495 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 504 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
496 | SLOT(selectionChanged(QListViewItem *))); | 505 | SLOT(selectionChanged(QListViewItem *))); |
497 | #endif | 506 | #endif |
498 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 507 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
499 | SLOT( processSelectionChange() ) ); | 508 | SLOT( processSelectionChange() ) ); |
500 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 509 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
501 | SLOT( addQuickTodo() ) ); | 510 | SLOT( addQuickTodo() ) ); |
502 | 511 | ||
503 | } | 512 | } |
504 | 513 | ||
505 | KOTodoView::~KOTodoView() | 514 | KOTodoView::~KOTodoView() |
506 | { | 515 | { |
507 | delete mDocPrefs; | 516 | delete mDocPrefs; |
508 | } | 517 | } |
509 | 518 | ||
510 | void KOTodoView::jumpToDate () | 519 | void KOTodoView::jumpToDate () |
511 | { | 520 | { |
512 | // if (mActiveItem) { | 521 | // if (mActiveItem) { |
513 | // mActiveItem->todo()); | 522 | // mActiveItem->todo()); |
514 | // if ( mActiveItem->todo()->hasDueDate() ) | 523 | // if ( mActiveItem->todo()->hasDueDate() ) |
515 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 524 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
516 | } | 525 | } |
517 | 526 | ||
518 | void KOTodoView::updateView() | 527 | void KOTodoView::updateView() |
519 | { | 528 | { |
520 | pendingSubtodo = 0; | 529 | pendingSubtodo = 0; |
521 | if ( mBlockUpdate ) { | 530 | if ( mBlockUpdate ) { |
522 | //qDebug("blocked "); | 531 | //qDebug("blocked "); |
523 | return; | 532 | return; |
524 | } | 533 | } |
534 | if ( isFlatDisplay ) { | ||
535 | setAllFlat(); | ||
536 | return; | ||
537 | } | ||
525 | //qDebug("update "); | 538 | //qDebug("update "); |
526 | // kdDebug() << "KOTodoView::updateView()" << endl; | 539 | // kdDebug() << "KOTodoView::updateView()" << endl; |
527 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 540 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
528 | mTodoListView->clear(); | 541 | mTodoListView->clear(); |
529 | if ( mName == "todolistsmall" ) { | 542 | if ( mName == "todolistsmall" ) { |
530 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 543 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
531 | int ps = fo.pointSize() -2; | 544 | int ps = fo.pointSize() -2; |
532 | if ( ps > 12 ) | 545 | if ( ps > 12 ) |
533 | ps -= 2; | 546 | ps -= 2; |
534 | fo.setPointSize( ps ); | 547 | fo.setPointSize( ps ); |
535 | } | 548 | } |
536 | } | 549 | } |
537 | 550 | ||
538 | mTodoListView->setFont( fo ); | 551 | mTodoListView->setFont( fo ); |
539 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 552 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
540 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 553 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
541 | QPtrList<Todo> todoList = calendar()->todos(); | 554 | QPtrList<Todo> todoList = calendar()->todos(); |
542 | 555 | ||
543 | /* | 556 | /* |
544 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 557 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
545 | Event *t; | 558 | Event *t; |
546 | for(t = todoList.first(); t; t = todoList.next()) { | 559 | for(t = todoList.first(); t; t = todoList.next()) { |
547 | kdDebug() << " " << t->getSummary() << endl; | 560 | kdDebug() << " " << t->getSummary() << endl; |
548 | 561 | ||
549 | if (t->getRelatedTo()) { | 562 | if (t->getRelatedTo()) { |
550 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 563 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
551 | } | 564 | } |
552 | 565 | ||
553 | QPtrList<Event> l = t->getRelations(); | 566 | QPtrList<Event> l = t->getRelations(); |
554 | Event *c; | 567 | Event *c; |
555 | for(c=l.first();c;c=l.next()) { | 568 | for(c=l.first();c;c=l.next()) { |
556 | kdDebug() << " - relation: " << c->getSummary() << endl; | 569 | kdDebug() << " - relation: " << c->getSummary() << endl; |
557 | } | 570 | } |
558 | } | 571 | } |
559 | */ | 572 | */ |
560 | 573 | ||
561 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 574 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
562 | // specific order of events. That means that we have to generate parent items | 575 | // specific order of events. That means that we have to generate parent items |
563 | // recursively for proper hierarchical display of Todos. | 576 | // recursively for proper hierarchical display of Todos. |
564 | mTodoMap.clear(); | 577 | mTodoMap.clear(); |
565 | Todo *todo; | 578 | Todo *todo; |
566 | todo = todoList.first();// todo; todo = todoList.next()) { | 579 | todo = todoList.first();// todo; todo = todoList.next()) { |
567 | while ( todo ) { | 580 | while ( todo ) { |
568 | bool next = true; | 581 | bool next = true; |
569 | // qDebug("todo %s ", todo->summary().latin1()); | 582 | // qDebug("todo %s ", todo->summary().latin1()); |
570 | Incidence *incidence = todo->relatedTo(); | 583 | Incidence *incidence = todo->relatedTo(); |
571 | while ( incidence ) { | 584 | while ( incidence ) { |
572 | if ( incidence->type() == "Todo") { | 585 | if ( incidence->type() == "Todo") { |
573 | //qDebug("related %s ",incidence->summary().latin1() ); | 586 | //qDebug("related %s ",incidence->summary().latin1() ); |
574 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 587 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
575 | //qDebug("related not found "); | 588 | //qDebug("related not found "); |
576 | todoList.remove( ); | 589 | todoList.remove( ); |
577 | todo = todoList.current(); | 590 | todo = todoList.current(); |
578 | next = false; | 591 | next = false; |
579 | incidence = 0; | 592 | incidence = 0; |
580 | 593 | ||
581 | } else { | 594 | } else { |
582 | //qDebug("related found "); | 595 | //qDebug("related found "); |
583 | incidence = incidence->relatedTo(); | 596 | incidence = incidence->relatedTo(); |
584 | } | 597 | } |
585 | } else | 598 | } else |
586 | incidence = 0; | 599 | incidence = 0; |
587 | } | 600 | } |
588 | if ( next ) | 601 | if ( next ) |
589 | todo = todoList.next(); | 602 | todo = todoList.next(); |
590 | } | 603 | } |
591 | // qDebug("again .... "); | 604 | // qDebug("again .... "); |
592 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 605 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
593 | 606 | ||
594 | // qDebug("yytodo %s ", todo->summary().latin1()); | 607 | // qDebug("yytodo %s ", todo->summary().latin1()); |
595 | // } | 608 | // } |
596 | //qDebug("for "); | 609 | //qDebug("for "); |
597 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 610 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
598 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 611 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
599 | { | 612 | { |
600 | insertTodoItem(todo); | 613 | insertTodoItem(todo); |
601 | } | 614 | } |
602 | } | 615 | } |
603 | //qDebug("for end "); | 616 | //qDebug("for end "); |
604 | // Restore opened/closed state | 617 | // Restore opened/closed state |
605 | mTodoListView->blockSignals( true ); | 618 | mTodoListView->blockSignals( true ); |
606 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 619 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
607 | mTodoListView->blockSignals( false ); | 620 | mTodoListView->blockSignals( false ); |
608 | mTodoListView->setFocus(); | 621 | mTodoListView->setFocus(); |
609 | processSelectionChange(); | 622 | processSelectionChange(); |
610 | } | 623 | } |
611 | 624 | ||
612 | bool KOTodoView::checkTodo( Todo * todo ) | 625 | bool KOTodoView::checkTodo( Todo * todo ) |
613 | { | 626 | { |
614 | 627 | ||
615 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 628 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
616 | return false; | 629 | return false; |
617 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 630 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
618 | if ( todo->hasStartDate() ) | 631 | if ( todo->hasStartDate() ) |
619 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 632 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
620 | return false; | 633 | return false; |
621 | if ( todo->hasDueDate() ) | 634 | if ( todo->hasDueDate() ) |
622 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 635 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
623 | return false; | 636 | return false; |
624 | } | 637 | } |
625 | return true; | 638 | return true; |
626 | } | 639 | } |
627 | 640 | ||
628 | void KOTodoView::restoreItemState( QListViewItem *item ) | 641 | void KOTodoView::restoreItemState( QListViewItem *item ) |
629 | { | 642 | { |
630 | pendingSubtodo = 0; | 643 | pendingSubtodo = 0; |
631 | while( item ) { | 644 | while( item ) { |
632 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 645 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
633 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 646 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
634 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 647 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
635 | item = item->nextSibling(); | 648 | item = item->nextSibling(); |
636 | } | 649 | } |
637 | } | 650 | } |
638 | 651 | ||
639 | 652 | ||
640 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 653 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
641 | KOTodoView::insertTodoItem(Todo *todo) | 654 | KOTodoView::insertTodoItem(Todo *todo) |
642 | { | 655 | { |
643 | 656 | ||
644 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 657 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
645 | // TODO: Check, if dynmaic cast is necessary | 658 | // TODO: Check, if dynmaic cast is necessary |
646 | 659 | ||
647 | pendingSubtodo = 0; | 660 | pendingSubtodo = 0; |
648 | Incidence *incidence = todo->relatedTo(); | 661 | Incidence *incidence = todo->relatedTo(); |
649 | if (incidence && incidence->type() == "Todo") { | 662 | if (incidence && incidence->type() == "Todo") { |
650 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 663 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
651 | 664 | ||
652 | // kdDebug() << " has Related" << endl; | 665 | // kdDebug() << " has Related" << endl; |
653 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 666 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
654 | itemIterator = mTodoMap.find(relatedTodo); | 667 | itemIterator = mTodoMap.find(relatedTodo); |
655 | if (itemIterator == mTodoMap.end()) { | 668 | if (itemIterator == mTodoMap.end()) { |
656 | // kdDebug() << " related not yet in list" << endl; | 669 | // kdDebug() << " related not yet in list" << endl; |
657 | itemIterator = insertTodoItem (relatedTodo); | 670 | itemIterator = insertTodoItem (relatedTodo); |
658 | } | 671 | } |
659 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 672 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
660 | // and one into the map. Sure finding is more easy but why? -zecke | 673 | // and one into the map. Sure finding is more easy but why? -zecke |
661 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 674 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
662 | return mTodoMap.insert(todo,todoItem); | 675 | return mTodoMap.insert(todo,todoItem); |
663 | } else { | 676 | } else { |
664 | // kdDebug() << " no Related" << endl; | 677 | // kdDebug() << " no Related" << endl; |
665 | // see above -zecke | 678 | // see above -zecke |
666 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 679 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
667 | return mTodoMap.insert(todo,todoItem); | 680 | return mTodoMap.insert(todo,todoItem); |
668 | } | 681 | } |
669 | } | 682 | } |
670 | 683 | ||
671 | 684 | ||
672 | void KOTodoView::updateConfig() | 685 | void KOTodoView::updateConfig() |
673 | { | 686 | { |
674 | updateView(); | 687 | updateView(); |
675 | mTodoListView->repaintContents(); | 688 | mTodoListView->repaintContents(); |
676 | } | 689 | } |
677 | 690 | ||
678 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 691 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
679 | { | 692 | { |
680 | QPtrList<Incidence> selected; | 693 | QPtrList<Incidence> selected; |
681 | 694 | ||
682 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 695 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
683 | // if (!item) item = mActiveItem; | 696 | // if (!item) item = mActiveItem; |
684 | if (item) selected.append(item->todo()); | 697 | if (item) selected.append(item->todo()); |
685 | 698 | ||
686 | return selected; | 699 | return selected; |
687 | } | 700 | } |
688 | 701 | ||
689 | QPtrList<Todo> KOTodoView::selectedTodos() | 702 | QPtrList<Todo> KOTodoView::selectedTodos() |
690 | { | 703 | { |
691 | QPtrList<Todo> selected; | 704 | QPtrList<Todo> selected; |
692 | 705 | ||
693 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 706 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
694 | // if (!item) item = mActiveItem; | 707 | // if (!item) item = mActiveItem; |
695 | if (item) selected.append(item->todo()); | 708 | if (item) selected.append(item->todo()); |
696 | 709 | ||
697 | return selected; | 710 | return selected; |
698 | } | 711 | } |
699 | 712 | ||
700 | void KOTodoView::changeEventDisplay(Event *, int) | 713 | void KOTodoView::changeEventDisplay(Event *, int) |
701 | { | 714 | { |
702 | updateView(); | 715 | updateView(); |
703 | } | 716 | } |
704 | 717 | ||
705 | void KOTodoView::showDates(const QDate &, const QDate &) | 718 | void KOTodoView::showDates(const QDate &, const QDate &) |
706 | { | 719 | { |
707 | } | 720 | } |
708 | 721 | ||
709 | void KOTodoView::showEvents(QPtrList<Event>) | 722 | void KOTodoView::showEvents(QPtrList<Event>) |
710 | { | 723 | { |
711 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 724 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
712 | } | 725 | } |
713 | 726 | ||
714 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 727 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
715 | const QDate &td) | 728 | const QDate &td) |
716 | { | 729 | { |
717 | #ifndef KORG_NOPRINTER | 730 | #ifndef KORG_NOPRINTER |
718 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 731 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
719 | #endif | 732 | #endif |
720 | } | 733 | } |
721 | 734 | ||
722 | void KOTodoView::editItem(QListViewItem *item ) | 735 | void KOTodoView::editItem(QListViewItem *item ) |
723 | { | 736 | { |
724 | // qDebug("editItem(QListViewItem *item ) "); | 737 | // qDebug("editItem(QListViewItem *item ) "); |
725 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 738 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
726 | } | 739 | } |
727 | 740 | ||
728 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 741 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
729 | { | 742 | { |
730 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 743 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
731 | } | 744 | } |
732 | 745 | ||
733 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) | 746 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) |
734 | { | 747 | { |
735 | pendingSubtodo = 0; | 748 | pendingSubtodo = 0; |
736 | mActiveItem = (KOTodoViewItem *)item; | 749 | mActiveItem = (KOTodoViewItem *)item; |
737 | if (item) { | 750 | if (item) { |
738 | switch (column){ | 751 | switch (column){ |
739 | case 1: | 752 | case 1: |
740 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 753 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
741 | case 2: | 754 | case 2: |
742 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 755 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
743 | case 3: | 756 | case 3: |
744 | moveTodo(); | 757 | moveTodo(); |
745 | break; | 758 | break; |
746 | case 8: | 759 | case 8: |
747 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 760 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
748 | default: | 761 | default: |
749 | mItemPopupMenu->popup(QCursor::pos()); | 762 | mItemPopupMenu->popup(QCursor::pos()); |
750 | } | 763 | } |
751 | } else mPopupMenu->popup(QCursor::pos()); | 764 | } else mPopupMenu->popup(QCursor::pos()); |
752 | } | 765 | } |
753 | void KOTodoView::newTodo() | 766 | void KOTodoView::newTodo() |
754 | { | 767 | { |
755 | emit newTodoSignal(); | 768 | emit newTodoSignal(); |
756 | } | 769 | } |
757 | 770 | ||
758 | void KOTodoView::newSubTodo() | 771 | void KOTodoView::newSubTodo() |
759 | { | 772 | { |
760 | if (mActiveItem) { | 773 | if (mActiveItem) { |
761 | emit newSubTodoSignal(mActiveItem->todo()); | 774 | emit newSubTodoSignal(mActiveItem->todo()); |
762 | } | 775 | } |
763 | } | 776 | } |
764 | void KOTodoView::unparentTodo() | 777 | void KOTodoView::unparentTodo() |
765 | { | 778 | { |
766 | if (mActiveItem) { | 779 | if (mActiveItem) { |
767 | emit unparentTodoSignal(mActiveItem->todo()); | 780 | emit unparentTodoSignal(mActiveItem->todo()); |
768 | } | 781 | } |
769 | } | 782 | } |
770 | 783 | ||
771 | void KOTodoView::reparentTodo() | 784 | void KOTodoView::reparentTodo() |
772 | { | 785 | { |
773 | if (mActiveItem) { | 786 | if (mActiveItem) { |
774 | qDebug("KOTodoView::reparentTodo() "); | 787 | qDebug("KOTodoView::reparentTodo() "); |
775 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 788 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
776 | pendingSubtodo = mActiveItem; | 789 | pendingSubtodo = mActiveItem; |
777 | } | 790 | } |
778 | } | 791 | } |
779 | void KOTodoView::editTodo() | 792 | void KOTodoView::editTodo() |
780 | { | 793 | { |
781 | if (mActiveItem) { | 794 | if (mActiveItem) { |
782 | emit editTodoSignal(mActiveItem->todo()); | 795 | emit editTodoSignal(mActiveItem->todo()); |
783 | } | 796 | } |
784 | } | 797 | } |
785 | void KOTodoView::cloneTodo() | 798 | void KOTodoView::cloneTodo() |
786 | { | 799 | { |
787 | if (mActiveItem) { | 800 | if (mActiveItem) { |
788 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 801 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
789 | } | 802 | } |
790 | } | 803 | } |
791 | void KOTodoView::cancelTodo() | 804 | void KOTodoView::cancelTodo() |
792 | { | 805 | { |
793 | if (mActiveItem) { | 806 | if (mActiveItem) { |
794 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 807 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
795 | } | 808 | } |
796 | } | 809 | } |
797 | void KOTodoView::moveTodo() | 810 | void KOTodoView::moveTodo() |
798 | { | 811 | { |
799 | if (mActiveItem) { | 812 | if (mActiveItem) { |
800 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 813 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
801 | } | 814 | } |
802 | } | 815 | } |
803 | void KOTodoView::beamTodo() | 816 | void KOTodoView::beamTodo() |
804 | { | 817 | { |
805 | if (mActiveItem) { | 818 | if (mActiveItem) { |
806 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 819 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
807 | } | 820 | } |
808 | } | 821 | } |
809 | 822 | ||
810 | 823 | ||
811 | void KOTodoView::showTodo() | 824 | void KOTodoView::showTodo() |
812 | { | 825 | { |
813 | if (mActiveItem) { | 826 | if (mActiveItem) { |
814 | emit showTodoSignal(mActiveItem->todo()); | 827 | emit showTodoSignal(mActiveItem->todo()); |
815 | } | 828 | } |
816 | } | 829 | } |
817 | 830 | ||
818 | void KOTodoView::deleteTodo() | 831 | void KOTodoView::deleteTodo() |
819 | { | 832 | { |
820 | if (mActiveItem) { | 833 | if (mActiveItem) { |
821 | emit deleteTodoSignal(mActiveItem->todo()); | 834 | emit deleteTodoSignal(mActiveItem->todo()); |
822 | } | 835 | } |
823 | } | 836 | } |
824 | 837 | ||
825 | void KOTodoView::setNewPriority(int index) | 838 | void KOTodoView::setNewPriority(int index) |
826 | { | 839 | { |
827 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 840 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
828 | mActiveItem->todo()->setPriority(mPriority[index]); | 841 | mActiveItem->todo()->setPriority(mPriority[index]); |
829 | mActiveItem->construct(); | 842 | mActiveItem->construct(); |
830 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 843 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
831 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 844 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
832 | } | 845 | } |
833 | } | 846 | } |
834 | 847 | ||
835 | void KOTodoView::setNewPercentage(int index) | 848 | void KOTodoView::setNewPercentage(int index) |
836 | { | 849 | { |
837 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 850 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
838 | if (mPercentage[index] == 100) { | 851 | if (mPercentage[index] == 100) { |
839 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 852 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
840 | } else { | 853 | } else { |
841 | mActiveItem->todo()->setCompleted(false); | 854 | mActiveItem->todo()->setCompleted(false); |
842 | } | 855 | } |
843 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 856 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
844 | mActiveItem->construct(); | 857 | mActiveItem->construct(); |
845 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 858 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
846 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 859 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
847 | } | 860 | } |
848 | } | 861 | } |
849 | 862 | ||
850 | 863 | ||
851 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 864 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
852 | { | 865 | { |
853 | QPopupMenu* tempMenu = new QPopupMenu (this); | 866 | QPopupMenu* tempMenu = new QPopupMenu (this); |
854 | QStringList checkedCategories = todoItem->todo()->categories (); | 867 | QStringList checkedCategories = todoItem->todo()->categories (); |
855 | 868 | ||
856 | tempMenu->setCheckable (true); | 869 | tempMenu->setCheckable (true); |
857 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 870 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
858 | it != KOPrefs::instance()->mCustomCategories.end (); | 871 | it != KOPrefs::instance()->mCustomCategories.end (); |
859 | ++it) { | 872 | ++it) { |
860 | int index = tempMenu->insertItem (*it); | 873 | int index = tempMenu->insertItem (*it); |
861 | mCategory[index] = *it; | 874 | mCategory[index] = *it; |
862 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 875 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
863 | } | 876 | } |
864 | 877 | ||
865 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 878 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
866 | return tempMenu; | 879 | return tempMenu; |
867 | 880 | ||
868 | 881 | ||
869 | } | 882 | } |
870 | void KOTodoView::changedCategories(int index) | 883 | void KOTodoView::changedCategories(int index) |
871 | { | 884 | { |
872 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 885 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
873 | QStringList categories = mActiveItem->todo()->categories (); | 886 | QStringList categories = mActiveItem->todo()->categories (); |
874 | if (categories.find (mCategory[index]) != categories.end ()) | 887 | if (categories.find (mCategory[index]) != categories.end ()) |
875 | categories.remove (mCategory[index]); | 888 | categories.remove (mCategory[index]); |
876 | else | 889 | else |
877 | categories.insert (categories.end(), mCategory[index]); | 890 | categories.insert (categories.end(), mCategory[index]); |
878 | categories.sort (); | 891 | categories.sort (); |
879 | mActiveItem->todo()->setCategories (categories); | 892 | mActiveItem->todo()->setCategories (categories); |
880 | mActiveItem->construct(); | 893 | mActiveItem->construct(); |
881 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 894 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
882 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 895 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
883 | } | 896 | } |
884 | } | 897 | } |
885 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 898 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
886 | { | 899 | { |
887 | if ( pendingSubtodo != 0 ) { | 900 | if ( pendingSubtodo != 0 ) { |
888 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 901 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
889 | } | 902 | } |
890 | pendingSubtodo = 0; | 903 | pendingSubtodo = 0; |
891 | if (!item) { | 904 | if (!item) { |
892 | newTodo(); | 905 | newTodo(); |
893 | return; | 906 | return; |
894 | } | 907 | } |
895 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 908 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
896 | editItem( item ); | 909 | editItem( item ); |
897 | else | 910 | else |
898 | showItem( item , QPoint(), 0 ); | 911 | showItem( item , QPoint(), 0 ); |
899 | } | 912 | } |
900 | void KOTodoView::itemClicked(QListViewItem *item) | 913 | void KOTodoView::itemClicked(QListViewItem *item) |
901 | { | 914 | { |
902 | 915 | ||
903 | if (!item) { | 916 | if (!item) { |
904 | if ( pendingSubtodo != 0 ) { | 917 | if ( pendingSubtodo != 0 ) { |
905 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 918 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
906 | } | 919 | } |
907 | pendingSubtodo = 0; | 920 | pendingSubtodo = 0; |
908 | return; | 921 | return; |
909 | } | 922 | } |
910 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 923 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
911 | if ( pendingSubtodo != 0 ) { | 924 | if ( pendingSubtodo != 0 ) { |
912 | bool allowReparent = true; | 925 | bool allowReparent = true; |
913 | QListViewItem *par = item; | 926 | QListViewItem *par = item; |
914 | while ( par ) { | 927 | while ( par ) { |
915 | if ( par == pendingSubtodo ) { | 928 | if ( par == pendingSubtodo ) { |
916 | allowReparent = false; | 929 | allowReparent = false; |
917 | break; | 930 | break; |
918 | } | 931 | } |
919 | par = par->parent(); | 932 | par = par->parent(); |
920 | } | 933 | } |
921 | if ( !allowReparent ) { | 934 | if ( !allowReparent ) { |
922 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 935 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
923 | qDebug("Recursive reparenting not possible "); | 936 | qDebug("Recursive reparenting not possible "); |
924 | pendingSubtodo = 0; | 937 | pendingSubtodo = 0; |
925 | } else { | 938 | } else { |
926 | Todo* newParent = todoItem->todo(); | 939 | Todo* newParent = todoItem->todo(); |
927 | Todo* newSub = pendingSubtodo->todo(); | 940 | Todo* newSub = pendingSubtodo->todo(); |
928 | pendingSubtodo = 0; | 941 | pendingSubtodo = 0; |
929 | emit reparentTodoSignal( newParent,newSub ); | 942 | emit reparentTodoSignal( newParent,newSub ); |
930 | return; | 943 | return; |
931 | } | 944 | } |
932 | } | 945 | } |
933 | int completed = todoItem->todo()->isCompleted(); // Completed or not? | 946 | int completed = todoItem->todo()->isCompleted(); // Completed or not? |
934 | 947 | ||
935 | if (todoItem->isOn()) { | 948 | if (todoItem->isOn()) { |
936 | if (!completed) { | 949 | if (!completed) { |
937 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); | 950 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); |
938 | } | 951 | } |
939 | } else { | 952 | } else { |
940 | if (completed) { | 953 | if (completed) { |
941 | todoItem->todo()->setCompleted(false); | 954 | todoItem->todo()->setCompleted(false); |
942 | } | 955 | } |
943 | } | 956 | } |
944 | } | 957 | } |
945 | 958 | ||
946 | void KOTodoView::setDocumentId( const QString &id ) | 959 | void KOTodoView::setDocumentId( const QString &id ) |
947 | { | 960 | { |
948 | kdDebug() << "KOTodoView::setDocumentId()" << endl; | 961 | kdDebug() << "KOTodoView::setDocumentId()" << endl; |
949 | 962 | ||
950 | mDocPrefs->setDoc( id ); | 963 | mDocPrefs->setDoc( id ); |
951 | } | 964 | } |
952 | 965 | ||
953 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 966 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
954 | { | 967 | { |
955 | if (!item) return; | 968 | if (!item) return; |
956 | 969 | ||
957 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 970 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
958 | 971 | ||
959 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 972 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
960 | 973 | ||
961 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 974 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
962 | } | 975 | } |
963 | 976 | ||
964 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 977 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
965 | { | 978 | { |
966 | mTodoListView->saveLayout(config,group); | 979 | mTodoListView->saveLayout(config,group); |
967 | } | 980 | } |
968 | 981 | ||
969 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 982 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
970 | { | 983 | { |
971 | mTodoListView->restoreLayout(config,group); | 984 | mTodoListView->restoreLayout(config,group); |
972 | } | 985 | } |
973 | 986 | ||
974 | void KOTodoView::processSelectionChange() | 987 | void KOTodoView::processSelectionChange() |
975 | { | 988 | { |
976 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 989 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
977 | 990 | ||
978 | KOTodoViewItem *item = | 991 | KOTodoViewItem *item = |
979 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 992 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
980 | 993 | ||
981 | if ( !item ) { | 994 | if ( !item ) { |
982 | emit incidenceSelected( 0 ); | 995 | emit incidenceSelected( 0 ); |
983 | } else { | 996 | } else { |
984 | emit incidenceSelected( item->todo() ); | 997 | emit incidenceSelected( item->todo() ); |
985 | } | 998 | } |
986 | } | 999 | } |
987 | 1000 | ||
988 | void KOTodoView::modified(bool b) | 1001 | void KOTodoView::modified(bool b) |
989 | { | 1002 | { |
990 | emit isModified(b); | 1003 | emit isModified(b); |
991 | } | 1004 | } |
992 | void KOTodoView::setTodoModified( Todo* todo ) | 1005 | void KOTodoView::setTodoModified( Todo* todo ) |
993 | { | 1006 | { |
994 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1007 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
995 | } | 1008 | } |
996 | void KOTodoView::clearSelection() | 1009 | void KOTodoView::clearSelection() |
997 | { | 1010 | { |
998 | mTodoListView->selectAll( false ); | 1011 | mTodoListView->selectAll( false ); |
999 | } | 1012 | } |
1013 | void KOTodoView::setAllOpen() | ||
1014 | { | ||
1015 | if ( isFlatDisplay ) { | ||
1016 | isFlatDisplay = false; | ||
1017 | mPopupMenu->setItemChecked( 8,false ); | ||
1018 | updateView(); | ||
1019 | } | ||
1020 | setOpen(mTodoListView->firstChild(), true); | ||
1021 | } | ||
1022 | void KOTodoView::setAllClose() | ||
1023 | { | ||
1024 | if ( isFlatDisplay ) { | ||
1025 | isFlatDisplay = false; | ||
1026 | mPopupMenu->setItemChecked( 8,false ); | ||
1027 | updateView(); | ||
1028 | } | ||
1029 | setOpen(mTodoListView->firstChild(), false); | ||
1030 | } | ||
1031 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | ||
1032 | { | ||
1033 | |||
1034 | while ( item ) { | ||
1035 | setOpen( item->firstChild(), setOpenI ); | ||
1036 | item->setOpen( setOpenI ); | ||
1037 | item = item->nextSibling(); | ||
1038 | } | ||
1039 | } | ||
1040 | |||
1041 | void KOTodoView::setAllFlat() | ||
1042 | { | ||
1043 | pendingSubtodo = 0; | ||
1044 | if ( mBlockUpdate ) { | ||
1045 | return; | ||
1046 | } | ||
1047 | mPopupMenu->setItemChecked( 8,true ); | ||
1048 | isFlatDisplay = true; | ||
1049 | QPtrList<Todo> todoList = calendar()->todos(); | ||
1050 | mTodoMap.clear(); | ||
1051 | mTodoListView->clear(); | ||
1052 | Todo *todo; | ||
1053 | for(todo = todoList.first(); todo; todo = todoList.next()) { | ||
1054 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | ||
1055 | mTodoMap.insert(todo,todoItem); | ||
1056 | } | ||
1057 | mTodoListView->setFocus(); | ||
1058 | processSelectionChange(); | ||
1059 | } | ||
1000 | 1060 | ||
1001 | void KOTodoView::purgeCompleted() | 1061 | void KOTodoView::purgeCompleted() |
1002 | { | 1062 | { |
1003 | emit purgeCompletedSignal(); | 1063 | emit purgeCompletedSignal(); |
1004 | } | 1064 | } |
1005 | void KOTodoView::toggleQuickTodo() | 1065 | void KOTodoView::toggleQuickTodo() |
1006 | { | 1066 | { |
1007 | if ( mQuickAdd->isVisible() ) { | 1067 | if ( mQuickAdd->isVisible() ) { |
1008 | mQuickAdd->hide(); | 1068 | mQuickAdd->hide(); |
1009 | KOPrefs::instance()->mEnableQuickTodo = false; | 1069 | KOPrefs::instance()->mEnableQuickTodo = false; |
1010 | } | 1070 | } |
1011 | else { | 1071 | else { |
1012 | mQuickAdd->show(); | 1072 | mQuickAdd->show(); |
1013 | KOPrefs::instance()->mEnableQuickTodo = true; | 1073 | KOPrefs::instance()->mEnableQuickTodo = true; |
1014 | } | 1074 | } |
1015 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1075 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1016 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1076 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1017 | } | 1077 | } |
1018 | 1078 | ||
1019 | void KOTodoView::toggleRunning() | 1079 | void KOTodoView::toggleRunning() |
1020 | { | 1080 | { |
1021 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1081 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1022 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1082 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1023 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1083 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1024 | updateView(); | 1084 | updateView(); |
1025 | } | 1085 | } |
1026 | 1086 | ||
1027 | void KOTodoView::toggleCompleted() | 1087 | void KOTodoView::toggleCompleted() |
1028 | { | 1088 | { |
1029 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1089 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1030 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1090 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1031 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1091 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1032 | updateView(); | 1092 | updateView(); |
1033 | } | 1093 | } |
1034 | 1094 | ||
1035 | void KOTodoView::addQuickTodo() | 1095 | void KOTodoView::addQuickTodo() |
1036 | { | 1096 | { |
1037 | Todo *todo = new Todo(); | 1097 | Todo *todo = new Todo(); |
1038 | todo->setSummary(mQuickAdd->text()); | 1098 | todo->setSummary(mQuickAdd->text()); |
1039 | todo->setOrganizer(KOPrefs::instance()->email()); | 1099 | todo->setOrganizer(KOPrefs::instance()->email()); |
1040 | CalFilter * cf = mCalendar->filter(); | 1100 | CalFilter * cf = mCalendar->filter(); |
1041 | if ( cf ) { | 1101 | if ( cf ) { |
1042 | if ( cf->isEnabled()&& cf->showCategories()) { | 1102 | if ( cf->isEnabled()&& cf->showCategories()) { |
1043 | todo->setCategories(cf->categoryList()); | 1103 | todo->setCategories(cf->categoryList()); |
1044 | } | 1104 | } |
1045 | if ( cf->isEnabled() ) | 1105 | if ( cf->isEnabled() ) |
1046 | todo->setSecrecy( cf->getSecrecy()); | 1106 | todo->setSecrecy( cf->getSecrecy()); |
1047 | } | 1107 | } |
1048 | mCalendar->addTodo(todo); | 1108 | mCalendar->addTodo(todo); |
1049 | mQuickAdd->setText(""); | 1109 | mQuickAdd->setText(""); |
1050 | todoModified (todo, KOGlobals::EVENTADDED ); | 1110 | todoModified (todo, KOGlobals::EVENTADDED ); |
1051 | updateView(); | 1111 | updateView(); |
1052 | } | 1112 | } |
1053 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1113 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1054 | { | 1114 | { |
1055 | // e->ignore(); | 1115 | // e->ignore(); |
1056 | //return; | 1116 | //return; |
1057 | //qDebug("KOTodoView::keyPressEvent "); | 1117 | //qDebug("KOTodoView::keyPressEvent "); |
1058 | switch ( e->key() ) { | 1118 | switch ( e->key() ) { |
1059 | case Qt::Key_Down: | 1119 | case Qt::Key_Down: |
1060 | case Qt::Key_Up: | 1120 | case Qt::Key_Up: |
1061 | QWidget::keyPressEvent ( e ); | 1121 | QWidget::keyPressEvent ( e ); |
1062 | break; | 1122 | break; |
1063 | 1123 | ||
1064 | case Qt::Key_Q: | 1124 | case Qt::Key_Q: |
1065 | toggleQuickTodo(); | 1125 | toggleQuickTodo(); |
1066 | break; | 1126 | break; |
1067 | case Qt::Key_U: | 1127 | case Qt::Key_U: |
1068 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1128 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1069 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1129 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1070 | unparentTodo(); | 1130 | unparentTodo(); |
1071 | e->accept(); | 1131 | e->accept(); |
1072 | } else | 1132 | } else |
1073 | e->ignore(); | 1133 | e->ignore(); |
1074 | break; | 1134 | break; |
1075 | case Qt::Key_S: | 1135 | case Qt::Key_S: |
1076 | if ( e->state() == Qt::ControlButton ) { | 1136 | if ( e->state() == Qt::ControlButton ) { |
1077 | e->ignore(); | 1137 | e->ignore(); |
1078 | break; | 1138 | break; |
1079 | } | 1139 | } |
1080 | if ( e->state() == Qt::ShiftButton ) { | 1140 | if ( e->state() == Qt::ShiftButton ) { |
1081 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1141 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1082 | reparentTodo(); | 1142 | reparentTodo(); |
1083 | e->accept(); | 1143 | e->accept(); |
1084 | } else | 1144 | } else |
1085 | e->ignore(); | 1145 | e->ignore(); |
1086 | break; | 1146 | break; |
1087 | case Qt::Key_P: | 1147 | case Qt::Key_P: |
1088 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1148 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1089 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1149 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1090 | if ( pendingSubtodo ) | 1150 | if ( pendingSubtodo ) |
1091 | itemClicked(mActiveItem); | 1151 | itemClicked(mActiveItem); |
1092 | e->accept(); | 1152 | e->accept(); |
1093 | } else | 1153 | } else |
1094 | e->ignore(); | 1154 | e->ignore(); |
1095 | break; | 1155 | break; |
1096 | case Qt::Key_Escape: | 1156 | case Qt::Key_Escape: |
1097 | if ( pendingSubtodo ) { | 1157 | if ( pendingSubtodo ) { |
1098 | itemClicked(0); | 1158 | itemClicked(0); |
1099 | e->accept(); | 1159 | e->accept(); |
1100 | } else | 1160 | } else |
1101 | e->ignore(); | 1161 | e->ignore(); |
1102 | break; | 1162 | break; |
1103 | default: | 1163 | default: |
1104 | e->ignore(); | 1164 | e->ignore(); |
1105 | } | 1165 | } |
1106 | 1166 | ||
1107 | if ( true ) { | 1167 | if ( true ) { |
1108 | if ( e->key() == Qt::Key_I ) { | 1168 | if ( e->key() == Qt::Key_I ) { |
1109 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1169 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1110 | if ( cn ) { | 1170 | if ( cn ) { |
1111 | mActiveItem = cn; | 1171 | mActiveItem = cn; |
1112 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1172 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1113 | if ( ci ){ | 1173 | if ( ci ){ |
1114 | showTodo(); | 1174 | showTodo(); |
1115 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1175 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1116 | if ( cn ) { | 1176 | if ( cn ) { |
1117 | mTodoListView->setCurrentItem ( cn ); | 1177 | mTodoListView->setCurrentItem ( cn ); |
1118 | mTodoListView->ensureItemVisible ( cn ); | 1178 | mTodoListView->ensureItemVisible ( cn ); |
1119 | } | 1179 | } |
1120 | 1180 | ||
1121 | } | 1181 | } |
1122 | } | 1182 | } |
1123 | e->accept(); | 1183 | e->accept(); |
1124 | 1184 | ||
1125 | } | 1185 | } |
1126 | 1186 | ||
1127 | } | 1187 | } |
1128 | 1188 | ||
1129 | } | 1189 | } |
1130 | void KOTodoView::updateTodo( Todo * t, int type ) | 1190 | void KOTodoView::updateTodo( Todo * t, int type ) |
1131 | { | 1191 | { |
1132 | if ( mBlockUpdate) | 1192 | if ( mBlockUpdate) |
1133 | return; | 1193 | return; |
1134 | 1194 | ||
1135 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1195 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1136 | itemIterator = mTodoMap.find(t); | 1196 | itemIterator = mTodoMap.find(t); |
1137 | if (itemIterator != mTodoMap.end()) { | 1197 | if (itemIterator != mTodoMap.end()) { |
1138 | (*itemIterator)->construct(); | 1198 | (*itemIterator)->construct(); |
1139 | } else { | 1199 | } else { |
1140 | if ( type == KOGlobals::EVENTADDED ) { | 1200 | if ( type == KOGlobals::EVENTADDED ) { |
1141 | insertTodoItem( t ); | 1201 | insertTodoItem( t ); |
1142 | } | 1202 | } |
1143 | } | 1203 | } |
1144 | 1204 | ||
1145 | } | 1205 | } |
1146 | 1206 | ||
1147 | void KOTodoView::todoModified(Todo * t , int p ) | 1207 | void KOTodoView::todoModified(Todo * t , int p ) |
1148 | { | 1208 | { |
1149 | mBlockUpdate = true; | 1209 | mBlockUpdate = true; |
1150 | emit todoModifiedSignal ( t, p ); | 1210 | emit todoModifiedSignal ( t, p ); |
1151 | mBlockUpdate = false; | 1211 | mBlockUpdate = false; |
1152 | } | 1212 | } |
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 5ca0362..f11518d 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h | |||
@@ -1,239 +1,244 @@ | |||
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 KOTODOVIEW_H | 23 | #ifndef KOTODOVIEW_H |
24 | #define KOTODOVIEW_H | 24 | #define KOTODOVIEW_H |
25 | 25 | ||
26 | #include <qfont.h> | 26 | #include <qfont.h> |
27 | #include <qfontmetrics.h> | 27 | #include <qfontmetrics.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qptrlist.h> | 29 | #include <qptrlist.h> |
30 | #include <qstrlist.h> | 30 | #include <qstrlist.h> |
31 | #include <qlistbox.h> | 31 | #include <qlistbox.h> |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qmap.h> | 34 | #include <qmap.h> |
35 | #include <qlistview.h> | 35 | #include <qlistview.h> |
36 | #include <klistview.h> | 36 | #include <klistview.h> |
37 | 37 | ||
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | 40 | ||
41 | #include <korganizer/baseview.h> | 41 | #include <korganizer/baseview.h> |
42 | 42 | ||
43 | #include "kotodoviewitem.h" | 43 | #include "kotodoviewitem.h" |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #include "koglobals.h" | 45 | #include "koglobals.h" |
46 | #include "datenavigator.h" | 46 | #include "datenavigator.h" |
47 | 47 | ||
48 | class QDragEnterEvent; | 48 | class QDragEnterEvent; |
49 | class QDragMoveEvent; | 49 | class QDragMoveEvent; |
50 | class QDragLeaveEvent; | 50 | class QDragLeaveEvent; |
51 | class QDropEvent; | 51 | class QDropEvent; |
52 | 52 | ||
53 | class DocPrefs; | 53 | class DocPrefs; |
54 | 54 | ||
55 | class KOTodoListView : public KListView | 55 | class KOTodoListView : public KListView |
56 | { | 56 | { |
57 | Q_OBJECT | 57 | Q_OBJECT |
58 | public: | 58 | public: |
59 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); | 59 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); |
60 | virtual ~KOTodoListView() {} | 60 | virtual ~KOTodoListView() {} |
61 | 61 | ||
62 | signals: | 62 | signals: |
63 | void todoDropped(Todo *); | 63 | void todoDropped(Todo *); |
64 | void double_Clicked(QListViewItem *item); | 64 | void double_Clicked(QListViewItem *item); |
65 | 65 | ||
66 | protected: | 66 | protected: |
67 | void contentsDragEnterEvent(QDragEnterEvent *); | 67 | void contentsDragEnterEvent(QDragEnterEvent *); |
68 | void contentsDragMoveEvent(QDragMoveEvent *); | 68 | void contentsDragMoveEvent(QDragMoveEvent *); |
69 | void contentsDragLeaveEvent(QDragLeaveEvent *); | 69 | void contentsDragLeaveEvent(QDragLeaveEvent *); |
70 | void contentsDropEvent(QDropEvent *); | 70 | void contentsDropEvent(QDropEvent *); |
71 | 71 | ||
72 | void contentsMousePressEvent(QMouseEvent *); | 72 | void contentsMousePressEvent(QMouseEvent *); |
73 | void contentsMouseMoveEvent(QMouseEvent *); | 73 | void contentsMouseMoveEvent(QMouseEvent *); |
74 | void contentsMouseReleaseEvent(QMouseEvent *); | 74 | void contentsMouseReleaseEvent(QMouseEvent *); |
75 | void contentsMouseDoubleClickEvent(QMouseEvent *); | 75 | void contentsMouseDoubleClickEvent(QMouseEvent *); |
76 | 76 | ||
77 | private: | 77 | private: |
78 | QString mName; | 78 | QString mName; |
79 | Calendar *mCalendar; | 79 | Calendar *mCalendar; |
80 | QPoint mPressPos; | 80 | QPoint mPressPos; |
81 | bool mMousePressed; | 81 | bool mMousePressed; |
82 | QListViewItem *mOldCurrent; | 82 | QListViewItem *mOldCurrent; |
83 | void keyPressEvent ( QKeyEvent * ) ; | 83 | void keyPressEvent ( QKeyEvent * ) ; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | 86 | ||
87 | /** | 87 | /** |
88 | This is the line-edit on top of the todoview for fast addition of new todos | 88 | This is the line-edit on top of the todoview for fast addition of new todos |
89 | */ | 89 | */ |
90 | class KOQuickTodo : public QLineEdit | 90 | class KOQuickTodo : public QLineEdit |
91 | { | 91 | { |
92 | public: | 92 | public: |
93 | KOQuickTodo(QWidget *parent=0); | 93 | KOQuickTodo(QWidget *parent=0); |
94 | protected: | 94 | protected: |
95 | void focusInEvent(QFocusEvent *ev); | 95 | void focusInEvent(QFocusEvent *ev); |
96 | void focusOutEvent(QFocusEvent *ev); | 96 | void focusOutEvent(QFocusEvent *ev); |
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
100 | /** | 100 | /** |
101 | This class provides a multi-column list view of todo events. | 101 | This class provides a multi-column list view of todo events. |
102 | 102 | ||
103 | @short multi-column list view of todo events. | 103 | @short multi-column list view of todo events. |
104 | @author Cornelius Schumacher <schumacher@kde.org> | 104 | @author Cornelius Schumacher <schumacher@kde.org> |
105 | */ | 105 | */ |
106 | class KOTodoView : public KOrg::BaseView | 106 | class KOTodoView : public KOrg::BaseView |
107 | { | 107 | { |
108 | Q_OBJECT | 108 | Q_OBJECT |
109 | public: | 109 | public: |
110 | KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); | 110 | KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); |
111 | ~KOTodoView(); | 111 | ~KOTodoView(); |
112 | 112 | ||
113 | QPtrList<Incidence> selectedIncidences(); | 113 | QPtrList<Incidence> selectedIncidences(); |
114 | QPtrList<Todo> selectedTodos(); | 114 | QPtrList<Todo> selectedTodos(); |
115 | 115 | ||
116 | DateList selectedDates() | 116 | DateList selectedDates() |
117 | {DateList q; | 117 | {DateList q; |
118 | return q;} | 118 | return q;} |
119 | 119 | ||
120 | /** Return number of shown dates. TodoView does not show dates, */ | 120 | /** Return number of shown dates. TodoView does not show dates, */ |
121 | int currentDateCount() { return 0; } | 121 | int currentDateCount() { return 0; } |
122 | 122 | ||
123 | void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); | 123 | void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); |
124 | 124 | ||
125 | void setDocumentId( const QString & ); | 125 | void setDocumentId( const QString & ); |
126 | 126 | ||
127 | void saveLayout(KConfig *config, const QString &group) const; | 127 | void saveLayout(KConfig *config, const QString &group) const; |
128 | void restoreLayout(KConfig *config, const QString &group); | 128 | void restoreLayout(KConfig *config, const QString &group); |
129 | /** Create a popup menu to set categories */ | 129 | /** Create a popup menu to set categories */ |
130 | QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); | 130 | QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); |
131 | void setNavigator( DateNavigator* nav ) {mNavigator = nav;} | 131 | void setNavigator( DateNavigator* nav ) {mNavigator = nav;} |
132 | 132 | ||
133 | public slots: | 133 | public slots: |
134 | void updateView(); | 134 | void updateView(); |
135 | void updateConfig(); | 135 | void updateConfig(); |
136 | 136 | ||
137 | void changeEventDisplay(Event *, int); | 137 | void changeEventDisplay(Event *, int); |
138 | 138 | ||
139 | void showDates(const QDate &start, const QDate &end); | 139 | void showDates(const QDate &start, const QDate &end); |
140 | void showEvents(QPtrList<Event> eventList); | 140 | void showEvents(QPtrList<Event> eventList); |
141 | 141 | ||
142 | void clearSelection(); | 142 | void clearSelection(); |
143 | void jumpToDate (); | 143 | void jumpToDate (); |
144 | 144 | ||
145 | void editItem(QListViewItem *item); | 145 | void editItem(QListViewItem *item); |
146 | void showItem(QListViewItem *item,const QPoint &,int); | 146 | void showItem(QListViewItem *item,const QPoint &,int); |
147 | void popupMenu(QListViewItem *item,const QPoint &,int); | 147 | void popupMenu(QListViewItem *item,const QPoint &,int); |
148 | void newTodo(); | 148 | void newTodo(); |
149 | void newSubTodo(); | 149 | void newSubTodo(); |
150 | void unparentTodo(); | 150 | void unparentTodo(); |
151 | void reparentTodo(); | 151 | void reparentTodo(); |
152 | void showTodo(); | 152 | void showTodo(); |
153 | void editTodo(); | 153 | void editTodo(); |
154 | void cloneTodo(); | 154 | void cloneTodo(); |
155 | void cancelTodo(); | 155 | void cancelTodo(); |
156 | void moveTodo(); | 156 | void moveTodo(); |
157 | void beamTodo(); | 157 | void beamTodo(); |
158 | void deleteTodo(); | 158 | void deleteTodo(); |
159 | 159 | ||
160 | void setNewPriority(int); | 160 | void setNewPriority(int); |
161 | void setNewPercentage(int); | 161 | void setNewPercentage(int); |
162 | void changedCategories(int); | 162 | void changedCategories(int); |
163 | 163 | ||
164 | void setAllOpen(); | ||
165 | void setAllClose(); | ||
166 | void setAllFlat(); | ||
167 | |||
164 | void purgeCompleted(); | 168 | void purgeCompleted(); |
165 | void toggleCompleted(); | 169 | void toggleCompleted(); |
166 | void toggleRunning(); | 170 | void toggleRunning(); |
167 | void toggleQuickTodo(); | 171 | void toggleQuickTodo(); |
168 | void updateTodo( Todo *, int ); | 172 | void updateTodo( Todo *, int ); |
169 | 173 | ||
170 | void itemClicked(QListViewItem *); | 174 | void itemClicked(QListViewItem *); |
171 | void itemStateChanged(QListViewItem *); | 175 | void itemStateChanged(QListViewItem *); |
172 | void modified(bool); | 176 | void modified(bool); |
173 | void itemDoubleClicked(QListViewItem *item); | 177 | void itemDoubleClicked(QListViewItem *item); |
174 | 178 | ||
175 | signals: | 179 | signals: |
176 | void newTodoSignal(); | 180 | void newTodoSignal(); |
177 | void newSubTodoSignal(Todo *); | 181 | void newSubTodoSignal(Todo *); |
178 | void unparentTodoSignal(Todo *); | 182 | void unparentTodoSignal(Todo *); |
179 | void reparentTodoSignal( Todo *,Todo * ); | 183 | void reparentTodoSignal( Todo *,Todo * ); |
180 | void showTodoSignal(Todo *); | 184 | void showTodoSignal(Todo *); |
181 | 185 | ||
182 | void editTodoSignal(Todo *); | 186 | void editTodoSignal(Todo *); |
183 | void deleteTodoSignal(Todo *); | 187 | void deleteTodoSignal(Todo *); |
184 | void todoModifiedSignal (Todo *, int); | 188 | void todoModifiedSignal (Todo *, int); |
185 | 189 | ||
186 | void isModified(bool); | 190 | void isModified(bool); |
187 | void cloneTodoSignal( Incidence * ); | 191 | void cloneTodoSignal( Incidence * ); |
188 | void cancelTodoSignal( Incidence * ); | 192 | void cancelTodoSignal( Incidence * ); |
189 | void moveTodoSignal( Incidence * ); | 193 | void moveTodoSignal( Incidence * ); |
190 | void beamTodoSignal( Incidence * ); | 194 | void beamTodoSignal( Incidence * ); |
191 | void purgeCompletedSignal(); | 195 | void purgeCompletedSignal(); |
192 | 196 | ||
193 | protected slots: | 197 | protected slots: |
194 | void processSelectionChange(); | 198 | void processSelectionChange(); |
195 | void addQuickTodo(); | 199 | void addQuickTodo(); |
196 | 200 | ||
197 | private: | 201 | private: |
198 | /* | 202 | /* |
199 | * the TodoEditor approach is rather unscaling in the long | 203 | * the TodoEditor approach is rather unscaling in the long |
200 | * run. | 204 | * run. |
201 | * Korganizer keeps it in memory and we need to update | 205 | * Korganizer keeps it in memory and we need to update |
202 | * 1. make KOTodoViewItem a QObject again? | 206 | * 1. make KOTodoViewItem a QObject again? |
203 | * 2. add a public method for setting one todo modified? | 207 | * 2. add a public method for setting one todo modified? |
204 | * 3. add a private method for setting a todo modified + friend here? | 208 | * 3. add a private method for setting a todo modified + friend here? |
205 | * -- zecke 2002-07-08 | 209 | * -- zecke 2002-07-08 |
206 | */ | 210 | */ |
207 | friend class KOTodoViewItem; | 211 | friend class KOTodoViewItem; |
208 | void setTodoModified( Todo* ); | 212 | void setTodoModified( Todo* ); |
209 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); | 213 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); |
210 | void restoreItemState( QListViewItem * ); | 214 | void restoreItemState( QListViewItem * ); |
211 | 215 | ||
212 | bool checkTodo( Todo * ); | 216 | bool checkTodo( Todo * ); |
213 | 217 | bool isFlatDisplay; | |
218 | void setOpen( QListViewItem*, bool setOpen); | ||
214 | KOTodoListView *mTodoListView; | 219 | KOTodoListView *mTodoListView; |
215 | QPopupMenu *mItemPopupMenu; | 220 | QPopupMenu *mItemPopupMenu; |
216 | QPopupMenu *mPopupMenu; | 221 | QPopupMenu *mPopupMenu; |
217 | QPopupMenu *mPriorityPopupMenu; | 222 | QPopupMenu *mPriorityPopupMenu; |
218 | QPopupMenu *mPercentageCompletedPopupMenu; | 223 | QPopupMenu *mPercentageCompletedPopupMenu; |
219 | QPopupMenu *mCategoryPopupMenu; | 224 | QPopupMenu *mCategoryPopupMenu; |
220 | 225 | ||
221 | QMap<int, int> mPercentage; | 226 | QMap<int, int> mPercentage; |
222 | QMap<int, int> mPriority; | 227 | QMap<int, int> mPriority; |
223 | QMap<int, QString> mCategory; | 228 | QMap<int, QString> mCategory; |
224 | KOTodoViewItem *mActiveItem; | 229 | KOTodoViewItem *mActiveItem; |
225 | 230 | ||
226 | QMap<Todo *,KOTodoViewItem *> mTodoMap; | 231 | QMap<Todo *,KOTodoViewItem *> mTodoMap; |
227 | QString mName; | 232 | QString mName; |
228 | 233 | ||
229 | DocPrefs *mDocPrefs; | 234 | DocPrefs *mDocPrefs; |
230 | QString mCurrentDoc; | 235 | QString mCurrentDoc; |
231 | KOQuickTodo *mQuickAdd; | 236 | KOQuickTodo *mQuickAdd; |
232 | bool mBlockUpdate; | 237 | bool mBlockUpdate; |
233 | void todoModified(Todo *, int ); | 238 | void todoModified(Todo *, int ); |
234 | void keyPressEvent ( QKeyEvent * ) ; | 239 | void keyPressEvent ( QKeyEvent * ) ; |
235 | KOTodoViewItem * pendingSubtodo; | 240 | KOTodoViewItem * pendingSubtodo; |
236 | DateNavigator* mNavigator; | 241 | DateNavigator* mNavigator; |
237 | }; | 242 | }; |
238 | 243 | ||
239 | #endif | 244 | #endif |