From d84fdff2e1c0b2dd52463658d6cee54446a41371 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 18 Jun 2016 20:03:55 +0200 Subject: [PATCH] Fix GxsChannelPostItem when received comment. --- libretroshare/src/retroshare/rsgxschannels.h | 5 +- libretroshare/src/retroshare/rsgxscommon.h | 13 +++ libretroshare/src/retroshare/rsgxsforums.h | 3 +- .../src/retroshare/rsgxsifacetypes.h | 18 ++++ libretroshare/src/retroshare/rsposted.h | 3 +- .../src/serialiser/rsgxscommentitems.cc | 1 + libretroshare/src/services/p3gxschannels.cc | 35 ++++--- libretroshare/src/services/p3gxschannels.h | 7 +- libretroshare/src/services/p3gxsforums.cc | 6 +- libretroshare/src/services/p3gxsforums.h | 3 +- libretroshare/src/services/p3posted.cc | 6 +- libretroshare/src/services/p3posted.h | 3 +- retroshare-gui/src/gui/Posted/PostedItem.cpp | 1 - .../src/gui/feeds/GxsChannelPostItem.cpp | 50 ++++++---- .../src/gui/feeds/GxsChannelPostItem.ui | 93 +++++++++++++++---- retroshare-gui/src/gui/gxs/GxsFeedItem.h | 2 + 16 files changed, 188 insertions(+), 61 deletions(-) diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index 8e78f9825..b5d46bc3b 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -83,9 +83,10 @@ virtual ~RsGxsChannels() { return; } /* Specific Service Data */ virtual bool getGroupData(const uint32_t &token, std::vector &groups) = 0; +virtual bool getPostData(const uint32_t &token, std::vector &posts, std::vector &cmts) = 0; virtual bool getPostData(const uint32_t &token, std::vector &posts) = 0; - -virtual bool getRelatedPosts(const uint32_t &token, std::vector &posts) = 0; +//Not currently used +//virtual bool getRelatedPosts(const uint32_t &token, std::vector &posts) = 0; /* From RsGxsCommentService */ //virtual bool getCommentData(const uint32_t &token, std::vector &comments) = 0; diff --git a/libretroshare/src/retroshare/rsgxscommon.h b/libretroshare/src/retroshare/rsgxscommon.h index bfb172b72..6d4b1655e 100644 --- a/libretroshare/src/retroshare/rsgxscommon.h +++ b/libretroshare/src/retroshare/rsgxscommon.h @@ -108,6 +108,19 @@ class RsGxsComment // This is filled in if detailed Comment Data is called. std::list 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; + } }; diff --git a/libretroshare/src/retroshare/rsgxsforums.h b/libretroshare/src/retroshare/rsgxsforums.h index c0e0b139d..cf7ca26ef 100644 --- a/libretroshare/src/retroshare/rsgxsforums.h +++ b/libretroshare/src/retroshare/rsgxsforums.h @@ -70,7 +70,8 @@ virtual ~RsGxsForums() { return; } /* Specific Service Data */ virtual bool getGroupData(const uint32_t &token, std::vector &groups) = 0; virtual bool getMsgData(const uint32_t &token, std::vector &msgs) = 0; -virtual bool getRelatedMessages(const uint32_t &token, std::vector &msgs) = 0; +//Not currently used +//virtual bool getRelatedMessages(const uint32_t &token, std::vector &msgs) = 0; ////////////////////////////////////////////////////////////////////////////// virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0; diff --git a/libretroshare/src/retroshare/rsgxsifacetypes.h b/libretroshare/src/retroshare/rsgxsifacetypes.h index e4c5e6048..87f024430 100644 --- a/libretroshare/src/retroshare/rsgxsifacetypes.h +++ b/libretroshare/src/retroshare/rsgxsifacetypes.h @@ -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 diff --git a/libretroshare/src/retroshare/rsposted.h b/libretroshare/src/retroshare/rsposted.h index bc2af4d9c..4a4c96269 100644 --- a/libretroshare/src/retroshare/rsposted.h +++ b/libretroshare/src/retroshare/rsposted.h @@ -84,7 +84,8 @@ virtual ~RsPosted() { return; } /* Specific Service Data */ virtual bool getGroupData(const uint32_t &token, std::vector &groups) = 0; virtual bool getPostData(const uint32_t &token, std::vector &posts) = 0; -virtual bool getRelatedPosts(const uint32_t &token, std::vector &posts) = 0; +//Not currently used +//virtual bool getRelatedPosts(const uint32_t &token, std::vector &posts) = 0; /* From RsGxsCommentService */ //virtual bool getCommentData(const uint32_t &token, std::vector &comments) = 0; diff --git a/libretroshare/src/serialiser/rsgxscommentitems.cc b/libretroshare/src/serialiser/rsgxscommentitems.cc index be07bc67c..11832701e 100644 --- a/libretroshare/src/serialiser/rsgxscommentitems.cc +++ b/libretroshare/src/serialiser/rsgxscommentitems.cc @@ -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; diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index eeab2b29b..cff1ffc74 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -321,7 +321,7 @@ bool p3GxsChannels::groupShareKeys(const RsGxsGroupId &groupId, std::set &msgs) +bool p3GxsChannels::getPostData(const uint32_t &token, std::vector &msgs, std::vector &cmts) { #ifdef GXSCHANNELS_DEBUG std::cerr << "p3GxsChannels::getPostData()"; @@ -342,19 +342,32 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector(*vit); + RsGxsChannelPostItem* postItem = dynamic_cast(*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(*vit); - if(!cmt) + RsGxsCommentItem* cmtItem = dynamic_cast(*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 &msgs) +//Not currently used +/*bool p3GxsChannels::getRelatedPosts(const uint32_t &token, std::vector &msgs) { #ifdef GXSCHANNELS_DEBUG std::cerr << "p3GxsChannels::getRelatedPosts()"; @@ -436,7 +449,7 @@ bool p3GxsChannels::getRelatedPosts(const uint32_t &token, std::vector &groups); -virtual bool getPostData(const uint32_t &token, std::vector &posts); - -virtual bool getRelatedPosts(const uint32_t &token, std::vector &posts); +virtual bool getPostData(const uint32_t &token, std::vector &posts, std::vector &cmts); +virtual bool getPostData(const uint32_t &token, std::vector &posts) { std::vector cmts; return getPostData( token, posts, cmts);} +//Not currently used +//virtual bool getRelatedPosts(const uint32_t &token, std::vector &posts); ////////////////////////////////////////////////////////////////////////////// diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index fa346e44c..e8b1affeb 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -255,8 +255,8 @@ bool p3GxsForums::getMsgData(const uint32_t &token, std::vector & return ok; } - -bool p3GxsForums::getRelatedMessages(const uint32_t &token, std::vector &msgs) +//Not currently used +/*bool p3GxsForums::getRelatedMessages(const uint32_t &token, std::vector &msgs) { GxsMsgRelatedDataMap msgData; bool ok = RsGenExchange::getMsgRelatedData(token, msgData); @@ -291,7 +291,7 @@ bool p3GxsForums::getRelatedMessages(const uint32_t &token, std::vector &groups); virtual bool getMsgData(const uint32_t &token, std::vector &msgs); -virtual bool getRelatedMessages(const uint32_t &token, std::vector &msgs); +//Not currently used +//virtual bool getRelatedMessages(const uint32_t &token, std::vector &msgs); ////////////////////////////////////////////////////////////////////////////// virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read); diff --git a/libretroshare/src/services/p3posted.cc b/libretroshare/src/services/p3posted.cc index 2a9237a13..271d269e1 100644 --- a/libretroshare/src/services/p3posted.cc +++ b/libretroshare/src/services/p3posted.cc @@ -139,8 +139,8 @@ bool p3Posted::getPostData(const uint32_t &token, std::vector &msg return ok; } - -bool p3Posted::getRelatedPosts(const uint32_t &token, std::vector &msgs) +//Not currently used +/*bool p3Posted::getRelatedPosts(const uint32_t &token, std::vector &msgs) { GxsMsgRelatedDataMap msgData; bool ok = RsGenExchange::getMsgRelatedData(token, msgData); @@ -178,7 +178,7 @@ bool p3Posted::getRelatedPosts(const uint32_t &token, std::vector } return ok; -} +}*/ /********************************************************************************************/ diff --git a/libretroshare/src/services/p3posted.h b/libretroshare/src/services/p3posted.h index b14d338ac..63ef72d32 100644 --- a/libretroshare/src/services/p3posted.h +++ b/libretroshare/src/services/p3posted.h @@ -64,7 +64,8 @@ virtual void receiveHelperChanges(std::vector& changes) // Posted Specific DataTypes. virtual bool getGroupData(const uint32_t &token, std::vector &groups); virtual bool getPostData(const uint32_t &token, std::vector &posts); -virtual bool getRelatedPosts(const uint32_t &token, std::vector &posts); +//Not currently used +//virtual bool getRelatedPosts(const uint32_t &token, std::vector &posts); virtual bool createGroup(uint32_t &token, RsPostedGroup &group); virtual bool createPost(uint32_t &token, RsPostedPost &post); diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index 314ec0df4..b8bcd0994 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -295,7 +295,6 @@ void PostedItem::fill() ui->voteDownButton->setEnabled(false); } - #if 0 uint32_t up, down, nComments; diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 3c087fbec..086d711eb 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -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 posts; - if (!rsGxsChannels->getPostData(token, posts)) + std::vector 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) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui index 58a0ac182..8d12fcc8e 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui @@ -6,22 +6,31 @@ 0 0 - 757 - 177 + 840 + 180 - + + + 1 + + + 1 + + + 1 + + + 1 + 6 1 - - 1 - - + 0 @@ -37,9 +46,9 @@ QFrame::Sunken - + - + @@ -69,9 +78,9 @@ - + - + @@ -114,7 +123,7 @@ - + @@ -153,7 +162,7 @@ - + @@ -180,7 +189,31 @@ - + + + 0 + + + + + New Comment: + + + true + + + + + + + Comment Value + + + + + + + 8 @@ -450,8 +483,17 @@ - - + + + 0 + + + 0 + + + 0 + + 0 @@ -462,8 +504,17 @@ QFrame::Sunken - - + + + 5 + + + 5 + + + 5 + + 5 @@ -508,6 +559,12 @@ QLabel
gui/common/StyledLabel.h
+ + ElidedLabel + QLabel +
gui/common/ElidedLabel.h
+ 1 +
diff --git a/retroshare-gui/src/gui/gxs/GxsFeedItem.h b/retroshare-gui/src/gui/gxs/GxsFeedItem.h index fe8d555e6..7061a4ce8 100644 --- a/retroshare-gui/src/gui/gxs/GxsFeedItem.h +++ b/retroshare-gui/src/gui/gxs/GxsFeedItem.h @@ -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 */