319 this, SLOT(logsRowsInserted(const QModelIndex &, int, int))); |
319 this, SLOT(logsRowsInserted(const QModelIndex &, int, int))); |
320 connect(d->m_AbstractLogsModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), |
320 connect(d->m_AbstractLogsModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), |
321 this, SLOT(logsRowsRemoved(const QModelIndex &, int, int))); |
321 this, SLOT(logsRowsRemoved(const QModelIndex &, int, int))); |
322 connect(d->m_AbstractLogsModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), |
322 connect(d->m_AbstractLogsModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), |
323 this, SLOT(logsDataChanged(const QModelIndex &, const QModelIndex &))); |
323 this, SLOT(logsDataChanged(const QModelIndex &, const QModelIndex &))); |
|
324 connect(d->m_AbstractLogsModel, SIGNAL(modelReset()), this, SLOT(handleLogsReset())); |
324 |
325 |
325 } |
326 } |
326 |
327 |
327 /*! |
328 /*! |
328 * Read call event into a history item |
329 * Read call event into a history item |
472 foreach( QList<int> l, batches ) |
473 foreach( QList<int> l, batches ) |
473 emit dataChanged( index(l.first(), 0), index(l.last(), 0) ); |
474 emit dataChanged( index(l.first(), 0), index(l.last(), 0) ); |
474 } |
475 } |
475 } |
476 } |
476 |
477 |
|
478 /* |
|
479 * Clear all call logs after receiving a reset model |
|
480 * signal from logs model |
|
481 */ |
|
482 void CntHistoryModel::handleLogsReset() |
|
483 { |
|
484 // Remove all call logs |
|
485 QList<HItemPointer> values = d->m_logsMap.values(); |
|
486 foreach(HItemPointer p, values) { |
|
487 d->m_List.removeOne( p ); |
|
488 } |
|
489 |
|
490 d->m_logsMap.clear(); |
|
491 |
|
492 //read first call events if any and start listening for more |
|
493 for ( int i = 0; i < d->m_AbstractLogsModel->rowCount(); ++i ) { |
|
494 LogsEvent* event = qVariantValue<LogsEvent*>( |
|
495 d->m_AbstractLogsModel->data(d->m_AbstractLogsModel->index(i, 0), LogsModel::RoleFullEvent) ); |
|
496 |
|
497 if ( event ) { |
|
498 HItemPointer item = HItemPointer(new HistoryItem()); |
|
499 readLogEvent(event, *item); |
|
500 d->m_logsMap.insert(i, item); |
|
501 d->m_List.append( item ); |
|
502 } |
|
503 } |
|
504 |
|
505 sortAndRefresh(); |
|
506 } |
|
507 |
477 /*! |
508 /*! |
478 * Check whether an idex is out of bound of our list |
509 * Check whether an idex is out of bound of our list |
479 * |
510 * |
480 * \param index Index to be validated |
511 * \param index Index to be validated |
481 */ |
512 */ |