From 8deeec61c51fc648eccd95f9ce3b39e60ab693b3 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 9 Feb 2017 18:45:55 +0100 Subject: [PATCH] fixed UI for post versions --- .../gui/gxsforums/GxsForumThreadWidget.cpp | 24 +++++++++++++++---- .../src/gui/gxsforums/GxsForumThreadWidget.h | 1 + .../src/gui/gxsforums/GxsForumThreadWidget.ui | 14 +++++------ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 9e731a0c7..b99af03f4 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -701,10 +701,16 @@ void GxsForumThreadWidget::changedThread() mThreadId.clear(); if(ui->versions_CB->count() > 0) + { mThreadId = RsGxsMessageId(ui->versions_CB->itemData(ui->versions_CB->currentIndex()).toString().toStdString()) ; + mOrigThreadId = RsGxsMessageId(ui->versions_CB->itemData(0).toString().toStdString()) ; + } if(mThreadId.isNull()) + { mThreadId = RsGxsMessageId(item->data(COLUMN_THREAD_MSGID, Qt::DisplayRole).toString().toStdString()); + mOrigThreadId = mThreadId ; + } } if (mFillThread) { @@ -1579,8 +1585,12 @@ void GxsForumThreadWidget::insertMessage() std::cerr << "Looking into existing versions for post " << mThreadId << ", thread history: " << mPostVersions.size() << std::endl; - QMap > >::const_iterator it = mPostVersions.find(mThreadId) ; - ui->versions_CB->clear(); + QMap > >::const_iterator it = mPostVersions.find(mOrigThreadId) ; + + ui->versions_CB->blockSignals(true) ; + + while(ui->versions_CB->count() > 0) + ui->versions_CB->removeItem(0); if(it != mPostVersions.end()) { @@ -1589,7 +1599,7 @@ void GxsForumThreadWidget::insertMessage() ui->versions_CB->setVisible(true) ; ui->time_label->hide(); - ui->versions_CB->blockSignals(true) ; + int current_index = 0 ; for(uint32_t i=0;i<(*it).size();++i) { @@ -1597,8 +1607,12 @@ void GxsForumThreadWidget::insertMessage() ui->versions_CB->setItemData(i,QString::fromStdString((*it)[i].second.toStdString())); std::cerr << " added new post version " << (*it)[i].first << " " << (*it)[i].second << std::endl; + + if(mThreadId == (*it)[i].second) + current_index = i ; } - ui->versions_CB->blockSignals(false) ; + + ui->versions_CB->setCurrentIndex(current_index) ; } else { @@ -1606,6 +1620,8 @@ void GxsForumThreadWidget::insertMessage() ui->time_label->show(); } + ui->versions_CB->blockSignals(false) ; + /* request Post */ RsGxsGrpMsgIdPair msgId = std::make_pair(groupId(), mThreadId); requestMessageData(msgId); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index f6eaeb208..456408fae 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -166,6 +166,7 @@ private: private: RsGxsGroupId mLastForumID; RsGxsMessageId mThreadId; + RsGxsMessageId mOrigThreadId; RsGxsForumGroup mForumGroup; QString mForumDescription; int mSubscribeFlags; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui index bd0d92e9e..789616228 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui @@ -289,13 +289,6 @@ - - - - - - - @@ -481,6 +474,13 @@ + + + + + + +