author | zautrix <zautrix> | 2005-02-13 19:07:45 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-13 19:07:45 (UTC) |
commit | 7bd83e913399b8be68a7d37e8f02118ec9eab90e (patch) (unidiff) | |
tree | 284d1592687ea4d3e0c220fafd289a702718dee4 /korganizer/calendarview.cpp | |
parent | 293271fe9e6a9061da329183f8f488d79580f7da (diff) | |
download | kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.zip kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.gz kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.bz2 |
todo fixi
-rw-r--r-- | korganizer/calendarview.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 7c8316f..3dac20b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2138,265 +2138,277 @@ void CalendarView::changeEventDisplay(Event *which, int action) | |||
2138 | // } | 2138 | // } |
2139 | } else { | 2139 | } else { |
2140 | mViewManager->currentView()->updateView(); | 2140 | mViewManager->currentView()->updateView(); |
2141 | } | 2141 | } |
2142 | } | 2142 | } |
2143 | 2143 | ||
2144 | 2144 | ||
2145 | void CalendarView::updateTodoViews() | 2145 | void CalendarView::updateTodoViews() |
2146 | { | 2146 | { |
2147 | mTodoList->updateView(); | 2147 | mTodoList->updateView(); |
2148 | mViewManager->currentView()->updateView(); | 2148 | mViewManager->currentView()->updateView(); |
2149 | 2149 | ||
2150 | } | 2150 | } |
2151 | 2151 | ||
2152 | 2152 | ||
2153 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2153 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2154 | { | 2154 | { |
2155 | mTodoList->updateView(); | 2155 | mTodoList->updateView(); |
2156 | mViewManager->updateView(start, end); | 2156 | mViewManager->updateView(start, end); |
2157 | //mDateNavigator->updateView(); | 2157 | //mDateNavigator->updateView(); |
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | void CalendarView::updateView() | 2160 | void CalendarView::updateView() |
2161 | { | 2161 | { |
2162 | DateList tmpList = mNavigator->selectedDates(); | 2162 | DateList tmpList = mNavigator->selectedDates(); |
2163 | 2163 | ||
2164 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2164 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2165 | mTodoList->updateView(); | 2165 | mTodoList->updateView(); |
2166 | // We assume that the navigator only selects consecutive days. | 2166 | // We assume that the navigator only selects consecutive days. |
2167 | updateView( tmpList.first(), tmpList.last() ); | 2167 | updateView( tmpList.first(), tmpList.last() ); |
2168 | } | 2168 | } |
2169 | 2169 | ||
2170 | void CalendarView::updateUnmanagedViews() | 2170 | void CalendarView::updateUnmanagedViews() |
2171 | { | 2171 | { |
2172 | mDateNavigator->updateDayMatrix(); | 2172 | mDateNavigator->updateDayMatrix(); |
2173 | } | 2173 | } |
2174 | 2174 | ||
2175 | int CalendarView::msgItemDelete(const QString name) | 2175 | int CalendarView::msgItemDelete(const QString name) |
2176 | { | 2176 | { |
2177 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2177 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2178 | i18n("This item will be\npermanently deleted."), | 2178 | i18n("This item will be\npermanently deleted."), |
2179 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2179 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2180 | } | 2180 | } |
2181 | 2181 | ||
2182 | 2182 | ||
2183 | void CalendarView::edit_cut() | 2183 | void CalendarView::edit_cut() |
2184 | { | 2184 | { |
2185 | Event *anEvent=0; | 2185 | Event *anEvent=0; |
2186 | 2186 | ||
2187 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2187 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2188 | 2188 | ||
2189 | if (mViewManager->currentView()->isEventView()) { | 2189 | if (mViewManager->currentView()->isEventView()) { |
2190 | if ( incidence && incidence->type() == "Event" ) { | 2190 | if ( incidence && incidence->type() == "Event" ) { |
2191 | anEvent = static_cast<Event *>(incidence); | 2191 | anEvent = static_cast<Event *>(incidence); |
2192 | } | 2192 | } |
2193 | } | 2193 | } |
2194 | 2194 | ||
2195 | if (!anEvent) { | 2195 | if (!anEvent) { |
2196 | KNotifyClient::beep(); | 2196 | KNotifyClient::beep(); |
2197 | return; | 2197 | return; |
2198 | } | 2198 | } |
2199 | DndFactory factory( mCalendar ); | 2199 | DndFactory factory( mCalendar ); |
2200 | factory.cutIncidence(anEvent); | 2200 | factory.cutIncidence(anEvent); |
2201 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2201 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2202 | } | 2202 | } |
2203 | 2203 | ||
2204 | void CalendarView::edit_copy() | 2204 | void CalendarView::edit_copy() |
2205 | { | 2205 | { |
2206 | Event *anEvent=0; | 2206 | Event *anEvent=0; |
2207 | 2207 | ||
2208 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2208 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2209 | 2209 | ||
2210 | if (mViewManager->currentView()->isEventView()) { | 2210 | if (mViewManager->currentView()->isEventView()) { |
2211 | if ( incidence && incidence->type() == "Event" ) { | 2211 | if ( incidence && incidence->type() == "Event" ) { |
2212 | anEvent = static_cast<Event *>(incidence); | 2212 | anEvent = static_cast<Event *>(incidence); |
2213 | } | 2213 | } |
2214 | } | 2214 | } |
2215 | 2215 | ||
2216 | if (!anEvent) { | 2216 | if (!anEvent) { |
2217 | KNotifyClient::beep(); | 2217 | KNotifyClient::beep(); |
2218 | return; | 2218 | return; |
2219 | } | 2219 | } |
2220 | DndFactory factory( mCalendar ); | 2220 | DndFactory factory( mCalendar ); |
2221 | factory.copyIncidence(anEvent); | 2221 | factory.copyIncidence(anEvent); |
2222 | } | 2222 | } |
2223 | 2223 | ||
2224 | void CalendarView::edit_paste() | 2224 | void CalendarView::edit_paste() |
2225 | { | 2225 | { |
2226 | QDate date = mNavigator->selectedDates().first(); | 2226 | QDate date = mNavigator->selectedDates().first(); |
2227 | 2227 | ||
2228 | DndFactory factory( mCalendar ); | 2228 | DndFactory factory( mCalendar ); |
2229 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2229 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2230 | 2230 | ||
2231 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2231 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2232 | } | 2232 | } |
2233 | 2233 | ||
2234 | void CalendarView::edit_options() | 2234 | void CalendarView::edit_options() |
2235 | { | 2235 | { |
2236 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2236 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2237 | emit save(); | 2237 | emit save(); |
2238 | emit saveStopTimer(); | 2238 | emit saveStopTimer(); |
2239 | mDialogManager->showOptionsDialog(); | 2239 | mDialogManager->showOptionsDialog(); |
2240 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2240 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2241 | emit saveStopTimer(); | 2241 | emit saveStopTimer(); |
2242 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2242 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2243 | i18n("Timezone settings"),i18n("Reload"))) { | 2243 | i18n("Timezone settings"),i18n("Reload"))) { |
2244 | qDebug("KO: TZ reload cancelled "); | 2244 | qDebug("KO: TZ reload cancelled "); |
2245 | return; | 2245 | return; |
2246 | } | 2246 | } |
2247 | qDebug("KO: Timezone change "); | 2247 | qDebug("KO: Timezone change "); |
2248 | openCalendar( MainWindow::defaultFileName() ); | 2248 | openCalendar( MainWindow::defaultFileName() ); |
2249 | setModified(true); | 2249 | setModified(true); |
2250 | } | 2250 | } |
2251 | else | 2251 | else |
2252 | qDebug("KO: No tz change "); | 2252 | qDebug("KO: No tz change "); |
2253 | 2253 | ||
2254 | } | 2254 | } |
2255 | 2255 | ||
2256 | 2256 | ||
2257 | void CalendarView::slotSelectPickerDate( QDate d) | 2257 | void CalendarView::slotSelectPickerDate( QDate d) |
2258 | { | 2258 | { |
2259 | mDateFrame->hide(); | 2259 | mDateFrame->hide(); |
2260 | if ( mDatePickerMode == 1 ) { | 2260 | if ( mDatePickerMode == 1 ) { |
2261 | mNavigator->slotDaySelect( d ); | 2261 | mNavigator->slotDaySelect( d ); |
2262 | } else if ( mDatePickerMode == 2 ) { | 2262 | } else if ( mDatePickerMode == 2 ) { |
2263 | if ( mMoveIncidence->type() == "Todo" ) { | 2263 | if ( mMoveIncidence->type() == "Todo" ) { |
2264 | Todo * to = (Todo *) mMoveIncidence; | 2264 | Todo * to = (Todo *) mMoveIncidence; |
2265 | QTime tim; | 2265 | QTime tim; |
2266 | int len = 0; | ||
2267 | if ( to->hasStartDate() && to->hasDueDate() ) | ||
2268 | len = to->dtStart().secsTo( to->dtDue()); | ||
2266 | if ( to->hasDueDate() ) | 2269 | if ( to->hasDueDate() ) |
2267 | tim = to->dtDue().time(); | 2270 | tim = to->dtDue().time(); |
2268 | else { | 2271 | else { |
2269 | tim = QTime ( 0,0,0 ); | 2272 | tim = QTime ( 0,0,0 ); |
2270 | to->setFloats( true ); | 2273 | to->setFloats( true ); |
2271 | to->setHasDueDate( true ); | 2274 | to->setHasDueDate( true ); |
2272 | } | 2275 | } |
2273 | QDateTime dt ( d,tim ); | 2276 | QDateTime dt ( d,tim ); |
2274 | to->setDtDue( dt ); | 2277 | to->setDtDue( dt ); |
2278 | |||
2279 | if ( to->hasStartDate() ) { | ||
2280 | if ( len>0 ) | ||
2281 | to->setDtStart(to->dtDue().addSecs( -len )); | ||
2282 | else | ||
2283 | if (to->dtStart() > to->dtDue() ) | ||
2284 | to->setDtStart(to->dtDue().addDays( -3 )); | ||
2285 | } | ||
2286 | |||
2275 | todoChanged( to ); | 2287 | todoChanged( to ); |
2276 | } else { | 2288 | } else { |
2277 | if ( mMoveIncidence->doesRecur() ) { | 2289 | if ( mMoveIncidence->doesRecur() ) { |
2278 | #if 0 | 2290 | #if 0 |
2279 | // PENDING implement this | 2291 | // PENDING implement this |
2280 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2292 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2281 | mCalendar()->addIncidence( newInc ); | 2293 | mCalendar()->addIncidence( newInc ); |
2282 | if ( mMoveIncidence->type() == "Todo" ) | 2294 | if ( mMoveIncidence->type() == "Todo" ) |
2283 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2295 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2284 | else | 2296 | else |
2285 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2297 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2286 | mMoveIncidence = newInc; | 2298 | mMoveIncidence = newInc; |
2287 | 2299 | ||
2288 | #endif | 2300 | #endif |
2289 | } | 2301 | } |
2290 | QTime tim = mMoveIncidence->dtStart().time(); | 2302 | QTime tim = mMoveIncidence->dtStart().time(); |
2291 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2303 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2292 | QDateTime dt ( d,tim ); | 2304 | QDateTime dt ( d,tim ); |
2293 | mMoveIncidence->setDtStart( dt ); | 2305 | mMoveIncidence->setDtStart( dt ); |
2294 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2306 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2295 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2307 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2296 | } | 2308 | } |
2297 | 2309 | ||
2298 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2310 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2299 | } | 2311 | } |
2300 | } | 2312 | } |
2301 | 2313 | ||
2302 | void CalendarView::removeCategories() | 2314 | void CalendarView::removeCategories() |
2303 | { | 2315 | { |
2304 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2316 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2305 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2317 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2306 | QStringList catIncList; | 2318 | QStringList catIncList; |
2307 | QStringList newCatList; | 2319 | QStringList newCatList; |
2308 | Incidence* inc = incList.first(); | 2320 | Incidence* inc = incList.first(); |
2309 | int i; | 2321 | int i; |
2310 | int count = 0; | 2322 | int count = 0; |
2311 | while ( inc ) { | 2323 | while ( inc ) { |
2312 | newCatList.clear(); | 2324 | newCatList.clear(); |
2313 | catIncList = inc->categories() ; | 2325 | catIncList = inc->categories() ; |
2314 | for( i = 0; i< catIncList.count(); ++i ) { | 2326 | for( i = 0; i< catIncList.count(); ++i ) { |
2315 | if ( catList.contains (catIncList[i])) | 2327 | if ( catList.contains (catIncList[i])) |
2316 | newCatList.append( catIncList[i] ); | 2328 | newCatList.append( catIncList[i] ); |
2317 | } | 2329 | } |
2318 | newCatList.sort(); | 2330 | newCatList.sort(); |
2319 | inc->setCategories( newCatList.join(",") ); | 2331 | inc->setCategories( newCatList.join(",") ); |
2320 | inc = incList.next(); | 2332 | inc = incList.next(); |
2321 | } | 2333 | } |
2322 | } | 2334 | } |
2323 | 2335 | ||
2324 | int CalendarView::addCategories() | 2336 | int CalendarView::addCategories() |
2325 | { | 2337 | { |
2326 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2338 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2327 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2339 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2328 | QStringList catIncList; | 2340 | QStringList catIncList; |
2329 | Incidence* inc = incList.first(); | 2341 | Incidence* inc = incList.first(); |
2330 | int i; | 2342 | int i; |
2331 | int count = 0; | 2343 | int count = 0; |
2332 | while ( inc ) { | 2344 | while ( inc ) { |
2333 | catIncList = inc->categories() ; | 2345 | catIncList = inc->categories() ; |
2334 | for( i = 0; i< catIncList.count(); ++i ) { | 2346 | for( i = 0; i< catIncList.count(); ++i ) { |
2335 | if ( !catList.contains (catIncList[i])) { | 2347 | if ( !catList.contains (catIncList[i])) { |
2336 | catList.append( catIncList[i] ); | 2348 | catList.append( catIncList[i] ); |
2337 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2349 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2338 | ++count; | 2350 | ++count; |
2339 | } | 2351 | } |
2340 | } | 2352 | } |
2341 | inc = incList.next(); | 2353 | inc = incList.next(); |
2342 | } | 2354 | } |
2343 | catList.sort(); | 2355 | catList.sort(); |
2344 | KOPrefs::instance()->mCustomCategories = catList; | 2356 | KOPrefs::instance()->mCustomCategories = catList; |
2345 | return count; | 2357 | return count; |
2346 | } | 2358 | } |
2347 | 2359 | ||
2348 | void CalendarView::manageCategories() | 2360 | void CalendarView::manageCategories() |
2349 | { | 2361 | { |
2350 | KOCatPrefs* cp = new KOCatPrefs(); | 2362 | KOCatPrefs* cp = new KOCatPrefs(); |
2351 | cp->show(); | 2363 | cp->show(); |
2352 | int w =cp->sizeHint().width() ; | 2364 | int w =cp->sizeHint().width() ; |
2353 | int h = cp->sizeHint().height() ; | 2365 | int h = cp->sizeHint().height() ; |
2354 | int dw = QApplication::desktop()->width(); | 2366 | int dw = QApplication::desktop()->width(); |
2355 | int dh = QApplication::desktop()->height(); | 2367 | int dh = QApplication::desktop()->height(); |
2356 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2368 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2357 | if ( !cp->exec() ) { | 2369 | if ( !cp->exec() ) { |
2358 | delete cp; | 2370 | delete cp; |
2359 | return; | 2371 | return; |
2360 | } | 2372 | } |
2361 | int count = 0; | 2373 | int count = 0; |
2362 | if ( cp->addCat() ) { | 2374 | if ( cp->addCat() ) { |
2363 | count = addCategories(); | 2375 | count = addCategories(); |
2364 | if ( count ) { | 2376 | if ( count ) { |
2365 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2377 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2366 | writeSettings(); | 2378 | writeSettings(); |
2367 | } else | 2379 | } else |
2368 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2380 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2369 | } else { | 2381 | } else { |
2370 | removeCategories(); | 2382 | removeCategories(); |
2371 | updateView(); | 2383 | updateView(); |
2372 | } | 2384 | } |
2373 | delete cp; | 2385 | delete cp; |
2374 | } | 2386 | } |
2375 | 2387 | ||
2376 | void CalendarView::beamIncidence(Incidence * Inc) | 2388 | void CalendarView::beamIncidence(Incidence * Inc) |
2377 | { | 2389 | { |
2378 | QPtrList<Incidence> delSel ; | 2390 | QPtrList<Incidence> delSel ; |
2379 | delSel.append(Inc); | 2391 | delSel.append(Inc); |
2380 | beamIncidenceList( delSel ); | 2392 | beamIncidenceList( delSel ); |
2381 | } | 2393 | } |
2382 | void CalendarView::beamCalendar() | 2394 | void CalendarView::beamCalendar() |
2383 | { | 2395 | { |
2384 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2396 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2385 | //qDebug("beamCalendar() "); | 2397 | //qDebug("beamCalendar() "); |
2386 | beamIncidenceList( delSel ); | 2398 | beamIncidenceList( delSel ); |
2387 | } | 2399 | } |
2388 | void CalendarView::beamFilteredCalendar() | 2400 | void CalendarView::beamFilteredCalendar() |
2389 | { | 2401 | { |
2390 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2402 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2391 | //qDebug("beamFilteredCalendar() "); | 2403 | //qDebug("beamFilteredCalendar() "); |
2392 | beamIncidenceList( delSel ); | 2404 | beamIncidenceList( delSel ); |
2393 | } | 2405 | } |
2394 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2406 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2395 | { | 2407 | { |
2396 | if ( beamDialog->exec () == QDialog::Rejected ) | 2408 | if ( beamDialog->exec () == QDialog::Rejected ) |
2397 | return; | 2409 | return; |
2398 | #ifdef DESKTOP_VERSION | 2410 | #ifdef DESKTOP_VERSION |
2399 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2411 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2400 | #else | 2412 | #else |
2401 | QString fn = "/tmp/kopibeamfile"; | 2413 | QString fn = "/tmp/kopibeamfile"; |
2402 | #endif | 2414 | #endif |
@@ -3685,228 +3697,228 @@ void CalendarView::toggleAllDaySize() | |||
3685 | void CalendarView::toggleExpand() | 3697 | void CalendarView::toggleExpand() |
3686 | { | 3698 | { |
3687 | // if ( mLeftFrame->isHidden() ) { | 3699 | // if ( mLeftFrame->isHidden() ) { |
3688 | // mLeftFrame->show(); | 3700 | // mLeftFrame->show(); |
3689 | // emit calendarViewExpanded( false ); | 3701 | // emit calendarViewExpanded( false ); |
3690 | // } else { | 3702 | // } else { |
3691 | // mLeftFrame->hide(); | 3703 | // mLeftFrame->hide(); |
3692 | // emit calendarViewExpanded( true ); | 3704 | // emit calendarViewExpanded( true ); |
3693 | // } | 3705 | // } |
3694 | //qDebug(" CalendarView::toggleExpand()"); | 3706 | //qDebug(" CalendarView::toggleExpand()"); |
3695 | globalFlagBlockAgenda = 1; | 3707 | globalFlagBlockAgenda = 1; |
3696 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3708 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3697 | globalFlagBlockAgenda = 5; | 3709 | globalFlagBlockAgenda = 5; |
3698 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3710 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3699 | //mViewManager->showView( 0, true ); | 3711 | //mViewManager->showView( 0, true ); |
3700 | } | 3712 | } |
3701 | 3713 | ||
3702 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3714 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3703 | { | 3715 | { |
3704 | setModified( modified ); | 3716 | setModified( modified ); |
3705 | } | 3717 | } |
3706 | 3718 | ||
3707 | Todo *CalendarView::selectedTodo() | 3719 | Todo *CalendarView::selectedTodo() |
3708 | { | 3720 | { |
3709 | Incidence *incidence = currentSelection(); | 3721 | Incidence *incidence = currentSelection(); |
3710 | if ( incidence && incidence->type() == "Todo" ) { | 3722 | if ( incidence && incidence->type() == "Todo" ) { |
3711 | return static_cast<Todo *>( incidence ); | 3723 | return static_cast<Todo *>( incidence ); |
3712 | } | 3724 | } |
3713 | 3725 | ||
3714 | incidence = mTodoList->selectedIncidences().first(); | 3726 | incidence = mTodoList->selectedIncidences().first(); |
3715 | if ( incidence && incidence->type() == "Todo" ) { | 3727 | if ( incidence && incidence->type() == "Todo" ) { |
3716 | return static_cast<Todo *>( incidence ); | 3728 | return static_cast<Todo *>( incidence ); |
3717 | } | 3729 | } |
3718 | 3730 | ||
3719 | return 0; | 3731 | return 0; |
3720 | } | 3732 | } |
3721 | 3733 | ||
3722 | void CalendarView::dialogClosing(Incidence *in) | 3734 | void CalendarView::dialogClosing(Incidence *in) |
3723 | { | 3735 | { |
3724 | // mDialogList.remove(in); | 3736 | // mDialogList.remove(in); |
3725 | } | 3737 | } |
3726 | 3738 | ||
3727 | void CalendarView::showIncidence() | 3739 | void CalendarView::showIncidence() |
3728 | { | 3740 | { |
3729 | Incidence *incidence = currentSelection(); | 3741 | Incidence *incidence = currentSelection(); |
3730 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3742 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3731 | if ( incidence ) { | 3743 | if ( incidence ) { |
3732 | ShowIncidenceVisitor v; | 3744 | ShowIncidenceVisitor v; |
3733 | v.act( incidence, this ); | 3745 | v.act( incidence, this ); |
3734 | } | 3746 | } |
3735 | } | 3747 | } |
3736 | void CalendarView::editIncidenceDescription() | 3748 | void CalendarView::editIncidenceDescription() |
3737 | { | 3749 | { |
3738 | mFlagEditDescription = true; | 3750 | mFlagEditDescription = true; |
3739 | editIncidence(); | 3751 | editIncidence(); |
3740 | mFlagEditDescription = false; | 3752 | mFlagEditDescription = false; |
3741 | } | 3753 | } |
3742 | void CalendarView::editIncidence() | 3754 | void CalendarView::editIncidence() |
3743 | { | 3755 | { |
3744 | // qDebug("editIncidence() "); | 3756 | // qDebug("editIncidence() "); |
3745 | Incidence *incidence = currentSelection(); | 3757 | Incidence *incidence = currentSelection(); |
3746 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3758 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3747 | if ( incidence ) { | 3759 | if ( incidence ) { |
3748 | EditIncidenceVisitor v; | 3760 | EditIncidenceVisitor v; |
3749 | v.act( incidence, this ); | 3761 | v.act( incidence, this ); |
3750 | } | 3762 | } |
3751 | } | 3763 | } |
3752 | 3764 | ||
3753 | void CalendarView::deleteIncidence() | 3765 | void CalendarView::deleteIncidence() |
3754 | { | 3766 | { |
3755 | Incidence *incidence = currentSelection(); | 3767 | Incidence *incidence = currentSelection(); |
3756 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3768 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3757 | if ( incidence ) { | 3769 | if ( incidence ) { |
3758 | deleteIncidence(incidence); | 3770 | deleteIncidence(incidence); |
3759 | } | 3771 | } |
3760 | } | 3772 | } |
3761 | 3773 | ||
3762 | void CalendarView::showIncidence(Incidence *incidence) | 3774 | void CalendarView::showIncidence(Incidence *incidence) |
3763 | { | 3775 | { |
3764 | if ( incidence ) { | 3776 | if ( incidence ) { |
3765 | ShowIncidenceVisitor v; | 3777 | ShowIncidenceVisitor v; |
3766 | v.act( incidence, this ); | 3778 | v.act( incidence, this ); |
3767 | } | 3779 | } |
3768 | } | 3780 | } |
3769 | 3781 | ||
3770 | void CalendarView::editIncidence(Incidence *incidence) | 3782 | void CalendarView::editIncidence(Incidence *incidence) |
3771 | { | 3783 | { |
3772 | if ( incidence ) { | 3784 | if ( incidence ) { |
3773 | 3785 | ||
3774 | EditIncidenceVisitor v; | 3786 | EditIncidenceVisitor v; |
3775 | v.act( incidence, this ); | 3787 | v.act( incidence, this ); |
3776 | 3788 | ||
3777 | } | 3789 | } |
3778 | } | 3790 | } |
3779 | 3791 | ||
3780 | void CalendarView::deleteIncidence(Incidence *incidence) | 3792 | void CalendarView::deleteIncidence(Incidence *incidence) |
3781 | { | 3793 | { |
3782 | //qDebug(" CalendarView::deleteIncidence "); | 3794 | //qDebug(" CalendarView::deleteIncidence "); |
3783 | if ( incidence ) { | 3795 | if ( incidence ) { |
3784 | DeleteIncidenceVisitor v; | 3796 | DeleteIncidenceVisitor v; |
3785 | v.act( incidence, this ); | 3797 | v.act( incidence, this ); |
3786 | } | 3798 | } |
3787 | } | 3799 | } |
3788 | 3800 | ||
3789 | 3801 | ||
3790 | void CalendarView::lookForOutgoingMessages() | 3802 | void CalendarView::lookForOutgoingMessages() |
3791 | { | 3803 | { |
3792 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3804 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3793 | ogd->loadMessages(); | 3805 | ogd->loadMessages(); |
3794 | } | 3806 | } |
3795 | 3807 | ||
3796 | void CalendarView::lookForIncomingMessages() | 3808 | void CalendarView::lookForIncomingMessages() |
3797 | { | 3809 | { |
3798 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3810 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3799 | icd->retrieve(); | 3811 | icd->retrieve(); |
3800 | } | 3812 | } |
3801 | 3813 | ||
3802 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3814 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3803 | { | 3815 | { |
3804 | bool deleteTodo = true; | 3816 | bool deleteTodo = true; |
3805 | QPtrList<Incidence> subTodos; | 3817 | QPtrList<Incidence> subTodos; |
3806 | Incidence *aTodo; | 3818 | Incidence *aTodo; |
3807 | subTodos = t->relations(); | 3819 | subTodos = t->relations(); |
3808 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3820 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3809 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3821 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3810 | deleteTodo = false; | 3822 | deleteTodo = false; |
3811 | } | 3823 | } |
3812 | if ( deleteTodo ) { | 3824 | if ( deleteTodo ) { |
3813 | if ( t->isCompleted() ) { | 3825 | if ( t->isCompleted() && !t->doesRecur()) { |
3814 | checkExternalId( t ); | 3826 | checkExternalId( t ); |
3815 | mCalendar->deleteTodo( t ); | 3827 | mCalendar->deleteTodo( t ); |
3816 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3828 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3817 | } | 3829 | } |
3818 | else | 3830 | else |
3819 | deleteTodo = false; | 3831 | deleteTodo = false; |
3820 | } | 3832 | } |
3821 | return deleteTodo; | 3833 | return deleteTodo; |
3822 | 3834 | ||
3823 | } | 3835 | } |
3824 | void CalendarView::purgeCompleted() | 3836 | void CalendarView::purgeCompleted() |
3825 | { | 3837 | { |
3826 | int result = KMessageBox::warningContinueCancel(this, | 3838 | int result = KMessageBox::warningContinueCancel(this, |
3827 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3839 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3828 | 3840 | ||
3829 | if (result == KMessageBox::Continue) { | 3841 | if (result == KMessageBox::Continue) { |
3830 | 3842 | ||
3831 | QPtrList<Todo> todoCal; | 3843 | QPtrList<Todo> todoCal; |
3832 | QPtrList<Todo> rootTodos; | 3844 | QPtrList<Todo> rootTodos; |
3833 | //QPtrList<Incidence> rel; | 3845 | //QPtrList<Incidence> rel; |
3834 | Todo *aTodo;//, *rTodo; | 3846 | Todo *aTodo;//, *rTodo; |
3835 | Incidence *rIncidence; | 3847 | Incidence *rIncidence; |
3836 | bool childDelete = false; | 3848 | bool childDelete = false; |
3837 | bool deletedOne = true; | 3849 | bool deletedOne = true; |
3838 | todoCal = calendar()->todos(); | 3850 | todoCal = calendar()->todos(); |
3839 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3851 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3840 | if ( !aTodo->relatedTo() ) | 3852 | if ( !aTodo->relatedTo() ) |
3841 | rootTodos.append( aTodo ); | 3853 | rootTodos.append( aTodo ); |
3842 | } | 3854 | } |
3843 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3855 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3844 | removeCompletedSubTodos( aTodo ); | 3856 | removeCompletedSubTodos( aTodo ); |
3845 | } | 3857 | } |
3846 | 3858 | ||
3847 | updateView(); | 3859 | updateView(); |
3848 | } | 3860 | } |
3849 | } | 3861 | } |
3850 | 3862 | ||
3851 | void CalendarView::slotCalendarChanged() | 3863 | void CalendarView::slotCalendarChanged() |
3852 | { | 3864 | { |
3853 | ; | 3865 | ; |
3854 | } | 3866 | } |
3855 | 3867 | ||
3856 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3868 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3857 | { | 3869 | { |
3858 | //qDebug(" alendarView::keyPressEvent "); | 3870 | //qDebug(" alendarView::keyPressEvent "); |
3859 | e->ignore(); | 3871 | e->ignore(); |
3860 | } | 3872 | } |
3861 | 3873 | ||
3862 | 3874 | ||
3863 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3875 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3864 | { | 3876 | { |
3865 | // mSyncManager = manager; | 3877 | // mSyncManager = manager; |
3866 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3878 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3867 | qDebug("KO: SyncKDE request detected!"); | 3879 | qDebug("KO: SyncKDE request detected!"); |
3868 | } | 3880 | } |
3869 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3881 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3870 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3882 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3871 | return syncCalendar( filename, mode ); | 3883 | return syncCalendar( filename, mode ); |
3872 | } | 3884 | } |
3873 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3885 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3874 | { | 3886 | { |
3875 | //mSyncManager = manager; | 3887 | //mSyncManager = manager; |
3876 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3888 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3877 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3889 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3878 | if ( resource == "sharp" ) | 3890 | if ( resource == "sharp" ) |
3879 | syncExternal( 0 ); | 3891 | syncExternal( 0 ); |
3880 | if ( resource == "phone" ) | 3892 | if ( resource == "phone" ) |
3881 | syncExternal( 1 ); | 3893 | syncExternal( 1 ); |
3882 | // pending setmodified | 3894 | // pending setmodified |
3883 | return true; | 3895 | return true; |
3884 | } | 3896 | } |
3885 | void CalendarView::setSyncManager(KSyncManager* manager) | 3897 | void CalendarView::setSyncManager(KSyncManager* manager) |
3886 | { | 3898 | { |
3887 | mSyncManager = manager; | 3899 | mSyncManager = manager; |
3888 | } | 3900 | } |
3889 | 3901 | ||
3890 | void CalendarView::removeSyncInfo( QString syncProfile) | 3902 | void CalendarView::removeSyncInfo( QString syncProfile) |
3891 | { | 3903 | { |
3892 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 3904 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
3893 | mCalendar->removeSyncInfo( syncProfile ); | 3905 | mCalendar->removeSyncInfo( syncProfile ); |
3894 | 3906 | ||
3895 | } | 3907 | } |
3896 | 3908 | ||
3897 | void CalendarView::undo_delete() | 3909 | void CalendarView::undo_delete() |
3898 | { | 3910 | { |
3899 | //qDebug("undo_delete() "); | 3911 | //qDebug("undo_delete() "); |
3900 | Incidence* undo = mCalendar->undoIncidence(); | 3912 | Incidence* undo = mCalendar->undoIncidence(); |
3901 | if ( !undo ) { | 3913 | if ( !undo ) { |
3902 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3914 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3903 | i18n("KO/Pi")); | 3915 | i18n("KO/Pi")); |
3904 | return; | 3916 | return; |
3905 | } | 3917 | } |
3906 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3918 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3907 | i18n("\nAre you sure you want\nto restore this?"), | 3919 | i18n("\nAre you sure you want\nto restore this?"), |
3908 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3920 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3909 | mCalendar->undoDeleteIncidence(); | 3921 | mCalendar->undoDeleteIncidence(); |
3910 | updateView(); | 3922 | updateView(); |
3911 | } | 3923 | } |
3912 | } | 3924 | } |