mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-29 00:27:27 -04:00
added two-views system for boards. Widgets are not yet correct
This commit is contained in:
parent
07cfa25c43
commit
033596a080
8 changed files with 780 additions and 624 deletions
|
@ -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,8 +118,37 @@ BoardPostDisplayWidget::~BoardPostDisplayWidget()
|
|||
delete(ui);
|
||||
}
|
||||
|
||||
void BoardPostDisplayWidget::toggleNotes() {}
|
||||
|
||||
void BoardPostDisplayWidget::setup()
|
||||
{
|
||||
// show/hide things based on the view type
|
||||
|
||||
if(dmode == DISPLAY_MODE_COMPACT)
|
||||
{
|
||||
ui->pictureLabel_compact->show();
|
||||
ui->expandButton->show();
|
||||
|
||||
if(mExpanded)
|
||||
{
|
||||
ui->frame_picture->show();
|
||||
ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/decrease.png")));
|
||||
ui->expandButton->setToolTip(tr("Hide"));
|
||||
}
|
||||
else
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
/* clear ui */
|
||||
|
@ -151,31 +184,26 @@ void BoardPostDisplayWidget::setup()
|
|||
|
||||
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) {
|
||||
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 {
|
||||
|
||||
}
|
||||
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");
|
||||
|
@ -229,12 +257,37 @@ void BoardPostDisplayWidget::fill()
|
|||
|
||||
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);
|
||||
|
@ -248,6 +301,7 @@ void BoardPostDisplayWidget::fill()
|
|||
else
|
||||
ui->pictureLabel->show();
|
||||
}
|
||||
}
|
||||
|
||||
//QString score = "Hot" + QString::number(post.mHotScore);
|
||||
//score += " Top" + QString::number(post.mTopScore);
|
||||
|
@ -344,4 +398,4 @@ void BoardPostDisplayWidget::fill()
|
|||
#endif
|
||||
}
|
||||
|
||||
void BoardPostDisplayWidget::toggleNotes() {}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
protected:
|
||||
RsPostedPost mPost;
|
||||
|
||||
DisplayMode dmode;
|
||||
bool mExpanded;
|
||||
|
||||
private:
|
||||
/** Qt Designer generated object */
|
||||
Ui::BoardPostDisplayWidget *ui;
|
||||
|
||||
RsPostedPost mPost;
|
||||
};
|
||||
|
||||
|
|
|
@ -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,7 +22,9 @@
|
|||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
|
@ -114,6 +116,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="pictureLabel_compact">
|
||||
<property name="text">
|
||||
<string>PictureLabel_compact</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
|
@ -323,6 +332,23 @@
|
|||
</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">
|
||||
|
@ -412,6 +438,65 @@
|
|||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<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>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -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>
|
||||
|
|
|
@ -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 {}
|
||||
|
|
|
@ -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();
|
||||
|
@ -173,7 +175,7 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie
|
|||
|
||||
if(index.column() == RsPostedPostsModel::COLUMN_POSTS)
|
||||
{
|
||||
QWidget *w = new BoardPostDisplayWidget(post,parent);
|
||||
QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent);
|
||||
w->setMinimumWidth(mCellWidthPix);
|
||||
w->setMaximumWidth(mCellWidthPix);
|
||||
w->adjustSize();
|
||||
|
@ -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,6 +252,8 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
|||
settingsChanged();
|
||||
setGroupId(postedId);
|
||||
|
||||
ui->classicViewButton->setChecked(true); // inits both button checking consistency and delegate display mode variables.
|
||||
|
||||
mPostedPostsModel->updateBoard(postedId);
|
||||
|
||||
mEventHandlerId = 0;
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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 switchDisplayMode();
|
||||
void updateGroupData();
|
||||
void createMsg();
|
||||
void subscribeGroup(bool subscribe);
|
||||
void setViewMode(int viewMode);
|
||||
void settingsChanged();
|
||||
void postPostLoad();
|
||||
void postContextMenu(const QPoint&);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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) ;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue