fixed bug causing link to forum post not to load the post on click if another forum is currently loaed

This commit is contained in:
csoler 2019-01-27 20:03:23 +01:00
parent bf1c433849
commit 0816c44d10
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C

View file

@ -1500,6 +1500,8 @@ bool GxsForumThreadWidget::navigate(const RsGxsMessageId &msgId)
if(!source_index.isValid()) if(!source_index.isValid())
{ {
std::cerr << "Cannot navigate to msg " << msgId << " in forum " << mForumGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl;
mNavigatePendingMsgId = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading. mNavigatePendingMsgId = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
return true; // we have to return true here, otherwise the caller will intepret the async loading as an error. return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
} }
@ -1855,9 +1857,19 @@ void GxsForumThreadWidget::postForumLoading()
#endif #endif
if(!mNavigatePendingMsgId.isNull() && mThreadModel->getIndexOfMessage(mNavigatePendingMsgId).isValid()) if(!mNavigatePendingMsgId.isNull() && mThreadModel->getIndexOfMessage(mNavigatePendingMsgId).isValid())
{ {
mThreadId = mNavigatePendingMsgId; std::cerr << "Pending msg navigation: " << mNavigatePendingMsgId << ". Using it as new thread Id" << std::endl;
QModelIndex source_index = mThreadModel->getIndexOfMessage(mNavigatePendingMsgId);
QModelIndex index = mThreadProxyModel->mapFromSource(source_index);
ui->threadTreeWidget->selectionModel()->setCurrentIndex(index,QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
ui->threadTreeWidget->scrollTo(index);
changedThread(index);
mNavigatePendingMsgId.clear(); mNavigatePendingMsgId.clear();
} }
else
{
QModelIndex source_index = mThreadModel->getIndexOfMessage(mThreadId); QModelIndex source_index = mThreadModel->getIndexOfMessage(mThreadId);
@ -1881,6 +1893,7 @@ void GxsForumThreadWidget::postForumLoading()
//blank(); //blank();
} }
// we also need to restore expanded threads // we also need to restore expanded threads
}
ui->forumName->setText(QString::fromUtf8(mForumGroup.mMeta.mGroupName.c_str())); ui->forumName->setText(QString::fromUtf8(mForumGroup.mMeta.mGroupName.c_str()));
ui->threadTreeWidget->sortByColumn(RsGxsForumModel::COLUMN_THREAD_DATE, Qt::DescendingOrder); ui->threadTreeWidget->sortByColumn(RsGxsForumModel::COLUMN_THREAD_DATE, Qt::DescendingOrder);