mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #2788 from csoler/v0.6-BugFixing_30
attempt to fix bug in closing GxsChannelComment feed item
This commit is contained in:
commit
6c22125980
@ -299,7 +299,7 @@ void NewsFeed::handleChannelEvent(std::shared_ptr<const RsEvent> event)
|
|||||||
addFeedItem(new GxsChannelPostItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId, false, true));
|
addFeedItem(new GxsChannelPostItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId, false, true));
|
||||||
break;
|
break;
|
||||||
case RsChannelEventCode::NEW_COMMENT:
|
case RsChannelEventCode::NEW_COMMENT:
|
||||||
addFeedItem(new ChannelsCommentsItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId, false, true));
|
addFeedItem(new ChannelsCommentsItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId,pe->mChannelThreadId, false, true));
|
||||||
break;
|
break;
|
||||||
case RsChannelEventCode::RECEIVED_PUBLISH_KEY:
|
case RsChannelEventCode::RECEIVED_PUBLISH_KEY:
|
||||||
addFeedItem(new GxsChannelGroupItem(this, NEWSFEED_CHANNELPUBKEYLIST, pe->mChannelGroupId, false, true));
|
addFeedItem(new GxsChannelGroupItem(this, NEWSFEED_CHANNELPUBKEYLIST, pe->mChannelGroupId, false, true));
|
||||||
|
@ -49,46 +49,41 @@
|
|||||||
* #define DEBUG_ITEM 1
|
* #define DEBUG_ITEM 1
|
||||||
****/
|
****/
|
||||||
|
|
||||||
ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group_meta, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set<RsGxsMessageId>& older_versions) :
|
// ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group_meta, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set<RsGxsMessageId>& older_versions) :
|
||||||
GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate),
|
// GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate),
|
||||||
mGroupMeta(group_meta)
|
// mGroupMeta(group_meta)
|
||||||
|
// {
|
||||||
|
// mLoadingGroup = false;
|
||||||
|
// mLoadingMessage = false;
|
||||||
|
// mLoadingComment = false;
|
||||||
|
//
|
||||||
|
// mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded
|
||||||
|
// mPost.mMeta.mGroupId = mGroupMeta.mGroupId;
|
||||||
|
//
|
||||||
|
// 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();
|
||||||
|
//
|
||||||
|
// // no call to loadGroup() here because we have it already.
|
||||||
|
// }
|
||||||
|
|
||||||
|
ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &commentId, const RsGxsMessageId &threadId, bool isHome, bool autoUpdate) :
|
||||||
|
GxsFeedItem(feedHolder, feedId, groupId, commentId, isHome, rsGxsChannels, autoUpdate), // this one should be in GxsFeedItem
|
||||||
|
mThreadId(threadId)
|
||||||
{
|
{
|
||||||
mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded
|
mLoading= false;
|
||||||
mPost.mMeta.mGroupId = mGroupMeta.mGroupId;
|
|
||||||
|
|
||||||
QVector<RsGxsMessageId> v;
|
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();
|
||||||
|
|
||||||
// no call to loadGroup() here because we have it already.
|
|
||||||
}
|
|
||||||
|
|
||||||
ChannelsCommentsItem::ChannelsCommentsItem(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) // this one should be in GxsFeedItem
|
|
||||||
{
|
|
||||||
mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
loadGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelsCommentsItem::paintEvent(QPaintEvent *e)
|
void ChannelsCommentsItem::paintEvent(QPaintEvent *e)
|
||||||
@ -99,14 +94,7 @@ void ChannelsCommentsItem::paintEvent(QPaintEvent *e)
|
|||||||
if(!mLoaded)
|
if(!mLoaded)
|
||||||
{
|
{
|
||||||
mLoaded = true ;
|
mLoaded = true ;
|
||||||
|
load();
|
||||||
std::set<RsGxsMessageId> older_versions; // not so nice. We need to use std::set everywhere
|
|
||||||
for(auto& m:messageVersions())
|
|
||||||
older_versions.insert(m);
|
|
||||||
|
|
||||||
fill();
|
|
||||||
requestMessage();
|
|
||||||
requestComment();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsFeedItem::paintEvent(e) ;
|
GxsFeedItem::paintEvent(e) ;
|
||||||
@ -114,6 +102,14 @@ void ChannelsCommentsItem::paintEvent(QPaintEvent *e)
|
|||||||
|
|
||||||
ChannelsCommentsItem::~ChannelsCommentsItem()
|
ChannelsCommentsItem::~ChannelsCommentsItem()
|
||||||
{
|
{
|
||||||
|
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300);
|
||||||
|
|
||||||
|
while( mLoading && std::chrono::steady_clock::now() < timeout )
|
||||||
|
{
|
||||||
|
RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for data to load " << std::endl;
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
}
|
||||||
|
|
||||||
delete(ui);
|
delete(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,20 +180,18 @@ void ChannelsCommentsItem::setup()
|
|||||||
|
|
||||||
bool ChannelsCommentsItem::setPost(const RsGxsChannelPost& post, bool doFill)
|
bool ChannelsCommentsItem::setPost(const RsGxsChannelPost& post, bool doFill)
|
||||||
{
|
{
|
||||||
if (groupId() != post.mMeta.mGroupId || messageId() != post.mMeta.mMsgId) {
|
|
||||||
std::cerr << "ChannelsCommentsItem::setPost() - Wrong id, cannot set post";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mPost = post;
|
mPost = post;
|
||||||
|
|
||||||
if (doFill) {
|
if (doFill)
|
||||||
fill();
|
fill();
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool ChannelsCommentsItem::setMissingPost()
|
||||||
|
{
|
||||||
|
fill(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QString ChannelsCommentsItem::getTitleLabel()
|
QString ChannelsCommentsItem::getTitleLabel()
|
||||||
{
|
{
|
||||||
@ -230,14 +224,68 @@ void ChannelsCommentsItem::loadComments()
|
|||||||
|
|
||||||
void ChannelsCommentsItem::loadGroup()
|
void ChannelsCommentsItem::loadGroup()
|
||||||
{
|
{
|
||||||
|
//#ifdef DEBUG_ITEM
|
||||||
|
// std::cerr << "GxsChannelGroupItem::loadGroup()";
|
||||||
|
// std::cerr << std::endl;
|
||||||
|
//#endif
|
||||||
|
// if(mLoading)
|
||||||
|
// return;
|
||||||
|
//
|
||||||
|
// mLoading= true;
|
||||||
|
//
|
||||||
|
// std::cerr << "Loading group" << std::endl;
|
||||||
|
// 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;
|
||||||
|
// mLoading= false;
|
||||||
|
//
|
||||||
|
// std::cerr << "End loading group" << std::endl;
|
||||||
|
// }, this );
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
void ChannelsCommentsItem::load()
|
||||||
|
{
|
||||||
|
// This function loads everything that's needed:
|
||||||
|
// - the comment text
|
||||||
|
// - the comment parent message
|
||||||
|
|
||||||
#ifdef DEBUG_ITEM
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsChannelGroupItem::loadGroup()";
|
std::cerr << "ChannelsCommentsItem::loadMessage()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
if(mLoading)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mLoading= true;
|
||||||
|
|
||||||
RsThread::async([this]()
|
RsThread::async([this]()
|
||||||
{
|
{
|
||||||
// 1 - get group data
|
// 1 - get group meta data
|
||||||
|
|
||||||
std::vector<RsGxsChannelGroup> groups;
|
std::vector<RsGxsChannelGroup> groups;
|
||||||
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||||
@ -250,13 +298,26 @@ void ChannelsCommentsItem::loadGroup()
|
|||||||
|
|
||||||
if (groups.size() != 1)
|
if (groups.size() != 1)
|
||||||
{
|
{
|
||||||
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
|
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items" << std::endl;
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RsGxsChannelGroup group(groups[0]);
|
RsGxsChannelGroup group(groups[0]);
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [group,this]()
|
// 2 - get message and comment data
|
||||||
|
|
||||||
|
std::vector<RsGxsChannelPost> posts;
|
||||||
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
|
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId(),mThreadId } ),posts,comments,votes))
|
||||||
|
{
|
||||||
|
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now that everything is in place, update the UI
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [group,posts,comments,this]()
|
||||||
{
|
{
|
||||||
/* Here it goes any code you want to be executed on the Qt Gui
|
/* 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
|
* thread, for example to update the data model with new information
|
||||||
@ -264,52 +325,14 @@ void ChannelsCommentsItem::loadGroup()
|
|||||||
|
|
||||||
mGroupMeta = group.mMeta;
|
mGroupMeta = group.mMeta;
|
||||||
|
|
||||||
}, this );
|
if(comments.size()==1)
|
||||||
});
|
|
||||||
}
|
|
||||||
void ChannelsCommentsItem::loadMessage()
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_ITEM
|
|
||||||
std::cerr << "ChannelsCommentsItem::loadMessage()";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
RsThread::async([this]()
|
|
||||||
{
|
|
||||||
// 1 - get group data
|
|
||||||
|
|
||||||
std::vector<RsGxsChannelPost> posts;
|
|
||||||
std::vector<RsGxsComment> comments;
|
|
||||||
std::vector<RsGxsVote> votes;
|
|
||||||
|
|
||||||
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments,votes))
|
|
||||||
{
|
|
||||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (posts.size() == 1)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_ITEM
|
|
||||||
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
|
||||||
#endif
|
|
||||||
RsGxsChannelPost post(posts[0]); // no reference to temporary here, because we pass this to a thread
|
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
|
|
||||||
}
|
|
||||||
else if(comments.size() == 1)
|
|
||||||
{
|
{
|
||||||
RsGxsComment cmt(comments[0]);
|
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]()
|
|
||||||
{
|
|
||||||
uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height())
|
uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height())
|
||||||
/ QFontMetricsF(ui->subjectLabel->font()).height());
|
/ QFontMetricsF(ui->subjectLabel->font()).height());
|
||||||
|
|
||||||
ui->commLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(cmt.mComment.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_LINKS));
|
ui->commLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(cmt.mComment.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||||
|
|
||||||
ui->nameLabel->setId(cmt.mMeta.mAuthorId);
|
ui->nameLabel->setId(cmt.mMeta.mAuthorId);
|
||||||
ui->datetimeLabel->setText(DateTime::formatLongDateTime(cmt.mMeta.mPublishTs));
|
ui->datetimeLabel->setText(DateTime::formatLongDateTime(cmt.mMeta.mPublishTs));
|
||||||
|
|
||||||
@ -321,77 +344,28 @@ void ChannelsCommentsItem::loadMessage()
|
|||||||
pixmap = GxsIdDetails::makeDefaultIcon(cmt.mMeta.mAuthorId,GxsIdDetails::LARGE);
|
pixmap = GxsIdDetails::makeDefaultIcon(cmt.mMeta.mAuthorId,GxsIdDetails::LARGE);
|
||||||
ui->avatarLabel->setPixmap(pixmap);
|
ui->avatarLabel->setPixmap(pixmap);
|
||||||
|
|
||||||
//Change this item to be uploaded with thread element.
|
//Change this item to be uploaded with thread element. This is really bad practice.
|
||||||
setMessageId(cmt.mMeta.mThreadId);
|
|
||||||
requestMessage();
|
|
||||||
|
|
||||||
}, this );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ITEM
|
mLoading=false;
|
||||||
std::cerr << "ChannelsCommentsItem::loadMessage() Wrong number of Items. Remove It.";
|
removeItem();
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
if (posts.size() == 1)
|
||||||
|
setPost(posts[0]);
|
||||||
|
else
|
||||||
|
setMissingPost();
|
||||||
|
|
||||||
emit sizeChanged(this);
|
emit sizeChanged(this);
|
||||||
}
|
mLoading=false;
|
||||||
|
|
||||||
void ChannelsCommentsItem::loadComment()
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_ITEM
|
|
||||||
std::cerr << "ChannelsCommentsItem::loadComment()";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RsThread::async([this]()
|
|
||||||
{
|
|
||||||
// 1 - get group data
|
|
||||||
|
|
||||||
std::set<RsGxsMessageId> msgIds;
|
|
||||||
|
|
||||||
for(auto MsgId: messageVersions())
|
|
||||||
msgIds.insert(MsgId);
|
|
||||||
|
|
||||||
std::vector<RsGxsChannelPost> posts;
|
|
||||||
std::vector<RsGxsComment> comments;
|
|
||||||
|
|
||||||
if(! rsGxsChannels->getChannelComments( groupId(),msgIds,comments))
|
|
||||||
{
|
|
||||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int comNb = comments.size();
|
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [comNb]()
|
|
||||||
{
|
|
||||||
QString sComButText = tr("Comment");
|
|
||||||
if (comNb == 1)
|
|
||||||
sComButText = sComButText.append("(1)");
|
|
||||||
else if(comNb > 1)
|
|
||||||
sComButText = tr("Comments ").append("(%1)").arg(comNb);
|
|
||||||
|
|
||||||
//ui->commentButton->setText(sComButText);
|
|
||||||
|
|
||||||
}, this );
|
}, this );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelsCommentsItem::fill()
|
void ChannelsCommentsItem::fill(bool missing_post)
|
||||||
{
|
{
|
||||||
/* fill in */
|
|
||||||
|
|
||||||
// if (isLoading()) {
|
|
||||||
// /* Wait for all requests */
|
|
||||||
//return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
#ifdef DEBUG_ITEM
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "ChannelsCommentsItem::fill()";
|
std::cerr << "ChannelsCommentsItem::fill()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -399,9 +373,6 @@ void ChannelsCommentsItem::fill()
|
|||||||
|
|
||||||
mInFill = true;
|
mInFill = true;
|
||||||
|
|
||||||
//QString title;
|
|
||||||
//float f = QFontMetricsF(font()).height()/14.0 ;
|
|
||||||
|
|
||||||
if (!mIsHome)
|
if (!mIsHome)
|
||||||
{
|
{
|
||||||
if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) {
|
if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) {
|
||||||
@ -413,18 +384,13 @@ void ChannelsCommentsItem::fill()
|
|||||||
//ui->titleLabel->setText(title);
|
//ui->titleLabel->setText(title);
|
||||||
|
|
||||||
RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName());
|
RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName());
|
||||||
|
|
||||||
|
if(missing_post)
|
||||||
|
ui->subjectLabel->setText("[" + QObject::tr("Missing channel post")+"]");
|
||||||
|
else
|
||||||
ui->subjectLabel->setText(msgLink.toHtml());
|
ui->subjectLabel->setText(msgLink.toHtml());
|
||||||
|
|
||||||
if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags))
|
|
||||||
{
|
|
||||||
//ui->unsubscribeButton->setEnabled(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//ui->unsubscribeButton->setEnabled(false);
|
|
||||||
}
|
|
||||||
ui->readButton->hide();
|
ui->readButton->hide();
|
||||||
//ui->titleLabel->hide();
|
|
||||||
|
|
||||||
if (IS_MSG_NEW(mPost.mMeta.mMsgStatus)) {
|
if (IS_MSG_NEW(mPost.mMeta.mMsgStatus)) {
|
||||||
mCloseOnRead = true;
|
mCloseOnRead = true;
|
||||||
@ -432,20 +398,11 @@ void ChannelsCommentsItem::fill()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* subject */
|
if(missing_post)
|
||||||
//ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str()));
|
ui->subjectLabel->setText("[" + QObject::tr("Missing channel post")+"]");
|
||||||
|
else
|
||||||
//uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->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()), autorized_lines), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
|
||||||
|
|
||||||
ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ;
|
ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ;
|
||||||
|
|
||||||
//QString score = QString::number(post.mTopScore);
|
|
||||||
// scoreLabel->setText(score);
|
|
||||||
|
|
||||||
/* disable buttons: deletion facility not enabled with cache services yet */
|
/* disable buttons: deletion facility not enabled with cache services yet */
|
||||||
ui->clearButton->setEnabled(false);
|
ui->clearButton->setEnabled(false);
|
||||||
ui->clearButton->hide();
|
ui->clearButton->hide();
|
||||||
@ -467,50 +424,9 @@ void ChannelsCommentsItem::fill()
|
|||||||
mCloseOnRead = false;
|
mCloseOnRead = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// differences between Feed or Top of Comment.
|
|
||||||
if (mFeedHolder)
|
|
||||||
{
|
|
||||||
//ui->commentButton->show();
|
|
||||||
|
|
||||||
// Not yet functional
|
|
||||||
/*if (mPost.mCommentCount)
|
|
||||||
{
|
|
||||||
QString commentText = QString::number(mPost.mCommentCount);
|
|
||||||
commentText += " ";
|
|
||||||
commentText += tr("Comments");
|
|
||||||
ui->commentButton->setText(commentText);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->commentButton->setText(tr("Comment"));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//ui->commentButton->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
// disable voting buttons - if they have already voted.
|
|
||||||
/*if (post.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK)
|
|
||||||
{
|
|
||||||
voteUpButton->setEnabled(false);
|
|
||||||
voteDownButton->setEnabled(false);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (wasExpanded() || ui->expandFrame->isVisible()) {
|
|
||||||
fillExpandFrame();
|
|
||||||
}
|
|
||||||
|
|
||||||
mInFill = false;
|
mInFill = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelsCommentsItem::fillExpandFrame()
|
|
||||||
{
|
|
||||||
//ui->msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ChannelsCommentsItem::messageName()
|
QString ChannelsCommentsItem::messageName()
|
||||||
{
|
{
|
||||||
return QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
|
return QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
|
||||||
@ -574,10 +490,6 @@ void ChannelsCommentsItem::doExpand(bool open)
|
|||||||
void ChannelsCommentsItem::expandFill(bool first)
|
void ChannelsCommentsItem::expandFill(bool first)
|
||||||
{
|
{
|
||||||
GxsFeedItem::expandFill(first);
|
GxsFeedItem::expandFill(first);
|
||||||
|
|
||||||
if (first) {
|
|
||||||
fillExpandFrame();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelsCommentsItem::toggle()
|
void ChannelsCommentsItem::toggle()
|
||||||
|
@ -42,12 +42,17 @@ 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
|
// 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.
|
// previous posts should be supplied. It's optional. If not supplied only the comments of the new version will be displayed.
|
||||||
|
|
||||||
ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set<RsGxsMessageId>& older_versions = std::set<RsGxsMessageId>());
|
ChannelsCommentsItem(FeedHolder *feedHolder,
|
||||||
|
uint32_t feedId,
|
||||||
|
const RsGxsGroupId& groupId,
|
||||||
|
const RsGxsMessageId& commentId,
|
||||||
|
const RsGxsMessageId& threadId,
|
||||||
|
bool isHome,
|
||||||
|
bool autoUpdate);
|
||||||
|
|
||||||
// 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
|
// 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.
|
// GxsChannelsPostsWidget and pass it to created items.
|
||||||
|
// ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set<RsGxsMessageId>& older_versions = std::set<RsGxsMessageId>());
|
||||||
ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set<RsGxsMessageId>& older_versions = std::set<RsGxsMessageId>());
|
|
||||||
|
|
||||||
virtual ~ChannelsCommentsItem();
|
virtual ~ChannelsCommentsItem();
|
||||||
|
|
||||||
@ -55,6 +60,7 @@ public:
|
|||||||
|
|
||||||
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);
|
||||||
|
bool setMissingPost();
|
||||||
|
|
||||||
QString getTitleLabel();
|
QString getTitleLabel();
|
||||||
QString getMsgLabel();
|
QString getMsgLabel();
|
||||||
@ -85,8 +91,8 @@ protected:
|
|||||||
|
|
||||||
/* GxsFeedItem */
|
/* GxsFeedItem */
|
||||||
virtual QString messageName();
|
virtual QString messageName();
|
||||||
virtual void loadMessage();
|
virtual void loadMessage() override {}
|
||||||
virtual void loadComment();
|
virtual void loadComment() override {}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/* default stuff */
|
/* default stuff */
|
||||||
@ -104,17 +110,20 @@ signals:
|
|||||||
void vote(const RsGxsGrpMsgIdPair& msgId, bool up);
|
void vote(const RsGxsGrpMsgIdPair& msgId, bool up);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void load();
|
||||||
void setup();
|
void setup();
|
||||||
void fill();
|
void fill(bool missing_post=false);
|
||||||
void fillExpandFrame();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mInFill;
|
bool mInFill;
|
||||||
bool mCloseOnRead;
|
bool mCloseOnRead;
|
||||||
bool mLoaded;
|
bool mLoaded;
|
||||||
|
|
||||||
|
bool mLoading;
|
||||||
|
|
||||||
RsGroupMetaData mGroupMeta;
|
RsGroupMetaData mGroupMeta;
|
||||||
RsGxsChannelPost mPost;
|
RsGxsChannelPost mPost;
|
||||||
|
RsGxsMessageId mThreadId;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::ChannelsCommentsItem *ui;
|
Ui::ChannelsCommentsItem *ui;
|
||||||
|
Loading…
Reference in New Issue
Block a user