diff --git a/src/categorizedcontactmodel.cpp b/src/categorizedcontactmodel.cpp index d6e353eb1189036ed14628726c8f24387d13bbe1..4a6f33da13901ff4baf5ddcf70be1257e1af5b09 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 3b0d612c7e254761660432887178b56b62b704ad..0e245d360b574967f9da9d6236b36159a033030b 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));