author | zautrix <zautrix> | 2005-03-26 11:03:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-26 11:03:22 (UTC) |
commit | ef825f1805452ba2cfb30cd7a41c392d3961f01e (patch) (unidiff) | |
tree | 60e896e2867bf3d90f0719f72c50add28bcf1d04 /korganizer/koagenda.cpp | |
parent | 6427570041c902840fe0f557415a07bb7aa8c031 (diff) | |
download | kdepimpi-ef825f1805452ba2cfb30cd7a41c392d3961f01e.zip kdepimpi-ef825f1805452ba2cfb30cd7a41c392d3961f01e.tar.gz kdepimpi-ef825f1805452ba2cfb30cd7a41c392d3961f01e.tar.bz2 |
next rry
-rw-r--r-- | korganizer/koagenda.cpp | 191 |
1 files changed, 188 insertions, 3 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 66ad4ec..14f52b8 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -69,9 +69,8 @@ MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | |||
69 | setBackgroundColor(Qt::red); | 69 | setBackgroundColor(Qt::red); |
70 | minutes = new QTimer(this); | 70 | minutes = new QTimer(this); |
71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
72 | minutes->start(0, true); | 72 | minutes->start(0, true); |
73 | |||
74 | mTimeBox = new QLabel(this); | 73 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 75 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 76 | pal.setColor(QColorGroup::Foreground, Qt::red); |
@@ -174,9 +173,9 @@ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | |||
174 | mRows = rows; | 173 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 174 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 175 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 176 | #ifndef DESKTOP_VERSION |
178 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 177 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 178 | #endif |
180 | mHolidayMask = 0; | 179 | mHolidayMask = 0; |
181 | init(); | 180 | init(); |
182 | } | 181 | } |
@@ -194,9 +193,9 @@ KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | |||
194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 193 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 194 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
196 | mAllDayMode = true; | 195 | mAllDayMode = true; |
197 | #ifndef DESKTOP_VERSION | 196 | #ifndef DESKTOP_VERSION |
198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 197 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
199 | #endif | 198 | #endif |
200 | mHolidayMask = 0; | 199 | mHolidayMask = 0; |
201 | init(); | 200 | init(); |
202 | } | 201 | } |
@@ -221,8 +220,11 @@ QDate KOAgenda::selectedIncidenceDate() const | |||
221 | 220 | ||
222 | 221 | ||
223 | void KOAgenda::init() | 222 | void KOAgenda::init() |
224 | { | 223 | { |
224 | mPopupTimer = new QTimer(this); | ||
225 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | ||
226 | |||
225 | mNewItemPopup = new QPopupMenu( this ); | 227 | mNewItemPopup = new QPopupMenu( this ); |
226 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 228 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
227 | QString pathString = ""; | 229 | QString pathString = ""; |
228 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 230 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
@@ -311,8 +313,10 @@ void KOAgenda::init() | |||
311 | else { | 313 | else { |
312 | mMarcusBains = new MarcusBains(this); | 314 | mMarcusBains = new MarcusBains(this); |
313 | addChild(mMarcusBains); | 315 | addChild(mMarcusBains); |
314 | } | 316 | } |
317 | mPopupKind = 0; | ||
318 | mPopupItem = 0; | ||
315 | } | 319 | } |
316 | 320 | ||
317 | void KOAgenda::clear() | 321 | void KOAgenda::clear() |
318 | { | 322 | { |
@@ -381,9 +385,32 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | |||
381 | default: | 385 | default: |
382 | return QScrollView::eventFilter(object,event); | 386 | return QScrollView::eventFilter(object,event); |
383 | } | 387 | } |
384 | } | 388 | } |
389 | void KOAgenda::popupMenu() | ||
390 | { | ||
391 | mPopupTimer->stop(); | ||
392 | if ( mPopupKind == 1 ) { | ||
393 | if (mActionItem ) { | ||
394 | endItemAction(); | ||
395 | } | ||
396 | mLeftMouseDown = false; // no more leftMouse computation | ||
397 | if (mPopupItem) { | ||
398 | selectItem(mPopupItem); | ||
399 | emit showIncidencePopupSignal(mPopupItem->incidence()); | ||
385 | 400 | ||
401 | } | ||
402 | } else if ( mPopupKind == 2 ) { | ||
403 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | ||
404 | endSelectAction( false ); // do not emit new event signal | ||
405 | mLeftMouseDown = false; // no more leftMouse computation | ||
406 | } | ||
407 | mNewItemPopup->popup( mPopupPos); | ||
408 | } | ||
409 | mLeftMouseDown = false; | ||
410 | mPopupItem = 0; | ||
411 | mPopupKind = 0; | ||
412 | } | ||
386 | 413 | ||
387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 414 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
388 | { | 415 | { |
389 | //qDebug("KOAgenda::eventFilter_mous "); | 416 | //qDebug("KOAgenda::eventFilter_mous "); |
@@ -396,8 +423,165 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | |||
396 | static int startX = 0; | 423 | static int startX = 0; |
397 | static int startY = 0; | 424 | static int startY = 0; |
398 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 425 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); |
399 | static bool blockMoving = true; | 426 | static bool blockMoving = true; |
427 | switch (me->type()) { | ||
428 | case QEvent::MouseButtonPress: | ||
429 | if (me->button() == LeftButton) { | ||
430 | mPopupTimer->start( 600 ); | ||
431 | mLeftMouseDown = true; | ||
432 | } | ||
433 | blockMoving = true; | ||
434 | startX = viewportPos.x(); | ||
435 | startY = viewportPos.y(); | ||
436 | if (object != viewport()) { | ||
437 | mPopupItem = (KOAgendaItem *)object; | ||
438 | mPopupKind = 1; | ||
439 | if (me->button() == RightButton) { | ||
440 | popupMenu(); | ||
441 | } else if (me->button() == LeftButton) { | ||
442 | mActionItem = (KOAgendaItem *)object; | ||
443 | if (mActionItem) { | ||
444 | if ( mSelectionHeight > 0 ) { | ||
445 | int selectionCellX = mSelectionCellX * mGridSpacingX; | ||
446 | int selectionYTop = mSelectionYTop; | ||
447 | int gridSpacingX = mGridSpacingX; | ||
448 | int selectionHeight = mSelectionHeight; | ||
449 | clearSelection(); | ||
450 | repaintContents( selectionCellX, selectionYTop, | ||
451 | gridSpacingX, selectionHeight,false ); | ||
452 | } | ||
453 | selectItem(mActionItem); | ||
454 | Incidence *incidence = mActionItem->incidence(); | ||
455 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | ||
456 | mActionItem = 0; | ||
457 | } else { | ||
458 | startItemAction(viewportPos); | ||
459 | } | ||
460 | } | ||
461 | } | ||
462 | } else { // ---------- viewport() | ||
463 | mPopupItem = 0; | ||
464 | mPopupKind = 2; | ||
465 | selectItem(0); | ||
466 | mActionItem = 0; | ||
467 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | ||
468 | if (me->button() == RightButton) { | ||
469 | popupMenu(); | ||
470 | } else if (me->button() == LeftButton) { | ||
471 | setCursor(arrowCursor); | ||
472 | startSelectAction(viewportPos); | ||
473 | } | ||
474 | } | ||
475 | break; | ||
476 | |||
477 | case QEvent::MouseButtonRelease: | ||
478 | if (me->button() == LeftButton ) { | ||
479 | mPopupTimer->stop(); | ||
480 | } | ||
481 | if (object != viewport()) { | ||
482 | if (me->button() == LeftButton && mLeftMouseDown) { | ||
483 | if (mActionItem) { | ||
484 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | ||
485 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | ||
486 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | ||
487 | mScrollUpTimer.stop(); | ||
488 | mScrollDownTimer.stop(); | ||
489 | mActionItem->resetMove(); | ||
490 | placeSubCells( mActionItem ); | ||
491 | // emit startDragSignal( mActionItem->incidence() ); | ||
492 | setCursor( arrowCursor ); | ||
493 | mActionItem = 0; | ||
494 | mActionType = NOP; | ||
495 | mItemMoved = 0; | ||
496 | mLeftMouseDown = false; | ||
497 | return true; | ||
498 | } | ||
499 | endItemAction(); | ||
500 | } | ||
501 | } | ||
502 | |||
503 | } else { // ---------- viewport() | ||
504 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | ||
505 | endSelectAction( true ); // emit new event signal | ||
506 | } | ||
507 | } | ||
508 | if (me->button() == LeftButton) | ||
509 | mLeftMouseDown = false; | ||
510 | |||
511 | break; | ||
512 | |||
513 | case QEvent::MouseMove: | ||
514 | if ( !mLeftMouseDown ) | ||
515 | return true; | ||
516 | if ( blockMoving ) { | ||
517 | int dX, dY; | ||
518 | dX = startX - viewportPos.x(); | ||
519 | if ( dX < 0 ) | ||
520 | dX = -dX; | ||
521 | dY = viewportPos.y() - startY; | ||
522 | if ( dY < 0 ) | ||
523 | dY = -dY; | ||
524 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | ||
525 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | ||
526 | blockMoving = false; | ||
527 | } | ||
528 | } | ||
529 | if ( ! blockMoving ) | ||
530 | mPopupTimer->stop(); | ||
531 | if (object != viewport()) { | ||
532 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | ||
533 | if (!moveItem->incidence()->isReadOnly() ) { | ||
534 | if (!mActionItem) | ||
535 | setNoActionCursor(moveItem,viewportPos); | ||
536 | else { | ||
537 | if ( !blockMoving ) | ||
538 | performItemAction(viewportPos); | ||
539 | } | ||
540 | } | ||
541 | } else { // ---------- viewport() | ||
542 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | ||
543 | if ( mActionType == SELECT ) { | ||
544 | performSelectAction( viewportPos ); | ||
545 | } | ||
546 | } | ||
547 | break; | ||
548 | |||
549 | case QEvent::MouseButtonDblClick: | ||
550 | mPopupTimer->stop(); | ||
551 | if (object == viewport()) { | ||
552 | selectItem(0); | ||
553 | int x,y; | ||
554 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | ||
555 | int gx,gy; | ||
556 | contentsToGrid(x,y,gx,gy); | ||
557 | emit newEventSignal(gx,gy); | ||
558 | } else { | ||
559 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | ||
560 | selectItem(doubleClickedItem); | ||
561 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | ||
562 | emit editIncidenceSignal(doubleClickedItem->incidence()); | ||
563 | else | ||
564 | emit showIncidenceSignal(doubleClickedItem->incidence()); | ||
565 | } | ||
566 | break; | ||
567 | |||
568 | default: | ||
569 | break; | ||
570 | } | ||
571 | return true; | ||
572 | #if 0 | ||
573 | //qDebug("KOAgenda::eventFilter_mous "); | ||
574 | QPoint viewportPos; | ||
575 | if (object != viewport()) { | ||
576 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | ||
577 | } else { | ||
578 | viewportPos = me->pos(); | ||
579 | } | ||
580 | static int startX = 0; | ||
581 | static int startY = 0; | ||
582 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | ||
583 | static bool blockMoving = true; | ||
400 | static bool leftMouseDown = false; | 584 | static bool leftMouseDown = false; |
401 | bool rightButtonPressed = false; | 585 | bool rightButtonPressed = false; |
402 | switch (me->type()) { | 586 | switch (me->type()) { |
403 | case QEvent::MouseButtonPress: | 587 | case QEvent::MouseButtonPress: |
@@ -558,8 +742,9 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | |||
558 | default: | 742 | default: |
559 | break; | 743 | break; |
560 | } | 744 | } |
561 | return true; | 745 | return true; |
746 | #endif | ||
562 | } | 747 | } |
563 | 748 | ||
564 | void KOAgenda::newItem( int item ) | 749 | void KOAgenda::newItem( int item ) |
565 | { | 750 | { |