phonebookui/cnthistorymodel/src/cnthistorymodel_p.cpp
changeset 59 a642906a277a
parent 47 7cbcb2896f0e
child 61 d30183af6ca6
--- a/phonebookui/cnthistorymodel/src/cnthistorymodel_p.cpp	Tue Jul 06 14:05:47 2010 +0300
+++ b/phonebookui/cnthistorymodel/src/cnthistorymodel_p.cpp	Wed Aug 18 09:39:00 2010 +0300
@@ -22,6 +22,7 @@
 #include <hbframebackground.h>
 
 #include "cnthistorymodel_p.h"
+#include "cntdebug.h"
 
 
 // Unnamed namespace for helper functions
@@ -36,6 +37,33 @@
     {
         return ((*t1).timeStamp < (*t2).timeStamp);
     }
+    
+#ifdef TRACES
+#define LOG_ITEM(i) logItem(i)
+#else
+#define LOG_ITEM(i)
+#endif
+    
+    void logItem(const HistoryItem& item)
+    {
+        QStringList l;
+        
+        l << item.message << item.number << item.timeStamp.toString() << item.title;
+        l << (item.flags & CntIncoming ? "incoming" : "outgoing");
+        l << (item.flags & CntUnseen ? "unseen" : "seen");
+        l << (item.flags & CntAttachment ? "attachment" : "");
+        l << (item.flags & CntCallLog ? "call" : "message");
+        if (item.flags & CntReceivedCall)
+            l << "recieved";
+        else if (item.flags & CntMissedCall)
+            l << "missed";
+        else if (item.flags & CntDialledCall)
+            l << "dialled";
+        
+        l.removeAll("");
+        
+        qDebug() << l;
+    }
 }
 
 Q_DECLARE_METATYPE(LogsEvent *)
@@ -382,16 +410,20 @@
         }
     }
 
-    if ( event->direction() == LogsEvent::DirOut )
-        item.flags |= CntOutgoing;
-    else
+    if ( event->direction() == LogsEvent::DirMissed
+        || event->direction() == LogsEvent::DirIn ) {
         item.flags |= CntIncoming;
+    } else {
+        item.flags &= ~CntIncoming;
+    }
     
     item.message = bodyText;
     item.title = title;
     item.timeStamp = event->time().toLocalTime();
     item.flags |= CntCallLog;
     item.number = QString(event->number());
+    
+    LOG_ITEM(item);
 }
 
 /*!
@@ -604,7 +636,7 @@
         else
             item.flags &= ~CntUnseen;
     } else if ( event.direction() == MsgItem::MsgDirectionOutgoing )
-        item.flags |= CntOutgoing;
+        item.flags &= ~CntIncoming;
     
     // Attachment
     if (event.isAttributeSet(MsgItem::MsgAttributeAttachment))
@@ -623,6 +655,8 @@
     }
     
     item.timeStamp = event.timeStamp().toLocalTime();
+    
+    LOG_ITEM(item);
 }
 
 /*!