phonebookui/cnthistorymodel/src/cnthistorymodel.cpp
changeset 46 efe85016a067
parent 40 b46a585f6909
child 47 7cbcb2896f0e
--- a/phonebookui/cnthistorymodel/src/cnthistorymodel.cpp	Fri Jun 11 13:29:23 2010 +0300
+++ b/phonebookui/cnthistorymodel/src/cnthistorymodel.cpp	Wed Jun 23 18:02:44 2010 +0300
@@ -321,6 +321,7 @@
             this, SLOT(logsRowsRemoved(const QModelIndex &, int, int)));
     connect(d->m_AbstractLogsModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), 
                 this, SLOT(logsDataChanged(const QModelIndex &, const QModelIndex &)));
+    connect(d->m_AbstractLogsModel, SIGNAL(modelReset()), this, SLOT(handleLogsReset()));
 
 }
 
@@ -474,6 +475,36 @@
     }
 }
 
+/*
+ * Clear all call logs after receiving a reset model
+ * signal from logs model
+ */
+void CntHistoryModel::handleLogsReset()
+{
+    // Remove all call logs
+    QList<HItemPointer> values = d->m_logsMap.values();
+    foreach(HItemPointer p, values) {
+        d->m_List.removeOne( p );
+    }
+    
+    d->m_logsMap.clear();
+    
+    //read first call events if any and start listening for more 
+    for ( int i = 0; i < d->m_AbstractLogsModel->rowCount(); ++i ) {
+        LogsEvent* event = qVariantValue<LogsEvent*>(
+                d->m_AbstractLogsModel->data(d->m_AbstractLogsModel->index(i, 0), LogsModel::RoleFullEvent) );
+        
+        if ( event ) {
+            HItemPointer item = HItemPointer(new HistoryItem());
+            readLogEvent(event, *item);
+            d->m_logsMap.insert(i, item);
+            d->m_List.append( item );
+        }
+    }
+    
+    sortAndRefresh();
+}
+
 /*!
  * Check whether an idex is out of bound of our list
  *