mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
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:
parent
3dff1d7bfc
commit
e07dac9ca7
@ -648,7 +648,7 @@ void GxsGroupFrameDialog::messageTabInfoChanged(QWidget *widget)
|
||||
}
|
||||
|
||||
///***** 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.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) {
|
||||
return;
|
||||
@ -688,7 +688,7 @@ void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGroupMetaData> &gro
|
||||
uint32_t flags = it->mSubscribeFlags;
|
||||
|
||||
GroupItemInfo groupItemInfo;
|
||||
groupInfoToGroupItemInfo(*it, groupItemInfo);
|
||||
groupInfoToGroupItemInfo(*it, groupItemInfo, userdata);
|
||||
|
||||
if (IS_GROUP_SUBSCRIBED(flags))
|
||||
{
|
||||
@ -788,12 +788,18 @@ void GxsGroupFrameDialog::requestGroupSummary()
|
||||
mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUP_SUMMARY);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
opts.mReqType = requestGroupSummaryType();
|
||||
|
||||
uint32_t token;
|
||||
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)
|
||||
{
|
||||
#ifdef DEBUG_GROUPFRAMEDIALOG
|
||||
@ -802,23 +808,16 @@ void GxsGroupFrameDialog::loadGroupSummary(const uint32_t &token)
|
||||
#endif
|
||||
|
||||
std::list<RsGroupMetaData> groupInfo;
|
||||
mInterface->getGroupSummary(token, groupInfo);
|
||||
RsUserdata *userdata = NULL;
|
||||
loadGroupSummaryToken(token, groupInfo, userdata);
|
||||
|
||||
if (groupInfo.size() > 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
insertGroupsData(groupInfo, userdata);
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, false);
|
||||
|
||||
if (userdata) {
|
||||
delete(userdata);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "util/RsUserdata.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
@ -90,6 +91,7 @@ protected:
|
||||
bool getCurrentGroupName(QString& name);
|
||||
virtual RetroShareLink::enumType getLinkType() = 0;
|
||||
virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Nothing; }
|
||||
virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata);
|
||||
|
||||
private slots:
|
||||
void todo();
|
||||
@ -139,7 +141,6 @@ private:
|
||||
void initUi();
|
||||
|
||||
void updateMessageSummaryList(RsGxsGroupId groupId);
|
||||
void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo);
|
||||
|
||||
void openGroupInNewTab(const RsGxsGroupId &groupId);
|
||||
void groupSubscribe(bool subscribe);
|
||||
@ -147,10 +148,12 @@ private:
|
||||
void processSettings(bool load);
|
||||
|
||||
// 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 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 loadGroupStatistics(const uint32_t &token);
|
||||
|
@ -27,6 +27,16 @@
|
||||
#include "gui/feeds/GxsChannelPostItem.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/common/GroupTreeWidget.h"
|
||||
|
||||
class GxsChannelGroupInfoData : public RsUserdata
|
||||
{
|
||||
public:
|
||||
GxsChannelGroupInfoData() : RsUserdata() {}
|
||||
|
||||
public:
|
||||
QMap<RsGxsGroupId, QIcon> mIcon;
|
||||
};
|
||||
|
||||
/** Constructor */
|
||||
GxsChannelDialog::GxsChannelDialog(QWidget *parent)
|
||||
@ -168,3 +178,42 @@ void GxsChannelDialog::toggleAutoDownload()
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -43,9 +43,11 @@ public:
|
||||
virtual UserNotify *getUserNotify(QObject *parent);
|
||||
|
||||
protected:
|
||||
/* GxsGroupFrameDialog */
|
||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
|
||||
virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Channel; }
|
||||
virtual QString getHelpString() const ;
|
||||
virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata);
|
||||
|
||||
private slots:
|
||||
void toggleAutoDownload();
|
||||
@ -62,6 +64,8 @@ private:
|
||||
virtual void groupTreeCustomActions(RsGxsGroupId grpId, int subscribeFlags, QList<QAction*> &actions);
|
||||
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
|
||||
|
@ -367,6 +367,7 @@ HEADERS += rshare.h \
|
||||
util/Widget.h \
|
||||
util/rsguiversion.h \
|
||||
util/RsAction.h \
|
||||
util/RsUserdata.h \
|
||||
util/printpreview.h \
|
||||
util/log.h \
|
||||
util/misc.h \
|
||||
|
34
retroshare-gui/src/util/RsUserdata.h
Normal file
34
retroshare-gui/src/util/RsUserdata.h
Normal 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
|
Loading…
Reference in New Issue
Block a user