mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-20 04:14:27 -04:00
started improving Boards the same way than Channels. Not working yet
This commit is contained in:
parent
5120f693be
commit
958db27eaa
8 changed files with 165 additions and 203 deletions
|
@ -40,43 +40,48 @@
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
|
|
||||||
PostedCardView::PostedCardView(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate) :
|
PostedCardView::PostedCardView(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData &group_meta, const RsGxsMessageId &post_id, bool isHome, bool autoUpdate) :
|
||||||
GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsPosted, autoUpdate)
|
GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, post_id, isHome, rsPosted, autoUpdate),
|
||||||
|
mGroupMeta(group_meta)
|
||||||
{
|
{
|
||||||
setup();
|
mPost.mMeta.mMsgId = post_id;
|
||||||
|
mPost.mMeta.mGroupId = mGroupMeta.mGroupId;
|
||||||
|
|
||||||
requestGroup();
|
mLoaded = false;
|
||||||
requestMessage();
|
setup();
|
||||||
requestComment();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PostedCardView::PostedCardView(FeedHolder *feedHolder, uint32_t feedId, const RsPostedGroup &group, const RsPostedPost &post, bool isHome, bool autoUpdate) :
|
PostedCardView::PostedCardView(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId& post_id, bool isHome, bool autoUpdate) :
|
||||||
GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsPosted, autoUpdate)
|
GxsFeedItem(feedHolder, feedId, groupId, post_id, isHome, rsPosted, autoUpdate)
|
||||||
{
|
{
|
||||||
|
mPost.mMeta.mMsgId = post_id;
|
||||||
|
mLoaded = false;
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
mMessageId = post.mMeta.mMsgId;
|
loadGroup();
|
||||||
|
|
||||||
|
|
||||||
setGroup(group, false);
|
|
||||||
setPost(post);
|
|
||||||
requestComment();
|
|
||||||
}
|
|
||||||
|
|
||||||
PostedCardView::PostedCardView(FeedHolder *feedHolder, uint32_t feedId, const RsPostedPost &post, bool isHome, bool autoUpdate) :
|
|
||||||
GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsPosted, autoUpdate)
|
|
||||||
{
|
|
||||||
setup();
|
|
||||||
|
|
||||||
requestGroup();
|
|
||||||
setPost(post);
|
|
||||||
requestComment();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PostedCardView::~PostedCardView()
|
PostedCardView::~PostedCardView()
|
||||||
{
|
{
|
||||||
delete(ui);
|
delete(ui);
|
||||||
}
|
}
|
||||||
|
void PostedCardView::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 ;
|
||||||
|
|
||||||
|
fill();
|
||||||
|
requestMessage();
|
||||||
|
requestComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
GxsFeedItem::paintEvent(e) ;
|
||||||
|
}
|
||||||
|
|
||||||
void PostedCardView::setup()
|
void PostedCardView::setup()
|
||||||
{
|
{
|
||||||
|
@ -125,23 +130,6 @@ void PostedCardView::setup()
|
||||||
ui->readAndClearButton->hide();
|
ui->readAndClearButton->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PostedCardView::setGroup(const RsPostedGroup &group, bool doFill)
|
|
||||||
{
|
|
||||||
if (groupId() != group.mMeta.mGroupId) {
|
|
||||||
std::cerr << "PostedCardView::setGroup() - Wrong id, cannot set post";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mGroup = group;
|
|
||||||
|
|
||||||
if (doFill) {
|
|
||||||
fill();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PostedCardView::setPost(const RsPostedPost &post, bool doFill)
|
bool PostedCardView::setPost(const RsPostedPost &post, bool doFill)
|
||||||
{
|
{
|
||||||
if (groupId() != post.mMeta.mGroupId || messageId() != post.mMeta.mMsgId) {
|
if (groupId() != post.mMeta.mGroupId || messageId() != post.mMeta.mMsgId) {
|
||||||
|
@ -192,7 +180,7 @@ void PostedCardView::loadGroup()
|
||||||
* thread, for example to update the data model with new information
|
* thread, for example to update the data model with new information
|
||||||
* after a blocking call to RetroShare API complete */
|
* after a blocking call to RetroShare API complete */
|
||||||
|
|
||||||
setGroup(group);
|
mGroupMeta = group.mMeta;
|
||||||
|
|
||||||
}, this );
|
}, this );
|
||||||
});
|
});
|
||||||
|
@ -218,7 +206,7 @@ void PostedCardView::loadMessage()
|
||||||
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
||||||
const RsPostedPost& post(posts[0]);
|
const RsPostedPost& post(posts[0]);
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
|
RsQThreadUtils::postToObject( [post,this]() { setPost(post,true); }, this );
|
||||||
}
|
}
|
||||||
else if(comments.size() == 1)
|
else if(comments.size() == 1)
|
||||||
{
|
{
|
||||||
|
@ -461,19 +449,19 @@ void PostedCardView::fill()
|
||||||
emit sizeChanged(this);
|
emit sizeChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const RsPostedPost &PostedCardView::getPost() const
|
//const RsPostedPost &PostedCardView::getPost() const
|
||||||
{
|
//{
|
||||||
return mPost;
|
// return mPost;
|
||||||
}
|
//}
|
||||||
|
|
||||||
RsPostedPost &PostedCardView::post()
|
//RsPostedPost &PostedCardView::post()
|
||||||
{
|
//{
|
||||||
return mPost;
|
// return mPost;
|
||||||
}
|
//}
|
||||||
|
|
||||||
QString PostedCardView::groupName()
|
QString PostedCardView::groupName()
|
||||||
{
|
{
|
||||||
return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str());
|
return QString::fromUtf8(mGroupMeta.mGroupName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PostedCardView::messageName()
|
QString PostedCardView::messageName()
|
||||||
|
@ -586,11 +574,11 @@ void PostedCardView::doExpand(bool open)
|
||||||
|
|
||||||
void PostedCardView::copyMessageLink()
|
void PostedCardView::copyMessageLink()
|
||||||
{
|
{
|
||||||
if (groupId().isNull() || mMessageId.isNull()) {
|
if (groupId().isNull() || messageId().isNull()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetroShareLink link = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_POSTED, groupId(), mMessageId, messageName());
|
RetroShareLink link = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_POSTED, groupId(), messageId(), messageName());
|
||||||
|
|
||||||
if (link.valid()) {
|
if (link.valid()) {
|
||||||
QList<RetroShareLink> urls;
|
QList<RetroShareLink> urls;
|
||||||
|
|
|
@ -38,22 +38,21 @@ class PostedCardView : public GxsFeedItem
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PostedCardView(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate);
|
PostedCardView(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId& messageId, bool isHome, bool autoUpdate);
|
||||||
PostedCardView(FeedHolder *parent, uint32_t feedId, const RsPostedGroup &group, const RsPostedPost &post, bool isHome, bool autoUpdate);
|
PostedCardView(FeedHolder *parent, uint32_t feedId, const RsGroupMetaData& group_meta, const RsGxsMessageId& post_id, bool isHome, bool autoUpdate);
|
||||||
PostedCardView(FeedHolder *parent, uint32_t feedId, const RsPostedPost &post, bool isHome, bool autoUpdate);
|
|
||||||
virtual ~PostedCardView();
|
virtual ~PostedCardView();
|
||||||
|
|
||||||
bool setGroup(const RsPostedGroup& group, bool doFill = true);
|
|
||||||
bool setPost(const RsPostedPost& post, bool doFill = true);
|
bool setPost(const RsPostedPost& post, bool doFill = true);
|
||||||
|
|
||||||
const RsPostedPost &getPost() const;
|
const RsPostedPost &getPost() const { return mPost; }
|
||||||
RsPostedPost &post();
|
//RsPostedPost& post();
|
||||||
|
|
||||||
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + mMessageId.toStdString()); }
|
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + messageId().toStdString()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
virtual void doExpand(bool open);
|
virtual void doExpand(bool open);
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void loadComments();
|
void loadComments();
|
||||||
|
@ -84,10 +83,10 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mInFill;
|
bool mInFill;
|
||||||
|
bool mLoaded;
|
||||||
|
|
||||||
RsPostedGroup mGroup;
|
RsGroupMetaData mGroupMeta;
|
||||||
RsPostedPost mPost;
|
RsPostedPost mPost;
|
||||||
RsGxsMessageId mMessageId;
|
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::PostedCardView *ui;
|
Ui::PostedCardView *ui;
|
||||||
|
|
|
@ -41,37 +41,27 @@
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
|
|
||||||
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate) :
|
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData &group_meta, const RsGxsMessageId& post_id, bool isHome, bool autoUpdate) :
|
||||||
GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsPosted, autoUpdate)
|
GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, post_id, isHome, rsPosted, autoUpdate),
|
||||||
|
mGroupMeta(group_meta)
|
||||||
{
|
{
|
||||||
setup();
|
mPost.mMeta.mMsgId = post_id;
|
||||||
|
mPost.mMeta.mGroupId = mGroupMeta.mGroupId;
|
||||||
|
|
||||||
requestGroup();
|
mLoaded = false;
|
||||||
requestMessage();
|
|
||||||
requestComment();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedGroup &group, const RsPostedPost &post, bool isHome, bool autoUpdate) :
|
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId& post_id, bool isHome, bool autoUpdate) :
|
||||||
GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsPosted, autoUpdate)
|
GxsFeedItem(feedHolder, feedId, groupId, post_id, isHome, rsPosted, autoUpdate)
|
||||||
{
|
{
|
||||||
|
mPost.mMeta.mMsgId = post_id;
|
||||||
|
|
||||||
|
mLoaded = false;
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
loadGroup();
|
||||||
mMessageId = post.mMeta.mMsgId;
|
|
||||||
|
|
||||||
|
|
||||||
setGroup(group, false);
|
|
||||||
setPost(post);
|
|
||||||
requestComment();
|
|
||||||
}
|
|
||||||
|
|
||||||
PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedPost &post, bool isHome, bool autoUpdate) :
|
|
||||||
GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsPosted, autoUpdate)
|
|
||||||
{
|
|
||||||
setup();
|
|
||||||
|
|
||||||
requestGroup();
|
|
||||||
setPost(post);
|
|
||||||
requestComment();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PostedItem::~PostedItem()
|
PostedItem::~PostedItem()
|
||||||
|
@ -79,6 +69,23 @@ PostedItem::~PostedItem()
|
||||||
delete(ui);
|
delete(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PostedItem::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 ;
|
||||||
|
|
||||||
|
fill();
|
||||||
|
requestMessage();
|
||||||
|
requestComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
GxsFeedItem::paintEvent(e) ;
|
||||||
|
}
|
||||||
|
|
||||||
void PostedItem::setup()
|
void PostedItem::setup()
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
|
@ -137,23 +144,6 @@ void PostedItem::setup()
|
||||||
ui->nameLabel->hide();
|
ui->nameLabel->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PostedItem::setGroup(const RsPostedGroup &group, bool doFill)
|
|
||||||
{
|
|
||||||
if (groupId() != group.mMeta.mGroupId) {
|
|
||||||
std::cerr << "PostedItem::setGroup() - Wrong id, cannot set post";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mGroup = group;
|
|
||||||
|
|
||||||
if (doFill) {
|
|
||||||
fill();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PostedItem::setPost(const RsPostedPost &post, bool doFill)
|
bool PostedItem::setPost(const RsPostedPost &post, bool doFill)
|
||||||
{
|
{
|
||||||
if (groupId() != post.mMeta.mGroupId || messageId() != post.mMeta.mMsgId) {
|
if (groupId() != post.mMeta.mGroupId || messageId() != post.mMeta.mMsgId) {
|
||||||
|
@ -204,7 +194,7 @@ void PostedItem::loadGroup()
|
||||||
* thread, for example to update the data model with new information
|
* thread, for example to update the data model with new information
|
||||||
* after a blocking call to RetroShare API complete */
|
* after a blocking call to RetroShare API complete */
|
||||||
|
|
||||||
setGroup(group);
|
mGroupMeta = group.mMeta;
|
||||||
|
|
||||||
}, this );
|
}, this );
|
||||||
});
|
});
|
||||||
|
@ -303,7 +293,7 @@ void PostedItem::loadComment()
|
||||||
|
|
||||||
void PostedItem::fill()
|
void PostedItem::fill()
|
||||||
{
|
{
|
||||||
RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroup.mMeta.mGroupId, groupName());
|
RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroupMeta.mGroupId, groupName());
|
||||||
ui->nameLabel->setText(link.toHtml());
|
ui->nameLabel->setText(link.toHtml());
|
||||||
|
|
||||||
QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png");
|
QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png");
|
||||||
|
@ -486,19 +476,9 @@ void PostedItem::fill()
|
||||||
emit sizeChanged(this);
|
emit sizeChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const RsPostedPost &PostedItem::getPost() const
|
|
||||||
{
|
|
||||||
return mPost;
|
|
||||||
}
|
|
||||||
|
|
||||||
RsPostedPost &PostedItem::post()
|
|
||||||
{
|
|
||||||
return mPost;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PostedItem::groupName()
|
QString PostedItem::groupName()
|
||||||
{
|
{
|
||||||
return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str());
|
return QString::fromUtf8(mGroupMeta.mGroupName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PostedItem::messageName()
|
QString PostedItem::messageName()
|
||||||
|
@ -619,11 +599,11 @@ void PostedItem::doExpand(bool open)
|
||||||
|
|
||||||
void PostedItem::copyMessageLink()
|
void PostedItem::copyMessageLink()
|
||||||
{
|
{
|
||||||
if (groupId().isNull() || mMessageId.isNull()) {
|
if (groupId().isNull() || messageId().isNull()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetroShareLink link = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_POSTED, groupId(), mMessageId, messageName());
|
RetroShareLink link = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_POSTED, groupId(), messageId(), messageName());
|
||||||
|
|
||||||
if (link.valid()) {
|
if (link.valid()) {
|
||||||
QList<RetroShareLink> urls;
|
QList<RetroShareLink> urls;
|
||||||
|
@ -663,7 +643,7 @@ void PostedItem::viewPicture()
|
||||||
PView->setName(authorID);
|
PView->setName(authorID);
|
||||||
PView->setTime(timestamp);
|
PView->setTime(timestamp);
|
||||||
PView->setGroupId(groupId());
|
PView->setGroupId(groupId());
|
||||||
PView->setMessageId(mMessageId);
|
PView->setMessageId(messageId());
|
||||||
|
|
||||||
PView->show();
|
PView->show();
|
||||||
|
|
||||||
|
|
|
@ -38,21 +38,21 @@ class PostedItem : public GxsFeedItem
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PostedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate);
|
PostedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId& messageId, bool isHome, bool autoUpdate);
|
||||||
PostedItem(FeedHolder *parent, uint32_t feedId, const RsPostedGroup &group, const RsPostedPost &post, bool isHome, bool autoUpdate);
|
PostedItem(FeedHolder *parent, uint32_t feedId, const RsGroupMetaData& group_meta, const RsGxsMessageId& post_id, bool isHome, bool autoUpdate);
|
||||||
PostedItem(FeedHolder *parent, uint32_t feedId, const RsPostedPost &post, bool isHome, bool autoUpdate);
|
|
||||||
virtual ~PostedItem();
|
virtual ~PostedItem();
|
||||||
|
|
||||||
bool setGroup(const RsPostedGroup& group, bool doFill = true);
|
|
||||||
bool setPost(const RsPostedPost& post, bool doFill = true);
|
bool setPost(const RsPostedPost& post, bool doFill = true);
|
||||||
|
|
||||||
const RsPostedPost& getPost() const;
|
const RsPostedPost& getPost() const { return mPost ; }
|
||||||
RsPostedPost &post();
|
RsPostedPost& getPost() { return mPost ; }
|
||||||
|
|
||||||
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + messageId().toStdString()); }
|
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + messageId().toStdString()); }
|
||||||
protected:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
virtual void doExpand(bool open);
|
virtual void doExpand(bool open);
|
||||||
|
virtual void paintEvent(QPaintEvent *) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void loadComments();
|
void loadComments();
|
||||||
|
@ -87,10 +87,10 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mInFill;
|
bool mInFill;
|
||||||
|
bool mLoaded;
|
||||||
|
|
||||||
RsPostedGroup mGroup;
|
RsGroupMetaData mGroupMeta;
|
||||||
RsPostedPost mPost;
|
RsPostedPost mPost;
|
||||||
RsGxsMessageId mMessageId;
|
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::PostedItem *ui;
|
Ui::PostedItem *ui;
|
||||||
|
|
|
@ -481,26 +481,22 @@ void PostedListWidget::insertPostedDetails(const RsPostedGroup &group)
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
|
|
||||||
void PostedListWidget::loadPost(const RsPostedPost &post)
|
void PostedListWidget::loadPost(const RsPostedPost& post)
|
||||||
{
|
{
|
||||||
/* Group is not always available because of the TokenQueue */
|
/* Group is not always available because of the TokenQueue */
|
||||||
RsPostedGroup dummyGroup;
|
|
||||||
dummyGroup.mMeta.mGroupId = groupId();
|
|
||||||
|
|
||||||
PostedItem *item = new PostedItem(this, 0, dummyGroup, post, true, false);
|
PostedItem *item = new PostedItem(this, 0, mGroup.mMeta, post.mMeta.mMsgId, true, false);
|
||||||
connect(item, SIGNAL(vote(RsGxsGrpMsgIdPair,bool)), this, SLOT(submitVote(RsGxsGrpMsgIdPair,bool)));
|
connect(item, SIGNAL(vote(RsGxsGrpMsgIdPair,bool)), this, SLOT(submitVote(RsGxsGrpMsgIdPair,bool)));
|
||||||
mPosts.insert(post.mMeta.mMsgId, item);
|
mPosts.insert(post.mMeta.mMsgId, item);
|
||||||
|
|
||||||
mPostItems.push_back(item);
|
mPostItems.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedListWidget::loadPostCardView(const RsPostedPost &post)
|
void PostedListWidget::loadPostCardView(const RsPostedPost& post)
|
||||||
{
|
{
|
||||||
/* Group is not always available because of the TokenQueue */
|
/* Group is not always available because of the TokenQueue */
|
||||||
RsPostedGroup dummyGroup;
|
|
||||||
dummyGroup.mMeta.mGroupId = groupId();
|
|
||||||
|
|
||||||
PostedCardView *cvitem = new PostedCardView(this, 0, dummyGroup, post, true, false);
|
PostedCardView *cvitem = new PostedCardView(this, 0, mGroup.mMeta, post.mMeta.mMsgId, true, false);
|
||||||
connect(cvitem, SIGNAL(vote(RsGxsGrpMsgIdPair,bool)), this, SLOT(submitVote(RsGxsGrpMsgIdPair,bool)));
|
connect(cvitem, SIGNAL(vote(RsGxsGrpMsgIdPair,bool)), this, SLOT(submitVote(RsGxsGrpMsgIdPair,bool)));
|
||||||
mCVPosts.insert(post.mMeta.mMsgId, cvitem);
|
mCVPosts.insert(post.mMeta.mMsgId, cvitem);
|
||||||
|
|
||||||
|
@ -928,7 +924,7 @@ void PostedListWidget::insertPostedPosts(const std::vector<RsPostedPost>& posts)
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
/* insert new entry */
|
/* insert new entry */
|
||||||
loadPost(p);
|
//loadPost(p);
|
||||||
loadPostCardView(p);
|
loadPostCardView(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -937,7 +933,7 @@ void PostedListWidget::insertPostedPosts(const std::vector<RsPostedPost>& posts)
|
||||||
QMap<RsGxsMessageId, PostedItem*>::iterator pit;
|
QMap<RsGxsMessageId, PostedItem*>::iterator pit;
|
||||||
for(pit = mPosts.begin(); pit != mPosts.end(); ++pit)
|
for(pit = mPosts.begin(); pit != mPosts.end(); ++pit)
|
||||||
{
|
{
|
||||||
(*pit)->post().calculateScores(now);
|
(*pit)->getPost().calculateScores(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
applyRanking();
|
applyRanking();
|
||||||
|
@ -1067,7 +1063,8 @@ bool PostedListWidget::getGroupData(RsGxsGenericGroupData*& data)
|
||||||
if(! rsPosted->getBoardsInfo(std::list<RsGxsGroupId>({groupId()}),groupInfo) || groupInfo.size() != 1)
|
if(! rsPosted->getBoardsInfo(std::list<RsGxsGroupId>({groupId()}),groupInfo) || groupInfo.size() != 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
data = new RsPostedGroup(groupInfo[0]);
|
mGroup = groupInfo[0];
|
||||||
|
data = new RsPostedGroup(mGroup);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
|
#include "retroshare/rsposted.h"
|
||||||
#include "gui/gxs/GxsMessageFramePostWidget.h"
|
#include "gui/gxs/GxsMessageFramePostWidget.h"
|
||||||
#include "gui/feeds/FeedHolder.h"
|
#include "gui/feeds/FeedHolder.h"
|
||||||
|
|
||||||
|
@ -127,6 +128,7 @@ private:
|
||||||
|
|
||||||
uint32_t mTokenTypeVote;
|
uint32_t mTokenTypeVote;
|
||||||
|
|
||||||
|
RsPostedGroup mGroup;
|
||||||
QMap<RsGxsMessageId, PostedItem*> mPosts;
|
QMap<RsGxsMessageId, PostedItem*> mPosts;
|
||||||
QList<PostedItem*> mPostItems;
|
QList<PostedItem*> mPostItems;
|
||||||
|
|
||||||
|
|
|
@ -95,23 +95,23 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId,
|
||||||
// mPost = post ;
|
// mPost = post ;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void GxsChannelPostItem::init(const RsGxsMessageId& messageId,const std::set<RsGxsMessageId>& older_versions)
|
// void GxsChannelPostItem::init(const RsGxsMessageId& messageId,const std::set<RsGxsMessageId>& older_versions)
|
||||||
{
|
// {
|
||||||
QVector<RsGxsMessageId> v;
|
// QVector<RsGxsMessageId> v;
|
||||||
//bool self = false;
|
// //bool self = false;
|
||||||
|
//
|
||||||
for(std::set<RsGxsMessageId>::const_iterator it(older_versions.begin());it!=older_versions.end();++it)
|
// for(std::set<RsGxsMessageId>::const_iterator it(older_versions.begin());it!=older_versions.end();++it)
|
||||||
v.push_back(*it) ;
|
// v.push_back(*it) ;
|
||||||
|
//
|
||||||
if(older_versions.find(messageId) == older_versions.end())
|
// if(older_versions.find(messageId) == older_versions.end())
|
||||||
v.push_back(messageId);
|
// v.push_back(messageId);
|
||||||
|
//
|
||||||
setMessageVersions(v) ;
|
// setMessageVersions(v) ;
|
||||||
|
//
|
||||||
setup();
|
// setup();
|
||||||
|
//
|
||||||
mLoaded = false ;
|
// mLoaded = false ;
|
||||||
}
|
// }
|
||||||
|
|
||||||
void GxsChannelPostItem::paintEvent(QPaintEvent *e)
|
void GxsChannelPostItem::paintEvent(QPaintEvent *e)
|
||||||
{
|
{
|
||||||
|
@ -267,6 +267,45 @@ void GxsChannelPostItem::loadComments()
|
||||||
comments(title);
|
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<RsGxsChannelGroup> groups;
|
||||||
|
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
mGroupMeta = group.mMeta;
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
});
|
||||||
|
}
|
||||||
void GxsChannelPostItem::loadMessage()
|
void GxsChannelPostItem::loadMessage()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ITEM
|
#ifdef DEBUG_ITEM
|
||||||
|
@ -834,42 +873,4 @@ void GxsChannelPostItem::makeUpVote()
|
||||||
emit vote(msgId, true);
|
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<RsGxsChannelGroup> groups;
|
|
||||||
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 */
|
|
||||||
|
|
||||||
mGroupMeta = group.mMeta;
|
|
||||||
|
|
||||||
}, this );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
|
@ -49,17 +49,12 @@ public:
|
||||||
|
|
||||||
GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set<RsGxsMessageId>& older_versions = std::set<RsGxsMessageId>());
|
GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set<RsGxsMessageId>& older_versions = std::set<RsGxsMessageId>());
|
||||||
|
|
||||||
// // 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<RsGxsMessageId>& older_versions = std::set<RsGxsMessageId>());
|
|
||||||
|
|
||||||
virtual ~GxsChannelPostItem();
|
virtual ~GxsChannelPostItem();
|
||||||
|
|
||||||
uint64_t uniqueIdentifier() const override { return hash_64bits("GxsChannelPostItem " + messageId().toStdString()) ; }
|
uint64_t uniqueIdentifier() const override { return hash_64bits("GxsChannelPostItem " + messageId().toStdString()) ; }
|
||||||
|
|
||||||
bool setGroup(const RsGxsChannelGroup &group, bool doFill = true);
|
bool setGroup(const RsGxsChannelGroup& group, bool doFill = true);
|
||||||
bool setPost(const RsGxsChannelPost &post, bool doFill = true);
|
bool setPost(const RsGxsChannelPost& post, bool doFill = true);
|
||||||
|
|
||||||
void setFileCleanUpWarning(uint32_t time_left);
|
void setFileCleanUpWarning(uint32_t time_left);
|
||||||
|
|
||||||
|
@ -72,7 +67,7 @@ public:
|
||||||
|
|
||||||
static uint64_t computeIdentifier(const RsGxsMessageId& msgid) { return hash64("GxsChannelPostItem " + msgid.toStdString()) ; }
|
static uint64_t computeIdentifier(const RsGxsMessageId& msgid) { return hash64("GxsChannelPostItem " + msgid.toStdString()) ; }
|
||||||
protected:
|
protected:
|
||||||
void init(const RsGxsMessageId& messageId,const std::set<RsGxsMessageId>& older_versions);
|
//void init(const RsGxsMessageId& messageId,const std::set<RsGxsMessageId>& older_versions);
|
||||||
|
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
virtual void doExpand(bool open);
|
virtual void doExpand(bool open);
|
||||||
|
@ -81,7 +76,7 @@ protected:
|
||||||
// This does nothing except triggering the loading of the post data and comments. This function is mainly used to detect
|
// 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.
|
// when the post is actually made visible.
|
||||||
|
|
||||||
virtual void paintEvent(QPaintEvent *);
|
virtual void paintEvent(QPaintEvent *) override;
|
||||||
|
|
||||||
/* GxsGroupFeedItem */
|
/* GxsGroupFeedItem */
|
||||||
virtual QString groupName();
|
virtual QString groupName();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue