forked from qt-creator/qt-creator
QmlDesigner.ItemLibrary: fixed: do not display non-visual components
Task-number: BAUHAUS-433 Reviewed-by: kkoehne
This commit is contained in:
committed by
Kai Koehne
parent
b3a6fe134a
commit
0943177d86
@@ -435,49 +435,53 @@ void ItemLibraryModel::updateVisibility()
|
|||||||
|
|
||||||
QList<ItemLibraryInfo> ItemLibraryModel::itemLibraryRepresentations(const QString &type)
|
QList<ItemLibraryInfo> ItemLibraryModel::itemLibraryRepresentations(const QString &type)
|
||||||
{
|
{
|
||||||
|
QList<ItemLibraryInfo> itemLibraryRepresentationList;
|
||||||
NodeMetaInfo nodeInfo = m_metaInfo->nodeMetaInfo(type);
|
NodeMetaInfo nodeInfo = m_metaInfo->nodeMetaInfo(type);
|
||||||
QList<ItemLibraryInfo> itemLibraryRepresentationList = m_metaInfo->itemLibraryRepresentations(nodeInfo);
|
|
||||||
|
|
||||||
QImage dragImage(64, 64, QImage::Format_RGB32); // TODO: draw item drag icon
|
if (nodeInfo.isQmlGraphicsItem()) {
|
||||||
dragImage.fill(0xffffffff);
|
itemLibraryRepresentationList = m_metaInfo->itemLibraryRepresentations(nodeInfo);
|
||||||
QPainter p(&dragImage);
|
|
||||||
QPen pen(Qt::gray);
|
|
||||||
pen.setWidth(2);
|
|
||||||
p.setPen(pen);
|
|
||||||
p.drawRect(1, 1, dragImage.width() - 2, dragImage.height() - 2);
|
|
||||||
QPixmap dragPixmap(QPixmap::fromImage(dragImage));
|
|
||||||
|
|
||||||
if (!m_metaInfo->hasNodeMetaInfo(type))
|
QImage dragImage(64, 64, QImage::Format_RGB32); // TODO: draw item drag icon
|
||||||
qWarning() << "ItemLibrary: type not declared: " << type;
|
dragImage.fill(0xffffffff);
|
||||||
|
QPainter p(&dragImage);
|
||||||
|
QPen pen(Qt::gray);
|
||||||
|
pen.setWidth(2);
|
||||||
|
p.setPen(pen);
|
||||||
|
p.drawRect(1, 1, dragImage.width() - 2, dragImage.height() - 2);
|
||||||
|
QPixmap dragPixmap(QPixmap::fromImage(dragImage));
|
||||||
|
|
||||||
static QIcon defaultIcon(QLatin1String(":/ItemLibrary/images/item-default-icon.png"));
|
if (!m_metaInfo->hasNodeMetaInfo(type))
|
||||||
|
qWarning() << "ItemLibrary: type not declared: " << type;
|
||||||
|
|
||||||
if (itemLibraryRepresentationList.isEmpty() || !m_metaInfo->hasNodeMetaInfo(type)) {
|
static QIcon defaultIcon(QLatin1String(":/ItemLibrary/images/item-default-icon.png"));
|
||||||
QIcon icon = nodeInfo.icon();
|
|
||||||
if (icon.isNull())
|
|
||||||
icon = defaultIcon;
|
|
||||||
|
|
||||||
ItemLibraryInfo itemLibraryInfo;
|
if (itemLibraryRepresentationList.isEmpty() || !m_metaInfo->hasNodeMetaInfo(type)) {
|
||||||
itemLibraryInfo.setName(type);
|
QIcon icon = nodeInfo.icon();
|
||||||
itemLibraryInfo.setTypeName(nodeInfo.typeName());
|
if (icon.isNull())
|
||||||
itemLibraryInfo.setCategory(nodeInfo.category());
|
icon = defaultIcon;
|
||||||
itemLibraryInfo.setIcon(icon);
|
|
||||||
itemLibraryInfo.setDragIcon(dragPixmap);
|
|
||||||
itemLibraryInfo.setMajorVersion(nodeInfo.majorVersion());
|
|
||||||
itemLibraryInfo.setMinorVersion(nodeInfo.minorVersion());
|
|
||||||
itemLibraryRepresentationList.append(itemLibraryInfo);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach (ItemLibraryInfo itemLibraryRepresentation, itemLibraryRepresentationList) {
|
|
||||||
QIcon icon = itemLibraryRepresentation.icon();
|
|
||||||
if (itemLibraryRepresentation.icon().isNull())
|
|
||||||
itemLibraryRepresentation.setIcon(defaultIcon);
|
|
||||||
|
|
||||||
if (itemLibraryRepresentation.dragIcon().isNull())
|
ItemLibraryInfo itemLibraryInfo;
|
||||||
itemLibraryRepresentation.setDragIcon(dragPixmap);
|
itemLibraryInfo.setName(type);
|
||||||
|
itemLibraryInfo.setTypeName(nodeInfo.typeName());
|
||||||
|
itemLibraryInfo.setCategory(nodeInfo.category());
|
||||||
|
itemLibraryInfo.setIcon(icon);
|
||||||
|
itemLibraryInfo.setDragIcon(dragPixmap);
|
||||||
|
itemLibraryInfo.setMajorVersion(nodeInfo.majorVersion());
|
||||||
|
itemLibraryInfo.setMinorVersion(nodeInfo.minorVersion());
|
||||||
|
itemLibraryRepresentationList.append(itemLibraryInfo);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foreach (ItemLibraryInfo itemLibraryRepresentation, itemLibraryRepresentationList) {
|
||||||
|
QIcon icon = itemLibraryRepresentation.icon();
|
||||||
|
if (itemLibraryRepresentation.icon().isNull())
|
||||||
|
itemLibraryRepresentation.setIcon(defaultIcon);
|
||||||
|
|
||||||
if (itemLibraryRepresentation.category().isEmpty())
|
if (itemLibraryRepresentation.dragIcon().isNull())
|
||||||
itemLibraryRepresentation.setCategory(nodeInfo.category());
|
itemLibraryRepresentation.setDragIcon(dragPixmap);
|
||||||
|
|
||||||
|
if (itemLibraryRepresentation.category().isEmpty())
|
||||||
|
itemLibraryRepresentation.setCategory(nodeInfo.category());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user