attempt to fix UI bug that automatically deselected after setting msg as read

This commit is contained in:
csoler 2020-06-11 22:17:33 +02:00
parent 2faaccbb7a
commit 67e8b87750
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
4 changed files with 29 additions and 27 deletions

View File

@ -398,7 +398,7 @@ void RsGxsChannelPostsModel::clear()
initEmptyHierarchy(); initEmptyHierarchy();
postMods(); postMods();
emit channelLoaded(); emit channelPostsLoaded();
} }
void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vector<RsGxsChannelPost>& posts) void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vector<RsGxsChannelPost>& posts)
@ -431,7 +431,7 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto
postMods(); postMods();
emit channelLoaded(); emit channelPostsLoaded();
} }
void RsGxsChannelPostsModel::update_posts(const RsGxsGroupId& group_id) void RsGxsChannelPostsModel::update_posts(const RsGxsGroupId& group_id)

View File

@ -173,7 +173,7 @@ public:
void debug_dump(); void debug_dump();
signals: 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: private:
RsGxsChannelGroup mChannelGroup; RsGxsChannelGroup mChannelGroup;

View File

@ -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->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(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()); QFontMetricsF fm(font());
@ -431,12 +431,6 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
{ {
QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); 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()) if(!index.isValid())
{ {
ui->postDetails_TE->clear(); ui->postDetails_TE->clear();
@ -503,20 +497,6 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
} }
} }
void GxsChannelPostsWidgetWithModel::updateChannelFiles()
{
std::list<RsGxsFile> 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() void GxsChannelPostsWidgetWithModel::updateGroupData()
{ {
if(groupId().isNull()) 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<RsGxsFile> 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) void GxsChannelPostsWidgetWithModel::updateDisplay(bool complete)
{ {
#ifdef DEBUG_CHANNEL #ifdef DEBUG_CHANNEL
@ -779,7 +782,6 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
} }
ui->infoDistribution->setText(distrib_string); ui->infoDistribution->setText(distrib_string);
#ifdef TODO #ifdef TODO
ui->infoWidget->show(); ui->infoWidget->show();
ui->feedWidget->hide(); ui->feedWidget->hide();
@ -788,8 +790,8 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
//ui->feedToolButton->setEnabled(false); //ui->feedToolButton->setEnabled(false);
//ui->fileToolButton->setEnabled(false); //ui->fileToolButton->setEnabled(false);
#endif #endif
ui->subscribeToolButton->setText(tr("Subscribe ") + " " + QString::number(group.mMeta.mPop) ); ui->subscribeToolButton->setText(tr("Subscribe ") + " " + QString::number(group.mMeta.mPop) );
} }
#ifdef TODO #ifdef TODO

View File

@ -138,7 +138,7 @@ private slots:
void setViewMode(int viewMode); void setViewMode(int viewMode);
void settingsChanged(); void settingsChanged();
void handlePostsTreeSizeChange(QSize s); void handlePostsTreeSizeChange(QSize s);
void updateChannelFiles(); void postChannelLoad();
public slots: public slots:
void sortColumnFiles(int col,Qt::SortOrder so); void sortColumnFiles(int col,Qt::SortOrder so);