mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 08:29:32 -05:00
use single view mode button system, similar to channels
This commit is contained in:
parent
395435b5f3
commit
364e9ffdd2
@ -67,6 +67,10 @@ Q_DECLARE_METATYPE(RsPostedPost);
|
|||||||
|
|
||||||
// Delegate used to paint into the table of thumbnails
|
// Delegate used to paint into the table of thumbnails
|
||||||
|
|
||||||
|
//===================================================================================================================================
|
||||||
|
//== PostedPostDelegate ==
|
||||||
|
//===================================================================================================================================
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& o,const QSize& s) { return o << s.width() << " x " << s.height() ; }
|
std::ostream& operator<<(std::ostream& o,const QSize& s) { return o << s.width() << " x " << s.height() ; }
|
||||||
|
|
||||||
void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
||||||
@ -189,6 +193,10 @@ void PostedPostDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptio
|
|||||||
editor->setGeometry(option.rect);
|
editor->setGeometry(option.rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===================================================================================================================================
|
||||||
|
//== PostedListWidgetWithModel ==
|
||||||
|
//===================================================================================================================================
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedId, QWidget *parent) :
|
PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedId, QWidget *parent) :
|
||||||
GxsMessageFrameWidget(rsPosted, parent),
|
GxsMessageFrameWidget(rsPosted, parent),
|
||||||
@ -214,8 +222,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
|||||||
connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prev10Posts()));
|
connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prev10Posts()));
|
||||||
|
|
||||||
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->viewModeButton,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()));
|
||||||
|
|
||||||
@ -251,9 +258,8 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
|||||||
settingsChanged();
|
settingsChanged();
|
||||||
setGroupId(postedId);
|
setGroupId(postedId);
|
||||||
|
|
||||||
ui->classicViewButton->setChecked(true); // inits both button checking consistency and delegate display mode variables.
|
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW);
|
||||||
|
switchDisplayMode(); // makes everything consistent and chooses classic view as default
|
||||||
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!
|
||||||
@ -265,18 +271,21 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
|||||||
|
|
||||||
void PostedListWidgetWithModel::switchDisplayMode()
|
void PostedListWidgetWithModel::switchDisplayMode()
|
||||||
{
|
{
|
||||||
if(sender() == ui->classicViewButton)
|
if(mPostedPostsDelegate->getDisplayMode() == BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW)
|
||||||
{
|
{
|
||||||
whileBlocking(ui->cardViewButton)->setChecked(false);
|
ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/classic.png"));
|
||||||
|
ui->viewModeButton->setToolTip(tr("Click to switch to card view"));
|
||||||
|
|
||||||
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT);
|
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
whileBlocking(ui->classicViewButton)->setChecked(false);
|
ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/card.png"));
|
||||||
|
ui->viewModeButton->setToolTip(tr("Click to switch to compact view"));
|
||||||
|
|
||||||
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW);
|
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW);
|
||||||
}
|
}
|
||||||
|
mPostedPostsModel->triggerRedraw();
|
||||||
forceRedraw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedListWidgetWithModel::updateSorting(int s)
|
void PostedListWidgetWithModel::updateSorting(int s)
|
||||||
|
@ -55,6 +55,7 @@ public:
|
|||||||
|
|
||||||
void setCellWidth(int pix) { mCellWidthPix = pix; }
|
void setCellWidth(int pix) { mCellWidthPix = pix; }
|
||||||
void setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; }
|
void setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; }
|
||||||
|
BoardPostDisplayWidget::DisplayMode getDisplayMode() const { return mDisplayMode; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void expandItem(RsGxsMessageId msgId,bool expanded);
|
void expandItem(RsGxsMessageId msgId,bool expanded);
|
||||||
|
@ -350,6 +350,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>24</width>
|
||||||
@ -411,7 +414,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="classicViewButton">
|
<widget class="QPushButton" name="viewModeButton">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<kerning>true</kerning>
|
<kerning>true</kerning>
|
||||||
@ -438,29 +441,6 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="cardViewButton">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Card View</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="Posted_images.qrc">
|
|
||||||
<normaloff>:/images/card.png</normaloff>:/images/card.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="iconSize">
|
|
||||||
<size>
|
|
||||||
<width>24</width>
|
|
||||||
<height>24</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="flat">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -561,8 +541,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../icons.qrc"/>
|
|
||||||
<include location="Posted_images.qrc"/>
|
<include location="Posted_images.qrc"/>
|
||||||
|
<include location="../icons.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
Reference in New Issue
Block a user