mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 17:43:23 -08:00
- Drop the dead VPN warning branch: rowVisible() already hides IP rows above the threshold, so setVpnThreshold(), its member and the spin-box connect never took effect. - Dim IP rows at shared_count > 2 instead of > 1: the count already includes the investigated account, so every IP row was dimmed. - Truncate backStack when a breadcrumb is clicked instead of pushing the current user again, so the trail keeps a single path and Back works. - Word-wrap the trail label so a long chain cannot widen the tab. - Extract the status/match pill painting into widgets/utility/pill_painter and use it from both delegates instead of duplicating it.
54 lines
2 KiB
C++
54 lines
2 KiB
C++
#include "report_status_delegate.h"
|
|
|
|
#include "../utility/pill_painter.h"
|
|
|
|
#include <QApplication>
|
|
#include <QPainter>
|
|
#include <QPalette>
|
|
#include <QStyle>
|
|
#include <QStyleOptionViewItem>
|
|
|
|
ReportStatusDelegate::ReportStatusDelegate(QObject *parent) : QStyledItemDelegate(parent)
|
|
{
|
|
}
|
|
|
|
void ReportStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
{
|
|
const bool selected = (option.state & QStyle::State_Selected) != 0;
|
|
QString status = index.data(Qt::UserRole).toString();
|
|
if (status.isEmpty()) {
|
|
status = index.data(Qt::DisplayRole).toString();
|
|
}
|
|
|
|
QPalette::ColorRole tintRole = QPalette::NoRole;
|
|
if (status == QStringLiteral("open")) {
|
|
tintRole = QPalette::Highlight;
|
|
} else if (status == QStringLiteral("assigned")) {
|
|
tintRole = QPalette::Link;
|
|
} else if (status == QStringLiteral("resolved")) {
|
|
tintRole = QPalette::PlaceholderText;
|
|
}
|
|
|
|
QStyleOptionViewItem opt(option);
|
|
initStyleOption(&opt, index);
|
|
painter->setFont(opt.font);
|
|
|
|
if (tintRole == QPalette::NoRole) {
|
|
const QPalette::ColorRole textRole = selected ? QPalette::HighlightedText : QPalette::PlaceholderText;
|
|
QStyle *fallbackStyle = opt.widget != nullptr ? opt.widget->style() : QApplication::style();
|
|
fallbackStyle->drawItemText(painter, opt.rect, Qt::AlignLeft | Qt::AlignVCenter, opt.palette, true, opt.text,
|
|
textRole);
|
|
return;
|
|
}
|
|
|
|
const QPalette::ColorRole textRole = selected ? QPalette::HighlightedText : QPalette::WindowText;
|
|
if (!pill_painter::paint(painter, opt, tintRole, textRole, opt.text.isEmpty() ? status : opt.text)) {
|
|
QStyledItemDelegate::paint(painter, opt, index);
|
|
}
|
|
}
|
|
|
|
QSize ReportStatusDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
{
|
|
const QSize hint = QStyledItemDelegate::sizeHint(option, index);
|
|
return hint + QSize(pill_painter::PAD_X, pill_painter::PAD_Y);
|
|
}
|