split the UI for board items into two different widgets

This commit is contained in:
csoler 2020-09-25 23:16:29 +02:00
parent 5dfa481f2f
commit 4787675e91
6 changed files with 897 additions and 379 deletions

View File

@ -22,6 +22,7 @@
#include <QMenu> #include <QMenu>
#include <QStyle> #include <QStyle>
#include <QTextDocument> #include <QTextDocument>
#include <QToolButton>
#include "rshare.h" #include "rshare.h"
#include "BoardPostDisplayWidget.h" #include "BoardPostDisplayWidget.h"
@ -34,7 +35,8 @@
#include "gui/Identity/IdDialog.h" #include "gui/Identity/IdDialog.h"
#include "gui/MainWindow.h" #include "gui/MainWindow.h"
#include "ui_BoardPostDisplayWidget.h" #include "ui_BoardPostDisplayWidget_compact.h"
#include "ui_BoardPostDisplayWidget_card.h"
#include <retroshare/rsposted.h> #include <retroshare/rsposted.h>
#include <iostream> #include <iostream>
@ -46,38 +48,15 @@
const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2.png"; const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2.png";
//=================================================================================================================================== //===================================================================================================================================
//== Base class BoardPostDisplayWidget == //== Base class BoardPostDisplayWidgetBase ==
//=================================================================================================================================== //===================================================================================================================================
BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, DisplayMode mode, uint8_t display_flags, QWidget *parent) BoardPostDisplayWidgetBase::BoardPostDisplayWidgetBase(const RsPostedPost& post,uint8_t display_flags,QWidget *parent)
: QWidget(parent),mPost(post),dmode(mode),mDisplayFlags(display_flags),ui(new Ui::BoardPostDisplayWidget()) : QWidget(parent), mPost(post),mDisplayFlags(display_flags)
{ {
ui->setupUi(this);
setup();
ui->verticalLayout->addStretch();
ui->verticalLayout->setAlignment(Qt::AlignTop);
ui->topLayout->setAlignment(Qt::AlignTop);
ui->arrowsLayout->addStretch();
ui->arrowsLayout->setAlignment(Qt::AlignTop);
ui->verticalLayout_2->addStretch();
// ui->verticalLayout_3->addStretch();
// ui->verticalLayout_3->setAlignment(Qt::AlignTop);
adjustSize();
// if(display_flags & SHOW_COMMENTS)
// {
// ui->commentsWidget->setTokenService(rsPosted->getTokenService(),rsPosted);
//
// std::set<RsGxsMessageId> post_versions ;
// post_versions.insert(post.mMeta.mMsgId) ;
//
// ui->commentsWidget->commentLoad(post.mMeta.mGroupId, post_versions,mPost.mMeta.mMsgId,true);
// }
} }
void BoardPostDisplayWidget::setCommentsSize(int comNb) void BoardPostDisplayWidgetBase::setCommentsSize(int comNb)
{ {
QString sComButText = tr("Comment"); QString sComButText = tr("Comment");
if (comNb == 1) if (comNb == 1)
@ -85,151 +64,106 @@ void BoardPostDisplayWidget::setCommentsSize(int comNb)
else if(comNb > 1) else if(comNb > 1)
sComButText = tr("Comments ").append("(%1)").arg(comNb); sComButText = tr("Comments ").append("(%1)").arg(comNb);
ui->commentButton->setText(sComButText); commentButton()->setText(sComButText);
} }
void BoardPostDisplayWidget::makeDownVote() void BoardPostDisplayWidgetBase::makeDownVote()
{ {
RsGxsGrpMsgIdPair msgId; RsGxsGrpMsgIdPair msgId;
msgId.first = mPost.mMeta.mGroupId; msgId.first = mPost.mMeta.mGroupId;
msgId.second = mPost.mMeta.mMsgId; msgId.second = mPost.mMeta.mMsgId;
ui->voteUpButton->setEnabled(false); voteUpButton()->setEnabled(false);
ui->voteDownButton->setEnabled(false); voteDownButton()->setEnabled(false);
emit vote(msgId, false); emit vote(msgId, false);
} }
void BoardPostDisplayWidget::makeUpVote() void BoardPostDisplayWidgetBase::makeUpVote()
{ {
RsGxsGrpMsgIdPair msgId; RsGxsGrpMsgIdPair msgId;
msgId.first = mPost.mMeta.mGroupId; msgId.first = mPost.mMeta.mGroupId;
msgId.second = mPost.mMeta.mMsgId; msgId.second = mPost.mMeta.mMsgId;
ui->voteUpButton->setEnabled(false); voteUpButton()->setEnabled(false);
ui->voteDownButton->setEnabled(false); voteDownButton()->setEnabled(false);
emit vote(msgId, true); emit vote(msgId, true);
} }
void BoardPostDisplayWidget::setReadStatus(bool isNew, bool isUnread) void BoardPostDisplayWidgetBase::setReadStatus(bool isNew, bool isUnread)
{ {
if (isUnread) if (isUnread)
{ {
ui->readButton->setChecked(true); readButton()->setChecked(true);
ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); readButton()->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png"));
} }
else else
{ {
ui->readButton->setChecked(false); readButton()->setChecked(false);
ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png")); readButton()->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png"));
} }
ui->newLabel->setVisible(isNew); newLabel()->setVisible(isNew);
// ui->mainFrame->setProperty("new", isNew);
// ui->mainFrame->style()->unpolish(ui->mainFrame);
// ui->mainFrame->style()->polish( ui->mainFrame);
} }
void BoardPostDisplayWidget::setComment(const RsGxsComment& cmt) {} void BoardPostDisplayWidget::doExpand(bool e)
BoardPostDisplayWidget::~BoardPostDisplayWidget()
{ {
delete(ui); std::cerr << "Expanding" << std::endl;
if(e)
ui->notes->show();
else
ui->notes->hide();
emit expand(mPost.mMeta.mMsgId,e);
} }
void BoardPostDisplayWidgetBase::loadComments(bool e)
void BoardPostDisplayWidget::viewPicture()
{ {
if(mPost.mImage.mData == NULL) emit commentsRequested(mPost.mMeta.mMsgId,e);
return; }
QString timestamp = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); void BoardPostDisplayWidgetBase::readToggled(bool s)
QPixmap pixmap; {
GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); emit changeReadStatusRequested(mPost.mMeta.mMsgId,s);
RsGxsId authorID = mPost.mMeta.mAuthorId; }
void BoardPostDisplayWidgetBase::showAuthorInPeople()
PhotoView *PView = new PhotoView(this); {
if(mPost.mMeta.mAuthorId.isNull())
PView->setPixmap(pixmap); {
PView->setTitle(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); std::cerr << "(EE) GxsForumThreadWidget::loadMsgData_showAuthorInPeople() ERROR Missing Message Data...";
PView->setName(authorID); std::cerr << std::endl;
PView->setTime(timestamp); }
PView->setGroupId(mPost.mMeta.mGroupId);
PView->setMessageId(mPost.mMeta.mMsgId);
PView->show();
/* window will destroy itself! */ /* window will destroy itself! */
IdDialog *idDialog = dynamic_cast<IdDialog*>(MainWindow::getPage(MainWindow::People));
if (!idDialog)
return ;
MainWindow::showWindow(MainWindow::People);
idDialog->navigate(RsGxsId(mPost.mMeta.mAuthorId));
} }
void BoardPostDisplayWidget::toggleNotes() {} void BoardPostDisplayWidgetBase::setup()
void BoardPostDisplayWidget::setup()
{ {
// show/hide things based on the view type // show/hide things based on the view type
switch(dmode)
{
default:
case DISPLAY_MODE_COMPACT:
{
ui->pictureLabel_compact->show();
//ui->expandButton->hide();
ui->expandButton->show(); // always hide, since we have the photoview already
ui->pictureLabel->hide();
ui->notes->hide();
ui->siteLabel->hide();
}
break;
case DISPLAY_MODE_CARD_VIEW:
{
ui->frame_picture->hide();
ui->pictureLabel_compact->hide();
ui->expandButton->hide();
}
break;
}
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)) if(!(mDisplayFlags & SHOW_COMMENTS))
{ commentButton()->setChecked(false);
//ui->commentsWidget->hide();
ui->commentButton->setChecked(false);
}
else else
ui->commentButton->setChecked(true); commentButton()->setChecked(true);
setAttribute(Qt::WA_DeleteOnClose, true);
/* clear ui */ /* clear ui */
ui->titleLabel->setText(tr("Loading")); titleLabel()->setText(tr("Loading"));
ui->dateLabel->clear(); dateLabel()->clear();
ui->fromLabel->clear(); fromLabel()->clear();
ui->siteLabel->clear(); siteLabel()->clear();
connect(ui->expandButton, SIGNAL(toggled(bool)), this, SLOT(doExpand(bool))); QObject::connect(commentButton(), SIGNAL(toggled(bool)), this, SLOT(loadComments(bool)));
connect(ui->commentButton, SIGNAL(toggled(bool)), this, SLOT(loadComments(bool))); QObject::connect(voteUpButton(), SIGNAL(clicked()), this, SLOT(makeUpVote()));
connect(ui->voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote())); QObject::connect(voteDownButton(), SIGNAL(clicked()), this, SLOT(makeDownVote()));
connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT(makeDownVote())); QObject::connect(readButton(), SIGNAL(toggled(bool)), this, SLOT(readToggled(bool)));
connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool)));
QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this); QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this);
connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink())); connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink()));
@ -239,32 +173,32 @@ void BoardPostDisplayWidget::setup()
int S = QFontMetricsF(font()).height() ; int S = QFontMetricsF(font()).height() ;
ui->voteUpButton->setIconSize(QSize(S*1.5,S*1.5)); voteUpButton()->setIconSize(QSize(S*1.5,S*1.5));
ui->voteDownButton->setIconSize(QSize(S*1.5,S*1.5)); voteDownButton()->setIconSize(QSize(S*1.5,S*1.5));
ui->commentButton->setIconSize(QSize(S*1.5,S*1.5)); commentButton()->setIconSize(QSize(S*1.5,S*1.5));
ui->readButton->setIconSize(QSize(S*1.5,S*1.5)); readButton()->setIconSize(QSize(S*1.5,S*1.5));
ui->shareButton->setIconSize(QSize(S*1.5,S*1.5)); shareButton()->setIconSize(QSize(S*1.5,S*1.5));
QMenu *menu = new QMenu(); QMenu *menu = new QMenu();
menu->addAction(CopyLinkAction); menu->addAction(CopyLinkAction);
menu->addSeparator(); menu->addSeparator();
menu->addAction(showInPeopleAct); menu->addAction(showInPeopleAct);
ui->shareButton->setMenu(menu); shareButton()->setMenu(menu);
RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId);
bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
if(redacted) if(redacted)
{ {
ui->commentButton->setDisabled(true); commentButton()->setDisabled(true);
ui->voteUpButton->setDisabled(true); voteUpButton()->setDisabled(true);
ui->voteDownButton->setDisabled(true); voteDownButton()->setDisabled(true);
ui->fromLabel->setId(mPost.mMeta.mAuthorId); fromLabel()->setId(mPost.mMeta.mAuthorId);
ui->titleLabel->setText(tr( "<p><font color=\"#ff0000\"><b>The author of this message (with ID %1) is banned.</b>").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; titleLabel()->setText(tr( "<p><font color=\"#ff0000\"><b>The author of this message (with ID %1) is banned.</b>").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ;
QDateTime qtime; QDateTime qtime;
qtime.setTime_t(mPost.mMeta.mPublishTs); qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy");
ui->dateLabel->setText(timestamp); dateLabel()->setText(timestamp);
} }
else else
{ {
@ -274,10 +208,10 @@ void BoardPostDisplayWidget::setup()
qtime.setTime_t(mPost.mMeta.mPublishTs); qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy");
QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs) + " " + tr("ago"); QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs) + " " + tr("ago");
ui->dateLabel->setText(timestamp2); dateLabel()->setText(timestamp2);
ui->dateLabel->setToolTip(timestamp); dateLabel()->setToolTip(timestamp);
ui->fromLabel->setId(mPost.mMeta.mAuthorId); fromLabel()->setId(mPost.mMeta.mAuthorId);
// Use QUrl to check/parse our URL // Use QUrl to check/parse our URL
// The only combination that seems to work: load as EncodedUrl, extract toEncoded(). // The only combination that seems to work: load as EncodedUrl, extract toEncoded().
@ -311,20 +245,97 @@ void BoardPostDisplayWidget::setup()
QString siteurl = url.toEncoded(); QString siteurl = url.toEncoded();
sitestr = QString("<a href=\"%1\" ><span style=\" text-decoration: underline; color:#0079d3;\"> %2 </span></a>").arg(siteurl).arg(siteurl); sitestr = QString("<a href=\"%1\" ><span style=\" text-decoration: underline; color:#0079d3;\"> %2 </span></a>").arg(siteurl).arg(siteurl);
ui->titleLabel->setText(urlstr); titleLabel()->setText(urlstr);
} }
else else
ui->titleLabel->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) ); titleLabel()->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) );
if (urlarray.isEmpty()) if (urlarray.isEmpty())
{ siteLabel()->hide();
ui->siteLabel->hide();
}
ui->siteLabel->setText(sitestr); siteLabel()->setText(sitestr);
}
if(dmode == DISPLAY_MODE_COMPACT) //QString score = "Hot" + QString::number(post.mHotScore);
{ //score += " Top" + QString::number(post.mTopScore);
//score += " New" + QString::number(post.mNewScore);
QString score = QString::number(mPost.mTopScore);
scoreLabel()->setText(score);
// FIX THIS UP LATER.
notes()->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
pictureLabel()->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
// feed.
//frame_comment->show();
commentButton()->show();
if (mPost.mComments)
{
QString commentText = tr("Comments (%1)").arg(QString::number(mPost.mComments));
commentButton()->setText(commentText);
}
else
commentButton()->setText(tr("Comment"));
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)
{
voteUpButton()->setEnabled(false);
voteDownButton()->setEnabled(false);
}
connect(pictureLabel(), SIGNAL(clicked()), this, SLOT(viewPicture()));
#ifdef TODO
emit sizeChanged(this);
#endif
}
//===================================================================================================================================
//== class BoardPostDisplayWidget ==
//===================================================================================================================================
BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, uint8_t display_flags,QWidget *parent=nullptr)
: BoardPostDisplayWidgetBase(post,display_flags,parent), ui(new Ui::BoardPostDisplayWidget_compact())
{
ui->setupUi(this);
setup();
ui->verticalLayout->addStretch();
ui->verticalLayout->setAlignment(Qt::AlignTop);
ui->topLayout->setAlignment(Qt::AlignTop);
ui->arrowsLayout->addStretch();
ui->arrowsLayout->setAlignment(Qt::AlignTop);
ui->verticalLayout_2->addStretch();
adjustSize();
}
BoardPostDisplayWidget::~BoardPostDisplayWidget()
{
delete ui;
}
void BoardPostDisplayWidget::setup()
{
BoardPostDisplayWidgetBase::setup();
// show/hide things based on the view type
setAttribute(Qt::WA_DeleteOnClose, true);
RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId);
bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
if(redacted)
{
}
else
{
if(mPost.mImage.mData != NULL) if(mPost.mImage.mData != NULL)
{ {
QPixmap pixmap; QPixmap pixmap;
@ -334,102 +345,38 @@ void BoardPostDisplayWidget::setup()
int desired_height = QFontMetricsF(font()).height() * 5; int desired_height = QFontMetricsF(font()).height() * 5;
QPixmap scaledpixmap = pixmap.scaledToHeight(desired_height, Qt::SmoothTransformation); QPixmap scaledpixmap = pixmap.scaledToHeight(desired_height, Qt::SmoothTransformation);
ui->pictureLabel_compact->setPixmap(scaledpixmap); ui->pictureLabel->setPixmap(scaledpixmap);
}
else if (mPost.mImage.mData == NULL)
ui->pictureLabel_compact->hide();
else
ui->pictureLabel_compact->show();
}
else
{
if(mPost.mImage.mData != NULL)
{
QPixmap pixmap;
GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL);
// Wiping data - as its been passed to thumbnail.
QPixmap scaledpixmap;
if(pixmap.width() > 800){
QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation);
ui->pictureLabel->setPixmap(scaledpixmap);
}else{
ui->pictureLabel->setPixmap(pixmap);
}
} }
else if (mPost.mImage.mData == NULL) else if (mPost.mImage.mData == NULL)
ui->pictureLabel->hide(); ui->pictureLabel->hide();
else else
ui->pictureLabel->show(); ui->pictureLabel->show();
} }
}
//QString score = "Hot" + QString::number(post.mHotScore);
//score += " Top" + QString::number(post.mTopScore);
//score += " New" + QString::number(post.mNewScore);
QString score = QString::number(mPost.mTopScore);
ui->scoreLabel->setText(score);
// FIX THIS UP LATER.
ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
ui->pictureLabel_2->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
QObject::connect(ui->expandButton, SIGNAL(toggled(bool)), this, SLOT(doExpand(bool)));
QTextDocument doc; QTextDocument doc;
doc.setHtml(ui->notes->text()); doc.setHtml(notes()->text());
if(mDisplayFlags & SHOW_NOTES)
{
notes()->show();
ui->expandButton->setChecked(true);
}
else
{
notes()->hide();
ui->expandButton->setChecked(false);
}
if(doc.toPlainText().trimmed().isEmpty()) if(doc.toPlainText().trimmed().isEmpty())
{ {
ui->notes->hide(); notes()->hide();
ui->expandButton->hide(); ui->expandButton->hide();
} }
// feed.
//frame_comment->show();
ui->commentButton->show();
if (mPost.mComments)
{
QString commentText = tr("Comments (%1)").arg(QString::number(mPost.mComments));
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));
// disable voting buttons - if they have already voted.
if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK)
{
ui->voteUpButton->setEnabled(false);
ui->voteDownButton->setEnabled(false);
}
#if 0
uint32_t up, down, nComments;
bool ok = rsPosted->retrieveScores(mPost.mMeta.mServiceString, up, down, nComments);
if(ok)
{
int32_t vote = up - down;
scoreLabel->setText(QString::number(vote));
numCommentsLabel->setText("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px;"
"margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span"
"style=\" font-size:10pt; font-weight:600;\">#</span><span "
"style=\" font-size:8pt; font-weight:600;\"> Comments: "
+ QString::number(nComments) + "</span></p>");
}
mInFill = false;
#endif
ui->pictureLabel_compact->setUseStyleSheet(false); // If not this, causes dilation of the image.
connect(ui->pictureLabel_compact, SIGNAL(clicked()), this, SLOT(viewPicture()));
updateGeometry(); updateGeometry();
#ifdef TODO #ifdef TODO
@ -437,45 +384,111 @@ void BoardPostDisplayWidget::setup()
#endif #endif
} }
void BoardPostDisplayWidget::doExpand(bool e) void BoardPostDisplayWidget::viewPicture()
{ {
std::cerr << "Expanding" << std::endl; if(mPost.mImage.mData == NULL)
if(e) return;
{
//ui->notes->show();
ui->pictureLabel_2->show();
}
else
{
//ui->notes->hide();
ui->pictureLabel_2->hide();
}
emit expand(mPost.mMeta.mMsgId,e);
}
void BoardPostDisplayWidget::loadComments(bool e) QString timestamp = misc::timeRelativeToNow(mPost.mMeta.mPublishTs);
{ QPixmap pixmap;
emit commentsRequested(mPost.mMeta.mMsgId,e); GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL);
} RsGxsId authorID = mPost.mMeta.mAuthorId;
void BoardPostDisplayWidget::readToggled(bool s) PhotoView *PView = new PhotoView();
{
emit changeReadStatusRequested(mPost.mMeta.mMsgId,s); PView->setPixmap(pixmap);
} PView->setTitle(QString::fromUtf8(mPost.mMeta.mMsgName.c_str()));
void BoardPostDisplayWidget::showAuthorInPeople() PView->setName(authorID);
{ PView->setTime(timestamp);
if(mPost.mMeta.mAuthorId.isNull()) PView->setGroupId(mPost.mMeta.mGroupId);
{ PView->setMessageId(mPost.mMeta.mMsgId);
std::cerr << "(EE) GxsForumThreadWidget::loadMsgData_showAuthorInPeople() ERROR Missing Message Data...";
std::cerr << std::endl; PView->show();
}
/* window will destroy itself! */ /* window will destroy itself! */
IdDialog *idDialog = dynamic_cast<IdDialog*>(MainWindow::getPage(MainWindow::People));
if (!idDialog)
return ;
MainWindow::showWindow(MainWindow::People);
idDialog->navigate(RsGxsId(mPost.mMeta.mAuthorId));
} }
QToolButton *BoardPostDisplayWidget::voteUpButton() { return ui->voteUpButton; }
QToolButton *BoardPostDisplayWidget::commentButton() { return ui->commentButton; }
QToolButton *BoardPostDisplayWidget::voteDownButton() { return ui->voteDownButton; }
QLabel *BoardPostDisplayWidget::newLabel() { return ui->newLabel; }
QToolButton *BoardPostDisplayWidget::readButton() { return ui->readButton; }
QLabel *BoardPostDisplayWidget::siteLabel() { return ui->siteLabel; }
GxsIdLabel *BoardPostDisplayWidget::fromLabel() { return ui->fromLabel; }
QLabel *BoardPostDisplayWidget::dateLabel() { return ui->dateLabel; }
QLabel *BoardPostDisplayWidget::titleLabel() { return ui->titleLabel; }
QLabel *BoardPostDisplayWidget::scoreLabel() { return ui->scoreLabel; }
QLabel *BoardPostDisplayWidget::notes() { return ui->notes; }
QPushButton *BoardPostDisplayWidget::shareButton() { return ui->shareButton; }
QLabel *BoardPostDisplayWidget::pictureLabel() { return ui->pictureLabel; }
//===================================================================================================================================
//== class BoardPostDisplayWidget_card ==
//===================================================================================================================================
BoardPostDisplayWidget_card::BoardPostDisplayWidget_card(const RsPostedPost& post, uint8_t display_flags, QWidget *parent)
: BoardPostDisplayWidgetBase(post,display_flags,parent), ui(new Ui::BoardPostDisplayWidget_card())
{
ui->setupUi(this);
setup();
ui->verticalLayout->addStretch();
ui->verticalLayout->setAlignment(Qt::AlignTop);
ui->topLayout->setAlignment(Qt::AlignTop);
ui->arrowsLayout->addStretch();
ui->arrowsLayout->setAlignment(Qt::AlignTop);
ui->verticalLayout_2->addStretch();
adjustSize();
}
BoardPostDisplayWidget_card::~BoardPostDisplayWidget_card()
{
delete ui;
}
void BoardPostDisplayWidget_card::setup()
{
BoardPostDisplayWidgetBase::setup();
if(mPost.mImage.mData != NULL)
{
QPixmap pixmap;
GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL);
// Wiping data - as its been passed to thumbnail.
QPixmap scaledpixmap;
if(pixmap.width() > 800){
QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation);
pictureLabel()->setPixmap(scaledpixmap);
}else{
pictureLabel()->setPixmap(pixmap);
}
}
else if (mPost.mImage.mData == NULL)
pictureLabel()->hide();
else
pictureLabel()->show();
QTextDocument doc;
doc.setHtml(notes()->text());
if(doc.toPlainText().trimmed().isEmpty())
notes()->hide();
}
QToolButton *BoardPostDisplayWidget_card::voteUpButton() { return ui->voteUpButton; }
QToolButton *BoardPostDisplayWidget_card::commentButton() { return ui->commentButton; }
QToolButton *BoardPostDisplayWidget_card::voteDownButton() { return ui->voteDownButton; }
QLabel *BoardPostDisplayWidget_card::newLabel() { return ui->newLabel; }
QToolButton *BoardPostDisplayWidget_card::readButton() { return ui->readButton; }
QLabel *BoardPostDisplayWidget_card::siteLabel() { return ui->siteLabel; }
GxsIdLabel *BoardPostDisplayWidget_card::fromLabel() { return ui->fromLabel; }
QLabel *BoardPostDisplayWidget_card::dateLabel() { return ui->dateLabel; }
QLabel *BoardPostDisplayWidget_card::titleLabel() { return ui->titleLabel; }
QLabel *BoardPostDisplayWidget_card::scoreLabel() { return ui->scoreLabel; }
QLabel *BoardPostDisplayWidget_card::notes() { return ui->notes; }
QPushButton *BoardPostDisplayWidget_card::shareButton() { return ui->shareButton; }
QLabel *BoardPostDisplayWidget_card::pictureLabel() { return ui->pictureLabel; }

View File

@ -26,53 +26,67 @@
#include <retroshare/rsposted.h> #include <retroshare/rsposted.h>
namespace Ui { namespace Ui {
class BoardPostDisplayWidget; class BoardPostDisplayWidget_card;
class BoardPostDisplayWidget_compact;
} }
class QPushButton;
class QLabel;
class QToolButton;
class QTextEdit;
class ClickableLabel;
class GxsIdLabel;
struct RsPostedPost; struct RsPostedPost;
class BoardPostDisplayWidget : public QWidget class BoardPostDisplayWidgetBase: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
enum DisplayMode {
DISPLAY_MODE_UNKNOWN = 0x00,
DISPLAY_MODE_CARD_VIEW = 0x01,
DISPLAY_MODE_COMPACT = 0x02,
};
enum DisplayFlags: uint8_t { enum DisplayFlags: uint8_t {
SHOW_NONE = 0x00, SHOW_NONE = 0x00,
SHOW_COMMENTS = 0x01, SHOW_COMMENTS = 0x01,
SHOW_NOTES = 0x02, SHOW_NOTES = 0x02,
}; };
BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,uint8_t display_flags,QWidget *parent=nullptr); enum DisplayMode: uint8_t {
virtual ~BoardPostDisplayWidget(); DISPLAY_MODE_UNKNOWN = 0x00,
DISPLAY_MODE_COMPACT = 0x01,
DISPLAY_MODE_CARD = 0x02,
};
BoardPostDisplayWidgetBase(const RsPostedPost& post,uint8_t display_flags,QWidget *parent);
virtual ~BoardPostDisplayWidgetBase() {}
static const char *DEFAULT_BOARD_IMAGE; static const char *DEFAULT_BOARD_IMAGE;
public slots:
void viewPicture() ;
protected slots: protected slots:
/* GxsGroupFeedItem */ /* GxsGroupFeedItem */
virtual void setup(); // to be overloaded by the different views virtual void setup(); // to be overloaded by the different views
void doExpand(bool) ; virtual QToolButton *voteUpButton() =0;
void setComment(const RsGxsComment&) ; virtual QToolButton *commentButton() =0;
void setReadStatus(bool isNew, bool isUnread) ; virtual QToolButton *voteDownButton() =0;
virtual QLabel *newLabel() =0;
virtual QLabel *titleLabel()=0;
virtual QLabel *siteLabel()=0;
virtual GxsIdLabel *fromLabel()=0;
virtual QLabel *dateLabel()=0;
virtual QLabel *scoreLabel() =0;
virtual QLabel *notes() =0;
virtual QLabel *pictureLabel()=0;
virtual QToolButton *readButton() =0;
virtual QPushButton *shareButton() =0;
void toggle() {}
void setCommentsSize(int comNb) ;
void loadComments(bool e); void loadComments(bool e);
void makeUpVote() ;
void makeDownVote() ;
void toggleNotes() ;
void showAuthorInPeople(); void showAuthorInPeople();
void readToggled(bool); void readToggled(bool);
void setReadStatus(bool isNew, bool isUnread) ;
void makeUpVote() ;
void makeDownVote() ;
void setCommentsSize(int comNb) ;
signals: signals:
void changeReadStatusRequested(const RsGxsMessageId&,bool); void changeReadStatusRequested(const RsGxsMessageId&,bool);
@ -82,12 +96,79 @@ signals:
protected: protected:
RsPostedPost mPost; RsPostedPost mPost;
uint8_t mDisplayFlags;
};
DisplayMode dmode; class BoardPostDisplayWidget : public BoardPostDisplayWidgetBase
uint8_t mDisplayFlags; {
Q_OBJECT
public:
BoardPostDisplayWidget(const RsPostedPost& post, uint8_t display_flags, QWidget *parent);
virtual ~BoardPostDisplayWidget();
static const char *DEFAULT_BOARD_IMAGE;
QToolButton *voteUpButton() override;
QToolButton *commentButton() override;
QToolButton *voteDownButton() override;
QLabel *newLabel() override;
QLabel *siteLabel() override;
GxsIdLabel *fromLabel() override;
QLabel *dateLabel() override;
QLabel *titleLabel() override;
QLabel *scoreLabel() override;
QLabel *notes() override;
QLabel *pictureLabel() override;
QToolButton *readButton() override;
QPushButton *shareButton() override;
public slots:
void viewPicture() ;
protected slots:
/* GxsGroupFeedItem */
void doExpand(bool) ;
protected:
void setup() override; // to be overloaded by the different views
private: private:
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::BoardPostDisplayWidget *ui; Ui::BoardPostDisplayWidget_compact *ui;
}; };
class BoardPostDisplayWidget_card : public BoardPostDisplayWidgetBase
{
Q_OBJECT
public:
BoardPostDisplayWidget_card(const RsPostedPost& post,uint8_t display_flags,QWidget *parent=nullptr);
virtual ~BoardPostDisplayWidget_card();
static const char *DEFAULT_BOARD_IMAGE;
QToolButton *voteUpButton() override;
QToolButton *commentButton() override;
QToolButton *voteDownButton() override;
QLabel *newLabel() override;
QLabel *siteLabel() override;
GxsIdLabel *fromLabel() override;
QLabel *dateLabel() override;
QLabel *titleLabel() override;
QLabel *scoreLabel() override;
QLabel *notes() override;
QToolButton *readButton() override;
QPushButton *shareButton() override;
QLabel *pictureLabel() override;
protected slots:
/* GxsGroupFeedItem */
protected:
void setup() override; // to be overloaded by the different views
private:
/** Qt Designer generated object */
Ui::BoardPostDisplayWidget_card *ui;
};

View File

@ -0,0 +1,449 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BoardPostDisplayWidget_card</class>
<widget class="QWidget" name="BoardPostDisplayWidget_card">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>558</width>
<height>202</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>2</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="topLayout">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QVBoxLayout" name="arrowsLayout">
<item>
<widget class="QToolButton" name="voteUpButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Vote up</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/up-arrow.png</normaloff>:/images/up-arrow.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="StyledLabel" name="scoreLabel">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="voteDownButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Vote down</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>\/</string>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/down-arrow.png</normaloff>:/images/down-arrow.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="StyledLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="fromBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Posted by</string>
</property>
</widget>
</item>
<item>
<widget class="GxsIdLabel" name="fromLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="dateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">You eyes only</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>70</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="readButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Toggle Message Read Status</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/message-state-unread.png</normaloff>:/images/message-state-unread.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="newLabel">
<property name="text">
<string>New</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="shareButton">
<property name="text">
<string>Share</string>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/share.png</normaloff>:/images/share.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="commentButton">
<property name="text">
<string>Comments</string>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/comments.png</normaloff>:/images/comments.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="siteLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">site</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="pictureLabelLayout">
<item>
<widget class="QLabel" name="pictureLabel">
<property name="text">
<string>PictureLabel</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>268</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="notes">
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GxsIdLabel</class>
<extends>QLabel</extends>
<header>gui/gxs/GxsIdLabel.h</header>
</customwidget>
<customwidget>
<class>StyledLabel</class>
<extends>QLabel</extends>
<header>gui/common/StyledLabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="Posted_images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>BoardPostDisplayWidget</class> <class>BoardPostDisplayWidget_compact</class>
<widget class="QWidget" name="BoardPostDisplayWidget"> <widget class="QWidget" name="BoardPostDisplayWidget_compact">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>558</width> <width>540</width>
<height>202</height> <height>172</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -163,7 +163,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="ClickableLabel" name="pictureLabel_compact"> <widget class="ClickableLabel" name="pictureLabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -293,6 +293,22 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QLabel" name="siteLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">site</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
@ -400,62 +416,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QLabel" name="notes">
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="siteLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">site</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="pictureLabelLayout">
<item>
<widget class="QLabel" name="pictureLabel">
<property name="text">
<string>PictureLabel</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>268</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -488,7 +448,7 @@
<number>2</number> <number>2</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="pictureLabel_2"> <widget class="QLabel" name="notes">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>

View File

@ -91,16 +91,25 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
painter->fillRect( option.rect, option.backgroundBrush); painter->fillRect( option.rect, option.backgroundBrush);
painter->restore(); painter->restore();
BoardPostDisplayWidget w(post,mDisplayMode,displayFlags(post.mMeta.mMsgId)); QPixmap pixmap(option.rect.size());
w.setFixedSize(option.rect.size());
w.adjustSize();
QPixmap pixmap(option.rect.size());
pixmap.fill(QRgb(0x00f0f0f0)); // choose a fully transparent background pixmap.fill(QRgb(0x00f0f0f0)); // choose a fully transparent background
w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background if(mDisplayMode == BoardPostDisplayWidget::DISPLAY_MODE_COMPACT)
{
BoardPostDisplayWidget w(post,displayFlags(post.mMeta.mMsgId),nullptr);
w.setFixedSize(option.rect.size());
w.adjustSize();
w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background
}
else
{
BoardPostDisplayWidget_card w(post,displayFlags(post.mMeta.mMsgId),nullptr);
w.setFixedSize(option.rect.size());
w.adjustSize();
w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background
}
#ifdef TODO #ifdef TODO
if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
@ -131,11 +140,19 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo
// This is the only place where we actually set the size of cells // This is the only place where we actually set the size of cells
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ; RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
BoardPostDisplayWidget w(post,mDisplayMode,displayFlags(post.mMeta.mMsgId));
w.adjustSize(); if(mDisplayMode == BoardPostDisplayWidget::DISPLAY_MODE_COMPACT)
{
return w.size(); BoardPostDisplayWidget w(post,displayFlags(post.mMeta.mMsgId),nullptr);
w.adjustSize();
return w.size();
}
else
{
BoardPostDisplayWidget_card w(post,displayFlags(post.mMeta.mMsgId),nullptr);
w.adjustSize();
return w.size();
}
} }
void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded) void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded)
{ {
@ -147,16 +164,7 @@ void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded)
mPostListWidget->forceRedraw(); 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 PostedPostDelegate::displayFlags(const RsGxsMessageId &id) const
{ {
uint8_t flags=0; uint8_t flags=0;
@ -176,7 +184,12 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie
if(index.column() == RsPostedPostsModel::COLUMN_POSTS) if(index.column() == RsPostedPostsModel::COLUMN_POSTS)
{ {
QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,displayFlags(post.mMeta.mMsgId),parent); QWidget *w ;
if(mDisplayMode==BoardPostDisplayWidget::DISPLAY_MODE_COMPACT)
w = new BoardPostDisplayWidget(post,displayFlags(post.mMeta.mMsgId),parent);
else
w = new BoardPostDisplayWidget_card(post,displayFlags(post.mMeta.mMsgId),parent);
QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool))); 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(expand(RsGxsMessageId,bool)),this,SLOT(expandItem(RsGxsMessageId,bool)));
@ -265,7 +278,8 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
settingsChanged(); settingsChanged();
setGroupId(postedId); setGroupId(postedId);
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD);
switchDisplayMode(); // makes everything consistent and chooses classic view as default switchDisplayMode(); // makes everything consistent and chooses classic view as default
updateSorting(ui->sortStrategy_CB->currentIndex()); updateSorting(ui->sortStrategy_CB->currentIndex());
@ -279,7 +293,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
void PostedListWidgetWithModel::switchDisplayMode() void PostedListWidgetWithModel::switchDisplayMode()
{ {
if(mPostedPostsDelegate->getDisplayMode() == BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW) if(mPostedPostsDelegate->getDisplayMode() == BoardPostDisplayWidget::DISPLAY_MODE_CARD)
{ {
ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/classic.png")); ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/classic.png"));
ui->viewModeButton->setToolTip(tr("Click to switch to card view")); ui->viewModeButton->setToolTip(tr("Click to switch to card view"));
@ -291,7 +305,7 @@ void PostedListWidgetWithModel::switchDisplayMode()
ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/card.png")); ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/card.png"));
ui->viewModeButton->setToolTip(tr("Click to switch to compact view")); ui->viewModeButton->setToolTip(tr("Click to switch to compact view"));
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD);
} }
mPostedPostsModel->triggerRedraw(); mPostedPostsModel->triggerRedraw();
} }

View File

@ -1405,7 +1405,8 @@ posted {
FORMS += gui/Posted/PostedListWidgetWithModel.ui \ FORMS += gui/Posted/PostedListWidgetWithModel.ui \
gui/feeds/PostedGroupItem.ui \ gui/feeds/PostedGroupItem.ui \
gui/Posted/BoardPostDisplayWidget.ui \ gui/Posted/BoardPostDisplayWidget_compact.ui \
gui/Posted/BoardPostDisplayWidget_card.ui \
gui/Posted/PostedItem.ui \ gui/Posted/PostedItem.ui \
gui/Posted/PostedCardView.ui \ gui/Posted/PostedCardView.ui \
gui/Posted/PostedCreatePostDialog.ui \ gui/Posted/PostedCreatePostDialog.ui \