From 4c66f82da80133908e8150417769e7844fe88839 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Tue, 6 May 2014 20:55:30 +0000 Subject: [PATCH] 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 --- libretroshare/src/services/p3gxschannels.cc | 3 +- .../src/gui/feeds/GxsChannelPostItem.cpp | 93 +++++++------------ .../src/gui/feeds/GxsChannelPostItem.h | 2 + .../src/gui/feeds/GxsChannelPostItem.ui | 7 ++ .../gui/gxschannels/GxsChannelPostsWidget.cpp | 4 +- .../gui/gxschannels/GxsChannelPostsWidget.ui | 13 ++- 6 files changed, 56 insertions(+), 66 deletions(-) diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index 6eea75192..55c82cb40 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -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) { diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index ba35f0938..eb517523d 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -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) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h index 0c2fc99db..6900dfd1f 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h @@ -76,6 +76,8 @@ private: void setup(); void loadPost(const RsGxsChannelPost &post); + void setReadStatus(bool isNew, bool isUnread); + bool mInUpdateItemStatic; uint32_t mMode; diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui index be4128033..3aba7e87a 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui @@ -221,6 +221,13 @@ + + + + New + + + diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index d24d16c47..7ab7f4287 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -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(); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui index 4946e57ce..678f47814 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui @@ -110,7 +110,7 @@ 2 - 2 + 5 2 @@ -151,6 +151,13 @@ + + + + Loading + + + @@ -236,10 +243,6 @@ scrollArea headFrame - toolBarFrame - scrollArea - - headFrame