mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 23:19:29 -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)
|
||||
: 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);
|
||||
mExpanded = false;
|
||||
|
||||
setup();
|
||||
}
|
||||
|
||||
@ -127,6 +125,10 @@ void BoardPostDisplayWidget::setup()
|
||||
if(dmode == DISPLAY_MODE_COMPACT)
|
||||
{
|
||||
ui->pictureLabel_compact->show();
|
||||
ui->pictureLabel->hide();
|
||||
ui->notes->hide();
|
||||
ui->siteLabel->hide();
|
||||
|
||||
ui->expandButton->show();
|
||||
|
||||
if(mExpanded)
|
||||
@ -182,9 +184,6 @@ void BoardPostDisplayWidget::setup()
|
||||
menu->addAction(showInPeopleAct);
|
||||
ui->shareButton->setMenu(menu);
|
||||
|
||||
ui->clearButton->hide();
|
||||
ui->readAndClearButton->hide();
|
||||
|
||||
RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId);
|
||||
bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
|
||||
|
||||
@ -265,14 +264,10 @@ void BoardPostDisplayWidget::setup()
|
||||
GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL);
|
||||
// Wiping data - as its been passed to thumbnail.
|
||||
|
||||
int desired_height = QFontMetricsF(font()).height() * 5;
|
||||
|
||||
QPixmap scaledpixmap;
|
||||
if(pixmap.width() > 800){
|
||||
QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation);
|
||||
ui->pictureLabel_compact->setPixmap(scaledpixmap);
|
||||
}else{
|
||||
ui->pictureLabel_compact->setPixmap(pixmap);
|
||||
}
|
||||
QPixmap scaledpixmap = pixmap.scaledToHeight(desired_height, Qt::SmoothTransformation);
|
||||
ui->pictureLabel_compact->setPixmap(scaledpixmap);
|
||||
}
|
||||
else if (mPost.mImage.mData == NULL)
|
||||
ui->pictureLabel_compact->hide();
|
||||
@ -353,19 +348,6 @@ void BoardPostDisplayWidget::setup()
|
||||
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.
|
||||
if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK)
|
||||
{
|
||||
@ -393,6 +375,8 @@ void BoardPostDisplayWidget::setup()
|
||||
mInFill = false;
|
||||
#endif
|
||||
|
||||
updateGeometry();
|
||||
|
||||
#ifdef TODO
|
||||
emit sizeChanged(this);
|
||||
#endif
|
||||
|
@ -6,12 +6,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>747</width>
|
||||
<height>221</height>
|
||||
<width>816</width>
|
||||
<height>203</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -22,87 +22,104 @@
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QToolButton" name="voteUpButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Vote up</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="Posted_images.qrc">
|
||||
<normaloff>:/images/up-arrow.png</normaloff>:/images/up-arrow.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="arrowsLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="voteUpButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Vote up</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="Posted_images.qrc">
|
||||
<normaloff>:/images/up-arrow.png</normaloff>:/images/up-arrow.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="StyledLabel" name="scoreLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="voteDownButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Vote down</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>\/</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="Posted_images.qrc">
|
||||
<normaloff>:/images/down-arrow.png</normaloff>:/images/down-arrow.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="StyledLabel" name="scoreLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<widget class="QLabel" name="pictureLabel_compact">
|
||||
<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>
|
||||
<string>PictureLabel_compact</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
@ -116,15 +133,11 @@
|
||||
</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">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
@ -239,6 +252,54 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</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>
|
||||
</item>
|
||||
<item>
|
||||
@ -330,123 +391,12 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="expandButton">
|
||||
<property name="toolTip">
|
||||
<string>Expand</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="Posted_images.qrc">
|
||||
<normaloff>:/images/expand.png</normaloff>:/images/expand.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="commentButton">
|
||||
<property name="text">
|
||||
<string>Comments</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="Posted_images.qrc">
|
||||
<normaloff>:/images/comments.png</normaloff>:/images/comments.png</iconset>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="shareButton">
|
||||
<property name="text">
|
||||
<string>Share</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="Posted_images.qrc">
|
||||
<normaloff>:/images/share.png</normaloff>:/images/share.png</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>308</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="readAndClearButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set as read and remove item</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/correct.png</normaloff>:/icons/png/correct.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove Item</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/exit2.png</normaloff>:/icons/png/exit2.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<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>
|
||||
@ -511,9 +461,8 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="Posted_images.qrc"/>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="Posted_images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -67,6 +67,8 @@ Q_DECLARE_METATYPE(RsPostedPost);
|
||||
|
||||
// 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
|
||||
{
|
||||
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);
|
||||
|
||||
w.setMaximumWidth(mCellWidthPix);
|
||||
w.setMinimumWidth(mCellWidthPix);
|
||||
//w.setMaximumWidth(mCellWidthPix);
|
||||
//w.setMinimumWidth(mCellWidthPix);
|
||||
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
|
||||
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
|
||||
|
||||
std::cerr << "PostedPostDelegate::paint(): w.size() = " << w.size() << std::endl;
|
||||
#ifdef TODO
|
||||
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
|
||||
|
||||
// debug
|
||||
if(index.row()==0 && index.column()==0)
|
||||
{
|
||||
QFile file("yourFile.png");
|
||||
file.open(QIODevice::WriteOnly);
|
||||
pixmap.save(&file, "PNG");
|
||||
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;
|
||||
// debug
|
||||
if(index.row()==0 && index.column()==0)
|
||||
{
|
||||
QFile file("yourFile.png");
|
||||
file.open(QIODevice::WriteOnly);
|
||||
pixmap.save(&file, "PNG");
|
||||
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;
|
||||
|
||||
painter->save();
|
||||
|
||||
@ -148,7 +151,7 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
||||
|
||||
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
|
||||
@ -158,15 +161,19 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo
|
||||
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
|
||||
|
||||
BoardPostDisplayWidget w(post,mDisplayMode);
|
||||
w.setMinimumWidth(mCellWidthPix);
|
||||
w.setMaximumWidth(mCellWidthPix);
|
||||
|
||||
//w.setMinimumWidth(mCellWidthPix);
|
||||
//w.setMaximumWidth(mCellWidthPix);
|
||||
|
||||
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
|
||||
@ -176,9 +183,13 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie
|
||||
if(index.column() == RsPostedPostsModel::COLUMN_POSTS)
|
||||
{
|
||||
QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent);
|
||||
w->setMinimumWidth(mCellWidthPix);
|
||||
w->setMaximumWidth(mCellWidthPix);
|
||||
|
||||
//w->setMinimumWidth(mCellWidthPix);
|
||||
//w->setMaximumWidth(mCellWidthPix);
|
||||
w->adjustSize();
|
||||
w->setFixedSize(cellSize(w->size()));
|
||||
|
||||
std::cerr << "PostedPostDelegate::createEditor(): size = " << w->size() << std::endl;
|
||||
return w;
|
||||
}
|
||||
else
|
||||
@ -277,7 +288,7 @@ void PostedListWidgetWithModel::switchDisplayMode()
|
||||
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW);
|
||||
}
|
||||
|
||||
mPostedPostsModel->update();
|
||||
mPostedPostsModel->deepUpdate();
|
||||
}
|
||||
|
||||
void PostedListWidgetWithModel::updateSorting(int s)
|
||||
|
@ -52,13 +52,14 @@ class PostedPostDelegate: public QAbstractItemDelegate
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) 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 setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; }
|
||||
|
||||
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;
|
||||
BoardPostDisplayWidget::DisplayMode mDisplayMode;
|
||||
@ -105,7 +106,7 @@ protected:
|
||||
#ifdef TODO
|
||||
virtual bool insertGroupData(const RsGxsGenericGroupData *data) override;
|
||||
#endif
|
||||
virtual void blank() ;
|
||||
virtual void blank() override;
|
||||
|
||||
#ifdef TODO
|
||||
virtual bool getGroupData(RsGxsGenericGroupData *& data) override;
|
||||
|
@ -489,6 +489,12 @@ void RsPostedPostsModel::setPostsInterval(int start,int nb_posts)
|
||||
postMods();
|
||||
}
|
||||
|
||||
void RsPostedPostsModel::deepUpdate()
|
||||
{
|
||||
auto posts(mPosts);
|
||||
setPosts(mPostedGroup,posts);
|
||||
}
|
||||
|
||||
void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPostedPost>& posts)
|
||||
{
|
||||
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.
|
||||
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
|
||||
void setSortMode(SortMode mode) ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user