Merge pull request #1502 from defnax/added-group-icons-for-posted-links

Added group icons for posted links
This commit is contained in:
csoler 2019-04-18 21:56:07 +02:00 committed by GitHub
commit bc8adb74c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 690 additions and 328 deletions

View File

@ -44,6 +44,7 @@ class RsPostedGroup
RsGroupMetaData mMeta;
std::string mDescription;
RsGxsImage mGroupImage;
};

View File

@ -44,7 +44,15 @@ void RsGxsPostedPostItem::serial_process(RsGenericSerializer::SerializeJob j,RsG
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
@ -109,6 +117,42 @@ void RsGxsPostedPostItem::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;
}

View File

@ -42,8 +42,12 @@ public:
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;
};

View File

@ -79,9 +79,8 @@ bool p3Posted::getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &g
RsGxsPostedGroupItem* item = dynamic_cast<RsGxsPostedGroupItem*>(*vit);
if (item)
{
RsPostedGroup grp = item->mGroup;
item->mGroup.mMeta = item->meta;
grp.mMeta = item->mGroup.mMeta;
RsPostedGroup grp;
item->toPostedGroup(grp, true);
delete item;
groups.push_back(grp);
}
@ -265,8 +264,8 @@ bool p3Posted::createGroup(uint32_t &token, RsPostedGroup &group)
std::cerr << "p3Posted::createGroup()" << std::endl;
RsGxsPostedGroupItem* grpItem = new RsGxsPostedGroupItem();
grpItem->mGroup = group;
grpItem->meta = group.mMeta;
grpItem->fromPostedGroup(group, true);
RsGenExchange::publishGroup(token, grpItem);
return true;
@ -278,8 +277,8 @@ bool p3Posted::updateGroup(uint32_t &token, RsPostedGroup &group)
std::cerr << "p3Posted::updateGroup()" << std::endl;
RsGxsPostedGroupItem* grpItem = new RsGxsPostedGroupItem();
grpItem->mGroup = group;
grpItem->meta = group.mMeta;
grpItem->fromPostedGroup(group, true);
RsGenExchange::updateGroup(token, grpItem);
return true;

View File

@ -35,6 +35,7 @@ public:
PostedGroupInfoData() : RsUserdata() {}
public:
QMap<RsGxsGroupId, QIcon> mIcon;
QMap<RsGxsGroupId, QString> mDescription;
};
@ -102,15 +103,15 @@ QString PostedDialog::icon(IconType type)
case ICON_NEW:
return ":/icons/png/add.png";
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 "";
case ICON_SUBSCRIBED_GROUP:
return "";
case ICON_POPULAR_GROUP:
return "";
case ICON_OTHER_GROUP:
return "";
case ICON_DEFAULT:
return ":/icons/png/posted.png";
}
return "";
@ -159,6 +160,12 @@ void PostedDialog::loadGroupSummaryToken(const uint32_t &token, std::list<RsGrou
for (groupIt = groups.begin(); groupIt != groups.end(); ++groupIt) {
RsPostedGroup &group = *groupIt;
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()) {
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()) {
groupItemInfo.description = descriptionIt.value();
}
QMap<RsGxsGroupId, QIcon>::const_iterator iconIt = postedData->mIcon.find(groupInfo.mGroupId);
if (iconIt != postedData->mIcon.end()) {
groupItemInfo.icon = iconIt.value();
}
}

View File

@ -17,6 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#include <QBuffer>
#include "PostedGroupDialog.h"
@ -25,7 +26,7 @@
const uint32_t PostedCreateEnabledFlags = (
GXS_GROUP_FLAGS_NAME |
// GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN |
@ -90,14 +91,31 @@ QPixmap PostedGroupDialog::serviceImage()
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)
{
// Specific Function.
RsPostedGroup grp;
grp.mMeta = meta;
grp.mDescription = getDescription().toStdString();
std::cerr << "PostedGroupDialog::service_CreateGroup() storing to Queue";
std::cerr << std::endl;
preparePostedGroup(grp, meta);
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)
{
RsPostedGroup grp;
grp.mMeta = editedMeta;
grp.mDescription = getDescription().toUtf8().constData();
preparePostedGroup(grp, editedMeta);
std::cerr << "PostedGroupDialog::service_EditGroup() submitting changes";
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 << std::endl;
groupMetaData = groups[0].mMeta;
description = QString::fromUtf8(groups[0].mDescription.c_str());
const RsPostedGroup &group = groups[0];
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;
}

View File

@ -39,6 +39,9 @@ protected:
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_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta);
private:
void preparePostedGroup(RsPostedGroup &group, const RsGroupMetaData &meta);
};
#endif

View File

@ -109,7 +109,18 @@ void PostedItem::setup()
QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this);
connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink()));
int S = QFontMetricsF(font()).height() ;
ui->voteUpButton->setIconSize(QSize(S*1.5,S*1.5));
ui->voteDownButton->setIconSize(QSize(S*1.5,S*1.5));
ui->commentButton->setIconSize(QSize(S*1.5,S*1.5));
ui->expandButton->setIconSize(QSize(S*1.5,S*1.5));
ui->notesButton->setIconSize(QSize(S*1.5,S*1.5));
ui->readButton->setIconSize(QSize(S*1.5,S*1.5));
ui->shareButton->setIconSize(QSize(S*1.5,S*1.5));
QMenu *menu = new QMenu();
menu->addAction(CopyLinkAction);
ui->shareButton->setMenu(menu);
@ -235,20 +246,25 @@ void PostedItem::fill()
return;
}
QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png");
mInFill = true;
int desired_height = 1.5*(ui->voteDownButton->height() + ui->voteUpButton->height() + ui->scoreLabel->height());
int desired_width = sqpixmap2.width()*desired_height/(float)sqpixmap2.height();
if(mPost.mImage.mData != NULL)
{
QPixmap pixmap;
pixmap.loadFromData(mPost.mImage.mData, mPost.mImage.mSize, "PNG");
// Wiping data - as its been passed to thumbnail.
QPixmap sqpixmap = pixmap.scaled(800, 600, Qt::KeepAspectRatio, Qt::SmoothTransformation);
ui->pictureLabel->setPixmap(sqpixmap);
ui->thumbnailLabel->setPixmap(pixmap);
}else
QPixmap sqpixmap = pixmap.scaled(desired_width,desired_height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
ui->thumbnailLabel->setPixmap(sqpixmap);
ui->pictureLabel->setPixmap(pixmap);
}
else
{
//ui->thumbnailLabel->setFixedSize(desired_width,desired_height);
ui->expandButton->setDisabled(true);
}
@ -290,7 +306,7 @@ void PostedItem::fill()
urlstr += QString(" </span></a>");
QString siteurl = url.scheme() + "://" + url.host();
sitestr = QString("<a href=\"%1\" ><span style=\" text-decoration: underline; color:#2255AA;\"> %2 </span></a>").arg(siteurl).arg(siteurl);
sitestr = QString("<a href=\"%1\" ><span style=\" text-decoration: underline; color:#0079d3;\"> %2 </span></a>").arg(siteurl).arg(siteurl);
ui->titleLabel->setText(urlstr);
}else

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>617</width>
<height>190</height>
<width>825</width>
<height>337</height>
</rect>
</property>
<property name="windowTitle">
@ -67,6 +67,12 @@
</property>
<item row="0" column="0" rowspan="2">
<widget class="QFrame" name="voteFrame">
<property name="minimumSize">
<size>
<width>37</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
@ -100,12 +106,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Vote up</string>
</property>
@ -116,12 +116,6 @@
<iconset resource="Posted_images.qrc">
<normaloff>:/images/up-arrow.png</normaloff>:/images/up-arrow.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
@ -161,12 +155,6 @@
<iconset resource="Posted_images.qrc">
<normaloff>:/images/down-arrow.png</normaloff>:/images/down-arrow.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
@ -198,6 +186,12 @@
</property>
<item>
<widget class="QLabel" name="thumbnailLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
@ -312,7 +306,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>3</number>
<number>5</number>
</property>
<property name="leftMargin">
<number>0</number>
@ -371,25 +365,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="siteBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Site</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="siteLabel">
<property name="sizePolicy">
@ -426,6 +401,9 @@
</item>
<item>
<layout class="QHBoxLayout" name="buttonHLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
@ -705,8 +683,8 @@
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
<include location="Posted_images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -26,8 +26,12 @@
#include "PostedCreatePostDialog.h"
#include "PostedItem.h"
#include "gui/common/UIStateHelper.h"
#include "gui/RetroShareLink.h"
#include "util/HandleRichText.h"
#include "util/DateTime.h"
#include <retroshare/rsposted.h>
#include "retroshare/rsgxscircles.h"
#define POSTED_DEFAULT_LISTING_LENGTH 10
#define POSTED_MAX_INDEX 10000
@ -65,12 +69,19 @@ PostedListWidget::PostedListWidget(const RsGxsGroupId &postedId, QWidget *parent
/* fill in the available OwnIds for signing */
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
int S = QFontMetricsF(font()).height() ;
ui->submitPostButton->setIconSize(QSize(S*1.5,S*1.5));
ui->comboBox->setIconSize(QSize(S*1.5,S*1.5));
connect(ui->submitPostButton, SIGNAL(clicked()), this, SLOT(newPost()));
ui->subscribeToolButton->setToolTip(tr( "<p>Subscribing to the links will gather \
available posts from your subscribed friends, and make the \
links visible to all other friends.</p><p>Afterwards you can unsubscribe from the context menu of the links list at left.</p>"));
ui->infoframe->hide();
/* load settings */
processSettings(true);
@ -293,6 +304,67 @@ void PostedListWidget::insertPostedDetails(const RsPostedGroup &group)
mStateHelper->setWidgetEnabled(ui->submitPostButton, IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags));
ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags));
ui->subscribeToolButton->setHidden(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) ;
RetroShareLink link;
if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) {
ui->infoframe->hide();
} else {
ui->infoPosts->setText(QString::number(group.mMeta.mVisibleMsgCount));
if(group.mMeta.mLastPost==0)
ui->infoLastPost->setText(tr("Never"));
else
ui->infoLastPost->setText(DateTime::formatLongDateTime(group.mMeta.mLastPost));
QString formatDescription = QString::fromUtf8(group.mDescription.c_str());
unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS;
formatDescription = RsHtml().formatText(NULL, formatDescription, formatFlag);
ui->infoDescription->setText(formatDescription);
ui->infoAdministrator->setId(group.mMeta.mAuthorId) ;
link = RetroShareLink::createMessage(group.mMeta.mAuthorId, "");
ui->infoAdministrator->setText(link.toHtml());
QString distrib_string ( "[unknown]" );
switch(group.mMeta.mCircleType)
{
case GXS_CIRCLE_TYPE_PUBLIC: distrib_string = tr("Public") ;
break ;
case GXS_CIRCLE_TYPE_EXTERNAL:
{
RsGxsCircleDetails det ;
// !! What we need here is some sort of CircleLabel, which loads the circle and updates the label when done.
if(rsGxsCircles->getCircleDetails(group.mMeta.mCircleId,det))
distrib_string = tr("Restricted to members of circle \"")+QString::fromUtf8(det.mCircleName.c_str()) +"\"";
else
distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ;
}
break ;
case GXS_CIRCLE_TYPE_YOUR_EYES_ONLY: distrib_string = tr("Your eyes only");
break ;
case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("You and your friend nodes");
break ;
default:
std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl;
}
ui->infoDistribution->setText(distrib_string);
ui->infoframe->show();
}
}
/*********************** **** **** **** ***********************/

View File

@ -205,6 +205,186 @@
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="infoframe">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="infoGroupBox">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="title">
<string>Topic Details</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<property name="topMargin">
<number>6</number>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Administrator:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="infoPostsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Posts:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="infoLastPostLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Last Post:</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QTextBrowser" name="infoDescription">
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="openLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="infoDescriptionLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="infoPosts">
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="infoLastPost">
<property name="text">
<string notr="true">unknown</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Distribution:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="infoDistribution">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
@ -258,6 +438,11 @@
<extends>QComboBox</extends>
<header>gui/gxs/GxsIdChooser.h</header>
</customwidget>
<customwidget>
<class>GxsIdLabel</class>
<extends>QLabel</extends>
<header>gui/gxs/GxsIdLabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>

View File

@ -134,14 +134,23 @@ void PostedGroupItem::fill()
// ui->nameLabel->setText(groupName());
ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str()));
//TODO - nice icon for subscribed group
if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) {
ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png"));
if (mGroup.mGroupImage.mData != NULL) {
QPixmap postedImage;
postedImage.loadFromData(mGroup.mGroupImage.mData, mGroup.mGroupImage.mSize, "PNG");
ui->logoLabel->setPixmap(QPixmap(postedImage));
} else {
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)) {
ui->subscribeButton->setEnabled(false);
} else {

View File

@ -49,6 +49,15 @@ GxsCommentDialog::GxsCommentDialog(QWidget *parent, RsTokenService *token_servic
connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
connect(ui->idChooser, SIGNAL(currentIndexChanged( int )), this, SLOT(voterSelectionChanged( int )));
connect(ui->idChooser, SIGNAL(idsLoaded()), this, SLOT(idChooserReady()));
connect(ui->sortBox, SIGNAL(currentIndexChanged(int)), this, SLOT(sortComments(int)));
// default sort method "HOT".
ui->treeWidget->sortByColumn(4, Qt::DescendingOrder);
int S = QFontMetricsF(font()).height() ;
ui->sortBox->setIconSize(QSize(S*1.5,S*1.5));
}
GxsCommentDialog::~GxsCommentDialog()
@ -141,3 +150,22 @@ void GxsCommentDialog::setCommentHeader(QWidget *header)
ui->notesBrowser->setPlainText(QString::fromStdString(mCurrentPost.mNotes));
#endif
}
void GxsCommentDialog::sortComments(int i)
{
switch(i)
{
default:
case 0:
ui->treeWidget->sortByColumn(4, Qt::DescendingOrder);
break;
case 1:
ui->treeWidget->sortByColumn(2, Qt::DescendingOrder);
break;
case 2:
ui->treeWidget->sortByColumn(3, Qt::DescendingOrder);
break;
}
}

View File

@ -45,6 +45,7 @@ private slots:
void refresh();
void idChooserReady();
void voterSelectionChanged( int index );
void sortComments(int);
private:
RsGxsGroupId mGrpId;

View File

@ -13,8 +13,8 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="GxsCommentDialogVLayout">
<item>
<layout class="QGridLayout" name="GxsCommentDialogGLayout">
<item row="0" column="0">
<widget class="QFrame" name="postFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
@ -24,59 +24,63 @@
</property>
<layout class="QVBoxLayout" name="postFrameVLayout">
<property name="leftMargin">
<number>9</number>
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
</layout>
</widget>
</item>
<item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="toolBarHLayout">
<item>
<widget class="QPushButton" name="hotSortButton">
<property name="text">
<string>Hot</string>
<widget class="QComboBox" name="sortBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol'; font-size:14px; color:#24292e; background-color:#ffffff;&quot;&gt;sort by&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="checkable">
<bool>true</bool>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="newSortButton">
<property name="text">
<string>New</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="topSortButton">
<property name="text">
<string>Top</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<item>
<property name="text">
<string>Hot</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/flame.png</normaloff>:/icons/png/flame.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>New</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/new.png</normaloff>:/icons/png/new.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Top</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/top.png</normaloff>:/icons/png/top.png</iconset>
</property>
</item>
</widget>
</item>
<item>
@ -111,8 +115,11 @@
</item>
</layout>
</item>
<item>
<item row="2" column="0">
<widget class="GxsCommentTreeWidget" name="treeWidget">
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Comment</string>
@ -164,6 +171,8 @@
<header>gui/gxs/GxsCommentTreeWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -31,6 +31,7 @@
#include "gui/gxs/GxsCommentTreeWidget.h"
#include "gui/gxs/GxsCreateCommentDialog.h"
#include "gui/gxs/GxsIdTreeWidgetItem.h"
#include "gui/common/RSTreeWidgetItem.h"
#include <iostream>
@ -45,6 +46,7 @@
#define PCITEM_COLUMN_PARENTID 8
#define PCITEM_COLUMN_AUTHORID 9
#define ROLE_SORT Qt::UserRole + 1
#define GXSCOMMENTS_LOADTHREAD 1
@ -139,6 +141,9 @@ GxsCommentTreeWidget::GxsCommentTreeWidget(QWidget *parent)
setWordWrap(true);
setItemDelegateForColumn(PCITEM_COLUMN_COMMENT,new MultiLinesCommentDelegate(QFontMetricsF(font()))) ;
commentsRole = new RSTreeWidgetItemCompareRole;
commentsRole->setRole(PCITEM_COLUMN_DATE, ROLE_SORT);
// QFont font = QFont("ARIAL", 10);
// font.setBold(true);
@ -537,6 +542,8 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token)
text = qtime.toString("yyyy-MM-dd hh:mm:ss") ;
item->setText(PCITEM_COLUMN_DATE, text) ;
item->setToolTip(PCITEM_COLUMN_DATE, text) ;
item->setData(PCITEM_COLUMN_DATE, ROLE_SORT, QVariant(qlonglong(comment.mMeta.mPublishTs)));
}
text = QString::fromUtf8(comment.mComment.c_str());

View File

@ -27,6 +27,8 @@
#include <retroshare/rsgxscommon.h>
#include <retroshare/rsidentity.h>
class RSTreeWidgetItemCompareRole;
class GxsCommentTreeWidget : public QTreeWidget, public TokenResponse
{
Q_OBJECT
@ -96,6 +98,8 @@ protected:
std::map<RsGxsMessageId, QTreeWidgetItem *> mLoadingMap;
std::multimap<RsGxsMessageId, QTreeWidgetItem *> mPendingInsertMap;
RSTreeWidgetItemCompareRole *commentsRole;
TokenQueue *mTokenQueue;
RsTokenService *mRsTokenService;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
<height>736</height>
<height>633</height>
</rect>
</property>
<property name="windowTitle">

View File

@ -294,7 +294,7 @@
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>3</number>
@ -304,211 +304,176 @@
</property>
<item>
<widget class="QFrame" name="infoFrame">
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>178</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>178</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>178</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>178</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Administrator:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="infoPostsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Posts (at neighbor nodes):</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="infoLastPostLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Last Post:</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QTextBrowser" name="infoDescription">
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Channel details</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Administrator:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="infoPostsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Posts:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="infoLastPostLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Last Post:</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QTextBrowser" name="infoDescription">
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="openLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="infoDescriptionLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="infoPosts">
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="infoLastPost">
<property name="text">
<string notr="true">unknown</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Distribution:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="infoDistribution">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
</layout>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="openLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="infoDescriptionLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="infoPosts">
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="infoLastPost">
<property name="text">
<string notr="true">unknown</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Distribution:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="infoDistribution">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>

View File

@ -786,13 +786,11 @@ GenCertDialog QFrame#profileframe{
PostedListWidget QComboBox#comboBox {
font: bold;
font-size: 15px;
color: #0099cc;
}
PostedListWidget QToolButton#submitPostButton {
font: bold;
font-size: 15px;
}
PostedListWidget QToolButton#subscribeToolButton {
@ -830,10 +828,7 @@ GxsForumThreadWidget QToolButton#subscribeToolButton:hover {
GxsChannelPostsWidget QFrame#infoFrame
{
border: 1px solid #DCDC41;
border-radius: 6px;
background: #FFFFD7;
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2);
}
GxsChannelPostsWidget QToolButton#subscribeToolButton {
@ -889,10 +884,14 @@ PostedItem QFrame#voteFrame {
background: #f8f9fa;
}
PostedItem QFrame#mainFrame{
PostedItem QFrame#mainFrame [new=false]{
background: white;
}
PostedItem > QFrame#mainFrame[new=true] {
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #F0F8FD, stop:0.8 #E6F2FD, stop: 0.81 #E6F2FD, stop: 1 #D2E7FD);
}
PostedItem QFrame#frame_picture{
background: white;
}
@ -906,8 +905,7 @@ PostedItem QLabel#fromBoldLabel, QLabel#fromLabel, QLabel#dateLabel, QLabel#site
color: #787c7e;
}
PostedItem QToolButton#commentButton, QPushButton#shareButton, QToolButton#notesButton{
font-size: 12px;
color: #878a8c;
font-weight: bold;
}
GxsCommentDialog QComboBox#sortBox {
font: bold;
color: #0099cc;
}