author | zautrix <zautrix> | 2005-01-30 15:38:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-30 15:38:08 (UTC) |
commit | 11736af9b5348f251b0e8a3cf90fdb960c877936 (patch) (unidiff) | |
tree | eda181731c3dd76cb448d103b8d8f9d30757450c | |
parent | 8d543aa1d1d1ed20001c8b18352d1d29c2979e48 (diff) | |
download | kdepimpi-11736af9b5348f251b0e8a3cf90fdb960c877936.zip kdepimpi-11736af9b5348f251b0e8a3cf90fdb960c877936.tar.gz kdepimpi-11736af9b5348f251b0e8a3cf90fdb960c877936.tar.bz2 |
fix
-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/datenavigator.cpp | 3 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 9 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 4 |
4 files changed, 8 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 96fb5ca..db33017 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2156,1762 +2156,1762 @@ void CalendarView::changeEventDisplay(Event *which, int action) | |||
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.cutIncidence(anEvent); | 2217 | factory.cutIncidence(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.copyIncidence(anEvent); | 2238 | factory.copyIncidence(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 = (Event *)factory.pasteIncidence( date ); | 2246 | Event *pastedEvent = (Event *)factory.pasteIncidence( 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(),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 | ||
3488 | 3488 | ||
3489 | if ( !mBlockShowDates ) { | 3489 | if ( !mBlockShowDates ) { |
3490 | if ( mViewManager->currentView() ) { | 3490 | if ( mViewManager->currentView() ) { |
3491 | updateView( selectedDates.first(), selectedDates.last() ); | 3491 | updateView( selectedDates.first(), selectedDates.last() ); |
3492 | } else { | 3492 | } else { |
3493 | mViewManager->showAgendaView(); | 3493 | mViewManager->showAgendaView(); |
3494 | } | 3494 | } |
3495 | } | 3495 | } |
3496 | 3496 | ||
3497 | QString selDates; | 3497 | QString selDates; |
3498 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3498 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3499 | if (selectedDates.first() < selectedDates.last() ) | 3499 | if (selectedDates.first() < selectedDates.last() ) |
3500 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3500 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3501 | else { | 3501 | else { |
3502 | QString addString; | 3502 | QString addString; |
3503 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3503 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3504 | addString = i18n("Today"); | 3504 | addString = i18n("Today"); |
3505 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3505 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3506 | addString = i18n("Tomorrow"); | 3506 | addString = i18n("Tomorrow"); |
3507 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3507 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3508 | addString = i18n("Yesterday"); | 3508 | addString = i18n("Yesterday"); |
3509 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3509 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3510 | addString = i18n("Day before yesterday"); | 3510 | addString = i18n("Day before yesterday"); |
3511 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3511 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3512 | addString = i18n("Day after tomorrow"); | 3512 | addString = i18n("Day after tomorrow"); |
3513 | if ( !addString.isEmpty() ) { | 3513 | if ( !addString.isEmpty() ) { |
3514 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3514 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3515 | return; | 3515 | return; |
3516 | } | 3516 | } |
3517 | } | 3517 | } |
3518 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3518 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3519 | 3519 | ||
3520 | } | 3520 | } |
3521 | 3521 | ||
3522 | QPtrList<CalFilter> CalendarView::filters() | 3522 | QPtrList<CalFilter> CalendarView::filters() |
3523 | { | 3523 | { |
3524 | return mFilters; | 3524 | return mFilters; |
3525 | 3525 | ||
3526 | } | 3526 | } |
3527 | void CalendarView::editFilters() | 3527 | void CalendarView::editFilters() |
3528 | { | 3528 | { |
3529 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3529 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3530 | 3530 | ||
3531 | CalFilter *filter = mFilters.first(); | 3531 | CalFilter *filter = mFilters.first(); |
3532 | while(filter) { | 3532 | while(filter) { |
3533 | kdDebug() << " Filter: " << filter->name() << endl; | 3533 | kdDebug() << " Filter: " << filter->name() << endl; |
3534 | filter = mFilters.next(); | 3534 | filter = mFilters.next(); |
3535 | } | 3535 | } |
3536 | 3536 | ||
3537 | mDialogManager->showFilterEditDialog(&mFilters); | 3537 | mDialogManager->showFilterEditDialog(&mFilters); |
3538 | } | 3538 | } |
3539 | void CalendarView::toggleFilter() | 3539 | void CalendarView::toggleFilter() |
3540 | { | 3540 | { |
3541 | showFilter(! mFilterView->isVisible()); | 3541 | showFilter(! mFilterView->isVisible()); |
3542 | } | 3542 | } |
3543 | 3543 | ||
3544 | KOFilterView *CalendarView::filterView() | 3544 | KOFilterView *CalendarView::filterView() |
3545 | { | 3545 | { |
3546 | return mFilterView; | 3546 | return mFilterView; |
3547 | } | 3547 | } |
3548 | void CalendarView::selectFilter( int fil ) | 3548 | void CalendarView::selectFilter( int fil ) |
3549 | { | 3549 | { |
3550 | mFilterView->setSelectedFilter( fil ); | 3550 | mFilterView->setSelectedFilter( fil ); |
3551 | } | 3551 | } |
3552 | void CalendarView::showFilter(bool visible) | 3552 | void CalendarView::showFilter(bool visible) |
3553 | { | 3553 | { |
3554 | if (visible) mFilterView->show(); | 3554 | if (visible) mFilterView->show(); |
3555 | else mFilterView->hide(); | 3555 | else mFilterView->hide(); |
3556 | } | 3556 | } |
3557 | void CalendarView::toggleFilerEnabled( ) | 3557 | void CalendarView::toggleFilerEnabled( ) |
3558 | { | 3558 | { |
3559 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3559 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3560 | if ( !mFilterView->filtersEnabled() ) | 3560 | if ( !mFilterView->filtersEnabled() ) |
3561 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3561 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3562 | 3562 | ||
3563 | } | 3563 | } |
3564 | void CalendarView::updateFilter() | 3564 | void CalendarView::updateFilter() |
3565 | { | 3565 | { |
3566 | CalFilter *filter = mFilterView->selectedFilter(); | 3566 | CalFilter *filter = mFilterView->selectedFilter(); |
3567 | if (filter) { | 3567 | if (filter) { |
3568 | if (mFilterView->filtersEnabled()) { | 3568 | if (mFilterView->filtersEnabled()) { |
3569 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3569 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3570 | filter->setEnabled(true); | 3570 | filter->setEnabled(true); |
3571 | } | 3571 | } |
3572 | else filter->setEnabled(false); | 3572 | else filter->setEnabled(false); |
3573 | mCalendar->setFilter(filter); | 3573 | mCalendar->setFilter(filter); |
3574 | updateView(); | 3574 | updateView(); |
3575 | } | 3575 | } |
3576 | } | 3576 | } |
3577 | 3577 | ||
3578 | void CalendarView::filterEdited() | 3578 | void CalendarView::filterEdited() |
3579 | { | 3579 | { |
3580 | mFilterView->updateFilters(); | 3580 | mFilterView->updateFilters(); |
3581 | updateFilter(); | 3581 | updateFilter(); |
3582 | writeSettings(); | 3582 | writeSettings(); |
3583 | } | 3583 | } |
3584 | 3584 | ||
3585 | 3585 | ||
3586 | void CalendarView::takeOverEvent() | 3586 | void CalendarView::takeOverEvent() |
3587 | { | 3587 | { |
3588 | Incidence *incidence = currentSelection(); | 3588 | Incidence *incidence = currentSelection(); |
3589 | 3589 | ||
3590 | if (!incidence) return; | 3590 | if (!incidence) return; |
3591 | 3591 | ||
3592 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3592 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3593 | incidence->recreate(); | 3593 | incidence->recreate(); |
3594 | incidence->setReadOnly(false); | 3594 | incidence->setReadOnly(false); |
3595 | 3595 | ||
3596 | updateView(); | 3596 | updateView(); |
3597 | } | 3597 | } |
3598 | 3598 | ||
3599 | void CalendarView::takeOverCalendar() | 3599 | void CalendarView::takeOverCalendar() |
3600 | { | 3600 | { |
3601 | // TODO: Create Calendar::allIncidences() function and use it here | 3601 | // TODO: Create Calendar::allIncidences() function and use it here |
3602 | 3602 | ||
3603 | QPtrList<Event> events = mCalendar->events(); | 3603 | QPtrList<Event> events = mCalendar->events(); |
3604 | for(uint i=0; i<events.count(); ++i) { | 3604 | for(uint i=0; i<events.count(); ++i) { |
3605 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3605 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3606 | events.at(i)->recreate(); | 3606 | events.at(i)->recreate(); |
3607 | events.at(i)->setReadOnly(false); | 3607 | events.at(i)->setReadOnly(false); |
3608 | } | 3608 | } |
3609 | 3609 | ||
3610 | QPtrList<Todo> todos = mCalendar->todos(); | 3610 | QPtrList<Todo> todos = mCalendar->todos(); |
3611 | for(uint i=0; i<todos.count(); ++i) { | 3611 | for(uint i=0; i<todos.count(); ++i) { |
3612 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3612 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3613 | todos.at(i)->recreate(); | 3613 | todos.at(i)->recreate(); |
3614 | todos.at(i)->setReadOnly(false); | 3614 | todos.at(i)->setReadOnly(false); |
3615 | } | 3615 | } |
3616 | 3616 | ||
3617 | QPtrList<Journal> journals = mCalendar->journals(); | 3617 | QPtrList<Journal> journals = mCalendar->journals(); |
3618 | for(uint i=0; i<journals.count(); ++i) { | 3618 | for(uint i=0; i<journals.count(); ++i) { |
3619 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3619 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3620 | journals.at(i)->recreate(); | 3620 | journals.at(i)->recreate(); |
3621 | journals.at(i)->setReadOnly(false); | 3621 | journals.at(i)->setReadOnly(false); |
3622 | } | 3622 | } |
3623 | 3623 | ||
3624 | updateView(); | 3624 | updateView(); |
3625 | } | 3625 | } |
3626 | 3626 | ||
3627 | void CalendarView::showIntro() | 3627 | void CalendarView::showIntro() |
3628 | { | 3628 | { |
3629 | kdDebug() << "To be implemented." << endl; | 3629 | kdDebug() << "To be implemented." << endl; |
3630 | } | 3630 | } |
3631 | 3631 | ||
3632 | QWidgetStack *CalendarView::viewStack() | 3632 | QWidgetStack *CalendarView::viewStack() |
3633 | { | 3633 | { |
3634 | return mRightFrame; | 3634 | return mRightFrame; |
3635 | } | 3635 | } |
3636 | 3636 | ||
3637 | QWidget *CalendarView::leftFrame() | 3637 | QWidget *CalendarView::leftFrame() |
3638 | { | 3638 | { |
3639 | return mLeftFrame; | 3639 | return mLeftFrame; |
3640 | } | 3640 | } |
3641 | 3641 | ||
3642 | DateNavigator *CalendarView::dateNavigator() | 3642 | DateNavigator *CalendarView::dateNavigator() |
3643 | { | 3643 | { |
3644 | return mNavigator; | 3644 | return mNavigator; |
3645 | } | 3645 | } |
3646 | 3646 | ||
3647 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3647 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3648 | { | 3648 | { |
3649 | return mDateNavigator; | 3649 | return mDateNavigator; |
3650 | } | 3650 | } |
3651 | void CalendarView::toggleDateNavigatorWidget() | 3651 | void CalendarView::toggleDateNavigatorWidget() |
3652 | { | 3652 | { |
3653 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3653 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3654 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3654 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3655 | mDateNavigator->hide(); | 3655 | mDateNavigator->hide(); |
3656 | else | 3656 | else |
3657 | mDateNavigator->show(); | 3657 | mDateNavigator->show(); |
3658 | } | 3658 | } |
3659 | void CalendarView::addView(KOrg::BaseView *view) | 3659 | void CalendarView::addView(KOrg::BaseView *view) |
3660 | { | 3660 | { |
3661 | mViewManager->addView(view); | 3661 | mViewManager->addView(view); |
3662 | } | 3662 | } |
3663 | 3663 | ||
3664 | void CalendarView::showView(KOrg::BaseView *view) | 3664 | void CalendarView::showView(KOrg::BaseView *view) |
3665 | { | 3665 | { |
3666 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3666 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3667 | } | 3667 | } |
3668 | 3668 | ||
3669 | Incidence *CalendarView::currentSelection() | 3669 | Incidence *CalendarView::currentSelection() |
3670 | { | 3670 | { |
3671 | return mViewManager->currentSelection(); | 3671 | return mViewManager->currentSelection(); |
3672 | } | 3672 | } |
3673 | void CalendarView::toggleAllDaySize() | 3673 | void CalendarView::toggleAllDaySize() |
3674 | { | 3674 | { |
3675 | /* | 3675 | /* |
3676 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3676 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3677 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3677 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3678 | else | 3678 | else |
3679 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3679 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3680 | */ | 3680 | */ |
3681 | viewManager()->agendaView()->toggleAllDay(); | 3681 | viewManager()->agendaView()->toggleAllDay(); |
3682 | } | 3682 | } |
3683 | void CalendarView::toggleExpand() | 3683 | void CalendarView::toggleExpand() |
3684 | { | 3684 | { |
3685 | // if ( mLeftFrame->isHidden() ) { | 3685 | // if ( mLeftFrame->isHidden() ) { |
3686 | // mLeftFrame->show(); | 3686 | // mLeftFrame->show(); |
3687 | // emit calendarViewExpanded( false ); | 3687 | // emit calendarViewExpanded( false ); |
3688 | // } else { | 3688 | // } else { |
3689 | // mLeftFrame->hide(); | 3689 | // mLeftFrame->hide(); |
3690 | // emit calendarViewExpanded( true ); | 3690 | // emit calendarViewExpanded( true ); |
3691 | // } | 3691 | // } |
3692 | 3692 | //qDebug(" CalendarView::toggleExpand()"); | |
3693 | globalFlagBlockAgenda = 1; | 3693 | globalFlagBlockAgenda = 1; |
3694 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3694 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3695 | globalFlagBlockAgenda = 5; | 3695 | globalFlagBlockAgenda = 5; |
3696 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3696 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3697 | //mViewManager->showView( 0, true ); | 3697 | //mViewManager->showView( 0, true ); |
3698 | } | 3698 | } |
3699 | 3699 | ||
3700 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3700 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3701 | { | 3701 | { |
3702 | setModified( modified ); | 3702 | setModified( modified ); |
3703 | } | 3703 | } |
3704 | 3704 | ||
3705 | Todo *CalendarView::selectedTodo() | 3705 | Todo *CalendarView::selectedTodo() |
3706 | { | 3706 | { |
3707 | Incidence *incidence = currentSelection(); | 3707 | Incidence *incidence = currentSelection(); |
3708 | if ( incidence && incidence->type() == "Todo" ) { | 3708 | if ( incidence && incidence->type() == "Todo" ) { |
3709 | return static_cast<Todo *>( incidence ); | 3709 | return static_cast<Todo *>( incidence ); |
3710 | } | 3710 | } |
3711 | 3711 | ||
3712 | incidence = mTodoList->selectedIncidences().first(); | 3712 | incidence = mTodoList->selectedIncidences().first(); |
3713 | if ( incidence && incidence->type() == "Todo" ) { | 3713 | if ( incidence && incidence->type() == "Todo" ) { |
3714 | return static_cast<Todo *>( incidence ); | 3714 | return static_cast<Todo *>( incidence ); |
3715 | } | 3715 | } |
3716 | 3716 | ||
3717 | return 0; | 3717 | return 0; |
3718 | } | 3718 | } |
3719 | 3719 | ||
3720 | void CalendarView::dialogClosing(Incidence *in) | 3720 | void CalendarView::dialogClosing(Incidence *in) |
3721 | { | 3721 | { |
3722 | // mDialogList.remove(in); | 3722 | // mDialogList.remove(in); |
3723 | } | 3723 | } |
3724 | 3724 | ||
3725 | void CalendarView::showIncidence() | 3725 | void CalendarView::showIncidence() |
3726 | { | 3726 | { |
3727 | Incidence *incidence = currentSelection(); | 3727 | Incidence *incidence = currentSelection(); |
3728 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3728 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3729 | if ( incidence ) { | 3729 | if ( incidence ) { |
3730 | ShowIncidenceVisitor v; | 3730 | ShowIncidenceVisitor v; |
3731 | v.act( incidence, this ); | 3731 | v.act( incidence, this ); |
3732 | } | 3732 | } |
3733 | } | 3733 | } |
3734 | void CalendarView::editIncidenceDescription() | 3734 | void CalendarView::editIncidenceDescription() |
3735 | { | 3735 | { |
3736 | mFlagEditDescription = true; | 3736 | mFlagEditDescription = true; |
3737 | editIncidence(); | 3737 | editIncidence(); |
3738 | mFlagEditDescription = false; | 3738 | mFlagEditDescription = false; |
3739 | } | 3739 | } |
3740 | void CalendarView::editIncidence() | 3740 | void CalendarView::editIncidence() |
3741 | { | 3741 | { |
3742 | // qDebug("editIncidence() "); | 3742 | // qDebug("editIncidence() "); |
3743 | Incidence *incidence = currentSelection(); | 3743 | Incidence *incidence = currentSelection(); |
3744 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3744 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3745 | if ( incidence ) { | 3745 | if ( incidence ) { |
3746 | EditIncidenceVisitor v; | 3746 | EditIncidenceVisitor v; |
3747 | v.act( incidence, this ); | 3747 | v.act( incidence, this ); |
3748 | } | 3748 | } |
3749 | } | 3749 | } |
3750 | 3750 | ||
3751 | void CalendarView::deleteIncidence() | 3751 | void CalendarView::deleteIncidence() |
3752 | { | 3752 | { |
3753 | Incidence *incidence = currentSelection(); | 3753 | Incidence *incidence = currentSelection(); |
3754 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3754 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3755 | if ( incidence ) { | 3755 | if ( incidence ) { |
3756 | deleteIncidence(incidence); | 3756 | deleteIncidence(incidence); |
3757 | } | 3757 | } |
3758 | } | 3758 | } |
3759 | 3759 | ||
3760 | void CalendarView::showIncidence(Incidence *incidence) | 3760 | void CalendarView::showIncidence(Incidence *incidence) |
3761 | { | 3761 | { |
3762 | if ( incidence ) { | 3762 | if ( incidence ) { |
3763 | ShowIncidenceVisitor v; | 3763 | ShowIncidenceVisitor v; |
3764 | v.act( incidence, this ); | 3764 | v.act( incidence, this ); |
3765 | } | 3765 | } |
3766 | } | 3766 | } |
3767 | 3767 | ||
3768 | void CalendarView::editIncidence(Incidence *incidence) | 3768 | void CalendarView::editIncidence(Incidence *incidence) |
3769 | { | 3769 | { |
3770 | if ( incidence ) { | 3770 | if ( incidence ) { |
3771 | 3771 | ||
3772 | EditIncidenceVisitor v; | 3772 | EditIncidenceVisitor v; |
3773 | v.act( incidence, this ); | 3773 | v.act( incidence, this ); |
3774 | 3774 | ||
3775 | } | 3775 | } |
3776 | } | 3776 | } |
3777 | 3777 | ||
3778 | void CalendarView::deleteIncidence(Incidence *incidence) | 3778 | void CalendarView::deleteIncidence(Incidence *incidence) |
3779 | { | 3779 | { |
3780 | //qDebug(" CalendarView::deleteIncidence "); | 3780 | //qDebug(" CalendarView::deleteIncidence "); |
3781 | if ( incidence ) { | 3781 | if ( incidence ) { |
3782 | DeleteIncidenceVisitor v; | 3782 | DeleteIncidenceVisitor v; |
3783 | v.act( incidence, this ); | 3783 | v.act( incidence, this ); |
3784 | } | 3784 | } |
3785 | } | 3785 | } |
3786 | 3786 | ||
3787 | 3787 | ||
3788 | void CalendarView::lookForOutgoingMessages() | 3788 | void CalendarView::lookForOutgoingMessages() |
3789 | { | 3789 | { |
3790 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3790 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3791 | ogd->loadMessages(); | 3791 | ogd->loadMessages(); |
3792 | } | 3792 | } |
3793 | 3793 | ||
3794 | void CalendarView::lookForIncomingMessages() | 3794 | void CalendarView::lookForIncomingMessages() |
3795 | { | 3795 | { |
3796 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3796 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3797 | icd->retrieve(); | 3797 | icd->retrieve(); |
3798 | } | 3798 | } |
3799 | 3799 | ||
3800 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3800 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3801 | { | 3801 | { |
3802 | bool deleteTodo = true; | 3802 | bool deleteTodo = true; |
3803 | QPtrList<Incidence> subTodos; | 3803 | QPtrList<Incidence> subTodos; |
3804 | Incidence *aTodo; | 3804 | Incidence *aTodo; |
3805 | subTodos = t->relations(); | 3805 | subTodos = t->relations(); |
3806 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3806 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3807 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3807 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3808 | deleteTodo = false; | 3808 | deleteTodo = false; |
3809 | } | 3809 | } |
3810 | if ( deleteTodo ) { | 3810 | if ( deleteTodo ) { |
3811 | if ( t->isCompleted() ) { | 3811 | if ( t->isCompleted() ) { |
3812 | checkExternalId( t ); | 3812 | checkExternalId( t ); |
3813 | mCalendar->deleteTodo( t ); | 3813 | mCalendar->deleteTodo( t ); |
3814 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3814 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3815 | } | 3815 | } |
3816 | else | 3816 | else |
3817 | deleteTodo = false; | 3817 | deleteTodo = false; |
3818 | } | 3818 | } |
3819 | return deleteTodo; | 3819 | return deleteTodo; |
3820 | 3820 | ||
3821 | } | 3821 | } |
3822 | void CalendarView::purgeCompleted() | 3822 | void CalendarView::purgeCompleted() |
3823 | { | 3823 | { |
3824 | int result = KMessageBox::warningContinueCancel(this, | 3824 | int result = KMessageBox::warningContinueCancel(this, |
3825 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3825 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3826 | 3826 | ||
3827 | if (result == KMessageBox::Continue) { | 3827 | if (result == KMessageBox::Continue) { |
3828 | 3828 | ||
3829 | QPtrList<Todo> todoCal; | 3829 | QPtrList<Todo> todoCal; |
3830 | QPtrList<Todo> rootTodos; | 3830 | QPtrList<Todo> rootTodos; |
3831 | //QPtrList<Incidence> rel; | 3831 | //QPtrList<Incidence> rel; |
3832 | Todo *aTodo;//, *rTodo; | 3832 | Todo *aTodo;//, *rTodo; |
3833 | Incidence *rIncidence; | 3833 | Incidence *rIncidence; |
3834 | bool childDelete = false; | 3834 | bool childDelete = false; |
3835 | bool deletedOne = true; | 3835 | bool deletedOne = true; |
3836 | todoCal = calendar()->todos(); | 3836 | todoCal = calendar()->todos(); |
3837 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3837 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3838 | if ( !aTodo->relatedTo() ) | 3838 | if ( !aTodo->relatedTo() ) |
3839 | rootTodos.append( aTodo ); | 3839 | rootTodos.append( aTodo ); |
3840 | } | 3840 | } |
3841 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3841 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3842 | removeCompletedSubTodos( aTodo ); | 3842 | removeCompletedSubTodos( aTodo ); |
3843 | } | 3843 | } |
3844 | 3844 | ||
3845 | updateView(); | 3845 | updateView(); |
3846 | } | 3846 | } |
3847 | } | 3847 | } |
3848 | 3848 | ||
3849 | void CalendarView::slotCalendarChanged() | 3849 | void CalendarView::slotCalendarChanged() |
3850 | { | 3850 | { |
3851 | ; | 3851 | ; |
3852 | } | 3852 | } |
3853 | 3853 | ||
3854 | NavigatorBar *CalendarView::navigatorBar() | 3854 | NavigatorBar *CalendarView::navigatorBar() |
3855 | { | 3855 | { |
3856 | return mNavigatorBar; | 3856 | return mNavigatorBar; |
3857 | } | 3857 | } |
3858 | 3858 | ||
3859 | 3859 | ||
3860 | 3860 | ||
3861 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3861 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3862 | { | 3862 | { |
3863 | //qDebug(" alendarView::keyPressEvent "); | 3863 | //qDebug(" alendarView::keyPressEvent "); |
3864 | e->ignore(); | 3864 | e->ignore(); |
3865 | } | 3865 | } |
3866 | 3866 | ||
3867 | 3867 | ||
3868 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3868 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3869 | { | 3869 | { |
3870 | // mSyncManager = manager; | 3870 | // mSyncManager = manager; |
3871 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3871 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3872 | qDebug("KO: SyncKDE request detected!"); | 3872 | qDebug("KO: SyncKDE request detected!"); |
3873 | } | 3873 | } |
3874 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3874 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3875 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3875 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3876 | return syncCalendar( filename, mode ); | 3876 | return syncCalendar( filename, mode ); |
3877 | } | 3877 | } |
3878 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3878 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3879 | { | 3879 | { |
3880 | //mSyncManager = manager; | 3880 | //mSyncManager = manager; |
3881 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3881 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3882 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3882 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3883 | if ( resource == "sharp" ) | 3883 | if ( resource == "sharp" ) |
3884 | syncExternal( 0 ); | 3884 | syncExternal( 0 ); |
3885 | if ( resource == "phone" ) | 3885 | if ( resource == "phone" ) |
3886 | syncExternal( 1 ); | 3886 | syncExternal( 1 ); |
3887 | // pending setmodified | 3887 | // pending setmodified |
3888 | return true; | 3888 | return true; |
3889 | } | 3889 | } |
3890 | void CalendarView::setSyncManager(KSyncManager* manager) | 3890 | void CalendarView::setSyncManager(KSyncManager* manager) |
3891 | { | 3891 | { |
3892 | mSyncManager = manager; | 3892 | mSyncManager = manager; |
3893 | } | 3893 | } |
3894 | 3894 | ||
3895 | void CalendarView::removeSyncInfo( QString syncProfile) | 3895 | void CalendarView::removeSyncInfo( QString syncProfile) |
3896 | { | 3896 | { |
3897 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 3897 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
3898 | mCalendar->removeSyncInfo( syncProfile ); | 3898 | mCalendar->removeSyncInfo( syncProfile ); |
3899 | 3899 | ||
3900 | } | 3900 | } |
3901 | 3901 | ||
3902 | void CalendarView::undo_delete() | 3902 | void CalendarView::undo_delete() |
3903 | { | 3903 | { |
3904 | //qDebug("undo_delete() "); | 3904 | //qDebug("undo_delete() "); |
3905 | Incidence* undo = mCalendar->undoIncidence(); | 3905 | Incidence* undo = mCalendar->undoIncidence(); |
3906 | if ( !undo ) { | 3906 | if ( !undo ) { |
3907 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3907 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3908 | i18n("KO/Pi")); | 3908 | i18n("KO/Pi")); |
3909 | return; | 3909 | return; |
3910 | } | 3910 | } |
3911 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3911 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3912 | i18n("\nAre you sure you want\nto restore this?"), | 3912 | i18n("\nAre you sure you want\nto restore this?"), |
3913 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3913 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3914 | mCalendar->undoDeleteIncidence(); | 3914 | mCalendar->undoDeleteIncidence(); |
3915 | updateView(); | 3915 | updateView(); |
3916 | } | 3916 | } |
3917 | } | 3917 | } |
diff --git a/korganizer/datenavigator.cpp b/korganizer/datenavigator.cpp index 3156b2b..d2824de 100644 --- a/korganizer/datenavigator.cpp +++ b/korganizer/datenavigator.cpp | |||
@@ -1,293 +1,292 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 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 "datenavigator.h" | 24 | #include "datenavigator.h" |
25 | 25 | ||
26 | #include "koglobals.h" | 26 | #include "koglobals.h" |
27 | 27 | ||
28 | #include <kcalendarsystem.h> | 28 | #include <kcalendarsystem.h> |
29 | 29 | ||
30 | #include <kdebug.h> | 30 | #include <kdebug.h> |
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | 33 | ||
34 | using namespace KCal; | 34 | using namespace KCal; |
35 | 35 | ||
36 | DateNavigator::DateNavigator( QObject *parent, const char *name , KOViewManager * v) | 36 | DateNavigator::DateNavigator( QObject *parent, const char *name , KOViewManager * v) |
37 | : QObject( parent, name ) | 37 | : QObject( parent, name ) |
38 | { | 38 | { |
39 | mViewManager = v; | 39 | mViewManager = v; |
40 | mSelectedDates.append( QDate::currentDate() ); | 40 | mSelectedDates.append( QDate::currentDate() ); |
41 | } | 41 | } |
42 | 42 | ||
43 | DateNavigator::~DateNavigator() | 43 | DateNavigator::~DateNavigator() |
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | void DateNavigator::slotMonthSelect( int m ) | 47 | void DateNavigator::slotMonthSelect( int m ) |
48 | { | 48 | { |
49 | QDate firstSelected = mSelectedDates.first(); | 49 | QDate firstSelected = mSelectedDates.first(); |
50 | int weekDay = firstSelected.dayOfWeek(); | 50 | int weekDay = firstSelected.dayOfWeek(); |
51 | int diff = m - firstSelected.month() ; | 51 | int diff = m - firstSelected.month() ; |
52 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, diff ); | 52 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, diff ); |
53 | 53 | ||
54 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) | 54 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) |
55 | selectMonthByDate( firstSelected ); | 55 | selectMonthByDate( firstSelected ); |
56 | else | 56 | else |
57 | selectWeekByDay( weekDay, firstSelected ); | 57 | selectWeekByDay( weekDay, firstSelected ); |
58 | 58 | ||
59 | } | 59 | } |
60 | 60 | ||
61 | void DateNavigator::slotDaySelect( QDate d ) | 61 | void DateNavigator::slotDaySelect( QDate d ) |
62 | { | 62 | { |
63 | QDate firstSelected = mSelectedDates.first(); | 63 | QDate firstSelected = mSelectedDates.first(); |
64 | int weekDay = firstSelected.dayOfWeek(); | 64 | int weekDay = firstSelected.dayOfWeek(); |
65 | //int diff = firstSelected.daysTo( d ) ; | 65 | //int diff = firstSelected.daysTo( d ) ; |
66 | firstSelected = firstSelected.addDays( firstSelected .daysTo( d ) ); | 66 | firstSelected = firstSelected.addDays( firstSelected .daysTo( d ) ); |
67 | 67 | ||
68 | selectWeekByDay( weekDay, firstSelected ); | 68 | selectWeekByDay( weekDay, firstSelected ); |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | void DateNavigator::selectMonthByDate( const QDate & firstSelected ) | 72 | void DateNavigator::selectMonthByDate( const QDate & firstSelected ) |
73 | { | 73 | { |
74 | 74 | ||
75 | int monthDay = firstSelected.day(); | 75 | int monthDay = firstSelected.day(); |
76 | QDate date = firstSelected.addDays( 1-monthDay ); | 76 | QDate date = firstSelected.addDays( 1-monthDay ); |
77 | selectDates( date , date.daysInMonth ()); | 77 | selectDates( date , date.daysInMonth ()); |
78 | 78 | ||
79 | } | 79 | } |
80 | void DateNavigator::selectMonth() | 80 | void DateNavigator::selectMonth() |
81 | { | 81 | { |
82 | 82 | ||
83 | QDate date =mSelectedDates.first(); | 83 | QDate date =mSelectedDates.first(); |
84 | selectMonthByDate( date ); | 84 | selectMonthByDate( date ); |
85 | } | 85 | } |
86 | 86 | ||
87 | DateList DateNavigator::selectedDates() | 87 | DateList DateNavigator::selectedDates() |
88 | { | 88 | { |
89 | return mSelectedDates; | 89 | return mSelectedDates; |
90 | } | 90 | } |
91 | 91 | ||
92 | int DateNavigator::datesCount() const | 92 | int DateNavigator::datesCount() const |
93 | { | 93 | { |
94 | return mSelectedDates.count(); | 94 | return mSelectedDates.count(); |
95 | } | 95 | } |
96 | 96 | ||
97 | void DateNavigator::selectDates( const DateList& dateList ) | 97 | void DateNavigator::selectDates( const DateList& dateList ) |
98 | { | 98 | { |
99 | if (dateList.count() > 0) { | 99 | if (dateList.count() > 0) { |
100 | mSelectedDates = dateList; | 100 | mSelectedDates = dateList; |
101 | emitSelected(); | 101 | emitSelected(); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | void DateNavigator::selectDate( const QDate &date ) | 105 | void DateNavigator::selectDate( const QDate &date ) |
106 | { | 106 | { |
107 | QDate d = date; | 107 | QDate d = date; |
108 | 108 | ||
109 | if ( !d.isValid() ) { | 109 | if ( !d.isValid() ) { |
110 | d = QDate::currentDate(); | 110 | d = QDate::currentDate(); |
111 | } | 111 | } |
112 | 112 | ||
113 | mSelectedDates.clear(); | 113 | mSelectedDates.clear(); |
114 | mSelectedDates.append( d ); | 114 | mSelectedDates.append( d ); |
115 | 115 | ||
116 | emitSelected(); | 116 | emitSelected(); |
117 | } | 117 | } |
118 | 118 | ||
119 | void DateNavigator::selectDates( int count ) | 119 | void DateNavigator::selectDates( int count ) |
120 | { | 120 | { |
121 | 121 | ||
122 | QDate d = mSelectedDates.first(); | 122 | QDate d = mSelectedDates.first(); |
123 | selectDates( d, count ); | 123 | selectDates( d, count ); |
124 | } | 124 | } |
125 | 125 | ||
126 | void DateNavigator::selectDates( const QDate &d, int count ) | 126 | void DateNavigator::selectDates( const QDate &d, int count ) |
127 | { | 127 | { |
128 | DateList dates; | 128 | DateList dates; |
129 | 129 | ||
130 | int i; | 130 | int i; |
131 | for( i = 0; i < count; ++i ) { | 131 | for( i = 0; i < count; ++i ) { |
132 | dates.append( d.addDays( i ) ); | 132 | dates.append( d.addDays( i ) ); |
133 | } | 133 | } |
134 | 134 | ||
135 | mSelectedDates = dates; | 135 | mSelectedDates = dates; |
136 | 136 | ||
137 | emitSelected(); | 137 | emitSelected(); |
138 | } | 138 | } |
139 | 139 | ||
140 | void DateNavigator::selectWeekByDay( int weekDay, const QDate &d ) | 140 | void DateNavigator::selectWeekByDay( int weekDay, const QDate &d ) |
141 | { | 141 | { |
142 | // qDebug("selectWeekByDay( %d %s ", weekDay, d.toString().latin1()); | 142 | // qDebug("selectWeekByDay( %d %s ", weekDay, d.toString().latin1()); |
143 | int dateCount = mSelectedDates.count(); | 143 | int dateCount = mSelectedDates.count(); |
144 | bool weekStart = ( weekDay == KGlobal::locale()->weekStartDay() ); | 144 | bool weekStart = ( weekDay == KGlobal::locale()->weekStartDay() ); |
145 | if ( weekDay == 1 && dateCount == 5 ) selectWorkWeek( d ); | 145 | if ( weekDay == 1 && dateCount == 5 ) selectWorkWeek( d ); |
146 | else if ( weekStart && dateCount == 7 ) selectWeek( d ); | 146 | else if ( weekStart && dateCount == 7 ) selectWeek( d ); |
147 | else selectDates( d, dateCount ); | 147 | else selectDates( d, dateCount ); |
148 | } | 148 | } |
149 | 149 | ||
150 | void DateNavigator::selectWeek() | 150 | void DateNavigator::selectWeek() |
151 | { | 151 | { |
152 | QDate d = mSelectedDates.first(); | 152 | QDate d = mSelectedDates.first(); |
153 | selectWeek( d ); | 153 | selectWeek( d ); |
154 | } | 154 | } |
155 | void DateNavigator::selectWeek( int num ) | 155 | void DateNavigator::selectWeek( int num ) |
156 | { | 156 | { |
157 | int year = mSelectedDates.first().year(); | 157 | int year = mSelectedDates.first().year(); |
158 | if ( mSelectedDates.first().dayOfYear() > 300 && num < 10 ) | 158 | if ( mSelectedDates.first().dayOfYear() > 300 && num < 10 ) |
159 | ++year; | 159 | ++year; |
160 | if ( mSelectedDates.first().dayOfYear() < 70 && num > 40 ) | 160 | if ( mSelectedDates.first().dayOfYear() < 70 && num > 40 ) |
161 | --year; | 161 | --year; |
162 | QDate d = QDate ( year, 1,1); | 162 | QDate d = QDate ( year, 1,1); |
163 | while ( d.dayOfWeek() != 4 ) | 163 | while ( d.dayOfWeek() != 4 ) |
164 | d = d.addDays( 1 ); | 164 | d = d.addDays( 1 ); |
165 | selectWeek( d.addDays ( (num-1) *7 ) ); | 165 | selectWeek( d.addDays ( (num-1) *7 ) ); |
166 | } | 166 | } |
167 | void DateNavigator::selectWeek( const QDate &d ) | 167 | void DateNavigator::selectWeek( const QDate &d ) |
168 | { | 168 | { |
169 | int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d ); | 169 | int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d ); |
170 | 170 | ||
171 | int weekStart = KGlobal::locale()->weekStartDay(); | 171 | int weekStart = KGlobal::locale()->weekStartDay(); |
172 | QDate firstDate = d.addDays( weekStart - dayOfWeek ); | 172 | QDate firstDate = d.addDays( weekStart - dayOfWeek ); |
173 | 173 | ||
174 | if ( weekStart != 1 && dayOfWeek < weekStart ) { | 174 | if ( weekStart != 1 && dayOfWeek < weekStart ) { |
175 | firstDate = firstDate.addDays(-7 ); | 175 | firstDate = firstDate.addDays(-7 ); |
176 | } | 176 | } |
177 | 177 | ||
178 | 178 | ||
179 | selectDates( firstDate, 7 ); | 179 | selectDates( firstDate, 7 ); |
180 | } | 180 | } |
181 | 181 | ||
182 | void DateNavigator::selectWorkWeek() | 182 | void DateNavigator::selectWorkWeek() |
183 | { | 183 | { |
184 | QDate d = mSelectedDates.first(); | 184 | QDate d = mSelectedDates.first(); |
185 | selectWorkWeek( d ); | 185 | selectWorkWeek( d ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void DateNavigator::selectWorkWeek( const QDate &d ) | 188 | void DateNavigator::selectWorkWeek( const QDate &d ) |
189 | { | 189 | { |
190 | int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d ); | 190 | int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d ); |
191 | 191 | ||
192 | QDate firstDate = d.addDays( 1 - dayOfWeek ); | 192 | QDate firstDate = d.addDays( 1 - dayOfWeek ); |
193 | 193 | ||
194 | int weekStart = KGlobal::locale()->weekStartDay(); | 194 | int weekStart = KGlobal::locale()->weekStartDay(); |
195 | if ( weekStart != 1 && dayOfWeek >= weekStart ) { | 195 | if ( weekStart != 1 && dayOfWeek >= weekStart ) { |
196 | firstDate = firstDate.addDays( 7 ); | 196 | firstDate = firstDate.addDays( 7 ); |
197 | } | 197 | } |
198 | 198 | ||
199 | selectDates( firstDate, 5 ); | 199 | selectDates( firstDate, 5 ); |
200 | } | 200 | } |
201 | 201 | ||
202 | void DateNavigator::selectTodayMonth() | 202 | void DateNavigator::selectTodayMonth() |
203 | { | 203 | { |
204 | QDate date = QDate::currentDate().addDays( 1-QDate::currentDate().day() ); | 204 | QDate date = QDate::currentDate().addDays( 1-QDate::currentDate().day() ); |
205 | selectDates( date , date.daysInMonth ()); | 205 | selectDates( date , date.daysInMonth ()); |
206 | 206 | ||
207 | } | 207 | } |
208 | void DateNavigator::selectToday() | 208 | void DateNavigator::selectToday() |
209 | { | 209 | { |
210 | QDate d = QDate::currentDate(); | 210 | QDate d = QDate::currentDate(); |
211 | 211 | ||
212 | int dateCount = mSelectedDates.count(); | 212 | int dateCount = mSelectedDates.count(); |
213 | 213 | if ( dateCount == 5 && d.dayOfWeek() < 6 ) selectWorkWeek( d ); | |
214 | if ( dateCount == 5 ) selectWorkWeek( d ); | ||
215 | else if ( dateCount == 7 ) selectWeek( d ); | 214 | else if ( dateCount == 7 ) selectWeek( d ); |
216 | else selectDates( d, dateCount ); | 215 | else selectDates( d, dateCount ); |
217 | } | 216 | } |
218 | 217 | ||
219 | void DateNavigator::selectPreviousYear() | 218 | void DateNavigator::selectPreviousYear() |
220 | { | 219 | { |
221 | QDate firstSelected = mSelectedDates.first(); | 220 | QDate firstSelected = mSelectedDates.first(); |
222 | int weekDay = firstSelected.dayOfWeek(); | 221 | int weekDay = firstSelected.dayOfWeek(); |
223 | firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, -1 ); | 222 | firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, -1 ); |
224 | 223 | ||
225 | selectWeekByDay( weekDay, firstSelected ); | 224 | selectWeekByDay( weekDay, firstSelected ); |
226 | } | 225 | } |
227 | 226 | ||
228 | void DateNavigator::selectPreviousMonth() | 227 | void DateNavigator::selectPreviousMonth() |
229 | { | 228 | { |
230 | QDate firstSelected = mSelectedDates.first(); | 229 | QDate firstSelected = mSelectedDates.first(); |
231 | int weekDay = firstSelected.dayOfWeek(); | 230 | int weekDay = firstSelected.dayOfWeek(); |
232 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, -1 ); | 231 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, -1 ); |
233 | 232 | ||
234 | 233 | ||
235 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) | 234 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) |
236 | selectMonthByDate( firstSelected ); | 235 | selectMonthByDate( firstSelected ); |
237 | else | 236 | else |
238 | selectWeekByDay( weekDay, firstSelected ); | 237 | selectWeekByDay( weekDay, firstSelected ); |
239 | } | 238 | } |
240 | 239 | ||
241 | void DateNavigator::selectNextMonth() | 240 | void DateNavigator::selectNextMonth() |
242 | { | 241 | { |
243 | QDate firstSelected = mSelectedDates.first(); | 242 | QDate firstSelected = mSelectedDates.first(); |
244 | int weekDay = firstSelected.dayOfWeek(); | 243 | int weekDay = firstSelected.dayOfWeek(); |
245 | 244 | ||
246 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, 1 ); | 245 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, 1 ); |
247 | 246 | ||
248 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) | 247 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) |
249 | selectMonthByDate( firstSelected ); | 248 | selectMonthByDate( firstSelected ); |
250 | else | 249 | else |
251 | selectWeekByDay( weekDay, firstSelected ); | 250 | selectWeekByDay( weekDay, firstSelected ); |
252 | 251 | ||
253 | } | 252 | } |
254 | 253 | ||
255 | void DateNavigator::selectNextYear() | 254 | void DateNavigator::selectNextYear() |
256 | { | 255 | { |
257 | QDate firstSelected = mSelectedDates.first(); | 256 | QDate firstSelected = mSelectedDates.first(); |
258 | int weekDay = firstSelected.dayOfWeek(); | 257 | int weekDay = firstSelected.dayOfWeek(); |
259 | firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, 1 ); | 258 | firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, 1 ); |
260 | 259 | ||
261 | selectWeekByDay( weekDay, firstSelected ); | 260 | selectWeekByDay( weekDay, firstSelected ); |
262 | } | 261 | } |
263 | 262 | ||
264 | void DateNavigator::selectPrevious() | 263 | void DateNavigator::selectPrevious() |
265 | { | 264 | { |
266 | int offset = -7; | 265 | int offset = -7; |
267 | if ( datesCount() == 1 ) { | 266 | if ( datesCount() == 1 ) { |
268 | offset = -1; | 267 | offset = -1; |
269 | } | 268 | } |
270 | if ( mViewManager ) | 269 | if ( mViewManager ) |
271 | if ( mViewManager->showsNextDays() ) | 270 | if ( mViewManager->showsNextDays() ) |
272 | offset = -datesCount(); | 271 | offset = -datesCount(); |
273 | selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); | 272 | selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); |
274 | } | 273 | } |
275 | 274 | ||
276 | void DateNavigator::selectNext() | 275 | void DateNavigator::selectNext() |
277 | { | 276 | { |
278 | int offset = 7; | 277 | int offset = 7; |
279 | if ( datesCount() == 1 ) { | 278 | if ( datesCount() == 1 ) { |
280 | offset = 1; | 279 | offset = 1; |
281 | } | 280 | } |
282 | if ( mViewManager ) | 281 | if ( mViewManager ) |
283 | if ( mViewManager->showsNextDays() ) | 282 | if ( mViewManager->showsNextDays() ) |
284 | offset = datesCount(); | 283 | offset = datesCount(); |
285 | selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); | 284 | selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); |
286 | } | 285 | } |
287 | 286 | ||
288 | void DateNavigator::emitSelected() | 287 | void DateNavigator::emitSelected() |
289 | { | 288 | { |
290 | emit datesSelected( mSelectedDates ); | 289 | emit datesSelected( mSelectedDates ); |
291 | } | 290 | } |
292 | 291 | ||
293 | //#include "datenavigator.moc" | 292 | //#include "datenavigator.moc" |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 10e4f1d..4cefb26 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1154 +1,1155 @@ | |||
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 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qtooltip.h> | 27 | #include <qtooltip.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPRINTER | 44 | #ifndef KORG_NOPRINTER |
45 | #include "calprinter.h" | 45 | #include "calprinter.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #ifndef KORG_NOPLUGINS | 48 | #ifndef KORG_NOPLUGINS |
49 | #include "kocore.h" | 49 | #include "kocore.h" |
50 | #endif | 50 | #endif |
51 | #include "koglobals.h" | 51 | #include "koglobals.h" |
52 | #include <libkcal/kincidenceformatter.h> | 52 | #include <libkcal/kincidenceformatter.h> |
53 | 53 | ||
54 | #include "komonthview.h" | 54 | #include "komonthview.h" |
55 | 55 | ||
56 | #define PIXMAP_SIZE 5 | 56 | #define PIXMAP_SIZE 5 |
57 | #ifdef DESKTOP_VERSION | 57 | #ifdef DESKTOP_VERSION |
58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
59 | #endif | 59 | #endif |
60 | class KNOWhatsThis :public QWhatsThis | 60 | class KNOWhatsThis :public QWhatsThis |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
65 | 65 | ||
66 | protected: | 66 | protected: |
67 | virtual QString text( const QPoint& p) | 67 | virtual QString text( const QPoint& p) |
68 | { | 68 | { |
69 | return _wid->getWhatsThisText(p) ; | 69 | return _wid->getWhatsThisText(p) ; |
70 | }; | 70 | }; |
71 | private: | 71 | private: |
72 | KNoScrollListBox* _wid; | 72 | KNoScrollListBox* _wid; |
73 | 73 | ||
74 | }; | 74 | }; |
75 | 75 | ||
76 | 76 | ||
77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
78 | : QListBox(parent, name, WRepaintNoErase) | 78 | : QListBox(parent, name, WRepaintNoErase) |
79 | { | 79 | { |
80 | #ifndef DESKTOP_VERSION | 80 | #ifndef DESKTOP_VERSION |
81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
82 | #endif | 82 | #endif |
83 | mWT = new KNOWhatsThis(this); | 83 | mWT = new KNOWhatsThis(this); |
84 | } | 84 | } |
85 | KNoScrollListBox::~KNoScrollListBox() | 85 | KNoScrollListBox::~KNoScrollListBox() |
86 | { | 86 | { |
87 | 87 | ||
88 | } | 88 | } |
89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
90 | { | 90 | { |
91 | QListBoxItem* item = itemAt ( p ); | 91 | QListBoxItem* item = itemAt ( p ); |
92 | if ( ! item ) { | 92 | if ( ! item ) { |
93 | return i18n("Click in the cell\nto add an event!"); | 93 | return i18n("Click in the cell\nto add an event!"); |
94 | } | 94 | } |
95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); |
96 | } | 96 | } |
97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
98 | { | 98 | { |
99 | 99 | ||
100 | switch(e->key()) { | 100 | switch(e->key()) { |
101 | case Key_Right: | 101 | case Key_Right: |
102 | // if ( e->state() == Qt::ControlButton ) | 102 | // if ( e->state() == Qt::ControlButton ) |
103 | { | 103 | { |
104 | e->ignore(); | 104 | e->ignore(); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | scrollBy(4,0); | 107 | scrollBy(4,0); |
108 | break; | 108 | break; |
109 | case Key_Left: | 109 | case Key_Left: |
110 | // if ( e->state() == Qt::ControlButton ) | 110 | // if ( e->state() == Qt::ControlButton ) |
111 | { | 111 | { |
112 | e->ignore(); | 112 | e->ignore(); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | scrollBy(-4,0); | 115 | scrollBy(-4,0); |
116 | break; | 116 | break; |
117 | case Key_Up: | 117 | case Key_Up: |
118 | if(count() < 2) { | 118 | if(count() < 2) { |
119 | e->ignore(); | 119 | e->ignore(); |
120 | break; | 120 | break; |
121 | } | 121 | } |
122 | setCurrentItem((currentItem()+count()-1)%count()); | 122 | setCurrentItem((currentItem()+count()-1)%count()); |
123 | if(!itemVisible(currentItem())) { | 123 | if(!itemVisible(currentItem())) { |
124 | if((unsigned int) currentItem() == (count()-1)) { | 124 | if((unsigned int) currentItem() == (count()-1)) { |
125 | setTopItem(currentItem()-numItemsVisible()+1); | 125 | setTopItem(currentItem()-numItemsVisible()+1); |
126 | } else { | 126 | } else { |
127 | setTopItem(topItem()-1); | 127 | setTopItem(topItem()-1); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | break; | 130 | break; |
131 | case Key_Down: | 131 | case Key_Down: |
132 | if(count() < 2) { | 132 | if(count() < 2) { |
133 | e->ignore(); | 133 | e->ignore(); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | setCurrentItem((currentItem()+1)%count()); | 136 | setCurrentItem((currentItem()+1)%count()); |
137 | if(!itemVisible(currentItem())) { | 137 | if(!itemVisible(currentItem())) { |
138 | if(currentItem() == 0) { | 138 | if(currentItem() == 0) { |
139 | setTopItem(0); | 139 | setTopItem(0); |
140 | } else { | 140 | } else { |
141 | setTopItem(topItem()+1); | 141 | setTopItem(topItem()+1); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | break; | 144 | break; |
145 | case Key_Shift: | 145 | case Key_Shift: |
146 | emit shiftDown(); | 146 | emit shiftDown(); |
147 | break; | 147 | break; |
148 | default: | 148 | default: |
149 | e->ignore(); | 149 | e->ignore(); |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 154 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
155 | { | 155 | { |
156 | switch(e->key()) { | 156 | switch(e->key()) { |
157 | case Key_Shift: | 157 | case Key_Shift: |
158 | emit shiftUp(); | 158 | emit shiftUp(); |
159 | break; | 159 | break; |
160 | default: | 160 | default: |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 165 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
166 | { | 166 | { |
167 | QListBox::mousePressEvent(e); | 167 | QListBox::mousePressEvent(e); |
168 | 168 | ||
169 | if(e->button() == RightButton) { | 169 | if(e->button() == RightButton) { |
170 | emit rightClick(); | 170 | emit rightClick(); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 174 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
175 | : QListBoxItem() | 175 | : QListBoxItem() |
176 | { | 176 | { |
177 | setText( s ); | 177 | setText( s ); |
178 | 178 | ||
179 | mIncidence = incidence; | 179 | mIncidence = incidence; |
180 | mDate = qd; | 180 | mDate = qd; |
181 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 181 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
182 | mRecur = false; | 182 | mRecur = false; |
183 | mAlarm = false; | 183 | mAlarm = false; |
184 | mReply = false; | 184 | mReply = false; |
185 | mInfo = false; | 185 | mInfo = false; |
186 | } | 186 | } |
187 | 187 | ||
188 | void MonthViewItem::paint(QPainter *p) | 188 | void MonthViewItem::paint(QPainter *p) |
189 | { | 189 | { |
190 | #if QT_VERSION >= 0x030000 | 190 | #if QT_VERSION >= 0x030000 |
191 | bool sel = isSelected(); | 191 | bool sel = isSelected(); |
192 | #else | 192 | #else |
193 | bool sel = selected(); | 193 | bool sel = selected(); |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | 196 | ||
197 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 197 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
198 | { | 198 | { |
199 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 199 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
200 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 200 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
201 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 201 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
202 | } | 202 | } |
203 | int x = 1; | 203 | int x = 1; |
204 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 204 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
205 | int size = PIXMAP_SIZE; | 205 | int size = PIXMAP_SIZE; |
206 | if ( QApplication::desktop()->width() < 300 ) | 206 | if ( QApplication::desktop()->width() < 300 ) |
207 | size = 3; | 207 | size = 3; |
208 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 208 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
209 | if ( mInfo ) { | 209 | if ( mInfo ) { |
210 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 210 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
211 | x += size + 1; | 211 | x += size + 1; |
212 | } | 212 | } |
213 | if ( mRecur ) { | 213 | if ( mRecur ) { |
214 | p->fillRect ( x, y,size,size, Qt::blue ); | 214 | p->fillRect ( x, y,size,size, Qt::blue ); |
215 | x += size + 1; | 215 | x += size + 1; |
216 | } | 216 | } |
217 | if ( mAlarm ) { | 217 | if ( mAlarm ) { |
218 | p->fillRect ( x, y,size,size, Qt::red ); | 218 | p->fillRect ( x, y,size,size, Qt::red ); |
219 | x += size + 1; | 219 | x += size + 1; |
220 | } | 220 | } |
221 | if ( mReply ) { | 221 | if ( mReply ) { |
222 | p->fillRect ( x, y,size,size, Qt::yellow ); | 222 | p->fillRect ( x, y,size,size, Qt::yellow ); |
223 | x += size + 1; | 223 | x += size + 1; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | QFontMetrics fm = p->fontMetrics(); | 226 | QFontMetrics fm = p->fontMetrics(); |
227 | int yPos; | 227 | int yPos; |
228 | int pmheight = size; | 228 | int pmheight = size; |
229 | if( pmheight < fm.height() ) | 229 | if( pmheight < fm.height() ) |
230 | yPos = fm.ascent() + fm.leading()/2; | 230 | yPos = fm.ascent() + fm.leading()/2; |
231 | else | 231 | else |
232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
233 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 233 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
235 | p->drawText( x, yPos, text() ); | 235 | p->drawText( x, yPos, text() ); |
236 | if ( mIncidence->cancelled() ) { | 236 | if ( mIncidence->cancelled() ) { |
237 | int wid = fm.width( text() ); | 237 | int wid = fm.width( text() ); |
238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); | 238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); |
239 | } | 239 | } |
240 | 240 | ||
241 | } | 241 | } |
242 | 242 | ||
243 | int MonthViewItem::height(const QListBox *lb) const | 243 | int MonthViewItem::height(const QListBox *lb) const |
244 | { | 244 | { |
245 | return lb->fontMetrics().lineSpacing()+1; | 245 | return lb->fontMetrics().lineSpacing()+1; |
246 | } | 246 | } |
247 | 247 | ||
248 | int MonthViewItem::width(const QListBox *lb) const | 248 | int MonthViewItem::width(const QListBox *lb) const |
249 | { | 249 | { |
250 | int size = PIXMAP_SIZE; | 250 | int size = PIXMAP_SIZE; |
251 | if ( QApplication::desktop()->width() < 300 ) | 251 | if ( QApplication::desktop()->width() < 300 ) |
252 | size = 3; | 252 | size = 3; |
253 | int x = 1; | 253 | int x = 1; |
254 | if ( mInfo ) { | 254 | if ( mInfo ) { |
255 | x += size + 1; | 255 | x += size + 1; |
256 | } | 256 | } |
257 | if( mRecur ) { | 257 | if( mRecur ) { |
258 | x += size+1; | 258 | x += size+1; |
259 | } | 259 | } |
260 | if( mAlarm ) { | 260 | if( mAlarm ) { |
261 | x += size+1; | 261 | x += size+1; |
262 | } | 262 | } |
263 | if( mReply ) { | 263 | if( mReply ) { |
264 | x += size+1; | 264 | x += size+1; |
265 | } | 265 | } |
266 | 266 | ||
267 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 267 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | MonthViewCell::MonthViewCell( KOMonthView *parent) | 271 | MonthViewCell::MonthViewCell( KOMonthView *parent) |
272 | : QWidget( parent ), | 272 | : QWidget( parent ), |
273 | mMonthView( parent ) | 273 | mMonthView( parent ) |
274 | { | 274 | { |
275 | 275 | ||
276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
277 | 277 | ||
278 | // mLabel = new QLabel( this );QPushButton | 278 | // mLabel = new QLabel( this );QPushButton |
279 | mLabel = new QPushButton( this ); | 279 | mLabel = new QPushButton( this ); |
280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
281 | //mLabel->setLineWidth( 1 ); | 281 | //mLabel->setLineWidth( 1 ); |
282 | //mLabel->setAlignment( AlignCenter ); | 282 | //mLabel->setAlignment( AlignCenter ); |
283 | mLabel->setFlat( true ); | 283 | mLabel->setFlat( true ); |
284 | mItemList = new KNoScrollListBox( this ); | 284 | mItemList = new KNoScrollListBox( this ); |
285 | mItemList->setMinimumSize( 10, 10 ); | 285 | mItemList->setMinimumSize( 10, 10 ); |
286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
287 | mItemList->setLineWidth( 1 ); | 287 | mItemList->setLineWidth( 1 ); |
288 | topLayout->addWidget( mItemList ); | 288 | topLayout->addWidget( mItemList ); |
289 | mLabel->raise(); | 289 | mLabel->raise(); |
290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
291 | mStandardPalette = palette(); | 291 | mStandardPalette = palette(); |
292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
293 | 293 | ||
294 | enableScrollBars( false ); | 294 | enableScrollBars( false ); |
295 | updateConfig(); | 295 | updateConfig(); |
296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
299 | SLOT( defaultAction( QListBoxItem * ) ) ); | 299 | SLOT( defaultAction( QListBoxItem * ) ) ); |
300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
301 | const QPoint &) ), | 301 | const QPoint &) ), |
302 | SLOT( contextMenu( QListBoxItem * ) ) ); | 302 | SLOT( contextMenu( QListBoxItem * ) ) ); |
303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
304 | SLOT( selection( QListBoxItem * ) ) ); | 304 | SLOT( selection( QListBoxItem * ) ) ); |
305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
306 | SLOT( cellClicked( QListBoxItem * ) ) ); | 306 | SLOT( cellClicked( QListBoxItem * ) ) ); |
307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
308 | SLOT( selection( QListBoxItem * ) ) ); | 308 | SLOT( selection( QListBoxItem * ) ) ); |
309 | } | 309 | } |
310 | #ifdef DESKTOP_VERSION | 310 | #ifdef DESKTOP_VERSION |
311 | QToolTipGroup *MonthViewCell::toolTipGroup() | 311 | QToolTipGroup *MonthViewCell::toolTipGroup() |
312 | { | 312 | { |
313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
314 | return mToolTipGroup; | 314 | return mToolTipGroup; |
315 | } | 315 | } |
316 | #endif | 316 | #endif |
317 | 317 | ||
318 | void MonthViewCell::setDate( const QDate &date ) | 318 | void MonthViewCell::setDate( const QDate &date ) |
319 | { | 319 | { |
320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
321 | mDate = date; | 321 | mDate = date; |
322 | 322 | ||
323 | 323 | ||
324 | 324 | ||
325 | //resizeEvent( 0 ); | 325 | //resizeEvent( 0 ); |
326 | } | 326 | } |
327 | 327 | ||
328 | QDate MonthViewCell::date() const | 328 | QDate MonthViewCell::date() const |
329 | { | 329 | { |
330 | return mDate; | 330 | return mDate; |
331 | } | 331 | } |
332 | 332 | ||
333 | void MonthViewCell::setPrimary( bool primary ) | 333 | void MonthViewCell::setPrimary( bool primary ) |
334 | { | 334 | { |
335 | mPrimary = primary; | 335 | mPrimary = primary; |
336 | //setMyPalette(); | 336 | //setMyPalette(); |
337 | } | 337 | } |
338 | void MonthViewCell::setMyPalette() | 338 | void MonthViewCell::setMyPalette() |
339 | { | 339 | { |
340 | 340 | ||
341 | if ( mHoliday) { | 341 | if ( mHoliday) { |
342 | setPalette( mHolidayPalette ); | 342 | setPalette( mHolidayPalette ); |
343 | } else { | 343 | } else { |
344 | if ( mPrimary ) { | 344 | if ( mPrimary ) { |
345 | setPalette( mPrimaryPalette ); | 345 | setPalette( mPrimaryPalette ); |
346 | } else { | 346 | } else { |
347 | setPalette( mNonPrimaryPalette ); | 347 | setPalette( mNonPrimaryPalette ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | QPalette pal = palette(); | 350 | QPalette pal = palette(); |
351 | 351 | ||
352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
353 | } | 353 | } |
354 | QPalette MonthViewCell::getPalette () | 354 | QPalette MonthViewCell::getPalette () |
355 | { | 355 | { |
356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
357 | return mStandardPalette; | 357 | return mStandardPalette; |
358 | if ( mHoliday) { | 358 | if ( mHoliday) { |
359 | return mHolidayPalette ; | 359 | return mHolidayPalette ; |
360 | } else { | 360 | } else { |
361 | if ( mPrimary ) { | 361 | if ( mPrimary ) { |
362 | return mPrimaryPalette ; | 362 | return mPrimaryPalette ; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | return mNonPrimaryPalette; | 365 | return mNonPrimaryPalette; |
366 | } | 366 | } |
367 | bool MonthViewCell::isPrimary() const | 367 | bool MonthViewCell::isPrimary() const |
368 | { | 368 | { |
369 | return mPrimary; | 369 | return mPrimary; |
370 | } | 370 | } |
371 | 371 | ||
372 | void MonthViewCell::setHoliday( bool holiday ) | 372 | void MonthViewCell::setHoliday( bool holiday ) |
373 | { | 373 | { |
374 | mHoliday = holiday; | 374 | mHoliday = holiday; |
375 | //setMyPalette(); | 375 | //setMyPalette(); |
376 | } | 376 | } |
377 | 377 | ||
378 | void MonthViewCell::setHoliday( const QString &holiday ) | 378 | void MonthViewCell::setHoliday( const QString &holiday ) |
379 | { | 379 | { |
380 | mHolidayString = holiday; | 380 | mHolidayString = holiday; |
381 | 381 | ||
382 | if ( !holiday.isEmpty() ) { | 382 | if ( !holiday.isEmpty() ) { |
383 | setHoliday( true ); | 383 | setHoliday( true ); |
384 | } | 384 | } |
385 | } | 385 | } |
386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
387 | { | 387 | { |
388 | 388 | ||
389 | e->ignore(); | 389 | e->ignore(); |
390 | 390 | ||
391 | } | 391 | } |
392 | void MonthViewCell::clear() | 392 | void MonthViewCell::clear() |
393 | { | 393 | { |
394 | mItemList->clear(); | 394 | mItemList->clear(); |
395 | QApplication::removePostedEvents ( mItemList ); | 395 | QApplication::removePostedEvents ( mItemList ); |
396 | QApplication::removePostedEvents ( mLabel ); | 396 | QApplication::removePostedEvents ( mLabel ); |
397 | QApplication::removePostedEvents ( this ); | 397 | QApplication::removePostedEvents ( this ); |
398 | } | 398 | } |
399 | void MonthViewCell::updateCell() | 399 | void MonthViewCell::updateCell() |
400 | { | 400 | { |
401 | if ( !mMonthView->isUpdatePossible() ) | 401 | if ( !mMonthView->isUpdatePossible() ) |
402 | return; | 402 | return; |
403 | /* | 403 | /* |
404 | if ( !isVisible() ){ | 404 | if ( !isVisible() ){ |
405 | return; | 405 | return; |
406 | } | 406 | } |
407 | */ | 407 | */ |
408 | // qDebug("MonthViewCell::updateCell() "); | 408 | // qDebug("MonthViewCell::updateCell() "); |
409 | setPrimary( mDate.month()%2 ); | 409 | setPrimary( mDate.month()%2 ); |
410 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 410 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
411 | if ( mDate == QDate::currentDate() ) { | 411 | if ( mDate == QDate::currentDate() ) { |
412 | mItemList->setLineWidth( 3 ); | 412 | mItemList->setLineWidth( 3 ); |
413 | } else { | 413 | } else { |
414 | mItemList->setLineWidth( 1 ); | 414 | mItemList->setLineWidth( 1 ); |
415 | } | 415 | } |
416 | mItemList->clear(); | 416 | mItemList->clear(); |
417 | 417 | ||
418 | #ifdef DESKTOP_VERSION | 418 | #ifdef DESKTOP_VERSION |
419 | QToolTip::remove(this); | 419 | QToolTip::remove(this); |
420 | #endif | 420 | #endif |
421 | QString tipText(""); | 421 | QString tipText(""); |
422 | //qApp->processEvents(); | 422 | //qApp->processEvents(); |
423 | if ( !mHolidayString.isEmpty() ) { | 423 | if ( !mHolidayString.isEmpty() ) { |
424 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 424 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
425 | item->setPalette( mHolidayPalette ); | 425 | item->setPalette( mHolidayPalette ); |
426 | mItemList->insertItem( item ); | 426 | mItemList->insertItem( item ); |
427 | tipText += mHolidayString+"\n"; | 427 | tipText += mHolidayString+"\n"; |
428 | } | 428 | } |
429 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 429 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
430 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 430 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
431 | Event *event; | 431 | Event *event; |
432 | for( event = events.first(); event; event = events.next() ) { // for event | 432 | for( event = events.first(); event; event = events.next() ) { // for event |
433 | 433 | ||
434 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 434 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
435 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 435 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
436 | continue; | 436 | continue; |
437 | else | 437 | else |
438 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 438 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
439 | continue; | 439 | continue; |
440 | } | 440 | } |
441 | 441 | ||
442 | if ( event->categories().contains("Holiday") || | 442 | if ( event->categories().contains("Holiday") || |
443 | event->categories().contains(i18n("Holiday"))) { | 443 | event->categories().contains(i18n("Holiday"))) { |
444 | setHoliday( true ); | 444 | setHoliday( true ); |
445 | if ( mDate.dayOfWeek() == 7 ) | 445 | if ( mDate.dayOfWeek() == 7 ) |
446 | mItemList->setLineWidth( 3 ); | 446 | mItemList->setLineWidth( 3 ); |
447 | } | 447 | } |
448 | QString text; | 448 | QString text; |
449 | if (event->isMultiDay()) { | 449 | if (event->isMultiDay()) { |
450 | QString prefix = "<->"; | 450 | QString prefix = "<->"; |
451 | if ( event->doesRecur() ) { | 451 | if ( event->doesRecur() ) { |
452 | if ( event->recursOn( mDate) ) | 452 | if ( event->recursOn( mDate) ) |
453 | prefix ="->" ; | 453 | prefix ="->" ; |
454 | else { | 454 | else { |
455 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 455 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
456 | if ( event->recursOn( mDate.addDays( -days)) ) | 456 | if ( event->recursOn( mDate.addDays( -days)) ) |
457 | prefix ="<-" ; | 457 | prefix ="<-" ; |
458 | } | 458 | } |
459 | 459 | ||
460 | } else { | 460 | } else { |
461 | if (mDate == event->dtStart().date()) { | 461 | if (mDate == event->dtStart().date()) { |
462 | prefix ="->" ; | 462 | prefix ="->" ; |
463 | } else if (mDate == event->dtEnd().date()) { | 463 | } else if (mDate == event->dtEnd().date()) { |
464 | prefix ="<-" ; | 464 | prefix ="<-" ; |
465 | } | 465 | } |
466 | } | 466 | } |
467 | text = prefix + event->summary(); | 467 | text = prefix + event->summary(); |
468 | tipText += text; | 468 | tipText += text; |
469 | } else { | 469 | } else { |
470 | if (event->doesFloat()) { | 470 | if (event->doesFloat()) { |
471 | text = event->summary(); | 471 | text = event->summary(); |
472 | tipText += text; | 472 | tipText += text; |
473 | } | 473 | } |
474 | else { | 474 | else { |
475 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 475 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
476 | text += " " + event->summary(); | 476 | text += " " + event->summary(); |
477 | tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 477 | tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||
481 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 481 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
482 | QPalette pal; | 482 | QPalette pal; |
483 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 483 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
484 | QStringList categories = event->categories(); | 484 | QStringList categories = event->categories(); |
485 | QString cat = categories.first(); | 485 | QString cat = categories.first(); |
486 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 486 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
487 | pal = getPalette(); | 487 | pal = getPalette(); |
488 | if (cat.isEmpty()) { | 488 | if (cat.isEmpty()) { |
489 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 489 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
490 | } else { | 490 | } else { |
491 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 491 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
492 | } | 492 | } |
493 | 493 | ||
494 | } else { | 494 | } else { |
495 | if (cat.isEmpty()) { | 495 | if (cat.isEmpty()) { |
496 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 496 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
497 | } else { | 497 | } else { |
498 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 498 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | } else { | 502 | } else { |
503 | pal = mStandardPalette ; | 503 | pal = mStandardPalette ; |
504 | } | 504 | } |
505 | item->setPalette( pal ); | 505 | item->setPalette( pal ); |
506 | item->setRecur( event->recurrence()->doesRecur() ); | 506 | item->setRecur( event->recurrence()->doesRecur() ); |
507 | item->setAlarm( event->isAlarmEnabled() ); | 507 | item->setAlarm( event->isAlarmEnabled() ); |
508 | item->setMoreInfo( event->description().length() > 0 ); | 508 | item->setMoreInfo( event->description().length() > 0 ); |
509 | #ifdef DESKTOP_VERSION | 509 | #ifdef DESKTOP_VERSION |
510 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 510 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
511 | KOPrefs::instance()->email()); | 511 | KOPrefs::instance()->email()); |
512 | if ( me != 0 ) { | 512 | if ( me != 0 ) { |
513 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 513 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
514 | item->setReply(true); | 514 | item->setReply(true); |
515 | else | 515 | else |
516 | item->setReply(false); | 516 | item->setReply(false); |
517 | } else | 517 | } else |
518 | item->setReply(false); | 518 | item->setReply(false); |
519 | #endif | 519 | #endif |
520 | mItemList->insertItem( item ); | 520 | mItemList->insertItem( item ); |
521 | tipText += "\n"; | 521 | tipText += "\n"; |
522 | 522 | ||
523 | } | 523 | } |
524 | 524 | ||
525 | // insert due todos | 525 | // insert due todos |
526 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 526 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
527 | Todo *todo; | 527 | Todo *todo; |
528 | for(todo = todos.first(); todo; todo = todos.next()) { | 528 | for(todo = todos.first(); todo; todo = todos.next()) { |
529 | QString text; | 529 | QString text; |
530 | if (todo->hasDueDate()) { | 530 | if (todo->hasDueDate()) { |
531 | if (!todo->doesFloat()) { | 531 | if (!todo->doesFloat()) { |
532 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 532 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
533 | text += " "; | 533 | text += " "; |
534 | } | 534 | } |
535 | } | 535 | } |
536 | text += i18n("To-Do: %1").arg(todo->summary()); | 536 | text += i18n("To-Do: %1").arg(todo->summary()); |
537 | 537 | ||
538 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 538 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
539 | //item->setPalette( mStandardPalette ); | 539 | //item->setPalette( mStandardPalette ); |
540 | QPalette pal; | 540 | QPalette pal; |
541 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 541 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
542 | QStringList categories = todo->categories(); | 542 | QStringList categories = todo->categories(); |
543 | QString cat = categories.first(); | 543 | QString cat = categories.first(); |
544 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 544 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
545 | pal = getPalette(); | 545 | pal = getPalette(); |
546 | if (cat.isEmpty()) { | 546 | if (cat.isEmpty()) { |
547 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 547 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
548 | } else { | 548 | } else { |
549 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 549 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
550 | } | 550 | } |
551 | 551 | ||
552 | } else { | 552 | } else { |
553 | if (cat.isEmpty()) { | 553 | if (cat.isEmpty()) { |
554 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 554 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
555 | } else { | 555 | } else { |
556 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 556 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
557 | } | 557 | } |
558 | } | 558 | } |
559 | 559 | ||
560 | } else { | 560 | } else { |
561 | pal = mStandardPalette ; | 561 | pal = mStandardPalette ; |
562 | } | 562 | } |
563 | item->setPalette( pal ); | 563 | item->setPalette( pal ); |
564 | mItemList->insertItem( item ); | 564 | mItemList->insertItem( item ); |
565 | tipText += text+"\n"; | 565 | tipText += text+"\n"; |
566 | } | 566 | } |
567 | #ifdef DESKTOP_VERSION | 567 | #ifdef DESKTOP_VERSION |
568 | if (tipText != "") | 568 | if (tipText != "") |
569 | QToolTip::add(this,tipText,toolTipGroup(),""); | 569 | QToolTip::add(this,tipText,toolTipGroup(),""); |
570 | #endif | 570 | #endif |
571 | 571 | ||
572 | //setMyPalette(); | 572 | //setMyPalette(); |
573 | setMyPalette(); | 573 | setMyPalette(); |
574 | QString text; | 574 | QString text; |
575 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 575 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
576 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 576 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
577 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 577 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
578 | mLabel->resize( mLabelBigSize ); | 578 | mLabel->resize( mLabelBigSize ); |
579 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 579 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
580 | } else { | 580 | } else { |
581 | mLabel->resize( mLabelSize ); | 581 | mLabel->resize( mLabelSize ); |
582 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 582 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
583 | } | 583 | } |
584 | 584 | ||
585 | mLabel->setText( text ); | 585 | mLabel->setText( text ); |
586 | resizeEvent( 0 ); | 586 | resizeEvent( 0 ); |
587 | // if ( isVisible()) | 587 | // if ( isVisible()) |
588 | //qApp->processEvents(); | 588 | //qApp->processEvents(); |
589 | } | 589 | } |
590 | 590 | ||
591 | void MonthViewCell::updateConfig() | 591 | void MonthViewCell::updateConfig() |
592 | { | 592 | { |
593 | 593 | ||
594 | setFont( KOPrefs::instance()->mMonthViewFont ); | 594 | setFont( KOPrefs::instance()->mMonthViewFont ); |
595 | 595 | ||
596 | QFontMetrics fm( font() ); | 596 | QFontMetrics fm( font() ); |
597 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 597 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
598 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 598 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
599 | mHolidayPalette = mStandardPalette; | 599 | mHolidayPalette = mStandardPalette; |
600 | mPrimaryPalette = mStandardPalette; | 600 | mPrimaryPalette = mStandardPalette; |
601 | mNonPrimaryPalette = mStandardPalette; | 601 | mNonPrimaryPalette = mStandardPalette; |
602 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 602 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
603 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 603 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
604 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 604 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
605 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 605 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
606 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 606 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
607 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 607 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
608 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 608 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
609 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 609 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
610 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 610 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
611 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 611 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
612 | } | 612 | } |
613 | updateCell(); | 613 | updateCell(); |
614 | } | 614 | } |
615 | 615 | ||
616 | void MonthViewCell::enableScrollBars( bool enabled ) | 616 | void MonthViewCell::enableScrollBars( bool enabled ) |
617 | { | 617 | { |
618 | if ( enabled ) { | 618 | if ( enabled ) { |
619 | mItemList->setVScrollBarMode(QScrollView::Auto); | 619 | mItemList->setVScrollBarMode(QScrollView::Auto); |
620 | mItemList->setHScrollBarMode(QScrollView::Auto); | 620 | mItemList->setHScrollBarMode(QScrollView::Auto); |
621 | } else { | 621 | } else { |
622 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 622 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
623 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 623 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
624 | } | 624 | } |
625 | } | 625 | } |
626 | 626 | ||
627 | Incidence *MonthViewCell::selectedIncidence() | 627 | Incidence *MonthViewCell::selectedIncidence() |
628 | { | 628 | { |
629 | int index = mItemList->currentItem(); | 629 | int index = mItemList->currentItem(); |
630 | if ( index < 0 ) return 0; | 630 | if ( index < 0 ) return 0; |
631 | 631 | ||
632 | MonthViewItem *item = | 632 | MonthViewItem *item = |
633 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 633 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
634 | 634 | ||
635 | if ( !item ) return 0; | 635 | if ( !item ) return 0; |
636 | 636 | ||
637 | return item->incidence(); | 637 | return item->incidence(); |
638 | } | 638 | } |
639 | 639 | ||
640 | QDate MonthViewCell::selectedIncidenceDate() | 640 | QDate MonthViewCell::selectedIncidenceDate() |
641 | { | 641 | { |
642 | QDate qd; | 642 | QDate qd; |
643 | int index = mItemList->currentItem(); | 643 | int index = mItemList->currentItem(); |
644 | if ( index < 0 ) return qd; | 644 | if ( index < 0 ) return qd; |
645 | 645 | ||
646 | MonthViewItem *item = | 646 | MonthViewItem *item = |
647 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 647 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
648 | 648 | ||
649 | if ( !item ) return qd; | 649 | if ( !item ) return qd; |
650 | 650 | ||
651 | return item->incidenceDate(); | 651 | return item->incidenceDate(); |
652 | } | 652 | } |
653 | 653 | ||
654 | void MonthViewCell::deselect() | 654 | void MonthViewCell::deselect() |
655 | { | 655 | { |
656 | mItemList->clearSelection(); | 656 | mItemList->clearSelection(); |
657 | enableScrollBars( false ); | 657 | enableScrollBars( false ); |
658 | // updateCell(); | 658 | // updateCell(); |
659 | } | 659 | } |
660 | void MonthViewCell::select() | 660 | void MonthViewCell::select() |
661 | { | 661 | { |
662 | ;// updateCell(); | 662 | ;// updateCell(); |
663 | } | 663 | } |
664 | 664 | ||
665 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 665 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
666 | { | 666 | { |
667 | if ( !mMonthView->isUpdatePossible() ) | 667 | if ( !mMonthView->isUpdatePossible() ) |
668 | return; | 668 | return; |
669 | #ifndef DESKTOP_VERSION | 669 | #ifndef DESKTOP_VERSION |
670 | if ( !isVisible() ){ | 670 | if ( !isVisible() ){ |
671 | return; | 671 | return; |
672 | } | 672 | } |
673 | #endif | 673 | #endif |
674 | int size = height() - mLabel->height(); | 674 | int size = height() - mLabel->height(); |
675 | if ( size > 0 ) | 675 | if ( size > 0 ) |
676 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 676 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
677 | size = width() - mLabel->width(); | 677 | size = width() - mLabel->width(); |
678 | if ( size > 0 ) | 678 | if ( size > 0 ) |
679 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 679 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
680 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 680 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
681 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 681 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
682 | } | 682 | } |
683 | 683 | ||
684 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 684 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
685 | { | 685 | { |
686 | if ( !item ) return; | 686 | if ( !item ) return; |
687 | 687 | ||
688 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 688 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
689 | Incidence *incidence = eventItem->incidence(); | 689 | Incidence *incidence = eventItem->incidence(); |
690 | if ( incidence ) mMonthView->defaultAction( incidence ); | 690 | if ( incidence ) mMonthView->defaultAction( incidence ); |
691 | } | 691 | } |
692 | void MonthViewCell::showDay() | 692 | void MonthViewCell::showDay() |
693 | { | 693 | { |
694 | emit showDaySignal( date() ); | 694 | emit showDaySignal( date() ); |
695 | } | 695 | } |
696 | void MonthViewCell::newEvent() | 696 | void MonthViewCell::newEvent() |
697 | { | 697 | { |
698 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 698 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
699 | emit newEventSignal( dt ); | 699 | emit newEventSignal( dt ); |
700 | } | 700 | } |
701 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 701 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
702 | { | 702 | { |
703 | static QListBoxItem * lastClicked = 0; | 703 | static QListBoxItem * lastClicked = 0; |
704 | if ( item == 0 ) { | 704 | if ( item == 0 ) { |
705 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 705 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
706 | emit newEventSignal( dt ); | 706 | emit newEventSignal( dt ); |
707 | return; | 707 | return; |
708 | } | 708 | } |
709 | /* | 709 | /* |
710 | if ( lastClicked ) | 710 | if ( lastClicked ) |
711 | if ( ! item ) { | 711 | if ( ! item ) { |
712 | if ( lastClicked->listBox() != item->listBox() ) | 712 | if ( lastClicked->listBox() != item->listBox() ) |
713 | lastClicked->listBox()->clearSelection(); | 713 | lastClicked->listBox()->clearSelection(); |
714 | } | 714 | } |
715 | */ | 715 | */ |
716 | 716 | ||
717 | mMonthView->setSelectedCell( this ); | 717 | mMonthView->setSelectedCell( this ); |
718 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); | 718 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); |
719 | select(); | 719 | select(); |
720 | } | 720 | } |
721 | 721 | ||
722 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 722 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
723 | { | 723 | { |
724 | if ( !item ) return; | 724 | if ( !item ) return; |
725 | 725 | ||
726 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 726 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
727 | Incidence *incidence = eventItem->incidence(); | 727 | Incidence *incidence = eventItem->incidence(); |
728 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 728 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
729 | } | 729 | } |
730 | 730 | ||
731 | void MonthViewCell::selection( QListBoxItem *item ) | 731 | void MonthViewCell::selection( QListBoxItem *item ) |
732 | { | 732 | { |
733 | if ( !item ) return; | 733 | if ( !item ) return; |
734 | 734 | ||
735 | mMonthView->setSelectedCell( this ); | 735 | mMonthView->setSelectedCell( this ); |
736 | } | 736 | } |
737 | 737 | ||
738 | 738 | ||
739 | // ******************************************************************************* | 739 | // ******************************************************************************* |
740 | // ******************************************************************************* | 740 | // ******************************************************************************* |
741 | // ******************************************************************************* | 741 | // ******************************************************************************* |
742 | 742 | ||
743 | 743 | ||
744 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 744 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
745 | : KOEventView( calendar, parent, name ), | 745 | : KOEventView( calendar, parent, name ), |
746 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 746 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
747 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 747 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
748 | { | 748 | { |
749 | 749 | ||
750 | updatePossible = false; | 750 | updatePossible = false; |
751 | mCells.setAutoDelete( true ); | 751 | mCells.setAutoDelete( true ); |
752 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 752 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
753 | // mDayLayout = new QGridLayout( this ); | 753 | // mDayLayout = new QGridLayout( this ); |
754 | // create the day of the week labels (Sun, Mon, etc) and add them to | 754 | // create the day of the week labels (Sun, Mon, etc) and add them to |
755 | // the layout. | 755 | // the layout. |
756 | mDayLabels.resize( mDaysPerWeek ); | 756 | mDayLabels.resize( mDaysPerWeek ); |
757 | QFont bfont = font(); | 757 | QFont bfont = font(); |
758 | if ( QApplication::desktop()->width() < 650 ) { | 758 | if ( QApplication::desktop()->width() < 650 ) { |
759 | bfont.setPointSize( bfont.pointSize() - 2 ); | 759 | bfont.setPointSize( bfont.pointSize() - 2 ); |
760 | } | 760 | } |
761 | bfont.setBold( true ); | 761 | bfont.setBold( true ); |
762 | int i; | 762 | int i; |
763 | 763 | ||
764 | for( i = 0; i < mDaysPerWeek; i++ ) { | 764 | for( i = 0; i < mDaysPerWeek; i++ ) { |
765 | QLabel *label = new QLabel( this ); | 765 | QLabel *label = new QLabel( this ); |
766 | label->setFont(bfont); | 766 | label->setFont(bfont); |
767 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 767 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
768 | label->setLineWidth(1); | 768 | label->setLineWidth(1); |
769 | label->setAlignment(AlignCenter); | 769 | label->setAlignment(AlignCenter); |
770 | mDayLabels.insert( i, label ); | 770 | mDayLabels.insert( i, label ); |
771 | } | 771 | } |
772 | 772 | ||
773 | bfont.setBold( false ); | 773 | bfont.setBold( false ); |
774 | mWeekLabels.resize( mNumWeeks+1 ); | 774 | mWeekLabels.resize( mNumWeeks+1 ); |
775 | for( i = 0; i < mNumWeeks+1; i++ ) { | 775 | for( i = 0; i < mNumWeeks+1; i++ ) { |
776 | KOWeekButton *label = new KOWeekButton( this ); | 776 | KOWeekButton *label = new KOWeekButton( this ); |
777 | label->setFont(bfont); | 777 | label->setFont(bfont); |
778 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); | 778 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); |
779 | label->setFlat(true); | 779 | label->setFlat(true); |
780 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); | 780 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); |
781 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 781 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
782 | //label->setLineWidth(1); | 782 | //label->setLineWidth(1); |
783 | //label->setAlignment(AlignCenter); | 783 | //label->setAlignment(AlignCenter); |
784 | mWeekLabels.insert( i, label ); | 784 | mWeekLabels.insert( i, label ); |
785 | } | 785 | } |
786 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 786 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
787 | int row, col; | 787 | int row, col; |
788 | mCells.resize( mNumCells ); | 788 | mCells.resize( mNumCells ); |
789 | for( row = 0; row < mNumWeeks; ++row ) { | 789 | for( row = 0; row < mNumWeeks; ++row ) { |
790 | for( col = 0; col < mDaysPerWeek; ++col ) { | 790 | for( col = 0; col < mDaysPerWeek; ++col ) { |
791 | MonthViewCell *cell = new MonthViewCell( this ); | 791 | MonthViewCell *cell = new MonthViewCell( this ); |
792 | mCells.insert( row * mDaysPerWeek + col, cell ); | 792 | mCells.insert( row * mDaysPerWeek + col, cell ); |
793 | 793 | ||
794 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 794 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
795 | SLOT( defaultAction( Incidence * ) ) ); | 795 | SLOT( defaultAction( Incidence * ) ) ); |
796 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 796 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
797 | SIGNAL( newEventSignal( QDateTime ) ) ); | 797 | SIGNAL( newEventSignal( QDateTime ) ) ); |
798 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 798 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
799 | SIGNAL( showDaySignal( QDate ) ) ); | 799 | SIGNAL( showDaySignal( QDate ) ) ); |
800 | } | 800 | } |
801 | } | 801 | } |
802 | 802 | ||
803 | mContextMenu = eventPopup(); | 803 | mContextMenu = eventPopup(); |
804 | // updateConfig(); //useless here | 804 | // updateConfig(); //useless here |
805 | 805 | ||
806 | emit incidenceSelected( 0 ); | 806 | emit incidenceSelected( 0 ); |
807 | } | 807 | } |
808 | 808 | ||
809 | KOMonthView::~KOMonthView() | 809 | KOMonthView::~KOMonthView() |
810 | { | 810 | { |
811 | delete mContextMenu; | 811 | delete mContextMenu; |
812 | } | 812 | } |
813 | 813 | ||
814 | int KOMonthView::maxDatesHint() | 814 | int KOMonthView::maxDatesHint() |
815 | { | 815 | { |
816 | return mNumCells; | 816 | return mNumCells; |
817 | } | 817 | } |
818 | 818 | ||
819 | int KOMonthView::currentDateCount() | 819 | int KOMonthView::currentDateCount() |
820 | { | 820 | { |
821 | return mNumCells; | 821 | return mNumCells; |
822 | } | 822 | } |
823 | 823 | ||
824 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 824 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
825 | { | 825 | { |
826 | QPtrList<Incidence> selected; | 826 | QPtrList<Incidence> selected; |
827 | 827 | ||
828 | if ( mSelectedCell ) { | 828 | if ( mSelectedCell ) { |
829 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 829 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
830 | if ( incidence ) selected.append( incidence ); | 830 | if ( incidence ) selected.append( incidence ); |
831 | } | 831 | } |
832 | 832 | ||
833 | return selected; | 833 | return selected; |
834 | } | 834 | } |
835 | 835 | ||
836 | DateList KOMonthView::selectedDates() | 836 | DateList KOMonthView::selectedDates() |
837 | { | 837 | { |
838 | DateList selected; | 838 | DateList selected; |
839 | 839 | ||
840 | if ( mSelectedCell ) { | 840 | if ( mSelectedCell ) { |
841 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 841 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
842 | if ( qd.isValid() ) selected.append( qd ); | 842 | if ( qd.isValid() ) selected.append( qd ); |
843 | } | 843 | } |
844 | 844 | ||
845 | return selected; | 845 | return selected; |
846 | } | 846 | } |
847 | 847 | ||
848 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 848 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
849 | const QDate &td) | 849 | const QDate &td) |
850 | { | 850 | { |
851 | #ifndef KORG_NOPRINTER | 851 | #ifndef KORG_NOPRINTER |
852 | calPrinter->preview(CalPrinter::Month, fd, td); | 852 | calPrinter->preview(CalPrinter::Month, fd, td); |
853 | #endif | 853 | #endif |
854 | } | 854 | } |
855 | 855 | ||
856 | void KOMonthView::updateConfig() | 856 | void KOMonthView::updateConfig() |
857 | { | 857 | { |
858 | 858 | ||
859 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 859 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
860 | 860 | ||
861 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 861 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
862 | mWidthLongDayLabel = 0; | 862 | mWidthLongDayLabel = 0; |
863 | 863 | ||
864 | for (int i = 0; i < 7; i++) { | 864 | for (int i = 0; i < 7; i++) { |
865 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 865 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
866 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 866 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
867 | } | 867 | } |
868 | bool temp = mShowSatSunComp ; | 868 | bool temp = mShowSatSunComp ; |
869 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 869 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
870 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 870 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
871 | computeLayout(); | 871 | computeLayout(); |
872 | updateDayLabels(); | 872 | updateDayLabels(); |
873 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 873 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
874 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 874 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
875 | //resizeEvent( 0 ); | 875 | //resizeEvent( 0 ); |
876 | for (uint i = 0; i < mCells.count(); ++i) { | 876 | for (uint i = 0; i < mCells.count(); ++i) { |
877 | mCells[i]->updateConfig(); | 877 | mCells[i]->updateConfig(); |
878 | } | 878 | } |
879 | #ifdef DESKTOP_VERSION | 879 | #ifdef DESKTOP_VERSION |
880 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 880 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
881 | #endif | 881 | #endif |
882 | } | 882 | } |
883 | 883 | ||
884 | void KOMonthView::updateDayLabels() | 884 | void KOMonthView::updateDayLabels() |
885 | { | 885 | { |
886 | 886 | ||
887 | for (int i = 0; i < 7; i++) { | 887 | for (int i = 0; i < 7; i++) { |
888 | if (mWeekStartsMonday) { | 888 | if (mWeekStartsMonday) { |
889 | bool show = mShortDayLabels; | 889 | bool show = mShortDayLabels; |
890 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 890 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
891 | show = true; | 891 | show = true; |
892 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 892 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
893 | } else { | 893 | } else { |
894 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 894 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
895 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 895 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
896 | 896 | ||
897 | } | 897 | } |
898 | } | 898 | } |
899 | } | 899 | } |
900 | 900 | ||
901 | void KOMonthView::showDates(const QDate &start, const QDate &) | 901 | void KOMonthView::showDates(const QDate &start, const QDate &) |
902 | { | 902 | { |
903 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 903 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
904 | 904 | ||
905 | 905 | ||
906 | mStartDate = start; | 906 | mStartDate = start; |
907 | 907 | ||
908 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 908 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
909 | 909 | ||
910 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 910 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
911 | mStartDate = mStartDate.addDays( -1 ); | 911 | mStartDate = mStartDate.addDays( -1 ); |
912 | } | 912 | } |
913 | 913 | ||
914 | bool primary = false; | 914 | bool primary = false; |
915 | uint i; | 915 | uint i; |
916 | for( i = 0; i < mCells.size(); ++i ) { | 916 | for( i = 0; i < mCells.size(); ++i ) { |
917 | QDate date = mStartDate.addDays( i ); | 917 | QDate date = mStartDate.addDays( i ); |
918 | mCells[i]->setDate( date ); | 918 | mCells[i]->setDate( date ); |
919 | 919 | ||
920 | #ifndef KORG_NOPLUGINS | 920 | #ifndef KORG_NOPLUGINS |
921 | // add holiday, if present | 921 | // add holiday, if present |
922 | QString hstring(KOCore::self()->holiday(date)); | 922 | QString hstring(KOCore::self()->holiday(date)); |
923 | mCells[i]->setHoliday( hstring ); | 923 | mCells[i]->setHoliday( hstring ); |
924 | #endif | 924 | #endif |
925 | 925 | ||
926 | } | 926 | } |
927 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 927 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
928 | for( i = 0; i < 6; ++i ) { | 928 | for( i = 0; i < 6; ++i ) { |
929 | int wno; | 929 | int wno; |
930 | // remember, according to ISO 8601, the first week of the year is the | 930 | // remember, according to ISO 8601, the first week of the year is the |
931 | // first week that contains a thursday. Thus we must subtract off 4, | 931 | // first week that contains a thursday. Thus we must subtract off 4, |
932 | // not just 1. | 932 | // not just 1. |
933 | int dayOfYear = date.dayOfYear(); | 933 | int dayOfYear = date.dayOfYear(); |
934 | if (dayOfYear % 7 != 0) | 934 | if (dayOfYear % 7 != 0) |
935 | wno = dayOfYear / 7 + 1; | 935 | wno = dayOfYear / 7 + 1; |
936 | else | 936 | else |
937 | wno =dayOfYear / 7; | 937 | wno =dayOfYear / 7; |
938 | mWeekLabels[i]->setWeekNum( wno ); | 938 | mWeekLabels[i]->setWeekNum( wno ); |
939 | date = date.addDays( 7 ); | 939 | date = date.addDays( 7 ); |
940 | } | 940 | } |
941 | updateView(); | 941 | updateView(); |
942 | } | 942 | } |
943 | 943 | ||
944 | void KOMonthView::showEvents(QPtrList<Event>) | 944 | void KOMonthView::showEvents(QPtrList<Event>) |
945 | { | 945 | { |
946 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 946 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
947 | } | 947 | } |
948 | 948 | ||
949 | void KOMonthView::changeEventDisplay(Event *, int) | 949 | void KOMonthView::changeEventDisplay(Event *, int) |
950 | { | 950 | { |
951 | // this should be re-written to be much more efficient, but this | 951 | // this should be re-written to be much more efficient, but this |
952 | // quick-and-dirty-hack gets the job done for right now. | 952 | // quick-and-dirty-hack gets the job done for right now. |
953 | updateView(); | 953 | updateView(); |
954 | } | 954 | } |
955 | 955 | ||
956 | void KOMonthView::updateView() | 956 | void KOMonthView::updateView() |
957 | { | 957 | { |
958 | 958 | ||
959 | if ( !updatePossible ) | 959 | if ( !updatePossible ) |
960 | return; | 960 | return; |
961 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 961 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
962 | int i; | 962 | int i; |
963 | for( i = 0; i < mCells.count(); ++i ) { | 963 | for( i = 0; i < mCells.count(); ++i ) { |
964 | mCells[i]->updateCell(); | 964 | mCells[i]->updateCell(); |
965 | } | 965 | } |
966 | 966 | ||
967 | //qDebug("KOMonthView::updateView() "); | 967 | //qDebug("KOMonthView::updateView() "); |
968 | processSelectionChange(); | 968 | processSelectionChange(); |
969 | // qDebug("---------------------------------------------------------------------+ "); | 969 | // qDebug("---------------------------------------------------------------------+ "); |
970 | setFocus(); | 970 | mCells[0]->setFocus(); |
971 | } | 971 | } |
972 | 972 | ||
973 | void KOMonthView::resizeEvent(QResizeEvent * e) | 973 | void KOMonthView::resizeEvent(QResizeEvent * e) |
974 | { | 974 | { |
975 | computeLayout(); | 975 | computeLayout(); |
976 | } | 976 | } |
977 | void KOMonthView::computeLayout() | 977 | void KOMonthView::computeLayout() |
978 | { | 978 | { |
979 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 979 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
980 | // note this only changes the text if the requested size crosses the | 980 | // note this only changes the text if the requested size crosses the |
981 | // threshold between big enough to support the full name and not big | 981 | // threshold between big enough to support the full name and not big |
982 | // enough. | 982 | // enough. |
983 | 983 | ||
984 | int daysToShow = 7; | 984 | int daysToShow = 7; |
985 | bool combinedSatSun = false; | 985 | bool combinedSatSun = false; |
986 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 986 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
987 | daysToShow = 6; | 987 | daysToShow = 6; |
988 | combinedSatSun = true; | 988 | combinedSatSun = true; |
989 | } | 989 | } |
990 | int tWid = topLevelWidget()->size().width(); | 990 | int tWid = topLevelWidget()->size().width(); |
991 | int tHei = topLevelWidget()->size().height(); | 991 | int tHei = topLevelWidget()->size().height(); |
992 | 992 | ||
993 | int wid = size().width();//e | 993 | int wid = size().width();//e |
994 | int hei = size().height()-1; | 994 | int hei = size().height()-1; |
995 | 995 | ||
996 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 996 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
997 | return; | 997 | return; |
998 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 998 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
999 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 999 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1000 | int weeklabelwid = fm.width( "888" ); | 1000 | int weeklabelwid = fm.width( "888" ); |
1001 | wid -= weeklabelwid; | 1001 | wid -= weeklabelwid; |
1002 | 1002 | ||
1003 | int colWid = wid / daysToShow; | 1003 | int colWid = wid / daysToShow; |
1004 | int lastCol = wid - ( colWid*6 ); | 1004 | int lastCol = wid - ( colWid*6 ); |
1005 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1005 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1006 | int cellHei = (hei - dayLabelHei) /6; | 1006 | int cellHei = (hei - dayLabelHei) /6; |
1007 | int colModulo = wid % daysToShow; | 1007 | int colModulo = wid % daysToShow; |
1008 | int rowModulo = (hei- dayLabelHei) % 6; | 1008 | int rowModulo = (hei- dayLabelHei) % 6; |
1009 | //qDebug("rowmod %d ", rowModulo); | 1009 | //qDebug("rowmod %d ", rowModulo); |
1010 | int i; | 1010 | int i; |
1011 | int x,y,w,h; | 1011 | int x,y,w,h; |
1012 | x= 0; | 1012 | x= 0; |
1013 | y= 0; | 1013 | y= 0; |
1014 | w = colWid; | 1014 | w = colWid; |
1015 | h = dayLabelHei ; | 1015 | h = dayLabelHei ; |
1016 | for ( i = 0; i < 7; i++) { | 1016 | for ( i = 0; i < 7; i++) { |
1017 | if ( i == daysToShow-colModulo ) | 1017 | if ( i == daysToShow-colModulo ) |
1018 | ++w; | 1018 | ++w; |
1019 | if ( combinedSatSun ) { | 1019 | if ( combinedSatSun ) { |
1020 | if ( i >= daysToShow-1 ) { | 1020 | if ( i >= daysToShow-1 ) { |
1021 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1021 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1022 | x -= w/2 ; | 1022 | x -= w/2 ; |
1023 | } | 1023 | } |
1024 | else | 1024 | else |
1025 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1025 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1026 | } else | 1026 | } else |
1027 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1027 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1028 | x += w; | 1028 | x += w; |
1029 | } | 1029 | } |
1030 | x= 0; | 1030 | x= 0; |
1031 | y= dayLabelHei; | 1031 | y= dayLabelHei; |
1032 | w = colWid; | 1032 | w = colWid; |
1033 | h = cellHei ; | 1033 | h = cellHei ; |
1034 | for ( i = 0; i < mCells.count(); ++i) { | 1034 | for ( i = 0; i < mCells.count(); ++i) { |
1035 | 1035 | ||
1036 | w = colWid; | 1036 | w = colWid; |
1037 | if ( ((i) % 7) >= 7-colModulo ) { | 1037 | if ( ((i) % 7) >= 7-colModulo ) { |
1038 | ++w; | 1038 | ++w; |
1039 | } | 1039 | } |
1040 | if ( i == (6-rowModulo)*7) | 1040 | if ( i == (6-rowModulo)*7) |
1041 | ++h; | 1041 | ++h; |
1042 | if ( combinedSatSun ) { | 1042 | if ( combinedSatSun ) { |
1043 | if ( (i)%7 >= daysToShow-1 ) { | 1043 | if ( (i)%7 >= daysToShow-1 ) { |
1044 | if ( (i)%7 == daysToShow-1 ) { | 1044 | if ( (i)%7 == daysToShow-1 ) { |
1045 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1045 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1046 | x -= w ;y += h/2; | 1046 | x -= w ;y += h/2; |
1047 | } else { | 1047 | } else { |
1048 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1048 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1049 | y -= h/2; | 1049 | y -= h/2; |
1050 | } | 1050 | } |
1051 | } else | 1051 | } else |
1052 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1052 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1053 | 1053 | ||
1054 | } | 1054 | } |
1055 | else | 1055 | else |
1056 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1056 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1057 | x += w; | 1057 | x += w; |
1058 | if ( x + w/2 > wid ) { | 1058 | if ( x + w/2 > wid ) { |
1059 | x = 0; | 1059 | x = 0; |
1060 | y += h; | 1060 | y += h; |
1061 | } | 1061 | } |
1062 | } | 1062 | } |
1063 | y= dayLabelHei; | 1063 | y= dayLabelHei; |
1064 | h = cellHei ; | 1064 | h = cellHei ; |
1065 | for ( i = 0; i < 6; i++) { | 1065 | for ( i = 0; i < 6; i++) { |
1066 | if ( i == (6-rowModulo)) | 1066 | if ( i == (6-rowModulo)) |
1067 | ++h; | 1067 | ++h; |
1068 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1068 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1069 | y += h; | 1069 | y += h; |
1070 | } | 1070 | } |
1071 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1071 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1072 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1072 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1073 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1073 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1074 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1074 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1075 | updateDayLabels(); | 1075 | updateDayLabels(); |
1076 | bool forceUpdate = !updatePossible; | 1076 | bool forceUpdate = !updatePossible; |
1077 | updatePossible = true; | 1077 | updatePossible = true; |
1078 | if ( forceUpdate ) | 1078 | if ( forceUpdate ) |
1079 | updateView(); | 1079 | updateView(); |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1082 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1083 | { | 1083 | { |
1084 | mContextMenu->showIncidencePopup(incidence); | 1084 | mContextMenu->showIncidencePopup(incidence); |
1085 | /* | 1085 | /* |
1086 | if( incidence && incidence->type() == "Event" ) { | 1086 | if( incidence && incidence->type() == "Event" ) { |
1087 | Event *event = static_cast<Event *>(incidence); | 1087 | Event *event = static_cast<Event *>(incidence); |
1088 | mContextMenu->showEventPopup(event); | 1088 | mContextMenu->showEventPopup(event); |
1089 | } else { | 1089 | } else { |
1090 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1090 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1091 | } | 1091 | } |
1092 | */ | 1092 | */ |
1093 | } | 1093 | } |
1094 | MonthViewCell * KOMonthView::selectedCell( ) | 1094 | MonthViewCell * KOMonthView::selectedCell( ) |
1095 | { | 1095 | { |
1096 | return mSelectedCell; | 1096 | return mSelectedCell; |
1097 | } | 1097 | } |
1098 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1098 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1099 | { | 1099 | { |
1100 | // qDebug("KOMonthView::setSelectedCell "); | 1100 | // qDebug("KOMonthView::setSelectedCell "); |
1101 | if ( mSelectedCell && mSelectedCell != cell ) { | 1101 | if ( mSelectedCell && mSelectedCell != cell ) { |
1102 | MonthViewCell * mvc = mSelectedCell; | 1102 | MonthViewCell * mvc = mSelectedCell; |
1103 | mSelectedCell = cell; | 1103 | mSelectedCell = cell; |
1104 | mvc->deselect(); | 1104 | mvc->deselect(); |
1105 | } else | 1105 | } else |
1106 | mSelectedCell = cell; | 1106 | mSelectedCell = cell; |
1107 | // if ( mSelectedCell ) | 1107 | // if ( mSelectedCell ) |
1108 | // mSelectedCell->select(); | 1108 | // mSelectedCell->select(); |
1109 | if ( !mSelectedCell ) | 1109 | if ( !mSelectedCell ) |
1110 | emit incidenceSelected( 0 ); | 1110 | emit incidenceSelected( 0 ); |
1111 | else | 1111 | else |
1112 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1112 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | void KOMonthView::processSelectionChange() | 1115 | void KOMonthView::processSelectionChange() |
1116 | { | 1116 | { |
1117 | QPtrList<Incidence> incidences = selectedIncidences(); | 1117 | QPtrList<Incidence> incidences = selectedIncidences(); |
1118 | if (incidences.count() > 0) { | 1118 | if (incidences.count() > 0) { |
1119 | emit incidenceSelected( incidences.first() ); | 1119 | emit incidenceSelected( incidences.first() ); |
1120 | } else { | 1120 | } else { |
1121 | emit incidenceSelected( 0 ); | 1121 | emit incidenceSelected( 0 ); |
1122 | } | 1122 | } |
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | void KOMonthView::clearSelection() | 1125 | void KOMonthView::clearSelection() |
1126 | { | 1126 | { |
1127 | if ( mSelectedCell ) { | 1127 | if ( mSelectedCell ) { |
1128 | mSelectedCell->deselect(); | 1128 | mSelectedCell->deselect(); |
1129 | mSelectedCell = 0; | 1129 | mSelectedCell = 0; |
1130 | } | 1130 | } |
1131 | } | 1131 | } |
1132 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1132 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1133 | { | 1133 | { |
1134 | //qDebug("KOMonthView::keyPressEvent "); | ||
1134 | switch(e->key()) { | 1135 | switch(e->key()) { |
1135 | break; | ||
1136 | case Key_Up: | 1136 | case Key_Up: |
1137 | { | 1137 | { |
1138 | emit prevMonth(); | 1138 | emit prevMonth(); |
1139 | setFocus(); | 1139 | mCells[0]->setFocus(); |
1140 | } | 1140 | } |
1141 | e->accept(); | 1141 | e->accept(); |
1142 | break; | 1142 | break; |
1143 | case Key_Down: | 1143 | case Key_Down: |
1144 | { | 1144 | { |
1145 | emit nextMonth(); | 1145 | emit nextMonth(); |
1146 | setFocus(); | 1146 | mCells[0]->setFocus(); |
1147 | |||
1147 | } | 1148 | } |
1148 | e->accept(); | 1149 | e->accept(); |
1149 | break; | 1150 | break; |
1150 | default: | 1151 | default: |
1151 | e->ignore(); | 1152 | e->ignore(); |
1152 | break; | 1153 | break; |
1153 | } | 1154 | } |
1154 | } | 1155 | } |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 6da4799..4c03f9a 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -1,647 +1,645 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001 | 4 | Copyright (c) 2001 |
5 | Cornelius Schumacher <schumacher@kde.org> | 5 | Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | mCurrentView = 0; | 63 | mCurrentView = 0; |
64 | 64 | ||
65 | mWhatsNextView = 0; | 65 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 66 | mTodoView = 0; |
67 | mAgendaView = 0; | 67 | mAgendaView = 0; |
68 | mMonthView = 0; | 68 | mMonthView = 0; |
69 | mListView = 0; | 69 | mListView = 0; |
70 | mJournalView = 0; | 70 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 71 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 72 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 73 | mFlagShowNextxDays = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") showMonthView(); | 91 | else if (view == "Month") showMonthView(); |
92 | else if (view == "List") showListView(); | 92 | else if (view == "List") showListView(); |
93 | else if (view == "Journal") showJournalView(); | 93 | else if (view == "Journal") showJournalView(); |
94 | else if (view == "TimeSpan") showTimeSpanView(); | 94 | else if (view == "TimeSpan") showTimeSpanView(); |
95 | else if (view == "Todo") showTodoView(); | 95 | else if (view == "Todo") showTodoView(); |
96 | else { | 96 | else { |
97 | showAgendaView(); | 97 | showAgendaView(); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void KOViewManager::showDateView( int view, QDate date) | 102 | void KOViewManager::showDateView( int view, QDate date) |
103 | { | 103 | { |
104 | 104 | ||
105 | qDebug("date %d %s", view, date.toString().latin1()); | 105 | //qDebug("date %d %s", view, date.toString().latin1()); |
106 | #if 0 | 106 | #if 0 |
107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); | 108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); |
109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); | 109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); |
110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); | 110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); |
111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
112 | #endif | 112 | #endif |
113 | if ( view == 3 ) { | 113 | if ( view == 3 ) { |
114 | mMainView->showDay( date ); | 114 | mMainView->showDay( date ); |
115 | } else if (view == 4 ) { | 115 | } else if (view == 4 ) { |
116 | mMainView->dateNavigator()->selectDates( date, 7 ); | 116 | mMainView->dateNavigator()->selectDates( date, 7 ); |
117 | } else if (view == 5 ) { | 117 | } else if (view == 5 ) { |
118 | mMainView->dateNavigator()->selectDates( date, 14); | 118 | mMainView->dateNavigator()->selectDates( date, 14); |
119 | } else if (view == 6 ) { | 119 | } else if (view == 6 ) { |
120 | showMonthView(); | 120 | showMonthView(); |
121 | mMainView->dateNavigator()->selectMonthByDate( date ); | 121 | mMainView->dateNavigator()->selectMonthByDate( date ); |
122 | mMainView->dateNavigator()->selectDate( date ); | 122 | mMainView->dateNavigator()->selectDate( date ); |
123 | } else if (view == 7 ) { | 123 | } else if (view == 7 ) { |
124 | mMainView->dateNavigator()->selectDate( date ); | 124 | mMainView->dateNavigator()->selectDate( date ); |
125 | showJournalView(); | 125 | showJournalView(); |
126 | } else if (view == 8 ) { | 126 | } else if (view == 8 ) { |
127 | globalFlagBlockAgenda = 1; | 127 | globalFlagBlockAgenda = 1; |
128 | if ( mCurrentAgendaView != 3 ) | 128 | if ( mCurrentAgendaView != 3 ) |
129 | mCurrentAgendaView = -1; | 129 | mCurrentAgendaView = -1; |
130 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 130 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
131 | globalFlagBlockAgenda = 2; | 131 | globalFlagBlockAgenda = 2; |
132 | mMainView->dateNavigator()->selectDates( date , | 132 | mMainView->dateNavigator()->selectDates( date , |
133 | KOPrefs::instance()->mNextXDays ); | 133 | KOPrefs::instance()->mNextXDays ); |
134 | mFlagShowNextxDays = true; | 134 | mFlagShowNextxDays = true; |
135 | mCurrentAgendaView = 3 ; | 135 | mCurrentAgendaView = 3 ; |
136 | } | 136 | } |
137 | 137 | ||
138 | #if 0 | 138 | #if 0 |
139 | dateNavigator()->blockSignals( true ); | 139 | dateNavigator()->blockSignals( true ); |
140 | dateNavigator()->selectDate( d ); | 140 | dateNavigator()->selectDate( d ); |
141 | dateNavigator()->blockSignals( false ); | 141 | dateNavigator()->blockSignals( false ); |
142 | mViewManager->showDayView(); | 142 | mViewManager->showDayView(); |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | 148 | ||
149 | void KOViewManager::writeSettings(KConfig *config) | 149 | void KOViewManager::writeSettings(KConfig *config) |
150 | { | 150 | { |
151 | config->setGroup("General"); | 151 | config->setGroup("General"); |
152 | 152 | ||
153 | QString view; | 153 | QString view; |
154 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 154 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
155 | else if (mCurrentView == mMonthView) view = "Month"; | 155 | else if (mCurrentView == mMonthView) view = "Month"; |
156 | else if (mCurrentView == mListView) view = "List"; | 156 | else if (mCurrentView == mListView) view = "List"; |
157 | else if (mCurrentView == mJournalView) view = "Journal"; | 157 | else if (mCurrentView == mJournalView) view = "Journal"; |
158 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 158 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
159 | else if (mCurrentView == mTodoView) view = "Todo"; | 159 | else if (mCurrentView == mTodoView) view = "Todo"; |
160 | else view = "Agenda"; | 160 | else view = "Agenda"; |
161 | 161 | ||
162 | config->writeEntry("Current View",view); | 162 | config->writeEntry("Current View",view); |
163 | 163 | ||
164 | if (mAgendaView) { | 164 | if (mAgendaView) { |
165 | mAgendaView->writeSettings(config); | 165 | mAgendaView->writeSettings(config); |
166 | } | 166 | } |
167 | if (mTimeSpanView) { | 167 | if (mTimeSpanView) { |
168 | mTimeSpanView->writeSettings(config); | 168 | mTimeSpanView->writeSettings(config); |
169 | } | 169 | } |
170 | if (mListView) { | 170 | if (mListView) { |
171 | mListView->writeSettings(config); | 171 | mListView->writeSettings(config); |
172 | } | 172 | } |
173 | if (mTodoView) { | 173 | if (mTodoView) { |
174 | mTodoView->saveLayout(config,"Todo View"); | 174 | mTodoView->saveLayout(config,"Todo View"); |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 178 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
179 | { | 179 | { |
180 | 180 | ||
181 | //mFlagShowNextxDays = false; | 181 | //mFlagShowNextxDays = false; |
182 | //if(view == mCurrentView) return; | 182 | //if(view == mCurrentView) return; |
183 | if ( view == 0 ) { | 183 | if ( view == 0 ) { |
184 | view = mCurrentView; | 184 | view = mCurrentView; |
185 | if ( view == 0 ) | 185 | if ( view == 0 ) |
186 | return; | 186 | return; |
187 | } | 187 | } |
188 | bool full = fullScreen; | 188 | bool full = fullScreen; |
189 | if(view == mCurrentView && view != mWhatsNextView ) { | 189 | if(view == mCurrentView && view != mWhatsNextView ) { |
190 | if ( mCurrentAgendaView < 0 ) | 190 | if ( mCurrentAgendaView < 0 ) |
191 | return; | 191 | return; |
192 | full = mMainView->leftFrame()->isVisible(); | 192 | full = mMainView->leftFrame()->isVisible(); |
193 | } else { | 193 | } else { |
194 | mCurrentView = view; | 194 | mCurrentView = view; |
195 | |||
196 | // bool full = fullScreen; | 195 | // bool full = fullScreen; |
197 | bool isFull = !mMainView->leftFrame()->isVisible(); | 196 | bool isFull = !mMainView->leftFrame()->isVisible(); |
198 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 197 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
199 | full = true; | 198 | full = true; |
200 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 199 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
201 | full = false; | 200 | full = false; |
202 | } | 201 | } |
203 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 202 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
204 | //raiseCurrentView( full ); | 203 | //raiseCurrentView( full ); |
205 | mMainView->processIncidenceSelection( 0 ); | 204 | mMainView->processIncidenceSelection( 0 ); |
206 | mMainView->updateView(); | 205 | mMainView->updateView(); |
207 | raiseCurrentView( full ); | 206 | raiseCurrentView( full ); |
208 | mMainView->adaptNavigationUnits(); | 207 | mMainView->adaptNavigationUnits(); |
209 | } | 208 | } |
210 | 209 | ||
211 | void KOViewManager::raiseCurrentView( bool fullScreen ) | 210 | void KOViewManager::raiseCurrentView( bool fullScreen ) |
212 | { | 211 | { |
213 | //qDebug("raiseCurrentView "); | ||
214 | mCurrentAgendaView = 0; | 212 | mCurrentAgendaView = 0; |
215 | int wid = mMainView->width() ; | 213 | int wid = mMainView->width() ; |
216 | int hei = mMainView->height(); | 214 | int hei = mMainView->height(); |
217 | if ( mCurrentView == mMonthView ) { | 215 | if ( mCurrentView == mMonthView ) { |
218 | mMainView->navigatorBar()->show(); | 216 | mMainView->navigatorBar()->show(); |
219 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 217 | hei -= mMainView->navigatorBar()->sizeHint().height(); |
220 | //mMainView->navigatorBar()->hide(); | 218 | //mMainView->navigatorBar()->hide(); |
221 | } else { | 219 | } else { |
222 | mMainView->navigatorBar()->hide(); | 220 | mMainView->navigatorBar()->hide(); |
223 | } | 221 | } |
224 | if ( fullScreen ) { | 222 | if ( fullScreen ) { |
225 | mMainView->leftFrame()->hide(); | 223 | mMainView->leftFrame()->hide(); |
226 | } else { | 224 | } else { |
227 | mMainView->leftFrame()->show(); | 225 | mMainView->leftFrame()->show(); |
228 | if ( KOPrefs::instance()->mVerticalScreen ) | 226 | if ( KOPrefs::instance()->mVerticalScreen ) |
229 | hei -= mMainView->leftFrame()->height(); | 227 | hei -= mMainView->leftFrame()->height(); |
230 | else | 228 | else |
231 | wid -= mMainView->leftFrame()->width(); | 229 | wid -= mMainView->leftFrame()->width(); |
232 | } | 230 | } |
233 | emit signalFullScreen( !fullScreen ); | 231 | emit signalFullScreen( !fullScreen ); |
234 | if ( globalFlagBlockAgenda == 5 ) { | 232 | if ( globalFlagBlockAgenda == 5 ) { |
235 | globalFlagBlockAgenda = 4; | 233 | globalFlagBlockAgenda = 4; |
236 | globalFlagBlockAgendaItemPaint = 1; | 234 | globalFlagBlockAgendaItemPaint = 1; |
237 | } | 235 | } |
238 | mMainView->viewStack()->raiseWidget(mCurrentView); | 236 | mMainView->viewStack()->raiseWidget(mCurrentView); |
239 | if ( globalFlagBlockAgenda == 4 ) { | 237 | if ( globalFlagBlockAgenda == 4 ) { |
240 | if ( mCurrentView == mAgendaView ) { | 238 | if ( mCurrentView == mAgendaView ) { |
241 | //globalFlagBlockAgenda =1 ; | 239 | //globalFlagBlockAgenda =1 ; |
242 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 240 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
243 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 241 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
244 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 242 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
245 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 243 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
246 | qApp->processEvents(); | 244 | qApp->processEvents(); |
247 | //qDebug("qApp->processEvents() "); | 245 | //qDebug("qApp->processEvents() "); |
248 | globalFlagBlockAgenda = 0; | 246 | globalFlagBlockAgenda = 0; |
249 | mAgendaView->repaintAgenda(); | 247 | mAgendaView->repaintAgenda(); |
250 | 248 | ||
251 | } | 249 | } |
252 | globalFlagBlockAgenda = 0; | 250 | globalFlagBlockAgenda = 0; |
253 | } | 251 | } |
254 | emit signalAgendaView( mCurrentView == mAgendaView ); | 252 | emit signalAgendaView( mCurrentView == mAgendaView ); |
255 | //qDebug("raiseCurrentView ende "); | 253 | //qDebug("raiseCurrentView ende "); |
256 | 254 | ||
257 | } | 255 | } |
258 | 256 | ||
259 | void KOViewManager::updateView() | 257 | void KOViewManager::updateView() |
260 | { | 258 | { |
261 | // qDebug("KOViewManager::updateView() "); | 259 | // qDebug("KOViewManager::updateView() "); |
262 | // if we are updating mTodoView, we get endless recursion | 260 | // if we are updating mTodoView, we get endless recursion |
263 | if ( mTodoView == mCurrentView ) | 261 | if ( mTodoView == mCurrentView ) |
264 | return; | 262 | return; |
265 | if ( mCurrentView ) mCurrentView->updateView(); | 263 | if ( mCurrentView ) mCurrentView->updateView(); |
266 | 264 | ||
267 | } | 265 | } |
268 | 266 | ||
269 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 267 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
270 | { | 268 | { |
271 | // kdDebug() << "KOViewManager::updateView()" << endl; | 269 | // kdDebug() << "KOViewManager::updateView()" << endl; |
272 | 270 | ||
273 | if (mCurrentView) mCurrentView->showDates(start, end); | 271 | if (mCurrentView) mCurrentView->showDates(start, end); |
274 | 272 | ||
275 | if (mTodoView) mTodoView->updateView(); | 273 | if (mTodoView) mTodoView->updateView(); |
276 | } | 274 | } |
277 | 275 | ||
278 | 276 | ||
279 | void KOViewManager::updateWNview() | 277 | void KOViewManager::updateWNview() |
280 | { | 278 | { |
281 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 279 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
282 | mWhatsNextView->updateView(); | 280 | mWhatsNextView->updateView(); |
283 | 281 | ||
284 | } | 282 | } |
285 | void KOViewManager::showWhatsNextView() | 283 | void KOViewManager::showWhatsNextView() |
286 | { | 284 | { |
287 | if (!mWhatsNextView) { | 285 | if (!mWhatsNextView) { |
288 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 286 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
289 | "KOViewManager::WhatsNextView"); | 287 | "KOViewManager::WhatsNextView"); |
290 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 288 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
291 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 289 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
292 | addView(mWhatsNextView); | 290 | addView(mWhatsNextView); |
293 | connect(this, SIGNAL( printWNV() ), | 291 | connect(this, SIGNAL( printWNV() ), |
294 | mWhatsNextView, SLOT( printMe() ) ); | 292 | mWhatsNextView, SLOT( printMe() ) ); |
295 | } | 293 | } |
296 | globalFlagBlockAgenda = 1; | 294 | globalFlagBlockAgenda = 1; |
297 | showView(mWhatsNextView, true ); | 295 | showView(mWhatsNextView, true ); |
298 | //mWhatsNextView->updateView(); | 296 | //mWhatsNextView->updateView(); |
299 | 297 | ||
300 | } | 298 | } |
301 | 299 | ||
302 | void KOViewManager::showListView() | 300 | void KOViewManager::showListView() |
303 | { | 301 | { |
304 | if (!mListView) { | 302 | if (!mListView) { |
305 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 303 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
306 | addView(mListView); | 304 | addView(mListView); |
307 | 305 | ||
308 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 306 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
309 | mMainView, SLOT(showIncidence(Incidence *))); | 307 | mMainView, SLOT(showIncidence(Incidence *))); |
310 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 308 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
311 | mMainView, SLOT(editIncidence(Incidence *))); | 309 | mMainView, SLOT(editIncidence(Incidence *))); |
312 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 310 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
313 | mMainView, SLOT(deleteIncidence(Incidence *))); | 311 | mMainView, SLOT(deleteIncidence(Incidence *))); |
314 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 312 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
315 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 313 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
316 | connect( mListView, SIGNAL( signalNewEvent() ), | 314 | connect( mListView, SIGNAL( signalNewEvent() ), |
317 | mMainView, SLOT( newEvent() ) ); | 315 | mMainView, SLOT( newEvent() ) ); |
318 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 316 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
319 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 317 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
320 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 318 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
321 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 319 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
322 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 320 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
323 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 321 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
324 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 322 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
325 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 323 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
326 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 324 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
327 | } | 325 | } |
328 | // bool temp = mFlagShowNextxDays; | 326 | // bool temp = mFlagShowNextxDays; |
329 | //globalFlagBlockPainting = true; | 327 | //globalFlagBlockPainting = true; |
330 | globalFlagBlockAgenda = 1; | 328 | globalFlagBlockAgenda = 1; |
331 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { | 329 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { |
332 | mMainView->setBlockShowDates( true ); | 330 | mMainView->setBlockShowDates( true ); |
333 | mMainView->dateNavigator()->selectMonth(); | 331 | mMainView->dateNavigator()->selectMonth(); |
334 | mMainView->setBlockShowDates( false ); | 332 | mMainView->setBlockShowDates( false ); |
335 | } | 333 | } |
336 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 334 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
337 | //mFlagShowNextxDays = temp; | 335 | //mFlagShowNextxDays = temp; |
338 | } | 336 | } |
339 | 337 | ||
340 | void KOViewManager::showAgendaView( bool fullScreen ) | 338 | void KOViewManager::showAgendaView( bool fullScreen ) |
341 | { | 339 | { |
342 | 340 | ||
343 | mMainView->dialogManager()->hideSearchDialog(); | 341 | mMainView->dialogManager()->hideSearchDialog(); |
344 | // qDebug("KOViewManager::showAgendaView "); | 342 | // qDebug("KOViewManager::showAgendaView "); |
345 | bool full; | 343 | bool full; |
346 | full = fullScreen; | 344 | full = fullScreen; |
347 | if (!mAgendaView) { | 345 | if (!mAgendaView) { |
348 | full = false; | 346 | full = false; |
349 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 347 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
350 | addView(mAgendaView); | 348 | addView(mAgendaView); |
351 | #ifndef DESKTOP_VERSION | 349 | #ifndef DESKTOP_VERSION |
352 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 350 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
353 | #endif | 351 | #endif |
354 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 352 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
355 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 353 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
356 | 354 | ||
357 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 355 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
358 | 356 | ||
359 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); | 357 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); |
360 | 358 | ||
361 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), | 359 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), |
362 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); | 360 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); |
363 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 361 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
364 | mMainView, SLOT(newEvent(QDateTime))); | 362 | mMainView, SLOT(newEvent(QDateTime))); |
365 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 363 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
366 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 364 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
367 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 365 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
368 | mMainView, SLOT(newEvent(QDate))); | 366 | mMainView, SLOT(newEvent(QDate))); |
369 | 367 | ||
370 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 368 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
371 | mMainView, SLOT(editIncidence(Incidence *))); | 369 | mMainView, SLOT(editIncidence(Incidence *))); |
372 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 370 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
373 | mMainView, SLOT(showIncidence(Incidence *))); | 371 | mMainView, SLOT(showIncidence(Incidence *))); |
374 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 372 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
375 | mMainView, SLOT(deleteIncidence(Incidence *))); | 373 | mMainView, SLOT(deleteIncidence(Incidence *))); |
376 | 374 | ||
377 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 375 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
378 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 376 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
379 | 377 | ||
380 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 378 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
381 | mMainView, SLOT( toggleExpand() ) ); | 379 | mMainView, SLOT( toggleExpand() ) ); |
382 | 380 | ||
383 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), | 381 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), |
384 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); | 382 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); |
385 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 383 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
386 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 384 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
387 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 385 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
388 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 386 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
389 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 387 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
390 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 388 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
391 | SLOT( updateTodo( Todo *, int ) ) ); | 389 | SLOT( updateTodo( Todo *, int ) ) ); |
392 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 390 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
393 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 391 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
394 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 392 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
395 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 393 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
396 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 394 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
397 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 395 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
398 | mAgendaView->readSettings(); | 396 | mAgendaView->readSettings(); |
399 | mAgendaView->updateConfig(); | 397 | mAgendaView->updateConfig(); |
400 | } | 398 | } |
401 | 399 | ||
402 | showView( mAgendaView, full); | 400 | showView( mAgendaView, full); |
403 | 401 | ||
404 | } | 402 | } |
405 | 403 | ||
406 | void KOViewManager::showDayView() | 404 | void KOViewManager::showDayView() |
407 | { | 405 | { |
408 | mFlagShowNextxDays = false; | 406 | mFlagShowNextxDays = false; |
409 | globalFlagBlockLabel = 1; | 407 | globalFlagBlockLabel = 1; |
410 | globalFlagBlockAgenda = 1; | 408 | globalFlagBlockAgenda = 1; |
411 | if ( mCurrentAgendaView != 1 ) | 409 | if ( mCurrentAgendaView != 1 ) |
412 | mCurrentAgendaView = -1; | 410 | mCurrentAgendaView = -1; |
413 | showAgendaView(); | 411 | showAgendaView(); |
414 | qApp->processEvents(); | 412 | qApp->processEvents(); |
415 | globalFlagBlockAgenda = 2; | 413 | globalFlagBlockAgenda = 2; |
416 | globalFlagBlockLabel = 0; | 414 | globalFlagBlockLabel = 0; |
417 | mMainView->dateNavigator()->selectDates( 1 ); | 415 | mMainView->dateNavigator()->selectDates( 1 ); |
418 | mCurrentAgendaView = 1 ; | 416 | mCurrentAgendaView = 1 ; |
419 | 417 | ||
420 | } | 418 | } |
421 | 419 | ||
422 | void KOViewManager::showWorkWeekView() | 420 | void KOViewManager::showWorkWeekView() |
423 | { | 421 | { |
424 | mFlagShowNextxDays = false; | 422 | mFlagShowNextxDays = false; |
425 | globalFlagBlockAgenda = 1; | 423 | globalFlagBlockAgenda = 1; |
426 | globalFlagBlockLabel = 1; | 424 | globalFlagBlockLabel = 1; |
427 | if ( mCurrentAgendaView != 5 ) | 425 | if ( mCurrentAgendaView != 5 ) |
428 | mCurrentAgendaView = -1; | 426 | mCurrentAgendaView = -1; |
429 | showAgendaView(); | 427 | showAgendaView(); |
430 | qApp->processEvents(); | 428 | qApp->processEvents(); |
431 | globalFlagBlockAgenda = 2; | 429 | globalFlagBlockAgenda = 2; |
432 | globalFlagBlockLabel = 0; | 430 | globalFlagBlockLabel = 0; |
433 | mMainView->dateNavigator()->selectWorkWeek(); | 431 | mMainView->dateNavigator()->selectWorkWeek(); |
434 | mCurrentAgendaView = 5 ; | 432 | mCurrentAgendaView = 5 ; |
435 | 433 | ||
436 | } | 434 | } |
437 | 435 | ||
438 | void KOViewManager::showWeekView() | 436 | void KOViewManager::showWeekView() |
439 | { | 437 | { |
440 | /* | 438 | /* |
441 | globalFlagBlockAgenda = 2; | 439 | globalFlagBlockAgenda = 2; |
442 | qDebug("4globalFlagBlockAgenda = 2; "); | 440 | qDebug("4globalFlagBlockAgenda = 2; "); |
443 | //globalFlagBlockPainting = true; | 441 | //globalFlagBlockPainting = true; |
444 | mMainView->dateNavigator()->selectWeek(); | 442 | mMainView->dateNavigator()->selectWeek(); |
445 | showAgendaView(); | 443 | showAgendaView(); |
446 | */ | 444 | */ |
447 | 445 | ||
448 | 446 | ||
449 | mFlagShowNextxDays = false; | 447 | mFlagShowNextxDays = false; |
450 | globalFlagBlockAgenda = 1; | 448 | globalFlagBlockAgenda = 1; |
451 | globalFlagBlockLabel = 1; | 449 | globalFlagBlockLabel = 1; |
452 | if ( mCurrentAgendaView != 7 ) | 450 | if ( mCurrentAgendaView != 7 ) |
453 | mCurrentAgendaView = -1; | 451 | mCurrentAgendaView = -1; |
454 | showAgendaView(); | 452 | showAgendaView(); |
455 | qApp->processEvents(); | 453 | qApp->processEvents(); |
456 | globalFlagBlockAgenda = 2; | 454 | globalFlagBlockAgenda = 2; |
457 | globalFlagBlockLabel = 0; | 455 | globalFlagBlockLabel = 0; |
458 | mMainView->dateNavigator()->selectWeek(); | 456 | mMainView->dateNavigator()->selectWeek(); |
459 | mCurrentAgendaView = 7 ; | 457 | mCurrentAgendaView = 7 ; |
460 | } | 458 | } |
461 | 459 | ||
462 | void KOViewManager::showNextXView() | 460 | void KOViewManager::showNextXView() |
463 | { | 461 | { |
464 | 462 | ||
465 | globalFlagBlockAgenda = 1; | 463 | globalFlagBlockAgenda = 1; |
466 | if ( mCurrentAgendaView != 3 ) | 464 | if ( mCurrentAgendaView != 3 ) |
467 | mCurrentAgendaView = -1; | 465 | mCurrentAgendaView = -1; |
468 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 466 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
469 | globalFlagBlockAgenda = 2; | 467 | globalFlagBlockAgenda = 2; |
470 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 468 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
471 | KOPrefs::instance()->mNextXDays ); | 469 | KOPrefs::instance()->mNextXDays ); |
472 | mFlagShowNextxDays = true; | 470 | mFlagShowNextxDays = true; |
473 | mCurrentAgendaView = 3 ; | 471 | mCurrentAgendaView = 3 ; |
474 | } | 472 | } |
475 | bool KOViewManager::showsNextDays() | 473 | bool KOViewManager::showsNextDays() |
476 | { | 474 | { |
477 | return mFlagShowNextxDays; | 475 | return mFlagShowNextxDays; |
478 | } | 476 | } |
479 | void KOViewManager::showMonthView() | 477 | void KOViewManager::showMonthView() |
480 | { | 478 | { |
481 | if (!mMonthView) { | 479 | if (!mMonthView) { |
482 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 480 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
483 | 481 | ||
484 | addView(mMonthView); | 482 | addView(mMonthView); |
485 | // mMonthView->show(); | 483 | // mMonthView->show(); |
486 | // SIGNALS/SLOTS FOR MONTH VIEW | 484 | // SIGNALS/SLOTS FOR MONTH VIEW |
487 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 485 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
488 | mMainView, SLOT(newEvent(QDateTime))); | 486 | mMainView, SLOT(newEvent(QDateTime))); |
489 | 487 | ||
490 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 488 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
491 | mMainView, SLOT(showIncidence(Incidence *))); | 489 | mMainView, SLOT(showIncidence(Incidence *))); |
492 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 490 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
493 | mMainView, SLOT(editIncidence(Incidence *))); | 491 | mMainView, SLOT(editIncidence(Incidence *))); |
494 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 492 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
495 | mMainView, SLOT(deleteIncidence(Incidence *))); | 493 | mMainView, SLOT(deleteIncidence(Incidence *))); |
496 | 494 | ||
497 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 495 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
498 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 496 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
499 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 497 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
500 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 498 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
501 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 499 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
502 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 500 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
503 | 501 | ||
504 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 502 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
505 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 503 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
506 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 504 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
507 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 505 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
508 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | 506 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), |
509 | mMainView, SLOT ( selectWeekNum( int ) ) ); | 507 | mMainView, SLOT ( selectWeekNum( int ) ) ); |
510 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), | 508 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), |
511 | mMainView, SLOT ( showDay( QDate ) ) ); | 509 | mMainView, SLOT ( showDay( QDate ) ) ); |
512 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | 510 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); |
513 | connect( mMonthView, SIGNAL(nextMonth() ), | 511 | connect( mMonthView, SIGNAL(nextMonth() ), |
514 | mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); | 512 | mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); |
515 | connect( mMonthView, SIGNAL(prevMonth() ), | 513 | connect( mMonthView, SIGNAL(prevMonth() ), |
516 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); | 514 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); |
517 | mMonthView->updateConfig(); | 515 | mMonthView->updateConfig(); |
518 | } | 516 | } |
519 | 517 | ||
520 | globalFlagBlockAgenda = 1; | 518 | globalFlagBlockAgenda = 1; |
521 | //mFlagShowNextxDays = false; | 519 | //mFlagShowNextxDays = false; |
522 | // if(mMonthView == mCurrentView) return; | 520 | // if(mMonthView == mCurrentView) return; |
523 | mMainView->dateNavigator()->selectMonth(); | 521 | mMainView->dateNavigator()->selectMonth(); |
524 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); | 522 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); |
525 | //mMonthView->showDates(tmpList.first(), tmpList.last()); | 523 | //mMonthView->showDates(tmpList.first(), tmpList.last()); |
526 | 524 | ||
527 | showView(mMonthView, true ); | 525 | showView(mMonthView, true ); |
528 | 526 | ||
529 | } | 527 | } |
530 | 528 | ||
531 | void KOViewManager::showTodoView() | 529 | void KOViewManager::showTodoView() |
532 | { | 530 | { |
533 | //mFlagShowNextxDays = false; | 531 | //mFlagShowNextxDays = false; |
534 | if ( !mTodoView ) { | 532 | if ( !mTodoView ) { |
535 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), | 533 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), |
536 | "KOViewManager::TodoView" ); | 534 | "KOViewManager::TodoView" ); |
537 | 535 | ||
538 | addView( mTodoView ); | 536 | addView( mTodoView ); |
539 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); | 537 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); |
540 | 538 | ||
541 | // SIGNALS/SLOTS FOR TODO VIEW | 539 | // SIGNALS/SLOTS FOR TODO VIEW |
542 | connect( mTodoView, SIGNAL( newTodoSignal() ), | 540 | connect( mTodoView, SIGNAL( newTodoSignal() ), |
543 | mMainView, SLOT( newTodo() ) ); | 541 | mMainView, SLOT( newTodo() ) ); |
544 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), | 542 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), |
545 | mMainView, SLOT( newSubTodo( Todo *) ) ); | 543 | mMainView, SLOT( newSubTodo( Todo *) ) ); |
546 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), | 544 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), |
547 | mMainView, SLOT( showTodo( Todo * ) ) ); | 545 | mMainView, SLOT( showTodo( Todo * ) ) ); |
548 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), | 546 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), |
549 | mMainView, SLOT( editTodo( Todo * ) ) ); | 547 | mMainView, SLOT( editTodo( Todo * ) ) ); |
550 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), | 548 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), |
551 | mMainView, SLOT( deleteTodo( Todo * ) ) ); | 549 | mMainView, SLOT( deleteTodo( Todo * ) ) ); |
552 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), | 550 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), |
553 | mMainView, SLOT( purgeCompleted() ) ); | 551 | mMainView, SLOT( purgeCompleted() ) ); |
554 | 552 | ||
555 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), | 553 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), |
556 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 554 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
557 | 555 | ||
558 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, | 556 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, |
559 | SLOT( updateConfig() ) ); | 557 | SLOT( updateConfig() ) ); |
560 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, | 558 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, |
561 | SLOT( updateTodo( Todo *, int ) ) ); | 559 | SLOT( updateTodo( Todo *, int ) ) ); |
562 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 560 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
563 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); | 561 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); |
564 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), | 562 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), |
565 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 563 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
566 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), | 564 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), |
567 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 565 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
568 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), | 566 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), |
569 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); | 567 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); |
570 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 568 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
571 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); | 569 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); |
572 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), | 570 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), |
573 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 571 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
574 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), | 572 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), |
575 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 573 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
576 | KConfig *config = KOGlobals::config(); | 574 | KConfig *config = KOGlobals::config(); |
577 | mTodoView->restoreLayout(config,"Todo View"); | 575 | mTodoView->restoreLayout(config,"Todo View"); |
578 | mTodoView->setNavigator( mMainView->dateNavigator() ); | 576 | mTodoView->setNavigator( mMainView->dateNavigator() ); |
579 | } | 577 | } |
580 | 578 | ||
581 | globalFlagBlockAgenda = 1; | 579 | globalFlagBlockAgenda = 1; |
582 | showView( mTodoView, true ); | 580 | showView( mTodoView, true ); |
583 | 581 | ||
584 | } | 582 | } |
585 | 583 | ||
586 | void KOViewManager::showJournalView() | 584 | void KOViewManager::showJournalView() |
587 | { | 585 | { |
588 | //mFlagShowNextxDays = false; | 586 | //mFlagShowNextxDays = false; |
589 | if (!mJournalView) { | 587 | if (!mJournalView) { |
590 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), | 588 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), |
591 | "KOViewManager::JournalView"); | 589 | "KOViewManager::JournalView"); |
592 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, | 590 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, |
593 | SLOT( updateConfig() ) ); | 591 | SLOT( updateConfig() ) ); |
594 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); | 592 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); |
595 | addView(mJournalView); | 593 | addView(mJournalView); |
596 | } | 594 | } |
597 | 595 | ||
598 | showView(mJournalView); | 596 | showView(mJournalView); |
599 | } | 597 | } |
600 | 598 | ||
601 | void KOViewManager::showTimeSpanView() | 599 | void KOViewManager::showTimeSpanView() |
602 | { | 600 | { |
603 | //mFlagShowNextxDays = false; | 601 | //mFlagShowNextxDays = false; |
604 | if (!mTimeSpanView) { | 602 | if (!mTimeSpanView) { |
605 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), | 603 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), |
606 | "KOViewManager::TimeSpanView"); | 604 | "KOViewManager::TimeSpanView"); |
607 | addView(mTimeSpanView); | 605 | addView(mTimeSpanView); |
608 | 606 | ||
609 | mTimeSpanView->readSettings(); | 607 | mTimeSpanView->readSettings(); |
610 | } | 608 | } |
611 | 609 | ||
612 | showView(mTimeSpanView); | 610 | showView(mTimeSpanView); |
613 | } | 611 | } |
614 | 612 | ||
615 | Incidence *KOViewManager::currentSelection() | 613 | Incidence *KOViewManager::currentSelection() |
616 | { | 614 | { |
617 | if (!mCurrentView) return 0; | 615 | if (!mCurrentView) return 0; |
618 | if ( mCurrentView == mListView ) { | 616 | if ( mCurrentView == mListView ) { |
619 | if ( mListView->currentItem() ) | 617 | if ( mListView->currentItem() ) |
620 | return mListView->currentItem(); | 618 | return mListView->currentItem(); |
621 | } | 619 | } |
622 | return mCurrentView->selectedIncidences().first(); | 620 | return mCurrentView->selectedIncidences().first(); |
623 | } | 621 | } |
624 | 622 | ||
625 | QDate KOViewManager::currentSelectionDate() | 623 | QDate KOViewManager::currentSelectionDate() |
626 | { | 624 | { |
627 | QDate qd; | 625 | QDate qd; |
628 | if (mCurrentView) { | 626 | if (mCurrentView) { |
629 | DateList qvl = mCurrentView->selectedDates(); | 627 | DateList qvl = mCurrentView->selectedDates(); |
630 | if (!qvl.isEmpty()) qd = qvl.first(); | 628 | if (!qvl.isEmpty()) qd = qvl.first(); |
631 | } | 629 | } |
632 | return qd; | 630 | return qd; |
633 | } | 631 | } |
634 | 632 | ||
635 | void KOViewManager::addView(KOrg::BaseView *view) | 633 | void KOViewManager::addView(KOrg::BaseView *view) |
636 | { | 634 | { |
637 | #if QT_VERSION >= 0x030000 | 635 | #if QT_VERSION >= 0x030000 |
638 | mMainView->viewStack()->addWidget( view ); | 636 | mMainView->viewStack()->addWidget( view ); |
639 | #else | 637 | #else |
640 | mMainView->viewStack()->addWidget( view, 1 ); | 638 | mMainView->viewStack()->addWidget( view, 1 ); |
641 | #endif | 639 | #endif |
642 | } | 640 | } |
643 | 641 | ||
644 | void KOViewManager::setDocumentId( const QString &id ) | 642 | void KOViewManager::setDocumentId( const QString &id ) |
645 | { | 643 | { |
646 | if (mTodoView) mTodoView->setDocumentId( id ); | 644 | if (mTodoView) mTodoView->setDocumentId( id ); |
647 | } | 645 | } |