forked from qt-creator/qt-creator
AutoTest: Avoid unnecessary local object
Change-Id: I9794a35ce5f983114769f3a14ab970f4e822471f Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -55,13 +55,11 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||||||
{
|
{
|
||||||
QStyleOptionViewItem opt = option;
|
QStyleOptionViewItem opt = option;
|
||||||
initStyleOption(&opt, index);
|
initStyleOption(&opt, index);
|
||||||
painter->save();
|
|
||||||
|
|
||||||
QFontMetrics fm(opt.font);
|
QFontMetrics fm(opt.font);
|
||||||
QBrush background;
|
QBrush background;
|
||||||
QColor foreground;
|
QColor foreground;
|
||||||
|
|
||||||
const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(opt.widget);
|
|
||||||
const bool selected = opt.state & QStyle::State_Selected;
|
const bool selected = opt.state & QStyle::State_Selected;
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
@@ -71,10 +69,14 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||||||
background = opt.palette.window().color();
|
background = opt.palette.window().color();
|
||||||
foreground = opt.palette.text().color();
|
foreground = opt.palette.text().color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto resultFilterModel = qobject_cast<const TestResultFilterModel *>(index.model());
|
||||||
|
if (!resultFilterModel)
|
||||||
|
return;
|
||||||
|
painter->save();
|
||||||
painter->fillRect(opt.rect, background);
|
painter->fillRect(opt.rect, background);
|
||||||
painter->setPen(foreground);
|
painter->setPen(foreground);
|
||||||
|
|
||||||
TestResultFilterModel *resultFilterModel = static_cast<TestResultFilterModel *>(view->model());
|
|
||||||
LayoutPositions positions(opt, resultFilterModel);
|
LayoutPositions positions(opt, resultFilterModel);
|
||||||
const TestResult *testResult = resultFilterModel->testResult(index);
|
const TestResult *testResult = resultFilterModel->testResult(index);
|
||||||
QTC_ASSERT(testResult, painter->restore();return);
|
QTC_ASSERT(testResult, painter->restore();return);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ private:
|
|||||||
class LayoutPositions
|
class LayoutPositions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LayoutPositions(QStyleOptionViewItem &options, TestResultFilterModel *filterModel)
|
LayoutPositions(QStyleOptionViewItem &options, const TestResultFilterModel *filterModel)
|
||||||
: m_totalWidth(options.rect.width()),
|
: m_totalWidth(options.rect.width()),
|
||||||
m_top(options.rect.top()),
|
m_top(options.rect.top()),
|
||||||
m_bottom(options.rect.bottom())
|
m_bottom(options.rect.bottom())
|
||||||
|
|||||||
Reference in New Issue
Block a user