mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-28 00:07:09 -05:00
fixing async loading of channels. To be tested.
This commit is contained in:
parent
f0ed0dd471
commit
d876bb721b
@ -46,16 +46,29 @@
|
|||||||
#define COLOR_NORMAL QColor(248, 248, 248)
|
#define COLOR_NORMAL QColor(248, 248, 248)
|
||||||
#define COLOR_NEW QColor(220, 236, 253)
|
#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<RsGxsMessageId>& older_versions) :
|
||||||
GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsGxsChannels, autoUpdate)
|
GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsGxsChannels, autoUpdate)
|
||||||
{
|
{
|
||||||
|
QVector<RsGxsMessageId> v;
|
||||||
|
bool self = false;
|
||||||
|
|
||||||
|
for(std::set<RsGxsMessageId>::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();
|
setup();
|
||||||
|
|
||||||
requestGroup();
|
mLoaded = false ;
|
||||||
requestMessage();
|
|
||||||
requestComment();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This code has been suspended because it adds more complexity than usefulness.
|
||||||
|
// It was used to load a channel post where the post item is already known.
|
||||||
|
|
||||||
|
#ifdef SUSPENDED
|
||||||
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup &group, const RsGxsChannelPost &post, bool isHome, bool autoUpdate) :
|
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup &group, const RsGxsChannelPost &post, bool isHome, bool autoUpdate) :
|
||||||
GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, autoUpdate)
|
GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, autoUpdate)
|
||||||
{
|
{
|
||||||
@ -82,9 +95,9 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId,
|
|||||||
setup();
|
setup();
|
||||||
|
|
||||||
setGroup(group, false);
|
setGroup(group, false);
|
||||||
//requestGroup(); //Already have RsGxsChannelGroup
|
|
||||||
setPost(post);
|
setPost(post,false);
|
||||||
requestComment();
|
mLoaded = false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, bool isHome, bool autoUpdate) :
|
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, bool isHome, bool autoUpdate) :
|
||||||
@ -97,10 +110,30 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId,
|
|||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
mLoaded = true ;
|
||||||
requestGroup();
|
requestGroup();
|
||||||
setPost(post);
|
setPost(post);
|
||||||
requestComment();
|
requestComment();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void GxsChannelPostItem::paintEvent(QPaintEvent *e)
|
||||||
|
{
|
||||||
|
/* This method employs a trick to trigger a deferred loading. The post and group is requested only
|
||||||
|
* when actually displayed on the screen. */
|
||||||
|
|
||||||
|
if(!mLoaded)
|
||||||
|
{
|
||||||
|
mLoaded = true ;
|
||||||
|
|
||||||
|
requestGroup();
|
||||||
|
requestMessage();
|
||||||
|
requestComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
GxsFeedItem::paintEvent(e) ;
|
||||||
|
}
|
||||||
|
|
||||||
GxsChannelPostItem::~GxsChannelPostItem()
|
GxsChannelPostItem::~GxsChannelPostItem()
|
||||||
{
|
{
|
||||||
@ -349,6 +382,14 @@ void GxsChannelPostItem::fill()
|
|||||||
|
|
||||||
QString title;
|
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 (!mIsHome)
|
||||||
{
|
{
|
||||||
if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) {
|
if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) {
|
||||||
@ -386,9 +427,12 @@ void GxsChannelPostItem::fill()
|
|||||||
/* subject */
|
/* subject */
|
||||||
ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str()));
|
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
|
// 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(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()), 4)) ;
|
|
||||||
|
//ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ;
|
||||||
|
|
||||||
//QString score = QString::number(post.mTopScore);
|
//QString score = QString::number(post.mTopScore);
|
||||||
// scoreLabel->setText(score);
|
// scoreLabel->setText(score);
|
||||||
@ -496,14 +540,6 @@ void GxsChannelPostItem::fill()
|
|||||||
layout->addWidget(fi);
|
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;
|
mInFill = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,9 +41,14 @@ class GxsChannelPostItem : public GxsFeedItem
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate);
|
// 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 RsGxsChannelGroup &group, const RsGxsChannelPost &post, 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
|
||||||
GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, bool isHome, bool autoUpdate);
|
// 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<RsGxsMessageId>& older_versions = std::set<RsGxsMessageId>());
|
||||||
|
|
||||||
|
//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();
|
virtual ~GxsChannelPostItem();
|
||||||
|
|
||||||
bool setGroup(const RsGxsChannelGroup &group, bool doFill = true);
|
bool setGroup(const RsGxsChannelGroup &group, bool doFill = true);
|
||||||
@ -62,6 +67,11 @@ protected:
|
|||||||
virtual void doExpand(bool open);
|
virtual void doExpand(bool open);
|
||||||
virtual void expandFill(bool first);
|
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 */
|
/* GxsGroupFeedItem */
|
||||||
virtual QString groupName();
|
virtual QString groupName();
|
||||||
virtual void loadGroup(const uint32_t &token);
|
virtual void loadGroup(const uint32_t &token);
|
||||||
@ -101,6 +111,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
bool mInFill;
|
bool mInFill;
|
||||||
bool mCloseOnRead;
|
bool mCloseOnRead;
|
||||||
|
bool mLoaded;
|
||||||
|
|
||||||
RsGxsChannelGroup mGroup;
|
RsGxsChannelGroup mGroup;
|
||||||
RsGxsChannelPost mPost;
|
RsGxsChannelPost mPost;
|
||||||
|
@ -407,10 +407,12 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost &post, bool re
|
|||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
ui->feedWidget->removeFeedItem(item) ;
|
ui->feedWidget->removeFeedItem(item) ;
|
||||||
RsGxsChannelGroup dummyGroup;
|
//RsGxsChannelGroup dummyGroup;
|
||||||
dummyGroup.mMeta.mGroupId = groupId();
|
//dummyGroup.mMeta.mGroupId = groupId();
|
||||||
dummyGroup.mMeta.mSubscribeFlags = 0xffffffff;
|
//dummyGroup.mMeta.mSubscribeFlags = 0xffffffff;
|
||||||
GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, dummyGroup, post, true, false);
|
//GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, dummyGroup, post, true, false);
|
||||||
|
|
||||||
|
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));
|
ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs));
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
@ -427,10 +429,13 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost &post, bool re
|
|||||||
ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs));
|
ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs));
|
||||||
} else {
|
} else {
|
||||||
/* Group is not always available because of the TokenQueue */
|
/* Group is not always available because of the TokenQueue */
|
||||||
RsGxsChannelGroup dummyGroup;
|
|
||||||
dummyGroup.mMeta.mGroupId = groupId();
|
//RsGxsChannelGroup dummyGroup;
|
||||||
dummyGroup.mMeta.mSubscribeFlags = 0xffffffff;
|
//dummyGroup.mMeta.mGroupId = groupId();
|
||||||
GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, dummyGroup, post, true, false);
|
//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, false,post.mOlderVersions);
|
||||||
ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs));
|
ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user