logsui/logsapp/src/logsmatchesview.cpp
changeset 11 64a47b97e1e1
parent 6 41c0a814d878
child 15 76d2cf7a585e
equal deleted inserted replaced
10:b04270301d3b 11:64a47b97e1e1
    43 LogsMatchesView::LogsMatchesView( 
    43 LogsMatchesView::LogsMatchesView( 
    44     LogsComponentRepository& repository, LogsAbstractViewManager& viewManager )
    44     LogsComponentRepository& repository, LogsAbstractViewManager& viewManager )
    45     : LogsBaseView(LogsMatchesViewId, repository, viewManager),
    45     : LogsBaseView(LogsMatchesViewId, repository, viewManager),
    46       mListView(0),
    46       mListView(0),
    47       mModel(0),
    47       mModel(0),
    48       mAddToContactsButton(0)
    48       mAddToContactsButton(0),
       
    49       mAddToContactsButtonDisabled(false)
    49 {
    50 {
    50     LOGS_QDEBUG( "logs [UI] <-> LogsMatchesView::LogsMatchesView()" );
    51     LOGS_QDEBUG( "logs [UI] <-> LogsMatchesView::LogsMatchesView()" );
    51     
    52     
    52     mActivities.append( logsActivityIdViewMatches );
    53     mActivities.append( logsActivityIdViewMatches );
    53 }
    54 }
    67 // LogsMatchesView::activated
    68 // LogsMatchesView::activated
    68 // -----------------------------------------------------------------------------
    69 // -----------------------------------------------------------------------------
    69 //
    70 //
    70 void LogsMatchesView::activated(bool showDialer, QVariant args)
    71 void LogsMatchesView::activated(bool showDialer, QVariant args)
    71 {
    72 {
    72     //base class handling first
    73     // Disable add to contacts button handling while view is activated
       
    74     // to avoid unnecessary quick appear/dissappear of it.
       
    75     mAddToContactsButtonDisabled = true;
       
    76     
    73     LogsBaseView::activated(showDialer, args);
    77     LogsBaseView::activated(showDialer, args);
    74     
    78     
    75     LogsMatchesModel* model = qVariantValue<LogsMatchesModel*>(args);
    79     LogsMatchesModel* model = qVariantValue<LogsMatchesModel*>(args);
    76     updateModel(model);
    80     updateModel(model);
    77     dialpadEditorTextChanged();
    81     dialpadEditorTextChanged();
    78     
    82     
    79     activateEmptyListIndicator(mModel);
    83     activateEmptyListIndicator(mModel);
       
    84     
       
    85     scrollToTopItem(mListView);
       
    86     
       
    87     mAddToContactsButtonDisabled = false;
    80 }
    88 }
    81 
    89 
    82 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
    83 // LogsMatchesView::deactivated
    91 // LogsMatchesView::deactivated
    84 // -----------------------------------------------------------------------------
    92 // -----------------------------------------------------------------------------
   188 // -----------------------------------------------------------------------------
   196 // -----------------------------------------------------------------------------
   189 //
   197 //
   190 void LogsMatchesView::handleBackSoftkey()
   198 void LogsMatchesView::handleBackSoftkey()
   191 {
   199 {
   192     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::handleBackSoftkey()" );
   200     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::handleBackSoftkey()" );
   193  
   201     mDialpad->editor().blockSignals(true);
   194     mDialpad->editor().setText(QString());
   202     mDialpad->editor().setText(QString());
       
   203     mDialpad->editor().blockSignals(false);
   195     
   204     
   196     if (mDialpad->isOpen()){
   205     if (mDialpad->isOpen()){
   197         LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::handleBackSoftkey() closeDialpad" );
   206         LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::handleBackSoftkey() closeDialpad" );
   198         // Block aboutToClose signal to interfere with layout loading 
   207         // Block aboutToClose signal to interfere with layout loading 
   199         // at backstepping phase
   208         // at backstepping phase
   200         mDialpad->blockSignals(true);
   209         mDialpad->blockSignals(true);
   201         mDialpad->closeDialpad();
   210         mDialpad->closeDialpad();
   202         mDialpad->blockSignals(false);
   211         mDialpad->blockSignals(false);
   203     }
   212     }
   204     
   213 
   205     LogsBaseView::handleBackSoftkey();
   214     LogsBaseView::handleBackSoftkey();
   206 
   215 
   207     LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::::handleBackSoftkey()" );
   216     LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::::handleBackSoftkey()" );
   208 }
   217 }
   209 
   218 
   211 // LogsMatchesView::dialpadEditorTextChanged
   220 // LogsMatchesView::dialpadEditorTextChanged
   212 // -----------------------------------------------------------------------------
   221 // -----------------------------------------------------------------------------
   213 //
   222 //
   214 void LogsMatchesView::dialpadEditorTextChanged()
   223 void LogsMatchesView::dialpadEditorTextChanged()
   215 {
   224 {
       
   225     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::dialpadEditorTextChanged()" );
   216     updateCallButton();
   226     updateCallButton();
   217     updateMenu();
   227     updateMenu();
   218     
   228     
   219     QString pattern = mDialpad->editor().text();
   229     QString pattern = mDialpad->editor().text();
   220     if ( pattern.isEmpty() ){
   230     if ( pattern.isEmpty() ){
   221         // Treat empty input field same way as back press
   231         // Treat empty input field same way as back press
   222         LogsBaseView::handleBackSoftkey();
   232         LogsBaseView::handleBackSoftkey();
   223     } else if ( mModel ) {
   233     } else if ( mModel ) {
   224         mModel->logsMatches( pattern );
   234         mModel->logsMatches( pattern );
   225     }
   235     }
       
   236     LOGS_QDEBUG_2( "logs [UI] <- LogsMatchesView::::dialpadEditorTextChanged(), text: ", pattern );
   226 }
   237 }
   227 
   238 
   228 // -----------------------------------------------------------------------------
   239 // -----------------------------------------------------------------------------
   229 // LogsMatchesView::dialpadOpened
   240 // LogsMatchesView::dialpadOpened
   230 // -----------------------------------------------------------------------------
   241 // -----------------------------------------------------------------------------
   255 {
   266 {
   256     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::updateWidgetsSizeAndLayout()" );
   267     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::updateWidgetsSizeAndLayout()" );
   257     if ( mListView ) {
   268     if ( mListView ) {
   258         updateMenu();
   269         updateMenu();
   259         updateListLayoutName(*mListView);
   270         updateListLayoutName(*mListView);
   260         updateListSize();
   271         updateListSize(*mListView);
   261     }
   272     }
   262     LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::updateWidgetsSizeAndLayout()" );
   273     LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::updateWidgetsSizeAndLayout()" );
   263 }
   274 }
   264 
   275 
   265 // -----------------------------------------------------------------------------
   276 // -----------------------------------------------------------------------------
   293 //
   304 //
   294 void LogsMatchesView::updateMenu()
   305 void LogsMatchesView::updateMenu()
   295 {
   306 {
   296     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::updateMenu()" );
   307     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::updateMenu()" );
   297     
   308     
   298     updateDialpadCallAndMessagingActions();
   309     updateDialpadCallAndMessagingActions();    
   299     
       
   300     updateContactSearchAction();
   310     updateContactSearchAction();
       
   311     updateMenuVisibility();
   301 	
   312 	
   302     LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::updateMenu()" );
   313     LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::updateMenu()" );
   303 }
   314 }
   304 
   315 
   305 // -----------------------------------------------------------------------------
   316 // -----------------------------------------------------------------------------
   309 void LogsMatchesView::updateAddContactButton()
   320 void LogsMatchesView::updateAddContactButton()
   310 {
   321 {
   311     if (mAddToContactsButton) {
   322     if (mAddToContactsButton) {
   312         LOGS_QDEBUG( "logs [UI] <-> LogsMatchesView::updateAddContactButton()" );
   323         LOGS_QDEBUG( "logs [UI] <-> LogsMatchesView::updateAddContactButton()" );
   313         bool matchesFound(model() && (model()->rowCount() > 0));
   324         bool matchesFound(model() && (model()->rowCount() > 0));
   314         mAddToContactsButton->setVisible(!matchesFound && isDialpadInput());
   325         mAddToContactsButton->setVisible(
   315     }
   326             !mAddToContactsButtonDisabled && !matchesFound && isDialpadInput() );
   316 }
   327     }
       
   328 }