added two-views system for boards. Widgets are not yet correct

This commit is contained in:
csoler 2020-08-07 17:22:55 +02:00
parent 07cfa25c43
commit 033596a080
8 changed files with 780 additions and 624 deletions

View File

@ -43,13 +43,17 @@
const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2.png";
BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,QWidget *parent)
: QWidget(parent),ui(new Ui::BoardPostDisplayWidget()),mPost(post)
//===================================================================================================================================
//== Base class BoardPostDisplayWidget ==
//===================================================================================================================================
BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode mode,QWidget *parent)
: QWidget(parent),ui(new Ui::BoardPostDisplayWidget()),dmode(mode),mPost(post)
{
ui->setupUi(this);
mExpanded = false;
setup();
fill();
}
void BoardPostDisplayWidget::setCommentsSize(int comNb)
@ -114,234 +118,284 @@ BoardPostDisplayWidget::~BoardPostDisplayWidget()
delete(ui);
}
void BoardPostDisplayWidget::toggleNotes() {}
void BoardPostDisplayWidget::setup()
{
setAttribute(Qt::WA_DeleteOnClose, true);
// show/hide things based on the view type
/* clear ui */
ui->titleLabel->setText(tr("Loading"));
ui->dateLabel->clear();
ui->fromLabel->clear();
ui->siteLabel->clear();
if(dmode == DISPLAY_MODE_COMPACT)
{
ui->pictureLabel_compact->show();
ui->expandButton->show();
connect(ui->commentButton, SIGNAL( clicked()), this, SLOT(loadComments()));
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)));
QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this);
connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink()));
QAction *showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this);
connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showAuthorInPeople()));
int S = QFontMetricsF(font()).height() ;
ui->voteUpButton->setIconSize(QSize(S*1.5,S*1.5));
ui->voteDownButton->setIconSize(QSize(S*1.5,S*1.5));
ui->commentButton->setIconSize(QSize(S*1.5,S*1.5));
ui->readButton->setIconSize(QSize(S*1.5,S*1.5));
ui->shareButton->setIconSize(QSize(S*1.5,S*1.5));
QMenu *menu = new QMenu();
menu->addAction(CopyLinkAction);
menu->addSeparator();
menu->addAction(showInPeopleAct);
ui->shareButton->setMenu(menu);
ui->clearButton->hide();
ui->readAndClearButton->hide();
}
void BoardPostDisplayWidget::fill()
{
RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId);
bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
if(redacted) {
ui->commentButton->setDisabled(true);
ui->voteUpButton->setDisabled(true);
ui->voteDownButton->setDisabled(true);
// ui->picture_frame->hide();
ui->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()))) ;
QDateTime qtime;
qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy");
ui->dateLabel->setText(timestamp);
} else {
QPixmap sqpixmap2 = FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png");
int desired_height = 1.5*(ui->voteDownButton->height() + ui->voteUpButton->height() + ui->scoreLabel->height());
int desired_width = sqpixmap2.width()*desired_height/(float)sqpixmap2.height();
QDateTime qtime;
qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy");
QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs);
ui->dateLabel->setText(timestamp2);
ui->dateLabel->setToolTip(timestamp);
ui->fromLabel->setId(mPost.mMeta.mAuthorId);
// Use QUrl to check/parse our URL
// The only combination that seems to work: load as EncodedUrl, extract toEncoded().
QByteArray urlarray(mPost.mLink.c_str());
QUrl url = QUrl::fromEncoded(urlarray.trimmed());
QString urlstr = "Invalid Link";
QString sitestr = "Invalid Link";
bool urlOkay = url.isValid();
if (urlOkay)
{
QString scheme = url.scheme();
if ((scheme != "https")
&& (scheme != "http")
&& (scheme != "ftp")
&& (scheme != "retroshare"))
{
urlOkay = false;
sitestr = "Invalid Link Scheme";
}
}
if (urlOkay)
{
urlstr = QString("<a href=\"");
urlstr += QString(url.toEncoded());
urlstr += QString("\" ><span style=\" text-decoration: underline; color:#2255AA;\"> ");
urlstr += QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
urlstr += QString(" </span></a>");
QString siteurl = url.toEncoded();
sitestr = QString("<a href=\"%1\" ><span style=\" text-decoration: underline; color:#0079d3;\"> %2 </span></a>").arg(siteurl).arg(siteurl);
ui->titleLabel->setText(urlstr);
}
if(mExpanded)
{
ui->frame_picture->show();
ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/decrease.png")));
ui->expandButton->setToolTip(tr("Hide"));
}
else
ui->titleLabel->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) );
if (urlarray.isEmpty())
{
ui->siteLabel->hide();
}
{
ui->frame_picture->hide();
ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/expand.png")));
ui->expandButton->setToolTip(tr("Expand"));
}
}
else
{
ui->frame_picture->hide();
ui->pictureLabel_compact->hide();
ui->expandButton->hide();
}
ui->siteLabel->setText(sitestr);
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)
ui->pictureLabel->hide();
else
ui->pictureLabel->show();
}
setAttribute(Qt::WA_DeleteOnClose, true);
//QString score = "Hot" + QString::number(post.mHotScore);
//score += " Top" + QString::number(post.mTopScore);
//score += " New" + QString::number(post.mNewScore);
/* clear ui */
ui->titleLabel->setText(tr("Loading"));
ui->dateLabel->clear();
ui->fromLabel->clear();
ui->siteLabel->clear();
QString score = QString::number(mPost.mTopScore);
connect(ui->commentButton, SIGNAL( clicked()), this, SLOT(loadComments()));
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)));
ui->scoreLabel->setText(score);
QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this);
connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink()));
// FIX THIS UP LATER.
ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
QAction *showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this);
connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showAuthorInPeople()));
QTextDocument doc;
doc.setHtml(ui->notes->text());
int S = QFontMetricsF(font()).height() ;
if(doc.toPlainText().trimmed().isEmpty())
ui->notes->hide();
ui->voteUpButton->setIconSize(QSize(S*1.5,S*1.5));
ui->voteDownButton->setIconSize(QSize(S*1.5,S*1.5));
ui->commentButton->setIconSize(QSize(S*1.5,S*1.5));
ui->readButton->setIconSize(QSize(S*1.5,S*1.5));
ui->shareButton->setIconSize(QSize(S*1.5,S*1.5));
QMenu *menu = new QMenu();
menu->addAction(CopyLinkAction);
menu->addSeparator();
menu->addAction(showInPeopleAct);
ui->shareButton->setMenu(menu);
ui->clearButton->hide();
ui->readAndClearButton->hide();
RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId);
bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
if(redacted)
{
ui->commentButton->setDisabled(true);
ui->voteUpButton->setDisabled(true);
ui->voteDownButton->setDisabled(true);
ui->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()))) ;
QDateTime qtime;
qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy");
ui->dateLabel->setText(timestamp);
}
else
{
QPixmap sqpixmap2 = FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png");
QDateTime qtime;
qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy");
QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs);
ui->dateLabel->setText(timestamp2);
ui->dateLabel->setToolTip(timestamp);
ui->fromLabel->setId(mPost.mMeta.mAuthorId);
// Use QUrl to check/parse our URL
// The only combination that seems to work: load as EncodedUrl, extract toEncoded().
QByteArray urlarray(mPost.mLink.c_str());
QUrl url = QUrl::fromEncoded(urlarray.trimmed());
QString urlstr = "Invalid Link";
QString sitestr = "Invalid Link";
bool urlOkay = url.isValid();
if (urlOkay)
{
QString scheme = url.scheme();
if ((scheme != "https")
&& (scheme != "http")
&& (scheme != "ftp")
&& (scheme != "retroshare"))
{
urlOkay = false;
sitestr = "Invalid Link Scheme";
}
}
if (urlOkay)
{
urlstr = QString("<a href=\"");
urlstr += QString(url.toEncoded());
urlstr += QString("\" ><span style=\" text-decoration: underline; color:#2255AA;\"> ");
urlstr += QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
urlstr += QString(" </span></a>");
QString siteurl = url.toEncoded();
sitestr = QString("<a href=\"%1\" ><span style=\" text-decoration: underline; color:#0079d3;\"> %2 </span></a>").arg(siteurl).arg(siteurl);
ui->titleLabel->setText(urlstr);
}
else
ui->titleLabel->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) );
if (urlarray.isEmpty())
{
ui->siteLabel->hide();
}
ui->siteLabel->setText(sitestr);
if(dmode == DISPLAY_MODE_COMPACT)
{
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_compact->setPixmap(scaledpixmap);
}else{
ui->pictureLabel_compact->setPixmap(pixmap);
}
}
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)
ui->pictureLabel->hide();
else
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));
QTextDocument doc;
doc.setHtml(ui->notes->text());
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();
// differences between Feed or Top of Comment.
if (mFeedHolder)
{
// 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"));
}
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));
}
else
setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus));
}
else
#endif
{
// no feed.
//frame_comment->hide();
ui->commentButton->hide();
{
// no feed.
//frame_comment->hide();
ui->commentButton->hide();
ui->readButton->hide();
ui->newLabel->hide();
}
ui->readButton->hide();
ui->newLabel->hide();
}
#ifdef TO_REMOVE
if (mIsHome)
{
ui->clearButton->hide();
ui->readAndClearButton->hide();
}
else
if (mIsHome)
{
ui->clearButton->hide();
ui->readAndClearButton->hide();
}
else
#endif
{
ui->clearButton->show();
ui->readAndClearButton->show();
}
{
ui->clearButton->show();
ui->readAndClearButton->show();
}
// 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);
}
// 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);
uint32_t up, down, nComments;
if(ok)
{
int32_t vote = up - down;
scoreLabel->setText(QString::number(vote));
bool ok = rsPosted->retrieveScores(mPost.mMeta.mServiceString, up, down, nComments);
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>");
}
if(ok)
{
int32_t vote = up - down;
scoreLabel->setText(QString::number(vote));
mInFill = false;
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
#ifdef TODO
emit sizeChanged(this);
emit sizeChanged(this);
#endif
}
void BoardPostDisplayWidget::toggleNotes() {}

View File

@ -29,25 +29,32 @@ namespace Ui {
class BoardPostDisplayWidget;
}
class RsPostedPost;
struct RsPostedPost;
class BoardPostDisplayWidget : public QWidget
{
Q_OBJECT
public:
BoardPostDisplayWidget(const RsPostedPost& post,QWidget *parent=nullptr);
enum DisplayMode {
DISPLAY_MODE_UNKNOWN = 0x00,
DISPLAY_MODE_CARD_VIEW = 0x01,
DISPLAY_MODE_COMPACT = 0x02
};
BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,QWidget *parent=nullptr);
virtual ~BoardPostDisplayWidget();
static const char *DEFAULT_BOARD_IMAGE;
protected:
/* GxsGroupFeedItem */
void setup() ;
void fill() ;
void doExpand(bool open) {}
virtual void setup(); // to be overloaded by the different views
void doExpand(bool) {}
void setComment(const RsGxsComment&) ;
void setReadStatus(bool isNew, bool isUnread) ;
void toggle() {}
void setCommentsSize(int comNb) ;
void makeUpVote() ;
@ -57,9 +64,14 @@ protected:
signals:
void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down);
private:
/** Qt Designer generated object */
Ui::BoardPostDisplayWidget *ui;
protected:
RsPostedPost mPost;
DisplayMode dmode;
bool mExpanded;
private:
/** Qt Designer generated object */
Ui::BoardPostDisplayWidget *ui;
};

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>747</width>
<height>199</height>
<height>221</height>
</rect>
</property>
<property name="sizePolicy">
@ -22,394 +22,479 @@
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_3">
<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>
<layout class="QVBoxLayout" name="verticalLayout">
<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>
<widget class="StyledLabel" name="scoreLabel">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</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">
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
<width>20</width>
<height>40</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>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="QLabel" name="pictureLabel_compact">
<property name="text">
<string>PictureLabel_compact</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<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>
<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>
<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>
<widget class="StyledLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<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>
<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="horizontalLayout_3">
<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>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="expandButton">
<property name="toolTip">
<string>Expand</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/expand.png</normaloff>:/images/expand.png</iconset>
</property>
<property name="autoRaise">
<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="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</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>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>308</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="readAndClearButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Set as read and remove item</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/correct.png</normaloff>:/icons/png/correct.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/exit2.png</normaloff>:/icons/png/exit2.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<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>
<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>
<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>
<widget class="StyledLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<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>
<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="horizontalLayout_3">
<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>
<layout class="QHBoxLayout" name="horizontalLayout">
<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="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</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>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>308</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="readAndClearButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Set as read and remove item</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/correct.png</normaloff>:/icons/png/correct.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/exit2.png</normaloff>:/icons/png/exit2.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<widget class="QFrame" name="frame_picture">
<property name="maximumSize">
<size>
<width>800</width>
<height>600</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>257</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="pictureLabel_2">
<property name="text">
<string>TextLabel</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>257</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
@ -426,9 +511,9 @@
</customwidget>
</customwidgets>
<resources>
<include location="Posted_images.qrc"/>
<include location="../icons.qrc"/>
<include location="../images.qrc"/>
<include location="Posted_images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -31,7 +31,7 @@ class PostedCardView;
}
class FeedHolder;
class RsPostedPost;
struct RsPostedPost;
class PostedCardView : public BasePostedItem
{
@ -47,7 +47,7 @@ protected:
void setup() override;
void fill() override;
void doExpand(bool open) override {}
void doExpand(bool) override {}
void setComment(const RsGxsComment&) override;
void setReadStatus(bool isNew, bool isUnread) override;
void toggle() override {}

View File

@ -43,7 +43,6 @@
#include "PostedListWidgetWithModel.h"
#include "PostedPostsModel.h"
#include "PostedCardView.h"
#include "BoardPostDisplayWidget.h"
#include <algorithm>
@ -64,6 +63,8 @@
//
#define IMAGE_COPYLINK ":/images/copyrslink.png"
Q_DECLARE_METATYPE(RsPostedPost);
// Delegate used to paint into the table of thumbnails
void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
@ -82,7 +83,8 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
painter->fillRect( option.rect, option.backgroundBrush);
painter->restore();
BoardPostDisplayWidget w(post);
BoardPostDisplayWidget w(post,mDisplayMode);
w.setMaximumWidth(mCellWidthPix);
w.setMinimumWidth(mCellWidthPix);
w.adjustSize();
@ -155,7 +157,7 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
BoardPostDisplayWidget w(post);
BoardPostDisplayWidget w(post,mDisplayMode);
w.setMinimumWidth(mCellWidthPix);
w.setMaximumWidth(mCellWidthPix);
w.adjustSize();
@ -169,15 +171,15 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo
QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const
{
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
if(index.column() == RsPostedPostsModel::COLUMN_POSTS)
{
QWidget *w = new BoardPostDisplayWidget(post,parent);
w->setMinimumWidth(mCellWidthPix);
w->setMaximumWidth(mCellWidthPix);
w->adjustSize();
return w;
QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent);
w->setMinimumWidth(mCellWidthPix);
w->setMaximumWidth(mCellWidthPix);
w->adjustSize();
return w;
}
else
return NULL;
@ -213,6 +215,8 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
//connect(ui->channelFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnFiles(int,Qt::SortOrder)));
connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&)));
connect(ui->cardViewButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode()));
connect(ui->classicViewButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode()));
connect(mPostedPostsModel,SIGNAL(boardPostsLoaded()),this,SLOT(postPostLoad()));
@ -248,7 +252,9 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
settingsChanged();
setGroupId(postedId);
mPostedPostsModel->updateBoard(postedId);
ui->classicViewButton->setChecked(true); // inits both button checking consistency and delegate display mode variables.
mPostedPostsModel->updateBoard(postedId);
mEventHandlerId = 0;
// Needs to be asynced because this function is called by another thread!
@ -258,6 +264,22 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
}, mEventHandlerId, RsEventType::GXS_POSTED );
}
void PostedListWidgetWithModel::switchDisplayMode()
{
if(sender() == ui->classicViewButton)
{
whileBlocking(ui->cardViewButton)->setChecked(false);
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT);
}
else
{
whileBlocking(ui->classicViewButton)->setChecked(false);
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW);
}
mPostedPostsModel->update();
}
void PostedListWidgetWithModel::updateSorting(int s)
{
switch(s)
@ -724,33 +746,6 @@ int PostedListWidgetWithModel::viewMode()
}
#endif
void PostedListWidgetWithModel::setViewMode(int viewMode)
{
#ifdef TODO
switch (viewMode) {
case VIEW_MODE_FEEDS:
ui->feedWidget->show();
ui->fileWidget->hide();
ui->feedToolButton->setChecked(true);
ui->fileToolButton->setChecked(false);
break;
case VIEW_MODE_FILES:
ui->feedWidget->hide();
ui->fileWidget->show();
ui->feedToolButton->setChecked(false);
ui->fileToolButton->setChecked(true);
break;
default:
setViewMode(VIEW_MODE_FEEDS);
return;
}
#endif
}
#ifdef TODO
/*static*/ bool PostedListWidgetWithModel::filterItem(FeedItem *feedItem, const QString &text, int filter)
{

View File

@ -29,6 +29,7 @@
#include "gui/gxs/GxsMessageFramePostWidget.h"
#include "gui/feeds/FeedHolder.h"
#include "gui/Posted/BoardPostDisplayWidget.h"
namespace Ui {
class PostedListWidgetWithModel;
@ -43,7 +44,7 @@ class PostedPostDelegate: public QAbstractItemDelegate
Q_OBJECT
public:
PostedPostDelegate(QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100){}
PostedPostDelegate(QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100),mDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT){}
virtual ~PostedPostDelegate(){}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
@ -54,11 +55,13 @@ class PostedPostDelegate: public QAbstractItemDelegate
int cellSize(const QFont& font) const;
void setCellWidth(int pix) { mCellWidthPix = pix; }
void setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; }
private:
QSize cellSize(const QSize& w) const;
int mCellWidthPix;
BoardPostDisplayWidget::DisplayMode mDisplayMode;
};
class PostedListWidgetWithModel: public GxsMessageFrameWidget
@ -117,10 +120,10 @@ protected:
private slots:
void updateSorting(int);
void updateGroupData();
void switchDisplayMode();
void updateGroupData();
void createMsg();
void subscribeGroup(bool subscribe);
void setViewMode(int viewMode);
void settingsChanged();
void postPostLoad();
void postContextMenu(const QPoint&);

View File

@ -139,6 +139,10 @@ void RsPostedPostsModel::postMods()
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL));
}
void RsPostedPostsModel::update()
{
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL));
}
void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
{

View File

@ -135,6 +135,9 @@ public:
void updateBoard(const RsGxsGroupId& posted_group_id);
const RsGxsGroupId& currentGroupId() const;
// Triggers a data change for all items. This can be used to redraw the view without re-loading the data.
void update();
#ifdef TODO
void setSortMode(SortMode mode) ;