attempt at fixing column resize

This commit is contained in:
csoler 2018-11-27 09:37:34 +01:00
parent 73e285805e
commit c0e87dbb3b
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 13 additions and 7 deletions

View File

@ -264,7 +264,7 @@ public:
QPixmap pix = icon.pixmap(r.size());
// draw pixmap at center of item
const QPoint p = QPoint((r.width() - pix.width())/2, (r.height() - pix.height())/2);
const QPoint p = QPoint(pix.width()/2.0, (r.height() - pix.height())/2);
painter->drawPixmap(r.topLeft() + p, pix);
painter->drawText(r.topLeft() + p + QPoint(pix.width()+f/2.0,f*0.8), str);
}
@ -371,13 +371,9 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
itemDelegate->setOnlyPlainText(true);
ui->threadTreeWidget->setItemDelegate(itemDelegate);
/* Set header resize modes and initial section sizes */
QHeaderView * ttheader = ui->threadTreeWidget->header () ;
QHeaderView_setSectionResizeModeColumn(ttheader, RsGxsForumModel::COLUMN_THREAD_TITLE, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(ttheader, RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION, QHeaderView::ResizeToContents);
float f = QFontMetricsF(font()).height()/14.0f ;
QHeaderView * ttheader = ui->threadTreeWidget->header () ;
ttheader->resizeSection (RsGxsForumModel::COLUMN_THREAD_DATE, 140*f);
ttheader->resizeSection (RsGxsForumModel::COLUMN_THREAD_TITLE, 440*f);
ttheader->resizeSection (RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION, 24*f);
@ -405,9 +401,16 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
// load settings
processSettings(true);
/* Set header resize modes and initial section sizes */
QHeaderView_setSectionResizeModeColumn(ttheader, RsGxsForumModel::COLUMN_THREAD_TITLE, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(ttheader, RsGxsForumModel::COLUMN_THREAD_READ, QHeaderView::Fixed);
QHeaderView_setSectionResizeModeColumn(ttheader, RsGxsForumModel::COLUMN_THREAD_DATE, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(ttheader, RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION, QHeaderView::ResizeToContents);
QHeaderView_setSectionResizeModeColumn(ttheader, RsGxsForumModel::COLUMN_THREAD_AUTHOR, QHeaderView::Interactive);
ui->threadTreeWidget->header()->setCascadingSectionResizes(true);
/* Set header sizes for the fixed columns and resize modes, must be set after processSettings */
ttheader->resizeSection (RsGxsForumModel::COLUMN_THREAD_READ, 24*f);
QHeaderView_setSectionResizeModeColumn(ttheader, RsGxsForumModel::COLUMN_THREAD_READ, QHeaderView::Fixed);
ttheader->hideSection (RsGxsForumModel::COLUMN_THREAD_CONTENT);
ttheader->hideSection (RsGxsForumModel::COLUMN_THREAD_MSGID);
ttheader->hideSection (RsGxsForumModel::COLUMN_THREAD_DATA);

View File

@ -225,6 +225,9 @@
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<attribute name="headerCascadingSectionResizes">
<bool>true</bool>
</attribute>
</widget>
</item>
<item>