mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 00:49:41 -05:00
Fix Posted Feed Item when received comment.
This commit is contained in:
parent
daf54dff3d
commit
7c7da7e6d1
@ -83,6 +83,7 @@ virtual ~RsPosted() { return; }
|
|||||||
|
|
||||||
/* Specific Service Data */
|
/* Specific Service Data */
|
||||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups) = 0;
|
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups) = 0;
|
||||||
|
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts, std::vector<RsGxsComment> &cmts) = 0;
|
||||||
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
|
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
|
||||||
//Not currently used
|
//Not currently used
|
||||||
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
|
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
|
||||||
|
@ -98,8 +98,13 @@ bool p3Posted::getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &g
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Posted::getPostData(const uint32_t &token, std::vector<RsPostedPost> &msgs)
|
bool p3Posted::getPostData(const uint32_t &token, std::vector<RsPostedPost> &msgs, std::vector<RsGxsComment> &cmts)
|
||||||
{
|
{
|
||||||
|
#ifdef POSTED_DEBUG
|
||||||
|
std::cerr << "p3Posted::getPostData()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
GxsMsgDataMap msgData;
|
GxsMsgDataMap msgData;
|
||||||
bool ok = RsGenExchange::getMsgData(token, msgData);
|
bool ok = RsGenExchange::getMsgData(token, msgData);
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
@ -110,32 +115,60 @@ bool p3Posted::getPostData(const uint32_t &token, std::vector<RsPostedPost> &msg
|
|||||||
|
|
||||||
for(; mit != msgData.end(); ++mit)
|
for(; mit != msgData.end(); ++mit)
|
||||||
{
|
{
|
||||||
RsGxsGroupId grpId = mit->first;
|
|
||||||
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||||
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
||||||
|
|
||||||
for(; vit != msgItems.end(); ++vit)
|
for(; vit != msgItems.end(); ++vit)
|
||||||
{
|
{
|
||||||
RsGxsPostedPostItem* item = dynamic_cast<RsGxsPostedPostItem*>(*vit);
|
RsGxsPostedPostItem* postItem = dynamic_cast<RsGxsPostedPostItem*>(*vit);
|
||||||
|
|
||||||
if(item)
|
if(postItem)
|
||||||
{
|
{
|
||||||
RsPostedPost msg = item->mPost;
|
RsPostedPost msg = postItem->mPost;
|
||||||
msg.mMeta = item->meta;
|
msg.mMeta = postItem->meta;
|
||||||
msg.calculateScores(now);
|
msg.calculateScores(now);
|
||||||
|
|
||||||
msgs.push_back(msg);
|
msgs.push_back(msg);
|
||||||
delete item;
|
delete postItem;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "Not a PostedPostItem, deleting!" << std::endl;
|
RsGxsCommentItem* cmtItem = dynamic_cast<RsGxsCommentItem*>(*vit);
|
||||||
delete *vit;
|
if(cmtItem)
|
||||||
|
{
|
||||||
|
RsGxsComment cmt;
|
||||||
|
RsGxsMsgItem *mi = (*vit);
|
||||||
|
cmt = cmtItem->mMsg;
|
||||||
|
cmt.mMeta = mi->meta;
|
||||||
|
#ifdef GXSCOMMENT_DEBUG
|
||||||
|
std::cerr << "p3Posted::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;
|
||||||
|
//const uint8_t RS_PKT_SUBTYPE_GXSCHANNEL_POST_ITEM = 0x03;
|
||||||
|
//const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM = 0xf1;
|
||||||
|
std::cerr << "Not a PostedPostItem neither a RsGxsCommentItem"
|
||||||
|
<< " PacketService=" << std::hex << (int)msg->PacketService() << std::dec
|
||||||
|
<< " PacketSubType=" << std::hex << (int)msg->PacketSubType() << std::dec
|
||||||
|
<< " , deleting!" << std::endl;
|
||||||
|
delete *vit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "p3GxsChannels::getPostData() ERROR in request";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,8 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
|
|
||||||
// Posted Specific DataTypes.
|
// Posted Specific DataTypes.
|
||||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups);
|
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups);
|
||||||
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts);
|
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts, std::vector<RsGxsComment> &cmts);
|
||||||
|
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts) { std::vector<RsGxsComment> cmts; return getPostData( token, posts, cmts);}
|
||||||
//Not currently used
|
//Not currently used
|
||||||
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts);
|
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts);
|
||||||
|
|
||||||
|
@ -84,6 +84,8 @@ void PostedItem::setup()
|
|||||||
ui->dateLabel->clear();
|
ui->dateLabel->clear();
|
||||||
ui->fromLabel->clear();
|
ui->fromLabel->clear();
|
||||||
ui->siteLabel->clear();
|
ui->siteLabel->clear();
|
||||||
|
ui->newCommentLabel->hide();
|
||||||
|
ui->commLabel->hide();
|
||||||
|
|
||||||
/* general ones */
|
/* general ones */
|
||||||
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(removeItem()));
|
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(removeItem()));
|
||||||
@ -160,21 +162,37 @@ void PostedItem::loadGroup(const uint32_t &token)
|
|||||||
void PostedItem::loadMessage(const uint32_t &token)
|
void PostedItem::loadMessage(const uint32_t &token)
|
||||||
{
|
{
|
||||||
std::vector<RsPostedPost> posts;
|
std::vector<RsPostedPost> posts;
|
||||||
if (!rsPosted->getPostData(token, posts))
|
std::vector<RsGxsComment> cmts;
|
||||||
|
if (!rsPosted->getPostData(token, posts, cmts))
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (posts.size() != 1)
|
if (posts.size() == 1)
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items";
|
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. Remove It.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
removeItem();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPost(posts[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedItem::fill()
|
void PostedItem::fill()
|
||||||
@ -390,15 +408,15 @@ void PostedItem::setReadStatus(bool isNew, bool isUnread)
|
|||||||
ui->newLabel->setVisible(isNew);
|
ui->newLabel->setVisible(isNew);
|
||||||
|
|
||||||
/* unpolish widget to clear the stylesheet's palette cache */
|
/* 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();
|
QPalette palette = ui->mainFrame->palette();
|
||||||
palette.setColor(ui->frame->backgroundRole(), isNew ? COLOR_NEW : COLOR_NORMAL); // QScrollArea
|
palette.setColor(ui->mainFrame->backgroundRole(), isNew ? COLOR_NEW : COLOR_NORMAL); // QScrollArea
|
||||||
palette.setColor(QPalette::Base, isNew ? COLOR_NEW : COLOR_NORMAL); // QTreeWidget
|
palette.setColor(QPalette::Base, isNew ? COLOR_NEW : COLOR_NORMAL); // QTreeWidget
|
||||||
ui->frame->setPalette(palette);
|
ui->mainFrame->setPalette(palette);
|
||||||
|
|
||||||
ui->frame->setProperty("new", isNew);
|
ui->mainFrame->setProperty("new", isNew);
|
||||||
Rshare::refreshStyleSheet(ui->frame, false);
|
Rshare::refreshStyleSheet(ui->mainFrame, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedItem::readToggled(bool checked)
|
void PostedItem::readToggled(bool checked)
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="PostedItemVLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="frame">
|
<widget class="QFrame" name="mainFrame">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -31,7 +31,7 @@
|
|||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="mainFrameVLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="StyledLabel" name="titleLabel">
|
<widget class="StyledLabel" name="titleLabel">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -59,9 +59,33 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<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>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="buttonHLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="StyledLabel" name="scoreLabel">
|
<widget class="StyledLabel" name="scoreLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -207,7 +231,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="fromBoldLabel_2">
|
<widget class="QLabel" name="siteBoldLabel">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -297,21 +321,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
<zorder>readAndClearButton</zorder>
|
|
||||||
<zorder>dateBoldLabel</zorder>
|
|
||||||
<zorder>dateLabel</zorder>
|
|
||||||
<zorder>fromBoldLabel</zorder>
|
|
||||||
<zorder>commentButton</zorder>
|
|
||||||
<zorder>newLabel</zorder>
|
|
||||||
<zorder>siteLabel</zorder>
|
|
||||||
<zorder>fromLabel</zorder>
|
|
||||||
<zorder>readButton</zorder>
|
|
||||||
<zorder>fromBoldLabel_2</zorder>
|
|
||||||
<zorder>clearButton</zorder>
|
|
||||||
<zorder>titleLabel</zorder>
|
<zorder>titleLabel</zorder>
|
||||||
<zorder>voteDownButton</zorder>
|
|
||||||
<zorder>voteUpButton</zorder>
|
|
||||||
<zorder>scoreLabel</zorder>
|
|
||||||
<zorder></zorder>
|
<zorder></zorder>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -357,6 +367,12 @@
|
|||||||
<extends>QLabel</extends>
|
<extends>QLabel</extends>
|
||||||
<header>gui/gxs/GxsIdLabel.h</header>
|
<header>gui/gxs/GxsIdLabel.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>ElidedLabel</class>
|
||||||
|
<extends>QLabel</extends>
|
||||||
|
<header location="global">gui/common/ElidedLabel.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
|
@ -269,8 +269,9 @@ void GxsChannelPostItem::loadMessage(const uint32_t &token)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items";
|
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
removeItem();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user