using a simple comments tree in tab in order to avoid layout problems

This commit is contained in:
csoler 2020-09-20 21:46:31 +02:00
parent 841152fb90
commit 1f253f6bfa
8 changed files with 60 additions and 105 deletions

View File

@ -55,11 +55,7 @@ BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, Display
ui->setupUi(this); ui->setupUi(this);
setup(); setup();
if(mode != DISPLAY_MODE_COMMENTS)
ui->verticalLayout->addStretch(); ui->verticalLayout->addStretch();
else
ui->commentsWidget->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
ui->verticalLayout->setAlignment(Qt::AlignTop); ui->verticalLayout->setAlignment(Qt::AlignTop);
ui->topLayout->setAlignment(Qt::AlignTop); ui->topLayout->setAlignment(Qt::AlignTop);
ui->arrowsLayout->addStretch(); ui->arrowsLayout->addStretch();
@ -184,24 +180,6 @@ void BoardPostDisplayWidget::setup()
ui->siteLabel->hide(); ui->siteLabel->hide();
} }
break; 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: case DISPLAY_MODE_CARD_VIEW:
{ {
ui->frame_picture->hide(); ui->frame_picture->hide();
@ -341,7 +319,7 @@ void BoardPostDisplayWidget::setup()
ui->siteLabel->setText(sitestr); ui->siteLabel->setText(sitestr);
if(dmode == DISPLAY_MODE_COMPACT || dmode == DISPLAY_MODE_COMMENTS) if(dmode == DISPLAY_MODE_COMPACT)
{ {
if(mPost.mImage.mData != NULL) if(mPost.mImage.mData != NULL)
{ {
@ -403,7 +381,6 @@ void BoardPostDisplayWidget::setup()
// feed. // feed.
//frame_comment->show(); //frame_comment->show();
if(dmode != DISPLAY_MODE_COMMENTS)
ui->commentButton->show(); ui->commentButton->show();
if (mPost.mComments) if (mPost.mComments)

View File

@ -40,7 +40,6 @@ public:
DISPLAY_MODE_UNKNOWN = 0x00, DISPLAY_MODE_UNKNOWN = 0x00,
DISPLAY_MODE_CARD_VIEW = 0x01, DISPLAY_MODE_CARD_VIEW = 0x01,
DISPLAY_MODE_COMPACT = 0x02, DISPLAY_MODE_COMPACT = 0x02,
DISPLAY_MODE_COMMENTS = 0x03,
}; };
enum DisplayFlags: uint8_t { enum DisplayFlags: uint8_t {

View File

@ -134,7 +134,7 @@
<item> <item>
<widget class="ClickableLabel" name="pictureLabel_compact"> <widget class="ClickableLabel" name="pictureLabel_compact">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>

View File

@ -29,6 +29,7 @@
#include "ui_PostedListWidgetWithModel.h" #include "ui_PostedListWidgetWithModel.h"
#include "gui/feeds/GxsChannelPostItem.h" #include "gui/feeds/GxsChannelPostItem.h"
#include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsIdDetails.h"
#include "gui/gxs/GxsCommentDialog.h"
#include "util/misc.h" #include "util/misc.h"
#include "gui/Posted/PostedCreatePostDialog.h" #include "gui/Posted/PostedCreatePostDialog.h"
#include "gui/common/UIStateHelper.h" #include "gui/common/UIStateHelper.h"
@ -653,14 +654,16 @@ void PostedListWidgetWithModel::openComments(const RsGxsMessageId& msgId)
return; return;
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ; RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
BoardPostDisplayWidget *w = new BoardPostDisplayWidget(post,BoardPostDisplayWidget::DISPLAY_MODE_COMMENTS,BoardPostDisplayWidget::SHOW_COMMENTS); auto *commentDialog = new GxsCommentDialog(this,rsPosted->getTokenService(),rsPosted);
std::set<RsGxsMessageId> msg_versions({post.mMeta.mMsgId});
commentDialog->commentLoad(post.mMeta.mGroupId, msg_versions, post.mMeta.mMsgId);
QString title = QString::fromUtf8(post.mMeta.mMsgName.c_str()); QString title = QString::fromUtf8(post.mMeta.mMsgName.c_str());
if(title.length() > 30) if(title.length() > 30)
title = title.left(27) + "..."; title = title.left(27) + "...";
ui->tabWidget->addTab(w,title); ui->tabWidget->addTab(commentDialog,title);
ui->tabWidget->layout();
} }
void PostedListWidgetWithModel::tabCloseRequested(int index) void PostedListWidgetWithModel::tabCloseRequested(int index)

View File

@ -152,10 +152,10 @@ void GxsCommentDialog::setCommentHeader(QWidget *header)
//header->setParent(ui->postFrame); //header->setParent(ui->postFrame);
//ui->postFrame->setVisible(true); //ui->postFrame->setVisible(true);
#if 0
QLayout *alayout = ui->postFrame->layout(); QLayout *alayout = ui->postFrame->layout();
alayout->addWidget(header); alayout->addWidget(header);
#if 0
ui->postFrame->setVisible(true); ui->postFrame->setVisible(true);
QDateTime qtime; QDateTime qtime;

View File

@ -20,31 +20,55 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="GxsCommentDialogGLayout"> <layout class="QGridLayout" name="GxsCommentDialogGLayout">
<item row="0" column="0"> <item row="1" column="0">
<widget class="QFrame" name="postFrame"> <widget class="GxsCommentTreeWidget" name="treeWidget">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QVBoxLayout" name="postFrameVLayout"> <property name="sortingEnabled">
<property name="leftMargin"> <bool>true</bool>
<number>1</number>
</property> </property>
<property name="topMargin"> <column>
<number>1</number> <property name="text">
<string>Comment</string>
</property> </property>
<property name="rightMargin"> </column>
<number>1</number> <column>
<property name="text">
<string>Author</string>
</property> </property>
<property name="bottomMargin"> </column>
<number>1</number> <column>
<property name="text">
<string>Date</string>
</property> </property>
</layout> </column>
<column>
<property name="text">
<string>Score</string>
</property>
</column>
<column>
<property name="text">
<string>UpVotes</string>
</property>
</column>
<column>
<property name="text">
<string>DownVotes</string>
</property>
</column>
<column>
<property name="text">
<string>OwnVote</string>
</property>
</column>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="0" column="0">
<layout class="QHBoxLayout" name="toolBarHLayout"> <layout class="QHBoxLayout" name="toolBarHLayout">
<item> <item>
<widget class="QToolButton" name="commentButton"> <widget class="QToolButton" name="commentButton">
@ -147,54 +171,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0">
<widget class="GxsCommentTreeWidget" name="treeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Comment</string>
</property>
</column>
<column>
<property name="text">
<string>Author</string>
</property>
</column>
<column>
<property name="text">
<string>Date</string>
</property>
</column>
<column>
<property name="text">
<string>Score</string>
</property>
</column>
<column>
<property name="text">
<string>UpVotes</string>
</property>
</column>
<column>
<property name="text">
<string>DownVotes</string>
</property>
</column>
<column>
<property name="text">
<string>OwnVote</string>
</property>
</column>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>

View File

@ -428,7 +428,7 @@ p, li { white-space: pre-wrap; }
</font> </font>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -593,16 +593,16 @@ p, li { white-space: pre-wrap; }
<extends>QToolButton</extends> <extends>QToolButton</extends>
<header>gui/common/SubscribeToolButton.h</header> <header>gui/common/SubscribeToolButton.h</header>
</customwidget> </customwidget>
<customwidget>
<class>StyledElidedLabel</class>
<extends>QLabel</extends>
<header>gui/common/StyledElidedLabel.h</header>
</customwidget>
<customwidget> <customwidget>
<class>RSTreeView</class> <class>RSTreeView</class>
<extends>QTreeView</extends> <extends>QTreeView</extends>
<header>gui/common/RSTreeView.h</header> <header>gui/common/RSTreeView.h</header>
</customwidget> </customwidget>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header>gui/common/LineEditClear.h</header>
</customwidget>
<customwidget> <customwidget>
<class>GxsCommentDialog</class> <class>GxsCommentDialog</class>
<extends>QWidget</extends> <extends>QWidget</extends>
@ -610,9 +610,9 @@ p, li { white-space: pre-wrap; }
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>LineEditClear</class> <class>StyledElidedLabel</class>
<extends>QLineEdit</extends> <extends>QLabel</extends>
<header>gui/common/LineEditClear.h</header> <header>gui/common/StyledElidedLabel.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>

View File

@ -1409,7 +1409,7 @@ posted {
gui/Posted/PostedItem.ui \ gui/Posted/PostedItem.ui \
gui/Posted/PostedCardView.ui \ gui/Posted/PostedCardView.ui \
gui/Posted/PostedCreatePostDialog.ui \ gui/Posted/PostedCreatePostDialog.ui \
gui/Posted/PhotoView.ui gui/Posted/PhotoView.ui \
#gui/Posted/PostedDialog.ui \ #gui/Posted/PostedDialog.ui \
#gui/Posted/PostedComments.ui \ #gui/Posted/PostedComments.ui \
#gui/Posted/PostedCreateCommentDialog.ui #gui/Posted/PostedCreateCommentDialog.ui