Fix GxsForumModel::setMsgReadStatus dataChanged call

This commit is contained in:
Phenom 2020-05-21 19:07:03 +02:00
parent ad1672a0a4
commit 319ebd66f6

View File

@ -1225,7 +1225,7 @@ void RsGxsForumModel::setMsgReadStatus(const QModelIndex& i,bool read_status,boo
if(!i.isValid())
return ;
// no need to call preMods()/postMods() here because we'renot changing the model
// no need to call preMods()/postMods() here because we'renot changing the model
void *ref = i.internalPointer();
uint32_t entry = 0;
@ -1233,18 +1233,10 @@ void RsGxsForumModel::setMsgReadStatus(const QModelIndex& i,bool read_status,boo
if(!convertRefPointerToTabEntry(ref,entry) || entry >= mPosts.size())
return ;
bool has_unread_below,has_read_below;
recursSetMsgReadStatus(entry,read_status,with_children) ;
bool has_unread_below, has_read_below;
recursSetMsgReadStatus(entry,read_status,with_children) ;
recursUpdateReadStatusAndTimes(0,has_unread_below,has_read_below);
// Normally we should only update the parents up to the top of the tree, but it's complicated and the update here doesn't really cost,
// so we blindly update the whole widget.
if(mTreeMode == TREE_MODE_FLAT)
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts.size(),COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
else
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts[0].mChildren.size(),COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
}
void RsGxsForumModel::recursSetMsgReadStatus(ForumModelIndex i,bool read_status,bool with_children)
@ -1270,6 +1262,9 @@ void RsGxsForumModel::recursSetMsgReadStatus(ForumModelIndex i,bool read_status,
}
else
rsGxsForums->setMessageReadStatus(token,std::make_pair( mForumGroup.mMeta.mGroupId, mPosts[i].mMsgId ), read_status);
QModelIndex itemIndex = createIndex(i - 1, 0, &mPosts[i]);
emit dataChanged(itemIndex, itemIndex);
}
if(!with_children)