mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
switched to using tabs for comments in order to have more room. Layout still not working
This commit is contained in:
parent
c7bc7e814b
commit
f64482e3dd
@ -55,11 +55,16 @@ BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, Display
|
||||
ui->setupUi(this);
|
||||
setup();
|
||||
|
||||
ui->verticalLayout->addStretch();
|
||||
if(mode != DISPLAY_MODE_COMMENTS)
|
||||
ui->verticalLayout->addStretch();
|
||||
else
|
||||
ui->commentsWidget->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
|
||||
|
||||
ui->verticalLayout->setAlignment(Qt::AlignTop);
|
||||
ui->topLayout->setAlignment(Qt::AlignTop);
|
||||
ui->arrowsLayout->addStretch();
|
||||
ui->arrowsLayout->setAlignment(Qt::AlignTop);
|
||||
ui->verticalLayout_2->addStretch();
|
||||
|
||||
if(display_flags & SHOW_COMMENTS)
|
||||
{
|
||||
@ -165,7 +170,10 @@ void BoardPostDisplayWidget::setup()
|
||||
{
|
||||
// show/hide things based on the view type
|
||||
|
||||
if(dmode == DISPLAY_MODE_COMPACT)
|
||||
switch(dmode)
|
||||
{
|
||||
default:
|
||||
case DISPLAY_MODE_COMPACT:
|
||||
{
|
||||
ui->pictureLabel_compact->show();
|
||||
ui->expandButton->hide();
|
||||
@ -175,12 +183,34 @@ void BoardPostDisplayWidget::setup()
|
||||
ui->notes->hide();
|
||||
ui->siteLabel->hide();
|
||||
}
|
||||
else
|
||||
break;
|
||||
case DISPLAY_MODE_COMMENTS:
|
||||
{
|
||||
ui->pictureLabel_compact->show();
|
||||
ui->expandButton->hide();
|
||||
ui->pictureLabel->hide();
|
||||
ui->notes->hide();
|
||||
ui->scoreLabel->hide();
|
||||
ui->voteDownButton->hide();
|
||||
ui->voteUpButton->hide();
|
||||
ui->siteLabel->hide();
|
||||
ui->newLabel->hide();
|
||||
ui->commentButton->hide();
|
||||
ui->expandButton->hide();
|
||||
ui->shareButton->hide();
|
||||
ui->readButton->hide();
|
||||
ui->newLabel->hide();
|
||||
}
|
||||
break;
|
||||
case DISPLAY_MODE_CARD_VIEW:
|
||||
{
|
||||
ui->frame_picture->hide();
|
||||
ui->pictureLabel_compact->hide();
|
||||
ui->expandButton->hide();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(mDisplayFlags & SHOW_NOTES)
|
||||
{
|
||||
@ -311,7 +341,7 @@ void BoardPostDisplayWidget::setup()
|
||||
|
||||
ui->siteLabel->setText(sitestr);
|
||||
|
||||
if(dmode == DISPLAY_MODE_COMPACT)
|
||||
if(dmode == DISPLAY_MODE_COMPACT || dmode == DISPLAY_MODE_COMMENTS)
|
||||
{
|
||||
if(mPost.mImage.mData != NULL)
|
||||
{
|
||||
@ -373,7 +403,8 @@ void BoardPostDisplayWidget::setup()
|
||||
|
||||
// feed.
|
||||
//frame_comment->show();
|
||||
ui->commentButton->show();
|
||||
if(dmode != DISPLAY_MODE_COMMENTS)
|
||||
ui->commentButton->show();
|
||||
|
||||
if (mPost.mComments)
|
||||
{
|
||||
|
@ -39,13 +39,14 @@ public:
|
||||
enum DisplayMode {
|
||||
DISPLAY_MODE_UNKNOWN = 0x00,
|
||||
DISPLAY_MODE_CARD_VIEW = 0x01,
|
||||
DISPLAY_MODE_COMPACT = 0x02
|
||||
DISPLAY_MODE_COMPACT = 0x02,
|
||||
DISPLAY_MODE_COMMENTS = 0x03,
|
||||
};
|
||||
|
||||
enum DisplayFlags: uint8_t {
|
||||
SHOW_NONE = 0x00,
|
||||
SHOW_COMMENTS = 0x01,
|
||||
SHOW_NOTES = 0x02,
|
||||
SHOW_NONE = 0x00,
|
||||
SHOW_COMMENTS = 0x01,
|
||||
SHOW_NOTES = 0x02,
|
||||
};
|
||||
|
||||
BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,uint8_t display_flags,QWidget *parent=nullptr);
|
||||
@ -76,7 +77,7 @@ protected slots:
|
||||
signals:
|
||||
void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down);
|
||||
void expand(RsGxsMessageId,bool);
|
||||
void commentsRequested(RsGxsMessageId,bool);
|
||||
void commentsRequested(const RsGxsMessageId&,bool);
|
||||
|
||||
protected:
|
||||
RsPostedPost mPost;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "util/misc.h"
|
||||
#include "gui/Posted/PostedCreatePostDialog.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
#include "gui/common/RSTabWidget.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/feeds/SubFileItem.h"
|
||||
#include "gui/notifyqt.h"
|
||||
@ -91,8 +92,8 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
||||
|
||||
BoardPostDisplayWidget w(post,mDisplayMode,displayFlags(post.mMeta.mMsgId));
|
||||
|
||||
w.adjustSize();
|
||||
w.setFixedSize(option.rect.size());
|
||||
w.adjustSize();
|
||||
|
||||
QPixmap pixmap(option.rect.size());
|
||||
|
||||
@ -145,16 +146,16 @@ void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded)
|
||||
|
||||
mPostListWidget->forceRedraw();
|
||||
}
|
||||
void PostedPostDelegate::commentItem(RsGxsMessageId msgId,bool comment)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": received commentItem signal. b=" << comment << std::endl;
|
||||
if(comment)
|
||||
mShowCommentItems.insert(msgId);
|
||||
else
|
||||
mShowCommentItems.erase(msgId);
|
||||
|
||||
mPostListWidget->forceRedraw();
|
||||
}
|
||||
// void PostedPostDelegate::commentItem(RsGxsMessageId msgId,bool comment)
|
||||
// {
|
||||
// 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;
|
||||
@ -178,10 +179,10 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie
|
||||
|
||||
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)));
|
||||
QObject::connect(w,SIGNAL(commentsRequested(const RsGxsMessageId&,bool)),mPostListWidget,SLOT(openComments(const RsGxsMessageId&)));
|
||||
|
||||
w->adjustSize();
|
||||
w->setFixedSize(option.rect.size());
|
||||
w->adjustSize();
|
||||
|
||||
return w;
|
||||
}
|
||||
@ -217,6 +218,10 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
||||
|
||||
ui->idChooser->setFlags(IDCHOOSER_ID_REQUIRED);
|
||||
|
||||
connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
|
||||
ui->tabWidget->hideCloseButton(0);
|
||||
ui->tabWidget->hideCloseButton(1);
|
||||
|
||||
connect(ui->sortStrategy_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(updateSorting(int)));
|
||||
connect(ui->nextButton,SIGNAL(clicked()),this,SLOT(next10Posts()));
|
||||
connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prev10Posts()));
|
||||
@ -522,6 +527,9 @@ void PostedListWidgetWithModel::updateGroupData()
|
||||
|
||||
insertBoardDetails(mGroup);
|
||||
|
||||
while(ui->tabWidget->widget(2) != nullptr)
|
||||
tabCloseRequested(2);
|
||||
|
||||
emit groupDataLoaded();
|
||||
emit groupChanged(this); // signals the parent widget to e.g. update the group tab name
|
||||
} );
|
||||
@ -637,9 +645,40 @@ void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token)
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": not implemented" << std::endl;
|
||||
}
|
||||
|
||||
void PostedListWidgetWithModel::openComments(uint32_t /*type*/, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId>& msg_versions,const RsGxsMessageId &msgId, const QString &title)
|
||||
void PostedListWidgetWithModel::openComments(const RsGxsMessageId& msgId)
|
||||
{
|
||||
emit loadComment(groupId, msg_versions,msgId, title);
|
||||
QModelIndex index = mPostedPostsModel->getIndexOfMessage(msgId);
|
||||
|
||||
if(!index.isValid())
|
||||
return;
|
||||
|
||||
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
|
||||
BoardPostDisplayWidget *w = new BoardPostDisplayWidget(post,BoardPostDisplayWidget::DISPLAY_MODE_COMMENTS,BoardPostDisplayWidget::SHOW_COMMENTS);
|
||||
|
||||
QString title = QString::fromUtf8(post.mMeta.mMsgName.c_str());
|
||||
if(title.length() > 30)
|
||||
title = title.left(27) + "...";
|
||||
|
||||
ui->tabWidget->addTab(w,title);
|
||||
ui->tabWidget->layout();
|
||||
}
|
||||
|
||||
void PostedListWidgetWithModel::tabCloseRequested(int index)
|
||||
{
|
||||
std::cerr << "GxsCommentContainer::tabCloseRequested(" << index << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (index != 0)
|
||||
{
|
||||
QWidget *comments = ui->tabWidget->widget(index);
|
||||
ui->tabWidget->removeTab(index);
|
||||
delete comments;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsCommentContainer::tabCloseRequested() Not closing First Tab";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void PostedListWidgetWithModel::createMsg()
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void expandItem(RsGxsMessageId msgId,bool expanded);
|
||||
void commentItem(RsGxsMessageId msgId,bool comment);
|
||||
//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
|
||||
@ -107,7 +107,8 @@ public:
|
||||
virtual void deleteFeedItem(FeedItem *feedItem, uint32_t type);
|
||||
virtual void openChat(const RsPeerId& peerId);
|
||||
#endif
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId> &msg_versions, const RsGxsMessageId &msgId, const QString &title);
|
||||
public slots:
|
||||
virtual void openComments(const RsGxsMessageId &msgId);
|
||||
|
||||
protected:
|
||||
/* GxsMessageFramePostWidget */
|
||||
@ -130,6 +131,7 @@ protected:
|
||||
virtual void setAllMessagesReadDo(bool read, uint32_t &token) override;
|
||||
|
||||
private slots:
|
||||
void tabCloseRequested(int index);
|
||||
void updateSorting(int);
|
||||
void switchDisplayMode();
|
||||
void updateGroupData();
|
||||
|
@ -15,10 +15,13 @@
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<widget class="RSTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Details</string>
|
||||
@ -539,6 +542,12 @@ p, li { white-space: pre-wrap; }
|
||||
<extends>QComboBox</extends>
|
||||
<header>gui/gxs/GxsIdChooser.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>RSTabWidget</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header>gui/common/RSTabWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="Posted_images.qrc"/>
|
||||
|
Loading…
Reference in New Issue
Block a user