diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index 56e26809f..850ba7314 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -78,6 +78,16 @@ void PostedItem::loadMessage(const uint32_t &token) setContent(mPost); } +void PostedItem::setContent(const QVariant &content) +{ + if (!content.canConvert()) { + return; + } + + RsPostedPost post = content.value(); + setContent(post); +} + void PostedItem::setContent(const RsPostedPost &post) { mPost = post; diff --git a/retroshare-gui/src/gui/Posted/PostedItem.h b/retroshare-gui/src/gui/Posted/PostedItem.h index 3429c2c35..0462f07bb 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.h +++ b/retroshare-gui/src/gui/Posted/PostedItem.h @@ -24,6 +24,8 @@ #ifndef MRK_POSTED_POSTED_ITEM_H #define MRK_POSTED_POSTED_ITEM_H +#include + #include "ui_PostedItem.h" #include @@ -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 diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 75e74149f..03037a4c5 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -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()) { + return; + } + + RsGxsChannelPost post = content.value(); + 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"; diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h index a05e404a9..359ea89e4 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h @@ -24,6 +24,8 @@ #ifndef _GXS_CHANNEL_POST_ITEM_H #define _GXS_CHANNEL_POST_ITEM_H +#include + #include #include "gui/gxs/GxsFeedItem.h" #include @@ -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 diff --git a/retroshare-gui/src/gui/gxs/GxsFeedItem.h b/retroshare-gui/src/gui/gxs/GxsFeedItem.h index 26c14f783..06a5e7d9a 100644 --- a/retroshare-gui/src/gui/gxs/GxsFeedItem.h +++ b/retroshare-gui/src/gui/gxs/GxsFeedItem.h @@ -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(); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index 2f864135d..25785c941 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -311,7 +311,7 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector &po } } if (item) { - item->setPost(*it); + item->setContent(*it); //TODO: Sort timestamp } else { item = new GxsChannelPostItem(this, 0, *it, subscribeFlags, true, false);