logsui/logsengine/src/logsmatchesmodel.cpp
changeset 10 b04270301d3b
parent 4 e52d42f9500c
child 11 64a47b97e1e1
--- a/logsui/logsengine/src/logsmatchesmodel.cpp	Fri Jun 11 13:38:41 2010 +0300
+++ b/logsui/logsengine/src/logsmatchesmodel.cpp	Wed Jun 23 18:13:05 2010 +0300
@@ -675,12 +675,7 @@
         const LogsCntEntry& entry) const
 {    
     QString callerId;
-    foreach( LogsCntText name, entry.firstName() ) {
-        callerId.append( name.richText() );
-        if ( name.text().length() > 0 ) {
-            callerId.append(" ");
-        }
-    }
+    getFormattedName(callerId, entry.firstName());
     
     if  ( callerId.length() == 0 ) {
         callerId = entry.phoneNumber().richText();
@@ -699,20 +694,25 @@
         QString& contactNumber ) const
 {
     contactName.clear();
-    foreach( LogsCntText name, entry.firstName() ) {
-        contactName.append( name.richText() );
+    
+    getFormattedName(contactName, entry.firstName());
+    getFormattedName(contactName, entry.lastName());
+
+    contactName = contactName.trimmed();
+    contactNumber = entry.phoneNumber().text();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void  LogsMatchesModelItemContainer::getFormattedName(QString& formattedName, 
+        const QList<LogsCntText>& list) const
+{
+    foreach( LogsCntText name, list ) {
         if ( name.text().length() > 0 ) {
-            contactName.append(" ");
+            formattedName.append(name.richText());
+            formattedName.append(" ");
         }
     }
-    
-    foreach( LogsCntText lastname, entry.lastName() ) {
-        contactName.append( lastname.richText() );
-        if ( lastname.text().length() > 0 ) {
-            contactName.append(" ");
-        }
-    }
-    contactName = contactName.trimmed();
-    
-    contactNumber = entry.phoneNumber().text();
 }