mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-20 12:24:24 -04:00
Added for posted links group icons
This commit is contained in:
parent
da505e0426
commit
b6c7afe989
8 changed files with 130 additions and 31 deletions
|
@ -44,6 +44,7 @@ class RsPostedGroup
|
||||||
|
|
||||||
RsGroupMetaData mMeta;
|
RsGroupMetaData mMeta;
|
||||||
std::string mDescription;
|
std::string mDescription;
|
||||||
|
RsGxsImage mGroupImage;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,15 @@ void RsGxsPostedPostItem::serial_process(RsGenericSerializer::SerializeJob j,RsG
|
||||||
|
|
||||||
void RsGxsPostedGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
void RsGxsPostedGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||||
{
|
{
|
||||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR ,mGroup.mDescription,"mGroup.mDescription") ;
|
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR ,mDescription,"mDescription") ;
|
||||||
|
|
||||||
|
if(j == RsGenericSerializer::DESERIALIZE && ctx.mOffset == ctx.mSize)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
if((j == RsGenericSerializer::SIZE_ESTIMATE || j == RsGenericSerializer::SERIALIZE) && mGroupImage.empty())
|
||||||
|
return ;
|
||||||
|
|
||||||
|
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,mGroupImage,"mGroupImage") ;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsItem *RsGxsPostedSerialiser::create_item(uint16_t service_id,uint8_t item_subtype) const
|
RsItem *RsGxsPostedSerialiser::create_item(uint16_t service_id,uint8_t item_subtype) const
|
||||||
|
@ -109,6 +117,42 @@ void RsGxsPostedPostItem::clear()
|
||||||
}
|
}
|
||||||
void RsGxsPostedGroupItem::clear()
|
void RsGxsPostedGroupItem::clear()
|
||||||
{
|
{
|
||||||
mGroup.mDescription.clear();
|
mDescription.clear();
|
||||||
|
mGroupImage.TlvClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RsGxsPostedGroupItem::fromPostedGroup(RsPostedGroup &group, bool moveImage)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
meta = group.mMeta;
|
||||||
|
mDescription = group.mDescription;
|
||||||
|
|
||||||
|
if (moveImage)
|
||||||
|
{
|
||||||
|
mGroupImage.binData.bin_data = group.mGroupImage.mData;
|
||||||
|
mGroupImage.binData.bin_len = group.mGroupImage.mSize;
|
||||||
|
group.mGroupImage.shallowClear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mGroupImage.binData.setBinData(group.mGroupImage.mData, group.mGroupImage.mSize);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RsGxsPostedGroupItem::toPostedGroup(RsPostedGroup &group, bool moveImage)
|
||||||
|
{
|
||||||
|
group.mMeta = meta;
|
||||||
|
group.mDescription = mDescription;
|
||||||
|
if (moveImage)
|
||||||
|
{
|
||||||
|
group.mGroupImage.take((uint8_t *) mGroupImage.binData.bin_data, mGroupImage.binData.bin_len);
|
||||||
|
// mGroupImage doesn't have a ShallowClear at the moment!
|
||||||
|
mGroupImage.binData.TlvShallowClear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
group.mGroupImage.copy((uint8_t *) mGroupImage.binData.bin_data, mGroupImage.binData.bin_len);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -42,8 +42,12 @@ public:
|
||||||
|
|
||||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||||
|
|
||||||
RsPostedGroup mGroup;
|
// use conversion functions to transform:
|
||||||
|
bool fromPostedGroup(RsPostedGroup &group, bool moveImage);
|
||||||
|
bool toPostedGroup(RsPostedGroup &group, bool moveImage);
|
||||||
|
|
||||||
|
std::string mDescription;
|
||||||
|
RsTlvImage mGroupImage;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -79,9 +79,8 @@ bool p3Posted::getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &g
|
||||||
RsGxsPostedGroupItem* item = dynamic_cast<RsGxsPostedGroupItem*>(*vit);
|
RsGxsPostedGroupItem* item = dynamic_cast<RsGxsPostedGroupItem*>(*vit);
|
||||||
if (item)
|
if (item)
|
||||||
{
|
{
|
||||||
RsPostedGroup grp = item->mGroup;
|
RsPostedGroup grp;
|
||||||
item->mGroup.mMeta = item->meta;
|
item->toPostedGroup(grp, true);
|
||||||
grp.mMeta = item->mGroup.mMeta;
|
|
||||||
delete item;
|
delete item;
|
||||||
groups.push_back(grp);
|
groups.push_back(grp);
|
||||||
}
|
}
|
||||||
|
@ -265,8 +264,8 @@ bool p3Posted::createGroup(uint32_t &token, RsPostedGroup &group)
|
||||||
std::cerr << "p3Posted::createGroup()" << std::endl;
|
std::cerr << "p3Posted::createGroup()" << std::endl;
|
||||||
|
|
||||||
RsGxsPostedGroupItem* grpItem = new RsGxsPostedGroupItem();
|
RsGxsPostedGroupItem* grpItem = new RsGxsPostedGroupItem();
|
||||||
grpItem->mGroup = group;
|
grpItem->fromPostedGroup(group, true);
|
||||||
grpItem->meta = group.mMeta;
|
|
||||||
|
|
||||||
RsGenExchange::publishGroup(token, grpItem);
|
RsGenExchange::publishGroup(token, grpItem);
|
||||||
return true;
|
return true;
|
||||||
|
@ -278,8 +277,8 @@ bool p3Posted::updateGroup(uint32_t &token, RsPostedGroup &group)
|
||||||
std::cerr << "p3Posted::updateGroup()" << std::endl;
|
std::cerr << "p3Posted::updateGroup()" << std::endl;
|
||||||
|
|
||||||
RsGxsPostedGroupItem* grpItem = new RsGxsPostedGroupItem();
|
RsGxsPostedGroupItem* grpItem = new RsGxsPostedGroupItem();
|
||||||
grpItem->mGroup = group;
|
grpItem->fromPostedGroup(group, true);
|
||||||
grpItem->meta = group.mMeta;
|
|
||||||
|
|
||||||
RsGenExchange::updateGroup(token, grpItem);
|
RsGenExchange::updateGroup(token, grpItem);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
PostedGroupInfoData() : RsUserdata() {}
|
PostedGroupInfoData() : RsUserdata() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
QMap<RsGxsGroupId, QIcon> mIcon;
|
||||||
QMap<RsGxsGroupId, QString> mDescription;
|
QMap<RsGxsGroupId, QString> mDescription;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -102,15 +103,15 @@ QString PostedDialog::icon(IconType type)
|
||||||
case ICON_NEW:
|
case ICON_NEW:
|
||||||
return ":/icons/png/add.png";
|
return ":/icons/png/add.png";
|
||||||
case ICON_YOUR_GROUP:
|
case ICON_YOUR_GROUP:
|
||||||
return ":/icons/png/feedreader.png";
|
|
||||||
case ICON_SUBSCRIBED_GROUP:
|
|
||||||
return ":/icons/png/feed-subscribed.png";
|
|
||||||
case ICON_POPULAR_GROUP:
|
|
||||||
return ":/icons/png/feed-popular.png";
|
|
||||||
case ICON_OTHER_GROUP:
|
|
||||||
return ":/icons/png/feed-other.png";
|
|
||||||
case ICON_DEFAULT:
|
|
||||||
return "";
|
return "";
|
||||||
|
case ICON_SUBSCRIBED_GROUP:
|
||||||
|
return "";
|
||||||
|
case ICON_POPULAR_GROUP:
|
||||||
|
return "";
|
||||||
|
case ICON_OTHER_GROUP:
|
||||||
|
return "";
|
||||||
|
case ICON_DEFAULT:
|
||||||
|
return ":/icons/png/posted.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
@ -159,6 +160,12 @@ void PostedDialog::loadGroupSummaryToken(const uint32_t &token, std::list<RsGrou
|
||||||
for (groupIt = groups.begin(); groupIt != groups.end(); ++groupIt) {
|
for (groupIt = groups.begin(); groupIt != groups.end(); ++groupIt) {
|
||||||
RsPostedGroup &group = *groupIt;
|
RsPostedGroup &group = *groupIt;
|
||||||
groupInfo.push_back(group.mMeta);
|
groupInfo.push_back(group.mMeta);
|
||||||
|
|
||||||
|
if (group.mGroupImage.mData != NULL) {
|
||||||
|
QPixmap image;
|
||||||
|
image.loadFromData(group.mGroupImage.mData, group.mGroupImage.mSize, "PNG");
|
||||||
|
postedData->mIcon[group.mMeta.mGroupId] = image;
|
||||||
|
}
|
||||||
|
|
||||||
if (!group.mDescription.empty()) {
|
if (!group.mDescription.empty()) {
|
||||||
postedData->mDescription[group.mMeta.mGroupId] = QString::fromUtf8(group.mDescription.c_str());
|
postedData->mDescription[group.mMeta.mGroupId] = QString::fromUtf8(group.mDescription.c_str());
|
||||||
|
@ -181,4 +188,9 @@ void PostedDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, Gr
|
||||||
if (descriptionIt != postedData->mDescription.end()) {
|
if (descriptionIt != postedData->mDescription.end()) {
|
||||||
groupItemInfo.description = descriptionIt.value();
|
groupItemInfo.description = descriptionIt.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMap<RsGxsGroupId, QIcon>::const_iterator iconIt = postedData->mIcon.find(groupInfo.mGroupId);
|
||||||
|
if (iconIt != postedData->mIcon.end()) {
|
||||||
|
groupItemInfo.icon = iconIt.value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
#include <QBuffer>
|
||||||
|
|
||||||
#include "PostedGroupDialog.h"
|
#include "PostedGroupDialog.h"
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
|
|
||||||
const uint32_t PostedCreateEnabledFlags = (
|
const uint32_t PostedCreateEnabledFlags = (
|
||||||
GXS_GROUP_FLAGS_NAME |
|
GXS_GROUP_FLAGS_NAME |
|
||||||
// GXS_GROUP_FLAGS_ICON |
|
GXS_GROUP_FLAGS_ICON |
|
||||||
GXS_GROUP_FLAGS_DESCRIPTION |
|
GXS_GROUP_FLAGS_DESCRIPTION |
|
||||||
GXS_GROUP_FLAGS_DISTRIBUTION |
|
GXS_GROUP_FLAGS_DISTRIBUTION |
|
||||||
// GXS_GROUP_FLAGS_PUBLISHSIGN |
|
// GXS_GROUP_FLAGS_PUBLISHSIGN |
|
||||||
|
@ -90,14 +91,31 @@ QPixmap PostedGroupDialog::serviceImage()
|
||||||
return QPixmap(":/icons/png/posted.png");
|
return QPixmap(":/icons/png/posted.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PostedGroupDialog::preparePostedGroup(RsPostedGroup &group, const RsGroupMetaData &meta)
|
||||||
|
{
|
||||||
|
group.mMeta = meta;
|
||||||
|
group.mDescription = getDescription().toUtf8().constData();
|
||||||
|
|
||||||
|
QPixmap pixmap = getLogo();
|
||||||
|
|
||||||
|
if (!pixmap.isNull()) {
|
||||||
|
QByteArray ba;
|
||||||
|
QBuffer buffer(&ba);
|
||||||
|
|
||||||
|
buffer.open(QIODevice::WriteOnly);
|
||||||
|
pixmap.save(&buffer, "PNG"); // writes image into ba in PNG format
|
||||||
|
|
||||||
|
group.mGroupImage.copy((uint8_t *) ba.data(), ba.size());
|
||||||
|
} else {
|
||||||
|
group.mGroupImage.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool PostedGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
|
bool PostedGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
|
||||||
{
|
{
|
||||||
// Specific Function.
|
// Specific Function.
|
||||||
RsPostedGroup grp;
|
RsPostedGroup grp;
|
||||||
grp.mMeta = meta;
|
preparePostedGroup(grp, meta);
|
||||||
grp.mDescription = getDescription().toStdString();
|
|
||||||
std::cerr << "PostedGroupDialog::service_CreateGroup() storing to Queue";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
rsPosted->createGroup(token, grp);
|
rsPosted->createGroup(token, grp);
|
||||||
|
|
||||||
|
@ -107,8 +125,7 @@ bool PostedGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaDa
|
||||||
bool PostedGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta)
|
bool PostedGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta)
|
||||||
{
|
{
|
||||||
RsPostedGroup grp;
|
RsPostedGroup grp;
|
||||||
grp.mMeta = editedMeta;
|
preparePostedGroup(grp, editedMeta);
|
||||||
grp.mDescription = getDescription().toUtf8().constData();
|
|
||||||
|
|
||||||
std::cerr << "PostedGroupDialog::service_EditGroup() submitting changes";
|
std::cerr << "PostedGroupDialog::service_EditGroup() submitting changes";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -140,8 +157,18 @@ bool PostedGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroup
|
||||||
std::cerr << "PostedGroupDialog::service_loadGroup() Unfinished Loading";
|
std::cerr << "PostedGroupDialog::service_loadGroup() Unfinished Loading";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
groupMetaData = groups[0].mMeta;
|
const RsPostedGroup &group = groups[0];
|
||||||
description = QString::fromUtf8(groups[0].mDescription.c_str());
|
groupMetaData = group.mMeta;
|
||||||
|
description = QString::fromUtf8(group.mDescription.c_str());
|
||||||
|
|
||||||
|
if (group.mGroupImage.mData) {
|
||||||
|
QPixmap pixmap;
|
||||||
|
if (pixmap.loadFromData(group.mGroupImage.mData, group.mGroupImage.mSize, "PNG")) {
|
||||||
|
setLogo(pixmap);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setLogo(QPixmap(":/icons/png/posted.png"));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,9 @@ protected:
|
||||||
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
|
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
|
||||||
virtual bool service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData, QString &description);
|
virtual bool service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData, QString &description);
|
||||||
virtual bool service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta);
|
virtual bool service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void preparePostedGroup(RsPostedGroup &group, const RsGroupMetaData &meta);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -134,14 +134,23 @@ void PostedGroupItem::fill()
|
||||||
// ui->nameLabel->setText(groupName());
|
// ui->nameLabel->setText(groupName());
|
||||||
|
|
||||||
ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str()));
|
ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str()));
|
||||||
|
|
||||||
//TODO - nice icon for subscribed group
|
if (mGroup.mGroupImage.mData != NULL) {
|
||||||
if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) {
|
QPixmap postedImage;
|
||||||
ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png"));
|
postedImage.loadFromData(mGroup.mGroupImage.mData, mGroup.mGroupImage.mSize, "PNG");
|
||||||
|
ui->logoLabel->setPixmap(QPixmap(postedImage));
|
||||||
} else {
|
} else {
|
||||||
ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png"));
|
ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO - nice icon for subscribed group
|
||||||
|
// if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) {
|
||||||
|
// ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png"));
|
||||||
|
// } else {
|
||||||
|
// ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png"));
|
||||||
|
// }
|
||||||
|
|
||||||
if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) {
|
if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) {
|
||||||
ui->subscribeButton->setEnabled(false);
|
ui->subscribeButton->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue