Added read status to posted messages

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7600 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-10-12 17:22:21 +00:00
parent d3682337f0
commit fbb177dd66
6 changed files with 181 additions and 79 deletions

View File

@ -86,7 +86,6 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << "p3PostBase::notifyChanges()";
std::cerr << std::endl;
std::vector<RsGxsNotify *> changesForGUI;
std::vector<RsGxsNotify *>::iterator it;
for(it = changes.begin(); it != changes.end(); it++)
@ -109,7 +108,6 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
// It could be taken a step further and directly request these msgs for an update.
addGroupForProcessing(mit->first);
}
delete msgChange;
}
/* pass on Group Changes to GUI */
@ -125,11 +123,9 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git;
std::cerr << std::endl;
}
changesForGUI.push_back(groupChange);
}
}
changes.clear();
receiveHelperChanges(changesForGUI);
receiveHelperChanges(changes);
std::cerr << "p3PostBase::notifyChanges() -> receiveChanges()";
std::cerr << std::endl;
@ -514,12 +510,12 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
std::cerr << std::endl;
}
/* flag all messages as processed */
/* flag all messages as processed and new for the gui */
if ((*vit)->meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_UNPROCESSED)
{
uint32_t token_a;
RsGxsGrpMsgIdPair msgId = std::make_pair(groupId, (*vit)->meta.mMsgId);
RsGenExchange::setMsgStatusFlags(token_a, msgId, 0, GXS_SERV::GXS_MSG_STATUS_UNPROCESSED);
RsGenExchange::setMsgStatusFlags(token_a, msgId, GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD, GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD);
}
delete(*vit);
}

View File

@ -23,13 +23,18 @@
#include <QDateTime>
#include "rshare.h"
#include "PostedItem.h"
#include "gui/feeds/FeedHolder.h"
#include "ui_PostedItem.h"
#include <retroshare/rsposted.h>
#include <iostream>
#define COLOR_NORMAL QColor(248, 248, 248)
#define COLOR_NEW QColor(220, 236, 253)
/** Constructor */
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome) :
@ -49,12 +54,19 @@ PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedPo
void PostedItem::setup()
{
setupUi(this);
/* Invoke the Qt Designer generated object setup routine */
ui = new Ui::PostedItem;
ui->setupUi(this);
mInSetContent = false;
setAttribute(Qt::WA_DeleteOnClose, true);
connect(commentButton, SIGNAL( clicked()), this, SLOT(loadComments()));
connect(voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote()));
connect(voteDownButton, SIGNAL(clicked()), this, SLOT( makeDownVote()));
connect(ui->commentButton, SIGNAL( clicked()), this, SLOT(loadComments()));
connect(ui->voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote()));
connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT( makeDownVote()));
connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool)));
}
void PostedItem::loadMessage(const uint32_t &token)
@ -90,19 +102,21 @@ void PostedItem::setContent(const QVariant &content)
void PostedItem::setContent(const RsPostedPost &post)
{
mInSetContent = true;
mPost = post;
QDateTime qtime;
qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
dateLabel->setText(timestamp);
fromLabel->setId(post.mMeta.mAuthorId);
titleLabel->setText("<a href=" + QString::fromStdString(post.mLink) +
"><span style=\" text-decoration: underline; color:#2255AA;\">" +
QString::fromStdString(post.mMeta.mMsgName) + "</span></a>");
siteLabel->setText("<a href=" + QString::fromStdString(post.mLink) +
"><span style=\" text-decoration: underline; color:#2255AA;\">" +
QString::fromStdString(post.mLink) + "</span></a>");
ui->dateLabel->setText(timestamp);
ui->fromLabel->setId(post.mMeta.mAuthorId);
ui->titleLabel->setText("<a href=" + QString::fromStdString(post.mLink) +
"><span style=\" text-decoration: underline; color:#2255AA;\">" +
QString::fromStdString(post.mMeta.mMsgName) + "</span></a>");
ui->siteLabel->setText("<a href=" + QString::fromStdString(post.mLink) +
"><span style=\" text-decoration: underline; color:#2255AA;\">" +
QString::fromStdString(post.mLink) + "</span></a>");
//QString score = "Hot" + QString::number(post.mHotScore);
//score += " Top" + QString::number(post.mTopScore);
@ -110,50 +124,55 @@ void PostedItem::setContent(const RsPostedPost &post)
QString score = QString::number(post.mTopScore);
scoreLabel->setText(score);
ui->scoreLabel->setText(score);
// FIX THIS UP LATER.
notes->setText(QString::fromUtf8(post.mNotes.c_str()));
ui->notes->setText(QString::fromUtf8(post.mNotes.c_str()));
// differences between Feed or Top of Comment.
if (mFeedHolder)
{
// feed.
frame_notes->hide();
ui->frame_notes->hide();
//frame_comment->show();
commentButton->show();
ui->commentButton->show();
if (post.mComments)
{
QString commentText = QString::number(post.mComments);
commentText += " ";
commentText += tr("Comments");
commentButton->setText(commentText);
ui->commentButton->setText(commentText);
}
else
{
commentButton->setText(tr("Comment"));
ui->commentButton->setText(tr("Comment"));
}
setReadStatus(IS_MSG_NEW(post.mMeta.mMsgStatus), IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus));
}
else
{
// no feed.
if(notes->text().isEmpty())
{
frame_notes->hide();
if(ui->notes->text().isEmpty())
{
ui->frame_notes->hide();
}
else
{
frame_notes->show();
ui->frame_notes->show();
}
//frame_comment->hide();
commentButton->hide();
ui->commentButton->hide();
ui->readButton->hide();
ui->newLabel->hide();
}
// disable voting buttons - if they have already voted.
if (post.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK)
{
voteUpButton->setEnabled(false);
voteDownButton->setEnabled(false);
ui->voteUpButton->setEnabled(false);
ui->voteDownButton->setEnabled(false);
}
uint32_t up, down, nComments;
@ -173,6 +192,8 @@ void PostedItem::setContent(const RsPostedPost &post)
+ QString::number(nComments) + "</span></p>");
}
#endif
mInSetContent = false;
}
const RsPostedPost &PostedItem::getPost() const
@ -196,8 +217,8 @@ void PostedItem::makeDownVote()
msgId.first = mPost.mMeta.mGroupId;
msgId.second = mPost.mMeta.mMsgId;
voteUpButton->setEnabled(false);
voteDownButton->setEnabled(false);
ui->voteUpButton->setEnabled(false);
ui->voteDownButton->setEnabled(false);
emit vote(msgId, false);
}
@ -208,8 +229,8 @@ void PostedItem::makeUpVote()
msgId.first = mPost.mMeta.mGroupId;
msgId.second = mPost.mMeta.mMsgId;
voteUpButton->setEnabled(false);
voteDownButton->setEnabled(false);
ui->voteUpButton->setEnabled(false);
ui->voteDownButton->setEnabled(false);
emit vote(msgId, true);
}
@ -225,3 +246,44 @@ void PostedItem::loadComments()
mFeedHolder->openComments(0, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, title);
}
}
void PostedItem::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); // QScrollArea
palette.setColor(QPalette::Base, isNew ? COLOR_NEW : COLOR_NORMAL); // QTreeWidget
ui->frame->setPalette(palette);
ui->frame->setProperty("new", isNew);
Rshare::refreshStyleSheet(ui->frame, false);
}
void PostedItem::readToggled(bool checked)
{
if (mInSetContent) {
return;
}
RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId());
uint32_t token;
rsPosted->setMessageReadStatus(token, msgPair, !checked);
setReadStatus(false, checked);
}

View File

@ -26,14 +26,16 @@
#include <QMetaType>
#include "ui_PostedItem.h"
#include <retroshare/rsposted.h>
#include "gui/gxs/GxsFeedItem.h"
namespace Ui {
class PostedItem;
}
class RsPostedPost;
class PostedItem : public GxsFeedItem, private Ui::PostedItem
class PostedItem : public GxsFeedItem
{
Q_OBJECT
@ -53,6 +55,7 @@ private slots:
void loadComments();
void makeUpVote();
void makeDownVote();
void readToggled(bool checked);
signals:
void vote(const RsGxsGrpMsgIdPair& msgId, bool up);
@ -64,10 +67,16 @@ protected:
private:
void setup();
void setReadStatus(bool isNew, bool isUnread);
bool mInSetContent;
uint32_t mType;
bool mSelected;
RsPostedPost mPost;
/** Qt Designer generated object */
Ui::PostedItem *ui;
};
Q_DECLARE_METATYPE(RsPostedPost)

View File

@ -43,6 +43,13 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="2">
<widget class="QLabel" name="newLabel">
<property name="text">
<string>New</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="2">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
@ -105,43 +112,14 @@
</item>
</layout>
</item>
<item row="0" column="1" colspan="8">
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="3">
<widget class="QPushButton" name="commentButton">
<property name="text">
<string>Comments</string>
</property>
</widget>
</item>
<item row="1" column="2">
<item row="1" column="4">
<widget class="QLabel" name="dateBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -161,7 +139,7 @@
</property>
</widget>
</item>
<item row="1" column="3">
<item row="1" column="5">
<widget class="QLabel" name="dateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -182,7 +160,7 @@
</property>
</widget>
</item>
<item row="1" column="4">
<item row="1" column="6">
<widget class="QLabel" name="fromBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -202,7 +180,7 @@
</property>
</widget>
</item>
<item row="1" column="5">
<item row="1" column="7">
<widget class="GxsIdLabel" name="fromLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -223,7 +201,7 @@
</property>
</widget>
</item>
<item row="1" column="6">
<item row="1" column="8">
<widget class="QLabel" name="fromBoldLabel_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -243,7 +221,7 @@
</property>
</widget>
</item>
<item row="1" column="7">
<item row="1" column="9">
<widget class="QLabel" name="siteLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -264,7 +242,7 @@
</property>
</widget>
</item>
<item row="1" column="8">
<item row="1" column="10">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -277,6 +255,64 @@
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="readButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Toggle Message Read Status</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/message-state-unread.png</normaloff>:/images/message-state-unread.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1" colspan="10">
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -65,7 +65,6 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId,
mMode = DATA_PROVIDED;
mGroupMeta.mSubscribeFlags = subFlags;
mInUpdateItemStatic = false;
setup();

View File

@ -1390,9 +1390,9 @@ void GxsForumThreadWidget::setMsgReadStatus(QList<QTreeWidgetItem*> &rows, bool
uint32_t status = (*row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
uint32_t statusNew = (status & ~(GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_USER_UNREAD)); // orig status, without UNREAD and UNPROCESSED.
uint32_t statusNew = (status & ~(GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD)); // orig status, without NEW AND UNREAD
if (!read) {
statusNew |= GXS_SERV::GXS_MSG_STATUS_GUI_USER_UNREAD;
statusNew |= GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
}
if (status != statusNew) // is it different?