From 67e8b87750210ddca6428ae18b9057bdff7870de Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 11 Jun 2020 22:17:33 +0200 Subject: [PATCH] attempt to fix UI bug that automatically deselected after setting msg as read --- .../gui/gxschannels/GxsChannelPostsModel.cpp | 4 +- .../gui/gxschannels/GxsChannelPostsModel.h | 2 +- .../GxsChannelPostsWidgetWithModel.cpp | 48 ++++++++++--------- .../GxsChannelPostsWidgetWithModel.h | 2 +- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index caca20f93..f22e7ca58 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -398,7 +398,7 @@ void RsGxsChannelPostsModel::clear() initEmptyHierarchy(); postMods(); - emit channelLoaded(); + emit channelPostsLoaded(); } void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vector& posts) @@ -431,7 +431,7 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto postMods(); - emit channelLoaded(); + emit channelPostsLoaded(); } void RsGxsChannelPostsModel::update_posts(const RsGxsGroupId& group_id) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h index b82f91783..59d937b6c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h @@ -173,7 +173,7 @@ public: void debug_dump(); signals: - void channelLoaded(); // emitted after the posts have been set. Can be used to updated the UI. + void channelPostsLoaded(); // emitted after the posts have been loaded. private: RsGxsChannelGroup mChannelGroup; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 17a9d5d85..31bd27b3f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -323,7 +323,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI connect(ui->channelFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnFiles(int,Qt::SortOrder))); connect(ui->postsTree->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(showPostDetails())); - connect(mChannelPostsModel,SIGNAL(channelLoaded()),this,SLOT(updateChannelFiles())); + connect(mChannelPostsModel,SIGNAL(channelPostsLoaded()),this,SLOT(postChannelLoad())); QFontMetricsF fm(font()); @@ -431,12 +431,6 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() { QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); - if(!index.isValid() && !mSelectedPost.isNull() && mGroup.mMeta.mGroupId == mSelectedGroup) - { - index = mChannelPostsModel->getIndexOfMessage(mSelectedPost); - whileBlocking(ui->postsTree)->setCurrentIndex(index); - } - if(!index.isValid()) { ui->postDetails_TE->clear(); @@ -503,20 +497,6 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() } } -void GxsChannelPostsWidgetWithModel::updateChannelFiles() -{ - std::list files; - - mChannelPostsModel->getFilesList(files); - mChannelFilesModel->setFiles(files); - - ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE); - ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE); - ui->channelFiles_TV->setAutoSelect(true); - - //mChannelPostFilesProxyModel->sort(0, Qt::AscendingOrder); -} - void GxsChannelPostsWidgetWithModel::updateGroupData() { if(groupId().isNull()) @@ -548,6 +528,29 @@ void GxsChannelPostsWidgetWithModel::updateGroupData() }); } +void GxsChannelPostsWidgetWithModel::postChannelLoad() +{ + std::cerr << "Post channel load..." << std::endl; + + if(!mSelectedPost.isNull() && mGroup.mMeta.mGroupId == mSelectedGroup) + { + QModelIndex index = mChannelPostsModel->getIndexOfMessage(mSelectedPost); + std::cerr << "Setting current index to " << index.row() << ","<< index.column() << " for current post " << mSelectedPost << std::endl; + whileBlocking(ui->postsTree)->setCurrentIndex(index); + } + + std::list files; + + mChannelPostsModel->getFilesList(files); + mChannelFilesModel->setFiles(files); + + ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE); + ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE); + ui->channelFiles_TV->setAutoSelect(true); + + +} + void GxsChannelPostsWidgetWithModel::updateDisplay(bool complete) { #ifdef DEBUG_CHANNEL @@ -779,7 +782,6 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou } ui->infoDistribution->setText(distrib_string); - #ifdef TODO ui->infoWidget->show(); ui->feedWidget->hide(); @@ -788,8 +790,8 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou //ui->feedToolButton->setEnabled(false); //ui->fileToolButton->setEnabled(false); #endif - ui->subscribeToolButton->setText(tr("Subscribe ") + " " + QString::number(group.mMeta.mPop) ); + } #ifdef TODO diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 49e5dc21e..7d2b9038c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -138,7 +138,7 @@ private slots: void setViewMode(int viewMode); void settingsChanged(); void handlePostsTreeSizeChange(QSize s); - void updateChannelFiles(); + void postChannelLoad(); public slots: void sortColumnFiles(int col,Qt::SortOrder so);