-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsuperstate.cpp
More file actions
43 lines (34 loc) · 886 Bytes
/
superstate.cpp
File metadata and controls
43 lines (34 loc) · 886 Bytes
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
#include "superstate.h"
#include "item.h"
#include <QLabel>
SuperState::SuperState(Item *item)
: State(item)
{
init();
}
void SuperState::draw(QPainter &p)
{
drawIcon(p);
}
void SuperState::init()
{
_sizeIcon = QSize(20, 20);
if (!_item) return;
// _item->_labTitle->move(_item->getItemHeight(), 0);
}
void SuperState::drawIcon(QPainter &p)
{
QString pixPath = (_item->isFold() ? "plus" : "subtract");
QRect rect(0, 0, _item->getItemHeight(), _item->getItemHeight());
QSize size(20, 20);
rect = calcCenterRect(rect, size);
p.save();
p.drawPixmap(rect, QPixmap(":/icon/" + pixPath));
p.restore();
}
QRect SuperState::calcCenterRect(QRect rect, QSize size)
{
int x = rect.x() + rect.width()/2 - size.width()/2;
int y = rect.y() + rect.height()/2 - size.height()/2;
return QRect(x, y, size.width(), size.height());
}