From ac02b68b34182f915ba896a95973255c20b07d21 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 15 Apr 2020 21:55:16 +0200 Subject: [PATCH 1/7] first step of partial channel loading: only load all posts from meta data --- .../src/gui/feeds/GxsChannelPostItem.h | 1 + .../gui/gxschannels/GxsChannelPostsWidget.cpp | 74 ++++++++++++++++--- 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h index 566acda30..e060c8c88 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h @@ -65,6 +65,7 @@ public: const std::list &getFileItems() {return mFileItems; } bool isUnread() const ; + const std::set& olderVersions() const { return mPost.mOlderVersions; } static uint64_t computeIdentifier(const RsGxsMessageId& msgid) { return hash64("GxsChannelPostItem " + msgid.toStdString()) ; } protected: diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index 2421756b8..36c0d8188 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -456,19 +456,24 @@ void GxsChannelPostsWidget::filterChanged(int filter) return bVisible; } -void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool related) +#ifdef TODO +void GxsChannelPostsWidget::createPostItemFromMetaData(const RsGxsMsgMetaData& meta,bool related) { GxsChannelPostItem *item = NULL; + RsGxsChannelPost post; - if(!post.mMeta.mOrigMsgId.isNull()) + if(!meta.mOrigMsgId.isNull()) { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(post.mMeta.mOrigMsgId)) ; + FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mOrigMsgId)) ; item = dynamic_cast(feedItem); if(item) { + post = feedItem->post(); ui->feedWidget->removeFeedItem(item) ; + post.mOlderVersions.insert(post.mMeta.mMsgId); + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post, true, false,post.mOlderVersions); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); @@ -478,18 +483,69 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool re if (related) { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(post.mMeta.mMsgId)) ; + FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mMsgId)) ; item = dynamic_cast(feedItem); } - if (item) { + if (item) + { item->setPost(post); - ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); - } else { - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post, true, false,post.mOlderVersions); + ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); + } + else + { + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, meta.mGroupId,meta.mMsgId, true, true); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); } - +#ifdef TODO ui->fileWidget->addFiles(post, related); +#endif +} +#endif + +void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool related) +{ + GxsChannelPostItem *item = NULL; + + const RsMsgMetaData& meta(post.mMeta); + + if(!meta.mOrigMsgId.isNull()) + { + FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mOrigMsgId)) ; + item = dynamic_cast(feedItem); + + if(item) + { + std::set older_versions(item->olderVersions()); + ui->feedWidget->removeFeedItem(item) ; + + older_versions.insert(meta.mMsgId); + + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, meta.mGroupId,meta.mMsgId, true, false,older_versions); + ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); + + return ; + } + } + + if (related) + { + FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mMsgId)) ; + item = dynamic_cast(feedItem); + } + if (item) + { + item->setPost(post); + ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); + } + else + { + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, meta.mGroupId,meta.mMsgId, true, true); + ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); + } + +#ifdef TODO + ui->fileWidget->addFiles(post, related); +#endif } void GxsChannelPostsWidget::fillThreadCreatePost(const QVariant &post, bool related, int current, int count) From fa8968797cf91f1182de81270852081f78b0e007 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 16 Apr 2020 21:35:57 +0200 Subject: [PATCH 2/7] added some tests to insertGroupData() to avoid inconsistent calls --- libretroshare/src/rsserver/rsinit.cc | 2 +- .../src/gui/gxs/GxsMessageFramePostWidget.cpp | 2 +- .../gui/gxschannels/GxsChannelPostsWidget.cpp | 20 +++++++++++++++---- .../gui/gxsforums/GxsForumThreadWidget.cpp | 6 ++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 25391fcbe..73a70d0c5 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1193,7 +1193,7 @@ int RsServer::StartupRetroShare() std::cerr << "(EE) Cannot create extensions directory " << extensions_dir << ". This is not mandatory, but you probably have a permission problem." << std::endl; -#ifdef DEBUG_PLUGIN_SYSTEM +#ifndef DEBUG_PLUGIN_SYSTEM plugins_directories.push_back(".") ; // this list should be saved/set to some correct value. // possible entries include: /usr/lib/retroshare, ~/.retroshare/extensions/, etc. #endif diff --git a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp index 06225843b..1eb52356a 100644 --- a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp @@ -185,7 +185,7 @@ void GxsMessageFramePostWidget::loadGroupData() RsThread::async([this]() { - RsGxsGenericGroupData *data; + RsGxsGenericGroupData *data = nullptr; getGroupData(data); if(!data) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index 36c0d8188..11ba70ccb 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -515,7 +515,7 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool re if(item) { - std::set older_versions(item->olderVersions()); + std::set older_versions(item->olderVersions()); // we make a copy because the item will be deleted ui->feedWidget->removeFeedItem(item) ; older_versions.insert(meta.mMsgId); @@ -792,9 +792,16 @@ void GxsChannelPostsWidget::toggleAutoDownload() bool GxsChannelPostsWidget::insertGroupData(const RsGxsGenericGroupData *data) { - insertChannelDetails(*dynamic_cast(data)); - return true; + const RsGxsChannelGroup *d = dynamic_cast(data); + if(!d) + { + RsErr() << __PRETTY_FUNCTION__ << " Cannot dynamic cast input data (" << (void*)data << " to RsGxsGenericGroupData. Something bad happenned." << std::endl; + return false; + } + + insertChannelDetails(*d); + return true; } void GxsChannelPostsWidget::getMsgData(const std::set& msgIds,std::vector& psts) @@ -825,6 +832,11 @@ void GxsChannelPostsWidget::getAllMsgData(std::vector& pst bool GxsChannelPostsWidget::getGroupData(RsGxsGenericGroupData *& data) { + if(groupId().isNull()) + { + RsErr() << __PRETTY_FUNCTION__ << " Trying to get data about null group!!" << std::endl; + return false; + } std::vector groups; if(rsGxsChannels->getChannelsInfo(std::list({groupId()}),groups) && groups.size()==1) @@ -851,7 +863,7 @@ void GxsChannelPostsWidget::insertAllPosts(const std::vector cposts; - for(auto post: posts) // This is not so nice but we have somehow to convert to RsGxsChannelPost at some timer, and the cposts list is being modified in the insert method. + for(auto post: posts) // This is not so nice but we have somehow to convert to RsGxsChannelPost at some time, and the cposts list is being modified in the insert method. cposts.push_back(*static_cast(post)); insertChannelPosts(cposts, thread, false); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 37b479e6a..c3d1ca70b 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -817,7 +817,10 @@ void GxsForumThreadWidget::changedThread(QModelIndex index) bool setToReadOnActive = Settings->getForumMsgSetToReadOnActivate(); if(setToReadOnActive) + { + saveExpandedItems(mSavedExpandedMessages); mThreadModel->setMsgReadStatus(src_index, true,false); + } } void GxsForumThreadWidget::clickedThread(QModelIndex index) @@ -837,6 +840,7 @@ void GxsForumThreadWidget::clickedThread(QModelIndex index) if (index.column() == RsGxsForumModel::COLUMN_THREAD_READ) { + saveExpandedItems(mSavedExpandedMessages); ForumModelPostEntry fmpe; QModelIndex src_index = mThreadProxyModel->mapToSource(index); @@ -845,6 +849,7 @@ void GxsForumThreadWidget::clickedThread(QModelIndex index) #ifdef DEBUG_FORUMS std::cerr << "Setting message read status to false" << std::endl; #endif + mThreadModel->setMsgReadStatus(src_index, IS_MSG_UNREAD(fmpe.mMsgStatus),false); } #ifdef DEBUG_FORUMS @@ -1266,6 +1271,7 @@ void GxsForumThreadWidget::markMsgAsReadUnread (bool read, bool children, bool f if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mForumGroup.mMeta.mSubscribeFlags)) { return; } + saveExpandedItems(mSavedExpandedMessages); if(forum) mThreadModel->setMsgReadStatus(mThreadModel->root(),read,children); From 678bcf5830d851e689a634b9201325838ccbc4a5 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 17 Apr 2020 23:23:59 +0200 Subject: [PATCH 3/7] improved efficiency of channel posts loading --- .../src/gui/feeds/GxsChannelPostItem.cpp | 163 ++++++++++-------- .../src/gui/feeds/GxsChannelPostItem.h | 15 +- .../src/gui/gxs/GxsMessageFramePostWidget.h | 1 - .../gui/gxschannels/GxsChannelPostsWidget.cpp | 9 +- .../gui/gxschannels/GxsChannelPostsWidget.h | 1 + 5 files changed, 108 insertions(+), 81 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 1e0fc57b9..f500295a8 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -44,21 +44,55 @@ * #define DEBUG_ITEM 1 ****/ -GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : - GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsGxsChannels, autoUpdate) +GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : + GxsFeedItem(feedHolder, feedId, group.mMeta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate), mGroup(group) // this one should be in GxsFeedItem { mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded - init(messageId,older_versions) ; + mPost.mMeta.mGroupId = group.mMeta.mGroupId; + + QVector v; + //bool self = false; + + for(std::set::const_iterator it(older_versions.begin());it!=older_versions.end();++it) + v.push_back(*it) ; + + if(older_versions.find(messageId) == older_versions.end()) + v.push_back(messageId); + + setMessageVersions(v) ; + setup(); + + //init(messageId,older_versions) ; } -GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost& post, bool isHome, bool autoUpdate,const std::set& older_versions) : - GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, autoUpdate) +GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : + GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsGxsChannels, autoUpdate) // this one should be in GxsFeedItem { - mPost.mMeta.mMsgId.clear(); // security - init(post.mMeta.mMsgId,older_versions) ; - mPost = post ; + mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded + + QVector v; + //bool self = false; + + for(std::set::const_iterator it(older_versions.begin());it!=older_versions.end();++it) + v.push_back(*it) ; + + if(older_versions.find(messageId) == older_versions.end()) + v.push_back(messageId); + + setMessageVersions(v) ; + setup(); + + loadGroup(); } +// GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost& post, bool isHome, bool autoUpdate,const std::set& older_versions) : +// GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, autoUpdate) +// { +// mPost.mMeta.mMsgId.clear(); // security +// init(post.mMeta.mMsgId,older_versions) ; +// mPost = post ; +// } + void GxsChannelPostItem::init(const RsGxsMessageId& messageId,const std::set& older_versions) { QVector v; @@ -86,7 +120,11 @@ void GxsChannelPostItem::paintEvent(QPaintEvent *e) { mLoaded = true ; - requestGroup(); + std::set older_versions; // not so nice. We need to use std::set everywhere + for(auto& m:messageVersions()) + older_versions.insert(m); + + fill(); requestMessage(); requestComment(); } @@ -107,6 +145,7 @@ bool GxsChannelPostItem::isUnread() const void GxsChannelPostItem::setup() { /* Invoke the Qt Designer generated object setup routine */ + ui = new Ui::GxsChannelPostItem; ui->setupUi(this); @@ -165,29 +204,6 @@ void GxsChannelPostItem::setup() ui->expandFrame->hide(); } -bool GxsChannelPostItem::setGroup(const RsGxsChannelGroup &group, bool doFill) -{ - if (groupId() != group.mMeta.mGroupId) { - std::cerr << "GxsChannelPostItem::setGroup() - Wrong id, cannot set post"; - std::cerr << std::endl; - return false; - } - - mGroup = group; - - // If not publisher, hide the edit button. Without the publish key, there's no way to edit a message. -#ifdef DEBUG_ITEM - std::cerr << "Group subscribe flags = " << std::hex << mGroup.mMeta.mSubscribeFlags << std::dec << std::endl ; -#endif - if( !IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags) ) - ui->editButton->hide() ; - - if (doFill) { - fill(); - } - - return true; -} bool GxsChannelPostItem::setPost(const RsGxsChannelPost &post, bool doFill) { @@ -231,46 +247,6 @@ void GxsChannelPostItem::loadComments() comments(title); } -void GxsChannelPostItem::loadGroup() -{ -#ifdef DEBUG_ITEM - std::cerr << "GxsChannelGroupItem::loadGroup()"; - std::cerr << std::endl; -#endif - - RsThread::async([this]() - { - // 1 - get group data - - std::vector groups; - const std::list groupIds = { groupId() }; - - if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) - { - RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; - return; - } - - if (groups.size() != 1) - { - std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items"; - std::cerr << std::endl; - return; - } - RsGxsChannelGroup group(groups[0]); - - RsQThreadUtils::postToObject( [group,this]() - { - /* Here it goes any code you want to be executed on the Qt Gui - * thread, for example to update the data model with new information - * after a blocking call to RetroShare API complete */ - - setGroup(group); - - }, this ); - }); -} - void GxsChannelPostItem::loadMessage() { #ifdef DEBUG_ITEM @@ -408,6 +384,9 @@ void GxsChannelPostItem::fill() ui->logoLabel->setPixmap(thumbnail); } + if( !IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags) ) + ui->editButton->hide() ; + if (!mIsHome) { if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { @@ -829,3 +808,43 @@ void GxsChannelPostItem::makeUpVote() emit vote(msgId, true); } + +void GxsChannelPostItem::loadGroup() +{ +#ifdef DEBUG_ITEM + std::cerr << "GxsChannelGroupItem::loadGroup()"; + std::cerr << std::endl; +#endif + + RsThread::async([this]() + { + // 1 - get group data + + std::vector groups; + const std::list groupIds = { groupId() }; + + if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) + { + RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; + return; + } + + if (groups.size() != 1) + { + std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items"; + std::cerr << std::endl; + return; + } + RsGxsChannelGroup group(groups[0]); + + RsQThreadUtils::postToObject( [group,this]() + { + /* Here it goes any code you want to be executed on the Qt Gui + * thread, for example to update the data model with new information + * after a blocking call to RetroShare API complete */ + + mGroup = group; + + }, this ); + }); +} diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h index e060c8c88..9535ac53c 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h @@ -42,15 +42,18 @@ public: // It can be used for all apparences of channel posts. But in rder to merge comments from the previous versions of the post, the list of // previous posts should be supplied. It's optional. If not supplied only the comments of the new version will be displayed. - GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); + GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); - // This method can be called when additional information is known about the post. In this case, the widget will be initialized with some - // minimap information from the post and completed when the use displays it, which shouldn't cost anything more. + // This one is used in channel thread widget. We don't want the group data to reload at every post, so we load it in the hosting + // GxsChannelsPostsWidget and pass it to created items. - GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost& post, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); + GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); + +// // This method can be called when additional information is known about the post. In this case, the widget will be initialized with some +// // minimap information from the post and completed when the use displays it, which shouldn't cost anything more. +// +// GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost& post, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); - //GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup &group, const RsGxsChannelPost &post, bool isHome, bool autoUpdate); - //GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, bool isHome, bool autoUpdate); virtual ~GxsChannelPostItem(); uint64_t uniqueIdentifier() const override { return hash_64bits("GxsChannelPostItem " + messageId().toStdString()) ; } diff --git a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h index 96a77a4e3..f47b9f3c9 100644 --- a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h +++ b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h @@ -67,7 +67,6 @@ protected: virtual void fillThreadCreatePost(const QVariant &/*post*/, bool /*related*/, int /*current*/, int /*count*/) {} /* GXS functions */ - void requestGroupData(); void loadGroupData(); void loadAllPosts(); void loadPosts(const std::set& msgIds); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index 11ba70ccb..c2c9ef6f3 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -520,7 +520,7 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool re older_versions.insert(meta.mMsgId); - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, meta.mGroupId,meta.mMsgId, true, false,older_versions); + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup,meta.mMsgId, true, false,older_versions); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); return ; @@ -539,7 +539,7 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool re } else { - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, meta.mGroupId,meta.mMsgId, true, true); + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup,meta.mMsgId, true, true); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); } @@ -548,6 +548,8 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool re #endif } + + void GxsChannelPostsWidget::fillThreadCreatePost(const QVariant &post, bool related, int current, int count) { /* show fill progress */ @@ -842,6 +844,8 @@ bool GxsChannelPostsWidget::getGroupData(RsGxsGenericGroupData *& data) if(rsGxsChannels->getChannelsInfo(std::list({groupId()}),groups) && groups.size()==1) { data = new RsGxsChannelGroup(groups[0]); + + mGroup = groups[0]; // make a local copy to pass on to items return true; } else @@ -852,6 +856,7 @@ bool GxsChannelPostsWidget::getGroupData(RsGxsGenericGroupData *& data) { insertChannelDetails(distant_group); data = new RsGxsChannelGroup(distant_group); + mGroup = distant_group; // make a local copy to pass on to items return true ; } } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h index b33a1a9f8..025d933bf 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h @@ -106,6 +106,7 @@ private: private: QAction *mAutoDownloadAction; + RsGxsChannelGroup mGroup; bool mUseThread; RsEventsHandlerId_t mEventHandlerId ; From 2a046eacb3767630362d74db4c063f503187d852 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 18 Apr 2020 13:45:55 +0200 Subject: [PATCH 4/7] have GxsChannelPostItem only keep a copy of the group meta data instead of the full group data to save memory --- .../src/gui/feeds/GxsChannelPostItem.cpp | 23 ++++++++++--------- .../src/gui/feeds/GxsChannelPostItem.h | 4 ++-- .../gui/gxschannels/GxsChannelPostsWidget.cpp | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index f500295a8..7813b5118 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -44,11 +44,12 @@ * #define DEBUG_ITEM 1 ****/ -GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : - GxsFeedItem(feedHolder, feedId, group.mMeta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate), mGroup(group) // this one should be in GxsFeedItem +GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group_meta, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : + GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate), + mGroupMeta(group_meta) { mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded - mPost.mMeta.mGroupId = group.mMeta.mGroupId; + mPost.mMeta.mGroupId = mGroupMeta.mGroupId; QVector v; //bool self = false; @@ -62,7 +63,7 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, setMessageVersions(v) ; setup(); - //init(messageId,older_versions) ; + // no call to loadGroup() here because we have it already. } GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : @@ -238,7 +239,7 @@ QString GxsChannelPostItem::getMsgLabel() QString GxsChannelPostItem::groupName() { - return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str()); + return QString::fromUtf8(mGroupMeta.mGroupName.c_str()); } void GxsChannelPostItem::loadComments() @@ -384,7 +385,7 @@ void GxsChannelPostItem::fill() ui->logoLabel->setPixmap(thumbnail); } - if( !IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags) ) + if( !IS_GROUP_PUBLISHER(mGroupMeta.mSubscribeFlags) ) ui->editButton->hide() ; if (!mIsHome) @@ -401,7 +402,7 @@ void GxsChannelPostItem::fill() RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName()); //ui->subjectLabel->setText(msgLink.toHtml()); - if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags)) + if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags)) { ui->unsubscribeButton->setEnabled(true); } @@ -440,7 +441,7 @@ void GxsChannelPostItem::fill() ui->unsubscribeButton->hide(); ui->copyLinkButton->show(); - if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags)) + if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags)) { ui->readButton->setVisible(true); @@ -753,7 +754,7 @@ void GxsChannelPostItem::download() void GxsChannelPostItem::edit() { - CreateGxsChannelMsg *msgDialog = new CreateGxsChannelMsg(mGroup.mMeta.mGroupId,mPost.mMeta.mMsgId); + CreateGxsChannelMsg *msgDialog = new CreateGxsChannelMsg(mGroupMeta.mGroupId,mPost.mMeta.mMsgId); msgDialog->show(); } @@ -823,7 +824,7 @@ void GxsChannelPostItem::loadGroup() std::vector groups; const std::list groupIds = { groupId() }; - if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) + if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group { RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; return; @@ -843,7 +844,7 @@ void GxsChannelPostItem::loadGroup() * thread, for example to update the data model with new information * after a blocking call to RetroShare API complete */ - mGroup = group; + mGroupMeta = group.mMeta; }, this ); }); diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h index 9535ac53c..b5dc7ab7f 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h @@ -47,7 +47,7 @@ public: // This one is used in channel thread widget. We don't want the group data to reload at every post, so we load it in the hosting // GxsChannelsPostsWidget and pass it to created items. - GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); + GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); // // This method can be called when additional information is known about the post. In this case, the widget will be initialized with some // // minimap information from the post and completed when the use displays it, which shouldn't cost anything more. @@ -124,7 +124,7 @@ private: bool mCloseOnRead; bool mLoaded; - RsGxsChannelGroup mGroup; + RsGroupMetaData mGroupMeta; RsGxsChannelPost mPost; std::list mFileItems; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index c2c9ef6f3..ce1fc5bad 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -520,7 +520,7 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool re older_versions.insert(meta.mMsgId); - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup,meta.mMsgId, true, false,older_versions); + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, false,older_versions); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); return ; @@ -539,7 +539,7 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool re } else { - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup,meta.mMsgId, true, true); + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, true); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); } From c84016c3b09d26626a4617292f44fc79ce52b691 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 19 Apr 2020 13:10:30 +0200 Subject: [PATCH 5/7] force Qt to use implicit data sharing in icons and pixmaps by using our own cache, and apply this to GxsChannelPostItem --- .../src/gui/FileTransfer/SearchDialog.cpp | 2 +- .../src/gui/FileTransfer/TransfersDialog.cpp | 283 +----------------- retroshare-gui/src/gui/RemoteDirModel.cpp | 2 +- retroshare-gui/src/gui/common/FilesDefs.cpp | 50 +++- retroshare-gui/src/gui/common/FilesDefs.h | 13 +- .../src/gui/feeds/GxsChannelPostItem.cpp | 27 +- .../src/gui/feeds/GxsChannelPostItem.ui | 50 ---- 7 files changed, 81 insertions(+), 346 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp index 55887b14a..fb72135ed 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp @@ -1470,7 +1470,7 @@ void SearchDialog::hideOrShowSearchResult(QTreeWidgetItem* resultItem, QString c void SearchDialog::setIconAndType(QTreeWidgetItem *item, const QString& filename) { - item->setIcon(SR_NAME_COL, FilesDefs::getIconFromFilename(filename)); + item->setIcon(SR_NAME_COL, FilesDefs::getIconFromFileType(filename)); item->setText(SR_TYPE_COL, FilesDefs::getNameFromFilename(filename)); } diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 9a901b809..eda3aa3e3 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -594,7 +594,7 @@ public: if(col == COLUMN_NAME) { if(source_id == -1) - return QVariant(FilesDefs::getIconFromFilename(QString::fromUtf8(fileInfo.fname.c_str()))); + return QVariant(FilesDefs::getIconFromFileType(QString::fromUtf8(fileInfo.fname.c_str()))); else { QString iconName,tooltip; @@ -1522,285 +1522,6 @@ void TransfersDialog::setDestinationDirectory() } } -/* -int TransfersDialog::addDLItem(int row, const FileInfo &fileInfo) -{ - QString fileHash = QString::fromStdString(fileInfo.hash.toStdString()); - double fileDlspeed = (fileInfo.downloadStatus == FT_STATE_DOWNLOADING) ? (fileInfo.tfRate * 1024.0) : 0.0; - - QString status; - switch (fileInfo.downloadStatus) { - case FT_STATE_FAILED: status = tr("Failed"); break; - case FT_STATE_OKAY: status = tr("Okay"); break; - case FT_STATE_WAITING: status = tr("Waiting"); break; - case FT_STATE_DOWNLOADING: status = tr("Downloading"); break; - case FT_STATE_COMPLETE: status = tr("Complete"); break; - case FT_STATE_QUEUED: status = tr("Queued"); break; - case FT_STATE_PAUSED: status = tr("Paused"); break; - case FT_STATE_CHECKING_HASH:status = tr("Checking..."); break; - default: status = tr("Unknown"); break; - } - - double priority = PRIORITY_NULL; - - if (fileInfo.downloadStatus == FT_STATE_QUEUED) { - priority = fileInfo.queue_position; - } else if (fileInfo.downloadStatus == FT_STATE_COMPLETE) { - priority = 0; - } else { - switch (fileInfo.priority) { - case SPEED_LOW: priority = PRIORITY_SLOWER; break; - case SPEED_NORMAL: priority = PRIORITY_AVERAGE; break; - case SPEED_HIGH: priority = PRIORITY_FASTER; break; - default: priority = PRIORITY_AVERAGE; break; - } - } - - qlonglong completed = fileInfo.transfered; - qlonglong remaining = fileInfo.size - fileInfo.transfered; - - qlonglong downloadtime = (fileInfo.tfRate > 0)?( (fileInfo.size - fileInfo.transfered) / (fileInfo.tfRate * 1024.0) ) : 0 ; - qint64 qi64LastDL = fileInfo.lastTS ; //std::numeric_limits::max(); - - if (qi64LastDL == 0) // file is complete, or any raison why the time has not been set properly - { - QFileInfo file; - - if (fileInfo.downloadStatus == FT_STATE_COMPLETE) - file = QFileInfo(QString::fromUtf8(fileInfo.path.c_str()), QString::fromUtf8(fileInfo.fname.c_str())); - else - file = QFileInfo(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()), QString::fromUtf8(fileInfo.hash.toStdString().c_str())); - - //Get Last Access on File - if (file.exists()) - qi64LastDL = file.lastModified().toTime_t(); - } - QString strPath = QString::fromUtf8(fileInfo.path.c_str()); - QString strPathAfterDL = strPath; - strPathAfterDL.replace(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()),""); - - FileChunksInfo fcinfo; - if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo)) { - return -1; - } - - FileProgressInfo pinfo; - pinfo.cmap = fcinfo.chunks; - pinfo.type = FileProgressInfo::DOWNLOAD_LINE; - pinfo.progress = (fileInfo.size == 0) ? 0 : (completed * 100.0 / fileInfo.size); - pinfo.nb_chunks = pinfo.cmap._map.empty() ? 0 : fcinfo.chunks.size(); - - for (uint32_t i = 0; i < fcinfo.chunks.size(); ++i) - switch(fcinfo.chunks[i]) - { - case FileChunksInfo::CHUNK_CHECKING: pinfo.chunks_in_checking.push_back(i); - break ; - case FileChunksInfo::CHUNK_ACTIVE: pinfo.chunks_in_progress.push_back(i); - break ; - case FileChunksInfo::CHUNK_DONE: - case FileChunksInfo::CHUNK_OUTSTANDING: - break ; - } - - QString tooltip; - - if (fileInfo.downloadStatus == FT_STATE_CHECKING_HASH) { - tooltip = tr("If the hash of the downloaded data does\nnot correspond to the hash announced\nby the file source. The data is likely \nto be corrupted.\n\nRetroShare will ask the source a detailed \nmap of the data; it will compare and invalidate\nbad blocks, and download them again\n\nTry to be patient!") ; - } - - if (row < 0) { - row = DLListModel->rowCount(); - DLListModel->insertRow(row); - - // change progress column to own class for sorting - DLListModel->setItem(row, COLUMN_PROGRESS, new ProgressItem(NULL)); - - DLListModel->setData(DLListModel->index(row, COLUMN_SIZE), QVariant((qlonglong) fileInfo.size)); - DLListModel->setData(DLListModel->index(row, COLUMN_ID), fileHash, Qt::DisplayRole); - DLListModel->setData(DLListModel->index(row, COLUMN_ID), fileHash, Qt::UserRole); - } - QString fileName = QString::fromUtf8(fileInfo.fname.c_str()); - - DLListModel->setData(DLListModel->index(row, COLUMN_NAME), fileName); - DLListModel->setData(DLListModel->index(row, COLUMN_NAME), FilesDefs::getIconFromFilename(fileName), Qt::DecorationRole); - - DLListModel->setData(DLListModel->index(row, COLUMN_COMPLETED), QVariant((qlonglong)completed)); - DLListModel->setData(DLListModel->index(row, COLUMN_DLSPEED), QVariant((double)fileDlspeed)); - DLListModel->setData(DLListModel->index(row, COLUMN_PROGRESS), QVariant((float)pinfo.progress)); - DLListModel->setData(DLListModel->index(row, COLUMN_PROGRESS), QVariant::fromValue(pinfo), Qt::UserRole); - DLListModel->setData(DLListModel->index(row, COLUMN_STATUS), QVariant(status)); - DLListModel->setData(DLListModel->index(row, COLUMN_PRIORITY), QVariant(priority)); - DLListModel->setData(DLListModel->index(row, COLUMN_REMAINING), QVariant((qlonglong)remaining)); - DLListModel->setData(DLListModel->index(row, COLUMN_DOWNLOADTIME), QVariant((qlonglong)downloadtime)); - DLListModel->setData(DLListModel->index(row, COLUMN_LASTDL), QVariant(qi64LastDL)); - DLListModel->setData(DLListModel->index(row, COLUMN_PATH), QVariant(strPathAfterDL)); - DLListModel->item(row,COLUMN_PATH)->setToolTip(strPath); - DLListModel->item(row,COLUMN_STATUS)->setToolTip(tooltip); - - QStandardItem *dlItem = DLListModel->item(row); - - std::set used_rows ; - int active = 0; - - if (fileInfo.downloadStatus != FT_STATE_COMPLETE) { - for (std::vector::const_iterator pit = fileInfo.peers.begin() ; pit != fileInfo.peers.end(); ++pit) - { - const TransferInfo &transferInfo = *pit; - - //unique combination: fileHash + peerId, variant: hash + peerName (too long) - QString hashFileAndPeerId = fileHash + QString::fromStdString(transferInfo.peerId.toStdString()); - - double peerDlspeed = 0; - if ((uint32_t)transferInfo.status == FT_STATE_DOWNLOADING && fileInfo.downloadStatus != FT_STATE_PAUSED && fileInfo.downloadStatus != FT_STATE_COMPLETE) - peerDlspeed = transferInfo.tfRate * 1024.0; - - FileProgressInfo peerpinfo; - peerpinfo.cmap = fcinfo.compressed_peer_availability_maps[transferInfo.peerId]; - peerpinfo.type = FileProgressInfo::DOWNLOAD_SOURCE ; - peerpinfo.progress = 0.0; // we don't display completion for sources. - peerpinfo.nb_chunks = peerpinfo.cmap._map.empty() ? 0 : fcinfo.chunks.size(); - - int row_id = addPeerToDLItem(dlItem, transferInfo.peerId, hashFileAndPeerId, peerDlspeed, transferInfo.status, peerpinfo); - - used_rows.insert(row_id); - - // get the sources (number of online peers) - if (transferInfo.tfRate > 0 && fileInfo.downloadStatus == FT_STATE_DOWNLOADING) - ++active; - } - } - - float fltSources = active + (float)fileInfo.peers.size()/1000; - DLListModel->setData(DLListModel->index(row, COLUMN_SOURCES), fltSources); - - // This is not optimal, but we deal with a small number of elements. The reverse order is really important, - // because rows after the deleted rows change positions ! - // - for (int r = dlItem->rowCount() - 1; r >= 0; --r) { - if (used_rows.find(r) == used_rows.end()) { - dlItem->removeRow(r); - } - } - - return row; -} - -int TransfersDialog::addPeerToDLItem(QStandardItem *dlItem, const RsPeerId& peer_ID, const QString& coreID, double dlspeed, uint32_t status, const FileProgressInfo& peerInfo) -{ - // try to find the item - int childRow = -1; - - QStandardItem *childId = NULL; - for (int count = 0; (childId = dlItem->child(count, COLUMN_ID)) != NULL; ++count) { - if (childId->data(Qt::UserRole).toString() == coreID) { - childRow = count; - break; - } - } - - QStandardItem *siName = NULL; - QStandardItem *siStatus = NULL; - - if (childRow == -1) { - // set this false if you want to expand on double click - dlItem->setEditable(false); - - QHeaderView *header = ui.downloadList->header(); - - QStandardItem *iName = new QStandardItem(); //COLUMN_NAME - QStandardItem *iSize = new SortByNameItem(header); //COLUMN_SIZE - QStandardItem *iCompleted = new SortByNameItem(header); //COLUMN_COMPLETED - QStandardItem *iDlSpeed = new SortByNameItem(header); //COLUMN_DLSPEED - QStandardItem *iProgress = new ProgressItem(header); //COLUMN_PROGRESS - QStandardItem *iSource = new SortByNameItem(header); //COLUMN_SOURCES - QStandardItem *iStatus = new SortByNameItem(header); //COLUMN_STATUS - QStandardItem *iPriority = new SortByNameItem(header); //COLUMN_PRIORITY - QStandardItem *iRemaining = new SortByNameItem(header); //COLUMN_REMAINING - QStandardItem *iDownloadTime = new SortByNameItem(header); //COLUMN_DOWNLOADTIME - QStandardItem *iID = new SortByNameItem(header); //COLUMN_ID - QStandardItem *iLastDL = new SortByNameItem(header); //COLUMN_LASTDL - QStandardItem *iPath = new SortByNameItem(header); //COLUMN_PATH - - siName = iName; - siStatus = iStatus; - - QList items; - QString iconName; - QString tooltip; - iName->setData(QVariant(getPeerName(peer_ID, iconName, tooltip)), Qt::DisplayRole); - iName->setData(QIcon(iconName), Qt::DecorationRole); - iName->setData(QVariant(tooltip), Qt::ToolTipRole); - iSize->setData(QVariant(QString()), Qt::DisplayRole); - iCompleted->setData(QVariant(QString()), Qt::DisplayRole); - iDlSpeed->setData(QVariant((double)dlspeed), Qt::DisplayRole); - iProgress->setData(QVariant((float)peerInfo.progress), Qt::DisplayRole); - iProgress->setData(QVariant::fromValue(peerInfo), Qt::UserRole); - iSource->setData(QVariant(QString()), Qt::DisplayRole); - - iPriority->setData(QVariant((double)PRIORITY_NULL), Qt::DisplayRole); // blank field for priority - iRemaining->setData(QVariant(QString()), Qt::DisplayRole); - iDownloadTime->setData(QVariant(QString()), Qt::DisplayRole); - iID->setData(QVariant() , Qt::DisplayRole); - iID->setData(QVariant(coreID), Qt::UserRole); - iLastDL->setData(QVariant(QString()), Qt::DisplayRole); - iPath->setData(QVariant(QString()), Qt::DisplayRole); - - items.append(iName); - items.append(iSize); - items.append(iCompleted); - items.append(iDlSpeed); - items.append(iProgress); - items.append(iSource); - items.append(iStatus); - items.append(iPriority); - items.append(iRemaining); - items.append(iDownloadTime); - items.append(iID); - items.append(iLastDL); - items.append(iPath); - dlItem->appendRow(items); - - childRow = dlItem->rowCount() - 1; - } else { - // just update the child (peer) - dlItem->child(childRow, COLUMN_DLSPEED)->setData(QVariant((double)dlspeed), Qt::DisplayRole); - dlItem->child(childRow, COLUMN_PROGRESS)->setData(QVariant((float)peerInfo.progress), Qt::DisplayRole); - dlItem->child(childRow, COLUMN_PROGRESS)->setData(QVariant::fromValue(peerInfo), Qt::UserRole); - - siName = dlItem->child(childRow,COLUMN_NAME); - siStatus = dlItem->child(childRow, COLUMN_STATUS); - } - - switch (status) { - case FT_STATE_FAILED: - siStatus->setData(QVariant(tr("Failed"))) ; - siName->setData(QIcon(":/images/Client1.png"), Qt::StatusTipRole); - break ; - case FT_STATE_OKAY: - siStatus->setData(QVariant(tr("Okay"))); - siName->setData(QIcon(":/images/Client2.png"), Qt::StatusTipRole); - break ; - case FT_STATE_WAITING: - siStatus->setData(QVariant(tr(""))); - siName->setData(QIcon(":/images/Client3.png"), Qt::StatusTipRole); - break ; - case FT_STATE_DOWNLOADING: - siStatus->setData(QVariant(tr("Transferring"))); - siName->setData(QIcon(":/images/Client0.png"), Qt::StatusTipRole); - break ; - case FT_STATE_COMPLETE: - siStatus->setData(QVariant(tr("Complete"))); - siName->setData(QIcon(":/images/Client0.png"), Qt::StatusTipRole); - break ; - default: - siStatus->setData(QVariant(tr(""))); - siName->setData(QIcon(":/images/Client4.png"), Qt::StatusTipRole); - } - - return childRow; -} -*/ - int TransfersDialog::addULItem(int row, const FileInfo &fileInfo) { if (fileInfo.peers.empty()) @@ -1822,7 +1543,7 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo) //ULListModel->setItem(row, COLUMN_UPROGRESS, new ProgressItem(NULL)); ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), fileName); - ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), FilesDefs::getIconFromFilename(fileName), Qt::DecorationRole); + ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), FilesDefs::getIconFromFileType(fileName), Qt::DecorationRole); ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash); ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash, Qt::UserRole); } diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 7fadce49a..e522eb4f8 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -430,7 +430,7 @@ QVariant RetroshareDirModel::decorationRole(const DirDetails& details,int coln) if(details.hash.isNull()) return QIcon(":/images/reset.png") ; // file is being hashed else - return FilesDefs::getIconFromFilename(QString::fromUtf8(details.name.c_str())); + return FilesDefs::getIconFromFileType(QString::fromUtf8(details.name.c_str())); } else return QVariant(); diff --git a/retroshare-gui/src/gui/common/FilesDefs.cpp b/retroshare-gui/src/gui/common/FilesDefs.cpp index 83474a752..dc8b30e86 100644 --- a/retroshare-gui/src/gui/common/FilesDefs.cpp +++ b/retroshare-gui/src/gui/common/FilesDefs.cpp @@ -85,23 +85,57 @@ QString FilesDefs::getImageFromFilename(const QString& filename, bool anyForUnkn return getInfoFromFilename(filename, anyForUnknown, true); } -QIcon FilesDefs::getIconFromFilename(const QString& filename) +QPixmap FilesDefs::getPixmapFromQtResourcePath(const QString& resource_path) { - QString sImage = getInfoFromFilename(filename, true, true); - static std::map mIconCache; - QIcon icon; - auto item = mIconCache.find(sImage); - if (item == mIconCache.end()) + static std::map mPixmapCache; + QPixmap pixmap; + std::cerr << "Creating Pixmap from resource path " << resource_path.toStdString() ; + + auto item = mPixmapCache.find(resource_path); + + if (item == mPixmapCache.end()) { - icon = QIcon(sImage); - mIconCache[sImage] = icon; + std::cerr << " Not in cache. Creating new one." << std::endl; + pixmap = QPixmap(resource_path); + mPixmapCache[resource_path] = pixmap; } else + { + std::cerr << " In cache. " << std::endl; + pixmap = item->second; + } + + return pixmap; +} + +QIcon FilesDefs::getIconFromQtResourcePath(const QString& resource_path) +{ + static std::map mIconCache; + QIcon icon; + std::cerr << "Creating Icon from resource path " << resource_path.toStdString() ; + + auto item = mIconCache.find(resource_path); + + if (item == mIconCache.end()) + { + std::cerr << " Not in cache. Creating new one." << std::endl; + icon = QIcon(resource_path); + mIconCache[resource_path] = icon; + } + else + { + std::cerr << " In cache. " << std::endl; icon = item->second; + } return icon; } +QIcon FilesDefs::getIconFromFileType(const QString& filename) +{ + return getIconFromQtResourcePath(getInfoFromFilename(filename,true,true)); +} + QString FilesDefs::getNameFromFilename(const QString &filename) { return getInfoFromFilename(filename, false, false); diff --git a/retroshare-gui/src/gui/common/FilesDefs.h b/retroshare-gui/src/gui/common/FilesDefs.h index 50a9e19ab..de0c0316a 100644 --- a/retroshare-gui/src/gui/common/FilesDefs.h +++ b/retroshare-gui/src/gui/common/FilesDefs.h @@ -28,7 +28,18 @@ class FilesDefs { public: static QString getImageFromFilename(const QString& filename, bool anyForUnknown); - static QIcon getIconFromFilename(const QString& filename); + + // Theses methods is here to fix a Qt design flow that makes QIcon loaded from filename (e.g. :/images/icon.png) to not use the cache. + // As a result, icons created by Qt in this way (mostly from GUI) do not use data sharing. + // The method below has its own cache. + + static QIcon getIconFromQtResourcePath(const QString& resource_path); + static QPixmap getPixmapFromQtResourcePath(const QString& resource_path); + + // This method returns a QIcon that is suitable to represent a file of a particular type (image, movie, etc.) + + static QIcon getIconFromFileType(const QString& filename); + static QString getNameFromFilename(const QString& filename); }; diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 7813b5118..4ee799041 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -23,6 +23,7 @@ #include #include "gui/gxs/GxsIdDetails.h" +#include "gui/common/FilesDefs.h" #include "rshare.h" #include "GxsChannelPostItem.h" #include "ui_GxsChannelPostItem.h" @@ -150,6 +151,24 @@ void GxsChannelPostItem::setup() ui = new Ui::GxsChannelPostItem; ui->setupUi(this); + // Manually set icons to allow to use clever resource sharing that is missing in Qt for Icons loaded from Qt resource file. + // This is particularly important here because a channel may contain many posts, so duplicating the QImages here is deadly for the + // memory. + + ui->logoLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default-video.png")); + ui->warn_image_label->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/status_unknown.png")); + ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); + ui->voteUpButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/vote_up.png")); + ui->voteDownButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/vote_down.png")); + ui->downloadButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/download.png")); + ui->playButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/play.png")); + ui->commentButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/commnt.png")); + ui->editButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/pencil-edit-button.png")); + ui->copyLinkButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/copy.png")); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/down-arrow.png")); + ui->readAndClearButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/correct.png")); + ui->clearButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/exit2.png")); + setAttribute(Qt::WA_DeleteOnClose, true); mInFill = false; @@ -566,12 +585,12 @@ void GxsChannelPostItem::setReadStatus(bool isNew, bool isUnread) if (isUnread) { ui->readButton->setChecked(true); - ui->readButton->setIcon(QIcon(":/images/message-state-unread.png")); + ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); } else { ui->readButton->setChecked(false); - ui->readButton->setIcon(QIcon(":/images/message-state-read.png")); + ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png")); } ui->newLabel->setVisible(isNew); @@ -684,7 +703,7 @@ void GxsChannelPostItem::doExpand(bool open) if (open) { ui->expandFrame->show(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); ui->expandButton->setToolTip(tr("Hide")); readToggled(false); @@ -692,7 +711,7 @@ void GxsChannelPostItem::doExpand(bool open) else { ui->expandFrame->hide(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); ui->expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui index 1f869dc37..e3558ea10 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui @@ -62,9 +62,6 @@ - - :/images/thumb-default-video.png - false @@ -156,9 +153,6 @@ - - :/images/status_unknown.png - @@ -213,10 +207,6 @@ Toggle Message Read Status - - - :/images/message-state-unread.png:/images/message-state-unread.png - true @@ -249,10 +239,6 @@ - - - :/images/vote_up.png:/images/vote_up.png - @@ -263,10 +249,6 @@ - - - :/images/vote_down.png:/images/vote_down.png - @@ -277,10 +259,6 @@ Download - - - :/icons/png/download.png:/icons/png/download.png - false @@ -294,10 +272,6 @@ Play - - - :/icons/png/play.png:/icons/png/play.png - @@ -305,10 +279,6 @@ Comments - - - :/icons/png/comment.png:/icons/png/comment.png - @@ -316,10 +286,6 @@ Edit - - - :/icons/png/pencil-edit-button.png:/icons/png/pencil-edit-button.png - @@ -336,10 +302,6 @@ Copy RetroShare Link - - - :/icons/png/copy.png:/icons/png/copy.png - @@ -398,10 +360,6 @@ Expand - - - :/icons/png/down-arrow.png:/icons/png/down-arrow.png - @@ -418,10 +376,6 @@ Set as read and remove item - - - :/icons/png/correct.png:/icons/png/correct.png - @@ -438,10 +392,6 @@ Remove Item - - - :/icons/png/exit2.png:/icons/png/exit2.png - From 02e939ac8fec0d418b9ec6ed7f2139481e171d8b Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 19 Apr 2020 17:41:13 +0200 Subject: [PATCH 6/7] replaced a bunch of explicit icons, mostly in abstract items models, by cached ones --- .../src/gui/FileTransfer/TransfersDialog.cpp | 84 +++++++++---------- retroshare-gui/src/gui/RemoteDirModel.cpp | 38 ++++----- .../src/gui/common/FriendListModel.cpp | 5 +- .../src/gui/gxs/GxsCommentTreeWidget.cpp | 11 +-- .../src/gui/gxsforums/GxsForumModel.cpp | 5 +- retroshare-gui/src/gui/msgs/MessageModel.cpp | 39 ++++----- 6 files changed, 92 insertions(+), 90 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index eda3aa3e3..3e010fc99 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -919,10 +919,10 @@ TransfersDialog::TransfersDialog(QWidget *parent) QObject::connect(ui.downloadList->selectionModel(),SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),this,SLOT(showFileDetails())) ; - ui.tabWidget->insertTab(2,searchDialog = new SearchDialog(), QIcon(IMAGE_SEARCH), tr("Search")) ; - ui.tabWidget->insertTab(3,remoteSharedFiles = new RemoteSharedFilesDialog(), QIcon(IMAGE_FRIENDSFILES), tr("Friends files")) ; + ui.tabWidget->insertTab(2,searchDialog = new SearchDialog(), FilesDefs::getIconFromQtResourcePath(IMAGE_SEARCH), tr("Search")) ; + ui.tabWidget->insertTab(3,remoteSharedFiles = new RemoteSharedFilesDialog(), FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDSFILES), tr("Friends files")) ; - ui.tabWidget->addTab(localSharedFiles = new LocalSharedFilesDialog(), QIcon(IMAGE_MYFILES), tr("My files")) ; + ui.tabWidget->addTab(localSharedFiles = new LocalSharedFilesDialog(), FilesDefs::getIconFromQtResourcePath(IMAGE_MYFILES), tr("My files")) ; for(int i=0;inbPlugins();++i) if(rsPlugins->plugin(i) != NULL && rsPlugins->plugin(i)->qt_transfers_tab() != NULL) @@ -933,79 +933,79 @@ TransfersDialog::TransfersDialog(QWidget *parent) /** Setup the actions for the context menu */ // Actions. Only need to be defined once. - pauseAct = new QAction(QIcon(IMAGE_PAUSE), tr("Pause"), this); + pauseAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PAUSE), tr("Pause"), this); connect(pauseAct, SIGNAL(triggered()), this, SLOT(pauseFileTransfer())); - resumeAct = new QAction(QIcon(IMAGE_RESUME), tr("Resume"), this); + resumeAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_RESUME), tr("Resume"), this); connect(resumeAct, SIGNAL(triggered()), this, SLOT(resumeFileTransfer())); - forceCheckAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Force Check" ), this ); + forceCheckAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CANCEL), tr( "Force Check" ), this ); connect( forceCheckAct , SIGNAL( triggered() ), this, SLOT( forceCheck() ) ); - cancelAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Cancel" ), this ); + cancelAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CANCEL), tr( "Cancel" ), this ); connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) ); - openFolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this); + openFolderAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_OPENFOLDER), tr("Open Folder"), this); connect(openFolderAct, SIGNAL(triggered()), this, SLOT(dlOpenFolder())); - openFileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this); + openFileAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_OPENFILE), tr("Open File"), this); connect(openFileAct, SIGNAL(triggered()), this, SLOT(dlOpenFile())); - previewFileAct = new QAction(QIcon(IMAGE_PREVIEW), tr("Preview File"), this); + previewFileAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PREVIEW), tr("Preview File"), this); connect(previewFileAct, SIGNAL(triggered()), this, SLOT(dlPreviewFile())); - detailsFileAct = new QAction(QIcon(IMAGE_INFO), tr("Details..."), this); + detailsFileAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_INFO), tr("Details..."), this); connect(detailsFileAct, SIGNAL(triggered()), this, SLOT(showDetailsDialog())); - clearCompletedAct = new QAction(QIcon(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this ); + clearCompletedAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this ); connect( clearCompletedAct , SIGNAL( triggered() ), this, SLOT( clearcompleted() ) ); - copyLinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy RetroShare Link" ), this ); + copyLinkAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr( "Copy RetroShare Link" ), this ); connect( copyLinkAct , SIGNAL( triggered() ), this, SLOT( dlCopyLink() ) ); - pasteLinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste RetroShare Link" ), this ); + pasteLinkAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PASTELINK), tr( "Paste RetroShare Link" ), this ); connect( pasteLinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) ); - queueDownAct = new QAction(QIcon(":/images/go-down.png"), tr("Down"), this); + queueDownAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/go-down.png"), tr("Down"), this); connect(queueDownAct, SIGNAL(triggered()), this, SLOT(priorityQueueDown())); - queueUpAct = new QAction(QIcon(":/images/go-up.png"), tr("Up"), this); + queueUpAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/go-up.png"), tr("Up"), this); connect(queueUpAct, SIGNAL(triggered()), this, SLOT(priorityQueueUp())); - queueTopAct = new QAction(QIcon(":/images/go-top.png"), tr("Top"), this); + queueTopAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/go-top.png"), tr("Top"), this); connect(queueTopAct, SIGNAL(triggered()), this, SLOT(priorityQueueTop())); - queueBottomAct = new QAction(QIcon(":/images/go-bottom.png"), tr("Bottom"), this); + queueBottomAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/go-bottom.png"), tr("Bottom"), this); connect(queueBottomAct, SIGNAL(triggered()), this, SLOT(priorityQueueBottom())); - chunkStreamingAct = new QAction(QIcon(IMAGE_STREAMING), tr("Streaming"), this); + chunkStreamingAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_STREAMING), tr("Streaming"), this); connect(chunkStreamingAct, SIGNAL(triggered()), this, SLOT(chunkStreaming())); - prioritySlowAct = new QAction(QIcon(IMAGE_PRIORITYLOW), tr("Slower"), this); + prioritySlowAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PRIORITYLOW), tr("Slower"), this); connect(prioritySlowAct, SIGNAL(triggered()), this, SLOT(speedSlow())); - priorityMediumAct = new QAction(QIcon(IMAGE_PRIORITYNORMAL), tr("Average"), this); + priorityMediumAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PRIORITYNORMAL), tr("Average"), this); connect(priorityMediumAct, SIGNAL(triggered()), this, SLOT(speedAverage())); - priorityFastAct = new QAction(QIcon(IMAGE_PRIORITYHIGH), tr("Faster"), this); + priorityFastAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PRIORITYHIGH), tr("Faster"), this); connect(priorityFastAct, SIGNAL(triggered()), this, SLOT(speedFast())); - chunkRandomAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Random"), this); + chunkRandomAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PRIORITYAUTO), tr("Random"), this); connect(chunkRandomAct, SIGNAL(triggered()), this, SLOT(chunkRandom())); - chunkProgressiveAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Progressive"), this); + chunkProgressiveAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PRIORITYAUTO), tr("Progressive"), this); connect(chunkProgressiveAct, SIGNAL(triggered()), this, SLOT(chunkProgressive())); - playAct = new QAction(QIcon(IMAGE_PLAY), tr( "Play" ), this ); + playAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PLAY), tr( "Play" ), this ); connect( playAct , SIGNAL( triggered() ), this, SLOT( dlOpenFile() ) ); - renameFileAct = new QAction(QIcon(IMAGE_RENAMEFILE), tr("Rename file..."), this); + renameFileAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_RENAMEFILE), tr("Rename file..."), this); connect(renameFileAct, SIGNAL(triggered()), this, SLOT(renameFile())); - specifyDestinationDirectoryAct = new QAction(QIcon(IMAGE_SEARCH),tr("Specify..."),this) ; + specifyDestinationDirectoryAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SEARCH),tr("Specify..."),this) ; connect(specifyDestinationDirectoryAct,SIGNAL(triggered()),this,SLOT(chooseDestinationDirectory())); - expandAllDLAct= new QAction(QIcon(IMAGE_EXPAND),tr("Expand all"),this); + expandAllDLAct= new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND),tr("Expand all"),this); connect(expandAllDLAct,SIGNAL(triggered()),this,SLOT(expandAllDL())); - collapseAllDLAct= new QAction(QIcon(IMAGE_COLLAPSE),tr("Collapse all"),this); + collapseAllDLAct= new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLAPSE),tr("Collapse all"),this); connect(collapseAllDLAct,SIGNAL(triggered()),this,SLOT(collapseAllDL())); - expandAllULAct= new QAction(QIcon(IMAGE_EXPAND),tr("Expand all"),this); + expandAllULAct= new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND),tr("Expand all"),this); connect(expandAllULAct,SIGNAL(triggered()),this,SLOT(expandAllUL())); - collapseAllULAct= new QAction(QIcon(IMAGE_COLLAPSE),tr("Collapse all"),this); + collapseAllULAct= new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLAPSE),tr("Collapse all"),this); connect(collapseAllULAct,SIGNAL(triggered()),this,SLOT(collapseAllUL())); - collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this); + collCreateAct= new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLCREATE), tr("Create Collection..."), this); connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate())); - collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this); + collModifAct= new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLMODIF), tr("Modify Collection..."), this); connect(collModifAct,SIGNAL(triggered()),this,SLOT(collModif())); - collViewAct= new QAction(QIcon(IMAGE_COLLVIEW), tr("View Collection..."), this); + collViewAct= new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLVIEW), tr("View Collection..."), this); connect(collViewAct,SIGNAL(triggered()),this,SLOT(collView())); - collOpenAct = new QAction(QIcon(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this ); + collOpenAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this ); connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen())); connect(NotifyQt::getInstance(), SIGNAL(downloadComplete(QString)), this, SLOT(collAutoOpen(QString))); @@ -1068,9 +1068,9 @@ TransfersDialog::TransfersDialog(QWidget *parent) connect(showULHashAct,SIGNAL(triggered(bool)),this,SLOT(setShowULHashColumn(bool))) ; /** Setup the actions for the upload context menu */ - ulOpenFolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this); + ulOpenFolderAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_OPENFOLDER), tr("Open Folder"), this); connect(ulOpenFolderAct, SIGNAL(triggered()), this, SLOT(ulOpenFolder())); - ulCopyLinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy RetroShare Link" ), this ); + ulCopyLinkAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr( "Copy RetroShare Link" ), this ); connect( ulCopyLinkAct , SIGNAL( triggered() ), this, SLOT( ulCopyLink() ) ); // load settings @@ -1231,26 +1231,26 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ ) FileInfo info; QMenu priorityQueueMenu(tr("Move in Queue..."), this); - priorityQueueMenu.setIcon(QIcon(IMAGE_PRIORITY)); + priorityQueueMenu.setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_PRIORITY)); priorityQueueMenu.addAction(queueTopAct); priorityQueueMenu.addAction(queueUpAct); priorityQueueMenu.addAction(queueDownAct); priorityQueueMenu.addAction(queueBottomAct); QMenu prioritySpeedMenu(tr("Priority (Speed)..."), this); - prioritySpeedMenu.setIcon(QIcon(IMAGE_PRIORITY)); + prioritySpeedMenu.setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_PRIORITY)); prioritySpeedMenu.addAction(prioritySlowAct); prioritySpeedMenu.addAction(priorityMediumAct); prioritySpeedMenu.addAction(priorityFastAct); QMenu chunkMenu(tr("Chunk strategy"), this); - chunkMenu.setIcon(QIcon(IMAGE_PRIORITY)); + chunkMenu.setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_PRIORITY)); chunkMenu.addAction(chunkStreamingAct); chunkMenu.addAction(chunkProgressiveAct); chunkMenu.addAction(chunkRandomAct); QMenu collectionMenu(tr("Collection"), this); - collectionMenu.setIcon(QIcon(IMAGE_LIBRARY)); + collectionMenu.setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_LIBRARY)); collectionMenu.addAction(collCreateAct); collectionMenu.addAction(collModifAct); collectionMenu.addAction(collViewAct); @@ -1331,7 +1331,7 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ ) contextMnu.addAction( renameFileAct) ; } - QMenu *directoryMenu = contextMnu.addMenu(QIcon(IMAGE_OPENFOLDER), tr("Set destination directory")) ; + QMenu *directoryMenu = contextMnu.addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_OPENFOLDER), tr("Set destination directory")) ; directoryMenu->addAction(specifyDestinationDirectoryAct) ; // Now get the list of existing directories. diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index e522eb4f8..ac4a34d37 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -100,11 +100,9 @@ static bool isNewerThanEpoque(uint32_t ts) void RetroshareDirModel::treeStyle() { - categoryIcon.addPixmap(QPixmap(":/icons/folder.png"), - QIcon::Normal, QIcon::Off); - categoryIcon.addPixmap(QPixmap(":/icons/folderopen.png"), - QIcon::Normal, QIcon::On); - peerIcon = QIcon(":/images/user/identity16.png"); + categoryIcon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/folder.png"), QIcon::Normal, QIcon::Off); + categoryIcon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/folderopen.png"), QIcon::Normal, QIcon::On); + peerIcon = FilesDefs::getIconFromQtResourcePath(":/images/user/identity16.png"); } void TreeStyle_RDM::update() { @@ -349,19 +347,19 @@ const QIcon& RetroshareDirModel::getFlagsIcon(FileStorageFlags flags) QList icons ; if(flags & DIR_FLAGS_ANONYMOUS_SEARCH) - icons.push_back(QIcon(":icons/search_red_128.png")) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath(":icons/search_red_128.png")) ; else - icons.push_back(QIcon(":icons/void_128.png")) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath(":icons/void_128.png")) ; if(flags & DIR_FLAGS_ANONYMOUS_DOWNLOAD) - icons.push_back(QIcon(":icons/anonymous_blue_128.png")) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath(":icons/anonymous_blue_128.png")) ; else - icons.push_back(QIcon(":icons/void_128.png")) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath(":icons/void_128.png")) ; if(flags & DIR_FLAGS_BROWSABLE) - icons.push_back(QIcon(":icons/browsable_green_128.png")) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath(":icons/browsable_green_128.png")) ; else - icons.push_back(QIcon(":icons/void_128.png")) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath(":icons/void_128.png")) ; QPixmap pix ; GxsIdDetails::GenerateCombinedPixmap(pix, icons, 128); @@ -399,13 +397,13 @@ QVariant RetroshareDirModel::decorationRole(const DirDetails& details,int coln) time_t now = time(NULL) ; if(ageIndicator != IND_ALWAYS && now > details.max_mtime + ageIndicator) - return QIcon(":/images/folder_grey.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/folder_grey.png"); else if (ageIndicator == IND_LAST_DAY ) - return QIcon(":/images/folder_green.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/folder_green.png"); else if (ageIndicator == IND_LAST_WEEK ) - return QIcon(":/images/folder_yellow.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/folder_yellow.png"); else if (ageIndicator == IND_LAST_MONTH ) - return QIcon(":/images/folder_red.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/folder_red.png"); else return (QIcon(peerIcon)); } @@ -414,13 +412,13 @@ QVariant RetroshareDirModel::decorationRole(const DirDetails& details,int coln) time_t now = time(NULL) ; if(ageIndicator != IND_ALWAYS && now > details.max_mtime + ageIndicator) - return QIcon(":/images/folder_grey.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/folder_grey.png"); else if (ageIndicator == IND_LAST_DAY ) - return QIcon(":/images/folder_green.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/folder_green.png"); else if (ageIndicator == IND_LAST_WEEK ) - return QIcon(":/images/folder_yellow.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/folder_yellow.png"); else if (ageIndicator == IND_LAST_MONTH ) - return QIcon(":/images/folder_red.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/folder_red.png"); else return QIcon(categoryIcon); } @@ -428,7 +426,7 @@ QVariant RetroshareDirModel::decorationRole(const DirDetails& details,int coln) { // extensions predefined if(details.hash.isNull()) - return QIcon(":/images/reset.png") ; // file is being hashed + return FilesDefs::getIconFromQtResourcePath(":/images/reset.png") ; // file is being hashed else return FilesDefs::getIconFromFileType(QString::fromUtf8(details.name.c_str())); } diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 3da609aa4..65fb56ee2 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -27,6 +27,7 @@ #include #include "gui/common/StatusDefs.h" +#include "gui/common/FilesDefs.h" #include "gui/common/AvatarDefs.h" #include "util/HandleRichText.h" #include "util/DateTime.h" @@ -815,13 +816,13 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons switch(entry.type) { - case ENTRY_TYPE_GROUP: return QVariant(QIcon(IMAGE_GROUP24)); + case ENTRY_TYPE_GROUP: return QVariant(FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP24)); case ENTRY_TYPE_PROFILE: { if(!isProfileExpanded(entry)) { - QPixmap sslAvatar(AVATAR_DEFAULT_IMAGE); + QPixmap sslAvatar = FilesDefs::getPixmapFromQtResourcePath(AVATAR_DEFAULT_IMAGE); const HierarchicalProfileInformation *hn = getProfileInfo(entry); diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index c142abf35..14413963f 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -28,6 +28,7 @@ #include #include "gui/common/RSElidedItemDelegate.h" +#include "gui/common/FilesDefs.h" #include "gui/gxs/GxsCommentTreeWidget.h" #include "gui/gxs/GxsCreateCommentDialog.h" #include "gui/gxs/GxsIdTreeWidgetItem.h" @@ -186,18 +187,18 @@ void GxsCommentTreeWidget::setCurrentCommentMsgId(QTreeWidgetItem *current, QTre void GxsCommentTreeWidget::customPopUpMenu(const QPoint& /*point*/) { QMenu contextMnu( this ); - QAction* action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Reply to Comment"), this, SLOT(replyToComment())); + QAction* action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("Reply to Comment"), this, SLOT(replyToComment())); action->setDisabled(mCurrentCommentMsgId.isNull()); - action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Submit Comment"), this, SLOT(makeComment())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("Submit Comment"), this, SLOT(makeComment())); action->setDisabled(mMsgVersions.empty()); - action = contextMnu.addAction(QIcon(IMAGE_COPY), tr("Copy Comment"), this, SLOT(copyComment())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPY), tr("Copy Comment"), this, SLOT(copyComment())); action->setDisabled(mCurrentCommentMsgId.isNull()); contextMnu.addSeparator(); - action = contextMnu.addAction(QIcon(IMAGE_VOTEUP), tr("Vote Up"), this, SLOT(voteUp())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_VOTEUP), tr("Vote Up"), this, SLOT(voteUp())); action->setDisabled(mVoterId.isNull()); - action = contextMnu.addAction(QIcon(IMAGE_VOTEDOWN), tr("Vote Down"), this, SLOT(voteDown())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_VOTEDOWN), tr("Vote Down"), this, SLOT(voteDown())); action->setDisabled(mVoterId.isNull()); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index 460939474..e126e55d4 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -23,6 +23,7 @@ #include #include +#include "gui/common/FilesDefs.h" #include "util/qtthreadsutils.h" #include "util/HandleRichText.h" #include "util/DateTime.h" @@ -359,8 +360,8 @@ QVariant RsGxsForumModel::headerData(int section, Qt::Orientation /*orientation* if(role == Qt::DecorationRole) switch(section) { - case COLUMN_THREAD_DISTRIBUTION: return QIcon(":/icons/flag-green.png"); - case COLUMN_THREAD_READ: return QIcon(":/images/message-state-read.png"); + case COLUMN_THREAD_DISTRIBUTION: return FilesDefs::getIconFromQtResourcePath(":/icons/flag-green.png"); + case COLUMN_THREAD_READ: return FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png"); default: return QVariant(); } diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index 2d794a8c7..aabcca492 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -27,6 +27,7 @@ #include #include "gui/common/TagDefs.h" +#include "gui/common/FilesDefs.h" #include "util/HandleRichText.h" #include "util/DateTime.h" #include "gui/gxs/GxsIdDetails.h" @@ -171,9 +172,9 @@ QVariant RsMessageModel::headerData(int section, Qt::Orientation orientation, in if(role == Qt::DecorationRole) switch(section) { - case COLUMN_THREAD_STAR: return QIcon(IMAGE_STAR_ON); - case COLUMN_THREAD_READ: return QIcon(":/images/message-state-header.png"); - case COLUMN_THREAD_ATTACHMENT: return QIcon(":/icons/png/attachements.png"); + case COLUMN_THREAD_STAR: return FilesDefs::getIconFromQtResourcePath(IMAGE_STAR_ON); + case COLUMN_THREAD_READ: return FilesDefs::getIconFromQtResourcePath(":/images/message-state-header.png"); + case COLUMN_THREAD_ATTACHMENT: return FilesDefs::getIconFromQtResourcePath(":/icons/png/attachements.png"); default: return QVariant(); } @@ -511,39 +512,39 @@ QVariant RsMessageModel::decorationRole(const Rs::Msgs::MsgInfoSummary& fmpe,int { if(col == COLUMN_THREAD_READ) if(fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER)) - return QIcon(":/images/message-state-unread.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png"); else - return QIcon(":/images/message-state-read.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png"); if(col == COLUMN_THREAD_SUBJECT) { - if(fmpe.msgflags & RS_MSG_NEW ) return QIcon(":/images/message-state-new.png"); - if(fmpe.msgflags & RS_MSG_USER_REQUEST) return QIcon(":/images/user/user_request16.png"); - if(fmpe.msgflags & RS_MSG_FRIEND_RECOMMENDATION) return QIcon(":/images/user/friend_suggestion16.png"); - if(fmpe.msgflags & RS_MSG_PUBLISH_KEY) return QIcon(":/images/share-icon-16.png"); + if(fmpe.msgflags & RS_MSG_NEW ) return FilesDefs::getIconFromQtResourcePath(":/images/message-state-new.png"); + if(fmpe.msgflags & RS_MSG_USER_REQUEST) return FilesDefs::getIconFromQtResourcePath(":/images/user/user_request16.png"); + if(fmpe.msgflags & RS_MSG_FRIEND_RECOMMENDATION) return FilesDefs::getIconFromQtResourcePath(":/images/user/friend_suggestion16.png"); + if(fmpe.msgflags & RS_MSG_PUBLISH_KEY) return FilesDefs::getIconFromQtResourcePath(":/images/share-icon-16.png"); if(fmpe.msgflags & RS_MSG_UNREAD_BY_USER) { - if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) return QIcon(":/images/message-mail-replied.png"); - if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) return QIcon(":/images/message-mail-forwarded.png"); - if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) return QIcon(":/images/message-mail-replied-forw.png"); + if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) return FilesDefs::getIconFromQtResourcePath(":/images/message-mail-replied.png"); + if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) return FilesDefs::getIconFromQtResourcePath(":/images/message-mail-forwarded.png"); + if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) return FilesDefs::getIconFromQtResourcePath(":/images/message-mail-replied-forw.png"); - return QIcon(":/images/message-mail.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/message-mail.png"); } - if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) return QIcon(":/images/message-mail-replied-read.png"); - if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) return QIcon(":/images/message-mail-forwarded-read.png"); - if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) return QIcon(":/images/message-mail-replied-forw-read.png"); + if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) return FilesDefs::getIconFromQtResourcePath(":/images/message-mail-replied-read.png"); + if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) return FilesDefs::getIconFromQtResourcePath(":/images/message-mail-forwarded-read.png"); + if((fmpe.msgflags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) return FilesDefs::getIconFromQtResourcePath(":/images/message-mail-replied-forw-read.png"); - return QIcon(":/images/message-mail-read.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/message-mail-read.png"); } if(col == COLUMN_THREAD_STAR) - return QIcon((fmpe.msgflags & RS_MSG_STAR) ? (IMAGE_STAR_ON ): (IMAGE_STAR_OFF)); + return FilesDefs::getIconFromQtResourcePath((fmpe.msgflags & RS_MSG_STAR) ? (IMAGE_STAR_ON ): (IMAGE_STAR_OFF)); bool isNew = fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER); if(col == COLUMN_THREAD_READ) - return QIcon(isNew ? ":/images/message-state-unread.png": ":/images/message-state-read.png"); + return FilesDefs::getIconFromQtResourcePath(isNew ? ":/images/message-state-unread.png": ":/images/message-state-read.png"); return QVariant(); } From 5b761c72bad6eb3b2dcd96fd0e3c9c00dfecb225 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 19 Apr 2020 21:07:53 +0200 Subject: [PATCH 7/7] removed debug info --- libretroshare/src/gxs/rsdataservice.cc | 4 ---- libretroshare/src/gxs/rsgxsdataaccess.cc | 2 -- libretroshare/src/retroshare/rsgxsifacehelper.h | 16 +++++++++++++++- retroshare-gui/src/gui/common/FilesDefs.cpp | 14 ++++++++++++++ .../src/gui/feeds/GxsChannelPostItem.cpp | 7 ++++++- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/libretroshare/src/gxs/rsdataservice.cc b/libretroshare/src/gxs/rsdataservice.cc index cc215dc14..6bdc924ed 100644 --- a/libretroshare/src/gxs/rsdataservice.cc +++ b/libretroshare/src/gxs/rsdataservice.cc @@ -26,10 +26,6 @@ * #define RS_DATA_SERVICE_DEBUG_CACHE 1 ****/ -#define RS_DATA_SERVICE_DEBUG 1 -#define RS_DATA_SERVICE_DEBUG_TIME 1 -#define RS_DATA_SERVICE_DEBUG_CACHE 1 - #include #include #include diff --git a/libretroshare/src/gxs/rsgxsdataaccess.cc b/libretroshare/src/gxs/rsgxsdataaccess.cc index f8300b37e..dd41f9237 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.cc +++ b/libretroshare/src/gxs/rsgxsdataaccess.cc @@ -30,8 +30,6 @@ * #define DATA_DEBUG 1 **********/ -#define DATA_DEBUG 1 - RsGxsDataAccess::RsGxsDataAccess(RsGeneralDataService* ds) : mDataStore(ds), mDataMutex("RsGxsDataAccess"), mNextToken(0) {} diff --git a/libretroshare/src/retroshare/rsgxsifacehelper.h b/libretroshare/src/retroshare/rsgxsifacehelper.h index 422261a02..9f49e76ef 100644 --- a/libretroshare/src/retroshare/rsgxsifacehelper.h +++ b/libretroshare/src/retroshare/rsgxsifacehelper.h @@ -40,7 +40,7 @@ * are necessary, so at this point this workaround seems acceptable. */ -#define DEBUG_GXSIFACEHELPER 1 +//#define DEBUG_GXSIFACEHELPER 1 enum class TokenRequestType: uint8_t { @@ -270,7 +270,9 @@ public: { RS_STACK_MUTEX(mMtx); mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type; +#ifdef DEBUG_GXSIFACEHELPER locked_dumpTokens(); +#endif return true; } else @@ -298,7 +300,9 @@ public: { RS_STACK_MUTEX(mMtx); mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type; +#ifdef DEBUG_GXSIFACEHELPER locked_dumpTokens(); +#endif return true; } else @@ -313,7 +317,9 @@ public: RS_STACK_MUTEX(mMtx); mActiveTokens[token]= (msgIds.size()==1 && msgIds.begin()->second.size()==0) ?(TokenRequestType::ALL_POSTS):(TokenRequestType::POSTS); +#ifdef DEBUG_GXSIFACEHELPER locked_dumpTokens(); +#endif return true; } else @@ -327,7 +333,9 @@ public: { RS_STACK_MUTEX(mMtx); mActiveTokens[token]=TokenRequestType::ALL_POSTS; +#ifdef DEBUG_GXSIFACEHELPER locked_dumpTokens(); +#endif return true; } else @@ -343,7 +351,9 @@ public: { RS_STACK_MUTEX(mMtx); mActiveTokens[token]=TokenRequestType::MSG_RELATED_INFO; +#ifdef DEBUG_GXSIFACEHELPER locked_dumpTokens(); +#endif return true; } else @@ -365,7 +375,9 @@ public: RS_STACK_MUTEX(mMtx); mActiveTokens[token]=TokenRequestType::SERVICE_STATISTICS; +#ifdef DEBUG_GXSIFACEHELPER locked_dumpTokens(); +#endif } /// @see RsTokenService::requestGroupStatistic @@ -375,7 +387,9 @@ public: RS_STACK_MUTEX(mMtx); mActiveTokens[token]=TokenRequestType::GROUP_STATISTICS; +#ifdef DEBUG_GXSIFACEHELPER locked_dumpTokens(); +#endif return true; } diff --git a/retroshare-gui/src/gui/common/FilesDefs.cpp b/retroshare-gui/src/gui/common/FilesDefs.cpp index dc8b30e86..c8b0d63d8 100644 --- a/retroshare-gui/src/gui/common/FilesDefs.cpp +++ b/retroshare-gui/src/gui/common/FilesDefs.cpp @@ -27,6 +27,8 @@ #include +//#define DEBUG_FILESDEFS 1 + static QString getInfoFromFilename(const QString& filename, bool anyForUnknown, bool image) { QString ext = QFileInfo(filename).suffix().toLower(); @@ -89,19 +91,25 @@ QPixmap FilesDefs::getPixmapFromQtResourcePath(const QString& resource_path) { static std::map mPixmapCache; QPixmap pixmap; +#ifdef DEBUG_FILESDEFS std::cerr << "Creating Pixmap from resource path " << resource_path.toStdString() ; +#endif auto item = mPixmapCache.find(resource_path); if (item == mPixmapCache.end()) { +#ifdef DEBUG_FILESDEFS std::cerr << " Not in cache. Creating new one." << std::endl; +#endif pixmap = QPixmap(resource_path); mPixmapCache[resource_path] = pixmap; } else { +#ifdef DEBUG_FILESDEFS std::cerr << " In cache. " << std::endl; +#endif pixmap = item->second; } @@ -112,19 +120,25 @@ QIcon FilesDefs::getIconFromQtResourcePath(const QString& resource_path) { static std::map mIconCache; QIcon icon; +#ifdef DEBUG_FILESDEFS std::cerr << "Creating Icon from resource path " << resource_path.toStdString() ; +#endif auto item = mIconCache.find(resource_path); if (item == mIconCache.end()) { +#ifdef DEBUG_FILESDEFS std::cerr << " Not in cache. Creating new one." << std::endl; +#endif icon = QIcon(resource_path); mIconCache[resource_path] = icon; } else { +#ifdef DEBUG_FILESDEFS std::cerr << " In cache. " << std::endl; +#endif icon = item->second; } diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 4ee799041..c01ca7315 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -288,7 +288,9 @@ void GxsChannelPostItem::loadMessage() if (posts.size() == 1) { +#ifdef DEBUG_ITEM std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl; +#endif const RsGxsChannelPost& post(posts[0]); RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this ); @@ -296,7 +298,9 @@ void GxsChannelPostItem::loadMessage() else if(comments.size() == 1) { const RsGxsComment& cmt = comments[0]; +#ifdef DEBUG_ITEM std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl; +#endif RsQThreadUtils::postToObject( [cmt,this]() { @@ -313,8 +317,10 @@ void GxsChannelPostItem::loadMessage() } else { +#ifdef DEBUG_ITEM std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It."; std::cerr << std::endl; +#endif RsQThreadUtils::postToObject( [this]() { removeItem(); }, this ); } @@ -745,7 +751,6 @@ void GxsChannelPostItem::readAndClearItem() std::cerr << "GxsChannelPostItem::readAndClearItem()"; std::cerr << std::endl; #endif - readToggled(false); removeItem(); }