Commit 5523bea6 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Fix icon names for ItemLibraryEntry

icon and iconPath are two different icons.

Change-Id: I62ab07a13240bc23bc9d807dbd46742ce7d71300
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 4a37d689
......@@ -192,7 +192,7 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model)
itemModel = new ItemLibraryItem(itemId, entry.name(), sectionModel);
itemModel->setItemIconPath(entry.iconPath());
itemModel->setItemIconPath(entry.libraryEntryIconPath());
itemModel->setItemIconSize(m_itemIconSize);
sectionModel->addSectionEntry(itemModel);
m_sections.insert(itemId, sectionId);
......@@ -224,9 +224,9 @@ QMimeData *ItemLibraryModel::getMimeData(int libId)
}
QIcon ItemLibraryModel::getIcon(int libId)
QIcon ItemLibraryModel::getTypeIcon(int libId)
{
return m_itemInfos.value(libId).icon();
return m_itemInfos.value(libId).typeIcon();
}
ItemLibrarySection *ItemLibraryModel::section(int libraryId)
......
......@@ -62,7 +62,7 @@ public:
QString getTypeName(int libId);
QMimeData *getMimeData(int libId);
QIcon getIcon(int libId);
QIcon getTypeIcon(int libId);
ItemLibrarySection* section(int libraryId);
QList<ItemLibrarySection*> sections() const;
......
......@@ -389,7 +389,7 @@ void ItemLibraryWidget::startDragAndDrop()
QMimeData *mimeData = m_itemLibraryModel->getMimeData(m_itemLibraryId);
QDrag *drag = new QDrag(this);
drag->setPixmap(m_itemLibraryModel->getIcon(m_itemLibraryId).pixmap(32, 32));
drag->setPixmap(m_itemLibraryModel->getTypeIcon(m_itemLibraryId).pixmap(32, 32));
drag->setMimeData(mimeData);
drag->exec();
......
......@@ -108,7 +108,7 @@ NameItemDelegate::NameItemDelegate(QObject *parent, NavigatorTreeModel *treeMode
{
}
static QIcon getIcon(const ModelNode &modelNode)
static QIcon getTypeIcon(const ModelNode &modelNode)
{
QIcon icon;
......@@ -119,7 +119,7 @@ static QIcon getIcon(const ModelNode &modelNode)
modelNode.majorVersion(),
modelNode.minorVersion());
if (!itemLibraryEntryList.isEmpty())
return itemLibraryEntryList.first().icon();
return itemLibraryEntryList.first().typeIcon();
else if (modelNode.metaInfo().isValid())
return QIcon(QStringLiteral(":/ItemLibrary/images/item-default-icon.png"));
else
......@@ -129,7 +129,7 @@ static QIcon getIcon(const ModelNode &modelNode)
return QIcon(QStringLiteral(":/ItemLibrary/images/item-invalid-icon.png"));
}
static int drawIcon(QPainter *painter,
static int drawTypeIcon(QPainter *painter,
const QStyleOptionViewItem &styleOption,
const QModelIndex &modelIndex,
NavigatorTreeModel *navigatorTreeModel
......@@ -141,7 +141,7 @@ static int drawIcon(QPainter *painter,
ModelNode modelNode = navigatorTreeModel->nodeForIndex(modelIndex);
// If no icon is present, leave an empty space of 24 pixels anyway
QPixmap pixmap = getIcon(modelNode).pixmap(pixmapSize, pixmapSize);
QPixmap pixmap = getTypeIcon(modelNode).pixmap(pixmapSize, pixmapSize);
painter->drawPixmap(styleOption.rect.x() +1 , styleOption.rect.y() + 2, pixmap);
}
......@@ -226,7 +226,7 @@ void NameItemDelegate::paint(QPainter *painter,
if (styleOption.state & QStyle::State_Selected)
drawSelectionBackground(painter, styleOption);
int iconOffset = drawIcon(painter, styleOption, modelIndex, m_navigatorTreeModel);
int iconOffset = drawTypeIcon(painter, styleOption, modelIndex, m_navigatorTreeModel);
QRect textFrame = drawText(painter, styleOption, modelIndex, iconOffset, m_navigatorTreeModel);
......
......@@ -64,8 +64,8 @@ public:
QString name() const;
TypeName typeName() const;
QIcon icon() const;
QString iconPath() const;
QIcon typeIcon() const;
QString libraryEntryIconPath() const;
int majorVersion() const;
int minorVersion() const;
QString category() const;
......@@ -83,10 +83,10 @@ public:
void setType(const TypeName &typeName, int majorVersion, int minorVersion);
void setName(const QString &name);
void setIconPath(const QString &iconPath);
void setLibraryEntryIconPath(const QString &libraryEntryIconPath);
void addProperty(const Property &p);
void addProperty(PropertyName &name, QString &type, QVariant &value);
void setIcon(const QIcon &icon);
void setTypeIcon(const QIcon &typeIcon);
void setCategory(const QString &category);
void setQmlPath(const QString &qml);
void setRequiredImport(const QString &requiredImport);
......
......@@ -48,8 +48,8 @@ public:
QString category;
int majorVersion;
int minorVersion;
QString iconPath;
QIcon icon;
QString libraryEntryIconPath;
QIcon typeIcon;
QList<PropertyContainer> properties;
QString qml;
QString qmlSource;
......@@ -75,9 +75,9 @@ ItemLibraryEntry& ItemLibraryEntry::operator=(const ItemLibraryEntry &other)
return *this;
}
void ItemLibraryEntry::setIcon(const QIcon &icon)
void ItemLibraryEntry::setTypeIcon(const QIcon &icon)
{
m_data->icon = icon;
m_data->typeIcon = icon;
}
void ItemLibraryEntry::addProperty(const Property &property)
......@@ -144,17 +144,17 @@ void ItemLibraryEntry::setCategory(const QString &category)
m_data->category = category;
}
QIcon ItemLibraryEntry::icon() const
QIcon ItemLibraryEntry::typeIcon() const
{
return m_data->icon;
return m_data->typeIcon;
}
QString ItemLibraryEntry::iconPath() const
QString ItemLibraryEntry::libraryEntryIconPath() const
{
if (m_data->iconPath.isEmpty())
if (m_data->libraryEntryIconPath.isEmpty())
return QStringLiteral(":/ItemLibrary/images/item-default-icon.png");
return m_data->iconPath;
return m_data->libraryEntryIconPath;
}
void ItemLibraryEntry::setName(const QString &name)
......@@ -169,9 +169,9 @@ void ItemLibraryEntry::setType(const TypeName &typeName, int majorVersion, int m
m_data->minorVersion = minorVersion;
}
void ItemLibraryEntry::setIconPath(const QString &iconPath)
void ItemLibraryEntry::setLibraryEntryIconPath(const QString &iconPath)
{
m_data->iconPath = iconPath;
m_data->libraryEntryIconPath = iconPath;
}
static QString getSourceForUrl(const QString &fileURl)
......@@ -209,8 +209,8 @@ QDataStream& operator<<(QDataStream& stream, const ItemLibraryEntry &itemLibrary
stream << itemLibraryEntry.typeName();
stream << itemLibraryEntry.majorVersion();
stream << itemLibraryEntry.minorVersion();
stream << itemLibraryEntry.icon();
stream << itemLibraryEntry.iconPath();
stream << itemLibraryEntry.typeIcon();
stream << itemLibraryEntry.libraryEntryIconPath();
stream << itemLibraryEntry.category();
stream << itemLibraryEntry.requiredImport();
......@@ -227,8 +227,8 @@ QDataStream& operator>>(QDataStream& stream, ItemLibraryEntry &itemLibraryEntry)
stream >> itemLibraryEntry.m_data->typeName;
stream >> itemLibraryEntry.m_data->majorVersion;
stream >> itemLibraryEntry.m_data->minorVersion;
stream >> itemLibraryEntry.m_data->icon;
stream >> itemLibraryEntry.m_data->iconPath;
stream >> itemLibraryEntry.m_data->typeIcon;
stream >> itemLibraryEntry.m_data->libraryEntryIconPath;
stream >> itemLibraryEntry.m_data->category;
stream >> itemLibraryEntry.m_data->requiredImport;
......@@ -245,8 +245,8 @@ QDebug operator<<(QDebug debug, const ItemLibraryEntry &itemLibraryEntry)
debug << itemLibraryEntry.m_data->typeName;
debug << itemLibraryEntry.m_data->majorVersion;
debug << itemLibraryEntry.m_data->minorVersion;
debug << itemLibraryEntry.m_data->icon;
debug << itemLibraryEntry.m_data->iconPath;
debug << itemLibraryEntry.m_data->typeIcon;
debug << itemLibraryEntry.m_data->libraryEntryIconPath;
debug << itemLibraryEntry.m_data->category;
debug << itemLibraryEntry.m_data->requiredImport;
......
......@@ -165,7 +165,7 @@ MetaInfoReader::ParserSate MetaInfoReader::readTypeElement(const QString &name)
if (name == ItemLibraryEntryElementName) {
m_currentEntry = ItemLibraryEntry();
m_currentEntry.setType(m_currentClassName, -1, -1);
m_currentEntry.setIcon(QIcon(m_currentIcon));
m_currentEntry.setTypeIcon(QIcon(m_currentIcon));
return ParsingItemLibrary;
} else {
addErrorInvalidType(name);
......@@ -221,7 +221,7 @@ void MetaInfoReader::readItemLibraryEntryProperty(const QString &name, const QVa
} else if (name == QStringLiteral("category")) {
m_currentEntry.setCategory(value.toString());
} else if (name == QStringLiteral("libraryIcon")) {
m_currentEntry.setIconPath(absoluteFilePathForDocument(value.toString()));
m_currentEntry.setLibraryEntryIconPath(absoluteFilePathForDocument(value.toString()));
} else if (name == QStringLiteral("version")) {
setVersion(value.toString());
} else if (name == QStringLiteral("requiredImport")) {
......
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