logsui/logsapp/src/logsmatchesview.cpp
changeset 2 7119b73b84d6
parent 0 4a5361db8937
child 6 41c0a814d878
equal deleted inserted replaced
0:4a5361db8937 2:7119b73b84d6
    22 #include "logslogger.h"
    22 #include "logslogger.h"
    23 #include "logsmodel.h"
    23 #include "logsmodel.h"
    24 #include "logsmatchesmodel.h"
    24 #include "logsmatchesmodel.h"
    25 #include "logscall.h"
    25 #include "logscall.h"
    26 #include "logscontact.h"
    26 #include "logscontact.h"
    27 #include "logsmessage.h"
       
    28 
    27 
    29 //SYSTEM
    28 //SYSTEM
    30 #include <hblistview.h>
    29 #include <hblistview.h>
    31 #include <hbaction.h>
    30 #include <hbaction.h>
    32 #include <dialpad.h>
    31 #include <dialpad.h>
   119 {
   118 {
   120     return mModel;
   119     return mModel;
   121 }
   120 }
   122 
   121 
   123 // -----------------------------------------------------------------------------
   122 // -----------------------------------------------------------------------------
   124 // 
   123 //
   125 // -----------------------------------------------------------------------------
   124 // -----------------------------------------------------------------------------
   126 //
   125 //
   127 void LogsMatchesView::callKeyPressed()
   126 HbListView* LogsMatchesView::listView() const
   128 {
   127 {
   129     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::callKeyPressed()" );
   128     return mListView;
   130     
       
   131     callToCurrentNum( LogsCall::TypeLogsVoiceCall );
       
   132     
       
   133     LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::callKeyPressed()" );
       
   134 }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // 
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void LogsMatchesView::videoCallToCurrentNum()
       
   141 {
       
   142     callToCurrentNum( LogsCall::TypeLogsVideoCall );
       
   143 }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // 
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 void LogsMatchesView::sendMessageToCurrentNum()
       
   150 {
       
   151     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::sendMessageToCurrentNum()" );
       
   152     if ( mDialpad->editor().text().length() > 0 ){
       
   153         // Message to inputted number
       
   154         LogsMessage::sendMessageToNumber( mDialpad->editor().text() );
       
   155     }
       
   156     LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::sendMessageToCurrentNum()" );
       
   157 }
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // 
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 void LogsMatchesView::saveNumberInDialpadToContacts()
       
   164 {
       
   165     if (mDialpad->editor().text().length() > 0){
       
   166         delete mContact;
       
   167         mContact = 0;
       
   168         mContact = mModel->createContact(mDialpad->editor().text());
       
   169         this->saveContact();
       
   170     }
       
   171 }
   129 }
   172 
   130 
   173 // -----------------------------------------------------------------------------
   131 // -----------------------------------------------------------------------------
   174 // LogsMatchesView::initListWidget
   132 // LogsMatchesView::initListWidget
   175 // -----------------------------------------------------------------------------
   133 // -----------------------------------------------------------------------------
   229 //
   187 //
   230 void LogsMatchesView::handleBackSoftkey()
   188 void LogsMatchesView::handleBackSoftkey()
   231 {
   189 {
   232     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::handleBackSoftkey()" );
   190     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::handleBackSoftkey()" );
   233  
   191  
       
   192     mDialpad->editor().setText(QString());
       
   193     
   234     if (mDialpad->isOpen()){
   194     if (mDialpad->isOpen()){
   235         LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::handleBackSoftkey() closeDialpad" );
   195         LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::handleBackSoftkey() closeDialpad" );
   236         // Block aboutToClose signal to interfere with layout loading 
   196         // Block aboutToClose signal to interfere with layout loading 
   237         // at backstepping phase
   197         // at backstepping phase
   238         mDialpad->blockSignals(true);
   198         mDialpad->blockSignals(true);
   267 // LogsMatchesView::dialpadOpened
   227 // LogsMatchesView::dialpadOpened
   268 // -----------------------------------------------------------------------------
   228 // -----------------------------------------------------------------------------
   269 //
   229 //
   270 void LogsMatchesView::dialpadOpened()
   230 void LogsMatchesView::dialpadOpened()
   271 {
   231 {
   272     LogsBaseView::dialpadOpened();
   232     updateWidgetsSizeAndLayout();
   273     updateAddContactButton();
   233     updateAddContactButton();
   274 }
   234 }
   275 
   235 
   276 // -----------------------------------------------------------------------------
   236 // -----------------------------------------------------------------------------
   277 // LogsMatchesView::dialpadClosed
   237 // LogsMatchesView::dialpadClosed
   309     updateEmptyListLabelVisibility();
   269     updateEmptyListLabelVisibility();
   310     updateAddContactButton();
   270     updateAddContactButton();
   311 }
   271 }
   312 
   272 
   313 // -----------------------------------------------------------------------------
   273 // -----------------------------------------------------------------------------
       
   274 // LogsMatchesView::toggleContactSearch
       
   275 // -----------------------------------------------------------------------------
       
   276 //
       
   277 void LogsMatchesView::toggleContactSearch()
       
   278 {
       
   279     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::toggleContactSearch()" );
       
   280 
       
   281     if ( isContactSearchEnabled() ){
       
   282         int result = mModel->setPredictiveSearch( false );
       
   283         LogsBaseView::handleBackSoftkey();
       
   284 	}
       
   285     LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::toggleContactSearch()" );
       
   286 }
       
   287 
       
   288 // -----------------------------------------------------------------------------
   314 //
   289 //
   315 // -----------------------------------------------------------------------------
   290 // -----------------------------------------------------------------------------
   316 //
   291 //
   317 void LogsMatchesView::updateMenu()
   292 void LogsMatchesView::updateMenu()
   318 {
   293 {
   319     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::updateMenu()" );
   294     LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::updateMenu()" );
   320     HbAction* videoCallAction = qobject_cast<HbAction*>( 
   295     
   321             mRepository.findObject( logsCommonVideoCallMenuActionId ) );
   296     updateDialpadCallAndMessagingActions();
   322     HbAction* sendMessageAction = qobject_cast<HbAction*>( 
   297     
   323             mRepository.findObject( logsCommonMessageMenuActionId ) );
   298     updateContactSearchAction();
   324     
   299 	
   325     bool visible( mDialpad->isOpen() && !mDialpad->editor().text().isEmpty() );
       
   326     
       
   327     toggleActionAvailability( videoCallAction, visible );
       
   328     toggleActionAvailability( sendMessageAction, visible );
       
   329     LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::updateMenu()" );
   300     LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::updateMenu()" );
   330 }
       
   331 
       
   332 // -----------------------------------------------------------------------------
       
   333 //
       
   334 // -----------------------------------------------------------------------------
       
   335 //
       
   336 void LogsMatchesView::callToCurrentNum( LogsCall::CallType callType )
       
   337 {
       
   338     if ( mDialpad->editor().text().length() > 0 ){
       
   339         // Call to inputted number
       
   340         LogsCall::callToNumber( callType, mDialpad->editor().text() );
       
   341     }
       
   342 }
   301 }
   343 
   302 
   344 // -----------------------------------------------------------------------------
   303 // -----------------------------------------------------------------------------
   345 // LogsMatchesView::updateAddContactButton
   304 // LogsMatchesView::updateAddContactButton
   346 // -----------------------------------------------------------------------------
   305 // -----------------------------------------------------------------------------
   348 void LogsMatchesView::updateAddContactButton()
   307 void LogsMatchesView::updateAddContactButton()
   349 {
   308 {
   350     if (mAddToContactsButton) {
   309     if (mAddToContactsButton) {
   351         LOGS_QDEBUG( "logs [UI] <-> LogsMatchesView::updateAddContactButton()" );
   310         LOGS_QDEBUG( "logs [UI] <-> LogsMatchesView::updateAddContactButton()" );
   352         bool matchesFound(model() && (model()->rowCount() > 0));
   311         bool matchesFound(model() && (model()->rowCount() > 0));
   353         mAddToContactsButton->setVisible(!matchesFound
   312         mAddToContactsButton->setVisible(!matchesFound && isDialpadInput());
   354                                          && mDialpad->isOpen() 
   313     }
   355                                          && !mDialpad->editor().text().isEmpty());
   314 }
   356     }
       
   357 }