Fix GxsChannelPostItem when received comment.

This commit is contained in:
Phenom 2016-06-18 20:03:55 +02:00
parent 7627bd96ca
commit d84fdff2e1
16 changed files with 188 additions and 61 deletions

View File

@ -83,9 +83,10 @@ virtual ~RsGxsChannels() { return; }
/* Specific Service Data */
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups) = 0;
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts) = 0;
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) = 0;
virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) = 0;
//Not currently used
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) = 0;
/* From RsGxsCommentService */
//virtual bool getCommentData(const uint32_t &token, std::vector<RsGxsComment> &comments) = 0;

View File

@ -108,6 +108,19 @@ class RsGxsComment
// This is filled in if detailed Comment Data is called.
std::list<RsGxsVote> mVotes;
const std::ostream &print(std::ostream &out, std::string indent = "", std::string varName = "") const {
out << indent << varName << " of RsGxsComment Values ###################" << std::endl;
mMeta.print(out, indent + " ", "mMeta");
out << indent << " mComment: " << mComment << std::endl;
out << indent << " mUpVotes: " << mUpVotes << std::endl;
out << indent << " mDownVotes: " << mDownVotes << std::endl;
out << indent << " mScore: " << mScore << std::endl;
out << indent << " mOwnVote: " << mOwnVote << std::endl;
out << indent << " mVotes.size(): " << mVotes.size() << std::endl;
out << indent << "######################################################" << std::endl;
return out;
}
};

View File

@ -70,7 +70,8 @@ virtual ~RsGxsForums() { return; }
/* Specific Service Data */
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) = 0;
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
//Not currently used
//virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
//////////////////////////////////////////////////////////////////////////////
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;

View File

@ -131,6 +131,24 @@ public:
time_t mChildTs;
std::string mServiceString; // Service Specific Free-Form extra storage.
const std::ostream &print(std::ostream &out, std::string indent = "", std::string varName = "") const {
out
<< indent << varName << " of RsMsgMetaData Values ###################" << std::endl
<< indent << " mGroupId: " << mGroupId.toStdString() << std::endl
<< indent << " mMsgId: " << mMsgId.toStdString() << std::endl
<< indent << " mThreadId: " << mThreadId.toStdString() << std::endl
<< indent << " mParentId: " << mParentId.toStdString() << std::endl
<< indent << " mOrigMsgId: " << mOrigMsgId.toStdString() << std::endl
<< indent << " mAuthorId: " << mAuthorId.toStdString() << std::endl
<< indent << " mMsgName: " << mMsgName << std::endl
<< indent << " mPublishTs: " << mPublishTs << std::endl
<< indent << " mMsgFlags: " << std::hex << mMsgFlags << std::dec << std::endl
<< indent << " mMsgStatus: " << std::hex << mMsgStatus << std::dec << std::endl
<< indent << " mChildTs: " << mChildTs << std::endl
<< indent << " mServiceString: " << mServiceString << std::endl
<< indent << "######################################################" << std::endl;
return out;
}
};
class GxsGroupStatistic

View File

@ -84,7 +84,8 @@ virtual ~RsPosted() { return; }
/* Specific Service Data */
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups) = 0;
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
//Not currently used
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
/* From RsGxsCommentService */
//virtual bool getCommentData(const uint32_t &token, std::vector<RsGxsComment> &comments) = 0;

View File

@ -147,6 +147,7 @@ uint32_t RsGxsCommentSerialiser::sizeGxsCommentItem(RsGxsCommentItem *item)
#ifdef GXSCOMMENT_DEBUG
std::cerr << "RsGxsCommentSerialiser::sizeGxsCommentItem() is: " << s << std::endl;
msg.print(std::cerr);
#endif
return s;

View File

@ -321,7 +321,7 @@ bool p3GxsChannels::groupShareKeys(const RsGxsGroupId &groupId, std::set<RsPeerI
* at the moment - fix it up later
*/
bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &msgs)
bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &msgs, std::vector<RsGxsComment> &cmts)
{
#ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::getPostData()";
@ -342,19 +342,32 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
for(; vit != msgItems.end(); ++vit)
{
RsGxsChannelPostItem* item = dynamic_cast<RsGxsChannelPostItem*>(*vit);
RsGxsChannelPostItem* postItem = dynamic_cast<RsGxsChannelPostItem*>(*vit);
if(item)
if(postItem)
{
RsGxsChannelPost msg;
item->toChannelPost(msg, true);
postItem->toChannelPost(msg, true);
msgs.push_back(msg);
delete item;
delete postItem;
}
else
{
RsGxsCommentItem* cmt = dynamic_cast<RsGxsCommentItem*>(*vit);
if(!cmt)
RsGxsCommentItem* cmtItem = dynamic_cast<RsGxsCommentItem*>(*vit);
if(cmtItem)
{
RsGxsComment cmt;
RsGxsMsgItem *mi = (*vit);
cmt = cmtItem->mMsg;
cmt.mMeta = mi->meta;
#ifdef GXSCOMMENT_DEBUG
std::cerr << "p3GxsChannels::getPostData Found Comment:" << std::endl;
cmt.print(std::cerr," ", "cmt");
#endif
cmts.push_back(cmt);
delete cmtItem;
}
else
{
RsGxsMsgItem* msg = (*vit);
//const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217;
@ -364,8 +377,8 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
<< " PacketService=" << std::hex << (int)msg->PacketService() << std::dec
<< " PacketSubType=" << std::hex << (int)msg->PacketSubType() << std::dec
<< " , deleting!" << std::endl;
delete *vit;
}
delete *vit;
}
}
}
@ -379,8 +392,8 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
return ok;
}
bool p3GxsChannels::getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &msgs)
//Not currently used
/*bool p3GxsChannels::getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &msgs)
{
#ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::getRelatedPosts()";
@ -436,7 +449,7 @@ bool p3GxsChannels::getRelatedPosts(const uint32_t &token, std::vector<RsGxsChan
}
return ok;
}
}*/
/********************************************************************************************/

View File

@ -79,9 +79,10 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
public:
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups);
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts);
virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts);
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts);
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) { std::vector<RsGxsComment> cmts; return getPostData( token, posts, cmts);}
//Not currently used
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts);
//////////////////////////////////////////////////////////////////////////////

View File

@ -255,8 +255,8 @@ bool p3GxsForums::getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &
return ok;
}
bool p3GxsForums::getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs)
//Not currently used
/*bool p3GxsForums::getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs)
{
GxsMsgRelatedDataMap msgData;
bool ok = RsGenExchange::getMsgRelatedData(token, msgData);
@ -291,7 +291,7 @@ bool p3GxsForums::getRelatedMessages(const uint32_t &token, std::vector<RsGxsFor
}
return ok;
}
}*/
/********************************************************************************************/

View File

@ -62,7 +62,8 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups);
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
//Not currently used
//virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
//////////////////////////////////////////////////////////////////////////////
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read);

View File

@ -139,8 +139,8 @@ bool p3Posted::getPostData(const uint32_t &token, std::vector<RsPostedPost> &msg
return ok;
}
bool p3Posted::getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &msgs)
//Not currently used
/*bool p3Posted::getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &msgs)
{
GxsMsgRelatedDataMap msgData;
bool ok = RsGenExchange::getMsgRelatedData(token, msgData);
@ -178,7 +178,7 @@ bool p3Posted::getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost>
}
return ok;
}
}*/
/********************************************************************************************/

View File

@ -64,7 +64,8 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
// Posted Specific DataTypes.
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups);
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts);
virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts);
//Not currently used
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts);
virtual bool createGroup(uint32_t &token, RsPostedGroup &group);
virtual bool createPost(uint32_t &token, RsPostedPost &post);

View File

@ -295,7 +295,6 @@ void PostedItem::fill()
ui->voteDownButton->setEnabled(false);
}
#if 0
uint32_t up, down, nComments;

View File

@ -108,6 +108,8 @@ void GxsChannelPostItem::setup()
ui->subjectLabel->clear();
ui->datetimelabel->clear();
ui->filelabel->clear();
ui->newCommentLabel->hide();
ui->commLabel->hide();
/* general ones */
connect(ui->expandButton, SIGNAL(clicked()), this, SLOT(toggle()));
@ -143,10 +145,10 @@ void GxsChannelPostItem::setup()
ui->subjectLabel->setMinimumWidth(100);
ui->warning_label->setMinimumWidth(100);
ui->frame->setProperty("state", "");
QPalette palette = ui->frame->palette();
palette.setColor(ui->frame->backgroundRole(), COLOR_NORMAL);
ui->frame->setPalette(palette);
ui->mainFrame->setProperty("state", "");
QPalette palette = ui->mainFrame->palette();
palette.setColor(ui->mainFrame->backgroundRole(), COLOR_NORMAL);
ui->mainFrame->setPalette(palette);
ui->expandFrame->hide();
}
@ -241,21 +243,36 @@ void GxsChannelPostItem::loadMessage(const uint32_t &token)
#endif
std::vector<RsGxsChannelPost> posts;
if (!rsGxsChannels->getPostData(token, posts))
std::vector<RsGxsComment> cmts;
if (!rsGxsChannels->getPostData(token, posts, cmts))
{
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
std::cerr << std::endl;
return;
}
if (posts.size() != 1)
if (posts.size() == 1)
{
setPost(posts[0]);
}
else if (cmts.size() == 1)
{
RsGxsComment cmt = cmts[0];
ui->newCommentLabel->show();
ui->commLabel->show();
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
//Change this item to be uploaded with thread element.
setMessageId(cmt.mMeta.mThreadId);
requestMessage();
}
else
{
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items";
std::cerr << std::endl;
return;
}
setPost(posts[0]);
}
void GxsChannelPostItem::fill()
@ -347,7 +364,8 @@ void GxsChannelPostItem::fill()
{
if (mIsHome) {
ui->commentButton->show();
} else {
} else if (ui->commentButton->icon().isNull()){
//Icon is seted if a comment received.
ui->commentButton->hide();
}
@ -458,15 +476,15 @@ void GxsChannelPostItem::setReadStatus(bool isNew, bool isUnread)
ui->newLabel->setVisible(isNew);
/* unpolish widget to clear the stylesheet's palette cache */
ui->frame->style()->unpolish(ui->frame);
ui->mainFrame->style()->unpolish(ui->mainFrame);
QPalette palette = ui->frame->palette();
palette.setColor(ui->frame->backgroundRole(), isNew ? COLOR_NEW : COLOR_NORMAL); // QScrollArea
QPalette palette = ui->mainFrame->palette();
palette.setColor(ui->mainFrame->backgroundRole(), isNew ? COLOR_NEW : COLOR_NORMAL); // QScrollArea
palette.setColor(QPalette::Base, isNew ? COLOR_NEW : COLOR_NORMAL); // QTreeWidget
ui->frame->setPalette(palette);
ui->mainFrame->setPalette(palette);
ui->frame->setProperty("new", isNew);
Rshare::refreshStyleSheet(ui->frame, false);
ui->mainFrame->setProperty("new", isNew);
Rshare::refreshStyleSheet(ui->mainFrame, false);
}
void GxsChannelPostItem::setFileCleanUpWarning(uint32_t time_left)

View File

@ -6,22 +6,31 @@
<rect>
<x>0</x>
<y>0</y>
<width>757</width>
<height>177</height>
<width>840</width>
<height>180</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<layout class="QGridLayout" name="gxsChannelPostItem_GLayout">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<property name="margin">
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<widget class="QFrame" name="mainFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -37,9 +46,9 @@
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QVBoxLayout" name="mainFrameVLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<layout class="QHBoxLayout" name="mainTopHLayout">
<item>
<widget class="QLabel" name="logoLabel">
<property name="minimumSize">
@ -69,9 +78,9 @@
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="mainRTopVLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="tilteHLayout">
<item>
<widget class="StyledLabel" name="titleLabel">
<property name="sizePolicy">
@ -114,7 +123,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<layout class="QHBoxLayout" name="subjectHLayout">
<item>
<widget class="QLabel" name="subjectLabel">
<property name="sizePolicy">
@ -153,7 +162,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<layout class="QHBoxLayout" name="warningHLayout">
<item>
<widget class="QLabel" name="warn_image_label">
<property name="maximumSize">
@ -180,7 +189,31 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="newCommHLayout">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="newCommentLabel">
<property name="text">
<string>New Comment:</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="ElidedLabel" name="commLabel">
<property name="text">
<string>Comment Value</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="buttonHLayout">
<property name="spacing">
<number>8</number>
</property>
@ -450,8 +483,17 @@
</item>
<item>
<widget class="QFrame" name="expandFrame">
<layout class="QVBoxLayout">
<property name="margin">
<layout class="QVBoxLayout" name="expandFrameVLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -462,8 +504,17 @@
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<layout class="QVBoxLayout" name="msgFrameVLayout">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
@ -508,6 +559,12 @@
<extends>QLabel</extends>
<header>gui/common/StyledLabel.h</header>
</customwidget>
<customwidget>
<class>ElidedLabel</class>
<extends>QLabel</extends>
<header location="global">gui/common/ElidedLabel.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>

View File

@ -36,6 +36,8 @@ public:
virtual ~GxsFeedItem();
RsGxsMessageId messageId() { return mMessageId; }
//To be able to update with thread message when comment is received.
void setMessageId( RsGxsMessageId id) {mMessageId = id;}
protected:
/* load message data */