mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 14:12:43 -04:00
Merge pull request #1801 from csoler/v0.6-FT4
Removed most of Token system from FeedItems [rebase of PR 1798]
This commit is contained in:
commit
be4d812df2
31 changed files with 618 additions and 1260 deletions
|
@ -302,17 +302,17 @@ bool p3Posted::createPost(uint32_t &token, RsPostedPost &msg)
|
||||||
|
|
||||||
bool p3Posted::getBoardsInfo(
|
bool p3Posted::getBoardsInfo(
|
||||||
const std::list<RsGxsGroupId>& boardsIds,
|
const std::list<RsGxsGroupId>& boardsIds,
|
||||||
std::vector<RsPostedGroup>& channelsInfo )
|
std::vector<RsPostedGroup>& groupsInfo )
|
||||||
{
|
{
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||||
if( !requestGroupInfo(token, opts, boardsIds)
|
if( !requestGroupInfo(token, opts, boardsIds)
|
||||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
|| 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,
|
const std::set<RsGxsMessageId>& contentsIds,
|
||||||
std::vector<RsPostedPost>& posts,
|
std::vector<RsPostedPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments )
|
std::vector<RsGxsComment>& comments )
|
||||||
|
@ -322,7 +322,7 @@ bool p3Posted::getBoardContent( const RsGxsGroupId& channelId,
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
|
|
||||||
GxsMsgReq msgIds;
|
GxsMsgReq msgIds;
|
||||||
msgIds[channelId] = contentsIds;
|
msgIds[groupId] = contentsIds;
|
||||||
|
|
||||||
if( !requestMsgInfo(token, opts, msgIds) ||
|
if( !requestMsgInfo(token, opts, msgIds) ||
|
||||||
waitToken(token) != RsTokenService::COMPLETE ) return false;
|
waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||||
|
|
|
@ -58,12 +58,10 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
|
||||||
return RsGxsIfaceHelper::receiveChanges(changes);
|
return RsGxsIfaceHelper::receiveChanges(changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getBoardsInfo(
|
bool getBoardsInfo(const std::list<RsGxsGroupId>& boardsIds,
|
||||||
const std::list<RsGxsGroupId>& boardsIds,
|
std::vector<RsPostedGroup>& groupsInfo ) override;
|
||||||
std::vector<RsPostedGroup>& channelsInfo ) override;
|
|
||||||
|
|
||||||
bool getBoardContent(
|
bool getBoardContent(const RsGxsGroupId& groupId,
|
||||||
const RsGxsGroupId& boardId,
|
|
||||||
const std::set<RsGxsMessageId>& contentsIds,
|
const std::set<RsGxsMessageId>& contentsIds,
|
||||||
std::vector<RsPostedPost>& posts,
|
std::vector<RsPostedPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments ) override;
|
std::vector<RsGxsComment>& comments ) override;
|
||||||
|
|
|
@ -484,46 +484,6 @@ void IdDialog::updateCirclesDisplay()
|
||||||
/************************** Request / Response *************************/
|
/************************** Request / Response *************************/
|
||||||
/*** Loading Main Index ***/
|
/*** 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()
|
void IdDialog::updateCircles()
|
||||||
{
|
{
|
||||||
RsThread::async([this]()
|
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;
|
std::cerr << " more than 1 item correspond to this ID. Removing!" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
delete clist.front() ;
|
delete clist.front() ;
|
||||||
|
clist.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
item = clist.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)
|
bool IdDialog::getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id)
|
||||||
{
|
{
|
||||||
#ifdef CIRCLE_MEMBERSHIP_CATEGORIES
|
#ifdef CIRCLE_MEMBERSHIP_CATEGORIES
|
||||||
|
@ -1044,7 +907,7 @@ void IdDialog::grantCircleMembership()
|
||||||
|
|
||||||
RsThread::async([circle_id,gxs_id_to_grant]()
|
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);
|
rsGxsCircles->inviteIdsToCircle(std::set<RsGxsId>( { gxs_id_to_grant } ),circle_id);
|
||||||
});
|
});
|
||||||
|
@ -2139,20 +2002,6 @@ void IdDialog::modifyReputation()
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#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.
|
// trigger refresh when finished.
|
||||||
// basic / anstype are not needed.
|
// basic / anstype are not needed.
|
||||||
updateIdentity();
|
updateIdentity();
|
||||||
|
@ -2197,17 +2046,6 @@ void IdDialog::updateDisplay(bool complete)
|
||||||
updateCircles();
|
updateCircles();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::set<RsGxsGroupId> grpIds;
|
|
||||||
// getAllGrpIds(grpIds);
|
|
||||||
// if (!getGrpIds().empty()) {
|
|
||||||
// requestIdList();
|
|
||||||
//
|
|
||||||
// if (!mId.isNull() && grpIds.find(mId)!=grpIds.end()) {
|
|
||||||
// requestIdDetails();
|
|
||||||
// requestRepList();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::addIdentity()
|
void IdDialog::addIdentity()
|
||||||
|
@ -2270,144 +2108,6 @@ void IdDialog::filterIds()
|
||||||
ui->idTreeWidget->filterItems(filterColumn, text);
|
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 )
|
void IdDialog::IdListCustomPopupMenu( QPoint )
|
||||||
{
|
{
|
||||||
QMenu *contextMenu = new QMenu(this);
|
QMenu *contextMenu = new QMenu(this);
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
|
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
|
|
||||||
#define IMAGE_IDDIALOG ":/icons/png/people.png"
|
#define IMAGE_IDDIALOG ":/icons/png/people.png"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "gui/feeds/FeedHolder.h"
|
#include "gui/feeds/FeedHolder.h"
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
|
|
||||||
#include "ui_PostedCardView.h"
|
#include "ui_PostedCardView.h"
|
||||||
|
@ -158,88 +159,134 @@ bool PostedCardView::setPost(const RsPostedPost &post, bool doFill)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedCardView::loadGroup(const uint32_t &token)
|
void PostedCardView::loadGroup()
|
||||||
{
|
{
|
||||||
std::vector<RsPostedGroup> groups;
|
RsThread::async([this]()
|
||||||
if (!rsPosted->getGroupData(token, groups))
|
|
||||||
{
|
{
|
||||||
std::cerr << "PostedCardView::loadGroup() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::vector<RsPostedGroup> groups;
|
||||||
|
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||||
|
|
||||||
|
if(!rsPosted->getBoardsInfo(groupIds,groups))
|
||||||
|
{
|
||||||
|
RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groups.size() != 1)
|
if (groups.size() != 1)
|
||||||
{
|
{
|
||||||
std::cerr << "PostedCardView::loadGroup() Wrong number of Items";
|
std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
RsPostedGroup group(groups[0]);
|
||||||
|
|
||||||
setGroup(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;
|
RsThread::async([this]()
|
||||||
std::vector<RsGxsComment> cmts;
|
|
||||||
if (!rsPosted->getPostData(token, posts, cmts))
|
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
|
std::vector<RsPostedPost> posts;
|
||||||
|
std::vector<RsGxsComment> comments;
|
||||||
|
|
||||||
|
if(! rsPosted->getBoardContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
|
||||||
|
{
|
||||||
|
RsErr() << "PostedItem::loadMessage() ERROR getting data" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (posts.size() == 1)
|
if (posts.size() == 1)
|
||||||
{
|
{
|
||||||
setPost(posts[0]);
|
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 (cmts.size() == 1)
|
else if(comments.size() == 1)
|
||||||
{
|
{
|
||||||
RsGxsComment cmt = cmts[0];
|
const RsGxsComment& cmt = comments[0];
|
||||||
|
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()));
|
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [cmt,this]()
|
||||||
|
{
|
||||||
//Change this item to be uploaded with thread element.
|
//Change this item to be uploaded with thread element.
|
||||||
setMessageId(cmt.mMeta.mThreadId);
|
setMessageId(cmt.mMeta.mThreadId);
|
||||||
requestMessage();
|
requestMessage();
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
removeItem();
|
|
||||||
return;
|
RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedCardView::loadComment(const uint32_t &token)
|
void PostedCardView::loadComment()
|
||||||
{
|
{
|
||||||
std::vector<RsGxsComment> cmts;
|
RsThread::async([this]()
|
||||||
if (!rsPosted->getRelatedComments(token, cmts))
|
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t comNb = cmts.size();
|
int comNb = comments.size();
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [comNb,this]()
|
||||||
|
{
|
||||||
QString sComButText = tr("Comment");
|
QString sComButText = tr("Comment");
|
||||||
if (comNb == 1) {
|
if (comNb == 1)
|
||||||
sComButText = sComButText.append("(1)");
|
sComButText = sComButText.append("(1)");
|
||||||
} else if (comNb > 1) {
|
else if(comNb > 1)
|
||||||
sComButText = " " + tr("Comments").append(" (%1)").arg(comNb);
|
sComButText = tr("Comments ").append("(%1)").arg(comNb);
|
||||||
}
|
|
||||||
ui->commentButton->setText(sComButText);
|
ui->commentButton->setText(sComButText);
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedCardView::fill()
|
void PostedCardView::fill()
|
||||||
{
|
{
|
||||||
if (isLoading()) {
|
// if (isLoading()) {
|
||||||
/* Wait for all requests */
|
// /* Wait for all requests */
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png");
|
QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png");
|
||||||
|
|
||||||
|
|
|
@ -69,13 +69,13 @@ signals:
|
||||||
protected:
|
protected:
|
||||||
/* GxsGroupFeedItem */
|
/* GxsGroupFeedItem */
|
||||||
virtual QString groupName();
|
virtual QString groupName();
|
||||||
virtual void loadGroup(const uint32_t &token);
|
virtual void loadGroup() override;
|
||||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
|
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
|
||||||
|
|
||||||
/* GxsFeedItem */
|
/* GxsFeedItem */
|
||||||
virtual QString messageName();
|
virtual QString messageName();
|
||||||
virtual void loadMessage(const uint32_t &token);
|
virtual void loadMessage();
|
||||||
virtual void loadComment(const uint32_t &token);
|
virtual void loadComment();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setup();
|
void setup();
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
#include "PhotoView.h"
|
#include "PhotoView.h"
|
||||||
#include "ui_PostedItem.h"
|
#include "ui_PostedItem.h"
|
||||||
|
@ -170,45 +171,74 @@ bool PostedItem::setPost(const RsPostedPost &post, bool doFill)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedItem::loadGroup(const uint32_t &token)
|
void PostedItem::loadGroup()
|
||||||
{
|
{
|
||||||
std::vector<RsPostedGroup> groups;
|
RsThread::async([this]()
|
||||||
if (!rsPosted->getGroupData(token, groups))
|
|
||||||
{
|
{
|
||||||
std::cerr << "PostedItem::loadGroup() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::vector<RsPostedGroup> groups;
|
||||||
|
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||||
|
|
||||||
|
if(!rsPosted->getBoardsInfo(groupIds,groups))
|
||||||
|
{
|
||||||
|
RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groups.size() != 1)
|
if (groups.size() != 1)
|
||||||
{
|
{
|
||||||
std::cerr << "PostedItem::loadGroup() Wrong number of Items";
|
std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
RsPostedGroup group(groups[0]);
|
||||||
|
|
||||||
setGroup(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;
|
RsThread::async([this]()
|
||||||
std::vector<RsGxsComment> cmts;
|
|
||||||
if (!rsPosted->getPostData(token, posts, cmts))
|
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
|
std::vector<RsPostedPost> posts;
|
||||||
|
std::vector<RsGxsComment> comments;
|
||||||
|
|
||||||
|
if(! rsPosted->getBoardContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
|
||||||
|
{
|
||||||
|
RsErr() << "PostedItem::loadMessage() ERROR getting data" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (posts.size() == 1)
|
if (posts.size() == 1)
|
||||||
{
|
{
|
||||||
setPost(posts[0]);
|
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
||||||
}
|
const RsPostedPost& post(posts[0]);
|
||||||
else if (cmts.size() == 1)
|
|
||||||
{
|
|
||||||
RsGxsComment cmt = cmts[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->newCommentLabel->show();
|
||||||
ui->commLabel->show();
|
ui->commLabel->show();
|
||||||
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
||||||
|
@ -216,43 +246,63 @@ void PostedItem::loadMessage(const uint32_t &token)
|
||||||
//Change this item to be uploaded with thread element.
|
//Change this item to be uploaded with thread element.
|
||||||
setMessageId(cmt.mMeta.mThreadId);
|
setMessageId(cmt.mMeta.mThreadId);
|
||||||
requestMessage();
|
requestMessage();
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
removeItem();
|
|
||||||
return;
|
RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedItem::loadComment(const uint32_t &token)
|
void PostedItem::loadComment()
|
||||||
{
|
{
|
||||||
std::vector<RsGxsComment> cmts;
|
#ifdef DEBUG_ITEM
|
||||||
if (!rsPosted->getRelatedComments(token, cmts))
|
std::cerr << "GxsChannelPostItem::loadComment()";
|
||||||
{
|
|
||||||
std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data";
|
|
||||||
std::cerr << std::endl;
|
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<RsPostedPost> posts;
|
||||||
|
std::vector<RsGxsComment> comments;
|
||||||
|
|
||||||
|
if(! rsPosted->getBoardContent( groupId(),msgIds,posts,comments))
|
||||||
|
{
|
||||||
|
RsErr() << "PostedItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t comNb = cmts.size();
|
int comNb = comments.size();
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [comNb,this]()
|
||||||
|
{
|
||||||
QString sComButText = tr("Comment");
|
QString sComButText = tr("Comment");
|
||||||
if (comNb == 1) {
|
if (comNb == 1)
|
||||||
sComButText = sComButText.append("(1)");
|
sComButText = sComButText.append("(1)");
|
||||||
} else if (comNb > 1) {
|
else if(comNb > 1)
|
||||||
sComButText = " " + tr("Comments").append(" (%1)").arg(comNb);
|
sComButText = tr("Comments ").append("(%1)").arg(comNb);
|
||||||
}
|
|
||||||
ui->commentButton->setText(sComButText);
|
ui->commentButton->setText(sComButText);
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedItem::fill()
|
void PostedItem::fill()
|
||||||
{
|
{
|
||||||
if (isLoading()) {
|
|
||||||
/* Wait for all requests */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroup.mMeta.mGroupId, groupName());
|
RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroup.mMeta.mGroupId, groupName());
|
||||||
ui->nameLabel->setText(link.toHtml());
|
ui->nameLabel->setText(link.toHtml());
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
bool setGroup(const RsPostedGroup& group, bool doFill = true);
|
bool setGroup(const RsPostedGroup& group, bool doFill = true);
|
||||||
bool setPost(const RsPostedPost& post, bool doFill = true);
|
bool setPost(const RsPostedPost& post, bool doFill = true);
|
||||||
|
|
||||||
const RsPostedPost &getPost() const;
|
const RsPostedPost& getPost() const;
|
||||||
RsPostedPost &post();
|
RsPostedPost &post();
|
||||||
|
|
||||||
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + messageId().toStdString()); }
|
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + messageId().toStdString()); }
|
||||||
|
@ -71,13 +71,14 @@ signals:
|
||||||
protected:
|
protected:
|
||||||
/* GxsGroupFeedItem */
|
/* GxsGroupFeedItem */
|
||||||
virtual QString groupName();
|
virtual QString groupName();
|
||||||
virtual void loadGroup(const uint32_t &token);
|
virtual void loadGroup() override;
|
||||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
|
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
|
||||||
|
|
||||||
/* GxsFeedItem */
|
/* GxsFeedItem */
|
||||||
virtual QString messageName();
|
virtual QString messageName();
|
||||||
virtual void loadMessage(const uint32_t &token);
|
|
||||||
virtual void loadComment(const uint32_t &token);
|
virtual void loadMessage();
|
||||||
|
virtual void loadComment();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setup();
|
void setup();
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#define POSTED_DEFAULT_LISTING_LENGTH 10
|
#define POSTED_DEFAULT_LISTING_LENGTH 10
|
||||||
#define POSTED_MAX_INDEX 10000
|
#define POSTED_MAX_INDEX 10000
|
||||||
|
|
||||||
#define DEBUG_POSTED_LIST_WIDGET
|
//#define DEBUG_POSTED_LIST_WIDGET
|
||||||
|
|
||||||
#define BOARD_DEFAULT_IMAGE ":/icons/png/posted.png"
|
#define BOARD_DEFAULT_IMAGE ":/icons/png/posted.png"
|
||||||
|
|
||||||
|
@ -714,35 +714,45 @@ void PostedListWidget::applyRanking()
|
||||||
|
|
||||||
foreach (PostedCardView *item, mPostCardView)
|
foreach (PostedCardView *item, mPostCardView)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::applyRanking() Item: " << item;
|
std::cerr << "PostedListWidget::applyRanking() Item: " << item;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (item->getPost().mMeta.mPublishTs < min_ts)
|
if (item->getPost().mMeta.mPublishTs < min_ts)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "\t Skipping OLD";
|
std::cerr << "\t Skipping OLD";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
item->hide();
|
item->hide();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counter >= mPostIndex + mPostShow)
|
if (counter >= mPostIndex + mPostShow)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "\t END - Counter too high";
|
std::cerr << "\t END - Counter too high";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
item->hide();
|
item->hide();
|
||||||
}
|
}
|
||||||
else if (counter >= mPostIndex)
|
else if (counter >= mPostIndex)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "\t Adding to Layout";
|
std::cerr << "\t Adding to Layout";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
/* add it in! */
|
/* add it in! */
|
||||||
cviewlayout->addWidget(item);
|
cviewlayout->addWidget(item);
|
||||||
item->show();
|
item->show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "\t Skipping to Low";
|
std::cerr << "\t Skipping to Low";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
item->hide();
|
item->hide();
|
||||||
}
|
}
|
||||||
++counter;
|
++counter;
|
||||||
|
|
|
@ -78,8 +78,7 @@
|
||||||
|
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
WikiDialog::WikiDialog(QWidget *parent)
|
WikiDialog::WikiDialog(QWidget *parent) : RsGxsUpdateBroadcastPage(rsWiki, parent)
|
||||||
: RsGxsUpdateBroadcastPage(rsWiki, parent)
|
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
|
@ -200,6 +200,7 @@ bool ElidedLabel::paintElidedLine(QPainter& painter,QString plainText,const QRec
|
||||||
iTransX = 0;
|
iTransX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(width+iTransX+cr.left() <= cr.right())
|
||||||
painter.drawText(QPoint(iTransX + cr.left(), y + fontMetrics.ascent() + cr.top()), elidedLastLine);
|
painter.drawText(QPoint(iTransX + cr.left(), y + fontMetrics.ascent() + cr.top()), elidedLastLine);
|
||||||
//Draw button to get ToolTip
|
//Draw button to get ToolTip
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "ui_GxsChannelGroupItem.h"
|
#include "ui_GxsChannelGroupItem.h"
|
||||||
|
|
||||||
#include "FeedHolder.h"
|
#include "FeedHolder.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "gui/NewsFeed.h"
|
#include "gui/NewsFeed.h"
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
|
|
||||||
|
@ -89,29 +90,39 @@ bool GxsChannelGroupItem::setGroup(const RsGxsChannelGroup &group)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelGroupItem::loadGroup(const uint32_t &token)
|
void GxsChannelGroupItem::loadGroup()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ITEM
|
RsThread::async([this]()
|
||||||
std::cerr << "GxsChannelGroupItem::loadGroup()";
|
{
|
||||||
std::cerr << std::endl;
|
// 1 - get group data
|
||||||
#endif
|
|
||||||
|
|
||||||
std::vector<RsGxsChannelGroup> groups;
|
std::vector<RsGxsChannelGroup> groups;
|
||||||
if (!rsGxsChannels->getGroupData(token, groups))
|
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||||
|
|
||||||
|
if(!rsGxsChannels->getChannelsInfo(groupIds,groups))
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelGroupItem::loadGroup() ERROR getting data";
|
RsErr() << "PostedItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groups.size() != 1)
|
if (groups.size() != 1)
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelGroupItem::loadGroup() Wrong number of Items";
|
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
RsGxsChannelGroup group(groups[0]);
|
||||||
|
|
||||||
setGroup(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()
|
QString GxsChannelGroupItem::groupName()
|
||||||
|
|
|
@ -48,7 +48,7 @@ protected:
|
||||||
|
|
||||||
/* GxsGroupFeedItem */
|
/* GxsGroupFeedItem */
|
||||||
virtual QString groupName();
|
virtual QString groupName();
|
||||||
virtual void loadGroup(const uint32_t &token);
|
virtual void loadGroup() override;
|
||||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
|
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "FeedHolder.h"
|
#include "FeedHolder.h"
|
||||||
#include "SubFileItem.h"
|
#include "SubFileItem.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
#include "util/DateTime.h"
|
#include "util/DateTime.h"
|
||||||
|
@ -230,57 +231,79 @@ void GxsChannelPostItem::loadComments()
|
||||||
comments(title);
|
comments(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostItem::loadGroup(const uint32_t &token)
|
void GxsChannelPostItem::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
|
||||||
|
|
||||||
std::vector<RsGxsChannelGroup> groups;
|
RsThread::async([this]()
|
||||||
if (!rsGxsChannels->getGroupData(token, groups))
|
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelGroupItem::loadGroup() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
|
std::vector<RsGxsChannelGroup> groups;
|
||||||
|
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||||
|
|
||||||
|
if(!rsGxsChannels->getChannelsInfo(groupIds,groups))
|
||||||
|
{
|
||||||
|
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groups.size() != 1)
|
if (groups.size() != 1)
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelGroupItem::loadGroup() Wrong number of Items";
|
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
RsGxsChannelGroup group(groups[0]);
|
||||||
|
|
||||||
setGroup(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
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage()";
|
std::cerr << "GxsChannelPostItem::loadMessage()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
RsThread::async([this]()
|
||||||
|
{
|
||||||
|
// 1 - get group data
|
||||||
|
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsChannelPost> posts;
|
||||||
std::vector<RsGxsComment> cmts;
|
std::vector<RsGxsComment> comments;
|
||||||
if (!rsGxsChannels->getPostData(token, posts, cmts))
|
|
||||||
|
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (posts.size() == 1)
|
if (posts.size() == 1)
|
||||||
{
|
{
|
||||||
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
||||||
setPost(posts[0]);
|
const RsGxsChannelPost& post(posts[0]);
|
||||||
}
|
|
||||||
else if (cmts.size() == 1)
|
|
||||||
{
|
|
||||||
RsGxsComment cmt = cmts[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;
|
std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl;
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [cmt,this]()
|
||||||
|
{
|
||||||
ui->newCommentLabel->show();
|
ui->newCommentLabel->show();
|
||||||
ui->commLabel->show();
|
ui->commLabel->show();
|
||||||
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
||||||
|
@ -288,49 +311,69 @@ void GxsChannelPostItem::loadMessage(const uint32_t &token)
|
||||||
//Change this item to be uploaded with thread element.
|
//Change this item to be uploaded with thread element.
|
||||||
setMessageId(cmt.mMeta.mThreadId);
|
setMessageId(cmt.mMeta.mThreadId);
|
||||||
requestMessage();
|
requestMessage();
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
removeItem();
|
|
||||||
return;
|
RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostItem::loadComment(const uint32_t &token)
|
void GxsChannelPostItem::loadComment()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ITEM
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsChannelPostItem::loadComment()";
|
std::cerr << "GxsChannelPostItem::loadComment()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<RsGxsComment> cmts;
|
RsThread::async([this]()
|
||||||
if (!rsGxsChannels->getRelatedComments(token, cmts))
|
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t comNb = cmts.size();
|
int comNb = comments.size();
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [comNb,this]()
|
||||||
|
{
|
||||||
QString sComButText = tr("Comment");
|
QString sComButText = tr("Comment");
|
||||||
if (comNb == 1) {
|
if (comNb == 1)
|
||||||
sComButText = sComButText.append("(1)");
|
sComButText = sComButText.append("(1)");
|
||||||
} else if (comNb > 1) {
|
else if(comNb > 1)
|
||||||
sComButText = tr("Comments ").append("(%1)").arg(comNb);
|
sComButText = tr("Comments ").append("(%1)").arg(comNb);
|
||||||
}
|
|
||||||
ui->commentButton->setText(sComButText);
|
ui->commentButton->setText(sComButText);
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostItem::fill()
|
void GxsChannelPostItem::fill()
|
||||||
{
|
{
|
||||||
/* fill in */
|
/* fill in */
|
||||||
|
|
||||||
if (isLoading()) {
|
// if (isLoading()) {
|
||||||
/* Wait for all requests */
|
// /* Wait for all requests */
|
||||||
return;
|
//return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
#ifdef DEBUG_ITEM
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsChannelPostItem::fill()";
|
std::cerr << "GxsChannelPostItem::fill()";
|
||||||
|
|
|
@ -81,13 +81,13 @@ protected:
|
||||||
|
|
||||||
/* GxsGroupFeedItem */
|
/* GxsGroupFeedItem */
|
||||||
virtual QString groupName();
|
virtual QString groupName();
|
||||||
virtual void loadGroup(const uint32_t &token);
|
virtual void loadGroup() override;
|
||||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
|
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
|
||||||
|
|
||||||
/* GxsFeedItem */
|
/* GxsFeedItem */
|
||||||
virtual QString messageName();
|
virtual QString messageName();
|
||||||
virtual void loadMessage(const uint32_t &token);
|
virtual void loadMessage();
|
||||||
virtual void loadComment(const uint32_t &token);
|
virtual void loadComment();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/* default stuff */
|
/* default stuff */
|
||||||
|
|
|
@ -45,7 +45,6 @@ GxsCircleItem::GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGx
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GxsCircleItem::~GxsCircleItem()
|
GxsCircleItem::~GxsCircleItem()
|
||||||
{
|
{
|
||||||
delete(ui);
|
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))
|
if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL))
|
||||||
pixmap = GxsIdDetails::makeDefaultIcon(mGxsId,GxsIdDetails::SMALL);
|
pixmap = GxsIdDetails::makeDefaultIcon(mGxsId,GxsIdDetails::SMALL);
|
||||||
|
|
||||||
|
|
||||||
/* update circle information */
|
/* update circle information */
|
||||||
|
|
||||||
RsGxsCircleDetails circleDetails;
|
RsGxsCircleDetails circleDetails;
|
||||||
|
@ -161,10 +159,6 @@ void GxsCircleItem::setup()
|
||||||
ui->gxsIdLabel->setText(idName);
|
ui->gxsIdLabel->setText(idName);
|
||||||
ui->gxsIdLabel->setId(mGxsId);
|
ui->gxsIdLabel->setId(mGxsId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup TokenQueue */
|
|
||||||
mCircleQueue = new TokenQueue(rsGxsCircles->getTokenService(), this);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GxsCircleItem::uniqueIdentifier() const
|
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());
|
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 ***********************/
|
/*********** SPECIFIC FUNCTIONS ***********************/
|
||||||
|
|
||||||
void GxsCircleItem::showCircleDetails()
|
void GxsCircleItem::showCircleDetails()
|
||||||
|
@ -219,92 +184,17 @@ void GxsCircleItem::acceptCircleSubscription()
|
||||||
|
|
||||||
void GxsCircleItem::grantCircleMembership()
|
void GxsCircleItem::grantCircleMembership()
|
||||||
{
|
{
|
||||||
|
RsThread::async([this]()
|
||||||
RsTokReqOptions opts;
|
{
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
rsGxsCircles->inviteIdsToCircle(std::set<RsGxsId>( { mGxsId } ),mCircleId);
|
||||||
|
});
|
||||||
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 ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsCircleItem::revokeCircleMembership()
|
void GxsCircleItem::revokeCircleMembership()
|
||||||
{
|
{
|
||||||
|
RsThread::async([this]()
|
||||||
RsTokReqOptions opts;
|
{
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
rsGxsCircles->revokeIdsFromCircle(std::set<RsGxsId>( { mGxsId } ),mCircleId);
|
||||||
|
});
|
||||||
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) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct CircleUpdateOrder
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class GxsCircleItem : public FeedItem, public TokenResponse
|
class GxsCircleItem : public FeedItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -78,10 +78,6 @@ private:
|
||||||
RsGxsCircleId mCircleId;
|
RsGxsCircleId mCircleId;
|
||||||
RsGxsId mGxsId;
|
RsGxsId mGxsId;
|
||||||
|
|
||||||
TokenQueue *mCircleQueue;
|
|
||||||
std::map<uint32_t, CircleUpdateOrder> mCircleUpdates ;
|
|
||||||
|
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::GxsCircleItem *ui;
|
Ui::GxsCircleItem *ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "FeedHolder.h"
|
#include "FeedHolder.h"
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
|
|
||||||
/****
|
/****
|
||||||
* #define DEBUG_ITEM 1
|
* #define DEBUG_ITEM 1
|
||||||
|
@ -87,18 +88,22 @@ bool GxsForumGroupItem::setGroup(const RsGxsForumGroup &group)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumGroupItem::loadGroup(const uint32_t &token)
|
void GxsForumGroupItem::loadGroup()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ITEM
|
RsThread::async([this]()
|
||||||
std::cerr << "GxsForumGroupItem::loadGroup()";
|
{
|
||||||
std::cerr << std::endl;
|
// 1 - get group data
|
||||||
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<RsGxsForumGroup> groups;
|
std::vector<RsGxsForumGroup> groups;
|
||||||
if (!rsGxsForums->getGroupData(token, groups))
|
const std::list<RsGxsGroupId> forumIds = { groupId() };
|
||||||
|
|
||||||
|
if(!rsGxsForums->getForumsInfo(forumIds,groups))
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumGroupItem::loadGroup() ERROR getting data";
|
RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,8 +113,18 @@ void GxsForumGroupItem::loadGroup(const uint32_t &token)
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const RsGxsForumGroup& group(groups[0]);
|
||||||
|
|
||||||
setGroup(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()
|
QString GxsForumGroupItem::groupName()
|
||||||
|
|
|
@ -50,7 +50,7 @@ protected:
|
||||||
|
|
||||||
/* GxsGroupFeedItem */
|
/* GxsGroupFeedItem */
|
||||||
virtual QString groupName();
|
virtual QString groupName();
|
||||||
virtual void loadGroup(const uint32_t &token);
|
virtual void loadGroup() override;
|
||||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
|
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "util/DateTime.h"
|
#include "util/DateTime.h"
|
||||||
|
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
@ -94,7 +95,6 @@ void GxsForumMsgItem::setup()
|
||||||
|
|
||||||
mInFill = false;
|
mInFill = false;
|
||||||
mCloseOnRead = false;
|
mCloseOnRead = false;
|
||||||
mTokenTypeParentMessage = nextTokenType();
|
|
||||||
|
|
||||||
/* clear ui */
|
/* clear ui */
|
||||||
ui->titleLabel->setText(tr("Loading"));
|
ui->titleLabel->setText(tr("Loading"));
|
||||||
|
@ -154,13 +154,10 @@ bool GxsForumMsgItem::setMessage(const RsGxsForumMsg &msg, bool doFill)
|
||||||
|
|
||||||
mMessage = msg;
|
mMessage = msg;
|
||||||
|
|
||||||
if (!isTop()) {
|
if (!isTop())
|
||||||
requestParentMessage(mMessage.mMeta.mParentId);
|
loadParentMessage(mMessage.mMeta.mParentId);
|
||||||
} else {
|
else if(doFill)
|
||||||
if (doFill) {
|
|
||||||
fill();
|
fill();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -170,18 +167,22 @@ QString GxsForumMsgItem::groupName()
|
||||||
return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str());
|
return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumMsgItem::loadGroup(const uint32_t &token)
|
void GxsForumMsgItem::loadGroup()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ITEM
|
RsThread::async([this]()
|
||||||
std::cerr << "GxsForumGroupItem::loadGroup()";
|
{
|
||||||
std::cerr << std::endl;
|
// 1 - get group data
|
||||||
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<RsGxsForumGroup> groups;
|
std::vector<RsGxsForumGroup> groups;
|
||||||
if (!rsGxsForums->getGroupData(token, groups))
|
const std::list<RsGxsGroupId> forumIds = { groupId() };
|
||||||
|
|
||||||
|
if(!rsGxsForums->getForumsInfo(forumIds,groups))
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumGroupItem::loadGroup() ERROR getting data";
|
RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,19 +192,39 @@ void GxsForumMsgItem::loadGroup(const uint32_t &token)
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
RsGxsForumGroup group(groups[0]);
|
||||||
|
|
||||||
setGroup(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
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsForumMsgItem::loadMessage()";
|
std::cerr << "GxsForumMsgItem::loadMessage()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
RsThread::async([this]()
|
||||||
|
{
|
||||||
|
// 1 - get group data
|
||||||
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::vector<RsGxsForumMsg> msgs;
|
std::vector<RsGxsForumMsg> msgs;
|
||||||
if (!rsGxsForums->getMsgData(token, 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 << "GxsForumMsgItem::loadMessage() ERROR getting data";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -216,45 +237,74 @@ void GxsForumMsgItem::loadMessage(const uint32_t &token)
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const RsGxsForumMsg& msg(msgs[0]);
|
||||||
|
|
||||||
setMessage(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
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsForumMsgItem::loadParentMessage()";
|
std::cerr << "GxsForumMsgItem::loadParentMessage()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<RsGxsForumMsg> msgs;
|
RsThread::async([parent_msg,this]()
|
||||||
if (!rsGxsForums->getMsgData(token, msgs))
|
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumMsgItem::loadParentMessage() ERROR getting data";
|
// 1 - get group data
|
||||||
|
|
||||||
|
#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>( { parent_msg } ),msgs))
|
||||||
|
{
|
||||||
|
std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgs.size() != 1)
|
if (msgs.size() != 1)
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumMsgItem::loadParentMessage() Wrong number of Items";
|
std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const RsGxsForumMsg& msg(msgs[0]);
|
||||||
|
|
||||||
mParentMessage = 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();
|
fill();
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumMsgItem::fill()
|
void GxsForumMsgItem::fill()
|
||||||
{
|
{
|
||||||
/* fill in */
|
/* fill in */
|
||||||
|
|
||||||
if (isLoading()) {
|
// if (isLoading()) {
|
||||||
/* Wait for all requests */
|
// /* Wait for all requests */
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
#ifdef DEBUG_ITEM
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsForumMsgItem::fill()";
|
std::cerr << "GxsForumMsgItem::fill()";
|
||||||
|
@ -307,18 +357,6 @@ void GxsForumMsgItem::fill()
|
||||||
|
|
||||||
ui->nameLabel->setId(mMessage.mMeta.mAuthorId);
|
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());
|
RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_FORUM, mMessage.mMeta.mGroupId, mMessage.mMeta.mMsgId, messageName());
|
||||||
ui->subLabel->setText(msgLink.toHtml());
|
ui->subLabel->setText(msgLink.toHtml());
|
||||||
if (wasExpanded() || ui->expandFrame->isVisible()) {
|
if (wasExpanded() || ui->expandFrame->isVisible()) {
|
||||||
|
@ -330,7 +368,6 @@ void GxsForumMsgItem::fill()
|
||||||
if (isTop()) {
|
if (isTop()) {
|
||||||
ui->parentFrame->hide();
|
ui->parentFrame->hide();
|
||||||
} else {
|
} 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()));
|
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->parentSubLabel->setText(linkParent.toHtml());
|
||||||
|
@ -348,16 +385,6 @@ void GxsForumMsgItem::fill()
|
||||||
|
|
||||||
ui->parentAvatar->setPixmap(pixmap);
|
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 */
|
/* header stuff */
|
||||||
|
@ -440,63 +467,6 @@ void GxsForumMsgItem::setReadStatus(bool isNew, bool /*isUnread*/)
|
||||||
ui->frame->style()->polish( ui->frame);
|
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 ***********************/
|
/*********** SPECIFIC FUNCTIONS ***********************/
|
||||||
|
|
||||||
void GxsForumMsgItem::readAndClearItem()
|
void GxsForumMsgItem::readAndClearItem()
|
||||||
|
|
|
@ -50,20 +50,18 @@ protected:
|
||||||
virtual void expandFill(bool first);
|
virtual void expandFill(bool first);
|
||||||
|
|
||||||
/* load message data */
|
/* load message data */
|
||||||
void requestParentMessage(const RsGxsMessageId &msgId);
|
virtual void loadParentMessage(const RsGxsMessageId &parent_msg);
|
||||||
virtual void loadParentMessage(const uint32_t &token);
|
|
||||||
|
|
||||||
/* GxsGroupFeedItem */
|
/* GxsGroupFeedItem */
|
||||||
virtual QString groupName();
|
virtual QString groupName();
|
||||||
virtual void loadGroup(const uint32_t &token);
|
virtual void loadGroup() override;
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
||||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
|
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
|
||||||
virtual bool isLoading();
|
//virtual bool isLoading();
|
||||||
|
|
||||||
/* GxsFeedItem */
|
/* GxsFeedItem */
|
||||||
virtual QString messageName();
|
virtual QString messageName();
|
||||||
virtual void loadMessage(const uint32_t &token);
|
virtual void loadMessage() override;
|
||||||
virtual void loadComment(const uint32_t &/*token*/){ return;}
|
virtual void loadComment() override { return; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/* default stuff */
|
/* default stuff */
|
||||||
|
@ -90,7 +88,6 @@ private:
|
||||||
RsGxsForumGroup mGroup;
|
RsGxsForumGroup mGroup;
|
||||||
RsGxsForumMsg mMessage;
|
RsGxsForumMsg mMessage;
|
||||||
RsGxsForumMsg mParentMessage;
|
RsGxsForumMsg mParentMessage;
|
||||||
uint32_t mTokenTypeParentMessage;
|
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::GxsForumMsgItem *ui;
|
Ui::GxsForumMsgItem *ui;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "ui_PostedGroupItem.h"
|
#include "ui_PostedGroupItem.h"
|
||||||
|
|
||||||
#include "FeedHolder.h"
|
#include "FeedHolder.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
|
|
||||||
|
@ -90,29 +91,43 @@ bool PostedGroupItem::setGroup(const RsPostedGroup &group)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedGroupItem::loadGroup(const uint32_t &token)
|
void PostedGroupItem::loadGroup()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ITEM
|
RsThread::async([this]()
|
||||||
std::cerr << "PostedGroupItem::loadGroup()";
|
{
|
||||||
std::cerr << std::endl;
|
// 1 - get group data
|
||||||
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<RsPostedGroup> groups;
|
std::vector<RsPostedGroup> groups;
|
||||||
if (!rsPosted->getGroupData(token, groups))
|
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||||
|
|
||||||
|
if(!rsPosted->getBoardsInfo(groupIds,groups))
|
||||||
{
|
{
|
||||||
std::cerr << "PostedGroupItem::loadGroup() ERROR getting data";
|
RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groups.size() != 1)
|
if (groups.size() != 1)
|
||||||
{
|
{
|
||||||
std::cerr << "PostedGroupItem::loadGroup() Wrong number of Items";
|
std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
RsPostedGroup group(groups[0]);
|
||||||
|
|
||||||
setGroup(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()
|
QString PostedGroupItem::groupName()
|
||||||
|
|
|
@ -50,7 +50,7 @@ protected:
|
||||||
|
|
||||||
/* GxsGroupFeedItem */
|
/* GxsGroupFeedItem */
|
||||||
virtual QString groupName();
|
virtual QString groupName();
|
||||||
virtual void loadGroup(const uint32_t &token);
|
virtual void loadGroup() override;
|
||||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
|
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -40,8 +40,10 @@ GxsFeedItem::GxsFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGro
|
||||||
/* load data if we can */
|
/* load data if we can */
|
||||||
mMessageId = messageId;
|
mMessageId = messageId;
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
mTokenTypeMessage = nextTokenType();
|
mTokenTypeMessage = nextTokenType();
|
||||||
mTokenTypeComment = nextTokenType();
|
mTokenTypeComment = nextTokenType();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsFeedItem::~GxsFeedItem()
|
GxsFeedItem::~GxsFeedItem()
|
||||||
|
@ -106,6 +108,8 @@ void GxsFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, boo
|
||||||
|
|
||||||
void GxsFeedItem::requestMessage()
|
void GxsFeedItem::requestMessage()
|
||||||
{
|
{
|
||||||
|
loadMessage();
|
||||||
|
#ifdef TO_REMOVE
|
||||||
#ifdef DEBUG_ITEM
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsFeedItem::requestMessage()";
|
std::cerr << "GxsFeedItem::requestMessage()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -129,15 +133,19 @@ void GxsFeedItem::requestMessage()
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeMessage);
|
mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeMessage);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsFeedItem::requestComment()
|
void GxsFeedItem::requestComment()
|
||||||
{
|
{
|
||||||
|
loadComment();
|
||||||
|
#ifdef TO_REMOVE
|
||||||
#ifdef DEBUG_ITEM
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsFeedItem::requestComment()";
|
std::cerr << "GxsFeedItem::requestComment()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
if (!initLoadQueue()) {
|
if (!initLoadQueue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -146,6 +154,7 @@ void GxsFeedItem::requestComment()
|
||||||
/* Request already running */
|
/* Request already running */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||||
|
@ -153,15 +162,17 @@ void GxsFeedItem::requestComment()
|
||||||
|
|
||||||
std::vector<RsGxsGrpMsgIdPair> msgIds;
|
std::vector<RsGxsGrpMsgIdPair> msgIds;
|
||||||
|
|
||||||
for(int i=0;i<mMessageVersions.size();++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(),mmessageversions[i])) ;
|
||||||
|
|
||||||
msgIds.push_back(std::make_pair(groupId(),messageId()));
|
msgids.push_back(std::make_pair(groupid(),messageid()));
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mLoadQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeComment);
|
mLoadQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeComment);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
void GxsFeedItem::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
void GxsFeedItem::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ITEM
|
#ifdef DEBUG_ITEM
|
||||||
|
@ -195,3 +206,4 @@ bool GxsFeedItem::isLoading()
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -45,15 +45,17 @@ protected:
|
||||||
void requestComment();
|
void requestComment();
|
||||||
|
|
||||||
virtual QString messageName() = 0;
|
virtual QString messageName() = 0;
|
||||||
virtual void loadMessage(const uint32_t &token) = 0;
|
virtual void loadMessage() = 0;
|
||||||
virtual void loadComment(const uint32_t &token) = 0;
|
virtual void loadComment() = 0;
|
||||||
|
|
||||||
/* GxsGroupFeedItem */
|
/* GxsGroupFeedItem */
|
||||||
virtual bool isLoading();
|
//virtual bool isLoading();
|
||||||
//virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete);
|
//virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete);
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
/* TokenResponse */
|
/* TokenResponse */
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||||
|
#endif
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void comments(const QString &title);
|
void comments(const QString &title);
|
||||||
|
|
|
@ -45,21 +45,6 @@ GxsGroupFeedItem::GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, cons
|
||||||
/* load data if we can */
|
/* load data if we can */
|
||||||
mGroupId = groupId;
|
mGroupId = groupId;
|
||||||
mGxsIface = iface;
|
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()
|
GxsGroupFeedItem::~GxsGroupFeedItem()
|
||||||
|
@ -69,30 +54,6 @@ GxsGroupFeedItem::~GxsGroupFeedItem()
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#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()
|
void GxsGroupFeedItem::unsubscribe()
|
||||||
|
@ -144,69 +105,12 @@ void GxsGroupFeedItem::copyGroupLink()
|
||||||
void GxsGroupFeedItem::fillDisplaySlot(bool complete)
|
void GxsGroupFeedItem::fillDisplaySlot(bool complete)
|
||||||
{
|
{
|
||||||
requestGroup();
|
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()
|
void GxsGroupFeedItem::requestGroup()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ITEM
|
loadGroup();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 <retroshare/rsgxsifacehelper.h>
|
||||||
#include "gui/feeds/FeedItem.h"
|
#include "gui/feeds/FeedItem.h"
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -33,7 +32,7 @@
|
||||||
class FeedHolder;
|
class FeedHolder;
|
||||||
class RsGxsUpdateBroadcastBase;
|
class RsGxsUpdateBroadcastBase;
|
||||||
|
|
||||||
class GxsGroupFeedItem : public FeedItem, public TokenResponse
|
class GxsGroupFeedItem : public FeedItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -46,20 +45,12 @@ public:
|
||||||
uint32_t feedId() const { return mFeedId; }
|
uint32_t feedId() const { return mFeedId; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32_t nextTokenType() { return ++mNextTokenType; }
|
|
||||||
bool initLoadQueue();
|
|
||||||
|
|
||||||
/* load group data */
|
/* load group data */
|
||||||
void requestGroup();
|
void requestGroup();
|
||||||
|
|
||||||
virtual bool isLoading();
|
virtual void loadGroup() = 0;
|
||||||
virtual void loadGroup(const uint32_t &token) = 0;
|
|
||||||
virtual RetroShareLink::enumType getLinkType() = 0;
|
virtual RetroShareLink::enumType getLinkType() = 0;
|
||||||
virtual QString groupName() = 0;
|
virtual QString groupName() = 0;
|
||||||
//virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete);
|
|
||||||
|
|
||||||
/* TokenResponse */
|
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void subscribe();
|
void subscribe();
|
||||||
|
@ -69,7 +60,6 @@ protected slots:
|
||||||
protected:
|
protected:
|
||||||
bool mIsHome;
|
bool mIsHome;
|
||||||
RsGxsIfaceHelper *mGxsIface;
|
RsGxsIfaceHelper *mGxsIface;
|
||||||
TokenQueue *mLoadQueue;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/* RsGxsUpdateBroadcastBase */
|
/* RsGxsUpdateBroadcastBase */
|
||||||
|
@ -77,9 +67,6 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RsGxsGroupId mGroupId;
|
RsGxsGroupId mGroupId;
|
||||||
// RsGxsUpdateBroadcastBase *mUpdateBroadcastBase;
|
|
||||||
uint32_t mNextTokenType;
|
|
||||||
uint32_t mTokenTypeGroup;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(RsGxsGroupId)
|
Q_DECLARE_METATYPE(RsGxsGroupId)
|
||||||
|
|
|
@ -221,50 +221,11 @@ bool GxsIdChooser::isInConstraintSet(const RsGxsId& id) const
|
||||||
void GxsIdChooser::setEntryEnabled(int indx,bool /*enabled*/)
|
void GxsIdChooser::setEntryEnabled(int indx,bool /*enabled*/)
|
||||||
{
|
{
|
||||||
removeItem(indx) ;
|
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
|
uint32_t GxsIdChooser::countEnabledEntries() const
|
||||||
{
|
{
|
||||||
return count() ;
|
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()
|
void GxsIdChooser::loadPrivateIds()
|
||||||
|
|
|
@ -263,19 +263,17 @@ void GxsIdTreeItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
||||||
launchAsyncLoading();
|
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);
|
const QPoint p = QPoint(r.height()/2.0, (r.height() - pix.height())/2);
|
||||||
|
|
||||||
// draw pixmap at center of item
|
// draw pixmap at center of item
|
||||||
painter->drawPixmap(r.topLeft() + p, pix);
|
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;
|
QRect mRectElision;
|
||||||
|
|
||||||
r.adjust(pix.height()+f,(r.height()-f)/2.0,0,0);
|
r.adjust(pix.height()+f,(r.height()-f)/2.0,0,0);
|
||||||
|
|
||||||
bool didElide = ElidedLabel::paintElidedLine(*painter,str,r,Qt::AlignLeft,false,false,mRectElision);
|
bool didElide = ElidedLabel::paintElidedLine(*painter,str,r,Qt::AlignLeft,false,false,mRectElision);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,35 +106,6 @@ void GxsMessageFramePostWidget::updateDisplay(bool complete)
|
||||||
if (groupId().isNull()) {
|
if (groupId().isNull()) {
|
||||||
return;
|
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)
|
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
|
class ForumPostSortFilterProxyModel: public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -331,7 +242,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
||||||
ui->threadTreeWidget->setSortingEnabled(true);
|
ui->threadTreeWidget->setSortingEnabled(true);
|
||||||
|
|
||||||
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION,new DistributionItemDelegate()) ;
|
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->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_READ,new ReadStatusItemDelegate()) ;
|
||||||
|
|
||||||
ui->threadTreeWidget->header()->setSortIndicatorShown(true);
|
ui->threadTreeWidget->header()->setSortIndicatorShown(true);
|
||||||
|
@ -570,55 +481,6 @@ QIcon GxsForumThreadWidget::groupIcon()
|
||||||
return QIcon();
|
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
|
void GxsForumThreadWidget::saveExpandedItems(QList<RsGxsMessageId>& expanded_items) const
|
||||||
{
|
{
|
||||||
expanded_items.clear();
|
expanded_items.clear();
|
||||||
|
@ -654,16 +516,6 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef DEBUG_FORUMS
|
||||||
std::cerr << "udateDisplay: groupId()=" << groupId()<< std::endl;
|
std::cerr << "udateDisplay: groupId()=" << groupId()<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
#ifdef TO_REMOVE
|
|
||||||
if(mUpdating)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_FORUMS
|
|
||||||
std::cerr << " Already updating. Return!"<< std::endl;
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(groupId().isNull())
|
if(groupId().isNull())
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef DEBUG_FORUMS
|
||||||
|
@ -679,55 +531,6 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
|
||||||
#endif
|
#endif
|
||||||
complete = true;
|
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.
|
if(complete) // need to update the group data, reload the messages etc.
|
||||||
{
|
{
|
||||||
saveExpandedItems(mSavedExpandedMessages);
|
saveExpandedItems(mSavedExpandedMessages);
|
||||||
|
@ -1303,27 +1106,6 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
|
||||||
bool redacted =
|
bool redacted =
|
||||||
(overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
|
(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->time_label->setText(DateTime::formatLongDateTime(msg.mMeta.mPublishTs));
|
||||||
ui->by_label->setId(msg.mMeta.mAuthorId);
|
ui->by_label->setId(msg.mMeta.mAuthorId);
|
||||||
ui->lineRight->show();
|
ui->lineRight->show();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue