make interactions on BoardPostWidget to mark the post as read

This commit is contained in:
csoler 2020-10-01 20:25:10 +02:00
parent 4fd7f455a1
commit c30c7a4dfe
5 changed files with 35 additions and 12 deletions

View file

@ -199,6 +199,13 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie
QObject::connect(w,SIGNAL(commentsRequested(const RsGxsMessageId&,bool)),mPostListWidget,SLOT(openComments(const RsGxsMessageId&)));
QObject::connect(w,SIGNAL(changeReadStatusRequested(const RsGxsMessageId&,bool)),mPostListWidget,SLOT(changeReadStatus(const RsGxsMessageId&,bool)));
// All other interactions with the widget should cause the msg to be set as read.
QObject::connect(w,SIGNAL(thumbnailOpenned()),mPostListWidget,SLOT(markCurrentPostAsRead()));
QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(markCurrentPostAsRead()));
QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(markCurrentPostAsRead()));
QObject::connect(w,SIGNAL(commentsRequested(const RsGxsMessageId&,bool)),mPostListWidget,SLOT(markCurrentPostAsRead()));
QObject::connect(w,SIGNAL(shareButtonClicked()),mPostListWidget,SLOT(markCurrentPostAsRead()));
w->setFixedSize(option.rect.size());
w->adjustSize();
w->updateGeometry();
@ -692,6 +699,16 @@ void PostedListWidgetWithModel::openComments(const RsGxsMessageId& msgId)
ui->tabWidget->addTab(commentDialog,title);
}
void PostedListWidgetWithModel::markCurrentPostAsRead()
{
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
if(!index.isValid())
throw std::runtime_error("No post under mouse!");
mPostedPostsModel->setMsgReadStatus(index,true);
}
void PostedListWidgetWithModel::changeReadStatus(const RsGxsMessageId& msgId,bool b)
{
QModelIndex index=mPostedPostsModel->getIndexOfMessage(msgId);