Added feed item for Posted group and message

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7694 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-11-21 00:50:18 +00:00
parent 7014a8f171
commit 3ef04a61c9
15 changed files with 1048 additions and 120 deletions

View File

@ -70,6 +70,7 @@ const uint32_t RS_FEED_TYPE_CHAT = 0x0100;
const uint32_t RS_FEED_TYPE_MSG = 0x0200;
const uint32_t RS_FEED_TYPE_FILES = 0x0400;
const uint32_t RS_FEED_TYPE_SECURITY = 0x0800;
const uint32_t RS_FEED_TYPE_POSTED = 0x1000;
const uint32_t RS_FEED_ITEM_PEER_CONNECT = RS_FEED_TYPE_PEER | 0x0001;
const uint32_t RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x0002;
@ -97,6 +98,10 @@ const uint32_t RS_FEED_ITEM_FORUM_MSG = RS_FEED_TYPE_FORUM | 0x0003;
//const uint32_t RS_FEED_ITEM_BLOG_UPDATE = RS_FEED_TYPE_BLOG | 0x0002;
//const uint32_t RS_FEED_ITEM_BLOG_MSG = RS_FEED_TYPE_BLOG | 0x0003;
const uint32_t RS_FEED_ITEM_POSTED_NEW = RS_FEED_TYPE_POSTED | 0x0001;
//const uint32_t RS_FEED_ITEM_POSTED_UPDATE = RS_FEED_TYPE_POSTED | 0x0002;
const uint32_t RS_FEED_ITEM_POSTED_MSG = RS_FEED_TYPE_POSTED | 0x0003;
const uint32_t RS_FEED_ITEM_CHAT_NEW = RS_FEED_TYPE_CHAT | 0x0001;
const uint32_t RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001;
const uint32_t RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001;

View File

@ -32,6 +32,9 @@
#include "services/p3postbase.h"
#include "serialiser/rsgxscommentitems.h"
#include "rsserver/p3face.h"
#include "retroshare/rsnotify.h"
// For Dummy Msgs.
#include "util/rsrandom.h"
#include "util/rsstring.h"
@ -86,14 +89,20 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << "p3PostBase::notifyChanges()";
std::cerr << std::endl;
p3Notify *notify = NULL;
if (!changes.empty())
{
notify = RsServer::notify();
}
std::vector<RsGxsNotify *>::iterator it;
for(it = changes.begin(); it != changes.end(); ++it)
{
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(*it);
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
if (msgChange)
{
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(*it);
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
if (msgChange)
{
std::cerr << "p3PostBase::notifyChanges() Found Message Change Notification";
std::cerr << std::endl;
@ -107,10 +116,19 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
// FUTURE OPTIMISATION.
// It could be taken a step further and directly request these msgs for an update.
addGroupForProcessing(mit->first);
}
}
/* pass on Group Changes to GUI */
if (notify && msgChange->getType() == RsGxsNotify::TYPE_RECEIVE)
{
std::vector<RsGxsMessageId>::iterator mit1;
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
{
notify->AddFeedItem(RS_FEED_ITEM_POSTED_MSG, mit->first.toStdString(), mit1->toStdString());
}
}
}
}
/* pass on Group Changes to GUI */
if (groupChange)
{
std::cerr << "p3PostBase::notifyChanges() Found Group Change Notification";
@ -122,6 +140,11 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
{
std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git;
std::cerr << std::endl;
if (notify && groupChange->getType() == RsGxsNotify::TYPE_RECEIVE)
{
notify->AddFeedItem(RS_FEED_ITEM_POSTED_NEW, git->toStdString());
}
}
}
}

View File

@ -29,6 +29,7 @@
#include <retroshare/rspeers.h>
#include <retroshare/rsgxschannels.h>
#include <retroshare/rsgxsforums.h>
#include <retroshare/rsposted.h>
#include <retroshare/rsmsgs.h>
#include <retroshare/rsplugin.h>
@ -36,6 +37,10 @@
#include "feeds/GxsChannelPostItem.h"
#include "feeds/GxsForumGroupItem.h"
#include "feeds/GxsForumMsgItem.h"
#include "feeds/PostedGroupItem.h"
#include "Posted/PostedItem.h"
#include "feeds/GxsForumMsgItem.h"
#include "settings/rsettingswin.h"
#ifdef BLOGS
@ -69,6 +74,8 @@ const uint32_t NEWSFEED_BLOGMSGLIST = 0x0007;
const uint32_t NEWSFEED_MESSAGELIST = 0x0008;
const uint32_t NEWSFEED_CHATMSGLIST = 0x0009;
const uint32_t NEWSFEED_SECLIST = 0x000a;
const uint32_t NEWSFEED_POSTEDNEWLIST = 0x000b;
const uint32_t NEWSFEED_POSTEDMSGLIST = 0x000c;
#define ROLE_RECEIVED FEED_TREEWIDGET_SORTROLE
@ -91,6 +98,7 @@ NewsFeed::NewsFeed(QWidget *parent) :
mTokenQueueChannel = NULL;
mTokenQueueForum = NULL;
mTokenQueuePosted = NULL;
setUpdateWhenInvisible(true);
@ -136,6 +144,9 @@ NewsFeed::~NewsFeed()
if (mTokenQueueForum) {
delete(mTokenQueueForum);
}
if (mTokenQueuePosted) {
delete(mTokenQueuePosted);
}
}
UserNotify *NewsFeed::getUserNotify(QObject *parent)
@ -228,6 +239,19 @@ void NewsFeed::updateDisplay()
addFeedItemForumMsg(fi);
break;
case RS_FEED_ITEM_POSTED_NEW:
if (flags & RS_FEED_TYPE_POSTED)
addFeedItemPostedNew(fi);
break;
// case RS_FEED_ITEM_POSTED_UPDATE:
// if (flags & RS_FEED_TYPE_POSTED)
// addFeedItemPostedUpdate(fi);
// break;
case RS_FEED_ITEM_POSTED_MSG:
if (flags & RS_FEED_TYPE_POSTED)
addFeedItemPostedMsg(fi);
break;
#if 0
case RS_FEED_ITEM_BLOG_NEW:
if (flags & RS_FEED_TYPE_BLOG)
@ -341,6 +365,20 @@ void NewsFeed::testFeeds(uint notifyFlags)
break;
}
case RS_FEED_TYPE_POSTED:
{
if (!instance->mTokenQueuePosted) {
instance->mTokenQueuePosted = new TokenQueue(rsPosted->getTokenService(), instance);
}
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
uint32_t token;
instance->mTokenQueuePosted->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_GROUP);
break;
}
#if 0
case RS_FEED_TYPE_BLOG:
// not used
@ -516,7 +554,7 @@ void NewsFeed::loadForumMessage(const uint32_t &token)
{
std::vector<RsGxsForumMsg> msgs;
if (!rsGxsForums->getMsgData(token, msgs)) {
std::cerr << "NewsFeed::loadChannelPost() ERROR getting data";
std::cerr << "NewsFeed::loadForumPost() ERROR getting data";
std::cerr << std::endl;
return;
}
@ -543,6 +581,80 @@ void NewsFeed::loadForumMessage(const uint32_t &token)
}
}
void NewsFeed::loadPostedGroup(const uint32_t &token)
{
std::vector<RsPostedGroup> posted;
if (!rsPosted->getGroupData(token, posted)) {
std::cerr << "NewsFeed::loadPostedGroup() ERROR getting data";
std::cerr << std::endl;
return;
}
RsFeedItem fi;
std::vector<RsPostedGroup>::iterator postedIt;
for (postedIt = posted.begin(); postedIt != posted.end(); ++postedIt) {
if (fi.mId1.empty()) {
/* store first posted */
fi.mId1 = postedIt->mMeta.mGroupId.toStdString();
}
if (!postedIt->mDescription.empty()) {
/* take posted with description */
fi.mId1 = postedIt->mMeta.mGroupId.toStdString();
break;
}
}
if (fi.mId1.empty()) {
return;
}
instance->addFeedItemPostedNew(fi);
// instance->addFeedItemPostedUpdate(fi);
/* Prepare group ids for message request */
std::list<RsGxsGroupId> grpIds;
for (postedIt = posted.begin(); postedIt != posted.end(); ++postedIt) {
grpIds.push_back(postedIt->mMeta.mGroupId);
}
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
opts.mOptions = RS_TOKREQOPT_MSG_THREAD;
uint32_t msgToken;
instance->mTokenQueuePosted->requestMsgInfo(msgToken, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, TOKEN_TYPE_MESSAGE);
}
void NewsFeed::loadPostedMessage(const uint32_t &token)
{
std::vector<RsPostedPost> msgs;
if (!rsPosted->getPostData(token, msgs)) {
std::cerr << "NewsFeed::loadPostedPost() ERROR getting data";
std::cerr << std::endl;
return;
}
RsFeedItem fi;
std::vector<RsPostedPost>::iterator msgIt;
for (msgIt = msgs.begin(); msgIt != msgs.end(); ++msgIt) {
if (fi.mId2.empty()) {
/* store first posted message */
fi.mId1 = msgIt->mMeta.mGroupId.toStdString();
fi.mId2 = msgIt->mMeta.mMsgId.toStdString();
}
if (!msgIt->mLink.empty()) {
/* take posted message with description */
fi.mId1 = msgIt->mMeta.mGroupId.toStdString();
fi.mId2 = msgIt->mMeta.mMsgId.toStdString();
break;
}
}
if (!fi.mId1.empty()) {
instance->addFeedItemPostedMsg(fi);
}
}
void NewsFeed::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
if (queue == mTokenQueueChannel) {
@ -578,6 +690,23 @@ void NewsFeed::loadRequest(const TokenQueue *queue, const TokenRequest &req)
break;
}
}
if (queue == mTokenQueuePosted) {
switch (req.mUserType) {
case TOKEN_TYPE_GROUP:
loadPostedGroup(req.mToken);
break;
case TOKEN_TYPE_MESSAGE:
loadPostedMessage(req.mToken);
break;
default:
std::cerr << "NewsFeed::loadRequest() ERROR: INVALID TYPE";
std::cerr << std::endl;
break;
}
}
}
void NewsFeed::testFeed(FeedNotify *feedNotify)
@ -886,6 +1015,61 @@ void NewsFeed::addFeedItemForumMsg(const RsFeedItem &fi)
#endif
}
void NewsFeed::addFeedItemPostedNew(const RsFeedItem &fi)
{
RsGxsGroupId grpId(fi.mId1);
if (grpId.isNull()) {
return;
}
/* make new widget */
PostedGroupItem *item = new PostedGroupItem(this, NEWSFEED_POSTEDNEWLIST, grpId, false, true);
/* add to layout */
addFeedItem(item);
#ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemPostedNew()";
std::cerr << std::endl;
#endif
}
//void NewsFeed::addFeedItemPostedUpdate(const RsFeedItem &fi)
//{
// /* make new widget */
// GxsPostedGroupItem *item = new GxsPostedGroupItem(this, NEWSFEED_POSTEDNEWLIST, grpId, false, true);
// /* add to layout */
// addFeedItem(item);
//#ifdef NEWS_DEBUG
// std::cerr << "NewsFeed::addFeedItemPostedUpdate()";
// std::cerr << std::endl;
//#endif
//}
void NewsFeed::addFeedItemPostedMsg(const RsFeedItem &fi)
{
RsGxsGroupId grpId(fi.mId1);
RsGxsMessageId msgId(fi.mId2);
if (grpId.isNull() || msgId.isNull()) {
return;
}
/* make new widget */
PostedItem *item = new PostedItem(this, NEWSFEED_POSTEDMSGLIST, grpId, msgId, false, true);
/* add to layout */
addFeedItem(item);
#ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemPostedMsg()";
std::cerr << std::endl;
#endif
}
#if 0
void NewsFeed::addFeedItemBlogNew(const RsFeedItem &fi)
{

View File

@ -96,9 +96,15 @@ private:
void addFeedItemChannelNew(const RsFeedItem &fi);
// void addFeedItemChannelUpdate(const RsFeedItem &fi);
void addFeedItemChannelMsg(const RsFeedItem &fi);
void addFeedItemForumNew(const RsFeedItem &fi);
// void addFeedItemForumUpdate(const RsFeedItem &fi);
void addFeedItemForumMsg(const RsFeedItem &fi);
void addFeedItemPostedNew(const RsFeedItem &fi);
// void addFeedItemPostedUpdate(const RsFeedItem &fi);
void addFeedItemPostedMsg(const RsFeedItem &fi);
#if 0
void addFeedItemBlogNew(const RsFeedItem &fi);
void addFeedItemBlogMsg(const RsFeedItem &fi);
@ -114,9 +120,13 @@ private:
virtual void loadForumGroup(const uint32_t &token);
virtual void loadForumMessage(const uint32_t &token);
virtual void loadPostedGroup(const uint32_t &token);
virtual void loadPostedMessage(const uint32_t &token);
private:
TokenQueue *mTokenQueueChannel;
TokenQueue *mTokenQueueForum;
TokenQueue *mTokenQueuePosted;
/* UI - from Designer */
Ui::NewsFeed *ui;

View File

@ -134,5 +134,5 @@ RsGxsCommentService *PostedDialog::getCommentService()
QWidget *PostedDialog::createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId)
{
return new PostedItem(NULL, 0, grpId, msgId, true);
return new PostedItem(NULL, 0, grpId, msgId, true, false);
}

View File

@ -37,8 +37,8 @@
/** Constructor */
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome) :
GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsPosted, false)
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate) :
GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsPosted, autoUpdate)
{
setup();
@ -46,8 +46,8 @@ PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroup
requestMessage();
}
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedGroup &group, const RsPostedPost &post, bool isHome) :
GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsPosted, false)
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedGroup &group, const RsPostedPost &post, bool isHome, bool autoUpdate) :
GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsPosted, autoUpdate)
{
setup();
@ -55,8 +55,8 @@ PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedGr
setPost(post);
}
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedPost &post, bool isHome) :
GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsPosted, false)
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedPost &post, bool isHome, bool autoUpdate) :
GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsPosted, autoUpdate)
{
setup();
@ -85,11 +85,22 @@ void PostedItem::setup()
ui->fromLabel->clear();
ui->siteLabel->clear();
/* general ones */
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(removeItem()));
/* specific */
connect(ui->readAndClearButton, SIGNAL(clicked()), this, SLOT(readAndClearItem()));
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)));
ui->clearButton->hide();
ui->readAndClearButton->hide();
ui->frame_notes->hide();
}
bool PostedItem::setGroup(const RsPostedGroup &group, bool doFill)
@ -237,6 +248,17 @@ void PostedItem::fill()
ui->newLabel->hide();
}
if (mIsHome)
{
ui->clearButton->hide();
ui->readAndClearButton->hide();
}
else
{
ui->clearButton->show();
ui->readAndClearButton->show();
}
// disable voting buttons - if they have already voted.
if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK)
{
@ -263,6 +285,8 @@ void PostedItem::fill()
#endif
mInFill = false;
emit sizeChanged(this);
}
const RsPostedPost &PostedItem::getPost() const
@ -361,3 +385,14 @@ void PostedItem::readToggled(bool checked)
setReadStatus(false, checked);
}
void PostedItem::readAndClearItem()
{
#ifdef DEBUG_ITEM
std::cerr << "PostedItem::readAndClearItem()";
std::cerr << std::endl;
#endif
readToggled(false);
removeItem();
}

View File

@ -40,9 +40,9 @@ class PostedItem : public GxsFeedItem
Q_OBJECT
public:
PostedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome);
PostedItem(FeedHolder *parent, uint32_t feedId, const RsPostedGroup &group, const RsPostedPost &post, bool isHome);
PostedItem(FeedHolder *parent, uint32_t feedId, const RsPostedPost &post, bool isHome);
PostedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate);
PostedItem(FeedHolder *parent, uint32_t feedId, const RsPostedGroup &group, const RsPostedPost &post, bool isHome, bool autoUpdate);
PostedItem(FeedHolder *parent, uint32_t feedId, const RsPostedPost &post, bool isHome, bool autoUpdate);
virtual ~PostedItem();
bool setGroup(const RsPostedGroup& group, bool doFill = true);
@ -59,6 +59,7 @@ private slots:
void makeUpVote();
void makeDownVote();
void readToggled(bool checked);
void readAndClearItem();
signals:
void vote(const RsGxsGrpMsgIdPair& msgId, bool up);

View File

@ -33,20 +33,74 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="2">
<widget class="QLabel" name="newLabel">
<item row="1" column="11">
<widget class="QPushButton" name="readAndClearButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Set as read and remove item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/cancel.png</normaloff>:/images/cancel.png</iconset>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="dateBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>New</string>
<string>Submitted</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QLabel" name="dateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">You eyes only</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
@ -112,54 +166,6 @@
</item>
</layout>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="commentButton">
<property name="text">
<string>Comments</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="dateBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Submitted</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QLabel" name="dateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">You eyes only</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QLabel" name="fromBoldLabel">
<property name="sizePolicy">
@ -180,44 +186,17 @@
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="GxsIdLabel" name="fromLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<item row="1" column="3">
<widget class="QPushButton" name="commentButton">
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
<string>Comments</string>
</property>
</widget>
</item>
<item row="1" column="8">
<widget class="QLabel" name="fromBoldLabel_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<item row="1" column="2">
<widget class="QLabel" name="newLabel">
<property name="text">
<string>Site</string>
<string>New</string>
</property>
</widget>
</item>
@ -242,18 +221,26 @@
</property>
</widget>
</item>
<item row="1" column="10">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="1" column="7">
<widget class="GxsIdLabel" name="fromLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>118</width>
<height>20</height>
</size>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
</spacer>
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="readButton">
@ -284,7 +271,60 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="10">
<item row="1" column="8">
<widget class="QLabel" name="fromBoldLabel_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Site</string>
</property>
</widget>
</item>
<item row="1" column="10">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>118</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="12">
<widget class="QPushButton" name="clearButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item row="0" column="1" colspan="12">
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
@ -319,10 +359,10 @@
<item>
<widget class="QFrame" name="frame_notes">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">

View File

@ -334,7 +334,7 @@ void PostedListWidget::loadPost(const RsPostedPost &post)
RsPostedGroup dummyGroup;
dummyGroup.mMeta.mGroupId = groupId();
PostedItem *item = new PostedItem(this, 0, dummyGroup, post, true);
PostedItem *item = new PostedItem(this, 0, dummyGroup, post, true, false);
connect(item, SIGNAL(vote(RsGxsGrpMsgIdPair,bool)), this, SLOT(submitVote(RsGxsGrpMsgIdPair,bool)));
mPosts.insert(post.mMeta.mMsgId, item);
//QLayout *alayout = ui.scrollAreaWidgetContents->layout();

View File

@ -0,0 +1,210 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2014 RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "PostedGroupItem.h"
#include "ui_PostedGroupItem.h"
#include "FeedHolder.h"
#include "gui/RetroShareLink.h"
/****
* #define DEBUG_ITEM 1
****/
PostedGroupItem::PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate) :
GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsPosted, autoUpdate)
{
setup();
requestGroup();
}
PostedGroupItem::PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedGroup &group, bool isHome, bool autoUpdate) :
GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsPosted, autoUpdate)
{
setup();
setGroup(group);
}
PostedGroupItem::~PostedGroupItem()
{
delete(ui);
}
void PostedGroupItem::setup()
{
/* Invoke the Qt Designer generated object setup routine */
ui = new(Ui::PostedGroupItem);
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
/* clear ui */
ui->nameLabel->setText(tr("Loading"));
ui->titleLabel->clear();
ui->descLabel->clear();
/* general ones */
connect(ui->expandButton, SIGNAL(clicked()), this, SLOT(toggle()));
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(removeItem()));
/* specific */
connect(ui->subscribeButton, SIGNAL(clicked()), this, SLOT(subscribePosted()));
connect(ui->copyLinkButton, SIGNAL(clicked()), this, SLOT(copyGroupLink()));
ui->copyLinkButton->hide(); // No link type at this moment
ui->expandFrame->hide();
}
bool PostedGroupItem::setGroup(const RsPostedGroup &group)
{
if (groupId() != group.mMeta.mGroupId) {
std::cerr << "PostedGroupItem::setContent() - Wrong id, cannot set post";
std::cerr << std::endl;
return false;
}
mGroup = group;
fill();
return true;
}
void PostedGroupItem::loadGroup(const uint32_t &token)
{
#ifdef DEBUG_ITEM
std::cerr << "PostedGroupItem::loadGroup()";
std::cerr << std::endl;
#endif
std::vector<RsPostedGroup> groups;
if (!rsPosted->getGroupData(token, groups))
{
std::cerr << "PostedGroupItem::loadGroup() ERROR getting data";
std::cerr << std::endl;
return;
}
if (groups.size() != 1)
{
std::cerr << "PostedGroupItem::loadGroup() Wrong number of Items";
std::cerr << std::endl;
return;
}
setGroup(groups[0]);
}
QString PostedGroupItem::groupName()
{
return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str());
}
void PostedGroupItem::fill()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "PostedGroupItem::fill()";
std::cerr << std::endl;
#endif
// No link type at this moment
// RetroShareLink link;
// link.createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroup.mMeta.mGroupId, groupName());
// ui->nameLabel->setText(link.toHtml());
ui->nameLabel->setText(groupName());
ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str()));
//TODO - nice icon for subscribed group
if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) {
ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png"));
} else {
ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png"));
}
if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) {
ui->subscribeButton->setEnabled(false);
} else {
ui->subscribeButton->setEnabled(true);
}
// if (mIsNew)
// {
ui->titleLabel->setText(tr("New Posted"));
// }
// else
// {
// ui->titleLabel->setText(tr("Updated Posted"));
// }
if (mIsHome)
{
/* disable buttons */
ui->clearButton->setEnabled(false);
}
}
void PostedGroupItem::toggle()
{
expand(ui->expandFrame->isHidden());
}
void PostedGroupItem::expand(bool open)
{
if (mFeedHolder)
{
mFeedHolder->lockLayout(this, true);
}
if (open)
{
ui->expandFrame->show();
ui->expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
ui->expandButton->setToolTip(tr("Hide"));
}
else
{
ui->expandFrame->hide();
ui->expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
ui->expandButton->setToolTip(tr("Expand"));
}
emit sizeChanged(this);
if (mFeedHolder)
{
mFeedHolder->lockLayout(this, false);
}
}
void PostedGroupItem::subscribePosted()
{
#ifdef DEBUG_ITEM
std::cerr << "PostedGroupItem::subscribePosted()";
std::cerr << std::endl;
#endif
subscribe();
}

View File

@ -0,0 +1,72 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2014 RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _POSTEDGROUPITEM_H
#define _POSTEDGROUPITEM_H
#include <retroshare/rsposted.h>
#include "gui/gxs/GxsGroupFeedItem.h"
namespace Ui {
class PostedGroupItem;
}
class FeedHolder;
class PostedGroupItem : public GxsGroupFeedItem
{
Q_OBJECT
public:
/** Default Constructor */
PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate);
PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedGroup &group, bool isHome, bool autoUpdate);
~PostedGroupItem();
bool setGroup(const RsPostedGroup &group);
/* FeedItem */
virtual void expand(bool open);
protected:
/* GxsGroupFeedItem */
virtual QString groupName();
virtual void loadGroup(const uint32_t &token);
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
private slots:
/* default stuff */
void toggle();
void subscribePosted();
private:
void fill();
void setup();
private:
RsPostedGroup mGroup;
/** Qt Designer generated object */
Ui::PostedGroupItem *ui;
};
#endif

View File

@ -0,0 +1,335 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PostedGroupItem</class>
<widget class="QWidget" name="PostedGroupItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>618</width>
<height>157</height>
</rect>
</property>
<layout class="QGridLayout">
<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>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<layout class="QGridLayout">
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="logoLabel">
<property name="minimumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../Posted/Posted_images.qrc">:/images/posted_64.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Posted</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="nameLabel">
<property name="text">
<string notr="true">name</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>254</width>
<height>28</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="copyLinkButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/copyrslink.png</normaloff>:/images/copyrslink.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="subscribeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Subscribe to Posted</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/directoryadd_24x24_shadow.png</normaloff>:/images/directoryadd_24x24_shadow.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QFrame" name="expandFrame">
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<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>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Posted Description</string>
</property>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="iconLabel">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/contacts24.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="descLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Description
of Posted</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -118,6 +118,8 @@ uint NotifyPage::getNewsFlags()
newsFlags |= RS_FEED_TYPE_CHANNEL;
if (ui.notify_Forums->isChecked())
newsFlags |= RS_FEED_TYPE_FORUM;
if (ui.notify_Posted->isChecked())
newsFlags |= RS_FEED_TYPE_POSTED;
#if 0
if (ui.notify_Blogs->isChecked())
newsFlags |= RS_FEED_TYPE_BLOG;
@ -228,6 +230,7 @@ void NotifyPage::load()
ui.notify_Peers->setChecked(newsflags & RS_FEED_TYPE_PEER);
ui.notify_Channels->setChecked(newsflags & RS_FEED_TYPE_CHANNEL);
ui.notify_Forums->setChecked(newsflags & RS_FEED_TYPE_FORUM);
ui.notify_Posted->setChecked(newsflags & RS_FEED_TYPE_POSTED);
#if 0
ui.notify_Blogs->setChecked(newsflags & RS_FEED_TYPE_BLOG);
#endif

View File

@ -48,6 +48,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="notify_Posted">
<property name="text">
<string>Posted</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="notify_Blogs">
<property name="text">

View File

@ -1227,6 +1227,7 @@ posted {
gui/Posted/PostedListWidget.h \
gui/Posted/PostedItem.h \
gui/Posted/PostedGroupDialog.h \
gui/feeds/PostedGroupItem.h \
gui/Posted/PostedCreatePostDialog.h \
gui/Posted/PostedUserNotify.h
@ -1234,6 +1235,7 @@ posted {
#gui/Posted/PostedComments.h \
FORMS += gui/Posted/PostedListWidget.ui \
gui/feeds/PostedGroupItem.ui \
gui/Posted/PostedItem.ui \
gui/Posted/PostedCreatePostDialog.ui \
@ -1243,6 +1245,7 @@ posted {
SOURCES += gui/Posted/PostedDialog.cpp \
gui/Posted/PostedListWidget.cpp \
gui/feeds/PostedGroupItem.cpp \
gui/Posted/PostedItem.cpp \
gui/Posted/PostedGroupDialog.cpp \
gui/Posted/PostedCreatePostDialog.cpp \