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"; 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); ui->setupUi(this);
mExpanded = false;
setup(); setup();
fill();
} }
void BoardPostDisplayWidget::setCommentsSize(int comNb) void BoardPostDisplayWidget::setCommentsSize(int comNb)
@ -114,234 +118,284 @@ BoardPostDisplayWidget::~BoardPostDisplayWidget()
delete(ui); delete(ui);
} }
void BoardPostDisplayWidget::toggleNotes() {}
void BoardPostDisplayWidget::setup() void BoardPostDisplayWidget::setup()
{ {
setAttribute(Qt::WA_DeleteOnClose, true); // show/hide things based on the view type
/* clear ui */ if(dmode == DISPLAY_MODE_COMPACT)
ui->titleLabel->setText(tr("Loading")); {
ui->dateLabel->clear(); ui->pictureLabel_compact->show();
ui->fromLabel->clear(); ui->expandButton->show();
ui->siteLabel->clear();
connect(ui->commentButton, SIGNAL( clicked()), this, SLOT(loadComments())); if(mExpanded)
connect(ui->voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote())); {
connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT( makeDownVote())); ui->frame_picture->show();
connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool))); ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/decrease.png")));
ui->expandButton->setToolTip(tr("Hide"));
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);
}
else else
ui->titleLabel->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) ); {
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();
}
if (urlarray.isEmpty()) setAttribute(Qt::WA_DeleteOnClose, true);
{
ui->siteLabel->hide();
}
ui->siteLabel->setText(sitestr); /* clear ui */
ui->titleLabel->setText(tr("Loading"));
ui->dateLabel->clear();
ui->fromLabel->clear();
ui->siteLabel->clear();
if(mPost.mImage.mData != NULL) connect(ui->commentButton, SIGNAL( clicked()), this, SLOT(loadComments()));
{ connect(ui->voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote()));
QPixmap pixmap; connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT( makeDownVote()));
GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool)));
// Wiping data - as its been passed to thumbnail.
QPixmap scaledpixmap; QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this);
if(pixmap.width() > 800){ connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink()));
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); QAction *showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this);
//score += " Top" + QString::number(post.mTopScore); connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showAuthorInPeople()));
//score += " New" + QString::number(post.mNewScore);
QString score = QString::number(mPost.mTopScore); int S = QFontMetricsF(font()).height() ;
ui->scoreLabel->setText(score); 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));
// FIX THIS UP LATER. QMenu *menu = new QMenu();
ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); menu->addAction(CopyLinkAction);
menu->addSeparator();
menu->addAction(showInPeopleAct);
ui->shareButton->setMenu(menu);
QTextDocument doc; ui->clearButton->hide();
doc.setHtml(ui->notes->text()); ui->readAndClearButton->hide();
if(doc.toPlainText().trimmed().isEmpty()) RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId);
ui->notes->hide(); 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 #ifdef TO_REMOVE
// differences between Feed or Top of Comment. // differences between Feed or Top of Comment.
if (mFeedHolder) if (mFeedHolder)
{ {
// feed. // feed.
//frame_comment->show(); //frame_comment->show();
ui->commentButton->show(); ui->commentButton->show();
if (mPost.mComments) if (mPost.mComments)
{ {
QString commentText = QString::number(mPost.mComments); QString commentText = QString::number(mPost.mComments);
commentText += " "; commentText += " ";
commentText += tr("Comments"); commentText += tr("Comments");
ui->commentButton->setText(commentText); ui->commentButton->setText(commentText);
} }
else else
{ {
ui->commentButton->setText(tr("Comment")); ui->commentButton->setText(tr("Comment"));
} }
setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus));
} }
else else
#endif #endif
{ {
// no feed. // no feed.
//frame_comment->hide(); //frame_comment->hide();
ui->commentButton->hide(); ui->commentButton->hide();
ui->readButton->hide(); ui->readButton->hide();
ui->newLabel->hide(); ui->newLabel->hide();
} }
#ifdef TO_REMOVE #ifdef TO_REMOVE
if (mIsHome) if (mIsHome)
{ {
ui->clearButton->hide(); ui->clearButton->hide();
ui->readAndClearButton->hide(); ui->readAndClearButton->hide();
} }
else else
#endif #endif
{ {
ui->clearButton->show(); ui->clearButton->show();
ui->readAndClearButton->show(); ui->readAndClearButton->show();
} }
// disable voting buttons - if they have already voted. // disable voting buttons - if they have already voted.
if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK)
{ {
ui->voteUpButton->setEnabled(false); ui->voteUpButton->setEnabled(false);
ui->voteDownButton->setEnabled(false); ui->voteDownButton->setEnabled(false);
} }
#if 0 #if 0
uint32_t up, down, nComments; uint32_t up, down, nComments;
bool ok = rsPosted->retrieveScores(mPost.mMeta.mServiceString, up, down, nComments); bool ok = rsPosted->retrieveScores(mPost.mMeta.mServiceString, up, down, nComments);
if(ok) if(ok)
{ {
int32_t vote = up - down; int32_t vote = up - down;
scoreLabel->setText(QString::number(vote)); scoreLabel->setText(QString::number(vote));
numCommentsLabel->setText("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px;" numCommentsLabel->setText("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px;"
"margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span" "margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span"
"style=\" font-size:10pt; font-weight:600;\">#</span><span " "style=\" font-size:10pt; font-weight:600;\">#</span><span "
"style=\" font-size:8pt; font-weight:600;\"> Comments: " "style=\" font-size:8pt; font-weight:600;\"> Comments: "
+ QString::number(nComments) + "</span></p>"); + QString::number(nComments) + "</span></p>");
} }
mInFill = false; mInFill = false;
#endif #endif
#ifdef TODO #ifdef TODO
emit sizeChanged(this); emit sizeChanged(this);
#endif #endif
} }
void BoardPostDisplayWidget::toggleNotes() {}

View file

@ -29,25 +29,32 @@ namespace Ui {
class BoardPostDisplayWidget; class BoardPostDisplayWidget;
} }
class RsPostedPost; struct RsPostedPost;
class BoardPostDisplayWidget : public QWidget class BoardPostDisplayWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: 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(); virtual ~BoardPostDisplayWidget();
static const char *DEFAULT_BOARD_IMAGE; static const char *DEFAULT_BOARD_IMAGE;
protected: protected:
/* GxsGroupFeedItem */ /* GxsGroupFeedItem */
void setup() ; virtual void setup(); // to be overloaded by the different views
void fill() ;
void doExpand(bool open) {} void doExpand(bool) {}
void setComment(const RsGxsComment&) ; void setComment(const RsGxsComment&) ;
void setReadStatus(bool isNew, bool isUnread) ; void setReadStatus(bool isNew, bool isUnread) ;
void toggle() {} void toggle() {}
void setCommentsSize(int comNb) ; void setCommentsSize(int comNb) ;
void makeUpVote() ; void makeUpVote() ;
@ -57,9 +64,14 @@ protected:
signals: signals:
void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down); void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down);
private: protected:
/** Qt Designer generated object */
Ui::BoardPostDisplayWidget *ui;
RsPostedPost mPost; RsPostedPost mPost;
DisplayMode dmode;
bool mExpanded;
private:
/** Qt Designer generated object */
Ui::BoardPostDisplayWidget *ui;
}; };

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>747</width> <width>747</width>
<height>199</height> <height>221</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -22,394 +22,479 @@
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QToolButton" name="voteUpButton"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="sizePolicy"> <item>
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <widget class="QToolButton" name="voteUpButton">
<horstretch>0</horstretch> <property name="sizePolicy">
<verstretch>0</verstretch> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
</sizepolicy> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
<property name="toolTip"> </sizepolicy>
<string>Vote up</string> </property>
</property> <property name="toolTip">
<property name="text"> <string>Vote up</string>
<string/> </property>
</property> <property name="text">
<property name="icon"> <string/>
<iconset resource="Posted_images.qrc"> </property>
<normaloff>:/images/up-arrow.png</normaloff>:/images/up-arrow.png</iconset> <property name="icon">
</property> <iconset resource="Posted_images.qrc">
<property name="autoRaise"> <normaloff>:/images/up-arrow.png</normaloff>:/images/up-arrow.png</iconset>
<bool>true</bool> </property>
</property> <property name="autoRaise">
</widget> <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>
<item> <item>
<widget class="StyledLabel" name="scoreLabel"> <spacer name="verticalSpacer">
<property name="font"> <property name="orientation">
<font> <enum>Qt::Vertical</enum>
<pointsize>9</pointsize>
</font>
</property> </property>
<property name="text"> <property name="sizeHint" stdset="0">
<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> <size>
<width>0</width> <width>20</width>
<height>0</height> <height>40</height>
</size> </size>
</property> </property>
<property name="toolTip"> </spacer>
<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> </item>
</layout> </layout>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <widget class="QLabel" name="pictureLabel_compact">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>PictureLabel_compact</string>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size> </item>
<width>20</width> <item>
<height>40</height> <layout class="QVBoxLayout" name="verticalLayout_2">
</size> <item>
</property> <layout class="QHBoxLayout" name="horizontalLayout_2">
</spacer> <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> </item>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <widget class="QFrame" name="frame_picture">
<item> <property name="maximumSize">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <size>
<property name="spacing"> <width>800</width>
<number>5</number> <height>600</height>
</property> </size>
<property name="leftMargin"> </property>
<number>0</number> <property name="frameShape">
</property> <enum>QFrame::StyledPanel</enum>
<property name="rightMargin"> </property>
<number>6</number> <property name="frameShadow">
</property> <enum>QFrame::Raised</enum>
<item> </property>
<widget class="QLabel" name="fromBoldLabel"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="sizePolicy"> <item>
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <spacer name="horizontalSpacer_2">
<horstretch>0</horstretch> <property name="orientation">
<verstretch>0</verstretch> <enum>Qt::Horizontal</enum>
</sizepolicy> </property>
</property> <property name="sizeHint" stdset="0">
<property name="font"> <size>
<font> <width>257</width>
<weight>50</weight> <height>20</height>
<bold>false</bold> </size>
</font> </property>
</property> </spacer>
<property name="text"> </item>
<string>Posted by</string> <item>
</property> <widget class="QLabel" name="pictureLabel_2">
</widget> <property name="text">
</item> <string>TextLabel</string>
<item> </property>
<widget class="GxsIdLabel" name="fromLabel"> <property name="scaledContents">
<property name="sizePolicy"> <bool>true</bool>
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> </property>
<horstretch>0</horstretch> <property name="textInteractionFlags">
<verstretch>0</verstretch> <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</sizepolicy> </property>
</property> </widget>
<property name="text"> </item>
<string notr="true">Signed by</string> <item>
</property> <spacer name="horizontalSpacer_5">
<property name="openExternalLinks"> <property name="orientation">
<bool>true</bool> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
</item> <size>
<item> <width>257</width>
<widget class="QLabel" name="dateLabel"> <height>20</height>
<property name="sizePolicy"> </size>
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> </property>
<horstretch>0</horstretch> </spacer>
<verstretch>0</verstretch> </item>
</sizepolicy> </layout>
</property> </widget>
<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>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -426,9 +511,9 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="Posted_images.qrc"/>
<include location="../icons.qrc"/> <include location="../icons.qrc"/>
<include location="../images.qrc"/> <include location="../images.qrc"/>
<include location="Posted_images.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View file

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

View file

@ -43,7 +43,6 @@
#include "PostedListWidgetWithModel.h" #include "PostedListWidgetWithModel.h"
#include "PostedPostsModel.h" #include "PostedPostsModel.h"
#include "PostedCardView.h"
#include "BoardPostDisplayWidget.h" #include "BoardPostDisplayWidget.h"
#include <algorithm> #include <algorithm>
@ -64,6 +63,8 @@
// //
#define IMAGE_COPYLINK ":/images/copyrslink.png" #define IMAGE_COPYLINK ":/images/copyrslink.png"
Q_DECLARE_METATYPE(RsPostedPost);
// Delegate used to paint into the table of thumbnails // Delegate used to paint into the table of thumbnails
void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const 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->fillRect( option.rect, option.backgroundBrush);
painter->restore(); painter->restore();
BoardPostDisplayWidget w(post); BoardPostDisplayWidget w(post,mDisplayMode);
w.setMaximumWidth(mCellWidthPix); w.setMaximumWidth(mCellWidthPix);
w.setMinimumWidth(mCellWidthPix); w.setMinimumWidth(mCellWidthPix);
w.adjustSize(); w.adjustSize();
@ -155,7 +157,7 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ; RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
BoardPostDisplayWidget w(post); BoardPostDisplayWidget w(post,mDisplayMode);
w.setMinimumWidth(mCellWidthPix); w.setMinimumWidth(mCellWidthPix);
w.setMaximumWidth(mCellWidthPix); w.setMaximumWidth(mCellWidthPix);
w.adjustSize(); 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 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) if(index.column() == RsPostedPostsModel::COLUMN_POSTS)
{ {
QWidget *w = new BoardPostDisplayWidget(post,parent); QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent);
w->setMinimumWidth(mCellWidthPix); w->setMinimumWidth(mCellWidthPix);
w->setMaximumWidth(mCellWidthPix); w->setMaximumWidth(mCellWidthPix);
w->adjustSize(); w->adjustSize();
return w; return w;
} }
else else
return NULL; 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->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->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())); connect(mPostedPostsModel,SIGNAL(boardPostsLoaded()),this,SLOT(postPostLoad()));
@ -248,7 +252,9 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
settingsChanged(); settingsChanged();
setGroupId(postedId); setGroupId(postedId);
mPostedPostsModel->updateBoard(postedId); ui->classicViewButton->setChecked(true); // inits both button checking consistency and delegate display mode variables.
mPostedPostsModel->updateBoard(postedId);
mEventHandlerId = 0; mEventHandlerId = 0;
// Needs to be asynced because this function is called by another thread! // 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 ); }, 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) void PostedListWidgetWithModel::updateSorting(int s)
{ {
switch(s) switch(s)
@ -724,33 +746,6 @@ int PostedListWidgetWithModel::viewMode()
} }
#endif #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 #ifdef TODO
/*static*/ bool PostedListWidgetWithModel::filterItem(FeedItem *feedItem, const QString &text, int filter) /*static*/ bool PostedListWidgetWithModel::filterItem(FeedItem *feedItem, const QString &text, int filter)
{ {

View file

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

View file

@ -135,6 +135,9 @@ public:
void updateBoard(const RsGxsGroupId& posted_group_id); void updateBoard(const RsGxsGroupId& posted_group_id);
const RsGxsGroupId& currentGroupId() const; 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 #ifdef TODO
void setSortMode(SortMode mode) ; void setSortMode(SortMode mode) ;