Merge pull request #827 from csoler/v0.6-EditPosts

V0.6 edit posts
This commit is contained in:
csoler 2017-05-20 18:34:07 +02:00 committed by GitHub
commit 8b079f8fdf
22 changed files with 133 additions and 83 deletions

View File

@ -60,6 +60,8 @@ public:
public: public:
RsMsgMetaData mMeta; RsMsgMetaData mMeta;
std::set<RsGxsMessageId> mOlderVersions ;
std::string mMsg; // UTF8 encoded. std::string mMsg; // UTF8 encoded.
std::list<RsGxsFile> mFiles; std::list<RsGxsFile> mFiles;

View File

@ -1403,7 +1403,7 @@ void NewsFeed::openChat(const RsPeerId &peerId)
ChatDialog::chatFriend(ChatId(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 << "NewsFeed::openComments() Not Handled Yet";
std::cerr << std::endl; std::cerr << std::endl;

View File

@ -58,7 +58,7 @@ public:
virtual QScrollArea *getScrollArea(); virtual QScrollArea *getScrollArea();
virtual void deleteFeedItem(QWidget *item, uint32_t type); virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void openChat(const RsPeerId& peerId); 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 testFeeds(uint notifyFlags);
static void testFeed(FeedNotify *feedNotify); static void testFeed(FeedNotify *feedNotify);

View File

@ -411,7 +411,13 @@ void PostedItem::loadComments()
if (mFeedHolder) if (mFeedHolder)
{ {
QString title = QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); 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);
} }
} }

View File

@ -139,9 +139,9 @@ void PostedListWidget::openChat(const RsPeerId & /*peerId*/)
return; 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() void PostedListWidget::newPost()

View File

@ -52,7 +52,7 @@ public:
virtual QScrollArea *getScrollArea(); virtual QScrollArea *getScrollArea();
virtual void deleteFeedItem(QWidget *item, uint32_t type); virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void openChat(const RsPeerId& peerId); 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 */ /* GXS functions */
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);

View File

@ -37,7 +37,7 @@ public:
virtual QScrollArea *getScrollArea() = 0; virtual QScrollArea *getScrollArea() = 0;
virtual void deleteFeedItem(QWidget *item, uint32_t type) = 0; virtual void deleteFeedItem(QWidget *item, uint32_t type) = 0;
virtual void openChat(const RsPeerId& peerId) = 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 // Workaround for QTBUG-3372
void lockLayout(QWidget *feedItem, bool lock); void lockLayout(QWidget *feedItem, bool lock);

View File

@ -64,6 +64,21 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId,
std::cerr << std::endl; std::cerr << std::endl;
#endif #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(); setup();
//setGroup(group, false); //setGroup(group, false);

View File

@ -54,7 +54,7 @@ void GxsCommentContainer::setup()
ui.tabWidget->hideCloseButton(index); 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; QString comments = title;
if (title.length() > MAX_COMMENT_TITLE) if (title.length() > MAX_COMMENT_TITLE)
@ -68,7 +68,7 @@ void GxsCommentContainer::commentLoad(const RsGxsGroupId &grpId, const RsGxsMess
QWidget *commentHeader = createHeaderWidget(grpId, msgId); QWidget *commentHeader = createHeaderWidget(grpId, msgId);
commentDialog->setCommentHeader(commentHeader); commentDialog->setCommentHeader(commentHeader);
commentDialog->commentLoad(grpId, msgId); commentDialog->commentLoad(grpId, msg_versions, msgId);
ui.tabWidget->addTab(commentDialog, comments); ui.tabWidget->addTab(commentDialog, comments);
} }

View File

@ -40,7 +40,7 @@ public:
GxsCommentContainer(QWidget *parent = 0); GxsCommentContainer(QWidget *parent = 0);
void setup(); 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 GxsServiceDialog *createServiceDialog() = 0;
virtual QString getServiceName() = 0; virtual QString getServiceName() = 0;
@ -67,9 +67,9 @@ public:
virtual ~GxsServiceDialog() { return; } 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: private:

View File

@ -59,20 +59,16 @@ GxsCommentDialog::~GxsCommentDialog()
delete(ui); 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; std::cerr << std::endl;
mGrpId = grpId; mGrpId = grpId;
mMsgId = msgId; mMostRecentMsgId = most_recent_msgId;
mMsgVersions = msg_versions;
RsGxsGrpMsgIdPair threadId; ui->treeWidget->requestComments(mGrpId,msg_versions,most_recent_msgId);
threadId.first = grpId;
threadId.second = msgId;
ui->treeWidget->requestComments(threadId);
} }
void GxsCommentDialog::refresh() void GxsCommentDialog::refresh()
@ -80,7 +76,7 @@ void GxsCommentDialog::refresh()
std::cerr << "GxsCommentDialog::refresh()"; std::cerr << "GxsCommentDialog::refresh()";
std::cerr << std::endl; std::cerr << std::endl;
commentLoad(mGrpId, mMsgId); commentLoad(mGrpId, mMsgVersions,mMostRecentMsgId);
} }
void GxsCommentDialog::idChooserReady() void GxsCommentDialog::idChooserReady()

View File

@ -39,10 +39,10 @@ public:
virtual ~GxsCommentDialog(); virtual ~GxsCommentDialog();
void setCommentHeader(QWidget *header); 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; } RsGxsGroupId groupId() { return mGrpId; }
RsGxsMessageId messageId() { return mMsgId; } RsGxsMessageId messageId() { return mMostRecentMsgId; }
private slots: private slots:
void refresh(); void refresh();
@ -51,7 +51,8 @@ private slots:
private: private:
RsGxsGroupId mGrpId; RsGxsGroupId mGrpId;
RsGxsMessageId mMsgId; RsGxsMessageId mMostRecentMsgId;
std::set<RsGxsMessageId> mMsgVersions;
/* UI - from Designer */ /* UI - from Designer */
Ui::GxsCommentDialog *ui; Ui::GxsCommentDialog *ui;

View File

@ -50,6 +50,8 @@
#define COMMENT_VOTE_ACK 0x001234 #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 */ /* Images for context menu icons */
#define IMAGE_MESSAGE ":/images/folder-draft.png" #define IMAGE_MESSAGE ":/images/folder-draft.png"
@ -65,7 +67,7 @@ public:
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const 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 virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
@ -96,11 +98,10 @@ public:
p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing);
QPainterPath path ; 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/4.0,m/4.0,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) ;
QPen pen(Qt::gray,m/7.0f); QPen pen(Qt::gray,m/7.0f);
p.setPen(pen); 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); p.drawPath(path);
QAbstractTextDocumentLayout::PaintContext ctx; QAbstractTextDocumentLayout::PaintContext ctx;
@ -110,7 +111,7 @@ public:
painter->drawPixmap(r.topLeft(),px); 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: private:
@ -153,14 +154,14 @@ GxsCommentTreeWidget::~GxsCommentTreeWidget()
} }
} }
void GxsCommentTreeWidget::setCurrentMsgId(QTreeWidgetItem *current, QTreeWidgetItem *previous) void GxsCommentTreeWidget::setCurrentCommentMsgId(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{ {
Q_UNUSED(previous); Q_UNUSED(previous);
if(current) 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 ); QMenu contextMnu( this );
QAction* action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Reply to Comment"), this, SLOT(replyToComment())); 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 = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Submit Comment"), this, SLOT(makeComment()));
action->setDisabled(mThreadId.first.isNull()); action->setDisabled(mMsgVersions.empty());
contextMnu.addSeparator(); contextMnu.addSeparator();
@ -180,7 +181,7 @@ void GxsCommentTreeWidget::customPopUpMenu(const QPoint& /*point*/)
action->setDisabled(mVoterId.isNull()); action->setDisabled(mVoterId.isNull());
if (!mCurrentMsgId.isNull()) if (!mCurrentCommentMsgId.isNull())
{ {
// not implemented yet // not implemented yet
/* /*
@ -206,7 +207,8 @@ void GxsCommentTreeWidget::voteUp()
{ {
std::cerr << "GxsCommentTreeWidget::voteUp()"; std::cerr << "GxsCommentTreeWidget::voteUp()";
std::cerr << std::endl; 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 << "GxsCommentTreeWidget::voteDown()";
std::cerr << std::endl; std::cerr << std::endl;
vote(mThreadId.first, mThreadId.second, mCurrentMsgId, mVoterId, false);
vote(mGroupId, mLatestMsgId, mCurrentCommentMsgId, mVoterId, false);
} }
void GxsCommentTreeWidget::setVoteId(const RsGxsId &voterId) void GxsCommentTreeWidget::setVoteId(const RsGxsId &voterId)
@ -284,16 +287,16 @@ void GxsCommentTreeWidget::banUser()
void GxsCommentTreeWidget::makeComment() void GxsCommentTreeWidget::makeComment()
{ {
GxsCreateCommentDialog pcc(mTokenQueue, mCommentService, mThreadId, mThreadId.second, this); GxsCreateCommentDialog pcc(mTokenQueue, mCommentService, std::make_pair(mGroupId,mLatestMsgId), mLatestMsgId, this);
pcc.exec(); pcc.exec();
} }
void GxsCommentTreeWidget::replyToComment() void GxsCommentTreeWidget::replyToComment()
{ {
RsGxsGrpMsgIdPair msgId; RsGxsGrpMsgIdPair msgId;
msgId.first = mThreadId.first; msgId.first = mGroupId;
msgId.second = mCurrentMsgId; msgId.second = mCurrentCommentMsgId;
GxsCreateCommentDialog pcc(mTokenQueue, mCommentService, msgId, mThreadId.second, this); GxsCreateCommentDialog pcc(mTokenQueue, mCommentService, msgId, mLatestMsgId, this);
pcc.exec(); pcc.exec();
} }
@ -303,36 +306,44 @@ void GxsCommentTreeWidget::setup(RsTokenService *token_service, RsGxsCommentServ
mCommentService = comment_service; mCommentService = comment_service;
mTokenQueue = new TokenQueue(token_service, this); mTokenQueue = new TokenQueue(token_service, this);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customPopUpMenu(QPoint))); 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; return;
} }
/* Load Comments */ /* 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 */ /* request comments */
mThreadId = threadId; mGroupId = group ;
service_requestComments(threadId); 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 */ /* request comments */
std::cerr << "GxsCommentTreeWidget::service_requestComments(" << threadId.second << ")"; std::cerr << "GxsCommentTreeWidget::service_requestComments for group " << group_id << std::endl;
std::cerr << 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; RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA; opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST; opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST;
std::vector<RsGxsGrpMsgIdPair> msgIds;
msgIds.push_back(threadId);
uint32_t token; 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); 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 << "GxsCommentTreeWidget::completeItems() Added to topLevelItems";
std::cerr << std::endl; std::cerr << std::endl;
@ -459,7 +470,7 @@ void GxsCommentTreeWidget::acknowledgeComment(const uint32_t &token)
mCommentService->acknowledgeComment(token, msgId); mCommentService->acknowledgeComment(token, msgId);
// simply reload data // 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)) if (mCommentService->acknowledgeVote(token, msgId))
{ {
// reload data if vote was added. // 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; RsGxsId authorId = comment.mMeta.mAuthorId;
item->setId(authorId, PCITEM_COLUMN_AUTHOR, false); item->setId(authorId, PCITEM_COLUMN_AUTHOR, false);
item->setData(PCITEM_COLUMN_COMMENT,POST_COLOR_ROLE,QVariant(authorId.toByteArray()[1]));
text = QString::number(comment.mScore); text = QString::number(comment.mScore);
item->setText(PCITEM_COLUMN_SCORE, text); item->setText(PCITEM_COLUMN_SCORE, text);

View File

@ -39,7 +39,7 @@ public:
~GxsCommentTreeWidget(); ~GxsCommentTreeWidget();
void setup(RsTokenService *token_service, RsGxsCommentService *comment_service); 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 getCurrentMsgId(RsGxsMessageId& parentId);
void applyRankings(std::map<RsGxsMessageId, uint32_t>& positions); void applyRankings(std::map<RsGxsMessageId, uint32_t>& positions);
@ -49,7 +49,7 @@ public:
protected: protected:
/* to be overloaded */ /* 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 void service_loadThread(const uint32_t &token);
virtual QTreeWidgetItem *service_createMissingItem(const RsGxsMessageId& parent); virtual QTreeWidgetItem *service_createMissingItem(const RsGxsMessageId& parent);
@ -65,7 +65,7 @@ protected:
public slots: public slots:
void customPopUpMenu(const QPoint& point); void customPopUpMenu(const QPoint& point);
void setCurrentMsgId(QTreeWidgetItem* current, QTreeWidgetItem* previous); void setCurrentCommentMsgId(QTreeWidgetItem* current, QTreeWidgetItem* previous);
void makeComment(); void makeComment();
@ -85,8 +85,10 @@ protected:
const RsGxsMessageId &parentId, const RsGxsId &authorId, bool up); const RsGxsMessageId &parentId, const RsGxsId &authorId, bool up);
/* Data */ /* Data */
RsGxsGrpMsgIdPair mThreadId; RsGxsGroupId mGroupId;
RsGxsMessageId mCurrentMsgId; std::set<RsGxsMessageId> mMsgVersions;
RsGxsMessageId mLatestMsgId;
RsGxsMessageId mCurrentCommentMsgId;
RsGxsId mVoterId; RsGxsId mVoterId;
std::map<RsGxsMessageId, QTreeWidgetItem *> mLoadingMap; std::map<RsGxsMessageId, QTreeWidgetItem *> mLoadingMap;

View File

@ -64,7 +64,10 @@ void GxsFeedItem::comments(const QString &title)
if (mFeedHolder) 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.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST; opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST;
RsGxsGrpMsgIdPair msgIdPair;
msgIdPair.first = groupId();
msgIdPair.second = messageId();
std::vector<RsGxsGrpMsgIdPair> msgIds; 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; uint32_t token;
mLoadQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeComment); mLoadQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeComment);

View File

@ -35,9 +35,12 @@ public:
GxsFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, RsGxsIfaceHelper *iface, bool autoUpdate); GxsFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, RsGxsIfaceHelper *iface, bool autoUpdate);
virtual ~GxsFeedItem(); 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. //To be able to update with thread message when comment is received.
void setMessageId( RsGxsMessageId id) {mMessageId = id;} void setMessageId( RsGxsMessageId id) {mMessageId = id;}
void setMessageVersions( const QVector<RsGxsMessageId>& v) { mMessageVersions = v;}
protected: protected:
/* load message data */ /* load message data */
@ -61,6 +64,7 @@ protected slots:
private: private:
RsGxsMessageId mMessageId; RsGxsMessageId mMessageId;
QVector<RsGxsMessageId> mMessageVersions ;
uint32_t mTokenTypeMessage; uint32_t mTokenTypeMessage;
uint32_t mTokenTypeComment; uint32_t mTokenTypeComment;
}; };

View File

@ -45,8 +45,8 @@ public:
GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, RsGxsIfaceHelper *iface, bool autoUpdate); GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, RsGxsIfaceHelper *iface, bool autoUpdate);
virtual ~GxsGroupFeedItem(); virtual ~GxsGroupFeedItem();
RsGxsGroupId groupId() { return mGroupId; } RsGxsGroupId groupId() const { return mGroupId; }
uint32_t feedId() { return mFeedId; } uint32_t feedId() const { return mFeedId; }
protected: protected:
uint32_t nextTokenType() { return ++mNextTokenType; } uint32_t nextTokenType() { return ++mNextTokenType; }

View File

@ -525,7 +525,7 @@ void GxsGroupFrameDialog::sharePublishKey()
shareUi.exec(); 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(); RsGxsCommentService *commentService = getCommentService();
if (!commentService) { if (!commentService) {
@ -533,7 +533,8 @@ void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const RsGxsMess
return; return;
} }
GxsCommentDialog *commentDialog = commentWidget(msgId); GxsCommentDialog *commentDialog = commentWidget(most_recent_msgId);
if (!commentDialog) { if (!commentDialog) {
QString comments = title; QString comments = title;
if (title.length() > MAX_COMMENT_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); commentDialog = new GxsCommentDialog(this, mInterface->getTokenService(), commentService);
QWidget *commentHeader = createCommentHeaderWidget(grpId, msgId); QWidget *commentHeader = createCommentHeaderWidget(grpId, most_recent_msgId);
if (commentHeader) { if (commentHeader) {
commentDialog->setCommentHeader(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); int index = ui->messageTabWidget->addTab(commentDialog, comments);
ui->messageTabWidget->setTabIcon(index, QIcon(IMAGE_COMMENT)); ui->messageTabWidget->setTabIcon(index, QIcon(IMAGE_COMMENT));
@ -620,7 +625,7 @@ GxsMessageFrameWidget *GxsGroupFrameDialog::createMessageWidget(const RsGxsGroup
connect(msgWidget, SIGNAL(groupChanged(QWidget*)), this, SLOT(messageTabInfoChanged(QWidget*))); connect(msgWidget, SIGNAL(groupChanged(QWidget*)), this, SLOT(messageTabInfoChanged(QWidget*)));
connect(msgWidget, SIGNAL(waitingChanged(QWidget*)), this, SLOT(messageTabWaitingChanged(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; return msgWidget;
} }

View File

@ -126,7 +126,7 @@ private slots:
void sharePublishKey(); 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: private:
virtual QString text(TextType type) = 0; virtual QString text(TextType type) = 0;

View File

@ -54,7 +54,7 @@ public:
signals: signals:
void groupChanged(QWidget *widget); void groupChanged(QWidget *widget);
void waitingChanged(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: protected:
virtual void setAllMessagesReadDo(bool read, uint32_t &token) = 0; virtual void setAllMessagesReadDo(bool read, uint32_t &token) = 0;

View File

@ -207,9 +207,9 @@ void GxsChannelPostsWidget::openChat(const RsPeerId & /*peerId*/)
} }
// Callback from Widget->FeedHolder->ServiceDialog->CommentContainer->CommentDialog, // 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() void GxsChannelPostsWidget::createMsg()
@ -543,6 +543,10 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
#ifdef DEBUG_CHANNEL #ifdef DEBUG_CHANNEL
std::cerr << " and is more recent => following" << std::endl; std::cerr << " and is more recent => following" << std::endl;
#endif #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 posts[current_index].mMeta.mMsgId.clear(); // clear the msg Id so the post will be ignored
} }
#ifdef DEBUG_CHANNEL #ifdef DEBUG_CHANNEL

View File

@ -61,7 +61,7 @@ public:
virtual QScrollArea *getScrollArea(); virtual QScrollArea *getScrollArea();
virtual void deleteFeedItem(QWidget *item, uint32_t type); virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void openChat(const RsPeerId& peerId); 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: protected:
/* GxsMessageFramePostWidget */ /* GxsMessageFramePostWidget */