logsui/logsengine/src/logsdetailsmodel.cpp
changeset 16 c5af8598d22c
parent 6 41c0a814d878
child 19 e4c884866116
equal deleted inserted replaced
14:f27aebe284bb 16:c5af8598d22c
    76 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    77 //
    77 //
    78 void LogsDetailsModel::clearEvent()
    78 void LogsDetailsModel::clearEvent()
    79 {
    79 {
    80     LOGS_QDEBUG( "logs [ENG] -> LogsDetailsModel::clearEvent()" )
    80     LOGS_QDEBUG( "logs [ENG] -> LogsDetailsModel::clearEvent()" )
    81     QList<int> eventIds;
    81     QList<LogsEvent*> events;
    82     eventIds.append(mEvent->logId());
    82     events.append(mEvent);
    83     mDbConnector->clearEvents(eventIds);    
    83     mDbConnector->clearEvents(events);    
    84     LOGS_QDEBUG( "logs [ENG] <- LogsDetailsModel::clearEvent()" )
    84     LOGS_QDEBUG( "logs [ENG] <- LogsDetailsModel::clearEvent()" )
    85 }
    85 }
    86 
    86 
    87 // -----------------------------------------------------------------------------
    87 // -----------------------------------------------------------------------------
    88 // From QAbstractItemModel
    88 // From QAbstractItemModel
   154 
   154 
   155 // -----------------------------------------------------------------------------
   155 // -----------------------------------------------------------------------------
   156 //
   156 //
   157 // -----------------------------------------------------------------------------
   157 // -----------------------------------------------------------------------------
   158 //
   158 //
       
   159 void LogsDetailsModel::updateModel()
       
   160 {
       
   161     LOGS_QDEBUG( "logs [ENG] -> LogsDetailsModel::updateModel()" )
       
   162     initContent();
       
   163     reset();
       
   164     LOGS_QDEBUG( "logs [ENG] <- LogsDetailsModel::updateModel()" )
       
   165 }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 // -----------------------------------------------------------------------------
       
   170 //
   159 void LogsDetailsModel::contactActionCompleted(bool modified)
   171 void LogsDetailsModel::contactActionCompleted(bool modified)
   160 {
   172 {
   161     if ( modified ){
   173     if ( modified ){
   162         mEvent->prepareForContactMatching();
   174         mEvent->prepareForContactMatching();
   163         if ( mEvent->updateRemotePartyFromContacts(
   175         if ( mEvent->updateRemotePartyFromContacts(
   164                 LogsCommonData::getInstance().contactManager() ).length() > 0 ) {
   176                 LogsCommonData::getInstance().contactManager() ).length() > 0 ) {
   165             initContent();
   177             updateModel();
   166             reset();
       
   167         }
   178         }
   168     }
   179     }
   169 }
   180 }
   170 
   181 
   171 // -----------------------------------------------------------------------------
   182 // -----------------------------------------------------------------------------
   178     
   189     
   179     qDeleteAll( mDuplicates );
   190     qDeleteAll( mDuplicates );
   180     mDuplicates.clear();
   191     mDuplicates.clear();
   181     mDuplicates = mDbConnector->takeDuplicates();
   192     mDuplicates = mDbConnector->takeDuplicates();
   182     
   193     
   183     initContent();
   194     updateModel();
   184     reset();
       
   185     
   195     
   186     // Someone else might be reading duplicates as well, don't interfere with them.
   196     // Someone else might be reading duplicates as well, don't interfere with them.
   187     disconnect( mDbConnector, SIGNAL(duplicatesRead()), this, SLOT(duplicatesRead()) );
   197     disconnect( mDbConnector, SIGNAL(duplicatesRead()), this, SLOT(duplicatesRead()) );
   188 
   198 
   189     LOGS_QDEBUG( "logs [ENG] <- LogsDetailsModel::duplicatesRead()" )
   199     LOGS_QDEBUG( "logs [ENG] <- LogsDetailsModel::duplicatesRead()" )
   220 //
   230 //
   221 QString LogsDetailsModel::getCallerId(const LogsEvent& event) const
   231 QString LogsDetailsModel::getCallerId(const LogsEvent& event) const
   222 {
   232 {
   223     QString callerId("");
   233     QString callerId("");
   224     if (event.remoteParty().length() > 0 && event.number().length() > 0){
   234     if (event.remoteParty().length() > 0 && event.number().length() > 0){
   225     	callerId = event.number();
   235     	callerId = phoneNumString(event.number());
   226     }
   236     }
   227     
   237     
   228     if (event.remoteParty().length() > 0 && getRemoteUri(event).length() > 0){
   238     if (event.remoteParty().length() > 0 && getRemoteUri(event).length() > 0){
   229     	callerId = getRemoteUri(event);
   239     	callerId = getRemoteUri(event);
   230     }
   240     }
   245     if ( event.isRemotePartyPrivate() ){
   255     if ( event.isRemotePartyPrivate() ){
   246         headerdata = hbTrId("txt_dial_dblist_call_id_val_privat_number");
   256         headerdata = hbTrId("txt_dial_dblist_call_id_val_privat_number");
   247     }
   257     }
   248     
   258     
   249     if ( headerdata.length() == 0 && event.number().length() > 0 ){
   259     if ( headerdata.length() == 0 && event.number().length() > 0 ){
   250         headerdata = event.number();
   260         headerdata = phoneNumString(event.number());
   251     }
   261     }
   252     
   262     
   253     if ( headerdata.length() == 0 ){
   263     if ( headerdata.length() == 0 ){
   254         headerdata = getRemoteUri(event);
   264         headerdata = getRemoteUri(event);
   255     }
   265     }
   279 //
   289 //
   280 void LogsDetailsModel::getNumberToClipboard()
   290 void LogsDetailsModel::getNumberToClipboard()
   281 {
   291 {
   282     HbLineEdit *cliptmp = new HbLineEdit("");
   292     HbLineEdit *cliptmp = new HbLineEdit("");
   283  
   293  
   284     QString num = mEvent->getNumberForCalling(); 
   294     // Localize digits only if it is used only used in CS context (don't 
       
   295     // localize any VoIP uri, not even if it would be tel uri).
       
   296     QString num = mEvent->number();
       
   297     if ( num.isEmpty() ){
       
   298         num = mEvent->getNumberForCalling();
       
   299     } else {
       
   300         num = phoneNumString(num);
       
   301     }
       
   302     
   285     cliptmp->setText(num);
   303     cliptmp->setText(num);
   286     cliptmp->setSelection(0, num.length());
   304     cliptmp->setSelection(0, num.length());
   287     cliptmp->copy();
   305     cliptmp->copy();
   288     delete cliptmp;
   306     delete cliptmp;
   289 }
   307 }
   357         QStringList remotePartyRow;
   375         QStringList remotePartyRow;
   358         remotePartyRow << getHeaderValue(getCallerId(*mEvent),true);
   376         remotePartyRow << getHeaderValue(getCallerId(*mEvent),true);
   359         remotePartyRow << getCallerId(*mEvent);
   377         remotePartyRow << getCallerId(*mEvent);
   360         mDetailTexts.append(remotePartyRow);
   378         mDetailTexts.append(remotePartyRow);
   361 	}
   379 	}
   362 	
   380 
   363 	// TODO: if more than one date and time rows, first row has text "Last call event"
       
   364 	// but there's no localization string for that yet
       
   365 	bool firstOfMultipleDates( mDuplicates.count() > 0 );
   381 	bool firstOfMultipleDates( mDuplicates.count() > 0 );
   366 	addDateAndTimeTextRow(*mEvent, firstOfMultipleDates);
   382 	addDateAndTimeTextRow(*mEvent, firstOfMultipleDates);
   367     
   383     
   368     QStringList callDirectionRow;
   384     QStringList callDirectionRow;
   369     callDirectionRow << hbTrId("txt_dialer_ui_dblist_call_direction");
   385     callDirectionRow << hbTrId("txt_dialer_ui_dblist_call_direction");
   378     if ( mEvent->direction() != LogsEvent::DirMissed ){
   394     if ( mEvent->direction() != LogsEvent::DirMissed ){
   379         QStringList callDurationRow;
   395         QStringList callDurationRow;
   380         callDurationRow << hbTrId("txt_dialer_ui_dblist_call_duration");
   396         callDurationRow << hbTrId("txt_dialer_ui_dblist_call_duration");
   381         QTime n(0, 0, 0);
   397         QTime n(0, 0, 0);
   382         QTime t = n.addSecs(mEvent->duration());                
   398         QTime t = n.addSecs(mEvent->duration());                
   383         callDurationRow << t.toString("hh:mm:ss");
   399         callDurationRow << durationString(t);
   384         mDetailTexts.append(callDurationRow);
   400         mDetailTexts.append(callDurationRow);
   385     }
   401     }
   386     
   402     
   387     foreach ( LogsEvent* event, mDuplicates ){
   403     foreach ( LogsEvent* event, mDuplicates ){
   388         addDateAndTimeTextRow(*event);
   404         addDateAndTimeTextRow(*event);
   433     if ( firstOfMultipleDates ){
   449     if ( firstOfMultipleDates ){
   434         dateAndTimeRow << hbTrId("txt_dial_dblist_last_call_event");
   450         dateAndTimeRow << hbTrId("txt_dial_dblist_last_call_event");
   435     } else {
   451     } else {
   436         dateAndTimeRow << hbTrId("txt_dialer_ui_dblist_date_and_time");
   452         dateAndTimeRow << hbTrId("txt_dialer_ui_dblist_date_and_time");
   437     }
   453     }
   438     dateAndTimeRow << event.time().toTimeSpec(Qt::LocalTime).toString();
   454     dateAndTimeRow << dateAndTimeString( event.time().toTimeSpec(Qt::LocalTime) );
   439     mDetailTexts.append(dateAndTimeRow);
   455     mDetailTexts.append(dateAndTimeRow);
   440 }
   456 }