Added set read status to channel post

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7343 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-05-06 20:55:30 +00:00
parent 0abc2342fe
commit 4c66f82da8
6 changed files with 56 additions and 66 deletions

View File

@ -796,7 +796,8 @@ void p3GxsChannels::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPai
std::cerr << "p3GxsChannels::setMessageReadStatus()";
std::cerr << std::endl;
uint32_t mask = GXS_SERV::GXS_MSG_STATUS_UNREAD;
/* Always remove status unprocessed */
uint32_t mask = GXS_SERV::GXS_MSG_STATUS_UNREAD | GXS_SERV::GXS_MSG_STATUS_UNPROCESSED;
uint32_t status = GXS_SERV::GXS_MSG_STATUS_UNREAD;
if (read)
{

View File

@ -205,7 +205,7 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
ui->unsubscribeButton->setEnabled(false);
}
ui->readButton->hide();
//newLabel->hide();
ui->newLabel->hide();
ui->copyLinkButton->hide();
}
else
@ -228,51 +228,13 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags))
{
ui->readButton->setVisible(true);
#if 0
uint32_t status = 0;
rsChannels->getMessageStatus(mChanId, mMsgId, status);
#endif
if (IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
{
ui->readButton->setChecked(true);
ui->readButton->setIcon(QIcon(":/images/message-state-unread.png"));
}
else
{
ui->readButton->setChecked(false);
ui->readButton->setIcon(QIcon(":/images/message-state-read.png"));
}
bool newState;
QColor color;
if (!IS_MSG_UNREAD(post.mMeta.mMsgStatus))
{
//newLabel->setVisible(false);
newState = false;
color = COLOR_NORMAL;
}
else
{
//newLabel->setVisible(true);
newState = true;
color = COLOR_NEW;
}
/* unpolish widget to clear the stylesheet's palette cache */
ui->frame->style()->unpolish(ui->frame);
QPalette palette = ui->frame->palette();
palette.setColor(ui->frame->backgroundRole(), color);
ui->frame->setPalette(palette);
ui->frame->setProperty("new", newState);
Rshare::refreshStyleSheet(ui->frame, false);
setReadStatus(IS_MSG_NEW(post.mMeta.mMsgStatus), IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus));
}
else
{
ui->readButton->setVisible(false);
//ui->newLabel->setVisible(false);
ui->newLabel->setVisible(false);
}
}
@ -352,6 +314,32 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
mInUpdateItemStatic = false;
}
void GxsChannelPostItem::setReadStatus(bool isNew, bool isUnread)
{
if (isUnread)
{
ui->readButton->setChecked(true);
ui->readButton->setIcon(QIcon(":/images/message-state-unread.png"));
}
else
{
ui->readButton->setChecked(false);
ui->readButton->setIcon(QIcon(":/images/message-state-read.png"));
}
ui->newLabel->setVisible(isNew);
/* unpolish widget to clear the stylesheet's palette cache */
ui->frame->style()->unpolish(ui->frame);
QPalette palette = ui->frame->palette();
palette.setColor(ui->frame->backgroundRole(), isNew ? COLOR_NEW : COLOR_NORMAL);
ui->frame->setPalette(palette);
ui->frame->setProperty("new", isNew);
Rshare::refreshStyleSheet(ui->frame, false);
}
void GxsChannelPostItem::setFileCleanUpWarning(uint32_t time_left)
{
int hours = (int)time_left/3600;
@ -521,29 +509,16 @@ void GxsChannelPostItem::play()
void GxsChannelPostItem::readToggled(bool checked)
{
#if 0
if (mInUpdateItemStatic) {
return;
}
/* set always as read ... */
uint32_t statusNew = CHANNEL_MSG_STATUS_READ;
if (checked) {
/* ... and as unread by user */
statusNew |= CHANNEL_MSG_STATUS_UNREAD_BY_USER;
} else {
/* ... and as read by user */
statusNew &= ~CHANNEL_MSG_STATUS_UNREAD_BY_USER;
}
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
if (!mIsHome) {
disconnect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
}
rsChannels->setMessageStatus(mChanId, mMsgId, statusNew, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER);
if (!mIsHome) {
connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
}
#endif
uint32_t token;
rsGxsChannels->setMessageReadStatus(token, msgPair, !checked);
setReadStatus(false, checked);
}
void GxsChannelPostItem::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status)

View File

@ -76,6 +76,8 @@ private:
void setup();
void loadPost(const RsGxsChannelPost &post);
void setReadStatus(bool isNew, bool isUnread);
bool mInUpdateItemStatic;
uint32_t mMode;

View File

@ -221,6 +221,13 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="newLabel">
<property name="text">
<string>New</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="scoreLabel">
<property name="font">

View File

@ -54,8 +54,9 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
mStateHelper = new UIStateHelper(this);
// No progress yet
mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
// mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressBar, UISTATE_LOADING_VISIBLE);
mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressLabel, UISTATE_LOADING_VISIBLE);
// mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressLabel, UISTATE_LOADING_VISIBLE);
mStateHelper->addLoadPlaceholder(TOKEN_TYPE_GROUP_DATA, ui->nameLabel);
@ -69,6 +70,7 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
/*************** Setup Left Hand Side (List of Channels) ****************/
ui->loadingLabel->hide();
ui->progressLabel->hide();
ui->progressBar->hide();

View File

@ -110,7 +110,7 @@
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
<number>5</number>
</property>
<property name="bottomMargin">
<number>2</number>
@ -151,6 +151,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="loadingLabel">
<property name="text">
<string>Loading</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -236,10 +243,6 @@
<zorder>scrollArea</zorder>
<zorder></zorder>
<zorder>headFrame</zorder>
<zorder>toolBarFrame</zorder>
<zorder>scrollArea</zorder>
<zorder></zorder>
<zorder>headFrame</zorder>
</widget>
<resources>
<include location="../images.qrc"/>