logsui/logsapp/src/logsrecentcallsview.cpp
changeset 17 90fe74753f71
parent 15 76d2cf7a585e
child 18 acd4e87b24b4
equal deleted inserted replaced
15:76d2cf7a585e 17:90fe74753f71
    19 #include "logscomponentrepository.h"
    19 #include "logscomponentrepository.h"
    20 #include "logsabstractviewmanager.h"
    20 #include "logsabstractviewmanager.h"
    21 #include "logsmodel.h"
    21 #include "logsmodel.h"
    22 #include "logsdefs.h"
    22 #include "logsdefs.h"
    23 #include "logslogger.h"
    23 #include "logslogger.h"
    24 #include "logscall.h"
       
    25 #include "logsmessage.h"
       
    26 #include "logscontact.h"
       
    27 #include "logseffecthandler.h"
    24 #include "logseffecthandler.h"
    28 #include "logsmatchesmodel.h"
    25 #include "logsmatchesmodel.h"
    29 #include "logspageindicator.h"
    26 #include "logspageindicator.h"
    30 #include "logsconfigurationparams.h"
    27 #include "logsconfigurationparams.h"
    31 
    28 
    44 #include <hbswipegesture.h>
    41 #include <hbswipegesture.h>
    45 #include <hbmessagebox.h>
    42 #include <hbmessagebox.h>
    46 #include <hbactivitymanager.h>
    43 #include <hbactivitymanager.h>
    47 #include <hbstyleloader.h>
    44 #include <hbstyleloader.h>
    48 #include <QTimer>
    45 #include <QTimer>
    49 #include <QApplication>
       
    50 
    46 
    51 Q_DECLARE_METATYPE(LogsMatchesModel*)
    47 Q_DECLARE_METATYPE(LogsMatchesModel*)
    52 
    48 
    53 const int logsMissedCallsMarkingDelayMs = 1000;
    49 const int logsMissedCallsMarkingDelayMs = 1000;
    54 
    50 
   126 
   122 
   127     // View update is needed when we activate view for the first time (!mFilter)
   123     // View update is needed when we activate view for the first time (!mFilter)
   128     // or if view has to be changed
   124     // or if view has to be changed
   129     if (  !mFilter || ( !args.isNull() && (mCurrentView != view) ) ) {
   125     if (  !mFilter || ( !args.isNull() && (mCurrentView != view) ) ) {
   130         updateView( view );
   126         updateView( view );
   131     }
   127     } else {
   132     activateEmptyListIndicator(mFilter);
   128         activateEmptyListIndicator(mFilter);
       
   129         handleMissedCallsCounter();
       
   130     }
   133     
   131     
   134     mPageIndicator->setActiveItemIndex(mConversionMap.value(mCurrentView));
   132     mPageIndicator->setActiveItemIndex(mConversionMap.value(mCurrentView));
   135 
   133 
   136     if (mEmptyListLabel) {
   134     if (mEmptyListLabel) {
   137         mEmptyListLabelX = mEmptyListLabel->pos().x();
   135         mEmptyListLabelX = mEmptyListLabel->pos().x();
   138     }
   136     }
   139 
   137 
   140     qApp->installEventFilter(this);
       
   141     
       
   142     LogsBaseView::activationCompleted();
   138     LogsBaseView::activationCompleted();
   143  
   139  
   144     LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::activated()" );  
   140     LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::activated()" );  
   145 }
   141 }
   146 
   142 
   154 
   150 
   155     //base class handling first
   151     //base class handling first
   156     LogsBaseView::deactivated();
   152     LogsBaseView::deactivated();
   157     
   153     
   158     deactivateEmptyListIndicator(mFilter);
   154     deactivateEmptyListIndicator(mFilter);
   159     qApp->removeEventFilter(this);
       
   160 }
   155 }
   161 
   156 
   162 // -----------------------------------------------------------------------------
   157 // -----------------------------------------------------------------------------
   163 //
   158 //
   164 // -----------------------------------------------------------------------------
   159 // -----------------------------------------------------------------------------
   381     LOGS_QDEBUG_2( "logs [UI] -> LogsRecentCallsView::updateView(), view:", view );
   376     LOGS_QDEBUG_2( "logs [UI] -> LogsRecentCallsView::updateView(), view:", view );
   382     mCurrentView = view;
   377     mCurrentView = view;
   383     LogsFilter::FilterType filter = getFilter( view );
   378     LogsFilter::FilterType filter = getFilter( view );
   384     updateFilter(filter);
   379     updateFilter(filter);
   385     updateViewName();
   380     updateViewName();
   386     updateContextMenuItems(mCurrentView);    
   381     updateContextMenuItems(mCurrentView);
       
   382     handleMissedCallsCounter();
   387     LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateView()" );
   383     LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateView()" );
   388 }
   384 }
   389 
   385 
   390 // -----------------------------------------------------------------------------
   386 // -----------------------------------------------------------------------------
   391 // LogsRecentCallsView::changeFilter
   387 // LogsRecentCallsView::changeFilter
   485         mListView->setModel( mFilter );//ownership not transferred
   481         mListView->setModel( mFilter );//ownership not transferred
   486         
   482         
   487         scrollToTopItem(mListView);
   483         scrollToTopItem(mListView);
   488         
   484         
   489         activateEmptyListIndicator(mFilter);
   485         activateEmptyListIndicator(mFilter);
   490          
   486         
   491         LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateFilter() " );
   487         LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateFilter() " );
   492     }  else {
   488     }  else {
   493         LOGS_QWARNING( "logs [UI] LogsRecentCallsView::updateFilter(), !no list widget!" );
   489         LOGS_QWARNING( "logs [UI] LogsRecentCallsView::updateFilter(), !no list widget!" );
   494     }
   490     }
   495 }
   491 }
   546             break;
   542             break;
   547     }
   543     }
   548     return filter;
   544     return filter;
   549 }
   545 }
   550 
   546 
   551 
       
   552 // -----------------------------------------------------------------------------
       
   553 // LogsRecentCallsView::eventFilter
       
   554 // -----------------------------------------------------------------------------
       
   555 //
       
   556 bool LogsRecentCallsView::eventFilter(QObject *obj, QEvent *event)
       
   557 {
       
   558     //This is a hack to fix ou1cimx1#481152(horizontal swiping initiates call)
       
   559     //Since w26 HbAbstractViewItemPrivate is setting threshold for Tap gesture
       
   560     //to be the bounding rect (i.e. if swiping is happening inside one list item
       
   561     //it will also be considered as a tap => item activated => call)
       
   562     //We are trying to prevent usage of the list item rect threshold by
       
   563     //setting "horizontallyRestricted" property.
       
   564     //See HbAbstractViewItemPrivate::tapTriggered() and 
       
   565     //HbTapGestureLogic::handleMouseMove() for more info
       
   566     if (event->type() == QEvent::Gesture) {
       
   567         QGestureEvent* gesture = static_cast<QGestureEvent*> (event);
       
   568         QTapGesture* tap = qobject_cast<QTapGesture*>(gesture->gesture(Qt::TapGesture));
       
   569         //only change property if swiping on our list, since for the menu it is
       
   570         //fine to generate tap gesture event during swiping on one item
       
   571         bool tapOnListView = (mListView && mListView->currentViewItem() == obj);
       
   572         if (tap && tapOnListView && tap->state() == Qt::GestureStarted) {
       
   573             tap->setProperty("horizontallyRestricted", true);
       
   574             LOGS_QDEBUG( "logs [UI] TapGesture on list, setting horizontallyRestricted" );
       
   575         }
       
   576     }
       
   577     return LogsBaseView::eventFilter(obj,event);
       
   578 }
       
   579 
       
   580 // -----------------------------------------------------------------------------
   547 // -----------------------------------------------------------------------------
   581 // LogsRecentCallsView::gestureEvent
   548 // LogsRecentCallsView::gestureEvent
   582 // -----------------------------------------------------------------------------
   549 // -----------------------------------------------------------------------------
   583 //
   550 //
   584 void LogsRecentCallsView::gestureEvent(QGestureEvent *event)
   551 void LogsRecentCallsView::gestureEvent(QGestureEvent *event)
   585 {
   552 {
   586     QGesture* gesture = event->gesture(Qt::SwipeGesture);
   553     QGesture* gesture = event->gesture(Qt::SwipeGesture);
   587     if (gesture) {
   554     if (gesture) {
   588         LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::gestureEvent()" );
   555         LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::gestureEvent()" );
   589         HbSwipeGesture* swipe = static_cast<HbSwipeGesture *>(gesture);
   556         HbSwipeGesture* swipe = static_cast<HbSwipeGesture *>(gesture);
   590         if (swipe && swipe->state() == Qt::GestureFinished) {
   557         if (swipe) {
   591             LOGS_QDEBUG_2( "logs [UI] sceneSwipeAngle: ", swipe->sceneSwipeAngle() );
       
   592             LOGS_QDEBUG_2( "logs [UI] swipeAngle: ", swipe->swipeAngle() );
       
   593             
       
   594             QSwipeGesture::SwipeDirection direction = swipe->sceneHorizontalDirection(); 
   558             QSwipeGesture::SwipeDirection direction = swipe->sceneHorizontalDirection(); 
   595             if ( decideListMoveDirection(direction) )
   559             if (swipe->state() == Qt::GestureStarted) {
   596                 event->accept(Qt::SwipeGesture);
   560                 //fix for ou1cimx1#481152, if policy not set then every swipe
       
   561                 //within list item boundaries will also activate list item
       
   562                 if (direction == QSwipeGesture::Left 
       
   563                    || direction == QSwipeGesture::Right) {
       
   564                     swipe->setGestureCancelPolicy(QGesture::CancelAllInContext);
       
   565                     LOGS_QDEBUG( "logs [UI] swipe->state() == Qt::GestureStarted" );
       
   566                 }
       
   567             } else  if (swipe->state() == Qt::GestureFinished) {
       
   568                 LOGS_QDEBUG_2( "logs [UI] sceneSwipeAngle: ", swipe->sceneSwipeAngle() );
       
   569                 LOGS_QDEBUG_2( "logs [UI] swipeAngle: ", swipe->swipeAngle() );
       
   570                 
       
   571                 if ( decideListMoveDirection(direction) ) {
       
   572                     event->accept(Qt::SwipeGesture);
       
   573                 }
   597             }
   574             }
   598         }
   575         }
       
   576     }
   599 }
   577 }
   600 
   578 
   601 // -----------------------------------------------------------------------------
   579 // -----------------------------------------------------------------------------
   602 // LogsRecentCallsView::decideListMoveDirection
   580 // LogsRecentCallsView::decideListMoveDirection
   603 // -----------------------------------------------------------------------------
   581 // -----------------------------------------------------------------------------
   916     if ( layoutDirection() == Qt::RightToLeft ){
   894     if ( layoutDirection() == Qt::RightToLeft ){
   917         return !toLeft;
   895         return !toLeft;
   918     }
   896     }
   919     return toLeft;
   897     return toLeft;
   920 }
   898 }
       
   899 
       
   900 // -----------------------------------------------------------------------------
       
   901 // LogsRecentCallsView::handleMissedCallsCounter
       
   902 // -----------------------------------------------------------------------------
       
   903 //
       
   904 void LogsRecentCallsView::handleMissedCallsCounter()
       
   905 {
       
   906     if (mModel && mCurrentView == XQService::LogsViewMissed) {
       
   907         LOGS_QDEBUG( "logs [UI] <-> LogsRecentCallsView::clearMissedCallsCounter()" );
       
   908         mModel->clearMissedCallsCounter();
       
   909     }
       
   910 }
       
   911