-
Notifications
You must be signed in to change notification settings - Fork 0
/
ElaTreeView.cpp
73 lines (63 loc) · 1.79 KB
/
ElaTreeView.cpp
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
#include "ElaTreeView.h"
#include "ElaScrollBar.h"
#include "ElaTreeViewPrivate.h"
#include "ElaTreeViewStyle.h"
ElaTreeView::ElaTreeView(QWidget* parent)
: QTreeView(parent), d_ptr(new ElaTreeViewPrivate())
{
Q_D(ElaTreeView);
d->q_ptr = this;
setObjectName("ElaTreeView");
setStyleSheet(
"#ElaTreeView{background-color:transparent;}"
"QHeaderView{background-color:transparent;border:0px;}");
setAnimated(true);
setMouseTracking(true);
ElaScrollBar* hScrollBar = new ElaScrollBar(this);
hScrollBar->setIsAnimation(true);
connect(hScrollBar, &ElaScrollBar::rangeAnimationFinished, this, [=]() {
doItemsLayout();
});
setHorizontalScrollBar(hScrollBar);
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
ElaScrollBar* vScrollBar = new ElaScrollBar(this);
vScrollBar->setIsAnimation(true);
connect(vScrollBar, &ElaScrollBar::rangeAnimationFinished, this, [=]() {
doItemsLayout();
});
setVerticalScrollBar(vScrollBar);
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
d->_treeViewStyle = new ElaTreeViewStyle(style());
setStyle(d->_treeViewStyle);
}
ElaTreeView::~ElaTreeView()
{
}
void ElaTreeView::setItemHeight(int itemHeight)
{
Q_D(ElaTreeView);
if (itemHeight > 0)
{
d->_treeViewStyle->setItemHeight(itemHeight);
doItemsLayout();
}
}
int ElaTreeView::getItemHeight() const
{
Q_D(const ElaTreeView);
return d->_treeViewStyle->getItemHeight();
}
void ElaTreeView::setHeaderMargin(int headerMargin)
{
Q_D(ElaTreeView);
if (headerMargin >= 0)
{
d->_treeViewStyle->setHeaderMargin(headerMargin);
doItemsLayout();
}
}
int ElaTreeView::getHeaderMargin() const
{
Q_D(const ElaTreeView);
return d->_treeViewStyle->getHeaderMargin();
}