Commit 1541dec6 authored by Kai Koehne's avatar Kai Koehne
Browse files

Add Icons provider to QmlJS library

Add an Icons class to QmlJS along the Icons class in the C++ support.
This will be used in the QmlJS Outline.
parent 1fff761d
......@@ -26,7 +26,8 @@ HEADERS += \
$$PWD/qmljsmodelmanagerinterface.h \
$$PWD/qmljsicontextpane.h \
$$PWD/qmljspropertyreader.h \
$$PWD/qmljsrewriter.h
$$PWD/qmljsrewriter.h \
$$PWD/qmljsicons.h
SOURCES += \
$$PWD/qmljsbind.cpp \
......@@ -42,7 +43,11 @@ SOURCES += \
$$PWD/qmljscomponentversion.cpp \
$$PWD/qmljsmodelmanagerinterface.cpp \
$$PWD/qmljspropertyreader.cpp \
$$PWD/qmljsrewriter.cpp
$$PWD/qmljsrewriter.cpp \
$$PWD/qmljsicons.cpp
RESOURCES += \
$$PWD/qmljs.qrc
OTHER_FILES += \
$$PWD/parser/qmljs.g
......
<RCC>
<qresource prefix="/qmljs">
<file>images/element.png</file>
<file>images/property.png</file>
</qresource>
</RCC>
#include "qmljsicons.h"
using namespace QmlJS;
using namespace QmlJS::AST;
namespace QmlJS {
class IconsPrivate
{
public:
QIcon elementIcon;
QIcon propertyIcon;
};
} // namespace QmlJS
Icons::Icons()
: m_d(new IconsPrivate)
{
m_d->elementIcon = QIcon(QLatin1String(":/qmljs/images/element.png"));
m_d->propertyIcon = QIcon(QLatin1String(":/qmljs/images/property.png"));
}
Icons::~Icons()
{
delete m_d;
}
QIcon Icons::icon(Node *node) const
{
if (dynamic_cast<AST::UiObjectDefinition*>(node)) {
return objectDefinitionIcon();
}
if (dynamic_cast<AST::UiScriptBinding*>(node)) {
return scriptBindingIcon();
}
return QIcon();
}
QIcon Icons::objectDefinitionIcon() const
{
return m_d->elementIcon;
}
QIcon Icons::scriptBindingIcon() const
{
return m_d->propertyIcon;
}
#ifndef QMLJSICONS_H
#define QMLJSICONS_H
#include <qmljs/qmljs_global.h>
#include <qmljs/parser/qmljsast_p.h>
#include <QtGui/QIcon>
namespace QmlJS {
class IconsPrivate;
class QMLJS_EXPORT Icons
{
public:
Icons();
~Icons();
QIcon icon(AST::Node *node) const;
QIcon objectDefinitionIcon() const;
QIcon scriptBindingIcon() const;
IconsPrivate *m_d;
};
} // namespace QmlJS
#endif // QMLJSICONS_H
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