equal
deleted
inserted
replaced
58 mClearingSelection(false), |
58 mClearingSelection(false), |
59 mAnimateItems(false), |
59 mAnimateItems(false), |
60 mPostponedScrollHint(HbAbstractItemView::PositionAtTop), |
60 mPostponedScrollHint(HbAbstractItemView::PositionAtTop), |
61 mPreviousSelectedCommand(QItemSelectionModel::NoUpdate), |
61 mPreviousSelectedCommand(QItemSelectionModel::NoUpdate), |
62 mAnimationTimer(0), |
62 mAnimationTimer(0), |
63 mModelIterator(0), |
63 mModelIterator(0), |
64 mEnabledAnimations(HbAbstractItemView::All), |
64 mEnabledAnimations(HbAbstractItemView::All), |
65 mLongPressEnabled(true), |
65 mLongPressEnabled(true), |
66 mDoingContiguousSelection(false) |
66 mDoingContiguousSelection(false) |
67 { |
67 { |
68 } |
68 } |
69 |
69 |
70 HbAbstractItemViewPrivate::~HbAbstractItemViewPrivate() |
70 HbAbstractItemViewPrivate::~HbAbstractItemViewPrivate() |
71 { |
71 { |
347 } |
347 } |
348 |
348 |
349 bool HbAbstractItemViewPrivate::panTriggered(QGestureEvent *event) |
349 bool HbAbstractItemViewPrivate::panTriggered(QGestureEvent *event) |
350 { |
350 { |
351 Q_Q(HbAbstractItemView); |
351 Q_Q(HbAbstractItemView); |
352 |
352 int retVal = false; |
353 HbPanGesture *gesture = static_cast<HbPanGesture *>(event->gesture(Qt::PanGesture)); |
353 HbPanGesture *gesture = static_cast<HbPanGesture *>(event->gesture(Qt::PanGesture)); |
354 |
354 |
355 switch (gesture->state()) { |
355 switch (gesture->state()) { |
356 case Qt::GestureStarted: |
356 case Qt::GestureStarted: |
357 mOptions |= PanningActive; |
357 mOptions |= PanningActive; |
358 // Fallthrough |
358 // Fallthrough |
359 case Qt::GestureUpdated: { |
359 case Qt::GestureUpdated: { |
360 QPointF scenePos = event->mapToGraphicsScene(gesture->hotSpot()); |
360 QPointF scenePos = event->mapToGraphicsScene(gesture->hotSpot()); |
361 if (mDoingContiguousSelection) { |
361 if (mDoingContiguousSelection) { |
362 int retVal = false; |
|
363 |
362 |
364 // loop through the items in the scene |
363 // loop through the items in the scene |
365 qreal scenePosY = scenePos.y(); |
364 qreal scenePosY = scenePos.y(); |
366 QPointF lastScenePos = scenePos + gesture->lastOffset() - gesture->offset(); |
365 QPointF lastScenePos = scenePos + gesture->lastOffset() - gesture->offset(); |
367 qreal lastScenePosY = lastScenePos.y(); |
366 qreal lastScenePosY = lastScenePos.y(); |
378 QPointF position(qBound((qreal)0.0, scenePosInItemCoordinates.x(), item->size().width()), |
377 QPointF position(qBound((qreal)0.0, scenePosInItemCoordinates.x(), item->size().width()), |
379 qBound((qreal)0.0, scenePosInItemCoordinates.y(), item->size().height())); |
378 qBound((qreal)0.0, scenePosInItemCoordinates.y(), item->size().height())); |
380 mouseMoveEvent.setPos(position); |
379 mouseMoveEvent.setPos(position); |
381 QItemSelectionModel::SelectionFlags command = q->selectionCommand(item, &mouseMoveEvent); |
380 QItemSelectionModel::SelectionFlags command = q->selectionCommand(item, &mouseMoveEvent); |
382 |
381 |
383 // in contiguousselectionarea there shall be no panning from HbScrollArea, thus return true |
382 // in contiguousselectionarea there shall be no panning from HbScrollArea, thus return true |
384 if (command != QItemSelectionModel::NoUpdate) { |
383 if (command != QItemSelectionModel::NoUpdate) { |
385 retVal = true; |
384 retVal = true; |
386 } |
385 } |
387 |
386 |
388 if ( itemIndex != mPreviousSelectedIndex |
387 if ( itemIndex != mPreviousSelectedIndex |
425 retVal = true; |
424 retVal = true; |
426 } |
425 } |
427 break; |
426 break; |
428 } |
427 } |
429 } |
428 } |
430 return retVal; |
429 } |
431 } |
430 else { |
432 else if (!mDoingContiguousSelection){ |
|
433 HbWidgetFeedback::continuousTriggered(q, Hb::ContinuousScrolled); |
431 HbWidgetFeedback::continuousTriggered(q, Hb::ContinuousScrolled); |
434 } |
432 } |
435 break; |
433 break; |
436 } |
434 } |
437 case Qt::GestureFinished: |
435 case Qt::GestureFinished: |
438 case Qt::GestureCanceled: { |
436 case Qt::GestureCanceled: { |
439 mOptions &= ~PanningActive; |
437 mOptions &= ~PanningActive; |
440 if (mDoingContiguousSelection) { |
438 if (mDoingContiguousSelection) { |
441 stopAnimating(); |
439 stopAnimating(); |
442 mDoingContiguousSelection = false; |
440 mDoingContiguousSelection = false; |
443 return true; |
441 retVal = true; |
444 } |
442 } |
445 else { |
443 else { |
446 HbWidgetFeedback::continuousStopped(q, Hb::ContinuousScrolled); |
444 HbWidgetFeedback::continuousStopped(q, Hb::ContinuousScrolled); |
447 } |
445 } |
448 break; |
446 break; |
449 } |
447 } |
450 default: |
448 default: |
451 break; |
449 break; |
452 } |
450 } |
453 |
451 return retVal; |
454 return false; |
|
455 } |
452 } |
456 |
453 |
457 /*! |
454 /*! |
458 This slot is called when the view is scrolling doing countinuousselection. It does the item |
455 This slot is called when the view is scrolling doing countinuousselection. It does the item |
459 selection/deselection |
456 selection/deselection |
479 { |
476 { |
480 Q_Q(HbAbstractItemView); |
477 Q_Q(HbAbstractItemView); |
481 |
478 |
482 mFrictionEnabled = mOrigFriction; |
479 mFrictionEnabled = mOrigFriction; |
483 |
480 |
484 QObject::disconnect(q, SIGNAL(scrollPositionChanged(QPointF)), q, SLOT(_q_scrollingI(QPointF))); |
481 QObject::disconnect(q, SIGNAL(scrollPositionChanged(QPointF)), q, SLOT(_q_scrolling(QPointF))); |
485 QObject::disconnect(q, SIGNAL(scrollingEnded()), q, SLOT(_q_scrollingEnded())); |
482 QObject::disconnect(q, SIGNAL(scrollingEnded()), q, SLOT(_q_scrollingEnded())); |
486 QObject::disconnect(q, SIGNAL(scrollingStarted()), q, SLOT(_q_scrollingStarted())); |
483 QObject::disconnect(q, SIGNAL(scrollingStarted()), q, SLOT(_q_scrollingStarted())); |
487 } |
484 } |
488 |
485 |
489 /*! |
486 /*! |
656 switch (event->type()) { |
653 switch (event->type()) { |
657 case QEvent::GraphicsSceneMousePress: |
654 case QEvent::GraphicsSceneMousePress: |
658 case QEvent::GraphicsSceneMouseDoubleClick: { |
655 case QEvent::GraphicsSceneMouseDoubleClick: { |
659 |
656 |
660 // check if the mouse click is in the multiselectionarea |
657 // check if the mouse click is in the multiselectionarea |
661 if (item->selectionAreaContains(static_cast<const QGraphicsSceneMouseEvent *>(event)->pos(), HbAbstractViewItem::MultiSelection)) { |
658 if (item->selectionAreaContains(static_cast<const QGraphicsSceneMouseEvent *>(event)->pos(), HbAbstractViewItem::MultiSelection)) { |
662 mSelectionSettings |= Selection; |
659 mSelectionSettings |= Selection; |
663 if (mSelectionModel && mSelectionModel->isSelected(item->modelIndex())) { |
660 if (mSelectionModel && mSelectionModel->isSelected(item->modelIndex())) { |
664 mContSelectionAction = QItemSelectionModel::Deselect; |
661 mContSelectionAction = QItemSelectionModel::Deselect; |
665 } else { |
662 } else { |
666 mContSelectionAction = QItemSelectionModel::Select; |
663 mContSelectionAction = QItemSelectionModel::Select; |
667 } |
664 } |