mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-11-24 09:43:18 -05:00
added menu entry to switch single post as unread, and fixed the setAllMsgAsRead function
This commit is contained in:
parent
96a8c23f1e
commit
8d6bd1a0b8
3 changed files with 16 additions and 20 deletions
|
|
@ -702,11 +702,15 @@ void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status)
|
||||||
{
|
{
|
||||||
for(uint32_t i=0;i<mPosts.size();++i)
|
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)
|
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))
|
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;
|
RsErr() << "setAllMsgReadStatus: failed to change status of msg " << mPosts[i].mMeta.mMsgId << " in group " << mPosts[i].mMeta.mGroupId << " to status " << read_status << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -490,6 +490,9 @@ void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&)
|
||||||
|
|
||||||
if(!post.mFiles.empty())
|
if(!post.mFiles.empty())
|
||||||
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DOWNLOAD), tr("Download files"), this, SLOT(download()));
|
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()));
|
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());
|
menu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsChannelPostsWidgetWithModel::markMessageUnread()
|
||||||
|
{
|
||||||
|
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
|
||||||
|
|
||||||
|
mChannelPostsModel->setMsgReadStatus(index,false);
|
||||||
|
}
|
||||||
|
|
||||||
RsGxsMessageId GxsChannelPostsWidgetWithModel::getCurrentItemId() const
|
RsGxsMessageId GxsChannelPostsWidgetWithModel::getCurrentItemId() const
|
||||||
{
|
{
|
||||||
RsGxsMessageId selected_msg_id ;
|
RsGxsMessageId selected_msg_id ;
|
||||||
|
|
@ -1393,25 +1403,6 @@ public:
|
||||||
uint32_t mLastToken;
|
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*/)
|
void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t& /*token*/)
|
||||||
{
|
{
|
||||||
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
|
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,7 @@ private slots:
|
||||||
void updateZoomFactor(bool zoom_or_unzoom);
|
void updateZoomFactor(bool zoom_or_unzoom);
|
||||||
void switchView();
|
void switchView();
|
||||||
void switchOnlyUnread(bool b);
|
void switchOnlyUnread(bool b);
|
||||||
|
void markMessageUnread();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void sortColumnFiles(int col,Qt::SortOrder so);
|
void sortColumnFiles(int col,Qt::SortOrder so);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue