Core: Gui: DAGView: see following note:

Rework highlight rendering.
    Exception for topo sort.
This commit is contained in:
blobfish
2015-07-30 12:55:36 -04:00
committed by Stefan Tröger
parent 3b43f2cdc5
commit 503a475e63
3 changed files with 38 additions and 37 deletions

View File

@@ -23,8 +23,11 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QPainter>
#include <QApplication>
#endif
#include <QStyleOptionViewItem>
#include "DAGRectItem.h"
using namespace Gui;
@@ -39,25 +42,37 @@ RectItem::RectItem(QGraphicsItem* parent) : QGraphicsRectItem(parent)
void RectItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
//TODO figure out how to mimic painting of itemviews. QStyle, QStyledItemDelegate.
painter->save();
QBrush brush = backgroundBrush;
if (selected)
brush = selectionBrush;
if (preSelected)
brush = preSelectionBrush;
if (selected && preSelected)
brush = bothBrush;
QStyleOptionViewItemV4 styleOption;
styleOption.backgroundBrush = backgroundBrush;
if (editing)
brush = editBrush;
styleOption.backgroundBrush = editBrush;
else
{
styleOption.state |= QStyle::State_Enabled;
if (selected)
styleOption.state |= QStyle::State_Selected;
if (preSelected)
{
if (!selected)
{
styleOption.state |= QStyle::State_Selected;
QPalette palette = styleOption.palette;
QColor tempColor = palette.color(QPalette::Active, QPalette::Highlight);
tempColor.setAlphaF(0.15);
palette.setColor(QPalette::Inactive, QPalette::Highlight, tempColor);
styleOption.palette = palette;
}
styleOption.state |= QStyle::State_MouseOver;
}
}
styleOption.rect = this->rect().toRect();
//heights are negative.
float radius = std::min(this->rect().width(), std::fabs(this->rect().height())) * 0.1;
painter->setBrush(brush);
painter->setPen(this->pen()); //should be Qt::NoPen.
painter->drawRoundedRect(this->rect(), radius, radius);
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &styleOption, painter);
// QGraphicsRectItem::paint(painter, option, widget);
painter->restore();
}
#include <moc_DAGRectItem.cpp>