logsui/logsapp/src/logsdetailsview.cpp
changeset 2 7119b73b84d6
parent 0 4a5361db8937
child 6 41c0a814d878
equal deleted inserted replaced
0:4a5361db8937 2:7119b73b84d6
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 //USER
       
    18 #include "logsdetailsview.h"
    17 #include "logsdetailsview.h"
    19 #include "logsdetailsmodel.h"
    18 #include "logsdetailsmodel.h"
    20 #include "logscall.h"
    19 #include "logscall.h"
    21 #include "logsmessage.h"
    20 #include "logsmessage.h"
    22 #include "logslogger.h"
    21 #include "logslogger.h"
    29 #include <hblistview.h>
    28 #include <hblistview.h>
    30 #include <hbaction.h>
    29 #include <hbaction.h>
    31 #include <hbgroupbox.h>
    30 #include <hbgroupbox.h>
    32 #include <hbmessagebox.h>
    31 #include <hbmessagebox.h>
    33 #include <hblabel.h>
    32 #include <hblabel.h>
       
    33 #include <dialpad.h>
       
    34 #include <hblineedit.h>
    34 Q_DECLARE_METATYPE(LogsDetailsModel*)
    35 Q_DECLARE_METATYPE(LogsDetailsModel*)
    35 
    36 
    36 
    37 
    37 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    38 // 
    39 // 
   116 // -----------------------------------------------------------------------------
   117 // -----------------------------------------------------------------------------
   117 //
   118 //
   118 void LogsDetailsView::callKeyPressed()
   119 void LogsDetailsView::callKeyPressed()
   119 {
   120 {
   120     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::callKeyPressed()" );
   121     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::callKeyPressed()" );
   121     if ( mCall ){
   122     if ( !tryCallToDialpadNumber() && mCall ){
   122         mCall->initiateCallback();
   123         mCall->initiateCallback();
   123     }
   124     }
   124     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::callKeyPressed()" );
   125     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::callKeyPressed()" );
   125 }
   126 }
   126 
   127 
   129 // -----------------------------------------------------------------------------
   130 // -----------------------------------------------------------------------------
   130 //
   131 //
   131 void LogsDetailsView::initiateVoiceCall()
   132 void LogsDetailsView::initiateVoiceCall()
   132 {
   133 {
   133     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::initiateVoiceCall()" );
   134     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::initiateVoiceCall()" );
   134     if ( mCall ){
   135     if ( !tryCallToDialpadNumber() && mCall ){
   135         mCall->call(LogsCall::TypeLogsVoiceCall);
   136         mCall->call(LogsCall::TypeLogsVoiceCall);
   136     }
   137     }
   137     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::initiateVoiceCall()" );
   138     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::initiateVoiceCall()" );
   138 }
   139 }
   139 
   140 
   142 // -----------------------------------------------------------------------------
   143 // -----------------------------------------------------------------------------
   143 //
   144 //
   144 void LogsDetailsView::initiateVideoCall()
   145 void LogsDetailsView::initiateVideoCall()
   145 {
   146 {
   146     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::initiateVideoCall()" );
   147     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::initiateVideoCall()" );
   147     if ( mCall ){
   148     if ( !tryCallToDialpadNumber(LogsCall::TypeLogsVideoCall) && mCall ){
   148         mCall->call(LogsCall::TypeLogsVideoCall);
   149         mCall->call(LogsCall::TypeLogsVideoCall);
   149     }
   150     }
   150     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::initiateVideoCall()" );
   151     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::initiateVideoCall()" );
   151 }
   152 }
   152 
   153 
   153 // -----------------------------------------------------------------------------
   154 // -----------------------------------------------------------------------------
   154 // 
   155 // 
   155 // -----------------------------------------------------------------------------
   156 // -----------------------------------------------------------------------------
   156 //
   157 //
   157 void LogsDetailsView::addToContacts()
   158 void LogsDetailsView::sendMessage()
   158 {
   159 {
   159     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::addToContacts()" );
   160     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::sendMessage()" );
   160     if ( mContact ){
   161     if ( !tryMessageToDialpadNumber() && mMessage ){
   161         // Use async connection to ensure that model can handle
   162         mMessage->sendMessage();
   162         // contact operation completion before view
   163     }
   163         QObject::connect(mContact, SIGNAL(saveCompleted(bool)),
   164     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::sendMessage()" );
   164                          this, SLOT(contactActionCompleted(bool)), 
       
   165                          Qt::QueuedConnection);
       
   166         this->saveContact();
       
   167     }
       
   168     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::addToContacts()" );
       
   169 }
   165 }
   170 
   166 
   171 // -----------------------------------------------------------------------------
   167 // -----------------------------------------------------------------------------
   172 // 
   168 // 
   173 // -----------------------------------------------------------------------------
   169 // -----------------------------------------------------------------------------
   204     
   200     
   205     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::contactActionCompleted()" );
   201     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::contactActionCompleted()" );
   206 }
   202 }
   207 
   203 
   208 // -----------------------------------------------------------------------------
   204 // -----------------------------------------------------------------------------
   209 //
       
   210 // -----------------------------------------------------------------------------
       
   211 //
       
   212 void LogsDetailsView::deleteEvent()
       
   213 {
       
   214     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::deleteEvent()" );
       
   215     if ( mDetailsModel ) {
       
   216         if ( askConfirmation( hbTrId("txt_dialer_ui_title_delete_event"),
       
   217                     hbTrId("txt_dialer_info_call_event_will_be_removed_from"))){
       
   218             mDetailsModel->clearEvent();
       
   219             handleBackSoftkey();       
       
   220         }
       
   221     }
       
   222     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::deleteEvent()" );
       
   223 }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // LogsDetailsView::copyNumberToClipboard()
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 void LogsDetailsView::copyNumberToClipboard()
       
   230 {
       
   231     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::copyNumberToClipboard()" );
       
   232     if ( mDetailsModel ) {
       
   233         mDetailsModel->getNumberToClipboard();
       
   234         handleBackSoftkey();    
       
   235     }
       
   236     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::copyNumberToClipboard()" );
       
   237 }
       
   238 
       
   239 // -----------------------------------------------------------------------------
       
   240 // LogsDetailsView::handleBackSoftkey
   205 // LogsDetailsView::handleBackSoftkey
   241 // -----------------------------------------------------------------------------
   206 // -----------------------------------------------------------------------------
   242 //
   207 //
   243 void LogsDetailsView::handleBackSoftkey()
   208 void LogsDetailsView::handleBackSoftkey()
   244 {
   209 {
   245     mViewManager.activatePreviousView();
   210     mViewManager.activatePreviousView();
       
   211 }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 void LogsDetailsView::deleteEventOkAnswer()
       
   218 {
       
   219     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::deleteEventOkAnswer()" );
       
   220     if (mDetailsModel) {
       
   221         mDetailsModel->clearEvent();
       
   222         handleBackSoftkey(); 
       
   223     }
       
   224     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::deleteEventOkAnswer()" );
   246 }
   225 }
   247 
   226 
   248 // -----------------------------------------------------------------------------
   227 // -----------------------------------------------------------------------------
   249 // 
   228 // 
   250 // -----------------------------------------------------------------------------
   229 // -----------------------------------------------------------------------------
   309     HbAction* internetCallAction = qobject_cast<HbAction*>( 
   288     HbAction* internetCallAction = qobject_cast<HbAction*>( 
   310             mRepository.findObject( logsDetailsViewInternetCallMenuActionId ) );
   289             mRepository.findObject( logsDetailsViewInternetCallMenuActionId ) );
   311     HbAction* messageAction = qobject_cast<HbAction*>( 
   290     HbAction* messageAction = qobject_cast<HbAction*>( 
   312             mRepository.findObject( logsCommonMessageMenuActionId ) );
   291             mRepository.findObject( logsCommonMessageMenuActionId ) );
   313     HbAction* addToContactsAction = qobject_cast<HbAction*>( 
   292     HbAction* addToContactsAction = qobject_cast<HbAction*>( 
   314             mRepository.findObject( logsDetailsAddToContactsMenuActionId ) );
   293             mRepository.findObject( logsCommonAddToContactsMenuActionId ) );
   315     HbAction* openContactAction = qobject_cast<HbAction*>( 
   294     HbAction* openContactAction = qobject_cast<HbAction*>( 
   316             mRepository.findObject( logsDetailsOpenContactMenuActionId ) );
   295             mRepository.findObject( logsDetailsOpenContactMenuActionId ) );
   317     
   296     
   318     bool voiceCallAvailable(false);
   297     bool voiceCallAvailable(false);
   319     bool videoCallAvailable(false);
   298     bool videoCallAvailable(false);
   328         }
   307         }
   329     }
   308     }
   330     
   309     
   331     bool contactCanBeAdded(false);
   310     bool contactCanBeAdded(false);
   332     bool contactCanBeOpened(false);
   311     bool contactCanBeOpened(false);
   333     if (mContact){
   312     if ( isDialpadInput() ){
       
   313         // Contact addition will be done using input field number
       
   314         contactCanBeAdded = true;
       
   315         // No need for voice call option in options menu as voice dialling
       
   316         // to dialpad num is possible from green button
       
   317         voiceCallAvailable = false;
       
   318     } else if (mContact){
   334         if (mContact->allowedRequestType() == LogsContact::TypeLogsContactSave){
   319         if (mContact->allowedRequestType() == LogsContact::TypeLogsContactSave){
   335             contactCanBeAdded = true;
   320             contactCanBeAdded = true;
   336         }
   321         }
   337         if (mContact->allowedRequestType() == LogsContact::TypeLogsContactOpen){
   322         if (mContact->allowedRequestType() == LogsContact::TypeLogsContactOpen){
   338             contactCanBeOpened = true;
   323             contactCanBeOpened = true;
   348     
   333     
   349     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::updateMenu()" );
   334     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::updateMenu()" );
   350 }
   335 }
   351 
   336 
   352 // -----------------------------------------------------------------------------
   337 // -----------------------------------------------------------------------------
       
   338 //
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 void LogsDetailsView::dialpadEditorTextChanged()
       
   342 {
       
   343     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::dialpadEditorTextChanged()" );
       
   344     if ( !tryMatchesViewTransition() ) {
       
   345         updateMenu();
       
   346         updateCallButton();  
       
   347     }
       
   348     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::dialpadEditorTextChanged()" );
       
   349 }
       
   350 
       
   351 // -----------------------------------------------------------------------------
   353 // LogsDetailsView::updateWidgetsSizeAndLayout
   352 // LogsDetailsView::updateWidgetsSizeAndLayout
   354 // -----------------------------------------------------------------------------
   353 // -----------------------------------------------------------------------------
   355 //
   354 //
   356 void LogsDetailsView::updateWidgetsSizeAndLayout()
   355 void LogsDetailsView::updateWidgetsSizeAndLayout()
   357 {
   356 {
   358     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::updateWidgetsSizeAndLayout()" );
   357     LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::updateWidgetsSizeAndLayout()" );
   359     if ( mListView ) {
   358     if ( mListView ) {
       
   359         updateMenu();
   360         updateListLayoutName(*mListView, true);
   360         updateListLayoutName(*mListView, true);
   361         updateListSize();
   361         updateListSize();
   362     }
   362     }
   363     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::updateWidgetsSizeAndLayout()" );
   363     LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::updateWidgetsSizeAndLayout()" );
   364 }
   364 }