Show channel logo in group tree

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7528 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-09-11 22:07:06 +00:00
parent 3dff1d7bfc
commit e07dac9ca7
6 changed files with 110 additions and 20 deletions

View File

@ -648,7 +648,7 @@ void GxsGroupFrameDialog::messageTabInfoChanged(QWidget *widget)
} }
///***** INSERT GROUP LISTS *****/ ///***** INSERT GROUP LISTS *****/
void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo) void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata */*userdata*/)
{ {
groupItemInfo.id = QString::fromStdString(groupInfo.mGroupId.toStdString()); groupItemInfo.id = QString::fromStdString(groupInfo.mGroupId.toStdString());
groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str()); groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str());
@ -669,7 +669,7 @@ void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupI
} }
} }
void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGroupMetaData> &groupList) void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGroupMetaData> &groupList, const RsUserdata *userdata)
{ {
if (!mInitialized) { if (!mInitialized) {
return; return;
@ -688,7 +688,7 @@ void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGroupMetaData> &gro
uint32_t flags = it->mSubscribeFlags; uint32_t flags = it->mSubscribeFlags;
GroupItemInfo groupItemInfo; GroupItemInfo groupItemInfo;
groupInfoToGroupItemInfo(*it, groupItemInfo); groupInfoToGroupItemInfo(*it, groupItemInfo, userdata);
if (IS_GROUP_SUBSCRIBED(flags)) if (IS_GROUP_SUBSCRIBED(flags))
{ {
@ -788,12 +788,18 @@ void GxsGroupFrameDialog::requestGroupSummary()
mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUP_SUMMARY); mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUP_SUMMARY);
RsTokReqOptions opts; RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; opts.mReqType = requestGroupSummaryType();
uint32_t token; uint32_t token;
mTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_GROUP_SUMMARY); mTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_GROUP_SUMMARY);
} }
void GxsGroupFrameDialog::loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata *&/*userdata*/)
{
/* Default implementation for request type GXS_REQUEST_TYPE_GROUP_META */
mInterface->getGroupSummary(token, groupInfo);
}
void GxsGroupFrameDialog::loadGroupSummary(const uint32_t &token) void GxsGroupFrameDialog::loadGroupSummary(const uint32_t &token)
{ {
#ifdef DEBUG_GROUPFRAMEDIALOG #ifdef DEBUG_GROUPFRAMEDIALOG
@ -802,23 +808,16 @@ void GxsGroupFrameDialog::loadGroupSummary(const uint32_t &token)
#endif #endif
std::list<RsGroupMetaData> groupInfo; std::list<RsGroupMetaData> groupInfo;
mInterface->getGroupSummary(token, groupInfo); RsUserdata *userdata = NULL;
loadGroupSummaryToken(token, groupInfo, userdata);
if (groupInfo.size() > 0) insertGroupsData(groupInfo, userdata);
{
mStateHelper->setActive(TOKEN_TYPE_GROUP_SUMMARY, true);
insertGroupsData(groupInfo);
}
else
{
std::cerr << "GxsGroupFrameDialog::loadGroupSummary() ERROR No Groups...";
std::cerr << std::endl;
mStateHelper->setActive(TOKEN_TYPE_GROUP_SUMMARY, false);
}
mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, false); mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, false);
if (userdata) {
delete(userdata);
}
} }
/*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/

View File

@ -26,6 +26,7 @@
#include "RsAutoUpdatePage.h" #include "RsAutoUpdatePage.h"
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "util/RsUserdata.h"
#include <inttypes.h> #include <inttypes.h>
@ -90,6 +91,7 @@ protected:
bool getCurrentGroupName(QString& name); bool getCurrentGroupName(QString& name);
virtual RetroShareLink::enumType getLinkType() = 0; virtual RetroShareLink::enumType getLinkType() = 0;
virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Nothing; } virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Nothing; }
virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata);
private slots: private slots:
void todo(); void todo();
@ -139,7 +141,6 @@ private:
void initUi(); void initUi();
void updateMessageSummaryList(RsGxsGroupId groupId); void updateMessageSummaryList(RsGxsGroupId groupId);
void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo);
void openGroupInNewTab(const RsGxsGroupId &groupId); void openGroupInNewTab(const RsGxsGroupId &groupId);
void groupSubscribe(bool subscribe); void groupSubscribe(bool subscribe);
@ -147,10 +148,12 @@ private:
void processSettings(bool load); void processSettings(bool load);
// New Request/Response Loading Functions. // New Request/Response Loading Functions.
void insertGroupsData(const std::list<RsGroupMetaData> &groupList); void insertGroupsData(const std::list<RsGroupMetaData> &groupList, const RsUserdata *userdata);
void requestGroupSummary(); void requestGroupSummary();
void loadGroupSummary(const uint32_t &token); void loadGroupSummary(const uint32_t &token);
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_META; } // request only meta data
virtual void loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata* &userdata); // use with requestGroupSummaryType
void requestGroupStatistics(const RsGxsGroupId &groupId); void requestGroupStatistics(const RsGxsGroupId &groupId);
void loadGroupStatistics(const uint32_t &token); void loadGroupStatistics(const uint32_t &token);

View File

@ -27,6 +27,16 @@
#include "gui/feeds/GxsChannelPostItem.h" #include "gui/feeds/GxsChannelPostItem.h"
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "gui/common/GroupTreeWidget.h"
class GxsChannelGroupInfoData : public RsUserdata
{
public:
GxsChannelGroupInfoData() : RsUserdata() {}
public:
QMap<RsGxsGroupId, QIcon> mIcon;
};
/** Constructor */ /** Constructor */
GxsChannelDialog::GxsChannelDialog(QWidget *parent) GxsChannelDialog::GxsChannelDialog(QWidget *parent)
@ -168,3 +178,42 @@ void GxsChannelDialog::toggleAutoDownload()
std::cerr << std::endl; std::cerr << std::endl;
} }
} }
void GxsChannelDialog::loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata *&userdata)
{
std::vector<RsGxsChannelGroup> groups;
rsGxsChannels->getGroupData(token, groups);
/* Save groups to fill icons */
GxsChannelGroupInfoData *channelData = new GxsChannelGroupInfoData;
userdata = channelData;
std::vector<RsGxsChannelGroup>::iterator groupIt;
for (groupIt = groups.begin(); groupIt != groups.end(); ++groupIt) {
RsGxsChannelGroup &group = *groupIt;
groupInfo.push_back(group.mMeta);
if (group.mImage.mData != NULL) {
QPixmap image;
image.loadFromData(group.mImage.mData, group.mImage.mSize, "PNG");
channelData->mIcon[group.mMeta.mGroupId] = image;
}
}
}
void GxsChannelDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata)
{
GxsGroupFrameDialog::groupInfoToGroupItemInfo(groupInfo, groupItemInfo, userdata);
const GxsChannelGroupInfoData *channelData = dynamic_cast<const GxsChannelGroupInfoData*>(userdata);
if (!channelData) {
std::cerr << "GxsChannelDialog::groupInfoToGroupItemInfo() Failed to cast data to GxsChannelGroupInfoData";
std::cerr << std::endl;
return;
}
QMap<RsGxsGroupId, QIcon>::const_iterator iconIt = channelData->mIcon.find(groupInfo.mGroupId);
if (iconIt != channelData->mIcon.end()) {
groupItemInfo.icon = iconIt.value();
}
}

View File

@ -43,9 +43,11 @@ public:
virtual UserNotify *getUserNotify(QObject *parent); virtual UserNotify *getUserNotify(QObject *parent);
protected: protected:
/* GxsGroupFrameDialog */
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; } virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Channel; } virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Channel; }
virtual QString getHelpString() const ; virtual QString getHelpString() const ;
virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata);
private slots: private slots:
void toggleAutoDownload(); void toggleAutoDownload();
@ -62,6 +64,8 @@ private:
virtual void groupTreeCustomActions(RsGxsGroupId grpId, int subscribeFlags, QList<QAction*> &actions); virtual void groupTreeCustomActions(RsGxsGroupId grpId, int subscribeFlags, QList<QAction*> &actions);
virtual RsGxsCommentService *getCommentService(); virtual RsGxsCommentService *getCommentService();
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId); 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 #endif

View File

@ -367,6 +367,7 @@ HEADERS += rshare.h \
util/Widget.h \ util/Widget.h \
util/rsguiversion.h \ util/rsguiversion.h \
util/RsAction.h \ util/RsAction.h \
util/RsUserdata.h \
util/printpreview.h \ util/printpreview.h \
util/log.h \ util/log.h \
util/misc.h \ util/misc.h \

View File

@ -0,0 +1,34 @@
/****************************************************************
* This file is distributed under the following license:
*
* Copyright (c) 2014, RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _RSUSERDATA_H
#define _RSUSERDATA_H
class RsUserdata
{
protected:
RsUserdata() {}
public:
virtual ~RsUserdata() {}
};
#endif