mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 16:09:37 -05:00
fixed sizes and switching between modes
This commit is contained in:
parent
033596a080
commit
bdb36f7528
@ -48,11 +48,9 @@ const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2
|
|||||||
//===================================================================================================================================
|
//===================================================================================================================================
|
||||||
|
|
||||||
BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode mode,QWidget *parent)
|
BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode mode,QWidget *parent)
|
||||||
: QWidget(parent),ui(new Ui::BoardPostDisplayWidget()),dmode(mode),mPost(post)
|
: QWidget(parent),mPost(post),dmode(mode),mExpanded(false),ui(new Ui::BoardPostDisplayWidget())
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
mExpanded = false;
|
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,6 +125,10 @@ void BoardPostDisplayWidget::setup()
|
|||||||
if(dmode == DISPLAY_MODE_COMPACT)
|
if(dmode == DISPLAY_MODE_COMPACT)
|
||||||
{
|
{
|
||||||
ui->pictureLabel_compact->show();
|
ui->pictureLabel_compact->show();
|
||||||
|
ui->pictureLabel->hide();
|
||||||
|
ui->notes->hide();
|
||||||
|
ui->siteLabel->hide();
|
||||||
|
|
||||||
ui->expandButton->show();
|
ui->expandButton->show();
|
||||||
|
|
||||||
if(mExpanded)
|
if(mExpanded)
|
||||||
@ -182,9 +184,6 @@ void BoardPostDisplayWidget::setup()
|
|||||||
menu->addAction(showInPeopleAct);
|
menu->addAction(showInPeopleAct);
|
||||||
ui->shareButton->setMenu(menu);
|
ui->shareButton->setMenu(menu);
|
||||||
|
|
||||||
ui->clearButton->hide();
|
|
||||||
ui->readAndClearButton->hide();
|
|
||||||
|
|
||||||
RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId);
|
RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId);
|
||||||
bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
|
bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
|
||||||
|
|
||||||
@ -265,14 +264,10 @@ void BoardPostDisplayWidget::setup()
|
|||||||
GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL);
|
GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL);
|
||||||
// Wiping data - as its been passed to thumbnail.
|
// Wiping data - as its been passed to thumbnail.
|
||||||
|
|
||||||
|
int desired_height = QFontMetricsF(font()).height() * 5;
|
||||||
|
|
||||||
QPixmap scaledpixmap;
|
QPixmap scaledpixmap = pixmap.scaledToHeight(desired_height, Qt::SmoothTransformation);
|
||||||
if(pixmap.width() > 800){
|
ui->pictureLabel_compact->setPixmap(scaledpixmap);
|
||||||
QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation);
|
|
||||||
ui->pictureLabel_compact->setPixmap(scaledpixmap);
|
|
||||||
}else{
|
|
||||||
ui->pictureLabel_compact->setPixmap(pixmap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (mPost.mImage.mData == NULL)
|
else if (mPost.mImage.mData == NULL)
|
||||||
ui->pictureLabel_compact->hide();
|
ui->pictureLabel_compact->hide();
|
||||||
@ -353,19 +348,6 @@ void BoardPostDisplayWidget::setup()
|
|||||||
ui->newLabel->hide();
|
ui->newLabel->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TO_REMOVE
|
|
||||||
if (mIsHome)
|
|
||||||
{
|
|
||||||
ui->clearButton->hide();
|
|
||||||
ui->readAndClearButton->hide();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
ui->clearButton->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)
|
||||||
{
|
{
|
||||||
@ -393,6 +375,8 @@ void BoardPostDisplayWidget::setup()
|
|||||||
mInFill = false;
|
mInFill = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
updateGeometry();
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
emit sizeChanged(this);
|
emit sizeChanged(this);
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>747</width>
|
<width>816</width>
|
||||||
<height>221</height>
|
<height>203</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -22,87 +22,104 @@
|
|||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="voteUpButton">
|
<layout class="QVBoxLayout" name="arrowsLayout">
|
||||||
<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">
|
<widget class="QLabel" name="pictureLabel_compact">
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<pointsize>9</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>0</string>
|
<string>PictureLabel_compact</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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -116,15 +133,11 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="pictureLabel_compact">
|
|
||||||
<property name="text">
|
|
||||||
<string>PictureLabel_compact</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
@ -239,6 +252,54 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</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>
|
||||||
|
<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>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -330,123 +391,12 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="frame_picture">
|
<widget class="QFrame" name="frame_picture">
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>800</width>
|
|
||||||
<height>600</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -511,9 +461,8 @@
|
|||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="Posted_images.qrc"/>
|
|
||||||
<include location="../icons.qrc"/>
|
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
|
<include location="Posted_images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -67,6 +67,8 @@ Q_DECLARE_METATYPE(RsPostedPost);
|
|||||||
|
|
||||||
// Delegate used to paint into the table of thumbnails
|
// Delegate used to paint into the table of thumbnails
|
||||||
|
|
||||||
|
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
|
||||||
{
|
{
|
||||||
if((option.state & QStyle::State_Selected)) // Avoids double display. The selected widget is never exactly the size of the rendered one,
|
if((option.state & QStyle::State_Selected)) // Avoids double display. The selected widget is never exactly the size of the rendered one,
|
||||||
@ -85,13 +87,13 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||||||
|
|
||||||
BoardPostDisplayWidget w(post,mDisplayMode);
|
BoardPostDisplayWidget w(post,mDisplayMode);
|
||||||
|
|
||||||
w.setMaximumWidth(mCellWidthPix);
|
//w.setMaximumWidth(mCellWidthPix);
|
||||||
w.setMinimumWidth(mCellWidthPix);
|
//w.setMinimumWidth(mCellWidthPix);
|
||||||
w.adjustSize();
|
w.adjustSize();
|
||||||
|
|
||||||
QPixmap pixmap(option.rect.size());
|
w.setFixedSize(cellSize(w.size()));
|
||||||
|
|
||||||
std::cerr << "pixmap.depth=" << pixmap.depth() << std::endl;
|
QPixmap pixmap(option.rect.size());
|
||||||
|
|
||||||
#ifdef SUSPENDED_CODE
|
#ifdef SUSPENDED_CODE
|
||||||
if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row)
|
if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row)
|
||||||
@ -114,6 +116,7 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||||||
|
|
||||||
w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background
|
w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background
|
||||||
|
|
||||||
|
std::cerr << "PostedPostDelegate::paint(): w.size() = " << w.size() << std::endl;
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
|
if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
|
||||||
{
|
{
|
||||||
@ -123,15 +126,15 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
if(index.row()==0 && index.column()==0)
|
if(index.row()==0 && index.column()==0)
|
||||||
{
|
{
|
||||||
QFile file("yourFile.png");
|
QFile file("yourFile.png");
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
pixmap.save(&file, "PNG");
|
pixmap.save(&file, "PNG");
|
||||||
std::cerr << "Saved pxmap to png" << std::endl;
|
std::cerr << "Saved pxmap to png" << std::endl;
|
||||||
}
|
}
|
||||||
//std::cerr << "option.rect = " << option.rect.width() << "x" << option.rect.height() << ". fm.height()=" << QFontMetricsF(option.font).height() << std::endl;
|
//std::cerr << "option.rect = " << option.rect.width() << "x" << option.rect.height() << ". fm.height()=" << QFontMetricsF(option.font).height() << std::endl;
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
@ -148,7 +151,7 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||||||
|
|
||||||
QSize PostedPostDelegate::cellSize(const QSize& w) const
|
QSize PostedPostDelegate::cellSize(const QSize& w) const
|
||||||
{
|
{
|
||||||
return QSize(mCellWidthPix,0 + w.height() * mCellWidthPix/(float)w.width());
|
return QSize(mCellWidthPix,mCellWidthPix * w.height()/(float)w.width());
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
|
QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||||
@ -158,15 +161,19 @@ 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,mDisplayMode);
|
BoardPostDisplayWidget w(post,mDisplayMode);
|
||||||
w.setMinimumWidth(mCellWidthPix);
|
|
||||||
w.setMaximumWidth(mCellWidthPix);
|
//w.setMinimumWidth(mCellWidthPix);
|
||||||
|
//w.setMaximumWidth(mCellWidthPix);
|
||||||
|
|
||||||
w.adjustSize();
|
w.adjustSize();
|
||||||
|
|
||||||
QSize ss = cellSize(w.size()) + QSize(0,5);
|
QSize ss = cellSize(w.size());
|
||||||
|
|
||||||
std::cerr << "w =" << w.width() << " x " << w.height() << " new size = " << ss.width() << " x " << ss.height() << std::endl;
|
std::cerr << "PostedPostDelegate::sizeHint(): w =" << w.width() << " x " << w.height() << " new size = " << ss.width() << " x " << ss.height() ;
|
||||||
|
w.setFixedSize(ss);
|
||||||
|
|
||||||
return ss;
|
std::cerr << " Final size:" << w.size() << std::endl;
|
||||||
|
return w.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||||
@ -176,9 +183,13 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie
|
|||||||
if(index.column() == RsPostedPostsModel::COLUMN_POSTS)
|
if(index.column() == RsPostedPostsModel::COLUMN_POSTS)
|
||||||
{
|
{
|
||||||
QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent);
|
QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent);
|
||||||
w->setMinimumWidth(mCellWidthPix);
|
|
||||||
w->setMaximumWidth(mCellWidthPix);
|
//w->setMinimumWidth(mCellWidthPix);
|
||||||
|
//w->setMaximumWidth(mCellWidthPix);
|
||||||
w->adjustSize();
|
w->adjustSize();
|
||||||
|
w->setFixedSize(cellSize(w->size()));
|
||||||
|
|
||||||
|
std::cerr << "PostedPostDelegate::createEditor(): size = " << w->size() << std::endl;
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -277,7 +288,7 @@ void PostedListWidgetWithModel::switchDisplayMode()
|
|||||||
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW);
|
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
mPostedPostsModel->update();
|
mPostedPostsModel->deepUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedListWidgetWithModel::updateSorting(int s)
|
void PostedListWidgetWithModel::updateSorting(int s)
|
||||||
|
@ -52,13 +52,14 @@ class PostedPostDelegate: public QAbstractItemDelegate
|
|||||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const override;
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const override;
|
||||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
|
|
||||||
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; }
|
void setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSize cellSize(const QSize& w) const;
|
QSize cellSize(const QSize& w) const; // Converts the supplied size to the cell size for the current container.
|
||||||
|
// The client should then scale its widget to fit the given size.
|
||||||
|
|
||||||
int mCellWidthPix;
|
int mCellWidthPix;
|
||||||
BoardPostDisplayWidget::DisplayMode mDisplayMode;
|
BoardPostDisplayWidget::DisplayMode mDisplayMode;
|
||||||
@ -105,7 +106,7 @@ protected:
|
|||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
virtual bool insertGroupData(const RsGxsGenericGroupData *data) override;
|
virtual bool insertGroupData(const RsGxsGenericGroupData *data) override;
|
||||||
#endif
|
#endif
|
||||||
virtual void blank() ;
|
virtual void blank() override;
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
virtual bool getGroupData(RsGxsGenericGroupData *& data) override;
|
virtual bool getGroupData(RsGxsGenericGroupData *& data) override;
|
||||||
|
@ -489,6 +489,12 @@ void RsPostedPostsModel::setPostsInterval(int start,int nb_posts)
|
|||||||
postMods();
|
postMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsPostedPostsModel::deepUpdate()
|
||||||
|
{
|
||||||
|
auto posts(mPosts);
|
||||||
|
setPosts(mPostedGroup,posts);
|
||||||
|
}
|
||||||
|
|
||||||
void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPostedPost>& posts)
|
void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPostedPost>& posts)
|
||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
|
@ -138,6 +138,9 @@ public:
|
|||||||
// Triggers a data change for all items. This can be used to redraw the view without re-loading the data.
|
// Triggers a data change for all items. This can be used to redraw the view without re-loading the data.
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
// Triggers a preMod, begin/end remove rows and data update. Could be useful if update is not enough to reset cell sizes.
|
||||||
|
void deepUpdate();
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
void setSortMode(SortMode mode) ;
|
void setSortMode(SortMode mode) ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user