QmlDesigner: Small tweak in content lib method add3DInstance()

Rename add3DInstance() to addItemToProject() and use it in
addToProject(). This makes things slightly clearer.

Change-Id: I25475559b4fcb864887f57617d125785a8e78fbe
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Mahmoud Badri
2024-06-13 18:14:15 +03:00
parent ceb5950573
commit 625a521cf7
3 changed files with 18 additions and 23 deletions

View File

@@ -155,18 +155,6 @@ void ContentLibraryUserModel::addTextures(const QStringList &paths)
emit dataChanged(index(TexturesSectionIdx), index(TexturesSectionIdx));
}
void ContentLibraryUserModel::add3DInstance(ContentLibraryItem *bundleItem)
{
QString err = m_widget->importer()->importComponent(m_bundlePath3D.path(), bundleItem->type(),
bundleItem->qml(),
bundleItem->files() + m_bundle3DSharedFiles);
if (err.isEmpty())
m_widget->setImporterRunning(true);
else
qWarning() << __FUNCTION__ << err;
}
void ContentLibraryUserModel::removeTexture(ContentLibraryTexture *tex)
{
// remove resources
@@ -624,23 +612,30 @@ void ContentLibraryUserModel::applyToSelected(ContentLibraryItem *mat, bool add)
void ContentLibraryUserModel::addToProject(QObject *item)
{
auto castedItem = qobject_cast<ContentLibraryItem *>(item);
QString bundleDir;
TypeName type = castedItem->type();
QString qmlFile = castedItem->qml();
QStringList files = castedItem->files();
QTC_ASSERT(castedItem, return);
if (castedItem->itemType() == "material") {
bundleDir = m_bundlePathMaterial.toFSPathString();
addItemToProject(castedItem);
}
void ContentLibraryUserModel::addItemToProject(ContentLibraryItem *item)
{
QString bundlePath;
TypeName type = item->type();
QString qmlFile = item->qml();
QStringList files = item->files();
if (item->itemType() == "material") {
bundlePath = m_bundlePathMaterial.toFSPathString();
files << m_bundleMaterialSharedFiles;
} else if (castedItem->itemType() == "3d") {
bundleDir = m_bundlePath3D.toFSPathString();
} else if (item->itemType() == "3d") {
bundlePath = m_bundlePath3D.toFSPathString();
files << m_bundle3DSharedFiles;
} else {
qWarning() << __FUNCTION__ << "Unsupported Item";
return;
}
QString err = m_widget->importer()->importComponent(bundleDir, type, qmlFile, files);
QString err = m_widget->importer()->importComponent(bundlePath, type, qmlFile, files);
if (err.isEmpty())
m_widget->setImporterRunning(true);

View File

@@ -65,7 +65,7 @@ public:
void refreshSection(SectionIndex sectionIndex);
void addTextures(const QStringList &paths);
void add3DInstance(ContentLibraryItem *bundleItem);
void addItemToProject(ContentLibraryItem *item);
void remove3DFromContentLibByName(const QString &qmlFileName);
void removeMaterialFromContentLibByName(const QString &qmlFileName);

View File

@@ -365,7 +365,7 @@ void ContentLibraryView::customNotification(const AbstractView *view,
m_bundleItemPos = data.size() == 1 ? data.first() : QVariant();
if (is3D)
m_widget->userModel()->add3DInstance(m_draggedBundleItem);
m_widget->userModel()->addItemToProject(m_draggedBundleItem);
else
m_widget->effectsModel()->addInstance(m_draggedBundleItem);
m_bundleItemTarget = nodeList.first() ? nodeList.first() : Utils3D::active3DSceneNode(this);