-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHistoryModelHierarchyDelegate.h
85 lines (46 loc) · 1.56 KB
/
HistoryModelHierarchyDelegate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// HistoryModelHierarchyDelegate.h
// Declares the HistoryModelHierarchyDelegate class representing the delegate that expands or collapses a HistoryModel in a QTreeView
#ifndef HISTORYMODELDELEGATE_H
#define HISTORYMODELDELEGATE_H
#include <QStyledItemDelegate>
class HistoryModelHierarchyDelegate:
public QStyledItemDelegate
{
typedef QStyledItemDelegate Super;
Q_OBJECT
public:
explicit HistoryModelHierarchyDelegate(QObject * a_Parent);
signals:
public slots:
protected:
/** Specifies the index of the model where mouse button is currently pressed.
Empty index when mouse button is released. */
QModelIndex m_CurrentIndex;
/** The button on which the last MouseDown event occured. */
enum
{
mdbNone, ///< Not on any button
mdbExpand, ///< On the Expand button
mdbCollapse, ///< On the Collapse button
} m_MouseDownButton;
virtual void paint(
QPainter * a_Painter,
const QStyleOptionViewItem & a_Option,
const QModelIndex & a_Index
) const override;
virtual QSize sizeHint(
const QStyleOptionViewItem & a_Option,
const QModelIndex & a_Index
) const override;
virtual bool editorEvent(
QEvent * a_Event,
QAbstractItemModel * a_Model,
const QStyleOptionViewItem & a_Option,
const QModelIndex & a_Index
) override;
/** Returns the bounding box of the Expand button. */
QRect getExpandButtonRect(const QStyleOptionViewItem & a_Option) const;
/** Returns the bounding box of the Collapse button. */
QRect getCollapseButtonRect(const QStyleOptionViewItem & a_Option) const;
};
#endif // HISTORYMODELDELEGATE_H