fixed UI for post versions

This commit is contained in:
csoler 2017-02-09 18:45:55 +01:00
parent b93130ac77
commit 8deeec61c5
3 changed files with 28 additions and 11 deletions

View File

@ -701,10 +701,16 @@ void GxsForumThreadWidget::changedThread()
mThreadId.clear(); mThreadId.clear();
if(ui->versions_CB->count() > 0) if(ui->versions_CB->count() > 0)
{
mThreadId = RsGxsMessageId(ui->versions_CB->itemData(ui->versions_CB->currentIndex()).toString().toStdString()) ; mThreadId = RsGxsMessageId(ui->versions_CB->itemData(ui->versions_CB->currentIndex()).toString().toStdString()) ;
mOrigThreadId = RsGxsMessageId(ui->versions_CB->itemData(0).toString().toStdString()) ;
}
if(mThreadId.isNull()) if(mThreadId.isNull())
{
mThreadId = RsGxsMessageId(item->data(COLUMN_THREAD_MSGID, Qt::DisplayRole).toString().toStdString()); mThreadId = RsGxsMessageId(item->data(COLUMN_THREAD_MSGID, Qt::DisplayRole).toString().toStdString());
mOrigThreadId = mThreadId ;
}
} }
if (mFillThread) { if (mFillThread) {
@ -1579,8 +1585,12 @@ void GxsForumThreadWidget::insertMessage()
std::cerr << "Looking into existing versions for post " << mThreadId << ", thread history: " << mPostVersions.size() << std::endl; std::cerr << "Looking into existing versions for post " << mThreadId << ", thread history: " << mPostVersions.size() << std::endl;
QMap<RsGxsMessageId,QVector<QPair<time_t,RsGxsMessageId> > >::const_iterator it = mPostVersions.find(mThreadId) ; QMap<RsGxsMessageId,QVector<QPair<time_t,RsGxsMessageId> > >::const_iterator it = mPostVersions.find(mOrigThreadId) ;
ui->versions_CB->clear();
ui->versions_CB->blockSignals(true) ;
while(ui->versions_CB->count() > 0)
ui->versions_CB->removeItem(0);
if(it != mPostVersions.end()) if(it != mPostVersions.end())
{ {
@ -1589,7 +1599,7 @@ void GxsForumThreadWidget::insertMessage()
ui->versions_CB->setVisible(true) ; ui->versions_CB->setVisible(true) ;
ui->time_label->hide(); ui->time_label->hide();
ui->versions_CB->blockSignals(true) ; int current_index = 0 ;
for(uint32_t i=0;i<(*it).size();++i) 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())); 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; 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 else
{ {
@ -1606,6 +1620,8 @@ void GxsForumThreadWidget::insertMessage()
ui->time_label->show(); ui->time_label->show();
} }
ui->versions_CB->blockSignals(false) ;
/* request Post */ /* request Post */
RsGxsGrpMsgIdPair msgId = std::make_pair(groupId(), mThreadId); RsGxsGrpMsgIdPair msgId = std::make_pair(groupId(), mThreadId);
requestMessageData(msgId); requestMessageData(msgId);

View File

@ -166,6 +166,7 @@ private:
private: private:
RsGxsGroupId mLastForumID; RsGxsGroupId mLastForumID;
RsGxsMessageId mThreadId; RsGxsMessageId mThreadId;
RsGxsMessageId mOrigThreadId;
RsGxsForumGroup mForumGroup; RsGxsForumGroup mForumGroup;
QString mForumDescription; QString mForumDescription;
int mSubscribeFlags; int mSubscribeFlags;

View File

@ -289,13 +289,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="7">
<widget class="QLabel" name="time_label">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="0" column="13"> <item row="0" column="13">
<widget class="QPushButton" name="nextUnreadButton"> <widget class="QPushButton" name="nextUnreadButton">
<property name="sizePolicy"> <property name="sizePolicy">
@ -481,6 +474,13 @@
<item row="0" column="9"> <item row="0" column="9">
<widget class="QComboBox" name="versions_CB"/> <widget class="QComboBox" name="versions_CB"/>
</item> </item>
<item row="0" column="7">
<widget class="QLabel" name="time_label">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>