-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcustomlistview.cpp
More file actions
74 lines (69 loc) · 1.59 KB
/
customlistview.cpp
File metadata and controls
74 lines (69 loc) · 1.59 KB
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
#include "customlistview.h"
#include "customborderstorage.h"
#include <definitions/resources.h>
#include <definitions/customborder.h>
#include <QEvent>
CustomListView::CustomListView() :
QListView(NULL),
border(NULL)
{
setBorder();
}
void CustomListView::setBorder()
{
border = CustomBorderStorage::staticStorage(RSR_STORAGE_CUSTOMBORDER)->addBorder(this, CBS_MENU);
if (border)
{
setFrameShape(QFrame::NoFrame);
setWindowFlags(Qt::Widget);
border->setShowInTaskBar(false);
border->setResizable(false);
border->setMovable(false);
border->setMinimizeButtonVisible(false);
border->setMaximizeButtonVisible(false);
border->setCloseButtonVisible(false);
}
}
bool CustomListView::event(QEvent * evt)
{
switch(evt->type())
{
case QEvent::Show:
if (border)
{
border->show();
}
break;
case QEvent::ShowToParent:
if (border)
{
if (!parentWidget())
{
border->releaseWidget();
border->setWidget(this);
}
QListView::event(evt);
QRect geom = geometry();
QPoint p = geom.topLeft();
p.setX(p.x() - border->leftBorderWidth());
p.setY(p.y() - border->topBorderWidth());
geom.moveTopLeft(p);
geom.setWidth(geom.width() + border->leftBorderWidth() + border->rightBorderWidth());
geom.setHeight(geom.height() + border->topBorderWidth() + border->bottomBorderWidth());
border->setGeometry(geom);
border->show();
return true;
}
break;
case QEvent::Hide:
if (border)
{
border->hide();
return true;
}
break;
default:
break;
}
return QListView::event(evt);
}