40 #include <dialpad.h> |
40 #include <dialpad.h> |
41 #include <hblineedit.h> |
41 #include <hblineedit.h> |
42 #include <hbgroupbox.h> |
42 #include <hbgroupbox.h> |
43 #include <hbmessagebox.h> |
43 #include <hbmessagebox.h> |
44 #include <hbmainwindow.h> |
44 #include <hbmainwindow.h> |
|
45 #include <hbswipegesture.h> |
45 #include <QTimer> |
46 #include <QTimer> |
46 #include <hbactivitymanager.h> |
47 #include <hbactivitymanager.h> |
47 |
48 |
48 Q_DECLARE_METATYPE(LogsMatchesModel*) |
49 Q_DECLARE_METATYPE(LogsMatchesModel*) |
49 |
50 |
50 const int logsMissedCallsMarkingDelayMs = 1000; |
51 const int logsMissedCallsMarkingDelayMs = 1000; |
51 const int logsSwipeAngleDelta = 30; // angle is from 0 to 360 |
|
52 |
52 |
53 // ----------------------------------------------------------------------------- |
53 // ----------------------------------------------------------------------------- |
54 // LogsRecentCallsView::LogsRecentCallsView |
54 // LogsRecentCallsView::LogsRecentCallsView |
55 // ----------------------------------------------------------------------------- |
55 // ----------------------------------------------------------------------------- |
56 // |
56 // |
63 mCurrentView(LogsServices::ViewAll), |
63 mCurrentView(LogsServices::ViewAll), |
64 mAppearingView(LogsServices::ViewAll), |
64 mAppearingView(LogsServices::ViewAll), |
65 mMoveLeftInList(false), |
65 mMoveLeftInList(false), |
66 mEffectHandler(0), |
66 mEffectHandler(0), |
67 mListViewX(0), |
67 mListViewX(0), |
|
68 mEmptyListLabelX(0), |
68 mMatchesModel(0), |
69 mMatchesModel(0), |
69 mMarkingMissedAsSeen(false), |
70 mMarkingMissedAsSeen(false), |
70 mPageIndicator(0), |
71 mPageIndicator(0), |
71 mFirstActivation(true) |
72 mFirstActivation(true), |
|
73 mListScrollBarPolicy(HbScrollArea::ScrollBarAutoHide) |
72 { |
74 { |
73 LOGS_QDEBUG( "logs [UI] <-> LogsRecentCallsView::LogsRecentCallsView()" ); |
75 LOGS_QDEBUG( "logs [UI] <-> LogsRecentCallsView::LogsRecentCallsView()" ); |
74 mModel = mRepository.model(); |
76 mModel = mRepository.model(); |
75 |
77 |
76 //TODO: taking away due to toolbar bug. If toolbar visibility changes on view |
78 //TODO: taking away due to toolbar bug. If toolbar visibility changes on view |
128 |
130 |
129 mPageIndicator->setActiveItemIndex(mConversionMap.value(mCurrentView)); |
131 mPageIndicator->setActiveItemIndex(mConversionMap.value(mCurrentView)); |
130 |
132 |
131 mFirstActivation = false; |
133 mFirstActivation = false; |
132 |
134 |
|
135 if (mEmptyListLabel) { |
|
136 mEmptyListLabelX = mEmptyListLabel->pos().x(); |
|
137 } |
|
138 |
133 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::activated()" ); |
139 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::activated()" ); |
134 } |
140 } |
135 |
141 |
136 // ----------------------------------------------------------------------------- |
142 // ----------------------------------------------------------------------------- |
137 // LogsRecentCallsView::deactivated |
143 // LogsRecentCallsView::deactivated |
211 mEffectHandler = new LogsEffectHandler; |
217 mEffectHandler = new LogsEffectHandler; |
212 connect(mEffectHandler, SIGNAL(dissappearByMovingComplete()), |
218 connect(mEffectHandler, SIGNAL(dissappearByMovingComplete()), |
213 this, SLOT(dissappearByMovingComplete())); |
219 this, SLOT(dissappearByMovingComplete())); |
214 connect(mEffectHandler, SIGNAL(dissappearByFadingComplete()), |
220 connect(mEffectHandler, SIGNAL(dissappearByFadingComplete()), |
215 this, SLOT(dissappearByFadingComplete())); |
221 this, SLOT(dissappearByFadingComplete())); |
216 |
222 connect(mEffectHandler, SIGNAL(appearByMovingComplete()), |
|
223 this, SLOT(appearByMovingComplete())); |
217 mPageIndicator = qobject_cast<LogsPageIndicator*> |
224 mPageIndicator = qobject_cast<LogsPageIndicator*> |
218 (mRepository.findWidget(logsPageIndicatorId)); |
225 (mRepository.findWidget(logsPageIndicatorId)); |
219 |
226 |
220 mPageIndicator->initialize(mTitleMap.count(), mConversionMap.value(mCurrentView)); |
227 mPageIndicator->initialize(mTitleMap.count(), mConversionMap.value(mCurrentView)); |
221 |
228 |
438 mListView->setFrictionEnabled(true); |
445 mListView->setFrictionEnabled(true); |
439 |
446 |
440 mListViewX = mListView->pos().x(); |
447 mListViewX = mListView->pos().x(); |
441 |
448 |
442 grabGesture(Qt::SwipeGesture); |
449 grabGesture(Qt::SwipeGesture); |
|
450 |
|
451 mListScrollBarPolicy = mListView->verticalScrollBarPolicy(); |
443 |
452 |
444 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::initListWidget() " ); |
453 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::initListWidget() " ); |
445 } |
454 } |
446 |
455 |
447 // ----------------------------------------------------------------------------- |
456 // ----------------------------------------------------------------------------- |
534 // |
543 // |
535 void LogsRecentCallsView::gestureEvent(QGestureEvent *event) |
544 void LogsRecentCallsView::gestureEvent(QGestureEvent *event) |
536 { |
545 { |
537 QGesture* gesture = event->gesture(Qt::SwipeGesture); |
546 QGesture* gesture = event->gesture(Qt::SwipeGesture); |
538 if (gesture) { |
547 if (gesture) { |
539 QSwipeGesture* swipe = static_cast<QSwipeGesture *>(gesture); |
548 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::gestureEvent()" ); |
540 if (swipe->state() == Qt::GestureFinished) { |
549 HbSwipeGesture* swipe = static_cast<HbSwipeGesture *>(gesture); |
541 QSwipeGesture::SwipeDirection direction = swipeAngleToDirection( |
550 if (swipe && swipe->state() == Qt::GestureFinished) { |
542 swipe->swipeAngle(), logsSwipeAngleDelta); |
551 LOGS_QDEBUG_2( "logs [UI] sceneSwipeAngle: ", swipe->sceneSwipeAngle() ); |
543 if (mViewManager.mainWindow().orientation() == Qt::Vertical) { |
552 LOGS_QDEBUG_2( "logs [UI] swipeAngle: ", swipe->swipeAngle() ); |
544 if (direction == QSwipeGesture::Left) { |
553 |
545 leftFlick(); |
554 QSwipeGesture::SwipeDirection direction = swipe->sceneHorizontalDirection(); |
546 event->accept(Qt::SwipeGesture); |
555 if (direction == QSwipeGesture::Left) { |
547 } else if (direction == QSwipeGesture::Right) { |
556 leftFlick(); |
548 rightFlick(); |
557 event->accept(Qt::SwipeGesture); |
549 event->accept(Qt::SwipeGesture); |
558 } else if (direction == QSwipeGesture::Right) { |
550 } |
559 rightFlick(); |
551 } else { |
560 event->accept(Qt::SwipeGesture); |
552 if (direction == QSwipeGesture::Down) { |
|
553 rightFlick(); |
|
554 event->accept(Qt::SwipeGesture); |
|
555 } else if (direction == QSwipeGesture::Up) { |
|
556 leftFlick(); |
|
557 event->accept(Qt::SwipeGesture); |
|
558 } |
|
559 } |
561 } |
560 } |
562 } |
561 } |
563 } |
562 } |
|
563 |
|
564 // ----------------------------------------------------------------------------- |
|
565 // LogsRecentCallsView::swipeAngleToDirection |
|
566 // ----------------------------------------------------------------------------- |
|
567 // |
|
568 QSwipeGesture::SwipeDirection LogsRecentCallsView::swipeAngleToDirection( |
|
569 int angle, int delta) |
|
570 { |
|
571 QSwipeGesture::SwipeDirection direction(QSwipeGesture::NoDirection); |
|
572 if ((angle > 90-delta) && (angle < 90+delta)) { |
|
573 direction = QSwipeGesture::Up; |
|
574 } else if ((angle > 270-delta) && (angle < 270+delta)) { |
|
575 direction = QSwipeGesture::Down; |
|
576 } else if (((angle >= 0) && (angle < delta)) |
|
577 || ((angle > 360-delta) && (angle <= 360))) { |
|
578 direction = QSwipeGesture::Right; |
|
579 } else if ((angle > 180-delta) && (angle < 180+delta)) { |
|
580 direction = QSwipeGesture::Left; |
|
581 } |
|
582 LOGS_QDEBUG_4( "logs [UI] LogsRecentCallsView::swipeAngleToDirection() angle: ", |
|
583 angle, " direction: ", direction ); |
|
584 return direction; |
|
585 } |
564 } |
586 |
565 |
587 // ----------------------------------------------------------------------------- |
566 // ----------------------------------------------------------------------------- |
588 // LogsRecentCallsView::leftFlick |
567 // LogsRecentCallsView::leftFlick |
589 // ----------------------------------------------------------------------------- |
568 // ----------------------------------------------------------------------------- |
597 changeView( mConversionMap.key(viewmap) ); |
576 changeView( mConversionMap.key(viewmap) ); |
598 } else { |
577 } else { |
599 if (model() && model()->rowCount() > 0) { |
578 if (model() && model()->rowCount() > 0) { |
600 mEffectHandler->startMoveNotPossibleEffect(*mListView, false, mListViewX); |
579 mEffectHandler->startMoveNotPossibleEffect(*mListView, false, mListViewX); |
601 } else { |
580 } else { |
602 mEffectHandler->startMoveNotPossibleEffect(*mEmptyListLabel, false, mListViewX); |
581 mEffectHandler->startMoveNotPossibleEffect(*mEmptyListLabel, |
|
582 false, mEmptyListLabelX); |
603 } |
583 } |
604 } |
584 } |
605 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::leftFlick()" ); |
585 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::leftFlick()" ); |
606 } |
586 } |
607 |
587 |
618 changeView( mConversionMap.key(viewmap) ); |
598 changeView( mConversionMap.key(viewmap) ); |
619 } else { |
599 } else { |
620 if (model() && model()->rowCount() > 0) { |
600 if (model() && model()->rowCount() > 0) { |
621 mEffectHandler->startMoveNotPossibleEffect(*mListView, true, mListViewX); |
601 mEffectHandler->startMoveNotPossibleEffect(*mListView, true, mListViewX); |
622 } else { |
602 } else { |
623 mEffectHandler->startMoveNotPossibleEffect(*mEmptyListLabel, true, mListViewX); |
603 mEffectHandler->startMoveNotPossibleEffect(*mEmptyListLabel, |
|
604 true, mEmptyListLabelX); |
624 } |
605 } |
625 } |
606 } |
626 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::rightFlick()" ); |
607 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::rightFlick()" ); |
627 } |
608 } |
628 |
609 |
641 mAppearingView = view; |
622 mAppearingView = view; |
642 return; |
623 return; |
643 } |
624 } |
644 |
625 |
645 mMoveLeftInList = mConversionMap.value(view) < mConversionMap.value(mCurrentView); |
626 mMoveLeftInList = mConversionMap.value(view) < mConversionMap.value(mCurrentView); |
646 |
|
647 mAppearingView = view; |
627 mAppearingView = view; |
|
628 // Disable scrollbar while moving the list for more nice looks |
|
629 mListView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
648 mEffectHandler->startDissappearAppearByFadingEffect(*mViewName); |
630 mEffectHandler->startDissappearAppearByFadingEffect(*mViewName); |
649 mEffectHandler->startDissappearAppearByMovingEffect( |
631 mEffectHandler->startDissappearAppearByMovingEffect( |
650 *mListView, *mEmptyListLabel, !mMoveLeftInList, mListViewX); |
632 *mListView, *mEmptyListLabel, !mMoveLeftInList, |
|
633 mListViewX, mEmptyListLabelX); |
651 |
634 |
652 mPageIndicator->setActiveItemIndex(mConversionMap.value(mAppearingView)); |
635 mPageIndicator->setActiveItemIndex(mConversionMap.value(mAppearingView)); |
653 |
636 |
654 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::changeView()" ); |
637 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::changeView()" ); |
655 } |
638 } |
675 // |
658 // |
676 void LogsRecentCallsView::dissappearByMovingComplete() |
659 void LogsRecentCallsView::dissappearByMovingComplete() |
677 { |
660 { |
678 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::dissappearByMovingComplete()" ) |
661 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::dissappearByMovingComplete()" ) |
679 |
662 |
680 updateView( mAppearingView ); |
663 updateView( mAppearingView ); |
681 |
664 |
682 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::dissappearByMovingComplete()" ) |
665 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::dissappearByMovingComplete()" ) |
|
666 } |
|
667 |
|
668 |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 // ----------------------------------------------------------------------------- |
|
672 // |
|
673 void LogsRecentCallsView::appearByMovingComplete() |
|
674 { |
|
675 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::appearByMovingComplete()" ) |
|
676 |
|
677 // Restore scrollbar which was hidden when animation started |
|
678 mListView->setVerticalScrollBarPolicy(mListScrollBarPolicy); |
|
679 |
|
680 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::appearByMovingComplete()" ) |
683 } |
681 } |
684 |
682 |
685 // ----------------------------------------------------------------------------- |
683 // ----------------------------------------------------------------------------- |
686 // LogsRecentCallsView::updateMenu |
684 // LogsRecentCallsView::updateMenu |
687 // ----------------------------------------------------------------------------- |
685 // ----------------------------------------------------------------------------- |
701 toggleActionAvailability(addToContactsAction, isDialpadInput()); |
699 toggleActionAvailability(addToContactsAction, isDialpadInput()); |
702 |
700 |
703 updateDialpadCallAndMessagingActions(); |
701 updateDialpadCallAndMessagingActions(); |
704 updateContactSearchAction(); |
702 updateContactSearchAction(); |
705 |
703 |
|
704 updateMenuVisibility(); |
|
705 |
706 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateMenu()" ); |
706 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateMenu()" ); |
707 } |
707 } |
708 |
708 |
709 // ----------------------------------------------------------------------------- |
709 // ----------------------------------------------------------------------------- |
710 // LogsRecentCallsView::updateEmptyListWidgetsVisibility |
710 // LogsRecentCallsView::updateEmptyListWidgetsVisibility |
725 { |
725 { |
726 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::updateWidgetsSizeAndLayout()" ); |
726 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::updateWidgetsSizeAndLayout()" ); |
727 if ( mListView ) { |
727 if ( mListView ) { |
728 updateMenu(); |
728 updateMenu(); |
729 updateListLayoutName(*mListView); |
729 updateListLayoutName(*mListView); |
730 updateListSize(); |
730 updateListSize(*mListView); |
731 LogsConfigurationParams param; |
731 LogsConfigurationParams param; |
732 param.setListItemTextWidth( getListItemTextWidth() ); |
732 param.setListItemTextWidth( getListItemTextWidth() ); |
733 mModel->updateConfiguration(param); |
733 mModel->updateConfiguration(param); |
734 } |
734 } |
735 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateWidgetsSizeAndLayout()" ); |
735 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateWidgetsSizeAndLayout()" ); |
813 mMarkingMissedAsSeen = |
813 mMarkingMissedAsSeen = |
814 mModel->markEventsSeen(LogsModel::TypeLogsClearMissed); |
814 mModel->markEventsSeen(LogsModel::TypeLogsClearMissed); |
815 } |
815 } |
816 return mMarkingMissedAsSeen; |
816 return mMarkingMissedAsSeen; |
817 } |
817 } |
818 |
|
819 // ----------------------------------------------------------------------------- |
|
820 // LogsRecentCallsView::scrollToTopItem |
|
821 // ----------------------------------------------------------------------------- |
|
822 // |
|
823 void LogsRecentCallsView::scrollToTopItem() |
|
824 { |
|
825 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::scrollToTopItem()" ); |
|
826 disconnect( mFilter, SIGNAL(rowsInserted(const QModelIndex&,int,int)), |
|
827 this, SLOT(scrollToTopItem())); |
|
828 if ( mFilter && mFilter->hasIndex(0,0) ) { |
|
829 mListView->scrollTo( mFilter->index(0,0) ); |
|
830 } |
|
831 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::scrollToTopItem()" ); |
|
832 } |
|