/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/UnitTests/TestFramework/Framework/Qt/qtTestDelegate.cpp
50 строк
2 KB
Ingrater
Clang-format fixes and update to 18.1.1 (#1234)
10 мар 2024, 15:51
Не верифицирован
10 мар 2024, 15:51
2f16acf
Код
Авторство
О чём код?
#include <TestFramework/TestFrameworkPCH.h> #ifdef EZ_USE_QT # include <QApplication> # include <QPainter> # include <TestFramework/Framework/Qt/qtTestDelegate.h> # include <TestFramework/Framework/Qt/qtTestModel.h> //////////////////////////////////////////////////////////////////////// // ezQtTestDelegate public functions //////////////////////////////////////////////////////////////////////// ezQtTestDelegate::ezQtTestDelegate(QObject* pParent) : QStyledItemDelegate(pParent) { } ezQtTestDelegate::~ezQtTestDelegate() = default; void ezQtTestDelegate::paint(QPainter* pPainter, const QStyleOptionViewItem& option, const QModelIndex& index) const { if (index.column() == ezQtTestModel::Columns::Duration) { // We need to draw the alternate background color here because setting it via the model would // overwrite our duration bar. pPainter->save(); pPainter->setPen(Qt::NoPen); pPainter->setBrush(option.palette.alternateBase()); pPainter->drawRect(option.rect); pPainter->restore(); bool bSuccess = false; float fProgress = index.data(ezQtTestModel::UserRoles::Duration).toFloat(&bSuccess); // If we got a valid float from the model we can draw a small duration bar on top of the background. if (bSuccess) { QColor DurationColor = index.data(ezQtTestModel::UserRoles::DurationColor).value<QColor>(); QStyleOptionViewItem option2 = option; option2.palette.setBrush(QPalette::Base, QBrush(DurationColor)); option2.rect.setWidth((int)((float)option2.rect.width() * fProgress)); QApplication::style()->drawControl(QStyle::CE_ProgressBarGroove, &option2, pPainter); } } QStyledItemDelegate::paint(pPainter, option, index); } #endif