Commit 89ada77e authored by Alessandro Portale's avatar Alessandro Portale

qmljs: Remove duplicated icons

This change makes qmljs reuse the equivalent icons from CPlusPlus.

Change-Id: I955fc0dd08282ed0556d804a59108a34e1212521
Reviewed-by: default avatarMarco Benelli <marco.benelli@theqtcompany.com>
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@theqtcompany.com>
parent 5e274c6f
......@@ -77,10 +77,6 @@ SOURCES += \
$$PWD/qmljsdescribevalue.cpp \
$$PWD/qmljsdialect.cpp
RESOURCES += \
$$PWD/qmljs.qrc
DISTFILES += \
$$PWD/parser/qmljs.g
......
......@@ -19,7 +19,6 @@ QtcLibrary {
files: [
"jsoncheck.cpp", "jsoncheck.h",
"persistenttrie.cpp", "persistenttrie.h",
"qmljs.qrc",
"qmljs_global.h",
"qmljsbind.cpp", "qmljsbind.h",
"qmljsbundle.cpp", "qmljsbundle.h",
......@@ -59,17 +58,6 @@ QtcLibrary {
]
}
Group {
name: "Images"
prefix: "images/"
files: [
"element.png",
"func.png",
"property.png",
"publicmember.png",
]
}
Group {
name: "Parser"
prefix: "parser/"
......
<RCC>
<qresource prefix="/qmljs">
<file>images/element.png</file>
<file>images/property.png</file>
<file>images/publicmember.png</file>
<file>images/func.png</file>
</qresource>
</RCC>
......@@ -25,6 +25,8 @@
#include "qmljsicons.h"
#include <cplusplus/Icons.h>
#include <QDir>
#include <QHash>
#include <QIcon>
......@@ -47,10 +49,6 @@ Icons *Icons::m_instance = 0;
class IconsPrivate
{
public:
QIcon elementIcon;
QIcon propertyIcon;
QIcon publicMemberIcon;
QIcon functionDeclarationIcon;
QHash<QPair<QString,QString>,QIcon> iconHash;
QString resourcePath;
};
......@@ -60,10 +58,6 @@ public:
Icons::Icons()
: d(new IconsPrivate)
{
d->elementIcon = QIcon(QLatin1String(":/qmljs/images/element.png"));
d->propertyIcon = QIcon(QLatin1String(":/qmljs/images/property.png"));
d->publicMemberIcon = QIcon(QLatin1String(":/qmljs/images/publicmember.png"));
d->functionDeclarationIcon = QIcon(QLatin1String(":/qmljs/images/func.png"));
}
Icons::~Icons()
......@@ -117,7 +111,7 @@ QIcon Icons::icon(const QString &packageName, const QString typeName) const
return d->iconHash.value(element);
}
QIcon Icons::icon(Node *node) const
QIcon Icons::icon(Node *node)
{
if (dynamic_cast<AST::UiObjectDefinition*>(node))
return objectDefinitionIcon();
......@@ -127,22 +121,22 @@ QIcon Icons::icon(Node *node) const
return QIcon();
}
QIcon Icons::objectDefinitionIcon() const
QIcon Icons::objectDefinitionIcon()
{
return d->elementIcon;
return CPlusPlus::Icons::iconForType(CPlusPlus::Icons::ClassIconType);
}
QIcon Icons::scriptBindingIcon() const
QIcon Icons::scriptBindingIcon()
{
return d->propertyIcon;
return CPlusPlus::Icons::iconForType(CPlusPlus::Icons::VarPublicIconType);
}
QIcon Icons::publicMemberIcon() const
QIcon Icons::publicMemberIcon()
{
return d->publicMemberIcon;
return CPlusPlus::Icons::iconForType(CPlusPlus::Icons::FuncPublicIconType);
}
QIcon Icons::functionDeclarationIcon() const
QIcon Icons::functionDeclarationIcon()
{
return d->functionDeclarationIcon;
return CPlusPlus::Icons::iconForType(CPlusPlus::Icons::FuncPublicIconType);
}
......@@ -45,12 +45,12 @@ public:
void setIconFilesPath(const QString &iconPath);
QIcon icon(const QString &packageName, const QString typeName) const;
QIcon icon(AST::Node *node) const;
static QIcon icon(AST::Node *node);
QIcon objectDefinitionIcon() const;
QIcon scriptBindingIcon() const;
QIcon publicMemberIcon() const;
QIcon functionDeclarationIcon() const;
static QIcon objectDefinitionIcon();
static QIcon scriptBindingIcon();
static QIcon publicMemberIcon();
static QIcon functionDeclarationIcon();
private:
Icons();
......
......@@ -472,7 +472,7 @@ QModelIndex QmlOutlineModel::enterObjectDefinition(AST::UiObjectDefinition *objD
} else {
// it's a grouped propery like 'anchors'
data.insert(ItemTypeRole, NonElementBindingType);
icon = m_icons->scriptBindingIcon();
icon = Icons::scriptBindingIcon();
}
QmlOutlineItem *item = enterNode(data, objDef, idNode, icon);
......@@ -492,7 +492,7 @@ QModelIndex QmlOutlineModel::enterObjectBinding(AST::UiObjectBinding *objBinding
bindingData.insert(Qt::DisplayRole, asString(objBinding->qualifiedId));
bindingData.insert(ItemTypeRole, ElementBindingType);
QmlOutlineItem *bindingItem = enterNode(bindingData, objBinding, objBinding->qualifiedId, m_icons->scriptBindingIcon());
QmlOutlineItem *bindingItem = enterNode(bindingData, objBinding, objBinding->qualifiedId, Icons::scriptBindingIcon());
const QString typeName = asString(objBinding->qualifiedTypeNameId);
if (!m_typeToIcon.contains(typeName))
......@@ -521,7 +521,7 @@ QModelIndex QmlOutlineModel::enterArrayBinding(AST::UiArrayBinding *arrayBinding
bindingData.insert(Qt::DisplayRole, asString(arrayBinding->qualifiedId));
bindingData.insert(ItemTypeRole, ElementBindingType);
QmlOutlineItem *item = enterNode(bindingData, arrayBinding, arrayBinding->qualifiedId, m_icons->scriptBindingIcon());
QmlOutlineItem *item = enterNode(bindingData, arrayBinding, arrayBinding->qualifiedId, Icons::scriptBindingIcon());
return item->index();
}
......@@ -539,7 +539,7 @@ QModelIndex QmlOutlineModel::enterScriptBinding(AST::UiScriptBinding *scriptBind
objectData.insert(AnnotationRole, getAnnotation(scriptBinding->statement));
objectData.insert(ItemTypeRole, NonElementBindingType);
QmlOutlineItem *item = enterNode(objectData, scriptBinding, scriptBinding->qualifiedId, m_icons->scriptBindingIcon());
QmlOutlineItem *item = enterNode(objectData, scriptBinding, scriptBinding->qualifiedId, Icons::scriptBindingIcon());
return item->index();
}
......@@ -558,7 +558,7 @@ QModelIndex QmlOutlineModel::enterPublicMember(AST::UiPublicMember *publicMember
objectData.insert(AnnotationRole, getAnnotation(publicMember->statement));
objectData.insert(ItemTypeRole, NonElementBindingType);
QmlOutlineItem *item = enterNode(objectData, publicMember, 0, m_icons->publicMemberIcon());
QmlOutlineItem *item = enterNode(objectData, publicMember, 0, Icons::publicMemberIcon());
return item->index();
}
......@@ -576,7 +576,7 @@ QModelIndex QmlOutlineModel::enterFunctionDeclaration(AST::FunctionDeclaration *
objectData.insert(Qt::DisplayRole, functionDeclaration->name.toString());
objectData.insert(ItemTypeRole, ElementBindingType);
QmlOutlineItem *item = enterNode(objectData, functionDeclaration, 0, m_icons->functionDeclarationIcon());
QmlOutlineItem *item = enterNode(objectData, functionDeclaration, 0, Icons::functionDeclarationIcon());
return item->index();
}
......@@ -593,7 +593,7 @@ QModelIndex QmlOutlineModel::enterTestCase(AST::ObjectLiteral *objectLiteral)
objectData.insert(Qt::DisplayRole, QLatin1String("testcase"));
objectData.insert(ItemTypeRole, ElementBindingType);
QmlOutlineItem *item = enterNode(objectData, objectLiteral, 0, m_icons->objectDefinitionIcon());
QmlOutlineItem *item = enterNode(objectData, objectLiteral, 0, Icons::objectDefinitionIcon());
return item->index();
}
......@@ -613,11 +613,11 @@ QModelIndex QmlOutlineModel::enterTestCaseProperties(AST::PropertyAssignmentList
objectData.insert(ItemTypeRole, ElementBindingType);
QmlOutlineItem *item;
if (assignment->value->kind == AST::Node::Kind_FunctionExpression)
item = enterNode(objectData, assignment, 0, m_icons->functionDeclarationIcon());
item = enterNode(objectData, assignment, 0, Icons::functionDeclarationIcon());
else if (assignment->value->kind == AST::Node::Kind_ObjectLiteral)
item = enterNode(objectData, assignment, 0, m_icons->objectDefinitionIcon());
item = enterNode(objectData, assignment, 0, Icons::objectDefinitionIcon());
else
item = enterNode(objectData, assignment, 0, m_icons->scriptBindingIcon());
item = enterNode(objectData, assignment, 0, Icons::scriptBindingIcon());
return item->index();
}
......@@ -628,7 +628,7 @@ QModelIndex QmlOutlineModel::enterTestCaseProperties(AST::PropertyAssignmentList
objectData.insert(Qt::DisplayRole, propertyName->id.toString());
objectData.insert(ItemTypeRole, ElementBindingType);
QmlOutlineItem *item;
item = enterNode(objectData, getterSetter, 0, m_icons->functionDeclarationIcon());
item = enterNode(objectData, getterSetter, 0, Icons::functionDeclarationIcon());
return item->index();
......
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