mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
commit
8b079f8fdf
@ -60,6 +60,8 @@ public:
|
||||
|
||||
public:
|
||||
RsMsgMetaData mMeta;
|
||||
|
||||
std::set<RsGxsMessageId> mOlderVersions ;
|
||||
std::string mMsg; // UTF8 encoded.
|
||||
|
||||
std::list<RsGxsFile> mFiles;
|
||||
|
@ -1403,7 +1403,7 @@ void NewsFeed::openChat(const RsPeerId &peerId)
|
||||
ChatDialog::chatFriend(ChatId(peerId));
|
||||
}
|
||||
|
||||
void NewsFeed::openComments(uint32_t /*type*/, const RsGxsGroupId &/*groupId*/, const RsGxsMessageId &/*msgId*/, const QString &/*title*/)
|
||||
void NewsFeed::openComments(uint32_t /*type*/, const RsGxsGroupId &/*groupId*/, const QVector<RsGxsMessageId>& versions,const RsGxsMessageId &/*msgId*/, const QString &/*title*/)
|
||||
{
|
||||
std::cerr << "NewsFeed::openComments() Not Handled Yet";
|
||||
std::cerr << std::endl;
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
virtual QScrollArea *getScrollArea();
|
||||
virtual void deleteFeedItem(QWidget *item, uint32_t type);
|
||||
virtual void openChat(const RsPeerId& peerId);
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId> &versions, const RsGxsMessageId &msgId, const QString &title);
|
||||
|
||||
static void testFeeds(uint notifyFlags);
|
||||
static void testFeed(FeedNotify *feedNotify);
|
||||
|
@ -411,7 +411,13 @@ void PostedItem::loadComments()
|
||||
if (mFeedHolder)
|
||||
{
|
||||
QString title = QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
|
||||
mFeedHolder->openComments(0, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, title);
|
||||
|
||||
#warning (csoler) Posted item versions not handled yet. When it is the case, start here.
|
||||
|
||||
QVector<RsGxsMessageId> post_versions ;
|
||||
post_versions.push_back(mPost.mMeta.mMsgId) ;
|
||||
|
||||
mFeedHolder->openComments(0, mPost.mMeta.mGroupId, post_versions,mPost.mMeta.mMsgId, title);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,9 +139,9 @@ void PostedListWidget::openChat(const RsPeerId & /*peerId*/)
|
||||
return;
|
||||
}
|
||||
|
||||
void PostedListWidget::openComments(uint32_t /*feed_type*/, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title)
|
||||
void PostedListWidget::openComments(uint32_t /*feed_type*/, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId> &versions, const RsGxsMessageId &msgId, const QString &title)
|
||||
{
|
||||
emit loadComment(groupId, msgId, title);
|
||||
emit loadComment(groupId, versions,msgId, title);
|
||||
}
|
||||
|
||||
void PostedListWidget::newPost()
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
virtual QScrollArea *getScrollArea();
|
||||
virtual void deleteFeedItem(QWidget *item, uint32_t type);
|
||||
virtual void openChat(const RsPeerId& peerId);
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId> &versions, const RsGxsMessageId &msgId, const QString &title);
|
||||
|
||||
/* GXS functions */
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
virtual QScrollArea *getScrollArea() = 0;
|
||||
virtual void deleteFeedItem(QWidget *item, uint32_t type) = 0;
|
||||
virtual void openChat(const RsPeerId& peerId) = 0;
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title) = 0;
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId> &msg_versions, const RsGxsMessageId &msgId, const QString &title)=0;
|
||||
|
||||
// Workaround for QTBUG-3372
|
||||
void lockLayout(QWidget *feedItem, bool lock);
|
||||
|
@ -64,6 +64,21 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId,
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
QVector<RsGxsMessageId> v;
|
||||
bool self = false;
|
||||
|
||||
for(std::set<RsGxsMessageId>::const_iterator it(post.mOlderVersions.begin());it!=post.mOlderVersions.end();++it)
|
||||
{
|
||||
if(*it == post.mMeta.mMsgId)
|
||||
self = true ;
|
||||
|
||||
v.push_back(*it) ;
|
||||
}
|
||||
if(!self)
|
||||
v.push_back(post.mMeta.mMsgId);
|
||||
|
||||
setMessageVersions(v) ;
|
||||
|
||||
setup();
|
||||
|
||||
//setGroup(group, false);
|
||||
@ -310,7 +325,7 @@ void GxsChannelPostItem::loadComment(const uint32_t &token)
|
||||
if (comNb == 1) {
|
||||
sComButText = sComButText.append("(1)");
|
||||
} else if (comNb > 1) {
|
||||
sComButText = tr("Comments").append("(%1)").arg(comNb);
|
||||
sComButText = tr("Comments ").append("(%1)").arg(comNb);
|
||||
}
|
||||
ui->commentButton->setText(sComButText);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ void GxsCommentContainer::setup()
|
||||
ui.tabWidget->hideCloseButton(index);
|
||||
}
|
||||
|
||||
void GxsCommentContainer::commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title)
|
||||
void GxsCommentContainer::commentLoad(const RsGxsGroupId &grpId, const std::set<RsGxsMessageId>& msg_versions,const RsGxsMessageId &msgId, const QString &title)
|
||||
{
|
||||
QString comments = title;
|
||||
if (title.length() > MAX_COMMENT_TITLE)
|
||||
@ -68,7 +68,7 @@ void GxsCommentContainer::commentLoad(const RsGxsGroupId &grpId, const RsGxsMess
|
||||
QWidget *commentHeader = createHeaderWidget(grpId, msgId);
|
||||
commentDialog->setCommentHeader(commentHeader);
|
||||
|
||||
commentDialog->commentLoad(grpId, msgId);
|
||||
commentDialog->commentLoad(grpId, msg_versions, msgId);
|
||||
|
||||
ui.tabWidget->addTab(commentDialog, comments);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
GxsCommentContainer(QWidget *parent = 0);
|
||||
void setup();
|
||||
|
||||
void commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title);
|
||||
void commentLoad(const RsGxsGroupId &grpId, const std::set<RsGxsMessageId> &msg_versions, const RsGxsMessageId &msgId, const QString &title);
|
||||
|
||||
virtual GxsServiceDialog *createServiceDialog() = 0;
|
||||
virtual QString getServiceName() = 0;
|
||||
@ -67,9 +67,9 @@ public:
|
||||
|
||||
virtual ~GxsServiceDialog() { return; }
|
||||
|
||||
void commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title)
|
||||
void commentLoad(const RsGxsGroupId &grpId, const std::set<RsGxsMessageId>& msg_versions,const RsGxsMessageId &msgId, const QString &title)
|
||||
{
|
||||
mContainer->commentLoad(grpId, msgId, title);
|
||||
mContainer->commentLoad(grpId, msg_versions,msgId, title);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -59,20 +59,16 @@ GxsCommentDialog::~GxsCommentDialog()
|
||||
delete(ui);
|
||||
}
|
||||
|
||||
void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId)
|
||||
void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const std::set<RsGxsMessageId>& msg_versions,const RsGxsMessageId& most_recent_msgId)
|
||||
{
|
||||
std::cerr << "GxsCommentDialog::commentLoad(" << grpId << ", " << msgId << ")";
|
||||
std::cerr << "GxsCommentDialog::commentLoad(" << grpId << ", most recent msg version: " << most_recent_msgId << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mGrpId = grpId;
|
||||
mMsgId = msgId;
|
||||
mMostRecentMsgId = most_recent_msgId;
|
||||
mMsgVersions = msg_versions;
|
||||
|
||||
RsGxsGrpMsgIdPair threadId;
|
||||
|
||||
threadId.first = grpId;
|
||||
threadId.second = msgId;
|
||||
|
||||
ui->treeWidget->requestComments(threadId);
|
||||
ui->treeWidget->requestComments(mGrpId,msg_versions,most_recent_msgId);
|
||||
}
|
||||
|
||||
void GxsCommentDialog::refresh()
|
||||
@ -80,7 +76,7 @@ void GxsCommentDialog::refresh()
|
||||
std::cerr << "GxsCommentDialog::refresh()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
commentLoad(mGrpId, mMsgId);
|
||||
commentLoad(mGrpId, mMsgVersions,mMostRecentMsgId);
|
||||
}
|
||||
|
||||
void GxsCommentDialog::idChooserReady()
|
||||
|
@ -39,10 +39,10 @@ public:
|
||||
virtual ~GxsCommentDialog();
|
||||
|
||||
void setCommentHeader(QWidget *header);
|
||||
void commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
|
||||
void commentLoad(const RsGxsGroupId &grpId, const std::set<RsGxsMessageId> &msg_versions, const RsGxsMessageId &most_recent_msgId);
|
||||
|
||||
RsGxsGroupId groupId() { return mGrpId; }
|
||||
RsGxsMessageId messageId() { return mMsgId; }
|
||||
RsGxsMessageId messageId() { return mMostRecentMsgId; }
|
||||
|
||||
private slots:
|
||||
void refresh();
|
||||
@ -51,7 +51,8 @@ private slots:
|
||||
|
||||
private:
|
||||
RsGxsGroupId mGrpId;
|
||||
RsGxsMessageId mMsgId;
|
||||
RsGxsMessageId mMostRecentMsgId;
|
||||
std::set<RsGxsMessageId> mMsgVersions;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::GxsCommentDialog *ui;
|
||||
|
@ -50,11 +50,13 @@
|
||||
|
||||
#define COMMENT_VOTE_ACK 0x001234
|
||||
|
||||
#define POST_CELL_SIZE_ROLE (Qt::UserRole+1)
|
||||
#define POST_COLOR_ROLE (Qt::UserRole+2)
|
||||
|
||||
/* Images for context menu icons */
|
||||
#define IMAGE_MESSAGE ":/images/folder-draft.png"
|
||||
#define IMAGE_VOTEUP ":/images/vote_up.png"
|
||||
#define IMAGE_VOTEDOWN ":/images/vote_down.png"
|
||||
#define IMAGE_VOTEUP ":/images/vote_up.png"
|
||||
#define IMAGE_VOTEDOWN ":/images/vote_down.png"
|
||||
|
||||
// This class allows to draw the item using an appropriate size
|
||||
|
||||
@ -65,7 +67,7 @@ public:
|
||||
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
return index.data(Qt::UserRole+1).toSize() ;
|
||||
return index.data(POST_CELL_SIZE_ROLE).toSize() ;
|
||||
}
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
@ -96,11 +98,10 @@ public:
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QPainterPath path ;
|
||||
//path.addRoundedRect(QRectF(m/4.0f,m/4.0f,s.width()+m/2.0,s.height()+m/2.0),m,m) ;
|
||||
path.addRoundedRect(QRectF(m/7.0,m/7.0,s.width()+m/2.0,s.height()+m/2.0),m,m) ;
|
||||
path.addRoundedRect(QRectF(m/4.0,m/4.0,s.width()+m/2.0,s.height()+m/2.0),m,m) ;
|
||||
QPen pen(Qt::gray,m/7.0f);
|
||||
p.setPen(pen);
|
||||
p.fillPath(path,QColor::fromRgb(250,230,200)); // Would be nice to vary the color according to the post author
|
||||
p.fillPath(path,QColor::fromHsv( index.data(POST_COLOR_ROLE).toInt()/255.0*360,40,220)); // varies the color according to the post author
|
||||
p.drawPath(path);
|
||||
|
||||
QAbstractTextDocumentLayout::PaintContext ctx;
|
||||
@ -110,7 +111,7 @@ public:
|
||||
|
||||
painter->drawPixmap(r.topLeft(),px);
|
||||
|
||||
const_cast<QAbstractItemModel*>(index.model())->setData(index,px.size(),Qt::UserRole+1);
|
||||
const_cast<QAbstractItemModel*>(index.model())->setData(index,px.size(),POST_CELL_SIZE_ROLE);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -153,14 +154,14 @@ GxsCommentTreeWidget::~GxsCommentTreeWidget()
|
||||
}
|
||||
}
|
||||
|
||||
void GxsCommentTreeWidget::setCurrentMsgId(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
void GxsCommentTreeWidget::setCurrentCommentMsgId(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
{
|
||||
|
||||
Q_UNUSED(previous);
|
||||
|
||||
if(current)
|
||||
{
|
||||
mCurrentMsgId = RsGxsMessageId(current->text(PCITEM_COLUMN_MSGID).toStdString());
|
||||
mCurrentCommentMsgId = RsGxsMessageId(current->text(PCITEM_COLUMN_MSGID).toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,9 +169,9 @@ void GxsCommentTreeWidget::customPopUpMenu(const QPoint& /*point*/)
|
||||
{
|
||||
QMenu contextMnu( this );
|
||||
QAction* action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Reply to Comment"), this, SLOT(replyToComment()));
|
||||
action->setDisabled(mCurrentMsgId.isNull());
|
||||
action->setDisabled(mCurrentCommentMsgId.isNull());
|
||||
action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Submit Comment"), this, SLOT(makeComment()));
|
||||
action->setDisabled(mThreadId.first.isNull());
|
||||
action->setDisabled(mMsgVersions.empty());
|
||||
|
||||
contextMnu.addSeparator();
|
||||
|
||||
@ -180,7 +181,7 @@ void GxsCommentTreeWidget::customPopUpMenu(const QPoint& /*point*/)
|
||||
action->setDisabled(mVoterId.isNull());
|
||||
|
||||
|
||||
if (!mCurrentMsgId.isNull())
|
||||
if (!mCurrentCommentMsgId.isNull())
|
||||
{
|
||||
// not implemented yet
|
||||
/*
|
||||
@ -206,7 +207,8 @@ void GxsCommentTreeWidget::voteUp()
|
||||
{
|
||||
std::cerr << "GxsCommentTreeWidget::voteUp()";
|
||||
std::cerr << std::endl;
|
||||
vote(mThreadId.first, mThreadId.second, mCurrentMsgId, mVoterId, true);
|
||||
|
||||
vote(mGroupId, mLatestMsgId, mCurrentCommentMsgId, mVoterId, true);
|
||||
}
|
||||
|
||||
|
||||
@ -214,7 +216,8 @@ void GxsCommentTreeWidget::voteDown()
|
||||
{
|
||||
std::cerr << "GxsCommentTreeWidget::voteDown()";
|
||||
std::cerr << std::endl;
|
||||
vote(mThreadId.first, mThreadId.second, mCurrentMsgId, mVoterId, false);
|
||||
|
||||
vote(mGroupId, mLatestMsgId, mCurrentCommentMsgId, mVoterId, false);
|
||||
}
|
||||
|
||||
void GxsCommentTreeWidget::setVoteId(const RsGxsId &voterId)
|
||||
@ -284,16 +287,16 @@ void GxsCommentTreeWidget::banUser()
|
||||
|
||||
void GxsCommentTreeWidget::makeComment()
|
||||
{
|
||||
GxsCreateCommentDialog pcc(mTokenQueue, mCommentService, mThreadId, mThreadId.second, this);
|
||||
GxsCreateCommentDialog pcc(mTokenQueue, mCommentService, std::make_pair(mGroupId,mLatestMsgId), mLatestMsgId, this);
|
||||
pcc.exec();
|
||||
}
|
||||
|
||||
void GxsCommentTreeWidget::replyToComment()
|
||||
{
|
||||
RsGxsGrpMsgIdPair msgId;
|
||||
msgId.first = mThreadId.first;
|
||||
msgId.second = mCurrentMsgId;
|
||||
GxsCreateCommentDialog pcc(mTokenQueue, mCommentService, msgId, mThreadId.second, this);
|
||||
msgId.first = mGroupId;
|
||||
msgId.second = mCurrentCommentMsgId;
|
||||
GxsCreateCommentDialog pcc(mTokenQueue, mCommentService, msgId, mLatestMsgId, this);
|
||||
pcc.exec();
|
||||
}
|
||||
|
||||
@ -303,36 +306,44 @@ void GxsCommentTreeWidget::setup(RsTokenService *token_service, RsGxsCommentServ
|
||||
mCommentService = comment_service;
|
||||
mTokenQueue = new TokenQueue(token_service, this);
|
||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customPopUpMenu(QPoint)));
|
||||
connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(setCurrentMsgId(QTreeWidgetItem*, QTreeWidgetItem*)));
|
||||
connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(setCurrentCommentMsgId(QTreeWidgetItem*, QTreeWidgetItem*)));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Load Comments */
|
||||
void GxsCommentTreeWidget::requestComments(const RsGxsGrpMsgIdPair& threadId)
|
||||
void GxsCommentTreeWidget::requestComments(const RsGxsGroupId& group, const std::set<RsGxsMessageId>& message_versions,const RsGxsMessageId& most_recent_message)
|
||||
{
|
||||
/* request comments */
|
||||
|
||||
mThreadId = threadId;
|
||||
service_requestComments(threadId);
|
||||
mGroupId = group ;
|
||||
mMsgVersions = message_versions ;
|
||||
mLatestMsgId = most_recent_message;
|
||||
|
||||
service_requestComments(group,message_versions);
|
||||
}
|
||||
|
||||
void GxsCommentTreeWidget::service_requestComments(const RsGxsGrpMsgIdPair& threadId)
|
||||
void GxsCommentTreeWidget::service_requestComments(const RsGxsGroupId& group_id,const std::set<RsGxsMessageId> & msgIds)
|
||||
{
|
||||
/* request comments */
|
||||
std::cerr << "GxsCommentTreeWidget::service_requestComments(" << threadId.second << ")";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "GxsCommentTreeWidget::service_requestComments for group " << group_id << std::endl;
|
||||
|
||||
std::vector<RsGxsGrpMsgIdPair> ids_to_ask;
|
||||
|
||||
for(std::set<RsGxsMessageId>::const_iterator it(msgIds.begin());it!=msgIds.end();++it)
|
||||
{
|
||||
std::cerr << " asking for msg " << *it << std::endl;
|
||||
|
||||
ids_to_ask.push_back(std::make_pair(group_id,*it));
|
||||
}
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST;
|
||||
|
||||
std::vector<RsGxsGrpMsgIdPair> msgIds;
|
||||
msgIds.push_back(threadId);
|
||||
|
||||
uint32_t token;
|
||||
mTokenQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, GXSCOMMENTS_LOADTHREAD);
|
||||
mTokenQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids_to_ask, GXSCOMMENTS_LOADTHREAD);
|
||||
}
|
||||
|
||||
|
||||
@ -385,7 +396,7 @@ void GxsCommentTreeWidget::completeItems()
|
||||
|
||||
parent->addChild(pit->second);
|
||||
}
|
||||
else if (parentId == mThreadId.second)
|
||||
else if (mMsgVersions.find(parentId) != mMsgVersions.end())
|
||||
{
|
||||
std::cerr << "GxsCommentTreeWidget::completeItems() Added to topLevelItems";
|
||||
std::cerr << std::endl;
|
||||
@ -459,7 +470,7 @@ void GxsCommentTreeWidget::acknowledgeComment(const uint32_t &token)
|
||||
mCommentService->acknowledgeComment(token, msgId);
|
||||
|
||||
// simply reload data
|
||||
service_requestComments(mThreadId);
|
||||
service_requestComments(mGroupId,mMsgVersions);
|
||||
}
|
||||
|
||||
|
||||
@ -469,7 +480,7 @@ void GxsCommentTreeWidget::acknowledgeVote(const uint32_t &token)
|
||||
if (mCommentService->acknowledgeVote(token, msgId))
|
||||
{
|
||||
// reload data if vote was added.
|
||||
service_requestComments(mThreadId);
|
||||
service_requestComments(mGroupId,mMsgVersions);
|
||||
}
|
||||
}
|
||||
|
||||
@ -509,6 +520,7 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token)
|
||||
|
||||
RsGxsId authorId = comment.mMeta.mAuthorId;
|
||||
item->setId(authorId, PCITEM_COLUMN_AUTHOR, false);
|
||||
item->setData(PCITEM_COLUMN_COMMENT,POST_COLOR_ROLE,QVariant(authorId.toByteArray()[1]));
|
||||
|
||||
text = QString::number(comment.mScore);
|
||||
item->setText(PCITEM_COLUMN_SCORE, text);
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
~GxsCommentTreeWidget();
|
||||
void setup(RsTokenService *token_service, RsGxsCommentService *comment_service);
|
||||
|
||||
void requestComments(const RsGxsGrpMsgIdPair& threadId);
|
||||
void requestComments(const RsGxsGroupId& group, const std::set<RsGxsMessageId> &message_versions, const RsGxsMessageId &most_recent_message);
|
||||
void getCurrentMsgId(RsGxsMessageId& parentId);
|
||||
void applyRankings(std::map<RsGxsMessageId, uint32_t>& positions);
|
||||
|
||||
@ -49,7 +49,7 @@ public:
|
||||
protected:
|
||||
|
||||
/* to be overloaded */
|
||||
virtual void service_requestComments(const RsGxsGrpMsgIdPair& threadId);
|
||||
virtual void service_requestComments(const RsGxsGroupId &group_id, const std::set<RsGxsMessageId> &msgIds);
|
||||
virtual void service_loadThread(const uint32_t &token);
|
||||
virtual QTreeWidgetItem *service_createMissingItem(const RsGxsMessageId& parent);
|
||||
|
||||
@ -65,7 +65,7 @@ protected:
|
||||
|
||||
public slots:
|
||||
void customPopUpMenu(const QPoint& point);
|
||||
void setCurrentMsgId(QTreeWidgetItem* current, QTreeWidgetItem* previous);
|
||||
void setCurrentCommentMsgId(QTreeWidgetItem* current, QTreeWidgetItem* previous);
|
||||
|
||||
|
||||
void makeComment();
|
||||
@ -85,8 +85,10 @@ protected:
|
||||
const RsGxsMessageId &parentId, const RsGxsId &authorId, bool up);
|
||||
|
||||
/* Data */
|
||||
RsGxsGrpMsgIdPair mThreadId;
|
||||
RsGxsMessageId mCurrentMsgId;
|
||||
RsGxsGroupId mGroupId;
|
||||
std::set<RsGxsMessageId> mMsgVersions;
|
||||
RsGxsMessageId mLatestMsgId;
|
||||
RsGxsMessageId mCurrentCommentMsgId;
|
||||
RsGxsId mVoterId;
|
||||
|
||||
std::map<RsGxsMessageId, QTreeWidgetItem *> mLoadingMap;
|
||||
|
@ -64,7 +64,10 @@ void GxsFeedItem::comments(const QString &title)
|
||||
|
||||
if (mFeedHolder)
|
||||
{
|
||||
mFeedHolder->openComments(feedId(), groupId(), messageId(), title);
|
||||
if(mMessageVersions.empty())
|
||||
mFeedHolder->openComments(feedId(), groupId(),QVector<RsGxsMessageId>(1,messageId()), messageId(), title);
|
||||
else
|
||||
mFeedHolder->openComments(feedId(), groupId(),mMessageVersions, messageId(), title);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,12 +156,12 @@ void GxsFeedItem::requestComment()
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST;
|
||||
|
||||
RsGxsGrpMsgIdPair msgIdPair;
|
||||
msgIdPair.first = groupId();
|
||||
msgIdPair.second = messageId();
|
||||
|
||||
std::vector<RsGxsGrpMsgIdPair> msgIds;
|
||||
msgIds.push_back(msgIdPair);
|
||||
|
||||
for(uint32_t i=0;i<mMessageVersions.size();++i)
|
||||
msgIds.push_back(std::make_pair(groupId(),mMessageVersions[i]));
|
||||
|
||||
msgIds.push_back(std::make_pair(groupId(),messageId()));
|
||||
|
||||
uint32_t token;
|
||||
mLoadQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeComment);
|
||||
|
@ -35,9 +35,12 @@ public:
|
||||
GxsFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, RsGxsIfaceHelper *iface, bool autoUpdate);
|
||||
virtual ~GxsFeedItem();
|
||||
|
||||
RsGxsMessageId messageId() { return mMessageId; }
|
||||
RsGxsMessageId messageId() const { return mMessageId; }
|
||||
const QVector<RsGxsMessageId>& messageVersions() const { return mMessageVersions ; }
|
||||
|
||||
//To be able to update with thread message when comment is received.
|
||||
void setMessageId( RsGxsMessageId id) {mMessageId = id;}
|
||||
void setMessageVersions( const QVector<RsGxsMessageId>& v) { mMessageVersions = v;}
|
||||
|
||||
protected:
|
||||
/* load message data */
|
||||
@ -61,6 +64,7 @@ protected slots:
|
||||
|
||||
private:
|
||||
RsGxsMessageId mMessageId;
|
||||
QVector<RsGxsMessageId> mMessageVersions ;
|
||||
uint32_t mTokenTypeMessage;
|
||||
uint32_t mTokenTypeComment;
|
||||
};
|
||||
|
@ -45,8 +45,8 @@ public:
|
||||
GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, RsGxsIfaceHelper *iface, bool autoUpdate);
|
||||
virtual ~GxsGroupFeedItem();
|
||||
|
||||
RsGxsGroupId groupId() { return mGroupId; }
|
||||
uint32_t feedId() { return mFeedId; }
|
||||
RsGxsGroupId groupId() const { return mGroupId; }
|
||||
uint32_t feedId() const { return mFeedId; }
|
||||
|
||||
protected:
|
||||
uint32_t nextTokenType() { return ++mNextTokenType; }
|
||||
|
@ -525,7 +525,7 @@ void GxsGroupFrameDialog::sharePublishKey()
|
||||
shareUi.exec();
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title)
|
||||
void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const QVector<RsGxsMessageId>& msg_versions, const RsGxsMessageId &most_recent_msgId, const QString &title)
|
||||
{
|
||||
RsGxsCommentService *commentService = getCommentService();
|
||||
if (!commentService) {
|
||||
@ -533,7 +533,8 @@ void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const RsGxsMess
|
||||
return;
|
||||
}
|
||||
|
||||
GxsCommentDialog *commentDialog = commentWidget(msgId);
|
||||
GxsCommentDialog *commentDialog = commentWidget(most_recent_msgId);
|
||||
|
||||
if (!commentDialog) {
|
||||
QString comments = title;
|
||||
if (title.length() > MAX_COMMENT_TITLE)
|
||||
@ -544,12 +545,16 @@ void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const RsGxsMess
|
||||
|
||||
commentDialog = new GxsCommentDialog(this, mInterface->getTokenService(), commentService);
|
||||
|
||||
QWidget *commentHeader = createCommentHeaderWidget(grpId, msgId);
|
||||
QWidget *commentHeader = createCommentHeaderWidget(grpId, most_recent_msgId);
|
||||
if (commentHeader) {
|
||||
commentDialog->setCommentHeader(commentHeader);
|
||||
}
|
||||
|
||||
commentDialog->commentLoad(grpId, msgId);
|
||||
std::set<RsGxsMessageId> msgv;
|
||||
for(int i=0;i<msg_versions.size();++i)
|
||||
msgv.insert(msg_versions[i]);
|
||||
|
||||
commentDialog->commentLoad(grpId, msgv,most_recent_msgId);
|
||||
|
||||
int index = ui->messageTabWidget->addTab(commentDialog, comments);
|
||||
ui->messageTabWidget->setTabIcon(index, QIcon(IMAGE_COMMENT));
|
||||
@ -620,12 +625,12 @@ GxsMessageFrameWidget *GxsGroupFrameDialog::createMessageWidget(const RsGxsGroup
|
||||
|
||||
connect(msgWidget, SIGNAL(groupChanged(QWidget*)), this, SLOT(messageTabInfoChanged(QWidget*)));
|
||||
connect(msgWidget, SIGNAL(waitingChanged(QWidget*)), this, SLOT(messageTabWaitingChanged(QWidget*)));
|
||||
connect(msgWidget, SIGNAL(loadComment(RsGxsGroupId,RsGxsMessageId,QString)), this, SLOT(loadComment(RsGxsGroupId,RsGxsMessageId,QString)));
|
||||
connect(msgWidget, SIGNAL(loadComment(RsGxsGroupId,QVector<RsGxsMessageId>,RsGxsMessageId,QString)), this, SLOT(loadComment(RsGxsGroupId,QVector<RsGxsMessageId>,RsGxsMessageId,QString)));
|
||||
|
||||
return msgWidget;
|
||||
}
|
||||
|
||||
GxsCommentDialog *GxsGroupFrameDialog::commentWidget(const RsGxsMessageId &msgId)
|
||||
GxsCommentDialog *GxsGroupFrameDialog::commentWidget(const RsGxsMessageId& msgId)
|
||||
{
|
||||
int tabCount = ui->messageTabWidget->count();
|
||||
for (int index = 0; index < tabCount; ++index) {
|
||||
|
@ -126,7 +126,7 @@ private slots:
|
||||
|
||||
void sharePublishKey();
|
||||
|
||||
void loadComment(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title);
|
||||
void loadComment(const RsGxsGroupId &grpId, const QVector<RsGxsMessageId>& msg_versions,const RsGxsMessageId &most_recent_msgId, const QString &title);
|
||||
|
||||
private:
|
||||
virtual QString text(TextType type) = 0;
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
signals:
|
||||
void groupChanged(QWidget *widget);
|
||||
void waitingChanged(QWidget *widget);
|
||||
void loadComment(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
|
||||
void loadComment(const RsGxsGroupId &groupId, const QVector<RsGxsMessageId>& msg_versions,const RsGxsMessageId &msgId, const QString &title);
|
||||
|
||||
protected:
|
||||
virtual void setAllMessagesReadDo(bool read, uint32_t &token) = 0;
|
||||
|
@ -207,9 +207,9 @@ void GxsChannelPostsWidget::openChat(const RsPeerId & /*peerId*/)
|
||||
}
|
||||
|
||||
// Callback from Widget->FeedHolder->ServiceDialog->CommentContainer->CommentDialog,
|
||||
void GxsChannelPostsWidget::openComments(uint32_t /*type*/, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title)
|
||||
void GxsChannelPostsWidget::openComments(uint32_t /*type*/, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId>& msg_versions,const RsGxsMessageId &msgId, const QString &title)
|
||||
{
|
||||
emit loadComment(groupId, msgId, title);
|
||||
emit loadComment(groupId, msg_versions,msgId, title);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::createMsg()
|
||||
@ -543,6 +543,10 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << " and is more recent => following" << std::endl;
|
||||
#endif
|
||||
for(std::set<RsGxsMessageId>::const_iterator itt(posts[current_index].mOlderVersions.begin());itt!=posts[current_index].mOlderVersions.end();++itt)
|
||||
posts[source_index].mOlderVersions.insert(*itt);
|
||||
|
||||
posts[source_index].mOlderVersions.insert(posts[current_index].mMeta.mMsgId);
|
||||
posts[current_index].mMeta.mMsgId.clear(); // clear the msg Id so the post will be ignored
|
||||
}
|
||||
#ifdef DEBUG_CHANNEL
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
virtual QScrollArea *getScrollArea();
|
||||
virtual void deleteFeedItem(QWidget *item, uint32_t type);
|
||||
virtual void openChat(const RsPeerId& peerId);
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId> &msg_versions, const RsGxsMessageId &msgId, const QString &title);
|
||||
|
||||
protected:
|
||||
/* GxsMessageFramePostWidget */
|
||||
|
Loading…
Reference in New Issue
Block a user