mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-23 22:25:55 +00:00
Move size delegate into item margins implemented by RDTreeView
This commit is contained in:
@@ -870,24 +870,6 @@ struct RDDialog
|
||||
QFileDialog::Options options = QFileDialog::Options());
|
||||
};
|
||||
|
||||
// useful delegate for enforcing a given size
|
||||
#include <QItemDelegate>
|
||||
|
||||
class SizeDelegate : public QItemDelegate
|
||||
{
|
||||
private:
|
||||
Q_OBJECT
|
||||
|
||||
QSize m_Size;
|
||||
|
||||
public:
|
||||
SizeDelegate(QSize size) : m_Size(size) {}
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
return m_Size;
|
||||
}
|
||||
};
|
||||
|
||||
class QGridLayout;
|
||||
|
||||
void addGridLines(QGridLayout *grid);
|
||||
|
||||
@@ -25,8 +25,26 @@
|
||||
#include "RDTreeView.h"
|
||||
#include <QPainter>
|
||||
|
||||
RDTreeViewDelegate::RDTreeViewDelegate(RDTreeView *view) : QStyledItemDelegate(view), m_View(view)
|
||||
{
|
||||
}
|
||||
|
||||
QSize RDTreeViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QSize ret = QStyledItemDelegate::sizeHint(option, index);
|
||||
|
||||
// expand by the margins
|
||||
ret.setWidth(ret.width() + m_View->m_HorizMargin);
|
||||
ret.setHeight(ret.height() + m_View->m_VertMargin);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
RDTreeView::RDTreeView(QWidget *parent) : QTreeView(NULL)
|
||||
{
|
||||
setItemDelegate(new RDTreeViewDelegate(this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const
|
||||
|
||||
@@ -24,8 +24,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QTreeView>
|
||||
|
||||
class RDTreeView;
|
||||
|
||||
class RDTreeViewDelegate : public QStyledItemDelegate
|
||||
{
|
||||
private:
|
||||
Q_OBJECT
|
||||
|
||||
RDTreeView *m_View;
|
||||
|
||||
public:
|
||||
RDTreeViewDelegate(RDTreeView *view);
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
};
|
||||
|
||||
class RDTreeView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -33,8 +48,20 @@ public:
|
||||
explicit RDTreeView(QWidget *parent = 0);
|
||||
|
||||
void setDrawBranches(bool draw) { m_DrawBranches = draw; }
|
||||
private:
|
||||
void setItemMargins(int horizontal, int vertical)
|
||||
{
|
||||
m_HorizMargin = horizontal;
|
||||
m_VertMargin = vertical;
|
||||
}
|
||||
int horizontalItemMargin() { return m_HorizMargin; }
|
||||
int verticalItemMargin() { return m_VertMargin; }
|
||||
protected:
|
||||
void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
bool m_DrawBranches = true;
|
||||
|
||||
int m_HorizMargin = 3, m_VertMargin = 3;
|
||||
|
||||
friend class RDTreeViewDelegate;
|
||||
};
|
||||
|
||||
@@ -85,9 +85,6 @@ EventBrowser::EventBrowser(ICaptureContext &ctx, QWidget *parent)
|
||||
// becomes quickly infuriating to rearrange, just disable until that can be fixed.
|
||||
ui->events->header()->setSectionsMovable(false);
|
||||
|
||||
m_SizeDelegate = new SizeDelegate(QSize(0, 16));
|
||||
ui->events->setItemDelegate(m_SizeDelegate);
|
||||
|
||||
UpdateDurationColumn();
|
||||
|
||||
m_FindHighlight = new QTimer(this);
|
||||
@@ -141,7 +138,6 @@ EventBrowser::~EventBrowser()
|
||||
m_Ctx.BuiltinWindowClosed(this);
|
||||
m_Ctx.RemoveLogViewer(this);
|
||||
delete ui;
|
||||
delete m_SizeDelegate;
|
||||
}
|
||||
|
||||
void EventBrowser::OnLogfileLoaded()
|
||||
|
||||
@@ -39,7 +39,6 @@ class RDTreeWidgetItem;
|
||||
class QTimer;
|
||||
class QTextStream;
|
||||
class FlowLayout;
|
||||
class SizeDelegate;
|
||||
struct EventItemTag;
|
||||
|
||||
class EventBrowser : public QFrame, public IEventBrowser, public ILogViewer
|
||||
@@ -123,7 +122,6 @@ private:
|
||||
|
||||
rdctype::array<CounterResult> m_Times;
|
||||
|
||||
SizeDelegate *m_SizeDelegate;
|
||||
QTimer *m_FindHighlight;
|
||||
|
||||
FlowLayout *m_BookmarkStripLayout;
|
||||
|
||||
Reference in New Issue
Block a user