Commit 8ac0e03e authored by Tim Jenssen's avatar Tim Jenssen Committed by Marco Bubke

QmlDesigner: fix using the right object/unit

TreeViewStyle is existing two times and wasn't in anonymous namespace.
The result after refactoring was that the wrong TreeViewStyle was used.
Moved the two times existing drawSelectionBackground to NavigatorTreeView
to avoid similar problems.

Change-Id: Id87894a01b5f6c94c81c478f9492ec6b78eb9e70
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent 2932e68f
......@@ -61,6 +61,7 @@ void ItemLibraryTreeView::drawSelectionBackground(QPainter *painter, const QStyl
painter->restore();
}
namespace {
// This style basically allows us to span the entire row
// including the arrow indicators which would otherwise not be
// drawn by the delegate
......@@ -82,6 +83,7 @@ public:
}
};
}
ItemLibraryTreeView::ItemLibraryTreeView(QWidget *parent) :
QTreeView(parent)
{
......
......@@ -82,7 +82,7 @@ void IconCheckboxItemDelegate::paint(QPainter *painter,
if (indexIsHolingModelNode(modelIndex)) {
painter->save();
if (styleOption.state & QStyle::State_Selected)
drawSelectionBackground(painter, styleOption);
NavigatorTreeView::drawSelectionBackground(painter, styleOption);
if (!m_navigatorTreeModel->nodeForIndex(modelIndex).isRootNode()) {
......
......@@ -224,7 +224,7 @@ void NameItemDelegate::paint(QPainter *painter,
painter->save();
if (styleOption.state & QStyle::State_Selected)
drawSelectionBackground(painter, styleOption);
NavigatorTreeView::drawSelectionBackground(painter, styleOption);
int iconOffset = drawTypeIcon(painter, styleOption, modelIndex, m_navigatorTreeModel);
......
......@@ -48,23 +48,7 @@
namespace QmlDesigner {
void drawSelectionBackground(QPainter *painter, const QStyleOption &option)
{
painter->save();
QLinearGradient gradient;
QColor highlightColor = Utils::StyleHelper::notTooBrightHighlightColor();
gradient.setColorAt(0, highlightColor.lighter(130));
gradient.setColorAt(1, highlightColor.darker(130));
gradient.setStart(option.rect.topLeft());
gradient.setFinalStop(option.rect.bottomLeft());
painter->fillRect(option.rect, gradient);
painter->setPen(highlightColor.lighter());
painter->drawLine(option.rect.topLeft(),option.rect.topRight());
painter->setPen(highlightColor.darker());
painter->drawLine(option.rect.bottomLeft(),option.rect.bottomRight());
painter->restore();
}
namespace {
// This style basically allows us to span the entire row
// including the arrow indicators which would otherwise not be
......@@ -76,7 +60,7 @@ public:
{
if (element == QStyle::PE_PanelItemViewRow) {
if (option->state & QStyle::State_Selected) {
drawSelectionBackground(painter, *option);
NavigatorTreeView::drawSelectionBackground(painter, *option);
} else {
// // 3D shadows
// painter->save();
......@@ -118,6 +102,8 @@ public:
}
};
}
NavigatorTreeView::NavigatorTreeView(QWidget *parent)
: QTreeView(parent)
{
......@@ -126,4 +112,23 @@ NavigatorTreeView::NavigatorTreeView(QWidget *parent)
style->setParent(this);
}
void NavigatorTreeView::drawSelectionBackground(QPainter *painter, const QStyleOption &option)
{
painter->save();
QLinearGradient gradient;
QColor highlightColor = Utils::StyleHelper::notTooBrightHighlightColor();
gradient.setColorAt(0, highlightColor.lighter(130));
gradient.setColorAt(1, highlightColor.darker(130));
gradient.setStart(option.rect.topLeft());
gradient.setFinalStop(option.rect.bottomLeft());
painter->fillRect(option.rect, gradient);
painter->setPen(highlightColor.lighter());
painter->drawLine(option.rect.topLeft(),option.rect.topRight());
painter->setPen(highlightColor.darker());
painter->drawLine(option.rect.bottomLeft(),option.rect.bottomRight());
painter->restore();
}
}
......@@ -35,12 +35,12 @@
namespace QmlDesigner {
void drawSelectionBackground(QPainter *painter, const QStyleOption &option);
class NavigatorTreeView : public QTreeView
{
public:
NavigatorTreeView(QWidget *parent = 0);
static void drawSelectionBackground(QPainter *painter, const QStyleOption &option);
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment