From 1e98de76a1a1bf10e6a33c65ddaf2d58a3ed89c3 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 16 Jul 2017 16:56:23 +0200 Subject: [PATCH] fixed filtering for channels when loading items on the fly --- .../src/gui/feeds/GxsChannelPostItem.cpp | 12 ++++++++++++ .../src/gui/feeds/GxsChannelPostItem.h | 7 +++++++ .../gui/gxschannels/GxsChannelPostsWidget.cpp | 17 +++-------------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 4b83f76b4..ed70c0931 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -49,6 +49,18 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsGxsChannels, autoUpdate) +{ + init(messageId,older_versions) ; +} + +GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost& post, bool isHome, bool autoUpdate,const std::set& older_versions) : + GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, autoUpdate) +{ + init(post.mMeta.mMsgId,older_versions) ; + mPost = post ; +} + +void GxsChannelPostItem::init(const RsGxsMessageId& messageId,const std::set& older_versions) { QVector v; bool self = false; diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h index 96d2f499e..1a87a7491 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h @@ -47,6 +47,11 @@ public: GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); + // This method can be called when additional information is known about the post. In this case, the widget will be initialized with some + // minimap information from the post and completed when the use displays it, which shouldn't cost anything more. + + GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost& post, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); + //GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup &group, const RsGxsChannelPost &post, bool isHome, bool autoUpdate); //GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, bool isHome, bool autoUpdate); virtual ~GxsChannelPostItem(); @@ -63,6 +68,8 @@ public: bool isUnread() const ; protected: + void init(const RsGxsMessageId& messageId,const std::set& older_versions); + /* FeedItem */ virtual void doExpand(bool open); virtual void expandFill(bool first); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index 12f5b5e85..3e73e038d 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -395,7 +395,7 @@ void GxsChannelPostsWidget::filterChanged(int filter) return bVisible; } -void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost &post, bool related) +void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool related) { GxsChannelPostItem *item = NULL; @@ -407,12 +407,8 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost &post, bool re if(item) { ui->feedWidget->removeFeedItem(item) ; - //RsGxsChannelGroup dummyGroup; - //dummyGroup.mMeta.mGroupId = groupId(); - //dummyGroup.mMeta.mSubscribeFlags = 0xffffffff; - //GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, dummyGroup, post, true, false); - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post.mMeta.mGroupId, post.mMeta.mMsgId, true, false,post.mOlderVersions); + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post, true, false,post.mOlderVersions); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); return ; @@ -428,14 +424,7 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost &post, bool re item->setPost(post); ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); } else { - /* Group is not always available because of the TokenQueue */ - - //RsGxsChannelGroup dummyGroup; - //dummyGroup.mMeta.mGroupId = groupId(); - //dummyGroup.mMeta.mSubscribeFlags = 0xffffffff; - //GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, dummyGroup, post, true, false); - - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post.mMeta.mGroupId, post.mMeta.mMsgId, true, false,post.mOlderVersions); + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post, true, false,post.mOlderVersions); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); }