mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 09:30:44 +00:00
Add option to ignore icon size when sizing rows in a RDTreeView
This commit is contained in:
@@ -36,10 +36,30 @@ RDTreeViewDelegate::RDTreeViewDelegate(RDTreeView *view) : QStyledItemDelegate(v
|
||||
|
||||
QSize RDTreeViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QSize ret = QStyledItemDelegate::sizeHint(option, index);
|
||||
QSize ret;
|
||||
|
||||
QVariant var = index.data(Qt::SizeHintRole);
|
||||
if(var.canConvert<QSize>())
|
||||
{
|
||||
ret = var.value<QSize>();
|
||||
}
|
||||
else
|
||||
{
|
||||
QStyleOptionViewItem opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
|
||||
if(m_View->ignoreIconSize())
|
||||
{
|
||||
opt.icon = QIcon();
|
||||
opt.features &= ~QStyleOptionViewItem::HasDecoration;
|
||||
opt.decorationSize = QSize();
|
||||
}
|
||||
|
||||
ret = m_View->style()->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), m_View);
|
||||
}
|
||||
|
||||
// expand a pixel for the grid lines
|
||||
if(m_View->m_VisibleGridLines)
|
||||
if(m_View->visibleGridLines())
|
||||
{
|
||||
ret.setWidth(ret.width() + 1);
|
||||
ret.setHeight(ret.height() + 1);
|
||||
@@ -47,7 +67,7 @@ QSize RDTreeViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo
|
||||
|
||||
// ensure we have at least the margin on top of font size. If the style applied more, don't add to
|
||||
// it.
|
||||
ret.setHeight(qMax(ret.height(), option.fontMetrics.height() + m_View->m_VertMargin));
|
||||
ret.setHeight(qMax(ret.height(), option.fontMetrics.height() + m_View->verticalItemMargin()));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -69,10 +69,13 @@ public:
|
||||
void hideBranches() { m_VisibleBranches = false; }
|
||||
void showGridLines() { m_VisibleGridLines = true; }
|
||||
void hideGridLines() { m_VisibleGridLines = false; }
|
||||
bool visibleGridLines() { return m_VisibleGridLines; }
|
||||
void setTooltipElidedItems(bool tool) { m_TooltipElidedItems = tool; }
|
||||
bool tooltipElidedItems() { return m_TooltipElidedItems; }
|
||||
void setItemVerticalMargin(int vertical) { m_VertMargin = vertical; }
|
||||
int verticalItemMargin() { return m_VertMargin; }
|
||||
void setIgnoreIconSize(bool ignore) { m_IgnoreIconSize = ignore; }
|
||||
bool ignoreIconSize() { return m_IgnoreIconSize; }
|
||||
protected:
|
||||
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
@@ -95,8 +98,7 @@ private:
|
||||
RDTipLabel *m_ElidedTooltip;
|
||||
|
||||
int m_VertMargin = 6;
|
||||
bool m_IgnoreIconSize = false;
|
||||
|
||||
bool m_fillBranchRect = true;
|
||||
|
||||
friend class RDTreeViewDelegate;
|
||||
};
|
||||
|
||||
@@ -91,6 +91,7 @@ EventBrowser::EventBrowser(ICaptureContext &ctx, QWidget *parent)
|
||||
ui->events->header()->setCascadingSectionResizes(false);
|
||||
|
||||
ui->events->setItemVerticalMargin(3);
|
||||
ui->events->setIgnoreIconSize(true);
|
||||
|
||||
// set up default section layout. This will be overridden in restoreState()
|
||||
ui->events->header()->resizeSection(COL_EID, 80);
|
||||
|
||||
Reference in New Issue
Block a user