summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
Unidiff
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 8c2996b..dcb46a8 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -154,49 +154,49 @@ void MarcusBains::updateLocation(bool recalculate)
154 154
155 mTimeBox->raise(); 155 mTimeBox->raise();
156 //mTimeBox->setAutoMask(true); 156 //mTimeBox->setAutoMask(true);
157 minutes->start(5000,true); 157 minutes->start(5000,true);
158} 158}
159 159
160 160
161//////////////////////////////////////////////////////////////////////////// 161////////////////////////////////////////////////////////////////////////////
162 162
163 163
164/* 164/*
165 Create an agenda widget with rows rows and columns columns. 165 Create an agenda widget with rows rows and columns columns.
166*/ 166*/
167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
168 const char *name,WFlags f) : 168 const char *name,WFlags f) :
169 QScrollView(parent,name,f) 169 QScrollView(parent,name,f)
170{ 170{
171 171
172 172
173 mColumns = columns; 173 mColumns = columns;
174 mRows = rows; 174 mRows = rows;
175 mGridSpacingY = rowSize; 175 mGridSpacingY = rowSize;
176 mAllDayMode = false; 176 mAllDayMode = false;
177#ifndef DESKTOP_VERSION 177#ifndef DESKTOP_VERSION
178 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 178 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
179#endif 179#endif
180 mHolidayMask = 0; 180 mHolidayMask = 0;
181 init(); 181 init();
182} 182}
183 183
184/* 184/*
185 Create an agenda widget with columns columns and one row. This is used for 185 Create an agenda widget with columns columns and one row. This is used for
186 all-day events. 186 all-day events.
187*/ 187*/
188KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 188KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
189 QScrollView(parent,name,f) 189 QScrollView(parent,name,f)
190{ 190{
191 blockResize = false; 191 blockResize = false;
192 mColumns = columns; 192 mColumns = columns;
193 mRows = 1; 193 mRows = 1;
194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
195 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 195 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
196 mAllDayMode = true; 196 mAllDayMode = true;
197#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
198 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 198 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 199#endif
200 mHolidayMask = 0; 200 mHolidayMask = 0;
201 init(); 201 init();
202} 202}
@@ -378,130 +378,137 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
378 setCursor(arrowCursor); 378 setCursor(arrowCursor);
379 return true; 379 return true;
380 380
381 default: 381 default:
382 return QScrollView::eventFilter(object,event); 382 return QScrollView::eventFilter(object,event);
383 } 383 }
384} 384}
385 385
386 386
387bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 387bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
388{ 388{
389 //qDebug("KOAgenda::eventFilter_mous "); 389 //qDebug("KOAgenda::eventFilter_mous ");
390 QPoint viewportPos; 390 QPoint viewportPos;
391 if (object != viewport()) { 391 if (object != viewport()) {
392 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 392 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
393 } else { 393 } else {
394 viewportPos = me->pos(); 394 viewportPos = me->pos();
395 } 395 }
396 static int startX = 0; 396 static int startX = 0;
397 static int startY = 0; 397 static int startY = 0;
398 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 398 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
399 static bool blockMoving = true; 399 static bool blockMoving = true;
400 static bool leftMouseDown = false; 400 static bool leftMouseDown = false;
401 static bool rightMouseDown = false; 401 static bool rightMouseDown = false;
402 static QTime rightClickTime;
403 bool rightButtonPressed = false;
402 switch (me->type()) { 404 switch (me->type()) {
403 case QEvent::MouseButtonPress: 405 case QEvent::MouseButtonPress:
404 if (me->button() == LeftButton) 406 rightClickTime.restart();
407 if (me->button() == LeftButton) {
405 leftMouseDown = true; 408 leftMouseDown = true;
409 }
406 else if (me->button() == RightButton) 410 else if (me->button() == RightButton)
407 rightMouseDown = true; 411 rightMouseDown = true;
408 blockMoving = true; 412 blockMoving = true;
409 startX = viewportPos.x(); 413 startX = viewportPos.x();
410 startY = viewportPos.y(); 414 startY = viewportPos.y();
411 if (object != viewport()) { 415 if (object != viewport()) {
412 if (me->button() == RightButton) { 416 if (me->button() == RightButton) {
413 mClickedItem = (KOAgendaItem *)object; 417 mClickedItem = (KOAgendaItem *)object;
414 if (mClickedItem) { 418 if (mClickedItem) {
415 selectItem(mClickedItem); 419 selectItem(mClickedItem);
416 } 420 }
417 } else if (me->button() == LeftButton) { 421 } else if (me->button() == LeftButton) {
418 mActionItem = (KOAgendaItem *)object; 422 mActionItem = (KOAgendaItem *)object;
419 if (mActionItem) { 423 if (mActionItem) {
420 if ( mSelectionHeight > 0 ) { 424 if ( mSelectionHeight > 0 ) {
421 int selectionCellX = mSelectionCellX * mGridSpacingX; 425 int selectionCellX = mSelectionCellX * mGridSpacingX;
422 int selectionYTop = mSelectionYTop; 426 int selectionYTop = mSelectionYTop;
423 int gridSpacingX = mGridSpacingX; 427 int gridSpacingX = mGridSpacingX;
424 int selectionHeight = mSelectionHeight; 428 int selectionHeight = mSelectionHeight;
425 clearSelection(); 429 clearSelection();
426 repaintContents( selectionCellX, selectionYTop, 430 repaintContents( selectionCellX, selectionYTop,
427 gridSpacingX, selectionHeight,false ); 431 gridSpacingX, selectionHeight,false );
428 } 432 }
429 selectItem(mActionItem); 433 selectItem(mActionItem);
430 Incidence *incidence = mActionItem->incidence(); 434 Incidence *incidence = mActionItem->incidence();
431 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 435 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
432 mActionItem = 0; 436 mActionItem = 0;
433 } else { 437 } else {
434 startItemAction(viewportPos); 438 startItemAction(viewportPos);
435 } 439 }
436 } 440 }
437 } 441 }
438 } else { // ---------- viewport() 442 } else { // ---------- viewport()
439 selectItem(0); 443 selectItem(0);
440 mActionItem = 0; 444 mActionItem = 0;
441 if (me->button() == LeftButton ) { 445 if (me->button() == LeftButton ) {
442 setCursor(arrowCursor); 446 setCursor(arrowCursor);
443 startSelectAction(viewportPos); 447 startSelectAction(viewportPos);
444 } 448 }
445 } 449 }
446 break; 450 break;
447 451
448 case QEvent::MouseButtonRelease: 452 case QEvent::MouseButtonRelease:
453 if ( rightClickTime.elapsed() > 700 && blockMoving )
454 rightButtonPressed = true;
449 if (object != viewport()) { 455 if (object != viewport()) {
450 if (me->button() == RightButton) { 456 if (me->button() == RightButton || rightButtonPressed ) {
451 if ( blockMoving ) { 457 if ( blockMoving ) {
452 mClickedItem = (KOAgendaItem *)object; 458 mClickedItem = (KOAgendaItem *)object;
453 if (mActionItem ) { 459 if (mActionItem ) {
454 endItemAction(); 460 endItemAction();
455 } 461 }
456 leftMouseDown = false; // no more leftMouse computation 462 leftMouseDown = false; // no more leftMouse computation
457 if (mClickedItem) { 463 if (mClickedItem) {
458 selectItem(mClickedItem); 464 selectItem(mClickedItem);
459 emit showIncidencePopupSignal(mClickedItem->incidence()); 465 emit showIncidencePopupSignal(mClickedItem->incidence());
460 } 466 }
461 } 467 }
462 } else if (me->button() == LeftButton && leftMouseDown) { 468 } else if (me->button() == LeftButton && leftMouseDown) {
463 if (mActionItem) { 469 if (mActionItem) {
464 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 470 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
465 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 471 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
466 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 472 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
467 mScrollUpTimer.stop(); 473 mScrollUpTimer.stop();
468 mScrollDownTimer.stop(); 474 mScrollDownTimer.stop();
469 mActionItem->resetMove(); 475 mActionItem->resetMove();
470 placeSubCells( mActionItem ); 476 placeSubCells( mActionItem );
471 // emit startDragSignal( mActionItem->incidence() ); 477 // emit startDragSignal( mActionItem->incidence() );
472 setCursor( arrowCursor ); 478 setCursor( arrowCursor );
473 mActionItem = 0; 479 mActionItem = 0;
474 mActionType = NOP; 480 mActionType = NOP;
475 mItemMoved = 0; 481 mItemMoved = 0;
482 leftMouseDown = false;
476 return true; 483 return true;
477 } 484 }
478 endItemAction(); 485 endItemAction();
479 } 486 }
480 } 487 }
481 488
482 } else { // ---------- viewport() 489 } else { // ---------- viewport()
483 if (me->button() == RightButton) { //right click 490 if (me->button() == RightButton || rightButtonPressed ) { //right click
484 if ( blockMoving ) { // we did mot moved the mouse much - popup menu 491 if ( blockMoving ) { // we did mot moved the mouse much - popup menu
485 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action 492 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
486 endSelectAction( false ); // do not emit new event signal 493 endSelectAction( false ); // do not emit new event signal
487 leftMouseDown = false; // no more leftMouse computation 494 leftMouseDown = false; // no more leftMouse computation
488 } 495 }
489 int x,y; 496 int x,y;
490 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 497 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
491 int gx,gy; 498 int gx,gy;
492 contentsToGrid(x,y,gx,gy); 499 contentsToGrid(x,y,gx,gy);
493 mCurrentCellX = gx; 500 mCurrentCellX = gx;
494 mCurrentCellY = gy; 501 mCurrentCellY = gy;
495 mStartCellX = gx; 502 mStartCellX = gx;
496 mStartCellY = gy; 503 mStartCellY = gy;
497 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); 504 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
498 } 505 }
499 } 506 }
500 else if (me->button() == LeftButton && leftMouseDown ) { //left click 507 else if (me->button() == LeftButton && leftMouseDown ) { //left click
501 endSelectAction( true ); // emit new event signal 508 endSelectAction( true ); // emit new event signal
502 } 509 }
503 } 510 }
504 if (me->button() == LeftButton) 511 if (me->button() == LeftButton)
505 leftMouseDown = false; 512 leftMouseDown = false;
506 else if (me->button() == RightButton) 513 else if (me->button() == RightButton)
507 rightMouseDown = false; 514 rightMouseDown = false;