-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqloghistoryitemdelegate.cpp
More file actions
39 lines (29 loc) · 1.18 KB
/
qloghistoryitemdelegate.cpp
File metadata and controls
39 lines (29 loc) · 1.18 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
#include "qloghistoryitemdelegate.h"
#include <QPalette>
#include <QPainter>
QLogHistoryItemDelegate::QLogHistoryItemDelegate(QWidget *parent)
: QStyledItemDelegate(parent)
{
}
void QLogHistoryItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter, option, index);
if (index.column() == 0)
{
auto data = index.data(Qt::UserRole).toList();
if (data.count() > 0)
{
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(QPen());
painter->setBrush(QBrush(QColor(71, 143, 178)));
constexpr int padding = 5;
int circleRadius = (option.rect.height() / 2) - padding;
QPoint circleCenter;
circleCenter.setY(option.rect.top() + (option.rect.height() / 2));
circleCenter.setX(option.rect.left() + (option.rect.height() / 2) + padding + (option.rect.height() * data.at(0).toInt()));
painter->setClipRect(option.rect);
painter->drawEllipse(circleCenter, circleRadius, circleRadius);
painter->setClipping(false);
}
}
}