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,21 +94,22 @@ 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) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,21 +178,19 @@ void ChannelsCommentsItem::setup()
|
|||||||
ui->expandFrame->hide();
|
ui->expandFrame->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
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,168 +224,148 @@ void ChannelsCommentsItem::loadComments()
|
|||||||
|
|
||||||
void ChannelsCommentsItem::loadGroup()
|
void ChannelsCommentsItem::loadGroup()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ITEM
|
//#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsChannelGroupItem::loadGroup()";
|
// std::cerr << "GxsChannelGroupItem::loadGroup()";
|
||||||
std::cerr << std::endl;
|
// std::cerr << std::endl;
|
||||||
#endif
|
//#endif
|
||||||
|
// if(mLoading)
|
||||||
RsThread::async([this]()
|
// return;
|
||||||
{
|
//
|
||||||
// 1 - get group data
|
// mLoading= true;
|
||||||
|
//
|
||||||
std::vector<RsGxsChannelGroup> groups;
|
// std::cerr << "Loading group" << std::endl;
|
||||||
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
// RsThread::async([this]()
|
||||||
|
// {
|
||||||
if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group
|
// // 1 - get group data
|
||||||
{
|
//
|
||||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
// std::vector<RsGxsChannelGroup> groups;
|
||||||
return;
|
// const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||||
}
|
//
|
||||||
|
// if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group
|
||||||
if (groups.size() != 1)
|
// {
|
||||||
{
|
// RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
|
// return;
|
||||||
std::cerr << std::endl;
|
// }
|
||||||
return;
|
//
|
||||||
}
|
// if (groups.size() != 1)
|
||||||
RsGxsChannelGroup group(groups[0]);
|
// {
|
||||||
|
// std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
|
||||||
RsQThreadUtils::postToObject( [group,this]()
|
// std::cerr << std::endl;
|
||||||
{
|
// return;
|
||||||
/* 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
|
// RsGxsChannelGroup group(groups[0]);
|
||||||
* after a blocking call to RetroShare API complete */
|
//
|
||||||
|
// RsQThreadUtils::postToObject( [group,this]()
|
||||||
mGroupMeta = group.mMeta;
|
// {
|
||||||
|
// /* Here it goes any code you want to be executed on the Qt Gui
|
||||||
}, this );
|
// * 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::loadMessage()
|
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 << "ChannelsCommentsItem::loadMessage()";
|
std::cerr << "ChannelsCommentsItem::loadMessage()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
RsThread::async([this]()
|
if(mLoading)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mLoading= true;
|
||||||
|
|
||||||
|
RsThread::async([this]()
|
||||||
{
|
{
|
||||||
// 1 - get group data
|
// 1 - get group meta 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::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
RsGxsChannelGroup group(groups[0]);
|
||||||
|
|
||||||
|
// 2 - get message and comment data
|
||||||
|
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsChannelPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
std::vector<RsGxsVote> votes;
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments,votes))
|
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId(),mThreadId } ),posts,comments,votes))
|
||||||
{
|
{
|
||||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (posts.size() == 1)
|
// now that everything is in place, update the UI
|
||||||
{
|
|
||||||
#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 );
|
RsQThreadUtils::postToObject( [group,posts,comments,this]()
|
||||||
}
|
{
|
||||||
else if(comments.size() == 1)
|
/* 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
|
||||||
RsGxsComment cmt(comments[0]);
|
* after a blocking call to RetroShare API complete */
|
||||||
#ifdef DEBUG_ITEM
|
|
||||||
std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [cmt,this]()
|
mGroupMeta = group.mMeta;
|
||||||
{
|
|
||||||
uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().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));
|
if(comments.size()==1)
|
||||||
|
{
|
||||||
|
RsGxsComment cmt(comments[0]);
|
||||||
|
|
||||||
ui->nameLabel->setId(cmt.mMeta.mAuthorId);
|
uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height())
|
||||||
ui->datetimeLabel->setText(DateTime::formatLongDateTime(cmt.mMeta.mPublishTs));
|
/ QFontMetricsF(ui->subjectLabel->font()).height());
|
||||||
|
|
||||||
RsIdentityDetails idDetails ;
|
ui->commLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(cmt.mComment.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||||
rsIdentity->getIdDetails(cmt.mMeta.mAuthorId,idDetails);
|
ui->nameLabel->setId(cmt.mMeta.mAuthorId);
|
||||||
QPixmap pixmap ;
|
ui->datetimeLabel->setText(DateTime::formatLongDateTime(cmt.mMeta.mPublishTs));
|
||||||
|
|
||||||
if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL))
|
RsIdentityDetails idDetails ;
|
||||||
pixmap = GxsIdDetails::makeDefaultIcon(cmt.mMeta.mAuthorId,GxsIdDetails::LARGE);
|
rsIdentity->getIdDetails(cmt.mMeta.mAuthorId,idDetails);
|
||||||
ui->avatarLabel->setPixmap(pixmap);
|
QPixmap pixmap ;
|
||||||
|
|
||||||
//Change this item to be uploaded with thread element.
|
if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL))
|
||||||
setMessageId(cmt.mMeta.mThreadId);
|
pixmap = GxsIdDetails::makeDefaultIcon(cmt.mMeta.mAuthorId,GxsIdDetails::LARGE);
|
||||||
requestMessage();
|
ui->avatarLabel->setPixmap(pixmap);
|
||||||
|
|
||||||
}, this );
|
//Change this item to be uploaded with thread element. This is really bad practice.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mLoading=false;
|
||||||
|
removeItem();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
if (posts.size() == 1)
|
||||||
else
|
setPost(posts[0]);
|
||||||
{
|
else
|
||||||
#ifdef DEBUG_ITEM
|
setMissingPost();
|
||||||
std::cerr << "ChannelsCommentsItem::loadMessage() Wrong number of Items. Remove It.";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
|
emit sizeChanged(this);
|
||||||
}
|
mLoading=false;
|
||||||
});
|
|
||||||
|
}, this );
|
||||||
emit sizeChanged(this);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelsCommentsItem::loadComment()
|
void ChannelsCommentsItem::fill(bool missing_post)
|
||||||
{
|
{
|
||||||
#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 );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChannelsCommentsItem::fill()
|
|
||||||
{
|
|
||||||
/* 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)) {
|
||||||
@ -412,19 +383,14 @@ void ChannelsCommentsItem::fill()
|
|||||||
//title += link.toHtml();
|
//title += link.toHtml();
|
||||||
//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());
|
||||||
ui->subjectLabel->setText(msgLink.toHtml());
|
|
||||||
|
if(missing_post)
|
||||||
|
ui->subjectLabel->setText("[" + QObject::tr("Missing channel post")+"]");
|
||||||
|
else
|
||||||
|
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,19 +398,10 @@ 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())
|
ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ;
|
||||||
// / 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)) ;
|
|
||||||
|
|
||||||
//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);
|
||||||
@ -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 setup();
|
void load();
|
||||||
void fill();
|
void setup();
|
||||||
void fillExpandFrame();
|
void fill(bool missing_post=false);
|
||||||
|
|
||||||
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