30 #include <hbicon.h> |
30 #include <hbicon.h> |
31 #include <QStringList> |
31 #include <QStringList> |
32 #include <QtGui> |
32 #include <QtGui> |
33 #include <hbfontspec.h> |
33 #include <hbfontspec.h> |
34 #include <hbinstance.h> |
34 #include <hbinstance.h> |
|
35 #include <hbstringutil.h> |
35 |
36 |
36 Q_DECLARE_METATYPE(LogsEvent *) |
37 Q_DECLARE_METATYPE(LogsEvent *) |
37 Q_DECLARE_METATYPE(LogsCall *) |
38 Q_DECLARE_METATYPE(LogsCall *) |
38 Q_DECLARE_METATYPE(LogsDetailsModel *) |
39 Q_DECLARE_METATYPE(LogsDetailsModel *) |
39 Q_DECLARE_METATYPE(LogsMessage *) |
40 Q_DECLARE_METATYPE(LogsMessage *) |
92 bool LogsModel::clearList(LogsModel::ClearType cleartype) |
93 bool LogsModel::clearList(LogsModel::ClearType cleartype) |
93 { |
94 { |
94 LOGS_QDEBUG( "logs [ENG] -> LogsModel::clearList()" ) |
95 LOGS_QDEBUG( "logs [ENG] -> LogsModel::clearList()" ) |
95 |
96 |
96 connect( mDbConnector, SIGNAL(clearingCompleted(int)), |
97 connect( mDbConnector, SIGNAL(clearingCompleted(int)), |
97 this, SIGNAL(clearingCompleted(int)) ); |
98 this, SIGNAL(clearingCompleted(int)), |
|
99 Qt::UniqueConnection ); |
98 return mDbConnector->clearList(cleartype); |
100 return mDbConnector->clearList(cleartype); |
99 } |
101 } |
100 |
102 |
101 // ----------------------------------------------------------------------------- |
103 // ----------------------------------------------------------------------------- |
102 // |
104 // |
104 // |
106 // |
105 bool LogsModel::markEventsSeen(LogsModel::ClearType cleartype) |
107 bool LogsModel::markEventsSeen(LogsModel::ClearType cleartype) |
106 { |
108 { |
107 LOGS_QDEBUG( "logs [ENG] -> LogsModel::markEventsSeen()" ) |
109 LOGS_QDEBUG( "logs [ENG] -> LogsModel::markEventsSeen()" ) |
108 |
110 |
109 QList<int> markedEvents; |
111 QList<LogsEvent*> markedEvents; |
110 foreach ( LogsEvent* event, mEvents ){ |
112 foreach ( LogsEvent* event, mEvents ){ |
111 if ( matchEventWithClearType(*event, cleartype) && !event->isSeenLocally() ){ |
113 if ( matchEventWithClearType(*event, cleartype) && !event->isSeenLocally() ){ |
112 markedEvents.append(event->logId()); |
114 markedEvents.append(event); |
113 } |
115 } |
114 } |
116 } |
115 connect( mDbConnector, SIGNAL(markingCompleted(int)), |
117 connect( mDbConnector, SIGNAL(markingCompleted(int)), |
116 this, SIGNAL(markingCompleted(int)) ); |
118 this, SIGNAL(markingCompleted(int)), |
|
119 Qt::UniqueConnection ); |
117 bool retVal = mDbConnector->markEventsSeen(markedEvents); |
120 bool retVal = mDbConnector->markEventsSeen(markedEvents); |
118 LOGS_QDEBUG_2( "logs [ENG] <- LogsModel::markEventsSeen()", retVal ) |
121 LOGS_QDEBUG_2( "logs [ENG] <- LogsModel::markEventsSeen()", retVal ) |
119 return retVal; |
122 return retVal; |
120 } |
123 } |
121 |
124 |
160 // ----------------------------------------------------------------------------- |
163 // ----------------------------------------------------------------------------- |
161 // |
164 // |
162 int LogsModel::updateConfiguration(LogsConfigurationParams& params) |
165 int LogsModel::updateConfiguration(LogsConfigurationParams& params) |
163 { |
166 { |
164 LOGS_QDEBUG( "logs [ENG] -> LogsModel::updateConfiguration()" ) |
167 LOGS_QDEBUG( "logs [ENG] -> LogsModel::updateConfiguration()" ) |
165 int currWidth = |
168 int retVal = 0; |
166 LogsCommonData::getInstance().currentConfiguration().listItemTextWidth(); |
169 if (params.localeChanged()) { |
167 int newWidth = params.listItemTextWidth(); |
170 LOGS_QDEBUG( "logs [ENG] -> Locale changed, have to update model" ) |
168 LOGS_QDEBUG_3( "logs [ENG] Curr and new width", currWidth, newWidth ) |
171 updateModel(); |
169 int retVal = LogsCommonData::getInstance().updateConfiguration(params); |
172 } else { |
170 |
173 int currWidth = |
171 // Do model reset if list item width has changed as we need to ensure |
174 LogsCommonData::getInstance().currentConfiguration().listItemTextWidth(); |
172 // missed call's duplicate info visibility |
175 int newWidth = params.listItemTextWidth(); |
173 bool unseenExists = false; |
176 LOGS_QDEBUG_3( "logs [ENG] Curr and new width", currWidth, newWidth ) |
174 for ( int i = 0; i < mEvents.count() && !unseenExists; i++ ){ |
177 retVal = LogsCommonData::getInstance().updateConfiguration(params); |
175 LogsEvent* event = mEvents.at(i); |
178 |
176 if ( event->duplicates() > 0 && !event->isSeenLocally() ){ |
179 // Do model reset if list item width has changed as we need to ensure |
177 unseenExists = true; |
180 // missed call's duplicate info visibility |
178 } |
181 bool unseenExists = false; |
179 } |
182 for ( int i = 0; i < mEvents.count() && !unseenExists; i++ ){ |
180 if ( unseenExists && currWidth > 0 && currWidth != newWidth ){ |
183 LogsEvent* event = mEvents.at(i); |
181 LOGS_QDEBUG( "logs [ENG] Do model reset" ) |
184 if ( event->duplicates() > 0 && !event->isSeenLocally() ){ |
182 resetModel(); |
185 unseenExists = true; |
|
186 } |
|
187 } |
|
188 if ( unseenExists && newWidth > 0 && currWidth != newWidth ){ |
|
189 LOGS_QDEBUG( "logs [ENG] Do model reset" ) |
|
190 resetModel(); |
|
191 } |
183 } |
192 } |
184 LOGS_QDEBUG( "logs [ENG] <- LogsModel::updateConfiguration()" ) |
193 LOGS_QDEBUG( "logs [ENG] <- LogsModel::updateConfiguration()" ) |
185 return retVal; |
194 return retVal; |
186 } |
195 } |
187 |
196 |
340 // |
349 // |
341 QString LogsModel::getCallerId(const LogsEvent& event) const |
350 QString LogsModel::getCallerId(const LogsEvent& event) const |
342 { |
351 { |
343 QString callerId(event.remoteParty()); |
352 QString callerId(event.remoteParty()); |
344 if ( callerId.length() == 0 ){ |
353 if ( callerId.length() == 0 ){ |
345 callerId = event.number(); |
354 callerId = phoneNumString(event.number()); |
346 } |
355 } |
347 if ( callerId.length() == 0 && event.logsEventData() ){ |
356 if ( callerId.length() == 0 && event.logsEventData() ){ |
348 callerId = event.logsEventData()->remoteUrl(); |
357 callerId = event.logsEventData()->remoteUrl(); |
349 } |
358 } |
350 if ( callerId.length() == 0 ){ |
359 if ( callerId.length() == 0 ){ |
357 |
366 |
358 } |
367 } |
359 int duplicates = event.duplicates(); |
368 int duplicates = event.duplicates(); |
360 if ( duplicates > 0 && !event.isSeenLocally() ){ |
369 if ( duplicates > 0 && !event.isSeenLocally() ){ |
361 QString callerIdBaseString = callerId; |
370 QString callerIdBaseString = callerId; |
362 QString callerIdDupString = "(" + QString::number(duplicates + 1) + ")"; |
371 QString callerIdDupString = "(" + |
|
372 HbStringUtil::convertDigits(QString::number(duplicates + 1)) + ")"; |
363 int width = LogsCommonData::getInstance().currentConfiguration().listItemTextWidth(); |
373 int width = LogsCommonData::getInstance().currentConfiguration().listItemTextWidth(); |
364 callerId = SqueezedString(callerIdBaseString,callerIdDupString,width); |
374 callerId = SqueezedString(callerIdBaseString,callerIdDupString,width); |
365 } |
375 } |
366 return callerId; |
376 return callerId; |
367 } |
377 } |