From dc90d6f6dc2f4450bea1aac03febcdb725a238e3 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 6 Nov 2020 23:08:18 +0100 Subject: [PATCH] renamed SSGXSChannelGroup to GxsChannelGroupInfo, mCount in RsGxsChannelPost to mAttachmentCount and added a mCommentCount member. Also added some missing override in p3gxschannels.cc --- libretroshare/src/retroshare/rsgxschannels.h | 12 +++-- .../src/rsitems/rsgxschannelitems.cc | 4 +- libretroshare/src/services/p3gxschannels.cc | 12 ++--- libretroshare/src/services/p3gxschannels.h | 49 ++++++++++--------- .../src/gui/feeds/GxsChannelPostItem.cpp | 4 +- .../GxsChannelPostsWidgetWithModel.cpp | 4 +- 6 files changed, 44 insertions(+), 41 deletions(-) diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index 7c91f41cd..d37d2d3f2 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -71,14 +71,15 @@ struct RsGxsChannelGroup : RsSerializable, RsGxsGenericGroupData struct RsGxsChannelPost : RsSerializable, RsGxsGenericMsgData { - RsGxsChannelPost() : mCount(0), mSize(0) {} + RsGxsChannelPost() : mAttachmentCount(0), mSize(0) {} std::set mOlderVersions; std::string mMsg; // UTF8 encoded. std::list mFiles; - uint32_t mCount; // auto calced. - uint64_t mSize; // auto calced. + uint32_t mAttachmentCount; // auto calced. + uint32_t mCommentCount; // auto calced. + uint64_t mSize; // auto calced. RsGxsImage mThumbnail; @@ -92,8 +93,9 @@ struct RsGxsChannelPost : RsSerializable, RsGxsGenericMsgData RS_SERIAL_PROCESS(mMsg); RS_SERIAL_PROCESS(mFiles); - RS_SERIAL_PROCESS(mCount); - RS_SERIAL_PROCESS(mSize); + RS_SERIAL_PROCESS(mAttachmentCount); + RS_SERIAL_PROCESS(mCommentCount); + RS_SERIAL_PROCESS(mSize); RS_SERIAL_PROCESS(mThumbnail); } diff --git a/libretroshare/src/rsitems/rsgxschannelitems.cc b/libretroshare/src/rsitems/rsgxschannelitems.cc index 123e85c17..9ef37d746 100644 --- a/libretroshare/src/rsitems/rsgxschannelitems.cc +++ b/libretroshare/src/rsitems/rsgxschannelitems.cc @@ -137,7 +137,7 @@ bool RsGxsChannelPostItem::toChannelPost(RsGxsChannelPost &post, bool moveImage) post.mThumbnail.copy((uint8_t *) mThumbnail.binData.bin_data, mThumbnail.binData.bin_len); } - post.mCount = 0; + post.mAttachmentCount = 0; post.mSize = 0; std::list::iterator fit; for(fit = mAttachment.items.begin(); fit != mAttachment.items.end(); ++fit) @@ -148,7 +148,7 @@ bool RsGxsChannelPostItem::toChannelPost(RsGxsChannelPost &post, bool moveImage) fi.mHash = fit->hash; post.mFiles.push_back(fi); - post.mCount++; + post.mAttachmentCount++; post.mSize += fi.mSize; } return true; diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index 839dd4b5a..b8cf42831 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -675,7 +675,7 @@ bool p3GxsChannels::setChannelDownloadDirectory( } /* extract from ServiceString */ - SSGxsChannelGroup ss; + GxsChannelGroupInfo ss; ss.load(it->second.mServiceString); if (directory == ss.mDownloadDirectory) @@ -728,7 +728,7 @@ bool p3GxsChannels::getChannelDownloadDirectory(const RsGxsGroupId & groupId,std } /* extract from ServiceString */ - SSGxsChannelGroup ss; + GxsChannelGroupInfo ss; ss.load(it->second.mServiceString); directory = ss.mDownloadDirectory; @@ -1729,14 +1729,14 @@ bool p3GxsChannels::autoDownloadEnabled(const RsGxsGroupId &groupId,bool& enable } /* extract from ServiceString */ - SSGxsChannelGroup ss; + GxsChannelGroupInfo ss; ss.load(it->second.mServiceString); enabled = ss.mAutoDownload; return true; } -bool SSGxsChannelGroup::load(const std::string &input) +bool GxsChannelGroupInfo::load(const std::string &input) { if(input.empty()) { @@ -1785,7 +1785,7 @@ bool SSGxsChannelGroup::load(const std::string &input) return true; } -std::string SSGxsChannelGroup::save() const +std::string GxsChannelGroupInfo::save() const { std::string output = "v2 "; @@ -1827,7 +1827,7 @@ bool p3GxsChannels::setAutoDownload(const RsGxsGroupId& groupId, bool enabled) } /* extract from ServiceString */ - SSGxsChannelGroup ss; + GxsChannelGroupInfo ss; ss.load(it->second.mServiceString); if (enabled == ss.mAutoDownload) { diff --git a/libretroshare/src/services/p3gxschannels.h b/libretroshare/src/services/p3gxschannels.h index 5ab1d414c..fd6eefd51 100644 --- a/libretroshare/src/services/p3gxschannels.h +++ b/libretroshare/src/services/p3gxschannels.h @@ -35,11 +35,12 @@ #include +// This class is only a helper to parse the channel group service string. -class SSGxsChannelGroup +class GxsChannelGroupInfo { public: - SSGxsChannelGroup(): mAutoDownload(false), mDownloadDirectory("") {} + GxsChannelGroupInfo(): mAutoDownload(false), mDownloadDirectory("") {} bool load(const std::string &input); std::string save() const; @@ -55,31 +56,31 @@ class p3GxsChannels: public RsGenExchange, public RsGxsChannels, public: p3GxsChannels( RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs ); - virtual RsServiceInfo getServiceInfo(); + virtual RsServiceInfo getServiceInfo() override; - virtual void service_tick(); + virtual void service_tick() override; protected: - virtual RsSerialiser* setupSerialiser(); // @see p3Config::setupSerialiser() - virtual bool saveList(bool &cleanup, std::list&saveList); // @see p3Config::saveList(bool &cleanup, std::list&) - virtual bool loadList(std::list& loadList); // @see p3Config::loadList(std::list&) + virtual RsSerialiser* setupSerialiser() override; // @see p3Config::setupSerialiser() + virtual bool saveList(bool &cleanup, std::list&saveList) override; // @see p3Config::saveList(bool &cleanup, std::list&) + virtual bool loadList(std::list& loadList) override; // @see p3Config::loadList(std::list&) - virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id); - virtual TurtleRequestId turtleSearchRequest(const std::string& match_string); - virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map &results) ; - virtual bool clearDistantSearchResults(TurtleRequestId req); - virtual bool getDistantSearchResultGroupData(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group); - virtual DistantSearchGroupStatus getDistantSearchStatus(const RsGxsGroupId& group_id) ; + virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id) override; + virtual TurtleRequestId turtleSearchRequest(const std::string& match_string) override; + virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map &results) override; + virtual bool clearDistantSearchResults(TurtleRequestId req) override; + virtual bool getDistantSearchResultGroupData(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group) override; + virtual DistantSearchGroupStatus getDistantSearchStatus(const RsGxsGroupId& group_id) override; // Overloaded to cache new groups. -virtual RsGenExchange::ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet); +virtual RsGenExchange::ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet) override; -virtual void notifyChanges(std::vector& changes); +virtual void notifyChanges(std::vector& changes) override; // Overloaded from RsTickEvent. -virtual void handle_event(uint32_t event_type, const std::string &elabel); +virtual void handle_event(uint32_t event_type, const std::string &elabel) override; public: @@ -97,18 +98,18 @@ virtual bool getPostData(const uint32_t &token, std::vector &p //virtual bool groupRestoreKeys(const std::string &groupId); virtual bool groupShareKeys( - const RsGxsGroupId &groupId, const std::set& peers); + const RsGxsGroupId &groupId, const std::set& peers) override; -virtual bool createGroup(uint32_t &token, RsGxsChannelGroup &group); -virtual bool createPost(uint32_t &token, RsGxsChannelPost &post); +virtual bool createGroup(uint32_t &token, RsGxsChannelGroup &group) override; +virtual bool createPost(uint32_t &token, RsGxsChannelPost &post) override; -virtual bool updateGroup(uint32_t &token, RsGxsChannelGroup &group); +virtual bool updateGroup(uint32_t &token, RsGxsChannelGroup &group) override; // no tokens... should be cached. -virtual bool setChannelAutoDownload(const RsGxsGroupId &groupId, bool enabled); -virtual bool getChannelAutoDownload(const RsGxsGroupId &groupid, bool& enabled); -virtual bool setChannelDownloadDirectory(const RsGxsGroupId &groupId, const std::string& directory); -virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::string& directory); +virtual bool setChannelAutoDownload(const RsGxsGroupId &groupId, bool enabled) override; +virtual bool getChannelAutoDownload(const RsGxsGroupId &groupid, bool& enabled) override; +virtual bool setChannelDownloadDirectory(const RsGxsGroupId &groupId, const std::string& directory) override; +virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::string& directory) override; #ifdef TO_REMOVE /// @see RsGxsChannels::turtleSearchRequest diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 560cbfa10..f8346183f 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -573,9 +573,9 @@ void GxsChannelPostItem::fill() ui->datetimelabel->setText(DateTime::formatLongDateTime(mPost.mMeta.mPublishTs)); - if ( (mPost.mCount != 0) || (mPost.mSize != 0) ) { + if ( (mPost.mAttachmentCount != 0) || (mPost.mSize != 0) ) { ui->filelabel->setVisible(true); - ui->filelabel->setText(QString("(%1 %2) %3").arg(mPost.mCount).arg( (mPost.mCount > 1)?tr("Files"):tr("File")).arg(misc::friendlyUnit(mPost.mSize))); + ui->filelabel->setText(QString("(%1 %2) %3").arg(mPost.mAttachmentCount).arg( (mPost.mAttachmentCount > 1)?tr("Files"):tr("File")).arg(misc::friendlyUnit(mPost.mSize))); } else { ui->filelabel->setVisible(false); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index a4f0acf1b..15f84f22a 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -222,8 +222,8 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & QString info_text = QDateTime::fromMSecsSinceEpoch(qint64(1000)*post.mMeta.mPublishTs).toString(Qt::DefaultLocaleShortDate); - if(post.mCount > 0) - info_text += ", " + QString::number(post.mCount)+ " " +((post.mCount>1)?tr("files"):tr("file")) + " (" + misc::friendlyUnit(qulonglong(post.mSize)) + ")" ; + if(post.mAttachmentCount > 0) + info_text += ", " + QString::number(post.mAttachmentCount)+ " " +((post.mAttachmentCount>1)?tr("files"):tr("file")) + " (" + misc::friendlyUnit(qulonglong(post.mSize)) + ")" ; painter->drawText(QPoint(p.x()+0.5*font_height,y),info_text); y += font_height;