Commit 7932fd0e authored by Alessandro Portale's avatar Alessandro Portale

Qt Quick Designer: Use QPixmap for navigator view delegate

...and rename the member variables accordingly.

Change-Id: I5dfc4e76efdec5e1b3267710ec1e06c500a61763
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@theqtcompany.com>
parent ed85f4cf
......@@ -39,17 +39,15 @@
#include <QMouseEvent>
#include <QPainter>
#include <utils/themehelper.h>
namespace QmlDesigner {
IconCheckboxItemDelegate::IconCheckboxItemDelegate(QObject *parent,
QString checkedPixmapURL,
QString uncheckedPixmapURL,
const QPixmap &checkedPixmap,
const QPixmap &uncheckedPixmap,
NavigatorTreeModel *treeModel)
: QStyledItemDelegate(parent),
offPixmap(Utils::ThemeHelper::themedIconPixmap(uncheckedPixmapURL)),
onPixmap(Utils::ThemeHelper::themedIconPixmap(checkedPixmapURL)),
m_checkedPixmap(checkedPixmap),
m_uncheckedPixmap(uncheckedPixmap),
m_navigatorTreeModel(treeModel)
{}
......@@ -77,7 +75,7 @@ void IconCheckboxItemDelegate::paint(QPainter *painter,
const QModelIndex &modelIndex) const
{
const int yOffset = (styleOption.rect.height()
- (onPixmap.height() / painter->device()->devicePixelRatio())) / 2;
- (m_checkedPixmap.height() / painter->device()->devicePixelRatio())) / 2;
const int xOffset = 2;
if (indexIsHolingModelNode(modelIndex)) {
painter->save();
......@@ -89,10 +87,9 @@ void IconCheckboxItemDelegate::paint(QPainter *painter,
if (m_navigatorTreeModel->isNodeInvisible(modelIndex))
painter->setOpacity(0.5);
if (isChecked(m_navigatorTreeModel, modelIndex))
painter->drawPixmap(styleOption.rect.x() + xOffset, styleOption.rect.y() + yOffset, onPixmap);
else
painter->drawPixmap(styleOption.rect.x() + xOffset, styleOption.rect.y() + yOffset, offPixmap);
const bool checked = isChecked(m_navigatorTreeModel, modelIndex);
painter->drawPixmap(styleOption.rect.x() + xOffset, styleOption.rect.y() + yOffset,
checked ? m_checkedPixmap : m_uncheckedPixmap);
}
painter->restore();
......
......@@ -36,8 +36,8 @@ class IconCheckboxItemDelegate : public QStyledItemDelegate
{
public:
explicit IconCheckboxItemDelegate(QObject *parent,
QString checkedPixmapURL,
QString uncheckedPixmapURL,
const QPixmap &checkedPixmap,
const QPixmap &uncheckedPixmap,
NavigatorTreeModel *treeModel);
QSize sizeHint(const QStyleOptionViewItem &option,
......@@ -48,8 +48,8 @@ public:
const QModelIndex &index) const;
private:
QPixmap offPixmap;
QPixmap onPixmap;
const QPixmap m_checkedPixmap;
const QPixmap m_uncheckedPixmap;
NavigatorTreeModel *m_navigatorTreeModel;
};
} // namespace QmlDesigner
......
......@@ -32,6 +32,8 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <utils/themehelper.h>
#include <bindingproperty.h>
#include <designmodecontext.h>
#include <nodeproperty.h>
......@@ -80,15 +82,17 @@ NavigatorView::NavigatorView(QObject* parent) :
NameItemDelegate *idDelegate = new NameItemDelegate(this,
m_treeModel.data());
IconCheckboxItemDelegate *showDelegate = new IconCheckboxItemDelegate(this,
QLatin1String(":/navigator/icon/eye_open.png"),
QLatin1String(":/navigator/icon/eye_closed.png"),
m_treeModel.data());
IconCheckboxItemDelegate *exportDelegate = new IconCheckboxItemDelegate(this,
QLatin1String(":/navigator/icon/export_checked.png"),
QLatin1String(":/navigator/icon/export_unchecked.png"),
m_treeModel.data());
IconCheckboxItemDelegate *showDelegate =
new IconCheckboxItemDelegate(this,
Utils::ThemeHelper::themedIconPixmap(QLatin1String(":/navigator/icon/eye_open.png")),
Utils::ThemeHelper::themedIconPixmap(QLatin1String(":/navigator/icon/eye_closed.png")),
m_treeModel.data());
IconCheckboxItemDelegate *exportDelegate =
new IconCheckboxItemDelegate(this,
Utils::ThemeHelper::themedIconPixmap(QLatin1String(":/navigator/icon/export_checked.png")),
Utils::ThemeHelper::themedIconPixmap(QLatin1String(":/navigator/icon/export_unchecked.png")),
m_treeModel.data());
#ifdef _LOCK_ITEMS_
IconCheckboxItemDelegate *lockDelegate = new IconCheckboxItemDelegate(this,":/qmldesigner/images/lock.png",
......
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