mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-24 22:30:42 -04:00
Add Save Selected Post in current Forum when switch to other.
This commit is contained in:
parent
1ee38877ca
commit
ee6f83aab4
2 changed files with 90 additions and 69 deletions
|
@ -908,6 +908,7 @@ void GxsForumThreadWidget::changedThread(QModelIndex index)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mThreadId = mOrigThreadId = new_id;
|
mThreadId = mOrigThreadId = new_id;
|
||||||
|
mLastSelectedPosts[groupId()] = new_id;
|
||||||
|
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef DEBUG_FORUMS
|
||||||
std::cerr << "Switched to new thread ID " << mThreadId << std::endl;
|
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);
|
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->scrollTo(ui->threadTreeWidget->currentIndex());//May change if model reloaded
|
||||||
ui->threadTreeWidget->setFocus();
|
ui->threadTreeWidget->setFocus();
|
||||||
|
|
||||||
|
mNavigatePendingMsgId.clear();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1813,6 +1817,17 @@ void GxsForumThreadWidget::changedViewBox()
|
||||||
mThreadModel->setSortMode(RsGxsForumModel::SORT_MODE_CHILDREN_PUBLISH_TS);
|
mThreadModel->setSortMode(RsGxsForumModel::SORT_MODE_CHILDREN_PUBLISH_TS);
|
||||||
else
|
else
|
||||||
mThreadModel->setSortMode(RsGxsForumModel::SORT_MODE_PUBLISH_TS);
|
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)
|
void GxsForumThreadWidget::filterColumnChanged(int column)
|
||||||
|
@ -1877,19 +1892,24 @@ void GxsForumThreadWidget::postForumLoading()
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef DEBUG_FORUMS
|
||||||
std::cerr << "Post forum loading..." << std::endl;
|
std::cerr << "Post forum loading..." << std::endl;
|
||||||
#endif
|
#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
|
#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
|
#endif
|
||||||
|
|
||||||
QModelIndex source_index = mThreadModel->getIndexOfMessage(mNavigatePendingMsgId);
|
QModelIndex source_index = mThreadModel->getIndexOfMessage(mLastSelectedPosts[groupId()]);
|
||||||
QModelIndex index = mThreadProxyModel->mapFromSource(source_index);
|
QModelIndex index = mThreadProxyModel->mapFromSource(source_index);
|
||||||
|
|
||||||
ui->threadTreeWidget->selectionModel()->setCurrentIndex(index,QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
ui->threadTreeWidget->selectionModel()->setCurrentIndex(index,QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||||
ui->threadTreeWidget->scrollTo(ui->threadTreeWidget->currentIndex());//May change if model reloaded
|
ui->threadTreeWidget->scrollTo(ui->threadTreeWidget->currentIndex());//May change if model reloaded
|
||||||
|
|
||||||
mNavigatePendingMsgId.clear();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -224,6 +224,7 @@ private:
|
||||||
QColor mBackgroundColorPinned;
|
QColor mBackgroundColorPinned;
|
||||||
QColor mBackgroundColorFiltered;
|
QColor mBackgroundColorFiltered;
|
||||||
|
|
||||||
|
std::map<RsGxsGroupId,RsGxsMessageId> mLastSelectedPosts;
|
||||||
RsGxsMessageId mNavigatePendingMsgId;
|
RsGxsMessageId mNavigatePendingMsgId;
|
||||||
QList<RsGxsMessageId> mIgnoredMsgId;
|
QList<RsGxsMessageId> mIgnoredMsgId;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue