Skip to content
Snippets Groups Projects
Commit d9b5922d authored by Stepan Salenikovich's avatar Stepan Salenikovich
Browse files

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
parent 937e726a
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
......
......@@ -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;
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));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment