author | zautrix <zautrix> | 2005-02-06 01:23:43 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-06 01:23:43 (UTC) |
commit | 118f5aab05c9ace5612d5c4fd69e7c5a59bed67b (patch) (unidiff) | |
tree | e097f3fecb6e2ae692b91ac29e58e6d5a51154c8 /korganizer/koagendaview.cpp | |
parent | 659f07aa44f44aebb74c83e7319021cfeb87f275 (diff) | |
download | kdepimpi-118f5aab05c9ace5612d5c4fd69e7c5a59bed67b.zip kdepimpi-118f5aab05c9ace5612d5c4fd69e7c5a59bed67b.tar.gz kdepimpi-118f5aab05c9ace5612d5c4fd69e7c5a59bed67b.tar.bz2 |
better week choose
-rw-r--r-- | korganizer/koagendaview.cpp | 72 |
1 files changed, 2 insertions, 70 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 36c66ea..0d36946 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -236,560 +236,518 @@ void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | |||
236 | if ( tSize > 22 ) | 236 | if ( tSize > 22 ) |
237 | tSize = 22; | 237 | tSize = 22; |
238 | tSize = (tSize/2)*2; | 238 | tSize = (tSize/2)*2; |
239 | if ( tSize == KOPrefs::instance()->mHourSize ) | 239 | if ( tSize == KOPrefs::instance()->mHourSize ) |
240 | return; | 240 | return; |
241 | KOPrefs::instance()->mHourSize = tSize; | 241 | KOPrefs::instance()->mHourSize = tSize; |
242 | emit scaleChanged(); | 242 | emit scaleChanged(); |
243 | } | 243 | } |
244 | 244 | ||
245 | /** This is called in response to repaint() */ | 245 | /** This is called in response to repaint() */ |
246 | void TimeLabels::paintEvent(QPaintEvent*) | 246 | void TimeLabels::paintEvent(QPaintEvent*) |
247 | { | 247 | { |
248 | 248 | ||
249 | // kdDebug() << "paintevent..." << endl; | 249 | // kdDebug() << "paintevent..." << endl; |
250 | // this is another hack! | 250 | // this is another hack! |
251 | // QPainter painter(this); | 251 | // QPainter painter(this); |
252 | //QString c | 252 | //QString c |
253 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 253 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
254 | } | 254 | } |
255 | 255 | ||
256 | //////////////////////////////////////////////////////////////////////////// | 256 | //////////////////////////////////////////////////////////////////////////// |
257 | 257 | ||
258 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 258 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
259 | : QFrame(parent,name) | 259 | : QFrame(parent,name) |
260 | { | 260 | { |
261 | mColumns = 1; | 261 | mColumns = 1; |
262 | mTopBox = 0; | 262 | mTopBox = 0; |
263 | mLocation = loc; | 263 | mLocation = loc; |
264 | mTopLayout = 0; | 264 | mTopLayout = 0; |
265 | mPaintWidget = 0; | 265 | mPaintWidget = 0; |
266 | mXOffset = 0; | 266 | mXOffset = 0; |
267 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 267 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
268 | else mPixmap = SmallIcon("1downarrow"); | 268 | else mPixmap = SmallIcon("1downarrow"); |
269 | mEnabled.resize(mColumns); | 269 | mEnabled.resize(mColumns); |
270 | if (mLocation == Top) | 270 | if (mLocation == Top) |
271 | setMaximumHeight(0); | 271 | setMaximumHeight(0); |
272 | else | 272 | else |
273 | setMinimumHeight(mPixmap.height()); | 273 | setMinimumHeight(mPixmap.height()); |
274 | } | 274 | } |
275 | 275 | ||
276 | EventIndicator::~EventIndicator() | 276 | EventIndicator::~EventIndicator() |
277 | { | 277 | { |
278 | } | 278 | } |
279 | 279 | ||
280 | void EventIndicator::drawContents(QPainter *p) | 280 | void EventIndicator::drawContents(QPainter *p) |
281 | { | 281 | { |
282 | 282 | ||
283 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 283 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
284 | KDGanttSplitterHandle* han = 0; | 284 | KDGanttSplitterHandle* han = 0; |
285 | if ( mPaintWidget ) | 285 | if ( mPaintWidget ) |
286 | han = mPaintWidget->firstHandle(); | 286 | han = mPaintWidget->firstHandle(); |
287 | if ( ! han ) { | 287 | if ( ! han ) { |
288 | int i; | 288 | int i; |
289 | for(i=0;i<mColumns;++i) { | 289 | for(i=0;i<mColumns;++i) { |
290 | if (mEnabled[i]) { | 290 | if (mEnabled[i]) { |
291 | int cellWidth = contentsRect().right()/mColumns; | 291 | int cellWidth = contentsRect().right()/mColumns; |
292 | int xOffset = KOGlobals::self()->reverseLayout() ? | 292 | int xOffset = KOGlobals::self()->reverseLayout() ? |
293 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 293 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
294 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 294 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
295 | p->drawPixmap(QPoint(xOffset,0),mPixmap); | 295 | p->drawPixmap(QPoint(xOffset,0),mPixmap); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | } else { | 298 | } else { |
299 | han->repaint(); | 299 | han->repaint(); |
300 | //mPaintWidget->setBackgroundColor( red ); | 300 | //mPaintWidget->setBackgroundColor( red ); |
301 | 301 | ||
302 | QPainter pa( han ); | 302 | QPainter pa( han ); |
303 | int i; | 303 | int i; |
304 | bool setColor = false; | 304 | bool setColor = false; |
305 | for(i=0;i<mColumns;++i) { | 305 | for(i=0;i<mColumns;++i) { |
306 | if (mEnabled[i]) { | 306 | if (mEnabled[i]) { |
307 | setColor = true; | 307 | setColor = true; |
308 | 308 | ||
309 | int cellWidth = contentsRect().right()/mColumns; | 309 | int cellWidth = contentsRect().right()/mColumns; |
310 | int xOffset = KOGlobals::self()->reverseLayout() ? | 310 | int xOffset = KOGlobals::self()->reverseLayout() ? |
311 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 311 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
312 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 312 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
313 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 313 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
314 | //qDebug("222draw pix %d ",xOffset ); | 314 | //qDebug("222draw pix %d ",xOffset ); |
315 | 315 | ||
316 | } | 316 | } |
317 | 317 | ||
318 | } | 318 | } |
319 | pa.end(); | 319 | pa.end(); |
320 | 320 | ||
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void EventIndicator::setXOffset( int x ) | 324 | void EventIndicator::setXOffset( int x ) |
325 | { | 325 | { |
326 | mXOffset = x; | 326 | mXOffset = x; |
327 | } | 327 | } |
328 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 328 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
329 | { | 329 | { |
330 | mPaintWidget = w; | 330 | mPaintWidget = w; |
331 | } | 331 | } |
332 | void EventIndicator::changeColumns(int columns) | 332 | void EventIndicator::changeColumns(int columns) |
333 | { | 333 | { |
334 | mColumns = columns; | 334 | mColumns = columns; |
335 | mEnabled.resize(mColumns); | 335 | mEnabled.resize(mColumns); |
336 | 336 | ||
337 | update(); | 337 | update(); |
338 | } | 338 | } |
339 | 339 | ||
340 | void EventIndicator::enableColumn(int column, bool enable) | 340 | void EventIndicator::enableColumn(int column, bool enable) |
341 | { | 341 | { |
342 | mEnabled[column] = enable; | 342 | mEnabled[column] = enable; |
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | //////////////////////////////////////////////////////////////////////////// | 346 | //////////////////////////////////////////////////////////////////////////// |
347 | //////////////////////////////////////////////////////////////////////////// | 347 | //////////////////////////////////////////////////////////////////////////// |
348 | //////////////////////////////////////////////////////////////////////////// | 348 | //////////////////////////////////////////////////////////////////////////// |
349 | 349 | ||
350 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 350 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
351 | KOEventView (cal,parent,name) | 351 | KOEventView (cal,parent,name) |
352 | { | 352 | { |
353 | mBlockUpdating = true; | 353 | mBlockUpdating = true; |
354 | mStartHour = 8; | 354 | mStartHour = 8; |
355 | mSelectedDates.append(QDate::currentDate()); | 355 | mSelectedDates.append(QDate::currentDate()); |
356 | 356 | ||
357 | mLayoutDayLabels = 0; | 357 | mLayoutDayLabels = 0; |
358 | mDayLabelsFrame = 0; | 358 | mDayLabelsFrame = 0; |
359 | mDayLabels = 0; | 359 | mDayLabels = 0; |
360 | bool isRTL = KOGlobals::self()->reverseLayout(); | 360 | bool isRTL = KOGlobals::self()->reverseLayout(); |
361 | 361 | ||
362 | if ( KOPrefs::instance()->mVerticalScreen ) { | 362 | if ( KOPrefs::instance()->mVerticalScreen ) { |
363 | mExpandedPixmap = SmallIcon( "1downarrow" ); | 363 | mExpandedPixmap = SmallIcon( "1downarrow" ); |
364 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); | 364 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); |
365 | } else { | 365 | } else { |
366 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); | 366 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); |
367 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); | 367 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); |
368 | } | 368 | } |
369 | 369 | ||
370 | QBoxLayout *topLayout = new QVBoxLayout(this); | 370 | QBoxLayout *topLayout = new QVBoxLayout(this); |
371 | 371 | ||
372 | // Create day name labels for agenda columns | 372 | // Create day name labels for agenda columns |
373 | mDayLabelsFrame = new QHBox(this); | 373 | mDayLabelsFrame = new QHBox(this); |
374 | topLayout->addWidget(mDayLabelsFrame); | 374 | topLayout->addWidget(mDayLabelsFrame); |
375 | mDayLabels = new QFrame (mDayLabelsFrame); | 375 | mDayLabels = new QFrame (mDayLabelsFrame); |
376 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 376 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
377 | // Create agenda splitter | 377 | // Create agenda splitter |
378 | #ifndef KORG_NOSPLITTER | 378 | #ifndef KORG_NOSPLITTER |
379 | mSplitterAgenda = new QSplitter(Vertical,this); | 379 | mSplitterAgenda = new QSplitter(Vertical,this); |
380 | topLayout->addWidget(mSplitterAgenda); | 380 | topLayout->addWidget(mSplitterAgenda); |
381 | mSplitterAgenda->setOpaqueResize(); | 381 | mSplitterAgenda->setOpaqueResize(); |
382 | 382 | ||
383 | mAllDayFrame = new QHBox(mSplitterAgenda); | 383 | mAllDayFrame = new QHBox(mSplitterAgenda); |
384 | 384 | ||
385 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 385 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
386 | #else | 386 | #else |
387 | #if 0 | 387 | #if 0 |
388 | QWidget *mainBox = new QWidget( this ); | 388 | QWidget *mainBox = new QWidget( this ); |
389 | topLayout->addWidget( mainBox ); | 389 | topLayout->addWidget( mainBox ); |
390 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); | 390 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); |
391 | mAllDayFrame = new QHBox(mainBox); | 391 | mAllDayFrame = new QHBox(mainBox); |
392 | mainLayout->addWidget(mAllDayFrame); | 392 | mainLayout->addWidget(mAllDayFrame); |
393 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); | 393 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); |
394 | mAllDayFrame->setFocusPolicy(NoFocus); | 394 | mAllDayFrame->setFocusPolicy(NoFocus); |
395 | QWidget *agendaFrame = new QWidget(mainBox); | 395 | QWidget *agendaFrame = new QWidget(mainBox); |
396 | mainLayout->addWidget(agendaFrame); | 396 | mainLayout->addWidget(agendaFrame); |
397 | mainLayout->setStretchFactor( agendaFrame, 10 ); | 397 | mainLayout->setStretchFactor( agendaFrame, 10 ); |
398 | 398 | ||
399 | agendaFrame->setFocusPolicy(NoFocus); | 399 | agendaFrame->setFocusPolicy(NoFocus); |
400 | #endif | 400 | #endif |
401 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 401 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
402 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 402 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
403 | topLayout->addWidget( mSplitterAgenda ); | 403 | topLayout->addWidget( mSplitterAgenda ); |
404 | mAllDayFrame = new QHBox(mSplitterAgenda); | 404 | mAllDayFrame = new QHBox(mSplitterAgenda); |
405 | mAllDayFrame->setFocusPolicy(NoFocus); | 405 | mAllDayFrame->setFocusPolicy(NoFocus); |
406 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 406 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
407 | agendaFrame->setFocusPolicy(NoFocus); | 407 | agendaFrame->setFocusPolicy(NoFocus); |
408 | 408 | ||
409 | #endif | 409 | #endif |
410 | 410 | ||
411 | // Create all-day agenda widget | 411 | // Create all-day agenda widget |
412 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 412 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
413 | 413 | ||
414 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 414 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
415 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 415 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
416 | int widebut = mExpandButton->sizeHint().width(); | 416 | int widebut = mExpandButton->sizeHint().width(); |
417 | if ( QApplication::desktop()->width() < 480 ) | 417 | if ( QApplication::desktop()->width() < 480 ) |
418 | widebut = widebut*2; | 418 | widebut = widebut*2; |
419 | else | 419 | else |
420 | widebut = (widebut*3) / 2; | 420 | widebut = (widebut*3) / 2; |
421 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 421 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
422 | // QSizePolicy::Fixed ) ); | 422 | // QSizePolicy::Fixed ) ); |
423 | mExpandButton->setFixedSize( widebut, widebut); | 423 | mExpandButton->setFixedSize( widebut, widebut); |
424 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 424 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
425 | mExpandButton->setFocusPolicy(NoFocus); | 425 | mExpandButton->setFocusPolicy(NoFocus); |
426 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 426 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
427 | mAllDayAgenda->setFocusPolicy(NoFocus); | 427 | mAllDayAgenda->setFocusPolicy(NoFocus); |
428 | QVBox *dummyAllDayRight = new QVBox(mAllDayFrame); | 428 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
429 | |||
430 | mDummyAllDayRightL = new QLabel ( dummyAllDayRight ); | ||
431 | QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight); | ||
432 | new QLabel ( dummyAllDayRight ); | ||
433 | mDummyAllDayRightL->setSizePolicy( QSizePolicy( QSizePolicy::Minimum,QSizePolicy::Fixed ) ); | ||
434 | dummyAllDayRightB->setFlat( true ); | ||
435 | dummyAllDayRightB->setFocusPolicy(NoFocus); | ||
436 | dummyAllDayRightB->setFixedHeight( (dummyAllDayRightB->sizeHint().height()/4)*3 ); | ||
437 | |||
438 | QPopupMenu * wpo = new QPopupMenu (this); | ||
439 | QPopupMenu * all = new QPopupMenu (this); | ||
440 | //wpo->insertItem( i18n("W#"), 0 ); | ||
441 | int first = 1; | ||
442 | int i; | ||
443 | for ( i = 1; i < 50; ++i ) { | ||
444 | if ( !(i%10) ) { | ||
445 | all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); | ||
446 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); | ||
447 | first = i; | ||
448 | wpo = new QPopupMenu (this); | ||
449 | } | ||
450 | wpo->insertItem( QString::number(i), i ); | ||
451 | } | ||
452 | for ( i = 50; i < 53; ++i ) { | ||
453 | wpo->insertItem( QString::number(i), i); | ||
454 | } | ||
455 | all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); | ||
456 | dummyAllDayRightB->setPopup( all ); | ||
457 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); | ||
458 | 429 | ||
459 | // Create event context menu for all day agenda | 430 | // Create event context menu for all day agenda |
460 | mAllDayAgendaPopup = eventPopup(); | 431 | mAllDayAgendaPopup = eventPopup(); |
461 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 432 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
462 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 433 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
463 | 434 | ||
464 | // Create agenda frame | 435 | // Create agenda frame |
465 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); | 436 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); |
466 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 437 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
467 | 438 | ||
468 | // create event indicator bars | 439 | // create event indicator bars |
469 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 440 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
470 | agendaLayout->addWidget(mEventIndicatorTop,0,1); | 441 | agendaLayout->addWidget(mEventIndicatorTop,0,1); |
471 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 442 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
472 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 443 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
473 | agendaFrame); | 444 | agendaFrame); |
474 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); | 445 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); |
475 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 446 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
476 | agendaLayout->addWidget(dummyAgendaRight,0,2); | 447 | agendaLayout->addWidget(dummyAgendaRight,0,2); |
477 | 448 | ||
478 | // Create time labels | 449 | // Create time labels |
479 | mTimeLabels = new TimeLabels(24,agendaFrame); | 450 | mTimeLabels = new TimeLabels(24,agendaFrame); |
480 | agendaLayout->addWidget(mTimeLabels,1,0); | 451 | agendaLayout->addWidget(mTimeLabels,1,0); |
481 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 452 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
482 | this,SLOT(updateConfig())); | 453 | this,SLOT(updateConfig())); |
483 | 454 | ||
484 | // Create agenda | 455 | // Create agenda |
485 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 456 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
486 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); | 457 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); |
487 | agendaLayout->setColStretch(1,1); | 458 | agendaLayout->setColStretch(1,1); |
488 | mAgenda->setFocusPolicy(NoFocus); | 459 | mAgenda->setFocusPolicy(NoFocus); |
489 | // Create event context menu for agenda | 460 | // Create event context menu for agenda |
490 | mAgendaPopup = eventPopup(); | 461 | mAgendaPopup = eventPopup(); |
491 | 462 | ||
492 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 463 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
493 | i18n("Toggle Alarm"),mAgenda, | 464 | i18n("Toggle Alarm"),mAgenda, |
494 | SLOT(popupAlarm()),true); | 465 | SLOT(popupAlarm()),true); |
495 | 466 | ||
496 | 467 | ||
497 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 468 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
498 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 469 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
499 | 470 | ||
500 | // make connections between dependent widgets | 471 | // make connections between dependent widgets |
501 | mTimeLabels->setAgenda(mAgenda); | 472 | mTimeLabels->setAgenda(mAgenda); |
502 | 473 | ||
503 | // Update widgets to reflect user preferences | 474 | // Update widgets to reflect user preferences |
504 | // updateConfig(); | 475 | // updateConfig(); |
505 | 476 | ||
506 | // createDayLabels(); | 477 | // createDayLabels(); |
507 | 478 | ||
508 | // these blank widgets make the All Day Event box line up with the agenda | 479 | // these blank widgets make the All Day Event box line up with the agenda |
509 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 480 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
510 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 481 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
511 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 482 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
512 | 483 | ||
513 | // Scrolling | 484 | // Scrolling |
514 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 485 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
515 | mTimeLabels, SLOT(positionChanged())); | 486 | mTimeLabels, SLOT(positionChanged())); |
516 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 487 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
517 | SLOT(setContentsPos(int))); | 488 | SLOT(setContentsPos(int))); |
518 | 489 | ||
519 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 490 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
520 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 491 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
521 | 492 | ||
522 | // Create/Show/Edit/Delete Event | 493 | // Create/Show/Edit/Delete Event |
523 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 494 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
524 | SLOT(newEvent(int,int))); | 495 | SLOT(newEvent(int,int))); |
525 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 496 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
526 | SLOT(newTodo(int,int))); | 497 | SLOT(newTodo(int,int))); |
527 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 498 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
528 | SLOT(newEvent(int,int,int,int))); | 499 | SLOT(newEvent(int,int,int,int))); |
529 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 500 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
530 | SLOT(newEventAllDay(int,int))); | 501 | SLOT(newEventAllDay(int,int))); |
531 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 502 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
532 | SLOT(newTodoAllDay(int,int))); | 503 | SLOT(newTodoAllDay(int,int))); |
533 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 504 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
534 | SLOT(newEventAllDay(int,int))); | 505 | SLOT(newEventAllDay(int,int))); |
535 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 506 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
536 | SLOT(newTimeSpanSelected(int,int,int,int))); | 507 | SLOT(newTimeSpanSelected(int,int,int,int))); |
537 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 508 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
538 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 509 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
539 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 510 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
540 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 511 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
541 | 512 | ||
542 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 513 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
543 | SIGNAL(editIncidenceSignal(Incidence *))); | 514 | SIGNAL(editIncidenceSignal(Incidence *))); |
544 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 515 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
545 | SIGNAL(editIncidenceSignal(Incidence *))); | 516 | SIGNAL(editIncidenceSignal(Incidence *))); |
546 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 517 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
547 | SIGNAL(showIncidenceSignal(Incidence *))); | 518 | SIGNAL(showIncidenceSignal(Incidence *))); |
548 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 519 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
549 | SIGNAL(showIncidenceSignal(Incidence *))); | 520 | SIGNAL(showIncidenceSignal(Incidence *))); |
550 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 521 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
551 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 522 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
552 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 523 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
553 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 524 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
554 | 525 | ||
555 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 526 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
556 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 527 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
557 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 528 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
558 | SLOT(updateEventDates(KOAgendaItem *, int))); | 529 | SLOT(updateEventDates(KOAgendaItem *, int))); |
559 | 530 | ||
560 | // event indicator update | 531 | // event indicator update |
561 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 532 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
562 | SLOT(updateEventIndicatorTop(int))); | 533 | SLOT(updateEventIndicatorTop(int))); |
563 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 534 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
564 | SLOT(updateEventIndicatorBottom(int))); | 535 | SLOT(updateEventIndicatorBottom(int))); |
565 | // drag signals | 536 | // drag signals |
566 | /* | 537 | /* |
567 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 538 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
568 | SLOT(startDrag(Event *))); | 539 | SLOT(startDrag(Event *))); |
569 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 540 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
570 | SLOT(startDrag(Event *))); | 541 | SLOT(startDrag(Event *))); |
571 | */ | 542 | */ |
572 | // synchronize selections | 543 | // synchronize selections |
573 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 544 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
574 | mAllDayAgenda, SLOT( deselectItem() ) ); | 545 | mAllDayAgenda, SLOT( deselectItem() ) ); |
575 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 546 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
576 | mAgenda, SLOT( deselectItem() ) ); | 547 | mAgenda, SLOT( deselectItem() ) ); |
577 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 548 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
578 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 549 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
579 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 550 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
580 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 551 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
581 | connect( mAgenda, SIGNAL( resizedSignal() ), | 552 | connect( mAgenda, SIGNAL( resizedSignal() ), |
582 | SLOT( updateConfig( ) ) ); | 553 | SLOT( updateConfig( ) ) ); |
583 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 554 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
584 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 555 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
585 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 556 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
586 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 557 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
587 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 558 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
588 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 559 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
589 | 560 | ||
590 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 561 | |
591 | QFontMetrics fm ( dlf ); | ||
592 | QString dayTest = "30"; | ||
593 | int wid = fm.width( dayTest ); | ||
594 | int maxWid = dummyAllDayRight->width()-2; | ||
595 | int fontPoint = dlf.pointSize(); | ||
596 | while ( wid > maxWid ) { | ||
597 | --fontPoint; | ||
598 | dlf.setPointSize( fontPoint ); | ||
599 | QFontMetrics f( dlf ); | ||
600 | wid = f.width( dayTest ); | ||
601 | } | ||
602 | mDummyAllDayRightL->setFont( dlf ); | ||
603 | mDummyAllDayRightL->setAlignment( AlignHCenter ); | ||
604 | } | 562 | } |
605 | 563 | ||
606 | void KOAgendaView::toggleAllDay() | 564 | void KOAgendaView::toggleAllDay() |
607 | { | 565 | { |
608 | if ( mSplitterAgenda->firstHandle() ) | 566 | if ( mSplitterAgenda->firstHandle() ) |
609 | mSplitterAgenda->firstHandle()->toggle(); | 567 | mSplitterAgenda->firstHandle()->toggle(); |
610 | } | 568 | } |
611 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 569 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
612 | { | 570 | { |
613 | calendar()->addIncidence( inc ); | 571 | calendar()->addIncidence( inc ); |
614 | 572 | ||
615 | if ( incOld ) { | 573 | if ( incOld ) { |
616 | if ( incOld->type() == "Todo" ) | 574 | if ( incOld->type() == "Todo" ) |
617 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 575 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
618 | else | 576 | else |
619 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 577 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
620 | } | 578 | } |
621 | 579 | ||
622 | } | 580 | } |
623 | 581 | ||
624 | KOAgendaView::~KOAgendaView() | 582 | KOAgendaView::~KOAgendaView() |
625 | { | 583 | { |
626 | delete mAgendaPopup; | 584 | delete mAgendaPopup; |
627 | delete mAllDayAgendaPopup; | 585 | delete mAllDayAgendaPopup; |
628 | delete KOAgendaItem::paintPix(); | 586 | delete KOAgendaItem::paintPix(); |
629 | delete KOAgendaItem::paintPixSel(); | 587 | delete KOAgendaItem::paintPixSel(); |
630 | } | 588 | } |
631 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 589 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
632 | { | 590 | { |
633 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 591 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
634 | bool uc = false; | 592 | bool uc = false; |
635 | int ow = e->oldSize().width(); | 593 | int ow = e->oldSize().width(); |
636 | int oh = e->oldSize().height(); | 594 | int oh = e->oldSize().height(); |
637 | int w = e->size().width(); | 595 | int w = e->size().width(); |
638 | int h = e->size().height(); | 596 | int h = e->size().height(); |
639 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 597 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
640 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 598 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
641 | uc = true; | 599 | uc = true; |
642 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 600 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
643 | } | 601 | } |
644 | mUpcomingWidth = e->size().width() ; | 602 | mUpcomingWidth = e->size().width() ; |
645 | if ( mBlockUpdating || uc ) { | 603 | if ( mBlockUpdating || uc ) { |
646 | mBlockUpdating = false; | 604 | mBlockUpdating = false; |
647 | //mAgenda->setMinimumSize(800 , 600 ); | 605 | //mAgenda->setMinimumSize(800 , 600 ); |
648 | //qDebug("mAgenda->resize+++++++++++++++ "); | 606 | //qDebug("mAgenda->resize+++++++++++++++ "); |
649 | updateConfig(); | 607 | updateConfig(); |
650 | //qDebug("KOAgendaView::Updating now possible "); | 608 | //qDebug("KOAgendaView::Updating now possible "); |
651 | } else | 609 | } else |
652 | createDayLabels(); | 610 | createDayLabels(); |
653 | //qDebug("resizeEvent end "); | 611 | //qDebug("resizeEvent end "); |
654 | 612 | ||
655 | } | 613 | } |
656 | void KOAgendaView::slotDaylabelClicked( int num ) | 614 | void KOAgendaView::slotDaylabelClicked( int num ) |
657 | { | 615 | { |
658 | 616 | ||
659 | QDate firstDate = mSelectedDates.first(); | 617 | QDate firstDate = mSelectedDates.first(); |
660 | if ( num == -1 ) | 618 | if ( num == -1 ) |
661 | emit showDateView( 6, firstDate ); | 619 | emit showDateView( 6, firstDate ); |
662 | else if (num >= 0 ) { | 620 | else if (num >= 0 ) { |
663 | if ( mSelectedDates.count() == 1) | 621 | if ( mSelectedDates.count() == 1) |
664 | emit showDateView( 9, firstDate.addDays( num ) ); | 622 | emit showDateView( 9, firstDate.addDays( num ) ); |
665 | else | 623 | else |
666 | emit showDateView( 3, firstDate.addDays( num ) ); | 624 | emit showDateView( 3, firstDate.addDays( num ) ); |
667 | } | 625 | } |
668 | else | 626 | else |
669 | showDateView( 10, firstDate.addDays(1) ); | 627 | showDateView( 10, firstDate.addDays(1) ); |
670 | } | 628 | } |
671 | 629 | ||
672 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 630 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
673 | { | 631 | { |
674 | 632 | ||
675 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 633 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
676 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 634 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
677 | mDayLabelsList.append( dayLabel ); | 635 | mDayLabelsList.append( dayLabel ); |
678 | mLayoutDayLabels->addWidget(dayLabel); | 636 | mLayoutDayLabels->addWidget(dayLabel); |
679 | return dayLabel ; | 637 | return dayLabel ; |
680 | } | 638 | } |
681 | 639 | ||
682 | void KOAgendaView::createDayLabels() | 640 | void KOAgendaView::createDayLabels() |
683 | { | 641 | { |
684 | 642 | ||
685 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 643 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
686 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 644 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
687 | return; | 645 | return; |
688 | 646 | ||
689 | } | 647 | } |
690 | int newHight; | 648 | int newHight; |
691 | 649 | ||
692 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 650 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
693 | // It would remove some flickering and gain speed (since this is called by | 651 | // It would remove some flickering and gain speed (since this is called by |
694 | // each updateView() call) | 652 | // each updateView() call) |
695 | 653 | ||
696 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 654 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
697 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 655 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
698 | if ( maxWid < 0 ) | 656 | if ( maxWid < 0 ) |
699 | maxWid = 20; | 657 | maxWid = 20; |
700 | 658 | ||
701 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 659 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
702 | QFontMetrics fm ( dlf ); | 660 | QFontMetrics fm ( dlf ); |
703 | int selCount = mSelectedDates.count(); | 661 | int selCount = mSelectedDates.count(); |
704 | QString dayTest = "Mon 20"; | 662 | QString dayTest = "Mon 20"; |
705 | //QString dayTest = "Mon 20"; | 663 | //QString dayTest = "Mon 20"; |
706 | int wid = fm.width( dayTest ); | 664 | int wid = fm.width( dayTest ); |
707 | //maxWid -= ( selCount * 3 ); //working for QLabels | 665 | //maxWid -= ( selCount * 3 ); //working for QLabels |
708 | maxWid -= ( selCount * 3 ); //working for QPushButton | 666 | maxWid -= ( selCount * 3 ); //working for QPushButton |
709 | if ( maxWid < 0 ) | 667 | if ( maxWid < 0 ) |
710 | maxWid = 20; | 668 | maxWid = 20; |
711 | int needWid = wid * selCount; | 669 | int needWid = wid * selCount; |
712 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 670 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
713 | //if ( needWid > maxWid ) | 671 | //if ( needWid > maxWid ) |
714 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 672 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
715 | while ( needWid > maxWid ) { | 673 | while ( needWid > maxWid ) { |
716 | dayTest = dayTest.left( dayTest.length() - 1 ); | 674 | dayTest = dayTest.left( dayTest.length() - 1 ); |
717 | wid = fm.width( dayTest ); | 675 | wid = fm.width( dayTest ); |
718 | needWid = wid * selCount; | 676 | needWid = wid * selCount; |
719 | } | 677 | } |
720 | int maxLen = dayTest.length(); | 678 | int maxLen = dayTest.length(); |
721 | int fontPoint = dlf.pointSize(); | 679 | int fontPoint = dlf.pointSize(); |
722 | if ( maxLen < 2 ) { | 680 | if ( maxLen < 2 ) { |
723 | int fontPoint = dlf.pointSize(); | 681 | int fontPoint = dlf.pointSize(); |
724 | while ( fontPoint > 4 ) { | 682 | while ( fontPoint > 4 ) { |
725 | --fontPoint; | 683 | --fontPoint; |
726 | dlf.setPointSize( fontPoint ); | 684 | dlf.setPointSize( fontPoint ); |
727 | QFontMetrics f( dlf ); | 685 | QFontMetrics f( dlf ); |
728 | wid = f.width( "30" ); | 686 | wid = f.width( "30" ); |
729 | needWid = wid * selCount; | 687 | needWid = wid * selCount; |
730 | if ( needWid < maxWid ) | 688 | if ( needWid < maxWid ) |
731 | break; | 689 | break; |
732 | } | 690 | } |
733 | maxLen = 2; | 691 | maxLen = 2; |
734 | } | 692 | } |
735 | //qDebug("Max len %d ", dayTest.length() ); | 693 | //qDebug("Max len %d ", dayTest.length() ); |
736 | 694 | ||
737 | QFontMetrics tempF( dlf ); | 695 | QFontMetrics tempF( dlf ); |
738 | newHight = tempF.height(); | 696 | newHight = tempF.height(); |
739 | mDayLabels->setFont( dlf ); | 697 | mDayLabels->setFont( dlf ); |
740 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 698 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
741 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 699 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
742 | //mLayoutDayLabels->addSpacing( 2 ); | 700 | //mLayoutDayLabels->addSpacing( 2 ); |
743 | // QFont lFont = dlf; | 701 | // QFont lFont = dlf; |
744 | bool appendLabels = false; | 702 | bool appendLabels = false; |
745 | KOAgendaButton *dayLabel; | 703 | KOAgendaButton *dayLabel; |
746 | dayLabel = mDayLabelsList.first(); | 704 | dayLabel = mDayLabelsList.first(); |
747 | if ( !dayLabel ) { | 705 | if ( !dayLabel ) { |
748 | appendLabels = true; | 706 | appendLabels = true; |
749 | dayLabel = getNewDaylabel(); | 707 | dayLabel = getNewDaylabel(); |
750 | } | 708 | } |
751 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 709 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
752 | dayLabel->setFont( dlf ); | 710 | dayLabel->setFont( dlf ); |
753 | dayLabel->setNum( -1 ); | 711 | dayLabel->setNum( -1 ); |
754 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 712 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
755 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 713 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
756 | dayLabel->show(); | 714 | dayLabel->show(); |
757 | DateList::ConstIterator dit; | 715 | DateList::ConstIterator dit; |
758 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 716 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
759 | int counter = -1; | 717 | int counter = -1; |
760 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 718 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
761 | ++counter; | 719 | ++counter; |
762 | QDate date = *dit; | 720 | QDate date = *dit; |
763 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 721 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
764 | if ( ! appendLabels ) { | 722 | if ( ! appendLabels ) { |
765 | dayLabel = mDayLabelsList.next(); | 723 | dayLabel = mDayLabelsList.next(); |
766 | if ( !dayLabel ) | 724 | if ( !dayLabel ) |
767 | appendLabels = true; | 725 | appendLabels = true; |
768 | } | 726 | } |
769 | if ( appendLabels ) { | 727 | if ( appendLabels ) { |
770 | dayLabel = getNewDaylabel(); | 728 | dayLabel = getNewDaylabel(); |
771 | } | 729 | } |
772 | dayLabel->setMinimumWidth( 1 ); | 730 | dayLabel->setMinimumWidth( 1 ); |
773 | dayLabel->setMaximumWidth( 1024 ); | 731 | dayLabel->setMaximumWidth( 1024 ); |
774 | dayLabel->setFont( dlf ); | 732 | dayLabel->setFont( dlf ); |
775 | dayLabel->show(); | 733 | dayLabel->show(); |
776 | dayLabel->setNum( counter ); | 734 | dayLabel->setNum( counter ); |
777 | QString str; | 735 | QString str; |
778 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 736 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
779 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 737 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
780 | switch ( maxLen ) { | 738 | switch ( maxLen ) { |
781 | case 2: | 739 | case 2: |
782 | str = QString::number( date.day() ); | 740 | str = QString::number( date.day() ); |
783 | break; | 741 | break; |
784 | 742 | ||
785 | case 3: | 743 | case 3: |
786 | str = dayName.left( 1 ) +QString::number( date.day()); | 744 | str = dayName.left( 1 ) +QString::number( date.day()); |
787 | 745 | ||
788 | break; | 746 | break; |
789 | case 4: | 747 | case 4: |
790 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 748 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
791 | 749 | ||
792 | break; | 750 | break; |
793 | case 5: | 751 | case 5: |
794 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 752 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
795 | 753 | ||
@@ -919,410 +877,384 @@ DateList KOAgendaView::selectedDates() | |||
919 | if (qd.isValid()) selected.append(qd); | 877 | if (qd.isValid()) selected.append(qd); |
920 | 878 | ||
921 | return selected; | 879 | return selected; |
922 | } | 880 | } |
923 | 881 | ||
924 | 882 | ||
925 | void KOAgendaView::updateView() | 883 | void KOAgendaView::updateView() |
926 | { | 884 | { |
927 | if ( mBlockUpdating ) | 885 | if ( mBlockUpdating ) |
928 | return; | 886 | return; |
929 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 887 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
930 | fillAgenda(); | 888 | fillAgenda(); |
931 | 889 | ||
932 | } | 890 | } |
933 | 891 | ||
934 | 892 | ||
935 | /* | 893 | /* |
936 | Update configuration settings for the agenda view. This method is not | 894 | Update configuration settings for the agenda view. This method is not |
937 | complete. | 895 | complete. |
938 | */ | 896 | */ |
939 | void KOAgendaView::updateConfig() | 897 | void KOAgendaView::updateConfig() |
940 | { | 898 | { |
941 | if ( mBlockUpdating ) | 899 | if ( mBlockUpdating ) |
942 | return; | 900 | return; |
943 | 901 | ||
944 | 902 | ||
945 | 903 | ||
946 | // update config for children | 904 | // update config for children |
947 | mTimeLabels->updateConfig(); | 905 | mTimeLabels->updateConfig(); |
948 | mAgenda->storePosition(); | 906 | mAgenda->storePosition(); |
949 | mAgenda->updateConfig(); | 907 | mAgenda->updateConfig(); |
950 | mAllDayAgenda->updateConfig(); | 908 | mAllDayAgenda->updateConfig(); |
951 | // widget synchronization | 909 | // widget synchronization |
952 | //TODO: find a better way, maybe signal/slot | 910 | //TODO: find a better way, maybe signal/slot |
953 | mTimeLabels->positionChanged(); | 911 | mTimeLabels->positionChanged(); |
954 | 912 | ||
955 | // for some reason, this needs to be called explicitly | 913 | // for some reason, this needs to be called explicitly |
956 | mTimeLabels->repaint(); | 914 | mTimeLabels->repaint(); |
957 | 915 | ||
958 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 916 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
959 | 917 | ||
960 | // ToolTips displaying summary of events | 918 | // ToolTips displaying summary of events |
961 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 919 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
962 | ->mEnableToolTips); | 920 | ->mEnableToolTips); |
963 | 921 | ||
964 | //setHolidayMasks(); | 922 | //setHolidayMasks(); |
965 | 923 | ||
966 | //createDayLabels(); called by via updateView(); | 924 | //createDayLabels(); called by via updateView(); |
967 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 925 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
968 | updateView(); | 926 | updateView(); |
969 | mAgenda->restorePosition(); | 927 | mAgenda->restorePosition(); |
970 | } | 928 | } |
971 | 929 | ||
972 | 930 | ||
973 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 931 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
974 | { | 932 | { |
975 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 933 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
976 | //qDebug("KOAgendaView::updateEventDates "); | 934 | //qDebug("KOAgendaView::updateEventDates "); |
977 | QDateTime startDt,endDt; | 935 | QDateTime startDt,endDt; |
978 | QDate startDate; | 936 | QDate startDate; |
979 | int lenInSecs; | 937 | int lenInSecs; |
980 | // if ( type == KOAgenda::RESIZETOP ) | 938 | // if ( type == KOAgenda::RESIZETOP ) |
981 | // qDebug("RESIZETOP "); | 939 | // qDebug("RESIZETOP "); |
982 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 940 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
983 | // qDebug("RESIZEBOTTOM "); | 941 | // qDebug("RESIZEBOTTOM "); |
984 | // if ( type == KOAgenda::MOVE ) | 942 | // if ( type == KOAgenda::MOVE ) |
985 | // qDebug("MOVE "); | 943 | // qDebug("MOVE "); |
986 | if ( item->incidence()->type() == "Event" ) { | 944 | if ( item->incidence()->type() == "Event" ) { |
987 | startDt =item->incidence()->dtStart(); | 945 | startDt =item->incidence()->dtStart(); |
988 | endDt = item->incidence()->dtEnd(); | 946 | endDt = item->incidence()->dtEnd(); |
989 | lenInSecs = startDt.secsTo( endDt ); | 947 | lenInSecs = startDt.secsTo( endDt ); |
990 | } | 948 | } |
991 | 949 | ||
992 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 950 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
993 | 951 | ||
994 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 952 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
995 | startDate = mSelectedDates[item->mLastMoveXPos]; | 953 | startDate = mSelectedDates[item->mLastMoveXPos]; |
996 | } else { | 954 | } else { |
997 | if (item->cellX() < 0) { | 955 | if (item->cellX() < 0) { |
998 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 956 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
999 | } else { | 957 | } else { |
1000 | startDate = mSelectedDates[item->cellX()]; | 958 | startDate = mSelectedDates[item->cellX()]; |
1001 | } | 959 | } |
1002 | } | 960 | } |
1003 | startDt.setDate(startDate); | 961 | startDt.setDate(startDate); |
1004 | 962 | ||
1005 | if (item->incidence()->doesFloat()) { | 963 | if (item->incidence()->doesFloat()) { |
1006 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 964 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
1007 | } else { | 965 | } else { |
1008 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 966 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
1009 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 967 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
1010 | if ( item->incidence()->type() == "Event" ) { | 968 | if ( item->incidence()->type() == "Event" ) { |
1011 | if ( type == KOAgenda::MOVE ) { | 969 | if ( type == KOAgenda::MOVE ) { |
1012 | endDt = startDt.addSecs(lenInSecs); | 970 | endDt = startDt.addSecs(lenInSecs); |
1013 | 971 | ||
1014 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 972 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
1015 | if (item->lastMultiItem()) { | 973 | if (item->lastMultiItem()) { |
1016 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 974 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1017 | endDt.setDate(startDate. | 975 | endDt.setDate(startDate. |
1018 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 976 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1019 | } else { | 977 | } else { |
1020 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 978 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1021 | endDt.setDate(startDate); | 979 | endDt.setDate(startDate); |
1022 | } | 980 | } |
1023 | } | 981 | } |
1024 | } else { | 982 | } else { |
1025 | // todo | 983 | // todo |
1026 | if (item->lastMultiItem()) { | 984 | if (item->lastMultiItem()) { |
1027 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 985 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1028 | endDt.setDate(startDate. | 986 | endDt.setDate(startDate. |
1029 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 987 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1030 | } else { | 988 | } else { |
1031 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 989 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1032 | if ( item->cellYBottom() > 0 ) | 990 | if ( item->cellYBottom() > 0 ) |
1033 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 991 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1034 | else | 992 | else |
1035 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 993 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1036 | endDt.setDate(startDate); | 994 | endDt.setDate(startDate); |
1037 | } | 995 | } |
1038 | } | 996 | } |
1039 | } | 997 | } |
1040 | if ( item->incidence()->type() == "Event" ) { | 998 | if ( item->incidence()->type() == "Event" ) { |
1041 | item->incidence()->setDtStart(startDt); | 999 | item->incidence()->setDtStart(startDt); |
1042 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1000 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1043 | } else if ( item->incidence()->type() == "Todo" ) { | 1001 | } else if ( item->incidence()->type() == "Todo" ) { |
1044 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); | 1002 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); |
1045 | } | 1003 | } |
1046 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1004 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1047 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1005 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1048 | item->setItemDate(startDt.date()); | 1006 | item->setItemDate(startDt.date()); |
1049 | //item->updateItem(); | 1007 | //item->updateItem(); |
1050 | if ( item->incidence()->type() == "Todo" ) { | 1008 | if ( item->incidence()->type() == "Todo" ) { |
1051 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1009 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1052 | 1010 | ||
1053 | } | 1011 | } |
1054 | else | 1012 | else |
1055 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1013 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1056 | item->updateItem(); | 1014 | item->updateItem(); |
1057 | } | 1015 | } |
1058 | 1016 | ||
1059 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1017 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1060 | { | 1018 | { |
1061 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1019 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1062 | 1020 | ||
1063 | mSelectedDates.clear(); | 1021 | mSelectedDates.clear(); |
1064 | // qDebug("KOAgendaView::showDates "); | 1022 | // qDebug("KOAgendaView::showDates "); |
1065 | QDate d = start; | 1023 | QDate d = start; |
1066 | while (d <= end) { | 1024 | while (d <= end) { |
1067 | mSelectedDates.append(d); | 1025 | mSelectedDates.append(d); |
1068 | d = d.addDays( 1 ); | 1026 | d = d.addDays( 1 ); |
1069 | } | 1027 | } |
1070 | 1028 | ||
1071 | // and update the view | 1029 | // and update the view |
1072 | fillAgenda(); | 1030 | fillAgenda(); |
1073 | } | 1031 | } |
1074 | 1032 | ||
1075 | 1033 | ||
1076 | void KOAgendaView::showEvents(QPtrList<Event>) | 1034 | void KOAgendaView::showEvents(QPtrList<Event>) |
1077 | { | 1035 | { |
1078 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1036 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1079 | } | 1037 | } |
1080 | 1038 | ||
1081 | void KOAgendaView::changeEventDisplay(Event *, int) | 1039 | void KOAgendaView::changeEventDisplay(Event *, int) |
1082 | { | 1040 | { |
1083 | // qDebug("KOAgendaView::changeEventDisplay "); | 1041 | // qDebug("KOAgendaView::changeEventDisplay "); |
1084 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1042 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1085 | // this should be re-written to be MUCH smarter. Right now we | 1043 | // this should be re-written to be MUCH smarter. Right now we |
1086 | // are just playing dumb. | 1044 | // are just playing dumb. |
1087 | fillAgenda(); | 1045 | fillAgenda(); |
1088 | } | 1046 | } |
1089 | 1047 | ||
1090 | void KOAgendaView::fillAgenda(const QDate &) | 1048 | void KOAgendaView::fillAgenda(const QDate &) |
1091 | { | 1049 | { |
1092 | // qDebug("KOAgendaView::fillAgenda "); | 1050 | // qDebug("KOAgendaView::fillAgenda "); |
1093 | fillAgenda(); | 1051 | fillAgenda(); |
1094 | } | 1052 | } |
1095 | 1053 | ||
1096 | void KOAgendaView::fillAgenda() | 1054 | void KOAgendaView::fillAgenda() |
1097 | { | 1055 | { |
1098 | if ( globalFlagBlockStartup ) | 1056 | if ( globalFlagBlockStartup ) |
1099 | return; | 1057 | return; |
1100 | if ( globalFlagBlockAgenda == 1 ) | 1058 | if ( globalFlagBlockAgenda == 1 ) |
1101 | return; | 1059 | return; |
1102 | //if ( globalFlagBlockAgenda == 2 ) | 1060 | //if ( globalFlagBlockAgenda == 2 ) |
1103 | //globalFlagBlockAgenda = 0; | 1061 | //globalFlagBlockAgenda = 0; |
1104 | // globalFlagBlockPainting = false; | 1062 | // globalFlagBlockPainting = false; |
1105 | if ( globalFlagBlockAgenda == 0 ) | 1063 | if ( globalFlagBlockAgenda == 0 ) |
1106 | globalFlagBlockAgenda = 1; | 1064 | globalFlagBlockAgenda = 1; |
1107 | // clearView(); | 1065 | // clearView(); |
1108 | //qDebug("fillAgenda()++++ "); | 1066 | //qDebug("fillAgenda()++++ "); |
1109 | globalFlagBlockAgendaItemPaint = 1; | 1067 | globalFlagBlockAgendaItemPaint = 1; |
1110 | 1068 | ||
1111 | int weekNum = 0; | ||
1112 | QDate seda = mSelectedDates.first(); | ||
1113 | QDate d = QDate ( seda.year(), 1,1); | ||
1114 | seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday | ||
1115 | if ( seda.addDays(6).year() != seda.year() ) { | ||
1116 | if ( seda.year() != d.year() ) { | ||
1117 | if ( d.dayOfWeek() > 4 ) | ||
1118 | d = QDate ( seda.year(), 1,1); | ||
1119 | else | ||
1120 | weekNum = 1; | ||
1121 | } else { | ||
1122 | QDate dd( seda.year()+1, 1,1); | ||
1123 | if ( dd.dayOfWeek() <= 4 ) | ||
1124 | weekNum = 1; | ||
1125 | } | ||
1126 | } | ||
1127 | if ( weekNum == 0 ){ | ||
1128 | int dow = d.dayOfWeek(); | ||
1129 | if ( dow <= 4 ) | ||
1130 | d = d.addDays( 1-dow ); | ||
1131 | else // 5,6,7 | ||
1132 | d = d.addDays( 8-dow ); | ||
1133 | // we have the first week of the year.we are on monday | ||
1134 | weekNum = d.daysTo( seda ) / 7 +1; | ||
1135 | } | ||
1136 | mDummyAllDayRightL->setText( QString::number( weekNum) ); | ||
1137 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1069 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1138 | mAgenda->changeColumns(mSelectedDates.count()); | 1070 | mAgenda->changeColumns(mSelectedDates.count()); |
1139 | qApp->processEvents(); | 1071 | qApp->processEvents(); |
1140 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1072 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1141 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1073 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1142 | setHolidayMasks(); | 1074 | setHolidayMasks(); |
1143 | 1075 | ||
1144 | //mAgenda->hideUnused(); | 1076 | //mAgenda->hideUnused(); |
1145 | //mAllDayAgenda->hideUnused(); | 1077 | //mAllDayAgenda->hideUnused(); |
1146 | 1078 | ||
1147 | // mAgenda->blockNextRepaint( false ); | 1079 | // mAgenda->blockNextRepaint( false ); |
1148 | // mAgenda->viewport()->repaint(); | 1080 | // mAgenda->viewport()->repaint(); |
1149 | // mAgenda->blockNextRepaint( true ); | 1081 | // mAgenda->blockNextRepaint( true ); |
1150 | mMinY.resize(mSelectedDates.count()); | 1082 | mMinY.resize(mSelectedDates.count()); |
1151 | mMaxY.resize(mSelectedDates.count()); | 1083 | mMaxY.resize(mSelectedDates.count()); |
1152 | 1084 | ||
1153 | QPtrList<Event> dayEvents; | 1085 | QPtrList<Event> dayEvents; |
1154 | 1086 | ||
1155 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1087 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1156 | // Therefore, gtodoset all of them. | 1088 | // Therefore, gtodoset all of them. |
1157 | QPtrList<Todo> todos = calendar()->todos(); | 1089 | QPtrList<Todo> todos = calendar()->todos(); |
1158 | 1090 | ||
1159 | mAgenda->setDateList(mSelectedDates); | 1091 | mAgenda->setDateList(mSelectedDates); |
1160 | 1092 | ||
1161 | QDate today = QDate::currentDate(); | 1093 | QDate today = QDate::currentDate(); |
1162 | 1094 | ||
1163 | DateList::ConstIterator dit; | 1095 | DateList::ConstIterator dit; |
1164 | int curCol = 0; | 1096 | int curCol = 0; |
1165 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1097 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1166 | QDate currentDate = *dit; | 1098 | QDate currentDate = *dit; |
1167 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1099 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1168 | // << endl; | 1100 | // << endl; |
1169 | 1101 | ||
1170 | dayEvents = calendar()->events(currentDate,true); | 1102 | dayEvents = calendar()->events(currentDate,true); |
1171 | 1103 | ||
1172 | // Default values, which can never be reached | 1104 | // Default values, which can never be reached |
1173 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1105 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1174 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1106 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1175 | 1107 | ||
1176 | unsigned int numEvent; | 1108 | unsigned int numEvent; |
1177 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1109 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1178 | Event *event = dayEvents.at(numEvent); | 1110 | Event *event = dayEvents.at(numEvent); |
1179 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1111 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1180 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1112 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1181 | continue; | 1113 | continue; |
1182 | // kdDebug() << " Event: " << event->summary() << endl; | 1114 | // kdDebug() << " Event: " << event->summary() << endl; |
1183 | 1115 | ||
1184 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1116 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1185 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1117 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1186 | 1118 | ||
1187 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1119 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1188 | 1120 | ||
1189 | if (event->doesFloat()) { | 1121 | if (event->doesFloat()) { |
1190 | if (event->recurrence()->doesRecur()) { | 1122 | if (event->recurrence()->doesRecur()) { |
1191 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1123 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1192 | } else { | 1124 | } else { |
1193 | if (beginX <= 0 && curCol == 0) { | 1125 | if (beginX <= 0 && curCol == 0) { |
1194 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1126 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1195 | } else if (beginX == curCol) { | 1127 | } else if (beginX == curCol) { |
1196 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1128 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1197 | } | 1129 | } |
1198 | } | 1130 | } |
1199 | } else if (event->isMultiDay()) { | 1131 | } else if (event->isMultiDay()) { |
1200 | if ( event->doesRecur () ) { | 1132 | if ( event->doesRecur () ) { |
1201 | QDate dateit = currentDate; | 1133 | QDate dateit = currentDate; |
1202 | int count = 0; | 1134 | int count = 0; |
1203 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1135 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1204 | while (! event->recursOn( dateit ) && count <= max ) { | 1136 | while (! event->recursOn( dateit ) && count <= max ) { |
1205 | ++count; | 1137 | ++count; |
1206 | dateit = dateit.addDays( -1 ); | 1138 | dateit = dateit.addDays( -1 ); |
1207 | } | 1139 | } |
1208 | bool ok; | 1140 | bool ok; |
1209 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1141 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1210 | if ( ok ) | 1142 | if ( ok ) |
1211 | { | 1143 | { |
1212 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1144 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1213 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1145 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1214 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1146 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1215 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1147 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1216 | 1148 | ||
1217 | } | 1149 | } |
1218 | } | 1150 | } |
1219 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1151 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1220 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1152 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1221 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1153 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1222 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1154 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1223 | //qDebug("insert!!! "); | 1155 | //qDebug("insert!!! "); |
1224 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1156 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1225 | } | 1157 | } |
1226 | if (beginX == curCol) { | 1158 | if (beginX == curCol) { |
1227 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1159 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1228 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1160 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1229 | } else if (endX == curCol) { | 1161 | } else if (endX == curCol) { |
1230 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1162 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1231 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1163 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1232 | } else { | 1164 | } else { |
1233 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1165 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1234 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1166 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1235 | } | 1167 | } |
1236 | } else { | 1168 | } else { |
1237 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1169 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1238 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1170 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1239 | if (endY < startY) endY = startY; | 1171 | if (endY < startY) endY = startY; |
1240 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1172 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1241 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1173 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1242 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1174 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1243 | } | 1175 | } |
1244 | } | 1176 | } |
1245 | // ---------- [display Todos -------------- | 1177 | // ---------- [display Todos -------------- |
1246 | unsigned int numTodo; | 1178 | unsigned int numTodo; |
1247 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1179 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1248 | Todo *todo = todos.at(numTodo); | 1180 | Todo *todo = todos.at(numTodo); |
1249 | 1181 | ||
1250 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1182 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1251 | 1183 | ||
1252 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1184 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1253 | // Already completed items can be displayed on their original due date | 1185 | // Already completed items can be displayed on their original due date |
1254 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1186 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1255 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1187 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1256 | bool fillIn = false; | 1188 | bool fillIn = false; |
1257 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1189 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1258 | fillIn = true; | 1190 | fillIn = true; |
1259 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1191 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1260 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1192 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1261 | if ( fillIn ) { | 1193 | if ( fillIn ) { |
1262 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1194 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1263 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1195 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1264 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1196 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1265 | } | 1197 | } |
1266 | else { | 1198 | else { |
1267 | QDateTime dt; | 1199 | QDateTime dt; |
1268 | if ( todo->hasCompletedDate() ) | 1200 | if ( todo->hasCompletedDate() ) |
1269 | dt = todo->completed(); | 1201 | dt = todo->completed(); |
1270 | else | 1202 | else |
1271 | dt = todo->dtDue();; | 1203 | dt = todo->dtDue();; |
1272 | 1204 | ||
1273 | 1205 | ||
1274 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1206 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1275 | int hi = (18/KOPrefs::instance()->mHourSize); | 1207 | int hi = (18/KOPrefs::instance()->mHourSize); |
1276 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1208 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1277 | int startY = endY -hi; | 1209 | int startY = endY -hi; |
1278 | 1210 | ||
1279 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1211 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1280 | 1212 | ||
1281 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1213 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1282 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1214 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1283 | } | 1215 | } |
1284 | } | 1216 | } |
1285 | } | 1217 | } |
1286 | // ---------- display Todos] -------------- | 1218 | // ---------- display Todos] -------------- |
1287 | 1219 | ||
1288 | ++curCol; | 1220 | ++curCol; |
1289 | } | 1221 | } |
1290 | mAgenda->hideUnused(); | 1222 | mAgenda->hideUnused(); |
1291 | mAllDayAgenda->hideUnused(); | 1223 | mAllDayAgenda->hideUnused(); |
1292 | mAgenda->checkScrollBoundaries(); | 1224 | mAgenda->checkScrollBoundaries(); |
1293 | 1225 | ||
1294 | deleteSelectedDateTime(); | 1226 | deleteSelectedDateTime(); |
1295 | 1227 | ||
1296 | createDayLabels(); | 1228 | createDayLabels(); |
1297 | emit incidenceSelected( 0 ); | 1229 | emit incidenceSelected( 0 ); |
1298 | 1230 | ||
1299 | if ( globalFlagBlockAgenda == 2 ) { | 1231 | if ( globalFlagBlockAgenda == 2 ) { |
1300 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1232 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1301 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1233 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1302 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1234 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1303 | setStartHour( QTime::currentTime ().hour() ); | 1235 | setStartHour( QTime::currentTime ().hour() ); |
1304 | // qApp->processEvents(); | 1236 | // qApp->processEvents(); |
1305 | } | 1237 | } |
1306 | qApp->processEvents(); | 1238 | qApp->processEvents(); |
1307 | //qDebug("qApp->processEvents(); END "); | 1239 | //qDebug("qApp->processEvents(); END "); |
1308 | globalFlagBlockAgenda = 0; | 1240 | globalFlagBlockAgenda = 0; |
1309 | 1241 | ||
1310 | // mAgenda->hideUnused(); | 1242 | // mAgenda->hideUnused(); |
1311 | //mAllDayAgenda->hideUnused(); | 1243 | //mAllDayAgenda->hideUnused(); |
1312 | mAllDayAgenda->drawContentsToPainter(); | 1244 | mAllDayAgenda->drawContentsToPainter(); |
1313 | mAgenda->drawContentsToPainter(); | 1245 | mAgenda->drawContentsToPainter(); |
1314 | repaintAgenda(); | 1246 | repaintAgenda(); |
1315 | // mAgenda->finishUpdate(); | 1247 | // mAgenda->finishUpdate(); |
1316 | //mAllDayAgenda->finishUpdate(); | 1248 | //mAllDayAgenda->finishUpdate(); |
1317 | 1249 | ||
1318 | // repaintAgenda(); | 1250 | // repaintAgenda(); |
1319 | //qApp->processEvents(); | 1251 | //qApp->processEvents(); |
1320 | // globalFlagBlockAgenda = 0; | 1252 | // globalFlagBlockAgenda = 0; |
1321 | } | 1253 | } |
1322 | void KOAgendaView::repaintAgenda() | 1254 | void KOAgendaView::repaintAgenda() |
1323 | { | 1255 | { |
1324 | // mAllDayAgenda->drawContentsToPainter(); | 1256 | // mAllDayAgenda->drawContentsToPainter(); |
1325 | // mAllDayAgenda->viewport()->repaint( false ); | 1257 | // mAllDayAgenda->viewport()->repaint( false ); |
1326 | // mAgenda->drawContentsToPainter(); | 1258 | // mAgenda->drawContentsToPainter(); |
1327 | // mAgenda->viewport()->repaint( false ); | 1259 | // mAgenda->viewport()->repaint( false ); |
1328 | // qApp->processEvents(); | 1260 | // qApp->processEvents(); |