Added new method to GxsFeedItem to set content with QVariant.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7477 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-07-27 18:29:35 +00:00
parent 3458cdc8fc
commit e588b25b67
6 changed files with 36 additions and 3 deletions

View File

@ -78,6 +78,16 @@ void PostedItem::loadMessage(const uint32_t &token)
setContent(mPost);
}
void PostedItem::setContent(const QVariant &content)
{
if (!content.canConvert<RsPostedPost>()) {
return;
}
RsPostedPost post = content.value<RsPostedPost>();
setContent(post);
}
void PostedItem::setContent(const RsPostedPost &post)
{
mPost = post;

View File

@ -24,6 +24,8 @@
#ifndef MRK_POSTED_POSTED_ITEM_H
#define MRK_POSTED_POSTED_ITEM_H
#include <QMetaType>
#include "ui_PostedItem.h"
#include <retroshare/rsposted.h>
@ -42,6 +44,7 @@ public:
const RsPostedPost &getPost() const;
RsPostedPost &post();
void setContent(const RsPostedPost& post);
virtual void setContent(const QVariant &content);
private slots:
void loadComments();
@ -64,4 +67,6 @@ private:
RsPostedPost mPost;
};
Q_DECLARE_METATYPE(RsPostedPost)
#endif

View File

@ -73,7 +73,17 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, cons
loadPost(post);
}
bool GxsChannelPostItem::setPost(const RsGxsChannelPost &post)
void GxsChannelPostItem::setContent(const QVariant &content)
{
if (!content.canConvert<RsGxsChannelPost>()) {
return;
}
RsGxsChannelPost post = content.value<RsGxsChannelPost>();
setContent(post);
}
bool GxsChannelPostItem::setContent(const RsGxsChannelPost &post)
{
if (groupId() != post.mMeta.mGroupId || messageId() != post.mMeta.mMsgId) {
std::cerr << "GxsChannelPostItem::setPost() - Wrong id, cannot set post";

View File

@ -24,6 +24,8 @@
#ifndef _GXS_CHANNEL_POST_ITEM_H
#define _GXS_CHANNEL_POST_ITEM_H
#include <QMetaType>
#include <retroshare/rsgxschannels.h>
#include "gui/gxs/GxsFeedItem.h"
#include <stdint.h>
@ -46,8 +48,10 @@ public:
GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subscribeFlags, bool isHome, bool autoUpdate);
virtual ~GxsChannelPostItem();
virtual void setContent(const QVariant &content);
bool setContent(const RsGxsChannelPost &post);
void setFileCleanUpWarning(uint32_t time_left);
bool setPost(const RsGxsChannelPost &post);
const QString getTitleLabel() {return QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); }
const QString getMsgLabel() {return RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); }
@ -96,4 +100,6 @@ private:
Ui::GxsChannelPostItem *ui;
};
Q_DECLARE_METATYPE(RsGxsChannelPost)
#endif

View File

@ -45,6 +45,8 @@ public:
RsGxsGroupId groupId() { return mGroupId; }
RsGxsMessageId messageId() { return mMessageId; }
virtual void setContent(const QVariant &content) = 0;
protected:
// generic Fns - to be overloaded.
virtual void updateItemStatic();

View File

@ -311,7 +311,7 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
}
}
if (item) {
item->setPost(*it);
item->setContent(*it);
//TODO: Sort timestamp
} else {
item = new GxsChannelPostItem(this, 0, *it, subscribeFlags, true, false);