From 719b414a82f3f53aa33bdcdaa0206463b18ca027 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 3 Jul 2017 22:32:08 +0200 Subject: [PATCH 1/4] fixed merging of comments in channel post with async-ed loading system --- retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp | 13 ++++++++++++- retroshare-gui/src/gui/feeds/GxsChannelPostItem.h | 8 +++++++- .../src/gui/gxschannels/GxsChannelPostsWidget.cpp | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 53fc4830f..93107d649 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -46,9 +46,20 @@ #define COLOR_NORMAL QColor(248, 248, 248) #define COLOR_NEW QColor(220, 236, 253) -GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool 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) { + 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(); mLoaded = false ; diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h index 32f8b0b06..96d2f499e 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h @@ -42,7 +42,10 @@ class GxsChannelPostItem : public GxsFeedItem public: // This one is used in NewFeed for incoming channel posts. Only the group and msg ids are known at this point. - GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate); + // 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 RsGxsChannelGroup &group, const RsGxsChannelPost &post, bool isHome, bool autoUpdate); //GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, bool isHome, bool autoUpdate); @@ -64,6 +67,9 @@ protected: virtual void doExpand(bool open); virtual void expandFill(bool first); + // This does nothing except triggering the loading of the post data and comments. This function is mainly used to detect + // when the post is actually made visible. + virtual void paintEvent(QPaintEvent *); /* GxsGroupFeedItem */ diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index f78bc339a..12f5b5e85 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -412,7 +412,7 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost &post, bool re //dummyGroup.mMeta.mSubscribeFlags = 0xffffffff; //GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, dummyGroup, post, true, false); - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post.mMeta.mGroupId, post.mMeta.mMsgId, true, true); + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post.mMeta.mGroupId, post.mMeta.mMsgId, true, false,post.mOlderVersions); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); return ; @@ -435,7 +435,7 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost &post, bool re //dummyGroup.mMeta.mSubscribeFlags = 0xffffffff; //GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, dummyGroup, post, true, false); - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post.mMeta.mGroupId, post.mMeta.mMsgId, true, true); + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post.mMeta.mGroupId, post.mMeta.mMsgId, true, false,post.mOlderVersions); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); } From 1dea00d2cbbaf7b6867e8eabd3a70c144be22e3d Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 3 Jul 2017 23:09:17 +0200 Subject: [PATCH 2/4] attempt to fix channel post auto-size by limiting the number of lines from message to display in summary depending on available size --- .../src/gui/feeds/GxsChannelPostItem.cpp | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 93107d649..4db137ff3 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -382,6 +382,14 @@ void GxsChannelPostItem::fill() QString title; + if(mPost.mThumbnail.mData != NULL) + { + QPixmap thumbnail; + thumbnail.loadFromData(mPost.mThumbnail.mData, mPost.mThumbnail.mSize, "PNG"); + // Wiping data - as its been passed to thumbnail. + ui->logoLabel->setPixmap(thumbnail); + } + if (!mIsHome) { if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { @@ -419,9 +427,12 @@ void GxsChannelPostItem::fill() /* subject */ ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); + uint32_t autorized_lines = (int)floor((ui->logoLabel->height() - ui->titleLabel->height() - ui->buttonHLayout->sizeHint().height())/QFontMetricsF(ui->subjectLabel->font()).height()); + // fill first 4 lines of message. (csoler) Disabled the replacement of smileys and links, because the cost is too crazy - //ui->subjectLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 4), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); - ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 4)) ; + ui->subjectLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); + + //ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ; //QString score = QString::number(post.mTopScore); // scoreLabel->setText(score); @@ -529,14 +540,6 @@ void GxsChannelPostItem::fill() layout->addWidget(fi); } - if(mPost.mThumbnail.mData != NULL) - { - QPixmap thumbnail; - thumbnail.loadFromData(mPost.mThumbnail.mData, mPost.mThumbnail.mSize, "PNG"); - // Wiping data - as its been passed to thumbnail. - ui->logoLabel->setPixmap(thumbnail); - } - mInFill = false; } From 931ddaef7950ce65c5b442fb4305dfc72656b7e7 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 4 Jul 2017 23:13:03 +0200 Subject: [PATCH 3/4] set load thread to false for channels on default. Fixed missing () in connect --- retroshare-gui/src/gui/settings/ChannelPage.cpp | 7 +++++-- retroshare-gui/src/gui/settings/rsharesettings.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/settings/ChannelPage.cpp b/retroshare-gui/src/gui/settings/ChannelPage.cpp index 199dd5b3a..eff89a5e5 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.cpp +++ b/retroshare-gui/src/gui/settings/ChannelPage.cpp @@ -33,10 +33,13 @@ ChannelPage::ChannelPage(QWidget * parent, Qt::WindowFlags flags) ui.groupFrameSettingsWidget->setOpenAllInNewTabText(tr("Open each channel in a new tab")); ui.groupFrameSettingsWidget->setType(GroupFrameSettings::Channel) ; - connect(ui.loadThreadCheckBox,SIGNAL(toggled(bool)),this,SLOT(updateLoadThread)) ; + connect(ui.loadThreadCheckBox,SIGNAL(toggled(bool)),this,SLOT(updateLoadThread())) ; } -void ChannelPage::updateLoadThread() { Settings->setChannelLoadThread(ui.loadThreadCheckBox->isChecked()); } +void ChannelPage::updateLoadThread() +{ + Settings->setChannelLoadThread(ui.loadThreadCheckBox->isChecked()); +} ChannelPage::~ChannelPage() { diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index f550c66be..1ad2a76d3 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -1066,7 +1066,7 @@ void RshareSettings::setForumLoadEmoticons(bool value) /* Channel */ bool RshareSettings::getChannelLoadThread() { - return valueFromGroup("Channel", "LoadThread", true).toBool(); + return valueFromGroup("Channel", "LoadThread", false).toBool(); } void RshareSettings::setChannelLoadThread(bool value) From 5f7df7cb736125183fe522e02833f25d0e2a9efb Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 4 Jul 2017 23:26:57 +0200 Subject: [PATCH 4/4] update call to notifySettingsChanged() when changing the thread loading of channels --- retroshare-gui/src/gui/settings/ChannelPage.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/retroshare-gui/src/gui/settings/ChannelPage.cpp b/retroshare-gui/src/gui/settings/ChannelPage.cpp index eff89a5e5..27f71e8e6 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.cpp +++ b/retroshare-gui/src/gui/settings/ChannelPage.cpp @@ -22,6 +22,7 @@ #include "ChannelPage.h" #include "rsharesettings.h" #include "util/misc.h" +#include "gui/notifyqt.h" ChannelPage::ChannelPage(QWidget * parent, Qt::WindowFlags flags) : ConfigPage(parent, flags) @@ -39,6 +40,7 @@ ChannelPage::ChannelPage(QWidget * parent, Qt::WindowFlags flags) void ChannelPage::updateLoadThread() { Settings->setChannelLoadThread(ui.loadThreadCheckBox->isChecked()); + NotifyQt::getInstance()->notifySettingsChanged(); } ChannelPage::~ChannelPage()