added menu entry to switch single post as unread, and fixed the setAllMsgAsRead function

This commit is contained in:
csoler 2020-09-10 20:07:13 +02:00
parent 96a8c23f1e
commit 8d6bd1a0b8
3 changed files with 16 additions and 20 deletions

View File

@ -702,11 +702,15 @@ void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status)
{
for(uint32_t i=0;i<mPosts.size();++i)
{
bool post_status = (IS_MSG_UNREAD(mPosts[i].mMeta.mMsgStatus) || IS_MSG_NEW(mPosts[i].mMeta.mMsgStatus));
bool post_status = !((IS_MSG_UNREAD(mPosts[i].mMeta.mMsgStatus) || IS_MSG_NEW(mPosts[i].mMeta.mMsgStatus)));
if(post_status != read_status)
{
std::cerr << "Switch read status of post " << mPosts[i].mMeta.mMsgId << std::endl;
if(!rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status))
RsErr() << "setAllMsgReadStatus: failed to change status of msg " << mPosts[i].mMeta.mMsgId << " in group " << mPosts[i].mMeta.mGroupId << " to status " << read_status << std::endl;
}
}
});
}

View File

@ -490,6 +490,9 @@ void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&)
if(!post.mFiles.empty())
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DOWNLOAD), tr("Download files"), this, SLOT(download()));
if(!IS_MSG_UNREAD(post.mMeta.mMsgStatus) && !IS_MSG_NEW(post.mMeta.mMsgStatus))
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Mark as unread"), this, SLOT(markMessageUnread()));
}
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink()));
@ -499,6 +502,13 @@ void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&)
menu.exec(QCursor::pos());
}
void GxsChannelPostsWidgetWithModel::markMessageUnread()
{
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
mChannelPostsModel->setMsgReadStatus(index,false);
}
RsGxsMessageId GxsChannelPostsWidgetWithModel::getCurrentItemId() const
{
RsGxsMessageId selected_msg_id ;
@ -1393,25 +1403,6 @@ public:
uint32_t mLastToken;
};
#ifdef TO_REMOVE
static void setAllMessagesReadCallback(FeedItem *feedItem, void *data)
{
GxsChannelPostItem *channelPostItem = dynamic_cast<GxsChannelPostItem*>(feedItem);
if (!channelPostItem) {
return;
}
GxsChannelPostsReadData *readData = (GxsChannelPostsReadData*) data;
bool isRead = !channelPostItem->isUnread() ;
if(channelPostItem->isLoaded() && (isRead == readData->mRead))
return ;
RsGxsGrpMsgIdPair msgPair = std::make_pair(channelPostItem->groupId(), channelPostItem->messageId());
rsGxsChannels->setMessageReadStatus(readData->mLastToken, msgPair, readData->mRead);
}
#endif
void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t& /*token*/)
{
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))

View File

@ -157,6 +157,7 @@ private slots:
void updateZoomFactor(bool zoom_or_unzoom);
void switchView();
void switchOnlyUnread(bool b);
void markMessageUnread();
public slots:
void sortColumnFiles(int col,Qt::SortOrder so);