diff --git a/libretroshare/src/retroshare/rsposted.h b/libretroshare/src/retroshare/rsposted.h index 02edb47c8..a42f06c40 100644 --- a/libretroshare/src/retroshare/rsposted.h +++ b/libretroshare/src/retroshare/rsposted.h @@ -44,6 +44,7 @@ class RsPostedGroup RsGroupMetaData mMeta; std::string mDescription; + RsGxsImage mGroupImage; }; diff --git a/libretroshare/src/rsitems/rsposteditems.cc b/libretroshare/src/rsitems/rsposteditems.cc index 7f7adac4d..23fb6633b 100644 --- a/libretroshare/src/rsitems/rsposteditems.cc +++ b/libretroshare/src/rsitems/rsposteditems.cc @@ -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(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; +} diff --git a/libretroshare/src/rsitems/rsposteditems.h b/libretroshare/src/rsitems/rsposteditems.h index ef88289b5..910471c19 100644 --- a/libretroshare/src/rsitems/rsposteditems.h +++ b/libretroshare/src/rsitems/rsposteditems.h @@ -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; }; diff --git a/libretroshare/src/services/p3posted.cc b/libretroshare/src/services/p3posted.cc index d50c0624c..1a1efe0b6 100644 --- a/libretroshare/src/services/p3posted.cc +++ b/libretroshare/src/services/p3posted.cc @@ -79,9 +79,8 @@ bool p3Posted::getGroupData(const uint32_t &token, std::vector &g RsGxsPostedGroupItem* item = dynamic_cast(*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; diff --git a/retroshare-gui/src/gui/Posted/PostedDialog.cpp b/retroshare-gui/src/gui/Posted/PostedDialog.cpp index 320618cab..d4c288732 100644 --- a/retroshare-gui/src/gui/Posted/PostedDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedDialog.cpp @@ -35,6 +35,7 @@ public: PostedGroupInfoData() : RsUserdata() {} public: + QMap mIcon; QMap 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::listmIcon[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::const_iterator iconIt = postedData->mIcon.find(groupInfo.mGroupId); + if (iconIt != postedData->mIcon.end()) { + groupItemInfo.icon = iconIt.value(); + } } diff --git a/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp b/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp index 031ce7da0..6fcb14024 100644 --- a/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp @@ -17,6 +17,7 @@ * along with this program. If not, see . * * * *******************************************************************************/ +#include #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; } diff --git a/retroshare-gui/src/gui/Posted/PostedGroupDialog.h b/retroshare-gui/src/gui/Posted/PostedGroupDialog.h index c96da3ebf..c0d860b96 100644 --- a/retroshare-gui/src/gui/Posted/PostedGroupDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedGroupDialog.h @@ -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 diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index 4a38c2a5a..9ad0aa839 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -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(" "); QString siteurl = url.scheme() + "://" + url.host(); - sitestr = QString(" %2 ").arg(siteurl).arg(siteurl); + sitestr = QString(" %2 ").arg(siteurl).arg(siteurl); ui->titleLabel->setText(urlstr); }else diff --git a/retroshare-gui/src/gui/Posted/PostedItem.ui b/retroshare-gui/src/gui/Posted/PostedItem.ui index af284a7a0..250f43007 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.ui +++ b/retroshare-gui/src/gui/Posted/PostedItem.ui @@ -6,8 +6,8 @@ 0 0 - 617 - 190 + 825 + 337 @@ -67,6 +67,12 @@ + + + 37 + 0 + + @@ -100,12 +106,6 @@ 0 - - - 24 - 24 - - Vote up @@ -116,12 +116,6 @@ :/images/up-arrow.png:/images/up-arrow.png - - - 16 - 16 - - true @@ -161,12 +155,6 @@ :/images/down-arrow.png:/images/down-arrow.png - - - 16 - 16 - - true @@ -198,6 +186,12 @@ + + + 0 + 0 + + 100 @@ -312,7 +306,7 @@ - 3 + 5 0 @@ -371,25 +365,6 @@ - - - - - 0 - 0 - - - - - 75 - true - - - - Site - - - @@ -426,6 +401,9 @@ + + 6 + 0 @@ -705,8 +683,8 @@ - + diff --git a/retroshare-gui/src/gui/Posted/PostedListWidget.cpp b/retroshare-gui/src/gui/Posted/PostedListWidget.cpp index be8e0ad69..2d8d2cfd9 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidget.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidget.cpp @@ -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 +#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( "

Subscribing to the links will gather \ available posts from your subscribed friends, and make the \ links visible to all other friends.

Afterwards you can unsubscribe from the context menu of the links list at left.

")); + + 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(); + + } } /*********************** **** **** **** ***********************/ diff --git a/retroshare-gui/src/gui/Posted/PostedListWidget.ui b/retroshare-gui/src/gui/Posted/PostedListWidget.ui index c96951823..13b3e208d 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidget.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidget.ui @@ -205,6 +205,186 @@
+ + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + false + + + + + + Topic Details + + + false + + + false + + + + + + 6 + + + + + + 75 + true + + + + Administrator: + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Posts: + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Last Post: + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Description</span></p></body></html> + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + true + + + true + + + + + + + + 75 + true + + + + Description: + + + + + + + unknown + + + true + + + + + + + 0 + + + + + + + unknown + + + + + + + + 75 + true + + + + Distribution: + + + + + + + unknown + + + + + + + + + + + @@ -258,6 +438,11 @@ QComboBox
gui/gxs/GxsIdChooser.h
+ + GxsIdLabel + QLabel +
gui/gxs/GxsIdLabel.h
+
diff --git a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp index 97c97c195..542e97a11 100644 --- a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp @@ -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 { diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp index 99f363f8d..57fc7031b 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp @@ -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; + } + +} diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h index 1a6999880..82d2fdbd1 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h @@ -45,6 +45,7 @@ private slots: void refresh(); void idChooserReady(); void voterSelectionChanged( int index ); + void sortComments(int); private: RsGxsGroupId mGrpId; diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui b/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui index 7961136c0..6bf6b1112 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui @@ -13,8 +13,8 @@ Form - - + + @@ -24,59 +24,63 @@ - 9 + 1 1 + + 1 + 1 - + - - - Hot + + + <html><head/><body><p><span style=" 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;">sort by</span></p></body></html> - - true + + - - true - - - - - - - New - - - true - - - true - - - - - - - Top - - - true - - - false - - - true + + + 24 + 24 + + + + Hot + + + + :/icons/png/flame.png:/icons/png/flame.png + + + + + New + + + + :/icons/png/new.png:/icons/png/new.png + + + + + Top + + + + :/icons/png/top.png:/icons/png/top.png + + @@ -111,8 +115,11 @@ - + + + true + Comment @@ -164,6 +171,8 @@
gui/gxs/GxsCommentTreeWidget.h
- + + + diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index dc1734556..296ce68c8 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -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 @@ -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()); diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h index a7e25df6e..a1977ab93 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h @@ -27,6 +27,8 @@ #include #include +class RSTreeWidgetItemCompareRole; + class GxsCommentTreeWidget : public QTreeWidget, public TokenResponse { Q_OBJECT @@ -96,6 +98,8 @@ protected: std::map mLoadingMap; std::multimap mPendingInsertMap; + + RSTreeWidgetItemCompareRole *commentsRole; TokenQueue *mTokenQueue; RsTokenService *mRsTokenService; diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui index 3cd4a50c6..9c6a9b662 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui @@ -7,7 +7,7 @@ 0 0 600 - 736 + 633
diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui index c175d95d8..850f81c8f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui @@ -294,7 +294,7 @@ 3 - 3 + 0 3 @@ -304,211 +304,176 @@ - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 178 - - - - - - - - - 255 - 255 - 178 - - - - - - - 255 - 255 - 178 - - - - - - - true + false - QFrame::Box + QFrame::NoFrame QFrame::Plain + + 6 + + + 6 + + + 6 + + + 6 + - - - - - - 75 - true - - - - Administrator: - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Posts (at neighbor nodes): - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Last Post: - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + + + Channel details + + + + 9 + + + 9 + + + 9 + + + 9 + + + + + + 75 + true + + + + Administrator: + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Posts: + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Last Post: + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Description</span></p></body></html> - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - true - - - true - - - - - - - - 75 - true - - - - Description: - - - - - - - unknown - - - true - - - - - - - 0 - - - - - - - unknown - - - - - - - - 75 - true - - - - Distribution: - - - - - - - unknown - - - - + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + true + + + true + + + + + + + + 75 + true + + + + Description: + + + + + + + unknown + + + true + + + + + + + 0 + + + + + + + unknown + + + + + + + + 75 + true + + + + Distribution: + + + + + + + unknown + + + + +
diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index a6089ab59..f1420a0a3 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -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; -} \ No newline at end of file +GxsCommentDialog QComboBox#sortBox { + font: bold; + color: #0099cc; +}