mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
commit
566399440c
@ -302,17 +302,17 @@ bool p3Posted::createPost(uint32_t &token, RsPostedPost &msg)
|
||||
|
||||
bool p3Posted::getBoardsInfo(
|
||||
const std::list<RsGxsGroupId>& boardsIds,
|
||||
std::vector<RsPostedGroup>& channelsInfo )
|
||||
std::vector<RsPostedGroup>& groupsInfo )
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
if( !requestGroupInfo(token, opts, boardsIds)
|
||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
return getGroupData(token, channelsInfo) && !channelsInfo.empty();
|
||||
return getGroupData(token, groupsInfo) && !groupsInfo.empty();
|
||||
}
|
||||
|
||||
bool p3Posted::getBoardContent( const RsGxsGroupId& channelId,
|
||||
bool p3Posted::getBoardContent( const RsGxsGroupId& groupId,
|
||||
const std::set<RsGxsMessageId>& contentsIds,
|
||||
std::vector<RsPostedPost>& posts,
|
||||
std::vector<RsGxsComment>& comments )
|
||||
@ -322,7 +322,7 @@ bool p3Posted::getBoardContent( const RsGxsGroupId& channelId,
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
msgIds[channelId] = contentsIds;
|
||||
msgIds[groupId] = contentsIds;
|
||||
|
||||
if( !requestMsgInfo(token, opts, msgIds) ||
|
||||
waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
|
@ -58,12 +58,10 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
|
||||
return RsGxsIfaceHelper::receiveChanges(changes);
|
||||
}
|
||||
|
||||
bool getBoardsInfo(
|
||||
const std::list<RsGxsGroupId>& boardsIds,
|
||||
std::vector<RsPostedGroup>& channelsInfo ) override;
|
||||
bool getBoardsInfo(const std::list<RsGxsGroupId>& boardsIds,
|
||||
std::vector<RsPostedGroup>& groupsInfo ) override;
|
||||
|
||||
bool getBoardContent(
|
||||
const RsGxsGroupId& boardId,
|
||||
bool getBoardContent(const RsGxsGroupId& groupId,
|
||||
const std::set<RsGxsMessageId>& contentsIds,
|
||||
std::vector<RsPostedPost>& posts,
|
||||
std::vector<RsGxsComment>& comments ) override;
|
||||
|
@ -484,46 +484,6 @@ void IdDialog::updateCirclesDisplay()
|
||||
/************************** Request / Response *************************/
|
||||
/*** Loading Main Index ***/
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void IdDialog::requestCircleGroupMeta()
|
||||
{
|
||||
mStateHelper->setLoading(CIRCLESDIALOG_GROUPMETA, true);
|
||||
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << "CirclesDialog::requestGroupMeta()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mCircleQueue->cancelActiveRequestTokens(CIRCLESDIALOG_GROUPMETA);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
|
||||
uint32_t token;
|
||||
mCircleQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, CIRCLESDIALOG_GROUPMETA);
|
||||
}
|
||||
void IdDialog::requestCircleGroupData(const RsGxsCircleId& circle_id)
|
||||
{
|
||||
mStateHelper->setLoading(CIRCLESDIALOG_GROUPDATA, true);
|
||||
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << "CirclesDialog::requestGroupData()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mCircleQueue->cancelActiveRequestTokens(CIRCLESDIALOG_GROUPDATA);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
std::list<RsGxsGroupId> grps ;
|
||||
grps.push_back(RsGxsGroupId(circle_id));
|
||||
|
||||
uint32_t token;
|
||||
mCircleQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grps, CIRCLESDIALOG_GROUPDATA);
|
||||
}
|
||||
#endif
|
||||
|
||||
void IdDialog::updateCircles()
|
||||
{
|
||||
RsThread::async([this]()
|
||||
@ -627,6 +587,7 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
|
||||
std::cerr << " more than 1 item correspond to this ID. Removing!" << std::endl;
|
||||
#endif
|
||||
delete clist.front() ;
|
||||
clist.pop_front();
|
||||
}
|
||||
|
||||
item = clist.front() ;
|
||||
@ -896,104 +857,6 @@ static void mark_matching_tree(QTreeWidget *w, const std::set<RsGxsId>& members,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void IdDialog::loadCircleGroupData(const uint32_t& token)
|
||||
{
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << "Loading circle info" << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsCircleGroup> circle_grp_v ;
|
||||
rsGxsCircles->getGroupData(token, circle_grp_v);
|
||||
|
||||
if (circle_grp_v.empty())
|
||||
{
|
||||
std::cerr << "(EE) unexpected empty result from getGroupData. Cannot process circle now!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
if (circle_grp_v.size() != 1)
|
||||
{
|
||||
std::cerr << "(EE) very weird result from getGroupData. Should get exactly one circle" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
RsGxsCircleGroup cg = circle_grp_v.front();
|
||||
RsGxsCircleId requested_cid(cg.mMeta.mGroupId) ;
|
||||
|
||||
QTreeWidgetItem *item = ui->treeWidget_membership->currentItem();
|
||||
|
||||
RsGxsCircleId id ;
|
||||
if(!getItemCircleId(item,id))
|
||||
return ;
|
||||
|
||||
if(requested_cid != id)
|
||||
{
|
||||
std::cerr << "(WW) not the same circle. Dropping request." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
/* now mark all the members */
|
||||
|
||||
std::set<RsGxsId> members = cg.mInvitedMembers;
|
||||
|
||||
mark_matching_tree(ui->idTreeWidget, members, RSID_COL_KEYID) ;
|
||||
|
||||
mStateHelper->setLoading(CIRCLESDIALOG_GROUPDATA, false);
|
||||
}
|
||||
|
||||
void IdDialog::updateCircleGroup(const uint32_t& token)
|
||||
{
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << "Loading circle info" << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsCircleGroup> circle_grp_v ;
|
||||
rsGxsCircles->getGroupData(token, circle_grp_v);
|
||||
|
||||
if (circle_grp_v.empty())
|
||||
{
|
||||
std::cerr << "(EE) unexpected empty result from getGroupData. Cannot process circle now!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
if (circle_grp_v.size() != 1)
|
||||
{
|
||||
std::cerr << "(EE) very weird result from getGroupData. Should get exactly one circle" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
RsGxsCircleGroup cg = circle_grp_v.front();
|
||||
|
||||
/* now mark all the members */
|
||||
|
||||
std::set<RsGxsId> members = cg.mInvitedMembers;
|
||||
|
||||
std::map<uint32_t,CircleUpdateOrder>::iterator it = mCircleUpdates.find(token) ;
|
||||
|
||||
if(it == mCircleUpdates.end())
|
||||
{
|
||||
std::cerr << "(EE) Cannot find token " << token << " to perform group update!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
if(it->second.action == CircleUpdateOrder::GRANT_MEMBERSHIP)
|
||||
cg.mInvitedMembers.insert(it->second.gxs_id) ;
|
||||
else if(it->second.action == CircleUpdateOrder::REVOKE_MEMBERSHIP)
|
||||
cg.mInvitedMembers.erase(it->second.gxs_id) ;
|
||||
else
|
||||
{
|
||||
std::cerr << "(EE) unrecognised membership action to perform: " << it->second.action << "!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
uint32_t token2 ;
|
||||
rsGxsCircles->updateGroup(token2,cg) ;
|
||||
|
||||
mCircleUpdates.erase(it) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool IdDialog::getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id)
|
||||
{
|
||||
#ifdef CIRCLE_MEMBERSHIP_CATEGORIES
|
||||
@ -1044,7 +907,7 @@ void IdDialog::grantCircleMembership()
|
||||
|
||||
RsThread::async([circle_id,gxs_id_to_grant]()
|
||||
{
|
||||
// 1 - get message data from p3GxsForums
|
||||
// 1 - set message data in p3GxsCircles
|
||||
|
||||
rsGxsCircles->inviteIdsToCircle(std::set<RsGxsId>( { gxs_id_to_grant } ),circle_id);
|
||||
});
|
||||
@ -2139,20 +2002,6 @@ void IdDialog::modifyReputation()
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
#ifdef SUSPENDED
|
||||
// Cyril: apparently the old reputation system was in used here. It's based on GXS data exchange, and probably not
|
||||
// very efficient because of this.
|
||||
|
||||
uint32_t token;
|
||||
if (!rsIdentity->submitOpinion(token, id, false, op))
|
||||
{
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << "IdDialog::modifyReputation() Error submitting Opinion";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// trigger refresh when finished.
|
||||
// basic / anstype are not needed.
|
||||
updateIdentity();
|
||||
@ -2197,17 +2046,6 @@ void IdDialog::updateDisplay(bool complete)
|
||||
updateCircles();
|
||||
return;
|
||||
}
|
||||
|
||||
// std::set<RsGxsGroupId> grpIds;
|
||||
// getAllGrpIds(grpIds);
|
||||
// if (!getGrpIds().empty()) {
|
||||
// requestIdList();
|
||||
//
|
||||
// if (!mId.isNull() && grpIds.find(mId)!=grpIds.end()) {
|
||||
// requestIdDetails();
|
||||
// requestRepList();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void IdDialog::addIdentity()
|
||||
@ -2270,144 +2108,6 @@ void IdDialog::filterIds()
|
||||
ui->idTreeWidget->filterItems(filterColumn, text);
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void IdDialog::requestRepList()
|
||||
{
|
||||
// Removing this for the moment.
|
||||
return;
|
||||
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, true);
|
||||
|
||||
mIdQueue->cancelActiveRequestTokens(IDDIALOG_REPLIST);
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(mId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
uint32_t token;
|
||||
mIdQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_REPLIST);
|
||||
}
|
||||
|
||||
void IdDialog::insertRepList(uint32_t token)
|
||||
{
|
||||
Q_UNUSED(token)
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, true);
|
||||
}
|
||||
|
||||
void IdDialog::handleSerializedGroupData(uint32_t token)
|
||||
{
|
||||
std::map<RsGxsId,std::string> serialized_group_map ;
|
||||
|
||||
rsIdentity->getGroupSerializedData(token, serialized_group_map);
|
||||
|
||||
if(serialized_group_map.size() < 1)
|
||||
{
|
||||
std::cerr << "(EE) Cannot get radix data " << std::endl;
|
||||
return;
|
||||
}
|
||||
if(serialized_group_map.size() > 1)
|
||||
{
|
||||
std::cerr << "(EE) Too many results for serialized data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
RsGxsId gxs_id = serialized_group_map.begin()->first ;
|
||||
std::string radix = serialized_group_map.begin()->second ;
|
||||
|
||||
RsIdentityDetails details ;
|
||||
|
||||
if(!rsIdentity->getIdDetails(gxs_id,details))
|
||||
{
|
||||
std::cerr << "(EE) Cannot get id details for key " << gxs_id << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
QList<RetroShareLink> urls ;
|
||||
|
||||
RetroShareLink link = RetroShareLink::createIdentity(gxs_id,QString::fromUtf8(details.mNickname.c_str()),QString::fromStdString(radix)) ;
|
||||
urls.push_back(link);
|
||||
|
||||
RSLinkClipboard::copyLinks(urls) ;
|
||||
|
||||
QMessageBox::information(NULL,tr("information"),tr("This identity link was copied to your clipboard. Paste it in a mail, or a message to transmit the identity to someone.")) ;
|
||||
}
|
||||
|
||||
void IdDialog::loadRequest(const TokenQueue * queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if(queue == mIdQueue)
|
||||
{
|
||||
switch(req.mUserType)
|
||||
{
|
||||
#ifdef TO_REMOVE
|
||||
case IDDIALOG_IDLIST:
|
||||
insertIdList(req.mToken);
|
||||
break;
|
||||
|
||||
case IDDIALOG_IDDETAILS:
|
||||
insertIdDetails(req.mToken);
|
||||
break;
|
||||
|
||||
case IDDIALOG_REPLIST:
|
||||
insertRepList(req.mToken);
|
||||
break;
|
||||
|
||||
case IDDIALOG_SERIALIZED_GROUP:
|
||||
handleSerializedGroupData(req.mToken);
|
||||
break;
|
||||
|
||||
case IDDIALOG_REFRESH:
|
||||
// replaced by RsGxsUpdateBroadcastPage
|
||||
// updateDisplay(true);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "IdDialog::loadRequest() ERROR";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
if(queue == mCircleQueue)
|
||||
{
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << "CirclesDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
{
|
||||
// case CIRCLESDIALOG_GROUPMETA:
|
||||
// loadCircleGroupMeta(req.mToken);
|
||||
// break;
|
||||
|
||||
// case CIRCLESDIALOG_GROUPDATA:
|
||||
// loadCircleGroupData(req.mToken);
|
||||
// break;
|
||||
//
|
||||
// case CIRCLESDIALOG_GROUPUPDATE:
|
||||
// updateCircleGroup(req.mToken);
|
||||
// break;
|
||||
|
||||
default:
|
||||
std::cerr << "CirclesDialog::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void IdDialog::IdListCustomPopupMenu( QPoint )
|
||||
{
|
||||
QMenu *contextMenu = new QMenu(this);
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
#define IMAGE_IDDIALOG ":/icons/png/people.png"
|
||||
|
||||
namespace Ui {
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "gui/feeds/FeedHolder.h"
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "util/HandleRichText.h"
|
||||
|
||||
#include "ui_PostedCardView.h"
|
||||
@ -158,88 +159,134 @@ bool PostedCardView::setPost(const RsPostedPost &post, bool doFill)
|
||||
return true;
|
||||
}
|
||||
|
||||
void PostedCardView::loadGroup(const uint32_t &token)
|
||||
void PostedCardView::loadGroup()
|
||||
{
|
||||
std::vector<RsPostedGroup> groups;
|
||||
if (!rsPosted->getGroupData(token, groups))
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "PostedCardView::loadGroup() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// 1 - get group data
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "PostedCardView::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||
#endif
|
||||
|
||||
setGroup(groups[0]);
|
||||
std::vector<RsPostedGroup> groups;
|
||||
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||
|
||||
if(!rsPosted->getBoardsInfo(groupIds,groups))
|
||||
{
|
||||
RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
RsPostedGroup 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 */
|
||||
|
||||
setGroup(group);
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
void PostedCardView::loadMessage(const uint32_t &token)
|
||||
void PostedCardView::loadMessage()
|
||||
{
|
||||
std::vector<RsPostedPost> posts;
|
||||
std::vector<RsGxsComment> cmts;
|
||||
if (!rsPosted->getPostData(token, posts, cmts))
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// 1 - get group data
|
||||
|
||||
if (posts.size() == 1)
|
||||
{
|
||||
setPost(posts[0]);
|
||||
}
|
||||
else if (cmts.size() == 1)
|
||||
{
|
||||
RsGxsComment cmt = cmts[0];
|
||||
std::vector<RsPostedPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
|
||||
//ui->newCommentLabel->show();
|
||||
//ui->commLabel->show();
|
||||
//ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
||||
if(! rsPosted->getBoardContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
|
||||
{
|
||||
RsErr() << "PostedItem::loadMessage() ERROR getting data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (posts.size() == 1)
|
||||
{
|
||||
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
||||
const RsPostedPost& post(posts[0]);
|
||||
|
||||
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
|
||||
}
|
||||
else if(comments.size() == 1)
|
||||
{
|
||||
const RsGxsComment& cmt = comments[0];
|
||||
std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl;
|
||||
|
||||
RsQThreadUtils::postToObject( [cmt,this]()
|
||||
{
|
||||
//Change this item to be uploaded with thread element.
|
||||
setMessageId(cmt.mMeta.mThreadId);
|
||||
requestMessage();
|
||||
|
||||
}, this );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
|
||||
}
|
||||
});
|
||||
|
||||
//Change this item to be uploaded with thread element.
|
||||
setMessageId(cmt.mMeta.mThreadId);
|
||||
requestMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
||||
std::cerr << std::endl;
|
||||
removeItem();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void PostedCardView::loadComment(const uint32_t &token)
|
||||
void PostedCardView::loadComment()
|
||||
{
|
||||
std::vector<RsGxsComment> cmts;
|
||||
if (!rsPosted->getRelatedComments(token, cmts))
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// 1 - get group data
|
||||
|
||||
size_t comNb = cmts.size();
|
||||
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);
|
||||
std::set<RsGxsMessageId> msgIds;
|
||||
|
||||
for(auto MsgId: messageVersions())
|
||||
msgIds.insert(MsgId);
|
||||
|
||||
std::vector<RsPostedPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
|
||||
if(! rsPosted->getBoardContent( groupId(),msgIds,posts,comments))
|
||||
{
|
||||
RsErr() << "PostedCardView::loadGroup() ERROR getting data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
int comNb = comments.size();
|
||||
|
||||
RsQThreadUtils::postToObject( [comNb,this]()
|
||||
{
|
||||
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 PostedCardView::fill()
|
||||
{
|
||||
if (isLoading()) {
|
||||
/* Wait for all requests */
|
||||
return;
|
||||
}
|
||||
// if (isLoading()) {
|
||||
// /* Wait for all requests */
|
||||
// return;
|
||||
// }
|
||||
|
||||
QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png");
|
||||
|
||||
|
@ -69,13 +69,13 @@ signals:
|
||||
protected:
|
||||
/* GxsGroupFeedItem */
|
||||
virtual QString groupName();
|
||||
virtual void loadGroup(const uint32_t &token);
|
||||
virtual void loadGroup() override;
|
||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
|
||||
|
||||
/* GxsFeedItem */
|
||||
virtual QString messageName();
|
||||
virtual void loadMessage(const uint32_t &token);
|
||||
virtual void loadComment(const uint32_t &token);
|
||||
virtual void loadMessage();
|
||||
virtual void loadComment();
|
||||
|
||||
private:
|
||||
void setup();
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "PhotoView.h"
|
||||
#include "ui_PostedItem.h"
|
||||
@ -170,89 +171,138 @@ bool PostedItem::setPost(const RsPostedPost &post, bool doFill)
|
||||
return true;
|
||||
}
|
||||
|
||||
void PostedItem::loadGroup(const uint32_t &token)
|
||||
void PostedItem::loadGroup()
|
||||
{
|
||||
std::vector<RsPostedGroup> groups;
|
||||
if (!rsPosted->getGroupData(token, groups))
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "PostedItem::loadGroup() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// 1 - get group data
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "PostedItem::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||
#endif
|
||||
|
||||
setGroup(groups[0]);
|
||||
std::vector<RsPostedGroup> groups;
|
||||
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||
|
||||
if(!rsPosted->getBoardsInfo(groupIds,groups))
|
||||
{
|
||||
RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
RsPostedGroup 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 */
|
||||
|
||||
setGroup(group);
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
void PostedItem::loadMessage(const uint32_t &token)
|
||||
void PostedItem::loadMessage()
|
||||
{
|
||||
std::vector<RsPostedPost> posts;
|
||||
std::vector<RsGxsComment> cmts;
|
||||
if (!rsPosted->getPostData(token, posts, cmts))
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// 1 - get group data
|
||||
|
||||
if (posts.size() == 1)
|
||||
{
|
||||
setPost(posts[0]);
|
||||
}
|
||||
else if (cmts.size() == 1)
|
||||
{
|
||||
RsGxsComment cmt = cmts[0];
|
||||
std::vector<RsPostedPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
|
||||
ui->newCommentLabel->show();
|
||||
ui->commLabel->show();
|
||||
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
||||
if(! rsPosted->getBoardContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
|
||||
{
|
||||
RsErr() << "PostedItem::loadMessage() ERROR getting data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
//Change this item to be uploaded with thread element.
|
||||
setMessageId(cmt.mMeta.mThreadId);
|
||||
requestMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
||||
std::cerr << std::endl;
|
||||
removeItem();
|
||||
return;
|
||||
}
|
||||
if (posts.size() == 1)
|
||||
{
|
||||
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
||||
const RsPostedPost& post(posts[0]);
|
||||
|
||||
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
|
||||
}
|
||||
else if(comments.size() == 1)
|
||||
{
|
||||
const RsGxsComment& cmt = comments[0];
|
||||
std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl;
|
||||
|
||||
RsQThreadUtils::postToObject( [cmt,this]()
|
||||
{
|
||||
ui->newCommentLabel->show();
|
||||
ui->commLabel->show();
|
||||
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
||||
|
||||
//Change this item to be uploaded with thread element.
|
||||
setMessageId(cmt.mMeta.mThreadId);
|
||||
requestMessage();
|
||||
|
||||
}, this );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void PostedItem::loadComment(const uint32_t &token)
|
||||
void PostedItem::loadComment()
|
||||
{
|
||||
std::vector<RsGxsComment> cmts;
|
||||
if (!rsPosted->getRelatedComments(token, cmts))
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsChannelPostItem::loadComment()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
size_t comNb = cmts.size();
|
||||
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);
|
||||
RsThread::async([this]()
|
||||
{
|
||||
// 1 - get group data
|
||||
|
||||
std::set<RsGxsMessageId> msgIds;
|
||||
|
||||
for(auto MsgId: messageVersions())
|
||||
msgIds.insert(MsgId);
|
||||
|
||||
std::vector<RsPostedPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
|
||||
if(! rsPosted->getBoardContent( groupId(),msgIds,posts,comments))
|
||||
{
|
||||
RsErr() << "PostedItem::loadGroup() ERROR getting data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
int comNb = comments.size();
|
||||
|
||||
RsQThreadUtils::postToObject( [comNb,this]()
|
||||
{
|
||||
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 PostedItem::fill()
|
||||
{
|
||||
if (isLoading()) {
|
||||
/* Wait for all requests */
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroup.mMeta.mGroupId, groupName());
|
||||
ui->nameLabel->setText(link.toHtml());
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
bool setGroup(const RsPostedGroup& group, bool doFill = true);
|
||||
bool setPost(const RsPostedPost& post, bool doFill = true);
|
||||
|
||||
const RsPostedPost &getPost() const;
|
||||
const RsPostedPost& getPost() const;
|
||||
RsPostedPost &post();
|
||||
|
||||
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + messageId().toStdString()); }
|
||||
@ -71,13 +71,14 @@ signals:
|
||||
protected:
|
||||
/* GxsGroupFeedItem */
|
||||
virtual QString groupName();
|
||||
virtual void loadGroup(const uint32_t &token);
|
||||
virtual void loadGroup() override;
|
||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
|
||||
|
||||
/* GxsFeedItem */
|
||||
virtual QString messageName();
|
||||
virtual void loadMessage(const uint32_t &token);
|
||||
virtual void loadComment(const uint32_t &token);
|
||||
|
||||
virtual void loadMessage();
|
||||
virtual void loadComment();
|
||||
|
||||
private:
|
||||
void setup();
|
||||
|
@ -42,7 +42,7 @@
|
||||
#define POSTED_DEFAULT_LISTING_LENGTH 10
|
||||
#define POSTED_MAX_INDEX 10000
|
||||
|
||||
#define DEBUG_POSTED_LIST_WIDGET
|
||||
//#define DEBUG_POSTED_LIST_WIDGET
|
||||
|
||||
#define BOARD_DEFAULT_IMAGE ":/icons/png/posted.png"
|
||||
|
||||
@ -714,35 +714,45 @@ void PostedListWidget::applyRanking()
|
||||
|
||||
foreach (PostedCardView *item, mPostCardView)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::applyRanking() Item: " << item;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (item->getPost().mMeta.mPublishTs < min_ts)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "\t Skipping OLD";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
item->hide();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (counter >= mPostIndex + mPostShow)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "\t END - Counter too high";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
item->hide();
|
||||
}
|
||||
else if (counter >= mPostIndex)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "\t Adding to Layout";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* add it in! */
|
||||
cviewlayout->addWidget(item);
|
||||
item->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "\t Skipping to Low";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
item->hide();
|
||||
}
|
||||
++counter;
|
||||
|
@ -78,8 +78,7 @@
|
||||
|
||||
|
||||
/** Constructor */
|
||||
WikiDialog::WikiDialog(QWidget *parent)
|
||||
: RsGxsUpdateBroadcastPage(rsWiki, parent)
|
||||
WikiDialog::WikiDialog(QWidget *parent) : RsGxsUpdateBroadcastPage(rsWiki, parent)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
@ -200,7 +200,8 @@ bool ElidedLabel::paintElidedLine(QPainter& painter,QString plainText,const QRec
|
||||
iTransX = 0;
|
||||
}
|
||||
|
||||
painter.drawText(QPoint(iTransX + cr.left(), y + fontMetrics.ascent() + cr.top()), elidedLastLine);
|
||||
if(width+iTransX+cr.left() <= cr.right())
|
||||
painter.drawText(QPoint(iTransX + cr.left(), y + fontMetrics.ascent() + cr.top()), elidedLastLine);
|
||||
//Draw button to get ToolTip
|
||||
|
||||
if(drawRoundRect)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "ui_GxsChannelGroupItem.h"
|
||||
|
||||
#include "FeedHolder.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "gui/NewsFeed.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
|
||||
@ -89,29 +90,39 @@ bool GxsChannelGroupItem::setGroup(const RsGxsChannelGroup &group)
|
||||
return true;
|
||||
}
|
||||
|
||||
void GxsChannelGroupItem::loadGroup(const uint32_t &token)
|
||||
void GxsChannelGroupItem::loadGroup()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsChannelGroupItem::loadGroup()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsChannelGroup> groups;
|
||||
if (!rsGxsChannels->getGroupData(token, groups))
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "GxsChannelGroupItem::loadGroup() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// 1 - get group data
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsChannelGroupItem::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
std::vector<RsGxsChannelGroup> groups;
|
||||
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||
|
||||
setGroup(groups[0]);
|
||||
if(!rsGxsChannels->getChannelsInfo(groupIds,groups))
|
||||
{
|
||||
RsErr() << "PostedItem::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 */
|
||||
|
||||
setGroup(group);
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
QString GxsChannelGroupItem::groupName()
|
||||
|
@ -48,7 +48,7 @@ protected:
|
||||
|
||||
/* GxsGroupFeedItem */
|
||||
virtual QString groupName();
|
||||
virtual void loadGroup(const uint32_t &token);
|
||||
virtual void loadGroup() override;
|
||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
|
||||
|
||||
private slots:
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "FeedHolder.h"
|
||||
#include "SubFileItem.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/DateTime.h"
|
||||
@ -230,107 +231,149 @@ void GxsChannelPostItem::loadComments()
|
||||
comments(title);
|
||||
}
|
||||
|
||||
void GxsChannelPostItem::loadGroup(const uint32_t &token)
|
||||
void GxsChannelPostItem::loadGroup()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsChannelGroupItem::loadGroup()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsChannelGroup> groups;
|
||||
if (!rsGxsChannels->getGroupData(token, groups))
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "GxsChannelGroupItem::loadGroup() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// 1 - get group data
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsChannelGroupItem::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
std::vector<RsGxsChannelGroup> groups;
|
||||
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||
|
||||
setGroup(groups[0]);
|
||||
if(!rsGxsChannels->getChannelsInfo(groupIds,groups))
|
||||
{
|
||||
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 */
|
||||
|
||||
setGroup(group);
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
void GxsChannelPostItem::loadMessage(const uint32_t &token)
|
||||
void GxsChannelPostItem::loadMessage()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsChannelPostItem::loadMessage()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
std::vector<RsGxsComment> cmts;
|
||||
if (!rsGxsChannels->getPostData(token, posts, cmts))
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// 1 - get group data
|
||||
|
||||
if (posts.size() == 1)
|
||||
{
|
||||
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
||||
setPost(posts[0]);
|
||||
}
|
||||
else if (cmts.size() == 1)
|
||||
{
|
||||
RsGxsComment cmt = cmts[0];
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
|
||||
std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl;
|
||||
ui->newCommentLabel->show();
|
||||
ui->commLabel->show();
|
||||
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
||||
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
|
||||
{
|
||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
//Change this item to be uploaded with thread element.
|
||||
setMessageId(cmt.mMeta.mThreadId);
|
||||
requestMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
||||
std::cerr << std::endl;
|
||||
removeItem();
|
||||
return;
|
||||
}
|
||||
if (posts.size() == 1)
|
||||
{
|
||||
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
||||
const RsGxsChannelPost& post(posts[0]);
|
||||
|
||||
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
|
||||
}
|
||||
else if(comments.size() == 1)
|
||||
{
|
||||
const RsGxsComment& cmt = comments[0];
|
||||
std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl;
|
||||
|
||||
RsQThreadUtils::postToObject( [cmt,this]()
|
||||
{
|
||||
ui->newCommentLabel->show();
|
||||
ui->commLabel->show();
|
||||
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
||||
|
||||
//Change this item to be uploaded with thread element.
|
||||
setMessageId(cmt.mMeta.mThreadId);
|
||||
requestMessage();
|
||||
|
||||
}, this );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void GxsChannelPostItem::loadComment(const uint32_t &token)
|
||||
void GxsChannelPostItem::loadComment()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsChannelPostItem::loadComment()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsComment> cmts;
|
||||
if (!rsGxsChannels->getRelatedComments(token, cmts))
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// 1 - get group data
|
||||
|
||||
size_t comNb = cmts.size();
|
||||
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);
|
||||
std::set<RsGxsMessageId> msgIds;
|
||||
|
||||
for(auto MsgId: messageVersions())
|
||||
msgIds.insert(MsgId);
|
||||
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
|
||||
if(! rsGxsChannels->getChannelContent( groupId(),msgIds,posts,comments))
|
||||
{
|
||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
int comNb = comments.size();
|
||||
|
||||
RsQThreadUtils::postToObject( [comNb,this]()
|
||||
{
|
||||
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 GxsChannelPostItem::fill()
|
||||
{
|
||||
/* fill in */
|
||||
|
||||
if (isLoading()) {
|
||||
/* Wait for all requests */
|
||||
return;
|
||||
}
|
||||
// if (isLoading()) {
|
||||
// /* Wait for all requests */
|
||||
//return;
|
||||
// }
|
||||
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsChannelPostItem::fill()";
|
||||
|
@ -81,13 +81,13 @@ protected:
|
||||
|
||||
/* GxsGroupFeedItem */
|
||||
virtual QString groupName();
|
||||
virtual void loadGroup(const uint32_t &token);
|
||||
virtual void loadGroup() override;
|
||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
|
||||
|
||||
/* GxsFeedItem */
|
||||
virtual QString messageName();
|
||||
virtual void loadMessage(const uint32_t &token);
|
||||
virtual void loadComment(const uint32_t &token);
|
||||
virtual void loadMessage();
|
||||
virtual void loadComment();
|
||||
|
||||
private slots:
|
||||
/* default stuff */
|
||||
|
@ -45,7 +45,6 @@ GxsCircleItem::GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGx
|
||||
setup();
|
||||
}
|
||||
|
||||
|
||||
GxsCircleItem::~GxsCircleItem()
|
||||
{
|
||||
delete(ui);
|
||||
@ -76,7 +75,6 @@ void GxsCircleItem::setup()
|
||||
if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL))
|
||||
pixmap = GxsIdDetails::makeDefaultIcon(mGxsId,GxsIdDetails::SMALL);
|
||||
|
||||
|
||||
/* update circle information */
|
||||
|
||||
RsGxsCircleDetails circleDetails;
|
||||
@ -161,10 +159,6 @@ void GxsCircleItem::setup()
|
||||
ui->gxsIdLabel->setText(idName);
|
||||
ui->gxsIdLabel->setId(mGxsId);
|
||||
}
|
||||
|
||||
/* Setup TokenQueue */
|
||||
mCircleQueue = new TokenQueue(rsGxsCircles->getTokenService(), this);
|
||||
|
||||
}
|
||||
|
||||
uint64_t GxsCircleItem::uniqueIdentifier() const
|
||||
@ -172,35 +166,6 @@ uint64_t GxsCircleItem::uniqueIdentifier() const
|
||||
return hash_64bits("GxsCircle " + mCircleId.toStdString() + " " + mGxsId.toStdString() + " " + QString::number(mType).toStdString());
|
||||
}
|
||||
|
||||
void GxsCircleItem::loadRequest(const TokenQueue * queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << "GxsCircleItem::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
if(queue == mCircleQueue)
|
||||
{
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << "CirclesDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
{
|
||||
case CIRCLESDIALOG_GROUPUPDATE:
|
||||
updateCircleGroup(req.mToken);
|
||||
break;
|
||||
|
||||
default:
|
||||
std::cerr << "GxsCircleItem::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*********** SPECIFIC FUNCTIONS ***********************/
|
||||
|
||||
void GxsCircleItem::showCircleDetails()
|
||||
@ -219,92 +184,17 @@ void GxsCircleItem::acceptCircleSubscription()
|
||||
|
||||
void GxsCircleItem::grantCircleMembership()
|
||||
{
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
std::list<RsGxsGroupId> grps ;
|
||||
grps.push_back(RsGxsGroupId(mCircleId));
|
||||
|
||||
uint32_t token;
|
||||
mCircleQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grps, CIRCLESDIALOG_GROUPUPDATE);
|
||||
|
||||
CircleUpdateOrder c ;
|
||||
c.token = token ;
|
||||
c.gxs_id = mGxsId ;
|
||||
c.action = CircleUpdateOrder::GRANT_MEMBERSHIP ;
|
||||
|
||||
mCircleUpdates[token] = c ;
|
||||
RsThread::async([this]()
|
||||
{
|
||||
rsGxsCircles->inviteIdsToCircle(std::set<RsGxsId>( { mGxsId } ),mCircleId);
|
||||
});
|
||||
}
|
||||
|
||||
void GxsCircleItem::revokeCircleMembership()
|
||||
{
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
std::list<RsGxsGroupId> grps;
|
||||
grps.push_back(RsGxsGroupId(mCircleId));
|
||||
|
||||
uint32_t token;
|
||||
mCircleQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grps, CIRCLESDIALOG_GROUPUPDATE);
|
||||
|
||||
CircleUpdateOrder c;
|
||||
c.token = token;
|
||||
c.gxs_id = mGxsId;
|
||||
c.action = CircleUpdateOrder::REVOKE_MEMBERSHIP;
|
||||
|
||||
mCircleUpdates[token] = c;
|
||||
}
|
||||
|
||||
void GxsCircleItem::updateCircleGroup(const uint32_t& token)
|
||||
{
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << "Loading circle info" << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsCircleGroup> circle_grp_v ;
|
||||
rsGxsCircles->getGroupData(token, circle_grp_v);
|
||||
|
||||
if (circle_grp_v.empty())
|
||||
{
|
||||
std::cerr << "(EE) unexpected empty result from getGroupData. Cannot process circle now!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
if (circle_grp_v.size() != 1)
|
||||
{
|
||||
std::cerr << "(EE) very weird result from getGroupData. Should get exactly one circle" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
RsGxsCircleGroup cg = circle_grp_v.front();
|
||||
|
||||
/* now mark all the members */
|
||||
|
||||
//std::set<RsGxsId> members = cg.mInvitedMembers;
|
||||
|
||||
std::map<uint32_t,CircleUpdateOrder>::iterator it = mCircleUpdates.find(token) ;
|
||||
|
||||
if(it == mCircleUpdates.end())
|
||||
{
|
||||
std::cerr << "(EE) Cannot find token " << token << " to perform group update!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
if(it->second.action == CircleUpdateOrder::GRANT_MEMBERSHIP)
|
||||
cg.mInvitedMembers.insert(it->second.gxs_id) ;
|
||||
else if(it->second.action == CircleUpdateOrder::REVOKE_MEMBERSHIP)
|
||||
cg.mInvitedMembers.erase(it->second.gxs_id) ;
|
||||
else
|
||||
{
|
||||
std::cerr << "(EE) unrecognised membership action to perform: " << it->second.action << "!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
uint32_t token2 ;
|
||||
rsGxsCircles->updateGroup(token2,cg) ;
|
||||
|
||||
mCircleUpdates.erase(it) ;
|
||||
RsThread::async([this]()
|
||||
{
|
||||
rsGxsCircles->revokeIdsFromCircle(std::set<RsGxsId>( { mGxsId } ),mCircleId);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ struct CircleUpdateOrder
|
||||
};
|
||||
|
||||
|
||||
class GxsCircleItem : public FeedItem, public TokenResponse
|
||||
class GxsCircleItem : public FeedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -78,10 +78,6 @@ private:
|
||||
RsGxsCircleId mCircleId;
|
||||
RsGxsId mGxsId;
|
||||
|
||||
TokenQueue *mCircleQueue;
|
||||
std::map<uint32_t, CircleUpdateOrder> mCircleUpdates ;
|
||||
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::GxsCircleItem *ui;
|
||||
};
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "FeedHolder.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
|
||||
/****
|
||||
* #define DEBUG_ITEM 1
|
||||
@ -87,29 +88,43 @@ bool GxsForumGroupItem::setGroup(const RsGxsForumGroup &group)
|
||||
return true;
|
||||
}
|
||||
|
||||
void GxsForumGroupItem::loadGroup(const uint32_t &token)
|
||||
void GxsForumGroupItem::loadGroup()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsForumGroupItem::loadGroup()";
|
||||
std::cerr << std::endl;
|
||||
RsThread::async([this]()
|
||||
{
|
||||
// 1 - get group data
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsForumGroup> groups;
|
||||
if (!rsGxsForums->getGroupData(token, groups))
|
||||
{
|
||||
std::cerr << "GxsForumGroupItem::loadGroup() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
std::vector<RsGxsForumGroup> groups;
|
||||
const std::list<RsGxsGroupId> forumIds = { groupId() };
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
if(!rsGxsForums->getForumsInfo(forumIds,groups))
|
||||
{
|
||||
RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
setGroup(groups[0]);
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
const RsGxsForumGroup& 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 */
|
||||
|
||||
setGroup(group);
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
QString GxsForumGroupItem::groupName()
|
||||
|
@ -50,7 +50,7 @@ protected:
|
||||
|
||||
/* GxsGroupFeedItem */
|
||||
virtual QString groupName();
|
||||
virtual void loadGroup(const uint32_t &token);
|
||||
virtual void loadGroup() override;
|
||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
|
||||
|
||||
private slots:
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "util/DateTime.h"
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
@ -94,7 +95,6 @@ void GxsForumMsgItem::setup()
|
||||
|
||||
mInFill = false;
|
||||
mCloseOnRead = false;
|
||||
mTokenTypeParentMessage = nextTokenType();
|
||||
|
||||
/* clear ui */
|
||||
ui->titleLabel->setText(tr("Loading"));
|
||||
@ -154,13 +154,10 @@ bool GxsForumMsgItem::setMessage(const RsGxsForumMsg &msg, bool doFill)
|
||||
|
||||
mMessage = msg;
|
||||
|
||||
if (!isTop()) {
|
||||
requestParentMessage(mMessage.mMeta.mParentId);
|
||||
} else {
|
||||
if (doFill) {
|
||||
fill();
|
||||
}
|
||||
}
|
||||
if (!isTop())
|
||||
loadParentMessage(mMessage.mMeta.mParentId);
|
||||
else if(doFill)
|
||||
fill();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -170,91 +167,144 @@ QString GxsForumMsgItem::groupName()
|
||||
return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str());
|
||||
}
|
||||
|
||||
void GxsForumMsgItem::loadGroup(const uint32_t &token)
|
||||
void GxsForumMsgItem::loadGroup()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsForumGroupItem::loadGroup()";
|
||||
std::cerr << std::endl;
|
||||
RsThread::async([this]()
|
||||
{
|
||||
// 1 - get group data
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsForumGroup> groups;
|
||||
if (!rsGxsForums->getGroupData(token, groups))
|
||||
{
|
||||
std::cerr << "GxsForumGroupItem::loadGroup() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
std::vector<RsGxsForumGroup> groups;
|
||||
const std::list<RsGxsGroupId> forumIds = { groupId() };
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
if(!rsGxsForums->getForumsInfo(forumIds,groups))
|
||||
{
|
||||
RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
setGroup(groups[0]);
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
RsGxsForumGroup 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 */
|
||||
|
||||
setGroup(group);
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
void GxsForumMsgItem::loadMessage(const uint32_t &token)
|
||||
void GxsForumMsgItem::loadMessage()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsForumMsgItem::loadMessage()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsForumMsg> msgs;
|
||||
if (!rsGxsForums->getMsgData(token, msgs))
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (msgs.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// 1 - get group data
|
||||
|
||||
setMessage(msgs[0]);
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsForumMsg> msgs;
|
||||
const std::list<RsGxsGroupId> forumIds = { groupId() };
|
||||
|
||||
if(!rsGxsForums->getForumContent(groupId(),std::set<RsGxsMessageId>( { messageId() } ),msgs))
|
||||
{
|
||||
std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (msgs.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
const RsGxsForumMsg& msg(msgs[0]);
|
||||
|
||||
RsQThreadUtils::postToObject( [msg,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 */
|
||||
|
||||
setMessage(msg);
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
void GxsForumMsgItem::loadParentMessage(const uint32_t &token)
|
||||
void GxsForumMsgItem::loadParentMessage(const RsGxsMessageId& parent_msg)
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsForumMsgItem::loadParentMessage()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsForumMsg> msgs;
|
||||
if (!rsGxsForums->getMsgData(token, msgs))
|
||||
RsThread::async([parent_msg,this]()
|
||||
{
|
||||
std::cerr << "GxsForumMsgItem::loadParentMessage() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// 1 - get group data
|
||||
|
||||
if (msgs.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsForumMsgItem::loadParentMessage() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||
#endif
|
||||
|
||||
mParentMessage = msgs[0];
|
||||
std::vector<RsGxsForumMsg> msgs;
|
||||
const std::list<RsGxsGroupId> forumIds = { groupId() };
|
||||
|
||||
fill();
|
||||
if(!rsGxsForums->getForumContent(groupId(),std::set<RsGxsMessageId>( { parent_msg } ),msgs))
|
||||
{
|
||||
std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (msgs.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
const RsGxsForumMsg& msg(msgs[0]);
|
||||
|
||||
RsQThreadUtils::postToObject( [msg,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 */
|
||||
|
||||
mParentMessage = msg;
|
||||
fill();
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
void GxsForumMsgItem::fill()
|
||||
{
|
||||
/* fill in */
|
||||
|
||||
if (isLoading()) {
|
||||
/* Wait for all requests */
|
||||
return;
|
||||
}
|
||||
// if (isLoading()) {
|
||||
// /* Wait for all requests */
|
||||
// return;
|
||||
// }
|
||||
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsForumMsgItem::fill()";
|
||||
@ -307,18 +357,6 @@ void GxsForumMsgItem::fill()
|
||||
|
||||
ui->nameLabel->setId(mMessage.mMeta.mAuthorId);
|
||||
|
||||
// ui->avatar->setId(msg.srcId, true);
|
||||
|
||||
// if (rsPeers->getPeerName(msg.srcId) != "") {
|
||||
// RetroShareLink linkMessage;
|
||||
// linkMessage.createMessage(msg.srcId, "");
|
||||
// nameLabel->setText(linkMessage.toHtml());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// nameLabel->setText(tr("Anonymous"));
|
||||
// }
|
||||
|
||||
RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_FORUM, mMessage.mMeta.mGroupId, mMessage.mMeta.mMsgId, messageName());
|
||||
ui->subLabel->setText(msgLink.toHtml());
|
||||
if (wasExpanded() || ui->expandFrame->isVisible()) {
|
||||
@ -330,14 +368,13 @@ void GxsForumMsgItem::fill()
|
||||
if (isTop()) {
|
||||
ui->parentFrame->hide();
|
||||
} else {
|
||||
// ui->parentAvatar->setId(msgParent.srcId, true);
|
||||
|
||||
RetroShareLink linkParent = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_FORUM, mParentMessage.mMeta.mGroupId, mParentMessage.mMeta.mMsgId, QString::fromUtf8(mParentMessage.mMeta.mMsgName.c_str()));
|
||||
ui->parentSubLabel->setText(linkParent.toHtml());
|
||||
ui->parentMsgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mParentMessage.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||
|
||||
ui->parentNameLabel->setId(mParentMessage.mMeta.mAuthorId);
|
||||
|
||||
|
||||
RsIdentityDetails idDetails ;
|
||||
rsIdentity->getIdDetails(mParentMessage.mMeta.mAuthorId,idDetails);
|
||||
|
||||
@ -348,16 +385,6 @@ void GxsForumMsgItem::fill()
|
||||
|
||||
ui->parentAvatar->setPixmap(pixmap);
|
||||
|
||||
// if (rsPeers->getPeerName(msgParent.srcId) !="")
|
||||
// {
|
||||
// RetroShareLink linkMessage;
|
||||
// linkMessage.createMessage(msgParent.srcId, "");
|
||||
// ui->parentNameLabel->setText(linkMessage.toHtml());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ui->parentNameLabel->setText(tr("Anonymous"));
|
||||
// }
|
||||
}
|
||||
|
||||
/* header stuff */
|
||||
@ -440,63 +467,6 @@ void GxsForumMsgItem::setReadStatus(bool isNew, bool /*isUnread*/)
|
||||
ui->frame->style()->polish( ui->frame);
|
||||
}
|
||||
|
||||
void GxsForumMsgItem::requestParentMessage(const RsGxsMessageId &msgId)
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsFeedItem::requestMessage()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (!initLoadQueue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mLoadQueue->activeRequestExist(mTokenTypeParentMessage)) {
|
||||
/* Request already running */
|
||||
return;
|
||||
}
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
std::set<RsGxsMessageId> &vect_msgIds = msgIds[groupId()];
|
||||
vect_msgIds.insert(msgId);
|
||||
|
||||
uint32_t token;
|
||||
mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeParentMessage);
|
||||
}
|
||||
|
||||
void GxsForumMsgItem::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsFeedItem::loadRequest()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (queue == mLoadQueue) {
|
||||
if (req.mUserType == mTokenTypeParentMessage) {
|
||||
loadParentMessage(req.mToken);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
GxsFeedItem::loadRequest(queue, req);
|
||||
}
|
||||
|
||||
bool GxsForumMsgItem::isLoading()
|
||||
{
|
||||
if (GxsFeedItem::isLoading()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mLoadQueue && mLoadQueue->activeRequestExist(mTokenTypeParentMessage)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*********** SPECIFIC FUNCTIONS ***********************/
|
||||
|
||||
void GxsForumMsgItem::readAndClearItem()
|
||||
|
@ -50,20 +50,18 @@ protected:
|
||||
virtual void expandFill(bool first);
|
||||
|
||||
/* load message data */
|
||||
void requestParentMessage(const RsGxsMessageId &msgId);
|
||||
virtual void loadParentMessage(const uint32_t &token);
|
||||
virtual void loadParentMessage(const RsGxsMessageId &parent_msg);
|
||||
|
||||
/* GxsGroupFeedItem */
|
||||
virtual QString groupName();
|
||||
virtual void loadGroup(const uint32_t &token);
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
virtual void loadGroup() override;
|
||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
|
||||
virtual bool isLoading();
|
||||
//virtual bool isLoading();
|
||||
|
||||
/* GxsFeedItem */
|
||||
virtual QString messageName();
|
||||
virtual void loadMessage(const uint32_t &token);
|
||||
virtual void loadComment(const uint32_t &/*token*/){ return;}
|
||||
virtual void loadMessage() override;
|
||||
virtual void loadComment() override { return; }
|
||||
|
||||
private slots:
|
||||
/* default stuff */
|
||||
@ -90,7 +88,6 @@ private:
|
||||
RsGxsForumGroup mGroup;
|
||||
RsGxsForumMsg mMessage;
|
||||
RsGxsForumMsg mParentMessage;
|
||||
uint32_t mTokenTypeParentMessage;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::GxsForumMsgItem *ui;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "ui_PostedGroupItem.h"
|
||||
|
||||
#include "FeedHolder.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
|
||||
@ -90,29 +91,43 @@ bool PostedGroupItem::setGroup(const RsPostedGroup &group)
|
||||
return true;
|
||||
}
|
||||
|
||||
void PostedGroupItem::loadGroup(const uint32_t &token)
|
||||
void PostedGroupItem::loadGroup()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "PostedGroupItem::loadGroup()";
|
||||
std::cerr << std::endl;
|
||||
RsThread::async([this]()
|
||||
{
|
||||
// 1 - get group data
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsPostedGroup> groups;
|
||||
if (!rsPosted->getGroupData(token, groups))
|
||||
{
|
||||
std::cerr << "PostedGroupItem::loadGroup() ERROR getting data";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
std::vector<RsPostedGroup> groups;
|
||||
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "PostedGroupItem::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
if(!rsPosted->getBoardsInfo(groupIds,groups))
|
||||
{
|
||||
RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
setGroup(groups[0]);
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
RsPostedGroup 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 */
|
||||
|
||||
setGroup(group);
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
QString PostedGroupItem::groupName()
|
||||
|
@ -50,7 +50,7 @@ protected:
|
||||
|
||||
/* GxsGroupFeedItem */
|
||||
virtual QString groupName();
|
||||
virtual void loadGroup(const uint32_t &token);
|
||||
virtual void loadGroup() override;
|
||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
|
||||
|
||||
private slots:
|
||||
|
@ -40,8 +40,10 @@ GxsFeedItem::GxsFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGro
|
||||
/* load data if we can */
|
||||
mMessageId = messageId;
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
mTokenTypeMessage = nextTokenType();
|
||||
mTokenTypeComment = nextTokenType();
|
||||
#endif
|
||||
}
|
||||
|
||||
GxsFeedItem::~GxsFeedItem()
|
||||
@ -106,6 +108,8 @@ void GxsFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, boo
|
||||
|
||||
void GxsFeedItem::requestMessage()
|
||||
{
|
||||
loadMessage();
|
||||
#ifdef TO_REMOVE
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsFeedItem::requestMessage()";
|
||||
std::cerr << std::endl;
|
||||
@ -129,15 +133,19 @@ void GxsFeedItem::requestMessage()
|
||||
|
||||
uint32_t token;
|
||||
mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeMessage);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsFeedItem::requestComment()
|
||||
{
|
||||
loadComment();
|
||||
#ifdef TO_REMOVE
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsFeedItem::requestComment()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
if (!initLoadQueue()) {
|
||||
return;
|
||||
}
|
||||
@ -146,6 +154,7 @@ void GxsFeedItem::requestComment()
|
||||
/* Request already running */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||
@ -153,15 +162,17 @@ void GxsFeedItem::requestComment()
|
||||
|
||||
std::vector<RsGxsGrpMsgIdPair> msgIds;
|
||||
|
||||
for(int i=0;i<mMessageVersions.size();++i)
|
||||
msgIds.push_back(std::make_pair(groupId(),mMessageVersions[i])) ;
|
||||
for(int i=0;i<mmessageversions.size();++i)
|
||||
msgids.push_back(std::make_pair(groupid(),mmessageversions[i])) ;
|
||||
|
||||
msgIds.push_back(std::make_pair(groupId(),messageId()));
|
||||
msgids.push_back(std::make_pair(groupid(),messageid()));
|
||||
|
||||
uint32_t token;
|
||||
mLoadQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeComment);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void GxsFeedItem::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
@ -195,3 +206,4 @@ bool GxsFeedItem::isLoading()
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -45,15 +45,17 @@ protected:
|
||||
void requestComment();
|
||||
|
||||
virtual QString messageName() = 0;
|
||||
virtual void loadMessage(const uint32_t &token) = 0;
|
||||
virtual void loadComment(const uint32_t &token) = 0;
|
||||
virtual void loadMessage() = 0;
|
||||
virtual void loadComment() = 0;
|
||||
|
||||
/* GxsGroupFeedItem */
|
||||
virtual bool isLoading();
|
||||
//virtual bool isLoading();
|
||||
//virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete);
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
/* TokenResponse */
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
#endif
|
||||
|
||||
protected slots:
|
||||
void comments(const QString &title);
|
||||
|
@ -45,21 +45,6 @@ GxsGroupFeedItem::GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, cons
|
||||
/* load data if we can */
|
||||
mGroupId = groupId;
|
||||
mGxsIface = iface;
|
||||
|
||||
mNextTokenType = 0;
|
||||
mTokenTypeGroup = nextTokenType();
|
||||
|
||||
mLoadQueue = NULL;
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
if (mGxsIface && autoUpdate) {
|
||||
/* Connect to update broadcast */
|
||||
mUpdateBroadcastBase = new RsGxsUpdateBroadcastBase(mGxsIface);
|
||||
connect(mUpdateBroadcastBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplaySlot(bool)));
|
||||
} else {
|
||||
mUpdateBroadcastBase = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
GxsGroupFeedItem::~GxsGroupFeedItem()
|
||||
@ -69,30 +54,6 @@ GxsGroupFeedItem::~GxsGroupFeedItem()
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (mLoadQueue) {
|
||||
delete mLoadQueue;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
if (mUpdateBroadcastBase)
|
||||
{
|
||||
delete(mUpdateBroadcastBase);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GxsGroupFeedItem::initLoadQueue()
|
||||
{
|
||||
if (mLoadQueue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mGxsIface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mLoadQueue = new TokenQueue(mGxsIface->getTokenService(), this);
|
||||
return (mLoadQueue != NULL);
|
||||
}
|
||||
|
||||
void GxsGroupFeedItem::unsubscribe()
|
||||
@ -144,69 +105,12 @@ void GxsGroupFeedItem::copyGroupLink()
|
||||
void GxsGroupFeedItem::fillDisplaySlot(bool complete)
|
||||
{
|
||||
requestGroup();
|
||||
// fillDisplay(mUpdateBroadcastBase, complete);
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void GxsGroupFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool /*complete*/)
|
||||
{
|
||||
std::set<RsGxsGroupId> grpIds;
|
||||
updateBroadcastBase->getAllGrpIds(grpIds);
|
||||
|
||||
if (grpIds.find(groupId()) != grpIds.end())
|
||||
requestGroup();
|
||||
}
|
||||
#endif
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
void GxsGroupFeedItem::requestGroup()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsGroupFeedItem::requestGroup()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (!initLoadQueue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mLoadQueue->activeRequestExist(mTokenTypeGroup)) {
|
||||
/* Request already running */
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<RsGxsGroupId> ids;
|
||||
ids.push_back(mGroupId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
uint32_t token;
|
||||
mLoadQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, ids, mTokenTypeGroup);
|
||||
loadGroup();
|
||||
}
|
||||
|
||||
void GxsGroupFeedItem::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "GxsGroupFeedItem::loadRequest()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (queue == mLoadQueue) {
|
||||
if (req.mUserType == mTokenTypeGroup) {
|
||||
loadGroup(req.mToken);
|
||||
} else {
|
||||
std::cerr << "GxsGroupFeedItem::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GxsGroupFeedItem::isLoading()
|
||||
{
|
||||
if (mLoadQueue && mLoadQueue->activeRequestExist(mTokenTypeGroup)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include <retroshare/rsgxsifacehelper.h>
|
||||
#include "gui/feeds/FeedItem.h"
|
||||
#include "util/TokenQueue.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
|
||||
#include <stdint.h>
|
||||
@ -33,7 +32,7 @@
|
||||
class FeedHolder;
|
||||
class RsGxsUpdateBroadcastBase;
|
||||
|
||||
class GxsGroupFeedItem : public FeedItem, public TokenResponse
|
||||
class GxsGroupFeedItem : public FeedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -46,20 +45,12 @@ public:
|
||||
uint32_t feedId() const { return mFeedId; }
|
||||
|
||||
protected:
|
||||
uint32_t nextTokenType() { return ++mNextTokenType; }
|
||||
bool initLoadQueue();
|
||||
|
||||
/* load group data */
|
||||
void requestGroup();
|
||||
|
||||
virtual bool isLoading();
|
||||
virtual void loadGroup(const uint32_t &token) = 0;
|
||||
virtual void loadGroup() = 0;
|
||||
virtual RetroShareLink::enumType getLinkType() = 0;
|
||||
virtual QString groupName() = 0;
|
||||
//virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete);
|
||||
|
||||
/* TokenResponse */
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
protected slots:
|
||||
void subscribe();
|
||||
@ -69,7 +60,6 @@ protected slots:
|
||||
protected:
|
||||
bool mIsHome;
|
||||
RsGxsIfaceHelper *mGxsIface;
|
||||
TokenQueue *mLoadQueue;
|
||||
|
||||
private slots:
|
||||
/* RsGxsUpdateBroadcastBase */
|
||||
@ -77,9 +67,6 @@ private slots:
|
||||
|
||||
private:
|
||||
RsGxsGroupId mGroupId;
|
||||
// RsGxsUpdateBroadcastBase *mUpdateBroadcastBase;
|
||||
uint32_t mNextTokenType;
|
||||
uint32_t mTokenTypeGroup;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(RsGxsGroupId)
|
||||
|
@ -221,50 +221,11 @@ bool GxsIdChooser::isInConstraintSet(const RsGxsId& id) const
|
||||
void GxsIdChooser::setEntryEnabled(int indx,bool /*enabled*/)
|
||||
{
|
||||
removeItem(indx) ;
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
// bool disable = !enabled ;
|
||||
//
|
||||
// QSortFilterProxyModel* model = qobject_cast<QSortFilterProxyModel*>(QComboBox::model());
|
||||
// //QStandardItem* item = model->item(index);
|
||||
//
|
||||
// QModelIndex ii = model->index(indx,0);
|
||||
//
|
||||
// // visually disable by greying out - works only if combobox has been painted already and palette returns the wanted color
|
||||
// //model->setFlags(ii,disable ? (model->flags(ii) & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled)) : (Qt::ItemIsSelectable|Qt::ItemIsEnabled));
|
||||
//
|
||||
// uint32_t v = enabled?(1|32):(0);
|
||||
//
|
||||
// std::cerr << "GxsIdChooser::setEnabledEntry: i=" << indx << ", v=" << v << std::endl;
|
||||
//
|
||||
// // clear item data in order to use default color
|
||||
// //model->setData(ii,disable ? (QComboBox::palette().color(QPalette::Disabled, QPalette::Text)) : QVariant(), Qt::TextColorRole);
|
||||
// model->setData(ii,QVariant(v),Qt::UserRole-1) ;
|
||||
//
|
||||
// std::cerr << "model data after operation: " << model->data(ii,Qt::UserRole-1).toUInt() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t GxsIdChooser::countEnabledEntries() const
|
||||
{
|
||||
return count() ;
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
// uint32_t res = 0 ;
|
||||
// QSortFilterProxyModel* model = qobject_cast<QSortFilterProxyModel*>(QComboBox::model());
|
||||
//
|
||||
// for(uint32_t i=0;i<model->rowCount();++i)
|
||||
// {
|
||||
// QModelIndex ii = model->index(i,0);
|
||||
// uint32_t v = model->data(ii,Qt::UserRole-1).toUInt() ;
|
||||
//
|
||||
// std::cerr << "GxsIdChooser::countEnabledEntries(): i=" << i << ", v=" << v << std::endl;
|
||||
// if(v > 0)
|
||||
// ++res ;
|
||||
// }
|
||||
//
|
||||
// return res ;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsIdChooser::loadPrivateIds()
|
||||
|
@ -263,19 +263,17 @@ void GxsIdTreeItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
||||
launchAsyncLoading();
|
||||
}
|
||||
|
||||
QPixmap pix = icon.pixmap(r.size());
|
||||
QRect pixmaprect(r);
|
||||
pixmaprect.adjust(r.height(),0,0,0);
|
||||
|
||||
QPixmap pix = icon.pixmap(pixmaprect.size());
|
||||
const QPoint p = QPoint(r.height()/2.0, (r.height() - pix.height())/2);
|
||||
|
||||
// draw pixmap at center of item
|
||||
painter->drawPixmap(r.topLeft() + p, pix);
|
||||
//painter->drawText(r.topLeft() + QPoint(r.height()+ f/2.0 + f/2.0,f*1.0), str);
|
||||
|
||||
//cr.adjust(margin(), margin(), -margin(), -margin());
|
||||
|
||||
QRect mRectElision;
|
||||
|
||||
r.adjust(pix.height()+f,(r.height()-f)/2.0,0,0);
|
||||
|
||||
bool didElide = ElidedLabel::paintElidedLine(*painter,str,r,Qt::AlignLeft,false,false,mRectElision);
|
||||
|
||||
}
|
||||
|
@ -106,35 +106,6 @@ void GxsMessageFramePostWidget::updateDisplay(bool complete)
|
||||
if (groupId().isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
bool updateGroup = false;
|
||||
const std::set<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
|
||||
|
||||
if(grpIdsMeta.find(groupId())!=grpIdsMeta.end())
|
||||
updateGroup = true;
|
||||
|
||||
const std::set<RsGxsGroupId> &grpIds = getGrpIds();
|
||||
if (!groupId().isNull() && grpIds.find(groupId())!=grpIds.end())
|
||||
{
|
||||
updateGroup = true;
|
||||
/* Do we need to fill all posts? */
|
||||
requestAllPosts();
|
||||
} else {
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgs;
|
||||
getAllMsgIds(msgs);
|
||||
if (!msgs.empty()) {
|
||||
auto mit = msgs.find(groupId());
|
||||
if (mit != msgs.end()) {
|
||||
requestPosts(mit->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateGroup) {
|
||||
requestGroupData();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::fillThreadAddPost(const QVariant &post, bool related, int current, int count)
|
||||
|
@ -184,95 +184,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class AuthorItemDelegate: public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
AuthorItemDelegate() {}
|
||||
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
|
||||
{
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
|
||||
// disable default icon
|
||||
opt.icon = QIcon();
|
||||
const QRect r = option.rect;
|
||||
|
||||
RsGxsId id(index.data(Qt::UserRole).toString().toStdString());
|
||||
QString str;
|
||||
QList<QIcon> icons;
|
||||
QString comment;
|
||||
|
||||
QFontMetricsF fm(option.font);
|
||||
float f = fm.height();
|
||||
|
||||
QIcon icon ;
|
||||
|
||||
if(!GxsIdDetails::MakeIdDesc(id, true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
|
||||
icon = GxsIdDetails::getLoadingIcon(id);
|
||||
else
|
||||
icon = *icons.begin();
|
||||
|
||||
QPixmap pix = icon.pixmap(r.size());
|
||||
|
||||
return QSize(1.2*(pix.width() + fm.width(str)),std::max(1.1*pix.height(),1.4*fm.height()));
|
||||
}
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const override
|
||||
{
|
||||
if(!index.isValid())
|
||||
{
|
||||
std::cerr << "(EE) attempt to draw an invalid index." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
|
||||
// disable default icon
|
||||
opt.icon = QIcon();
|
||||
// draw default item
|
||||
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, 0);
|
||||
|
||||
const QRect r = option.rect;
|
||||
|
||||
RsGxsId id(index.data(Qt::UserRole).toString().toStdString());
|
||||
QString str;
|
||||
QList<QIcon> icons;
|
||||
QString comment;
|
||||
|
||||
QFontMetricsF fm(painter->font());
|
||||
float f = fm.height();
|
||||
|
||||
QIcon icon ;
|
||||
|
||||
if(!GxsIdDetails::MakeIdDesc(id, true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
|
||||
icon = GxsIdDetails::getLoadingIcon(id);
|
||||
else
|
||||
icon = *icons.begin();
|
||||
|
||||
unsigned int warning_level = qvariant_cast<unsigned int>(index.sibling(index.row(),RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION).data(Qt::DecorationRole));
|
||||
|
||||
if(warning_level == 2)
|
||||
{
|
||||
str = tr("[Banned]");
|
||||
icon = QIcon(IMAGE_BIOHAZARD);
|
||||
}
|
||||
|
||||
if(index.data(RsGxsForumModel::MissingRole).toBool())
|
||||
painter->drawText(r.topLeft() + QPoint(f/2.0,f*1.0), tr("[None]"));
|
||||
else
|
||||
{
|
||||
QPixmap pix = icon.pixmap(r.size());
|
||||
const QPoint p = QPoint(r.height()/2.0, (r.height() - pix.height())/2);
|
||||
|
||||
// draw pixmap at center of item
|
||||
painter->drawPixmap(r.topLeft() + p, pix);
|
||||
painter->drawText(r.topLeft() + QPoint(r.height()+ f/2.0 + f/2.0,f*1.0), str);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class ForumPostSortFilterProxyModel: public QSortFilterProxyModel
|
||||
{
|
||||
public:
|
||||
@ -331,7 +242,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
||||
ui->threadTreeWidget->setSortingEnabled(true);
|
||||
|
||||
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION,new DistributionItemDelegate()) ;
|
||||
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_AUTHOR,new AuthorItemDelegate()) ;
|
||||
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_AUTHOR,new GxsIdTreeItemDelegate()) ;
|
||||
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_READ,new ReadStatusItemDelegate()) ;
|
||||
|
||||
ui->threadTreeWidget->header()->setSortIndicatorShown(true);
|
||||
@ -570,55 +481,6 @@ QIcon GxsForumThreadWidget::groupIcon()
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void GxsForumThreadWidget::changeEvent(QEvent *e)
|
||||
{
|
||||
RsGxsUpdateBroadcastWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::StyleChange:
|
||||
//calculateIconsAndFonts();
|
||||
break;
|
||||
default:
|
||||
// remove compiler warnings
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void removeMessages(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds, QList<RsGxsMessageId> &removeMsgId)
|
||||
{
|
||||
QList<RsGxsMessageId> removedMsgId;
|
||||
|
||||
for (auto grpIt = msgIds.begin(); grpIt != msgIds.end(); )
|
||||
{
|
||||
std::set<RsGxsMessageId> &msgs = grpIt->second;
|
||||
|
||||
QList<RsGxsMessageId>::const_iterator removeMsgIt;
|
||||
for (removeMsgIt = removeMsgId.begin(); removeMsgIt != removeMsgId.end(); ++removeMsgIt) {
|
||||
if(msgs.find(*removeMsgIt) != msgs.end())
|
||||
{
|
||||
removedMsgId.push_back(*removeMsgIt);
|
||||
msgs.erase(*removeMsgIt);
|
||||
}
|
||||
}
|
||||
|
||||
if (msgs.empty()) {
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >::iterator grpItErase = grpIt++;
|
||||
msgIds.erase(grpItErase);
|
||||
} else {
|
||||
++grpIt;
|
||||
}
|
||||
}
|
||||
|
||||
if (!removedMsgId.isEmpty()) {
|
||||
QList<RsGxsMessageId>::const_iterator removedMsgIt;
|
||||
for (removedMsgIt = removedMsgId.begin(); removedMsgIt != removedMsgId.end(); ++removedMsgIt) {
|
||||
// remove first message id
|
||||
removeMsgId.removeOne(*removedMsgIt);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void GxsForumThreadWidget::saveExpandedItems(QList<RsGxsMessageId>& expanded_items) const
|
||||
{
|
||||
expanded_items.clear();
|
||||
@ -654,16 +516,6 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "udateDisplay: groupId()=" << groupId()<< std::endl;
|
||||
#endif
|
||||
#ifdef TO_REMOVE
|
||||
if(mUpdating)
|
||||
{
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << " Already updating. Return!"<< std::endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(groupId().isNull())
|
||||
{
|
||||
#ifdef DEBUG_FORUMS
|
||||
@ -679,55 +531,6 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
|
||||
#endif
|
||||
complete = true;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
if(!complete)
|
||||
{
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << " checking changed group data and msgs"<< std::endl;
|
||||
#endif
|
||||
|
||||
const std::set<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
|
||||
|
||||
if(grpIdsMeta.find(groupId())!=grpIdsMeta.end())
|
||||
{
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << " grpMeta change. reloading!" << std::endl;
|
||||
#endif
|
||||
complete = true;
|
||||
}
|
||||
|
||||
const std::set<RsGxsGroupId> &grpIds = getGrpIds();
|
||||
|
||||
if (grpIds.find(groupId())!=grpIds.end())
|
||||
{
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << " grp data change. reloading!" << std::endl;
|
||||
#endif
|
||||
complete = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// retrieve the list of modified msg ids
|
||||
// if current group is listed in the map, reload the whole hierarchy
|
||||
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgIds;
|
||||
getAllMsgIds(msgIds);
|
||||
|
||||
// if (!mIgnoredMsgId.empty()) /* Filter ignored messages */
|
||||
// removeMessages(msgIds, mIgnoredMsgId);
|
||||
|
||||
if (msgIds.find(groupId()) != msgIds.end())
|
||||
{
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << " msg data change. reloading!" << std::endl;
|
||||
#endif
|
||||
complete=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(complete) // need to update the group data, reload the messages etc.
|
||||
{
|
||||
saveExpandedItems(mSavedExpandedMessages);
|
||||
@ -1303,27 +1106,6 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
|
||||
bool redacted =
|
||||
(overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
bool setToReadOnActive = Settings->getForumMsgSetToReadOnActivate();
|
||||
uint32_t status = msg.mMeta.mMsgStatus ;//item->data(RsGxsForumModel::COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
|
||||
|
||||
QModelIndex index = getCurrentIndex();
|
||||
if (IS_MSG_NEW(status)) {
|
||||
if (setToReadOnActive) {
|
||||
/* set to read */
|
||||
mThreadModel->setMsgReadStatus(mThreadProxyModel->mapToSource(index),true,false);
|
||||
} else {
|
||||
/* set to unread by user */
|
||||
mThreadModel->setMsgReadStatus(mThreadProxyModel->mapToSource(index),false,false);
|
||||
}
|
||||
} else {
|
||||
if (setToReadOnActive && IS_MSG_UNREAD(status)) {
|
||||
/* set to read */
|
||||
mThreadModel->setMsgReadStatus(mThreadProxyModel->mapToSource(index), true,false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ui->time_label->setText(DateTime::formatLongDateTime(msg.mMeta.mPublishTs));
|
||||
ui->by_label->setId(msg.mMeta.mAuthorId);
|
||||
ui->lineRight->show();
|
||||
|
Loading…
Reference in New Issue
Block a user