From d9b5922d2baf16843e8f2dd79b67d2b18dafed46 Mon Sep 17 00:00:00 2001 From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> Date: Thu, 14 May 2015 15:40:23 -0400 Subject: [PATCH] history model: emit row remove and inserted signals emit these signals instead of reset model when reloading the categories, like the contacts model Refs #71950 --- src/categorizedcontactmodel.cpp | 2 -- src/categorizedhistorymodel.cpp | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/categorizedcontactmodel.cpp b/src/categorizedcontactmodel.cpp index d6e353eb..4a6f33da 100644 --- a/src/categorizedcontactmodel.cpp +++ b/src/categorizedcontactmodel.cpp @@ -259,7 +259,6 @@ ContactTreeNode* CategorizedContactModelPrivate::getContactTopLevelItem(const QS void CategorizedContactModelPrivate::reloadCategories() { emit q_ptr->layoutAboutToBeChanged(); //FIXME far from optimal - q_ptr->beginResetModel(); m_hCategories.clear(); q_ptr->beginRemoveRows(QModelIndex(),0,m_lCategoryCounter.size()-1); foreach(ContactTreeNode* item,m_lCategoryCounter) { @@ -271,7 +270,6 @@ void CategorizedContactModelPrivate::reloadCategories() Person* cont = qvariant_cast<Person*>(PersonModel::instance()->index(i,0).data((int)Person::Role::Object)); slotContactAdded(cont); } - q_ptr->endResetModel(); emit q_ptr->layoutChanged(); } diff --git a/src/categorizedhistorymodel.cpp b/src/categorizedhistorymodel.cpp index 3b0d612c..0e245d36 100644 --- a/src/categorizedhistorymodel.cpp +++ b/src/categorizedhistorymodel.cpp @@ -363,13 +363,15 @@ int CategorizedHistoryModel::historyLimit() const void CategorizedHistoryModelPrivate::reloadCategories() { - q_ptr->beginResetModel(); m_hCategories.clear(); m_hCategoryByName.clear(); + q_ptr->beginRemoveRows(QModelIndex(),0,m_lCategoryCounter.size()-1); foreach(HistoryTopLevelItem* item, m_lCategoryCounter) { delete item; } + q_ptr->endRemoveRows(); m_lCategoryCounter.clear(); + foreach(Call* call, m_sHistoryCalls) { HistoryTopLevelItem* category = getCategory(call); if (category) { @@ -378,12 +380,13 @@ void CategorizedHistoryModelPrivate::reloadCategories() item->m_pNode = new HistoryItemNode(q_ptr,call,item); connect(item->m_pNode,SIGNAL(changed(QModelIndex)),this,SLOT(slotChanged(QModelIndex))); item->m_pParent = category; - category->m_lChildren << item; + q_ptr->beginInsertRows(q_ptr->index(category->modelRow,0), item->m_Index, item->m_Index); { + category->m_lChildren << item; + } q_ptr->endInsertRows(); } else qDebug() << "ERROR count"; } - q_ptr->endResetModel(); emit q_ptr->layoutAboutToBeChanged(); emit q_ptr->layoutChanged(); emit q_ptr->dataChanged(q_ptr->index(0,0),q_ptr->index(q_ptr->rowCount()-1,0)); -- GitLab