Fixed filter of description in group tree of forums, channels and posted.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7797 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-12-27 22:13:29 +00:00
parent f7a08a53a1
commit 51825d851c
6 changed files with 114 additions and 5 deletions

View File

@ -28,9 +28,19 @@
#include "PostedUserNotify.h"
#include "gui/gxs/GxsGroupShareKey.h"
#include "gui/settings/rsharesettings.h"
#include "gui/common/GroupTreeWidget.h"
#include <retroshare/rsposted.h>
class PostedGroupInfoData : public RsUserdata
{
public:
PostedGroupInfoData() : RsUserdata() {}
public:
QMap<RsGxsGroupId, QString> mDescription;
};
/** Constructor */
PostedDialog::PostedDialog(QWidget *parent)
: GxsGroupFrameDialog(rsPosted, parent)
@ -136,3 +146,40 @@ QWidget *PostedDialog::createCommentHeaderWidget(const RsGxsGroupId &grpId, cons
{
return new PostedItem(NULL, 0, grpId, msgId, true, false);
}
void PostedDialog::loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata *&userdata)
{
std::vector<RsPostedGroup> groups;
rsPosted->getGroupData(token, groups);
/* Save groups to fill description */
PostedGroupInfoData *postedData = new PostedGroupInfoData;
userdata = postedData;
std::vector<RsPostedGroup>::iterator groupIt;
for (groupIt = groups.begin(); groupIt != groups.end(); ++groupIt) {
RsPostedGroup &group = *groupIt;
groupInfo.push_back(group.mMeta);
if (!group.mDescription.empty()) {
postedData->mDescription[group.mMeta.mGroupId] = QString::fromUtf8(group.mDescription.c_str());
}
}
}
void PostedDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata)
{
GxsGroupFrameDialog::groupInfoToGroupItemInfo(groupInfo, groupItemInfo, userdata);
const PostedGroupInfoData *postedData = dynamic_cast<const PostedGroupInfoData*>(userdata);
if (!postedData) {
std::cerr << "PostedDialog::groupInfoToGroupItemInfo() Failed to cast data to PostedGroupInfoData";
std::cerr << std::endl;
return;
}
QMap<RsGxsGroupId, QString>::const_iterator descriptionIt = postedData->mDescription.find(groupInfo.mGroupId);
if (descriptionIt != postedData->mDescription.end()) {
groupItemInfo.description = descriptionIt.value();
}
}

View File

@ -48,6 +48,7 @@ protected:
virtual QString getHelpString() const ;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Posted; }
virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata);
private:
/* GxsGroupFrameDialog */
@ -60,6 +61,8 @@ private:
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId);
virtual RsGxsCommentService *getCommentService();
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data
virtual void loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata* &userdata);
};
#endif

View File

@ -649,7 +649,6 @@ void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupI
{
groupItemInfo.id = QString::fromStdString(groupInfo.mGroupId.toStdString());
groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str());
//groupItemInfo.description =
groupItemInfo.popularity = groupInfo.mPop;
groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost);
groupItemInfo.subscribeFlags = groupInfo.mSubscribeFlags;

View File

@ -36,6 +36,7 @@ public:
public:
QMap<RsGxsGroupId, QIcon> mIcon;
QMap<RsGxsGroupId, QString> mDescription;
};
/** Constructor */
@ -181,7 +182,7 @@ void GxsChannelDialog::loadGroupSummaryToken(const uint32_t &token, std::list<Rs
std::vector<RsGxsChannelGroup> groups;
rsGxsChannels->getGroupData(token, groups);
/* Save groups to fill icons */
/* Save groups to fill icons and description */
GxsChannelGroupInfoData *channelData = new GxsChannelGroupInfoData;
userdata = channelData;
@ -195,6 +196,10 @@ void GxsChannelDialog::loadGroupSummaryToken(const uint32_t &token, std::list<Rs
image.loadFromData(group.mImage.mData, group.mImage.mSize, "PNG");
channelData->mIcon[group.mMeta.mGroupId] = image;
}
if (!group.mDescription.empty()) {
channelData->mDescription[group.mMeta.mGroupId] = QString::fromUtf8(group.mDescription.c_str());
}
}
}
@ -209,6 +214,11 @@ void GxsChannelDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo
return;
}
QMap<RsGxsGroupId, QString>::const_iterator descriptionIt = channelData->mDescription.find(groupInfo.mGroupId);
if (descriptionIt != channelData->mDescription.end()) {
groupItemInfo.description = descriptionIt.value();
}
QMap<RsGxsGroupId, QIcon>::const_iterator iconIt = channelData->mIcon.find(groupInfo.mGroupId);
if (iconIt != channelData->mIcon.end()) {
groupItemInfo.icon = iconIt.value();

View File

@ -25,6 +25,16 @@
#include "GxsForumUserNotify.h"
#include "gui/notifyqt.h"
#include "gui/gxs/GxsGroupShareKey.h"
#include "gui/common/GroupTreeWidget.h"
class GxsForumGroupInfoData : public RsUserdata
{
public:
GxsForumGroupInfoData() : RsUserdata() {}
public:
QMap<RsGxsGroupId, QString> mDescription;
};
/** Constructor */
GxsForumsDialog::GxsForumsDialog(QWidget *parent)
@ -125,3 +135,40 @@ GxsMessageFrameWidget *GxsForumsDialog::createMessageFrameWidget(const RsGxsGrou
{
return new GxsForumThreadWidget(groupId);
}
void GxsForumsDialog::loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata *&userdata)
{
std::vector<RsGxsForumGroup> groups;
rsGxsForums->getGroupData(token, groups);
/* Save groups to fill description */
GxsForumGroupInfoData *forumData = new GxsForumGroupInfoData;
userdata = forumData;
std::vector<RsGxsForumGroup>::iterator groupIt;
for (groupIt = groups.begin(); groupIt != groups.end(); ++groupIt) {
RsGxsForumGroup &group = *groupIt;
groupInfo.push_back(group.mMeta);
if (!group.mDescription.empty()) {
forumData->mDescription[group.mMeta.mGroupId] = QString::fromUtf8(group.mDescription.c_str());
}
}
}
void GxsForumsDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata)
{
GxsGroupFrameDialog::groupInfoToGroupItemInfo(groupInfo, groupItemInfo, userdata);
const GxsForumGroupInfoData *forumData = dynamic_cast<const GxsForumGroupInfoData*>(userdata);
if (!forumData) {
std::cerr << "GxsForumsDialog::groupInfoToGroupItemInfo() Failed to cast data to GxsForumGroupInfoData";
std::cerr << std::endl;
return;
}
QMap<RsGxsGroupId, QString>::const_iterator descriptionIt = forumData->mDescription.find(groupInfo.mGroupId);
if (descriptionIt != forumData->mDescription.end()) {
groupItemInfo.description = descriptionIt.value();
}
}

View File

@ -44,6 +44,7 @@ protected:
virtual QString getHelpString() const ;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Forum; }
virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata);
private:
/* GxsGroupFrameDialog */
@ -54,6 +55,8 @@ private:
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId);
virtual int shareKeyType();
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId);
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data
virtual void loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata* &userdata);
};
#endif