diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp
index 73d323a58..b11413603 100644
--- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp
+++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp
@@ -47,8 +47,8 @@ const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2
//== Base class BoardPostDisplayWidget ==
//===================================================================================================================================
-BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode mode,bool expanded,QWidget *parent)
- : QWidget(parent),mPost(post),dmode(mode),mExpanded(expanded),ui(new Ui::BoardPostDisplayWidget())
+BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, DisplayMode mode, uint8_t display_flags, QWidget *parent)
+ : QWidget(parent),mPost(post),dmode(mode),mDisplayFlags(display_flags),ui(new Ui::BoardPostDisplayWidget())
{
ui->setupUi(this);
setup();
@@ -161,21 +161,6 @@ void BoardPostDisplayWidget::setup()
ui->pictureLabel->hide();
ui->notes->hide();
ui->siteLabel->hide();
-
- if(mExpanded)
- {
- ui->frame_picture->show();
- ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/decrease.png")));
- ui->expandButton->setToolTip(tr("Hide"));
- ui->expandButton->setChecked(true);
- }
- else
- {
- ui->frame_picture->hide();
- ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/expand.png")));
- ui->expandButton->setToolTip(tr("Expand"));
- ui->expandButton->setChecked(false);
- }
}
else
{
@@ -184,6 +169,29 @@ void BoardPostDisplayWidget::setup()
ui->expandButton->hide();
}
+ if(mDisplayFlags & SHOW_NOTES)
+ {
+ ui->frame_picture->show();
+ ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/decrease.png")));
+ ui->expandButton->setToolTip(tr("Hide"));
+ ui->expandButton->setChecked(true);
+ }
+ else
+ {
+ ui->frame_picture->hide();
+ ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/expand.png")));
+ ui->expandButton->setToolTip(tr("Expand"));
+ ui->expandButton->setChecked(false);
+ }
+
+ if(!(mDisplayFlags & SHOW_COMMENTS))
+ {
+ ui->commentsWidget->hide();
+ ui->commentButton->setChecked(false);
+ }
+ else
+ ui->commentButton->setChecked(true);
+
setAttribute(Qt::WA_DeleteOnClose, true);
/* clear ui */
@@ -193,7 +201,7 @@ void BoardPostDisplayWidget::setup()
ui->siteLabel->clear();
connect(ui->expandButton, SIGNAL(toggled(bool)), this, SLOT(doExpand(bool)));
- connect(ui->commentButton, SIGNAL(clicked()), this, SLOT(loadComments()));
+ connect(ui->commentButton, SIGNAL(toggled(bool)), this, SLOT(loadComments(bool)));
connect(ui->voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote()));
connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT(makeDownVote()));
connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool)));
@@ -350,38 +358,21 @@ void BoardPostDisplayWidget::setup()
if(doc.toPlainText().trimmed().isEmpty())
ui->notes->hide();
-#ifdef TO_REMOVE
- // differences between Feed or Top of Comment.
- if (mFeedHolder)
+ // feed.
+ //frame_comment->show();
+ ui->commentButton->show();
+
+ if (mPost.mComments)
{
- // feed.
- //frame_comment->show();
- ui->commentButton->show();
-
- if (mPost.mComments)
- {
- QString commentText = QString::number(mPost.mComments);
- commentText += " ";
- commentText += tr("Comments");
- ui->commentButton->setText(commentText);
- }
- else
- {
- ui->commentButton->setText(tr("Comment"));
- }
-
- setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus));
+ QString commentText = QString::number(mPost.mComments);
+ commentText += " ";
+ commentText += tr("Comments");
+ ui->commentButton->setText(commentText);
}
else
-#endif
- {
- // no feed.
- //frame_comment->hide();
- ui->commentButton->hide();
+ ui->commentButton->setText(tr("Comment"));
- ui->readButton->hide();
- ui->newLabel->hide();
- }
+ setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus));
// disable voting buttons - if they have already voted.
if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK)
@@ -426,3 +417,7 @@ void BoardPostDisplayWidget::doExpand(bool e)
emit expand(mPost.mMeta.mMsgId,e);
}
+void BoardPostDisplayWidget::loadComments(bool e)
+{
+ emit commentsRequested(mPost.mMeta.mMsgId,e);
+}
diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h
index e262a77f4..a8098ef02 100644
--- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h
+++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h
@@ -42,7 +42,13 @@ public:
DISPLAY_MODE_COMPACT = 0x02
};
- BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,bool expanded,QWidget *parent=nullptr);
+ enum DisplayFlags: uint8_t {
+ SHOW_NONE = 0x00,
+ SHOW_COMMENTS = 0x01,
+ SHOW_NOTES = 0x02,
+ };
+
+ BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,uint8_t display_flags,QWidget *parent=nullptr);
virtual ~BoardPostDisplayWidget();
static const char *DEFAULT_BOARD_IMAGE;
@@ -61,6 +67,7 @@ protected slots:
void toggle() {}
void setCommentsSize(int comNb) ;
+ void loadComments(bool e);
void makeUpVote() ;
void makeDownVote() ;
void toggleNotes() ;
@@ -68,12 +75,13 @@ protected slots:
signals:
void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down);
void expand(RsGxsMessageId,bool);
+ void commentsRequested(RsGxsMessageId,bool);
protected:
RsPostedPost mPost;
DisplayMode dmode;
- bool mExpanded;
+ uint8_t mDisplayFlags;
private:
/** Qt Designer generated object */
diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui
index 3e43e9303..2dbc0ca3b 100644
--- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui
+++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui
@@ -7,7 +7,7 @@
0
0
758
- 190
+ 205
@@ -52,7 +52,7 @@
QFrame::Raised
-
+
-
-
@@ -269,6 +269,9 @@
:/images/comments.png:/images/comments.png
+
+ true
+
Qt::ToolButtonTextBesideIcon
@@ -440,6 +443,9 @@
+ -
+
+
@@ -463,6 +469,12 @@
QLabel
+
+ GxsCommentDialog
+ QWidget
+ gui/gxs/GxsCommentDialog.h
+ 1
+
diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp
index 5f64f2bab..84ff81d75 100644
--- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp
+++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp
@@ -85,7 +85,7 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
painter->fillRect( option.rect, option.backgroundBrush);
painter->restore();
- BoardPostDisplayWidget w(post,mDisplayMode,isExpanded(post.mMeta.mMsgId));
+ BoardPostDisplayWidget w(post,mDisplayMode,displayFlags(post.mMeta.mMsgId));
w.adjustSize();
w.setFixedSize(option.rect.size());
@@ -125,13 +125,12 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo
// This is the only place where we actually set the size of cells
RsPostedPost post = index.data(Qt::UserRole).value() ;
- BoardPostDisplayWidget w(post,mDisplayMode,isExpanded(post.mMeta.mMsgId));
+ BoardPostDisplayWidget w(post,mDisplayMode,displayFlags(post.mMeta.mMsgId));
w.adjustSize();
return w.size();
}
-
void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded)
{
std::cerr << __PRETTY_FUNCTION__ << ": received expandItem signal. b=" << expanded << std::endl;
@@ -142,9 +141,27 @@ void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded)
mPostListWidget->forceRedraw();
}
-bool PostedPostDelegate::isExpanded(const RsGxsMessageId &id) const
+void PostedPostDelegate::commentItem(RsGxsMessageId msgId,bool comment)
{
- return mExpandedItems.find(id) != mExpandedItems.end();
+ std::cerr << __PRETTY_FUNCTION__ << ": received commentItem signal. b=" << comment << std::endl;
+ if(comment)
+ mShowCommentItems.insert(msgId);
+ else
+ mShowCommentItems.erase(msgId);
+
+ mPostListWidget->forceRedraw();
+}
+uint8_t PostedPostDelegate::displayFlags(const RsGxsMessageId &id) const
+{
+ uint8_t flags=0;
+
+ if(mExpandedItems.find(id) != mExpandedItems.end())
+ flags |= BoardPostDisplayWidget::SHOW_NOTES;
+
+ if(mShowCommentItems.find(id) != mShowCommentItems.end())
+ flags |= BoardPostDisplayWidget::SHOW_COMMENTS;
+
+ return flags;
}
QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const
@@ -153,10 +170,11 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie
if(index.column() == RsPostedPostsModel::COLUMN_POSTS)
{
- QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,isExpanded(post.mMeta.mMsgId),parent);
+ QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,displayFlags(post.mMeta.mMsgId),parent);
QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool)));
QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(expandItem(RsGxsMessageId,bool)));
+ QObject::connect(w,SIGNAL(commentsRequested(RsGxsMessageId,bool)),this,SLOT(commentItem(RsGxsMessageId,bool)));
w->adjustSize();
w->setFixedSize(option.rect.size());
diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h
index 4e3f8171c..60e2b510d 100644
--- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h
+++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h
@@ -58,17 +58,19 @@ public:
public slots:
void expandItem(RsGxsMessageId msgId,bool expanded);
+ void commentItem(RsGxsMessageId msgId,bool comment);
private:
// The class keeps a list of expanded items. Because items are constantly re-created, it is not possible
// to let the items themselves hold that information.
- bool isExpanded(const RsGxsMessageId& id) const;
+ uint8_t displayFlags(const RsGxsMessageId& id) const;
int mCellWidthPix;
PostedListWidgetWithModel *mPostListWidget; // used for sending vote signals and so on.
BoardPostDisplayWidget::DisplayMode mDisplayMode;
std::set mExpandedItems;
+ std::set mShowCommentItems;
};
class PostedListWidgetWithModel: public GxsMessageFrameWidget