mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Add Save Selected Post in current Forum when switch to other.
This commit is contained in:
parent
1ee38877ca
commit
ee6f83aab4
@ -908,6 +908,7 @@ void GxsForumThreadWidget::changedThread(QModelIndex index)
|
||||
return;
|
||||
|
||||
mThreadId = mOrigThreadId = new_id;
|
||||
mLastSelectedPosts[groupId()] = new_id;
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "Switched to new thread ID " << mThreadId << std::endl;
|
||||
@ -1504,9 +1505,12 @@ bool GxsForumThreadWidget::navigate(const RsGxsMessageId &msgId)
|
||||
|
||||
QModelIndex indx = mThreadProxyModel->mapFromSource(source_index);
|
||||
|
||||
ui->threadTreeWidget->setCurrentIndex(indx);
|
||||
ui->threadTreeWidget->selectionModel()->setCurrentIndex(indx,QItemSelectionModel::ClearAndSelect);
|
||||
ui->threadTreeWidget->scrollTo(ui->threadTreeWidget->currentIndex());//May change if model reloaded
|
||||
ui->threadTreeWidget->setFocus();
|
||||
|
||||
mNavigatePendingMsgId.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1813,6 +1817,17 @@ void GxsForumThreadWidget::changedViewBox()
|
||||
mThreadModel->setSortMode(RsGxsForumModel::SORT_MODE_CHILDREN_PUBLISH_TS);
|
||||
else
|
||||
mThreadModel->setSortMode(RsGxsForumModel::SORT_MODE_PUBLISH_TS);
|
||||
|
||||
if( (mLastSelectedPosts.count(groupId()) > 0)
|
||||
&& !mLastSelectedPosts[groupId()].isNull()
|
||||
&& mThreadModel->getIndexOfMessage(mLastSelectedPosts[groupId()]).isValid())
|
||||
{
|
||||
QModelIndex source_index = mThreadModel->getIndexOfMessage(mLastSelectedPosts[groupId()]);
|
||||
QModelIndex index = mThreadProxyModel->mapFromSource(source_index);
|
||||
|
||||
ui->threadTreeWidget->selectionModel()->setCurrentIndex(index,QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||
ui->threadTreeWidget->scrollTo(ui->threadTreeWidget->currentIndex());//May change if model reloaded
|
||||
}
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::filterColumnChanged(int column)
|
||||
@ -1877,19 +1892,24 @@ void GxsForumThreadWidget::postForumLoading()
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "Post forum loading..." << std::endl;
|
||||
#endif
|
||||
if(!mNavigatePendingMsgId.isNull() && mThreadModel->getIndexOfMessage(mNavigatePendingMsgId).isValid())
|
||||
|
||||
if (!mNavigatePendingMsgId.isNull())
|
||||
navigate(mNavigatePendingMsgId);
|
||||
|
||||
else if( (mLastSelectedPosts.count(groupId()) > 0)
|
||||
&& !mLastSelectedPosts[groupId()].isNull()
|
||||
&& mThreadModel->getIndexOfMessage(mLastSelectedPosts[groupId()]).isValid())
|
||||
{
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "Pending msg navigation: " << mNavigatePendingMsgId << ". Using it as new thread Id" << std::endl;
|
||||
std::cerr << "Last selected msg navigation: " << mLastSelectedPosts[groupId()].toStdString() << ". Using it as new thread Id" << std::endl;
|
||||
#endif
|
||||
|
||||
QModelIndex source_index = mThreadModel->getIndexOfMessage(mNavigatePendingMsgId);
|
||||
QModelIndex source_index = mThreadModel->getIndexOfMessage(mLastSelectedPosts[groupId()]);
|
||||
QModelIndex index = mThreadProxyModel->mapFromSource(source_index);
|
||||
|
||||
ui->threadTreeWidget->selectionModel()->setCurrentIndex(index,QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||
ui->threadTreeWidget->scrollTo(ui->threadTreeWidget->currentIndex());//May change if model reloaded
|
||||
|
||||
mNavigatePendingMsgId.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -224,6 +224,7 @@ private:
|
||||
QColor mBackgroundColorPinned;
|
||||
QColor mBackgroundColorFiltered;
|
||||
|
||||
std::map<RsGxsGroupId,RsGxsMessageId> mLastSelectedPosts;
|
||||
RsGxsMessageId mNavigatePendingMsgId;
|
||||
QList<RsGxsMessageId> mIgnoredMsgId;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user