diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 9b85a32d1..391aba690 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -251,14 +251,20 @@ void NewsFeed::handleForumEvent(std::shared_ptr event) switch(pe->mForumEventCode) { + case RsForumEventCode::MODERATOR_LIST_CHANGED: + addFeedItem(new GxsForumGroupItem(this, NEWSFEED_UPDATED_FORUM, pe->mForumGroupId,pe->mModeratorsAdded,pe->mModeratorsRemoved, false, true)); + break; + case RsForumEventCode::UPDATED_FORUM: case RsForumEventCode::NEW_FORUM: - addFeedItem(new GxsForumGroupItem(this, NEWSFEED_FORUMNEWLIST, pe->mForumGroupId, false, true)); + addFeedItem(new GxsForumGroupItem(this, NEWSFEED_NEW_FORUM, pe->mForumGroupId, false, true)); break; + case RsForumEventCode::UPDATED_MESSAGE: case RsForumEventCode::NEW_MESSAGE: - addFeedItem(new GxsForumMsgItem(this, NEWSFEED_FORUMNEWLIST, pe->mForumGroupId, pe->mForumMsgId, false, true)); + addFeedItem(new GxsForumMsgItem(this, NEWSFEED_NEW_FORUM, pe->mForumGroupId, pe->mForumMsgId, false, true)); break; + default: break; } } diff --git a/retroshare-gui/src/gui/NewsFeed.h b/retroshare-gui/src/gui/NewsFeed.h index 0086009aa..713bcf96c 100644 --- a/retroshare-gui/src/gui/NewsFeed.h +++ b/retroshare-gui/src/gui/NewsFeed.h @@ -31,8 +31,10 @@ const uint32_t NEWSFEED_PEERLIST = 0x0001; -const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002; -const uint32_t NEWSFEED_FORUMMSGLIST = 0x0003; +const uint32_t NEWSFEED_NEW_FORUM = 0x0002; +const uint32_t NEWSFEED_NEW_FORUM_MSG = 0x0003; +const uint32_t NEWSFEED_UPDATED_FORUM = 0x000f; + const uint32_t NEWSFEED_CHANNELNEWLIST = 0x0004; //const uint32_t NEWSFEED_CHANNELMSGLIST = 0x0005; #if 0 diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp index ee96c068e..99a7f61a0 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp @@ -20,6 +20,7 @@ #include "GxsForumGroupItem.h" #include "ui_GxsForumGroupItem.h" +#include "gui/NewsFeed.h" #include "FeedHolder.h" #include "gui/RetroShareLink.h" @@ -37,6 +38,16 @@ GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, co requestGroup(); } +GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const std::list& added_moderators,const std::list& removed_moderators,bool isHome, bool autoUpdate): + GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsForums, autoUpdate), + mAddedModerators(added_moderators), + mRemovedModerators(removed_moderators) +{ + setup(); + + requestGroup(); +} + GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate) : GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsForums, autoUpdate) { @@ -158,10 +169,59 @@ void GxsForumGroupItem::fill() ui->subscribeButton->setEnabled(true); } -// if (mIsNew) -// { + if(feedId() == NEWSFEED_UPDATED_FORUM) + { + if(!mAddedModerators.empty() || !mRemovedModerators.empty()) + { + ui->titleLabel->setText(tr("Moderator list changed")); + ui->moderatorList_GB->show(); + + QString msg; + + if(!mAddedModerators.empty()) + { + msg += "Added moderators:" ; + msg += "

"; + for(auto& gxsid: mAddedModerators) + { + RsIdentityDetails det; + if(rsIdentity->getIdDetails(gxsid,det)) + msg += QString::fromUtf8(det.mNickname.c_str())+" ("+QString::fromStdString(gxsid.toStdString())+"), "; + else + msg += QString("[Unknown name]") + " ("+QString::fromStdString(gxsid.toStdString())+"), "; + } + msg.resize(msg.size()-2); + msg += "

"; + } + if(!mRemovedModerators.empty()) + { + msg += "Removed moderators:" ; + msg += "

"; + for(auto& gxsid: mRemovedModerators) + { + RsIdentityDetails det; + + if( rsIdentity->getIdDetails(gxsid,det)) + msg += QString::fromUtf8(det.mNickname.c_str())+" ("+QString::fromStdString(gxsid.toStdString())+"), "; + else + msg += QString("[Unknown name]") + " ("+QString::fromStdString(gxsid.toStdString())+"), "; + } + msg.resize(msg.size()-2); + msg += "

"; + } + ui->moderatorList_TE->setText(msg); + } + else + { + ui->moderatorList_GB->hide(); + + ui->titleLabel->setText(tr("Forum updated")); + ui->moderatorList_GB->hide(); + } + } + else ui->titleLabel->setText(tr("New Forum")); -// } + // else // { // ui->titleLabel->setText(tr("Updated Forum")); diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h index 442ad70e8..29b7851f2 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h @@ -37,6 +37,7 @@ class GxsForumGroupItem : public GxsGroupFeedItem public: /** Default Constructor */ GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate); + GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const std::list& added_moderators,const std::list& removed_moderators,bool isHome, bool autoUpdate); GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate); ~GxsForumGroupItem(); @@ -65,6 +66,9 @@ private: /** Qt Designer generated object */ Ui::GxsForumGroupItem *ui; + + std::list mAddedModerators; + std::list mRemovedModerators; }; #endif diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui index a506efa7b..cc3994307 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui @@ -6,8 +6,8 @@ 0 0 - 618 - 161 + 784 + 464 @@ -104,8 +104,8 @@ QFrame::Sunken - - + + @@ -280,7 +280,7 @@ - + @@ -334,6 +334,33 @@ + + + + Moderator list + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + +