forked from qt-creator/qt-creator
QmlDesigner: Add all Quick3DAssets under 1 import section
Fixes: QDS-3866 Change-Id: I3aad4aee0d6c388446b459e558d87f68b204de59 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -41,6 +41,9 @@ QString ItemLibraryImport::importName() const
|
|||||||
if (m_sectionType == SectionType::User)
|
if (m_sectionType == SectionType::User)
|
||||||
return userComponentsTitle();
|
return userComponentsTitle();
|
||||||
|
|
||||||
|
if (m_sectionType == SectionType::Quick3DAssets)
|
||||||
|
return quick3DAssetsTitle();
|
||||||
|
|
||||||
if (m_sectionType == SectionType::Unimported)
|
if (m_sectionType == SectionType::Unimported)
|
||||||
return unimportedComponentsTitle();
|
return unimportedComponentsTitle();
|
||||||
|
|
||||||
@@ -55,6 +58,9 @@ QString ItemLibraryImport::importUrl() const
|
|||||||
if (m_sectionType == SectionType::User)
|
if (m_sectionType == SectionType::User)
|
||||||
return userComponentsTitle();
|
return userComponentsTitle();
|
||||||
|
|
||||||
|
if (m_sectionType == SectionType::Quick3DAssets)
|
||||||
|
return quick3DAssetsTitle();
|
||||||
|
|
||||||
if (m_sectionType == SectionType::Unimported)
|
if (m_sectionType == SectionType::Unimported)
|
||||||
return unimportedComponentsTitle();
|
return unimportedComponentsTitle();
|
||||||
|
|
||||||
@@ -71,10 +77,13 @@ QString ItemLibraryImport::sortingName() const
|
|||||||
if (m_sectionType == SectionType::User)
|
if (m_sectionType == SectionType::User)
|
||||||
return "_"; // user components always come first
|
return "_"; // user components always come first
|
||||||
|
|
||||||
if (m_sectionType == SectionType::Unimported)
|
if (m_sectionType == SectionType::Quick3DAssets)
|
||||||
return "zzzzzz"; // Unimported components always come last
|
return "__"; // Quick3DAssets come second
|
||||||
|
|
||||||
if (!hasCategories()) // imports with no categories are at the bottom of the list
|
if (m_sectionType == SectionType::Unimported)
|
||||||
|
return "zzzzzz"; // Unimported components come last
|
||||||
|
|
||||||
|
if (!hasCategories()) // imports with no categories come before last
|
||||||
return "zzzzz_" + importName();
|
return "zzzzz_" + importName();
|
||||||
|
|
||||||
return importName();
|
return importName();
|
||||||
@@ -188,6 +197,13 @@ QString ItemLibraryImport::userComponentsTitle()
|
|||||||
return tr("My Components");
|
return tr("My Components");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
QString ItemLibraryImport::quick3DAssetsTitle()
|
||||||
|
{
|
||||||
|
return tr("My 3D Components");
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
QString ItemLibraryImport::unimportedComponentsTitle()
|
QString ItemLibraryImport::unimportedComponentsTitle()
|
||||||
{
|
{
|
||||||
return tr("All Other Components");
|
return tr("All Other Components");
|
||||||
|
@@ -48,6 +48,7 @@ public:
|
|||||||
enum class SectionType {
|
enum class SectionType {
|
||||||
Default,
|
Default,
|
||||||
User,
|
User,
|
||||||
|
Quick3DAssets,
|
||||||
Unimported
|
Unimported
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,6 +76,7 @@ public:
|
|||||||
void expandCategories(bool expand = true);
|
void expandCategories(bool expand = true);
|
||||||
|
|
||||||
static QString userComponentsTitle();
|
static QString userComponentsTitle();
|
||||||
|
static QString quick3DAssetsTitle();
|
||||||
static QString unimportedComponentsTitle();
|
static QString unimportedComponentsTitle();
|
||||||
|
|
||||||
SectionType sectionType() const;
|
SectionType sectionType() const;
|
||||||
|
@@ -216,24 +216,32 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model)
|
|||||||
for (const Import &import : model->imports()) {
|
for (const Import &import : model->imports()) {
|
||||||
if (import.isLibraryImport() && import.url() != projectName) {
|
if (import.isLibraryImport() && import.url() != projectName) {
|
||||||
bool addNew = true;
|
bool addNew = true;
|
||||||
ItemLibraryImport *oldImport = importHash.value(import.url());
|
bool isQuick3DAsset = import.url().startsWith("Quick3DAssets.");
|
||||||
if (oldImport && oldImport->importEntry().url() == import.url()) {
|
QString importUrl = isQuick3DAsset ? ItemLibraryImport::quick3DAssetsTitle() : import.url();
|
||||||
|
ItemLibraryImport *oldImport = importHash.value(importUrl);
|
||||||
|
if (oldImport && oldImport->sectionType() == ItemLibraryImport::SectionType::Quick3DAssets
|
||||||
|
&& isQuick3DAsset) {
|
||||||
|
addNew = false; // add only 1 Quick3DAssets import section
|
||||||
|
} else if (oldImport && oldImport->importEntry().url() == import.url()) {
|
||||||
// Retain the higher version if multiples exist
|
// Retain the higher version if multiples exist
|
||||||
if (compareVersions(oldImport->importEntry().version(), import.version()))
|
if (compareVersions(oldImport->importEntry().version(), import.version()))
|
||||||
addNew = false;
|
addNew = false;
|
||||||
else
|
else
|
||||||
delete oldImport;
|
delete oldImport;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addNew) {
|
if (addNew) {
|
||||||
ItemLibraryImport *itemLibImport = new ItemLibraryImport(import, this);
|
auto sectionType = isQuick3DAsset ? ItemLibraryImport::SectionType::Quick3DAssets
|
||||||
importHash.insert(import.url(), itemLibImport);
|
: ItemLibraryImport::SectionType::Default;
|
||||||
|
ItemLibraryImport *itemLibImport = new ItemLibraryImport(import, this, sectionType);
|
||||||
|
importHash.insert(importUrl, itemLibImport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto itemLibImport : qAsConst(importHash)) {
|
for (const auto itemLibImport : qAsConst(importHash)) {
|
||||||
m_importList.append(itemLibImport);
|
m_importList.append(itemLibImport);
|
||||||
itemLibImport->setImportExpanded(loadExpandedState(itemLibImport->importEntry().url()));
|
itemLibImport->setImportExpanded(loadExpandedState(itemLibImport->importUrl()));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<ItemLibraryEntry> itemLibEntries = itemLibraryInfo->entries();
|
const QList<ItemLibraryEntry> itemLibEntries = itemLibraryInfo->entries();
|
||||||
@@ -280,6 +288,8 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model)
|
|||||||
m_importList.append(importSection);
|
m_importList.append(importSection);
|
||||||
importSection->setImportExpanded(loadExpandedState(catName));
|
importSection->setImportExpanded(loadExpandedState(catName));
|
||||||
}
|
}
|
||||||
|
} else if (catName == "My Quick3D Components") {
|
||||||
|
importSection = importByUrl(ItemLibraryImport::quick3DAssetsTitle());
|
||||||
} else {
|
} else {
|
||||||
if (catName.startsWith("Qt Quick - "))
|
if (catName.startsWith("Qt Quick - "))
|
||||||
catName = catName.mid(11); // remove "Qt Quick - "
|
catName = catName.mid(11); // remove "Qt Quick - "
|
||||||
@@ -354,6 +364,8 @@ ItemLibraryImport *ItemLibraryModel::importByUrl(const QString &importUrl) const
|
|||||||
|| (importUrl.isEmpty() && itemLibraryImport->importUrl() == "QtQuick")
|
|| (importUrl.isEmpty() && itemLibraryImport->importUrl() == "QtQuick")
|
||||||
|| (importUrl == ItemLibraryImport::userComponentsTitle()
|
|| (importUrl == ItemLibraryImport::userComponentsTitle()
|
||||||
&& itemLibraryImport->sectionType() == ItemLibraryImport::SectionType::User)
|
&& itemLibraryImport->sectionType() == ItemLibraryImport::SectionType::User)
|
||||||
|
|| (importUrl == ItemLibraryImport::quick3DAssetsTitle()
|
||||||
|
&& itemLibraryImport->sectionType() == ItemLibraryImport::SectionType::Quick3DAssets)
|
||||||
|| (importUrl == ItemLibraryImport::unimportedComponentsTitle()
|
|| (importUrl == ItemLibraryImport::unimportedComponentsTitle()
|
||||||
&& itemLibraryImport->sectionType() == ItemLibraryImport::SectionType::Unimported)) {
|
&& itemLibraryImport->sectionType() == ItemLibraryImport::SectionType::Unimported)) {
|
||||||
return itemLibraryImport;
|
return itemLibraryImport;
|
||||||
|
Reference in New Issue
Block a user