-rw-r--r-- | korganizer/koagendaview.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index c5acafd..6428757 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -257,813 +257,829 @@ void EventIndicator::drawContents(QPainter *p) | |||
257 | } | 257 | } |
258 | } | 258 | } |
259 | } else { | 259 | } else { |
260 | han->repaint(); | 260 | han->repaint(); |
261 | //mPaintWidget->setBackgroundColor( red ); | 261 | //mPaintWidget->setBackgroundColor( red ); |
262 | 262 | ||
263 | QPainter pa( han ); | 263 | QPainter pa( han ); |
264 | int i; | 264 | int i; |
265 | bool setColor = false; | 265 | bool setColor = false; |
266 | for(i=0;i<mColumns;++i) { | 266 | for(i=0;i<mColumns;++i) { |
267 | if (mEnabled[i]) { | 267 | if (mEnabled[i]) { |
268 | setColor = true; | 268 | setColor = true; |
269 | 269 | ||
270 | int cellWidth = contentsRect().right()/mColumns; | 270 | int cellWidth = contentsRect().right()/mColumns; |
271 | int xOffset = KOGlobals::self()->reverseLayout() ? | 271 | int xOffset = KOGlobals::self()->reverseLayout() ? |
272 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 272 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
273 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 273 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
274 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 274 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
275 | //qDebug("222draw pix %d ",xOffset ); | 275 | //qDebug("222draw pix %d ",xOffset ); |
276 | 276 | ||
277 | } | 277 | } |
278 | 278 | ||
279 | } | 279 | } |
280 | pa.end(); | 280 | pa.end(); |
281 | 281 | ||
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | void EventIndicator::setXOffset( int x ) | 285 | void EventIndicator::setXOffset( int x ) |
286 | { | 286 | { |
287 | mXOffset = x; | 287 | mXOffset = x; |
288 | } | 288 | } |
289 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 289 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
290 | { | 290 | { |
291 | mPaintWidget = w; | 291 | mPaintWidget = w; |
292 | } | 292 | } |
293 | void EventIndicator::changeColumns(int columns) | 293 | void EventIndicator::changeColumns(int columns) |
294 | { | 294 | { |
295 | mColumns = columns; | 295 | mColumns = columns; |
296 | mEnabled.resize(mColumns); | 296 | mEnabled.resize(mColumns); |
297 | 297 | ||
298 | update(); | 298 | update(); |
299 | } | 299 | } |
300 | 300 | ||
301 | void EventIndicator::enableColumn(int column, bool enable) | 301 | void EventIndicator::enableColumn(int column, bool enable) |
302 | { | 302 | { |
303 | mEnabled[column] = enable; | 303 | mEnabled[column] = enable; |
304 | } | 304 | } |
305 | 305 | ||
306 | 306 | ||
307 | //////////////////////////////////////////////////////////////////////////// | 307 | //////////////////////////////////////////////////////////////////////////// |
308 | //////////////////////////////////////////////////////////////////////////// | 308 | //////////////////////////////////////////////////////////////////////////// |
309 | //////////////////////////////////////////////////////////////////////////// | 309 | //////////////////////////////////////////////////////////////////////////// |
310 | 310 | ||
311 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 311 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
312 | KOEventView (cal,parent,name) | 312 | KOEventView (cal,parent,name) |
313 | { | 313 | { |
314 | mBlockUpdating = true; | 314 | mBlockUpdating = true; |
315 | mStartHour = 8; | 315 | mStartHour = 8; |
316 | mSelectedDates.append(QDate::currentDate()); | 316 | mSelectedDates.append(QDate::currentDate()); |
317 | 317 | ||
318 | mLayoutDayLabels = 0; | 318 | mLayoutDayLabels = 0; |
319 | mDayLabelsFrame = 0; | 319 | mDayLabelsFrame = 0; |
320 | mDayLabels = 0; | 320 | mDayLabels = 0; |
321 | bool isRTL = KOGlobals::self()->reverseLayout(); | 321 | bool isRTL = KOGlobals::self()->reverseLayout(); |
322 | 322 | ||
323 | if ( KOPrefs::instance()->mVerticalScreen ) { | 323 | if ( KOPrefs::instance()->mVerticalScreen ) { |
324 | mExpandedPixmap = SmallIcon( "1downarrow" ); | 324 | mExpandedPixmap = SmallIcon( "1downarrow" ); |
325 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); | 325 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); |
326 | } else { | 326 | } else { |
327 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); | 327 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); |
328 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); | 328 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); |
329 | } | 329 | } |
330 | 330 | ||
331 | QBoxLayout *topLayout = new QVBoxLayout(this); | 331 | QBoxLayout *topLayout = new QVBoxLayout(this); |
332 | 332 | ||
333 | // Create day name labels for agenda columns | 333 | // Create day name labels for agenda columns |
334 | mDayLabelsFrame = new QHBox(this); | 334 | mDayLabelsFrame = new QHBox(this); |
335 | topLayout->addWidget(mDayLabelsFrame); | 335 | topLayout->addWidget(mDayLabelsFrame); |
336 | mDayLabels = new QFrame (mDayLabelsFrame); | 336 | mDayLabels = new QFrame (mDayLabelsFrame); |
337 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 337 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
338 | // Create agenda splitter | 338 | // Create agenda splitter |
339 | #ifndef KORG_NOSPLITTER | 339 | #ifndef KORG_NOSPLITTER |
340 | mSplitterAgenda = new QSplitter(Vertical,this); | 340 | mSplitterAgenda = new QSplitter(Vertical,this); |
341 | topLayout->addWidget(mSplitterAgenda); | 341 | topLayout->addWidget(mSplitterAgenda); |
342 | mSplitterAgenda->setOpaqueResize(); | 342 | mSplitterAgenda->setOpaqueResize(); |
343 | 343 | ||
344 | mAllDayFrame = new QHBox(mSplitterAgenda); | 344 | mAllDayFrame = new QHBox(mSplitterAgenda); |
345 | 345 | ||
346 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 346 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
347 | #else | 347 | #else |
348 | #if 0 | 348 | #if 0 |
349 | QWidget *mainBox = new QWidget( this ); | 349 | QWidget *mainBox = new QWidget( this ); |
350 | topLayout->addWidget( mainBox ); | 350 | topLayout->addWidget( mainBox ); |
351 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); | 351 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); |
352 | mAllDayFrame = new QHBox(mainBox); | 352 | mAllDayFrame = new QHBox(mainBox); |
353 | mainLayout->addWidget(mAllDayFrame); | 353 | mainLayout->addWidget(mAllDayFrame); |
354 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); | 354 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); |
355 | mAllDayFrame->setFocusPolicy(NoFocus); | 355 | mAllDayFrame->setFocusPolicy(NoFocus); |
356 | QWidget *agendaFrame = new QWidget(mainBox); | 356 | QWidget *agendaFrame = new QWidget(mainBox); |
357 | mainLayout->addWidget(agendaFrame); | 357 | mainLayout->addWidget(agendaFrame); |
358 | mainLayout->setStretchFactor( agendaFrame, 10 ); | 358 | mainLayout->setStretchFactor( agendaFrame, 10 ); |
359 | 359 | ||
360 | agendaFrame->setFocusPolicy(NoFocus); | 360 | agendaFrame->setFocusPolicy(NoFocus); |
361 | #endif | 361 | #endif |
362 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 362 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
363 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 363 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
364 | topLayout->addWidget( mSplitterAgenda ); | 364 | topLayout->addWidget( mSplitterAgenda ); |
365 | mAllDayFrame = new QHBox(mSplitterAgenda); | 365 | mAllDayFrame = new QHBox(mSplitterAgenda); |
366 | mAllDayFrame->setFocusPolicy(NoFocus); | 366 | mAllDayFrame->setFocusPolicy(NoFocus); |
367 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 367 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
368 | agendaFrame->setFocusPolicy(NoFocus); | 368 | agendaFrame->setFocusPolicy(NoFocus); |
369 | 369 | ||
370 | #endif | 370 | #endif |
371 | 371 | ||
372 | // Create all-day agenda widget | 372 | // Create all-day agenda widget |
373 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 373 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
374 | 374 | ||
375 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 375 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
376 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 376 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
377 | int widebut = mExpandButton->sizeHint().width(); | 377 | int widebut = mExpandButton->sizeHint().width(); |
378 | if ( QApplication::desktop()->width() < 480 ) | 378 | if ( QApplication::desktop()->width() < 480 ) |
379 | widebut = widebut*2; | 379 | widebut = widebut*2; |
380 | else | 380 | else |
381 | widebut = (widebut*3) / 2; | 381 | widebut = (widebut*3) / 2; |
382 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 382 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
383 | // QSizePolicy::Fixed ) ); | 383 | // QSizePolicy::Fixed ) ); |
384 | mExpandButton->setFixedSize( widebut, widebut); | 384 | mExpandButton->setFixedSize( widebut, widebut); |
385 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 385 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
386 | mExpandButton->setFocusPolicy(NoFocus); | 386 | mExpandButton->setFocusPolicy(NoFocus); |
387 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 387 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
388 | mAllDayAgenda->setFocusPolicy(NoFocus); | 388 | mAllDayAgenda->setFocusPolicy(NoFocus); |
389 | QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); | 389 | QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); |
390 | 390 | ||
391 | // Create event context menu for all day agenda | 391 | // Create event context menu for all day agenda |
392 | mAllDayAgendaPopup = eventPopup(); | 392 | mAllDayAgendaPopup = eventPopup(); |
393 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 393 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
394 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 394 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
395 | 395 | ||
396 | // Create agenda frame | 396 | // Create agenda frame |
397 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); | 397 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); |
398 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 398 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
399 | 399 | ||
400 | // create event indicator bars | 400 | // create event indicator bars |
401 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 401 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
402 | agendaLayout->addWidget(mEventIndicatorTop,0,1); | 402 | agendaLayout->addWidget(mEventIndicatorTop,0,1); |
403 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 403 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
404 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 404 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
405 | agendaFrame); | 405 | agendaFrame); |
406 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); | 406 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); |
407 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 407 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
408 | agendaLayout->addWidget(dummyAgendaRight,0,2); | 408 | agendaLayout->addWidget(dummyAgendaRight,0,2); |
409 | 409 | ||
410 | // Create time labels | 410 | // Create time labels |
411 | mTimeLabels = new TimeLabels(24,agendaFrame); | 411 | mTimeLabels = new TimeLabels(24,agendaFrame); |
412 | agendaLayout->addWidget(mTimeLabels,1,0); | 412 | agendaLayout->addWidget(mTimeLabels,1,0); |
413 | 413 | ||
414 | // Create agenda | 414 | // Create agenda |
415 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 415 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
416 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); | 416 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); |
417 | agendaLayout->setColStretch(1,1); | 417 | agendaLayout->setColStretch(1,1); |
418 | mAgenda->setFocusPolicy(NoFocus); | 418 | mAgenda->setFocusPolicy(NoFocus); |
419 | // Create event context menu for agenda | 419 | // Create event context menu for agenda |
420 | mAgendaPopup = eventPopup(); | 420 | mAgendaPopup = eventPopup(); |
421 | 421 | ||
422 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 422 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
423 | i18n("Toggle Alarm"),mAgenda, | 423 | i18n("Toggle Alarm"),mAgenda, |
424 | SLOT(popupAlarm()),true); | 424 | SLOT(popupAlarm()),true); |
425 | 425 | ||
426 | 426 | ||
427 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 427 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
428 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 428 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
429 | 429 | ||
430 | // make connections between dependent widgets | 430 | // make connections between dependent widgets |
431 | mTimeLabels->setAgenda(mAgenda); | 431 | mTimeLabels->setAgenda(mAgenda); |
432 | 432 | ||
433 | // Update widgets to reflect user preferences | 433 | // Update widgets to reflect user preferences |
434 | // updateConfig(); | 434 | // updateConfig(); |
435 | 435 | ||
436 | // createDayLabels(); | 436 | // createDayLabels(); |
437 | 437 | ||
438 | // these blank widgets make the All Day Event box line up with the agenda | 438 | // these blank widgets make the All Day Event box line up with the agenda |
439 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 439 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
440 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 440 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
441 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 441 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
442 | 442 | ||
443 | // Scrolling | 443 | // Scrolling |
444 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 444 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
445 | mTimeLabels, SLOT(positionChanged())); | 445 | mTimeLabels, SLOT(positionChanged())); |
446 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 446 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
447 | SLOT(setContentsPos(int))); | 447 | SLOT(setContentsPos(int))); |
448 | 448 | ||
449 | // Create/Show/Edit/Delete Event | 449 | // Create/Show/Edit/Delete Event |
450 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 450 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
451 | SLOT(newEvent(int,int))); | 451 | SLOT(newEvent(int,int))); |
452 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 452 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
453 | SLOT(newEvent(int,int,int,int))); | 453 | SLOT(newEvent(int,int,int,int))); |
454 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 454 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
455 | SLOT(newEventAllDay(int,int))); | 455 | SLOT(newEventAllDay(int,int))); |
456 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 456 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
457 | SLOT(newEventAllDay(int,int))); | 457 | SLOT(newEventAllDay(int,int))); |
458 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 458 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
459 | SLOT(newTimeSpanSelected(int,int,int,int))); | 459 | SLOT(newTimeSpanSelected(int,int,int,int))); |
460 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 460 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
461 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 461 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
462 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 462 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
463 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 463 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
464 | 464 | ||
465 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 465 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
466 | SIGNAL(editIncidenceSignal(Incidence *))); | 466 | SIGNAL(editIncidenceSignal(Incidence *))); |
467 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 467 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
468 | SIGNAL(editIncidenceSignal(Incidence *))); | 468 | SIGNAL(editIncidenceSignal(Incidence *))); |
469 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 469 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
470 | SIGNAL(showIncidenceSignal(Incidence *))); | 470 | SIGNAL(showIncidenceSignal(Incidence *))); |
471 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 471 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
472 | SIGNAL(showIncidenceSignal(Incidence *))); | 472 | SIGNAL(showIncidenceSignal(Incidence *))); |
473 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 473 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
474 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 474 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
475 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 475 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
476 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 476 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
477 | 477 | ||
478 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 478 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
479 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 479 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
480 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 480 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
481 | SLOT(updateEventDates(KOAgendaItem *, int))); | 481 | SLOT(updateEventDates(KOAgendaItem *, int))); |
482 | 482 | ||
483 | // event indicator update | 483 | // event indicator update |
484 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 484 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
485 | SLOT(updateEventIndicatorTop(int))); | 485 | SLOT(updateEventIndicatorTop(int))); |
486 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 486 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
487 | SLOT(updateEventIndicatorBottom(int))); | 487 | SLOT(updateEventIndicatorBottom(int))); |
488 | // drag signals | 488 | // drag signals |
489 | /* | 489 | /* |
490 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 490 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
491 | SLOT(startDrag(Event *))); | 491 | SLOT(startDrag(Event *))); |
492 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 492 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
493 | SLOT(startDrag(Event *))); | 493 | SLOT(startDrag(Event *))); |
494 | */ | 494 | */ |
495 | // synchronize selections | 495 | // synchronize selections |
496 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 496 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
497 | mAllDayAgenda, SLOT( deselectItem() ) ); | 497 | mAllDayAgenda, SLOT( deselectItem() ) ); |
498 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 498 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
499 | mAgenda, SLOT( deselectItem() ) ); | 499 | mAgenda, SLOT( deselectItem() ) ); |
500 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 500 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
501 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 501 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
502 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 502 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
503 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 503 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
504 | connect( mAgenda, SIGNAL( resizedSignal() ), | 504 | connect( mAgenda, SIGNAL( resizedSignal() ), |
505 | SLOT( updateConfig( ) ) ); | 505 | SLOT( updateConfig( ) ) ); |
506 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 506 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
507 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 507 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
508 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 508 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
509 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 509 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
510 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 510 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
511 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 511 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
512 | 512 | ||
513 | 513 | ||
514 | } | 514 | } |
515 | 515 | ||
516 | void KOAgendaView::toggleAllDay() | 516 | void KOAgendaView::toggleAllDay() |
517 | { | 517 | { |
518 | if ( mSplitterAgenda->firstHandle() ) | 518 | if ( mSplitterAgenda->firstHandle() ) |
519 | mSplitterAgenda->firstHandle()->toggle(); | 519 | mSplitterAgenda->firstHandle()->toggle(); |
520 | } | 520 | } |
521 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 521 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
522 | { | 522 | { |
523 | calendar()->addIncidence( inc ); | 523 | calendar()->addIncidence( inc ); |
524 | 524 | ||
525 | if ( incOld ) { | 525 | if ( incOld ) { |
526 | if ( incOld->type() == "Todo" ) | 526 | if ( incOld->type() == "Todo" ) |
527 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 527 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
528 | else | 528 | else |
529 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 529 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
530 | } | 530 | } |
531 | 531 | ||
532 | } | 532 | } |
533 | 533 | ||
534 | KOAgendaView::~KOAgendaView() | 534 | KOAgendaView::~KOAgendaView() |
535 | { | 535 | { |
536 | delete mAgendaPopup; | 536 | delete mAgendaPopup; |
537 | delete mAllDayAgendaPopup; | 537 | delete mAllDayAgendaPopup; |
538 | delete KOAgendaItem::paintPix(); | 538 | delete KOAgendaItem::paintPix(); |
539 | delete KOAgendaItem::paintPixSel(); | 539 | delete KOAgendaItem::paintPixSel(); |
540 | } | 540 | } |
541 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 541 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
542 | { | 542 | { |
543 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 543 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
544 | bool uc = false; | 544 | bool uc = false; |
545 | int ow = e->oldSize().width(); | 545 | int ow = e->oldSize().width(); |
546 | int oh = e->oldSize().height(); | 546 | int oh = e->oldSize().height(); |
547 | int w = e->size().width(); | 547 | int w = e->size().width(); |
548 | int h = e->size().height(); | 548 | int h = e->size().height(); |
549 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 549 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
550 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 550 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
551 | uc = true; | 551 | uc = true; |
552 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 552 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
553 | } | 553 | } |
554 | mUpcomingWidth = e->size().width() ; | 554 | mUpcomingWidth = e->size().width() ; |
555 | if ( mBlockUpdating || uc ) { | 555 | if ( mBlockUpdating || uc ) { |
556 | mBlockUpdating = false; | 556 | mBlockUpdating = false; |
557 | //mAgenda->setMinimumSize(800 , 600 ); | 557 | //mAgenda->setMinimumSize(800 , 600 ); |
558 | //qDebug("mAgenda->resize+++++++++++++++ "); | 558 | //qDebug("mAgenda->resize+++++++++++++++ "); |
559 | updateConfig(); | 559 | updateConfig(); |
560 | //qDebug("KOAgendaView::Updating now possible "); | 560 | //qDebug("KOAgendaView::Updating now possible "); |
561 | } else | 561 | } else |
562 | createDayLabels(); | 562 | createDayLabels(); |
563 | //qDebug("resizeEvent end "); | 563 | //qDebug("resizeEvent end "); |
564 | 564 | ||
565 | } | 565 | } |
566 | void KOAgendaView::createDayLabels() | 566 | void KOAgendaView::createDayLabels() |
567 | { | 567 | { |
568 | 568 | ||
569 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 569 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
570 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 570 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
571 | return; | 571 | return; |
572 | 572 | ||
573 | } | 573 | } |
574 | int newHight; | 574 | int newHight; |
575 | 575 | ||
576 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 576 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
577 | // It would remove some flickering and gain speed (since this is called by | 577 | // It would remove some flickering and gain speed (since this is called by |
578 | // each updateView() call) | 578 | // each updateView() call) |
579 | 579 | ||
580 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 580 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
581 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 581 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
582 | if ( maxWid < 0 ) | 582 | if ( maxWid < 0 ) |
583 | maxWid = 20; | 583 | maxWid = 20; |
584 | 584 | ||
585 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 585 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
586 | QFontMetrics fm ( dlf ); | 586 | QFontMetrics fm ( dlf ); |
587 | int selCount = mSelectedDates.count(); | 587 | int selCount = mSelectedDates.count(); |
588 | QString dayTest = "Mon 20"; | 588 | QString dayTest = "Mon 20"; |
589 | int wid = fm.width( dayTest ); | 589 | int wid = fm.width( dayTest ); |
590 | maxWid -= ( selCount * 3 ); | 590 | maxWid -= ( selCount * 3 ); |
591 | if ( maxWid < 0 ) | 591 | if ( maxWid < 0 ) |
592 | maxWid = 20; | 592 | maxWid = 20; |
593 | int needWid = wid * selCount; | 593 | int needWid = wid * selCount; |
594 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 594 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
595 | //if ( needWid > maxWid ) | 595 | //if ( needWid > maxWid ) |
596 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 596 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
597 | while ( needWid > maxWid ) { | 597 | while ( needWid > maxWid ) { |
598 | dayTest = dayTest.left( dayTest.length() - 1 ); | 598 | dayTest = dayTest.left( dayTest.length() - 1 ); |
599 | wid = fm.width( dayTest ); | 599 | wid = fm.width( dayTest ); |
600 | needWid = wid * selCount; | 600 | needWid = wid * selCount; |
601 | } | 601 | } |
602 | int maxLen = dayTest.length(); | 602 | int maxLen = dayTest.length(); |
603 | int fontPoint = dlf.pointSize(); | 603 | int fontPoint = dlf.pointSize(); |
604 | if ( maxLen < 2 ) { | 604 | if ( maxLen < 2 ) { |
605 | int fontPoint = dlf.pointSize(); | 605 | int fontPoint = dlf.pointSize(); |
606 | while ( fontPoint > 4 ) { | 606 | while ( fontPoint > 4 ) { |
607 | --fontPoint; | 607 | --fontPoint; |
608 | dlf.setPointSize( fontPoint ); | 608 | dlf.setPointSize( fontPoint ); |
609 | QFontMetrics f( dlf ); | 609 | QFontMetrics f( dlf ); |
610 | wid = f.width( "20" ); | 610 | wid = f.width( "20" ); |
611 | needWid = wid * selCount; | 611 | needWid = wid * selCount; |
612 | if ( needWid < maxWid ) | 612 | if ( needWid < maxWid ) |
613 | break; | 613 | break; |
614 | } | 614 | } |
615 | maxLen = 2; | 615 | maxLen = 2; |
616 | } | 616 | } |
617 | //qDebug("Max len %d ", dayTest.length() ); | 617 | //qDebug("Max len %d ", dayTest.length() ); |
618 | 618 | ||
619 | QFontMetrics tempF( dlf ); | 619 | QFontMetrics tempF( dlf ); |
620 | newHight = tempF.height(); | 620 | newHight = tempF.height(); |
621 | mDayLabels->setFont( dlf ); | 621 | mDayLabels->setFont( dlf ); |
622 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 622 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
623 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 623 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
624 | //mLayoutDayLabels->addSpacing( 2 ); | 624 | //mLayoutDayLabels->addSpacing( 2 ); |
625 | // QFont lFont = dlf; | 625 | // QFont lFont = dlf; |
626 | bool appendLabels = false; | 626 | bool appendLabels = false; |
627 | QLabel *dayLabel; | 627 | QLabel *dayLabel; |
628 | dayLabel = mDayLabelsList.first(); | 628 | dayLabel = mDayLabelsList.first(); |
629 | if ( !dayLabel ) { | 629 | if ( !dayLabel ) { |
630 | appendLabels = true; | 630 | appendLabels = true; |
631 | dayLabel = new QLabel(mDayLabels); | 631 | dayLabel = new QLabel(mDayLabels); |
632 | mDayLabelsList.append( dayLabel ); | 632 | mDayLabelsList.append( dayLabel ); |
633 | mLayoutDayLabels->addWidget(dayLabel); | 633 | mLayoutDayLabels->addWidget(dayLabel); |
634 | } | 634 | } |
635 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 635 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
636 | dayLabel->setFont( dlf ); | 636 | dayLabel->setFont( dlf ); |
637 | dayLabel->setAlignment(QLabel::AlignHCenter); | 637 | dayLabel->setAlignment(QLabel::AlignHCenter); |
638 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 638 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
639 | dayLabel->show(); | 639 | dayLabel->show(); |
640 | DateList::ConstIterator dit; | 640 | DateList::ConstIterator dit; |
641 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | ||
641 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 642 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
642 | QDate date = *dit; | 643 | QDate date = *dit; |
643 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 644 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
644 | if ( ! appendLabels ) { | 645 | if ( ! appendLabels ) { |
645 | dayLabel = mDayLabelsList.next(); | 646 | dayLabel = mDayLabelsList.next(); |
646 | if ( !dayLabel ) | 647 | if ( !dayLabel ) |
647 | appendLabels = true; | 648 | appendLabels = true; |
648 | } | 649 | } |
649 | if ( appendLabels ) { | 650 | if ( appendLabels ) { |
650 | dayLabel = new QLabel(mDayLabels); | 651 | dayLabel = new QLabel(mDayLabels); |
651 | mDayLabelsList.append( dayLabel ); | 652 | mDayLabelsList.append( dayLabel ); |
652 | mLayoutDayLabels->addWidget(dayLabel); | 653 | mLayoutDayLabels->addWidget(dayLabel); |
653 | } | 654 | } |
654 | dayLabel->setMinimumWidth( 1 ); | 655 | dayLabel->setMinimumWidth( 1 ); |
655 | dayLabel->setMaximumWidth( 2048 ); | 656 | dayLabel->setMaximumWidth( 2048 ); |
656 | dayLabel->setFont( dlf ); | 657 | dayLabel->setFont( dlf ); |
657 | dayLabel->show(); | 658 | dayLabel->show(); |
658 | QString str; | 659 | QString str; |
659 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 660 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
660 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 661 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
661 | switch ( maxLen ) { | 662 | switch ( maxLen ) { |
662 | case 2: | 663 | case 2: |
663 | str = QString::number( date.day() ); | 664 | str = QString::number( date.day() ); |
664 | break; | 665 | break; |
665 | 666 | ||
666 | case 3: | 667 | case 3: |
667 | str = dayName.left( 1 ) +QString::number( date.day()); | 668 | str = dayName.left( 1 ) +QString::number( date.day()); |
668 | 669 | ||
669 | break; | 670 | break; |
670 | case 4: | 671 | case 4: |
671 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 672 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
672 | 673 | ||
673 | break; | 674 | break; |
674 | case 5: | 675 | case 5: |
675 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 676 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
676 | 677 | ||
677 | break; | 678 | break; |
678 | case 6: | 679 | case 6: |
679 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 680 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
680 | break; | 681 | break; |
681 | 682 | ||
682 | default: | 683 | default: |
683 | break; | 684 | break; |
684 | } | 685 | } |
685 | 686 | if ( oneday ) { | |
687 | QString addString; | ||
688 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | ||
689 | addString = i18n("Today"); | ||
690 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | ||
691 | addString = i18n("Tomorrow"); | ||
692 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | ||
693 | addString = i18n("Yesterday"); | ||
694 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | ||
695 | addString = i18n("Day before yesterday"); | ||
696 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | ||
697 | addString = i18n("Day after tomorrow"); | ||
698 | if ( !addString.isEmpty() ) { | ||
699 | str = addString+", " + str; | ||
700 | } | ||
701 | } | ||
686 | dayLabel->setText(str); | 702 | dayLabel->setText(str); |
687 | dayLabel->setAlignment(QLabel::AlignHCenter); | 703 | dayLabel->setAlignment(QLabel::AlignHCenter); |
688 | if (date == QDate::currentDate()) { | 704 | if (date == QDate::currentDate()) { |
689 | QFont bFont = dlf; | 705 | QFont bFont = dlf; |
690 | bFont.setBold( true ); | 706 | bFont.setBold( true ); |
691 | dayLabel->setFont(bFont); | 707 | dayLabel->setFont(bFont); |
692 | } | 708 | } |
693 | //dayLayout->addWidget(dayLabel); | 709 | //dayLayout->addWidget(dayLabel); |
694 | 710 | ||
695 | #ifndef KORG_NOPLUGINS | 711 | #ifndef KORG_NOPLUGINS |
696 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 712 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
697 | CalendarDecoration *it; | 713 | CalendarDecoration *it; |
698 | for(it = cds.first(); it; it = cds.next()) { | 714 | for(it = cds.first(); it; it = cds.next()) { |
699 | QString text = it->shortText( date ); | 715 | QString text = it->shortText( date ); |
700 | if ( !text.isEmpty() ) { | 716 | if ( !text.isEmpty() ) { |
701 | QLabel *label = new QLabel(text,mDayLabels); | 717 | QLabel *label = new QLabel(text,mDayLabels); |
702 | label->setAlignment(AlignCenter); | 718 | label->setAlignment(AlignCenter); |
703 | dayLayout->addWidget(label); | 719 | dayLayout->addWidget(label); |
704 | } | 720 | } |
705 | } | 721 | } |
706 | 722 | ||
707 | for(it = cds.first(); it; it = cds.next()) { | 723 | for(it = cds.first(); it; it = cds.next()) { |
708 | QWidget *wid = it->smallWidget(mDayLabels,date); | 724 | QWidget *wid = it->smallWidget(mDayLabels,date); |
709 | if ( wid ) { | 725 | if ( wid ) { |
710 | // wid->setHeight(20); | 726 | // wid->setHeight(20); |
711 | dayLayout->addWidget(wid); | 727 | dayLayout->addWidget(wid); |
712 | } | 728 | } |
713 | } | 729 | } |
714 | #endif | 730 | #endif |
715 | } | 731 | } |
716 | if ( ! appendLabels ) { | 732 | if ( ! appendLabels ) { |
717 | dayLabel = mDayLabelsList.next(); | 733 | dayLabel = mDayLabelsList.next(); |
718 | if ( !dayLabel ) | 734 | if ( !dayLabel ) |
719 | appendLabels = true; | 735 | appendLabels = true; |
720 | } | 736 | } |
721 | if ( appendLabels ) { | 737 | if ( appendLabels ) { |
722 | dayLabel = new QLabel(mDayLabels); | 738 | dayLabel = new QLabel(mDayLabels); |
723 | mDayLabelsList.append( dayLabel ); | 739 | mDayLabelsList.append( dayLabel ); |
724 | mLayoutDayLabels->addWidget(dayLabel); | 740 | mLayoutDayLabels->addWidget(dayLabel); |
725 | } | 741 | } |
726 | //dayLabel->hide();//test only | 742 | //dayLabel->hide();//test only |
727 | 743 | ||
728 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 744 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
729 | if ( offset < 0 ) offset = 0; | 745 | if ( offset < 0 ) offset = 0; |
730 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 746 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
731 | dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); | 747 | dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); |
732 | dayLabel->show(); | 748 | dayLabel->show(); |
733 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 749 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
734 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 750 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
735 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 751 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
736 | if ( !appendLabels ) { | 752 | if ( !appendLabels ) { |
737 | dayLabel = mDayLabelsList.next(); | 753 | dayLabel = mDayLabelsList.next(); |
738 | while ( dayLabel ) { | 754 | while ( dayLabel ) { |
739 | //qDebug("!dayLabel %d",dayLabel ); | 755 | //qDebug("!dayLabel %d",dayLabel ); |
740 | dayLabel->hide(); | 756 | dayLabel->hide(); |
741 | dayLabel = mDayLabelsList.next(); | 757 | dayLabel = mDayLabelsList.next(); |
742 | } | 758 | } |
743 | } | 759 | } |
744 | //mDayLabelsFrame->show(); | 760 | //mDayLabelsFrame->show(); |
745 | //mDayLabels->show(); | 761 | //mDayLabels->show(); |
746 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 762 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
747 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 763 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
748 | mDayLabelsFrame->setFixedHeight( newHight ); | 764 | mDayLabelsFrame->setFixedHeight( newHight ); |
749 | } | 765 | } |
750 | 766 | ||
751 | int KOAgendaView::maxDatesHint() | 767 | int KOAgendaView::maxDatesHint() |
752 | { | 768 | { |
753 | // Not sure about the max number of events, so return 0 for now. | 769 | // Not sure about the max number of events, so return 0 for now. |
754 | return 0; | 770 | return 0; |
755 | } | 771 | } |
756 | 772 | ||
757 | int KOAgendaView::currentDateCount() | 773 | int KOAgendaView::currentDateCount() |
758 | { | 774 | { |
759 | return mSelectedDates.count(); | 775 | return mSelectedDates.count(); |
760 | } | 776 | } |
761 | 777 | ||
762 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 778 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
763 | { | 779 | { |
764 | QPtrList<Incidence> selected; | 780 | QPtrList<Incidence> selected; |
765 | Incidence *incidence; | 781 | Incidence *incidence; |
766 | 782 | ||
767 | incidence = mAgenda->selectedIncidence(); | 783 | incidence = mAgenda->selectedIncidence(); |
768 | if (incidence) selected.append(incidence); | 784 | if (incidence) selected.append(incidence); |
769 | 785 | ||
770 | incidence = mAllDayAgenda->selectedIncidence(); | 786 | incidence = mAllDayAgenda->selectedIncidence(); |
771 | if (incidence) selected.append(incidence); | 787 | if (incidence) selected.append(incidence); |
772 | 788 | ||
773 | return selected; | 789 | return selected; |
774 | } | 790 | } |
775 | 791 | ||
776 | DateList KOAgendaView::selectedDates() | 792 | DateList KOAgendaView::selectedDates() |
777 | { | 793 | { |
778 | DateList selected; | 794 | DateList selected; |
779 | QDate qd; | 795 | QDate qd; |
780 | 796 | ||
781 | qd = mAgenda->selectedIncidenceDate(); | 797 | qd = mAgenda->selectedIncidenceDate(); |
782 | if (qd.isValid()) selected.append(qd); | 798 | if (qd.isValid()) selected.append(qd); |
783 | 799 | ||
784 | qd = mAllDayAgenda->selectedIncidenceDate(); | 800 | qd = mAllDayAgenda->selectedIncidenceDate(); |
785 | if (qd.isValid()) selected.append(qd); | 801 | if (qd.isValid()) selected.append(qd); |
786 | 802 | ||
787 | return selected; | 803 | return selected; |
788 | } | 804 | } |
789 | 805 | ||
790 | 806 | ||
791 | void KOAgendaView::updateView() | 807 | void KOAgendaView::updateView() |
792 | { | 808 | { |
793 | if ( mBlockUpdating ) | 809 | if ( mBlockUpdating ) |
794 | return; | 810 | return; |
795 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 811 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
796 | fillAgenda(); | 812 | fillAgenda(); |
797 | 813 | ||
798 | } | 814 | } |
799 | 815 | ||
800 | 816 | ||
801 | /* | 817 | /* |
802 | Update configuration settings for the agenda view. This method is not | 818 | Update configuration settings for the agenda view. This method is not |
803 | complete. | 819 | complete. |
804 | */ | 820 | */ |
805 | void KOAgendaView::updateConfig() | 821 | void KOAgendaView::updateConfig() |
806 | { | 822 | { |
807 | if ( mBlockUpdating ) | 823 | if ( mBlockUpdating ) |
808 | return; | 824 | return; |
809 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; | 825 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; |
810 | 826 | ||
811 | // update config for children | 827 | // update config for children |
812 | mTimeLabels->updateConfig(); | 828 | mTimeLabels->updateConfig(); |
813 | mAgenda->storePosition(); | 829 | mAgenda->storePosition(); |
814 | mAgenda->updateConfig(); | 830 | mAgenda->updateConfig(); |
815 | mAllDayAgenda->updateConfig(); | 831 | mAllDayAgenda->updateConfig(); |
816 | // widget synchronization | 832 | // widget synchronization |
817 | //TODO: find a better way, maybe signal/slot | 833 | //TODO: find a better way, maybe signal/slot |
818 | mTimeLabels->positionChanged(); | 834 | mTimeLabels->positionChanged(); |
819 | 835 | ||
820 | // for some reason, this needs to be called explicitly | 836 | // for some reason, this needs to be called explicitly |
821 | mTimeLabels->repaint(); | 837 | mTimeLabels->repaint(); |
822 | 838 | ||
823 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 839 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
824 | 840 | ||
825 | // ToolTips displaying summary of events | 841 | // ToolTips displaying summary of events |
826 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 842 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
827 | ->mEnableToolTips); | 843 | ->mEnableToolTips); |
828 | 844 | ||
829 | //setHolidayMasks(); | 845 | //setHolidayMasks(); |
830 | 846 | ||
831 | //createDayLabels(); called by via updateView(); | 847 | //createDayLabels(); called by via updateView(); |
832 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 848 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
833 | updateView(); | 849 | updateView(); |
834 | mAgenda->restorePosition(); | 850 | mAgenda->restorePosition(); |
835 | } | 851 | } |
836 | 852 | ||
837 | 853 | ||
838 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 854 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
839 | { | 855 | { |
840 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 856 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
841 | //qDebug("KOAgendaView::updateEventDates "); | 857 | //qDebug("KOAgendaView::updateEventDates "); |
842 | QDateTime startDt,endDt; | 858 | QDateTime startDt,endDt; |
843 | QDate startDate; | 859 | QDate startDate; |
844 | int lenInSecs; | 860 | int lenInSecs; |
845 | // if ( type == KOAgenda::RESIZETOP ) | 861 | // if ( type == KOAgenda::RESIZETOP ) |
846 | // qDebug("RESIZETOP "); | 862 | // qDebug("RESIZETOP "); |
847 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 863 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
848 | // qDebug("RESIZEBOTTOM "); | 864 | // qDebug("RESIZEBOTTOM "); |
849 | // if ( type == KOAgenda::MOVE ) | 865 | // if ( type == KOAgenda::MOVE ) |
850 | // qDebug("MOVE "); | 866 | // qDebug("MOVE "); |
851 | if ( item->incidence()->type() == "Event" ) { | 867 | if ( item->incidence()->type() == "Event" ) { |
852 | startDt =item->incidence()->dtStart(); | 868 | startDt =item->incidence()->dtStart(); |
853 | endDt = item->incidence()->dtEnd(); | 869 | endDt = item->incidence()->dtEnd(); |
854 | lenInSecs = startDt.secsTo( endDt ); | 870 | lenInSecs = startDt.secsTo( endDt ); |
855 | } | 871 | } |
856 | 872 | ||
857 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 873 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
858 | 874 | ||
859 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 875 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
860 | startDate = mSelectedDates[item->mLastMoveXPos]; | 876 | startDate = mSelectedDates[item->mLastMoveXPos]; |
861 | } else { | 877 | } else { |
862 | if (item->cellX() < 0) { | 878 | if (item->cellX() < 0) { |
863 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 879 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
864 | } else { | 880 | } else { |
865 | startDate = mSelectedDates[item->cellX()]; | 881 | startDate = mSelectedDates[item->cellX()]; |
866 | } | 882 | } |
867 | } | 883 | } |
868 | startDt.setDate(startDate); | 884 | startDt.setDate(startDate); |
869 | 885 | ||
870 | if (item->incidence()->doesFloat()) { | 886 | if (item->incidence()->doesFloat()) { |
871 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 887 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
872 | } else { | 888 | } else { |
873 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 889 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
874 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 890 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
875 | if ( item->incidence()->type() == "Event" ) { | 891 | if ( item->incidence()->type() == "Event" ) { |
876 | if ( type == KOAgenda::MOVE ) { | 892 | if ( type == KOAgenda::MOVE ) { |
877 | endDt = startDt.addSecs(lenInSecs); | 893 | endDt = startDt.addSecs(lenInSecs); |
878 | 894 | ||
879 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 895 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
880 | if (item->lastMultiItem()) { | 896 | if (item->lastMultiItem()) { |
881 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 897 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
882 | endDt.setDate(startDate. | 898 | endDt.setDate(startDate. |
883 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 899 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
884 | } else { | 900 | } else { |
885 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 901 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
886 | endDt.setDate(startDate); | 902 | endDt.setDate(startDate); |
887 | } | 903 | } |
888 | } | 904 | } |
889 | } else { | 905 | } else { |
890 | // todo | 906 | // todo |
891 | if (item->lastMultiItem()) { | 907 | if (item->lastMultiItem()) { |
892 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 908 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
893 | endDt.setDate(startDate. | 909 | endDt.setDate(startDate. |
894 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 910 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
895 | } else { | 911 | } else { |
896 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 912 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
897 | if ( item->cellYBottom() > 0 ) | 913 | if ( item->cellYBottom() > 0 ) |
898 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 914 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
899 | else | 915 | else |
900 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 916 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
901 | endDt.setDate(startDate); | 917 | endDt.setDate(startDate); |
902 | } | 918 | } |
903 | } | 919 | } |
904 | } | 920 | } |
905 | 921 | ||
906 | 922 | ||
907 | if ( item->incidence()->type() == "Event" ) { | 923 | if ( item->incidence()->type() == "Event" ) { |
908 | item->incidence()->setDtStart(startDt); | 924 | item->incidence()->setDtStart(startDt); |
909 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 925 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
910 | } else if ( item->incidence()->type() == "Todo" ) { | 926 | } else if ( item->incidence()->type() == "Todo" ) { |
911 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); | 927 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); |
912 | } | 928 | } |
913 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 929 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
914 | item->incidence()->setRevision(item->incidence()->revision()+1); | 930 | item->incidence()->setRevision(item->incidence()->revision()+1); |
915 | item->setItemDate(startDt.date()); | 931 | item->setItemDate(startDt.date()); |
916 | //item->updateItem(); | 932 | //item->updateItem(); |
917 | if ( item->incidence()->type() == "Todo" ) { | 933 | if ( item->incidence()->type() == "Todo" ) { |
918 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 934 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
919 | 935 | ||
920 | } | 936 | } |
921 | else | 937 | else |
922 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 938 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
923 | item->updateItem(); | 939 | item->updateItem(); |
924 | } | 940 | } |
925 | 941 | ||
926 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 942 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
927 | { | 943 | { |
928 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 944 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
929 | 945 | ||
930 | mSelectedDates.clear(); | 946 | mSelectedDates.clear(); |
931 | // qDebug("KOAgendaView::showDates "); | 947 | // qDebug("KOAgendaView::showDates "); |
932 | QDate d = start; | 948 | QDate d = start; |
933 | while (d <= end) { | 949 | while (d <= end) { |
934 | mSelectedDates.append(d); | 950 | mSelectedDates.append(d); |
935 | d = d.addDays( 1 ); | 951 | d = d.addDays( 1 ); |
936 | } | 952 | } |
937 | 953 | ||
938 | // and update the view | 954 | // and update the view |
939 | fillAgenda(); | 955 | fillAgenda(); |
940 | } | 956 | } |
941 | 957 | ||
942 | 958 | ||
943 | void KOAgendaView::showEvents(QPtrList<Event>) | 959 | void KOAgendaView::showEvents(QPtrList<Event>) |
944 | { | 960 | { |
945 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 961 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
946 | } | 962 | } |
947 | 963 | ||
948 | void KOAgendaView::changeEventDisplay(Event *, int) | 964 | void KOAgendaView::changeEventDisplay(Event *, int) |
949 | { | 965 | { |
950 | // qDebug("KOAgendaView::changeEventDisplay "); | 966 | // qDebug("KOAgendaView::changeEventDisplay "); |
951 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 967 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
952 | // this should be re-written to be MUCH smarter. Right now we | 968 | // this should be re-written to be MUCH smarter. Right now we |
953 | // are just playing dumb. | 969 | // are just playing dumb. |
954 | fillAgenda(); | 970 | fillAgenda(); |
955 | } | 971 | } |
956 | 972 | ||
957 | void KOAgendaView::fillAgenda(const QDate &) | 973 | void KOAgendaView::fillAgenda(const QDate &) |
958 | { | 974 | { |
959 | // qDebug("KOAgendaView::fillAgenda "); | 975 | // qDebug("KOAgendaView::fillAgenda "); |
960 | fillAgenda(); | 976 | fillAgenda(); |
961 | } | 977 | } |
962 | 978 | ||
963 | void KOAgendaView::fillAgenda() | 979 | void KOAgendaView::fillAgenda() |
964 | { | 980 | { |
965 | if ( globalFlagBlockStartup ) | 981 | if ( globalFlagBlockStartup ) |
966 | return; | 982 | return; |
967 | if ( globalFlagBlockAgenda == 1 ) | 983 | if ( globalFlagBlockAgenda == 1 ) |
968 | return; | 984 | return; |
969 | //if ( globalFlagBlockAgenda == 2 ) | 985 | //if ( globalFlagBlockAgenda == 2 ) |
970 | //globalFlagBlockAgenda = 0; | 986 | //globalFlagBlockAgenda = 0; |
971 | // globalFlagBlockPainting = false; | 987 | // globalFlagBlockPainting = false; |
972 | if ( globalFlagBlockAgenda == 0 ) | 988 | if ( globalFlagBlockAgenda == 0 ) |
973 | globalFlagBlockAgenda = 1; | 989 | globalFlagBlockAgenda = 1; |
974 | // clearView(); | 990 | // clearView(); |
975 | //qDebug("fillAgenda()++++ "); | 991 | //qDebug("fillAgenda()++++ "); |
976 | globalFlagBlockAgendaItemPaint = 1; | 992 | globalFlagBlockAgendaItemPaint = 1; |
977 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 993 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
978 | mAgenda->changeColumns(mSelectedDates.count()); | 994 | mAgenda->changeColumns(mSelectedDates.count()); |
979 | qApp->processEvents(); | 995 | qApp->processEvents(); |
980 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 996 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
981 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 997 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
982 | setHolidayMasks(); | 998 | setHolidayMasks(); |
983 | 999 | ||
984 | //mAgenda->hideUnused(); | 1000 | //mAgenda->hideUnused(); |
985 | //mAllDayAgenda->hideUnused(); | 1001 | //mAllDayAgenda->hideUnused(); |
986 | 1002 | ||
987 | // mAgenda->blockNextRepaint( false ); | 1003 | // mAgenda->blockNextRepaint( false ); |
988 | // mAgenda->viewport()->repaint(); | 1004 | // mAgenda->viewport()->repaint(); |
989 | // mAgenda->blockNextRepaint( true ); | 1005 | // mAgenda->blockNextRepaint( true ); |
990 | mMinY.resize(mSelectedDates.count()); | 1006 | mMinY.resize(mSelectedDates.count()); |
991 | mMaxY.resize(mSelectedDates.count()); | 1007 | mMaxY.resize(mSelectedDates.count()); |
992 | 1008 | ||
993 | QPtrList<Event> dayEvents; | 1009 | QPtrList<Event> dayEvents; |
994 | 1010 | ||
995 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1011 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
996 | // Therefore, get all of them. | 1012 | // Therefore, get all of them. |
997 | QPtrList<Todo> todos = calendar()->todos(); | 1013 | QPtrList<Todo> todos = calendar()->todos(); |
998 | 1014 | ||
999 | mAgenda->setDateList(mSelectedDates); | 1015 | mAgenda->setDateList(mSelectedDates); |
1000 | 1016 | ||
1001 | QDate today = QDate::currentDate(); | 1017 | QDate today = QDate::currentDate(); |
1002 | 1018 | ||
1003 | DateList::ConstIterator dit; | 1019 | DateList::ConstIterator dit; |
1004 | int curCol = 0; | 1020 | int curCol = 0; |
1005 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1021 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1006 | QDate currentDate = *dit; | 1022 | QDate currentDate = *dit; |
1007 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1023 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1008 | // << endl; | 1024 | // << endl; |
1009 | 1025 | ||
1010 | dayEvents = calendar()->events(currentDate,true); | 1026 | dayEvents = calendar()->events(currentDate,true); |
1011 | 1027 | ||
1012 | // Default values, which can never be reached | 1028 | // Default values, which can never be reached |
1013 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1029 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1014 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1030 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1015 | 1031 | ||
1016 | unsigned int numEvent; | 1032 | unsigned int numEvent; |
1017 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1033 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1018 | Event *event = dayEvents.at(numEvent); | 1034 | Event *event = dayEvents.at(numEvent); |
1019 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1035 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1020 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1036 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1021 | continue; | 1037 | continue; |
1022 | // kdDebug() << " Event: " << event->summary() << endl; | 1038 | // kdDebug() << " Event: " << event->summary() << endl; |
1023 | 1039 | ||
1024 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1040 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1025 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1041 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1026 | 1042 | ||
1027 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1043 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1028 | 1044 | ||
1029 | if (event->doesFloat()) { | 1045 | if (event->doesFloat()) { |
1030 | if (event->recurrence()->doesRecur()) { | 1046 | if (event->recurrence()->doesRecur()) { |
1031 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1047 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1032 | } else { | 1048 | } else { |
1033 | if (beginX <= 0 && curCol == 0) { | 1049 | if (beginX <= 0 && curCol == 0) { |
1034 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1050 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1035 | } else if (beginX == curCol) { | 1051 | } else if (beginX == curCol) { |
1036 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1052 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1037 | } | 1053 | } |
1038 | } | 1054 | } |
1039 | } else if (event->isMultiDay()) { | 1055 | } else if (event->isMultiDay()) { |
1040 | if ( event->doesRecur () ) { | 1056 | if ( event->doesRecur () ) { |
1041 | QDate dateit = currentDate; | 1057 | QDate dateit = currentDate; |
1042 | int count = 0; | 1058 | int count = 0; |
1043 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1059 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1044 | while (! event->recursOn( dateit ) && count <= max ) { | 1060 | while (! event->recursOn( dateit ) && count <= max ) { |
1045 | ++count; | 1061 | ++count; |
1046 | dateit = dateit.addDays( -1 ); | 1062 | dateit = dateit.addDays( -1 ); |
1047 | } | 1063 | } |
1048 | bool ok; | 1064 | bool ok; |
1049 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1065 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1050 | if ( ok ) | 1066 | if ( ok ) |
1051 | { | 1067 | { |
1052 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1068 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1053 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1069 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1054 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1070 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1055 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1071 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1056 | 1072 | ||
1057 | } | 1073 | } |
1058 | } | 1074 | } |
1059 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1075 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1060 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1076 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1061 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1077 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1062 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1078 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1063 | //qDebug("insert!!! "); | 1079 | //qDebug("insert!!! "); |
1064 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1080 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1065 | } | 1081 | } |
1066 | if (beginX == curCol) { | 1082 | if (beginX == curCol) { |
1067 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1083 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1068 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1084 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1069 | } else if (endX == curCol) { | 1085 | } else if (endX == curCol) { |