QmlDesigner: 2 item library import section improvements

- Move imports with no categories to the bottom of the list.
- Remove the project import from the list.

Change-Id: I41d229bb776bfe845dadbfc5c1be5b7d50aeee3e
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Mahmoud Badri
2021-02-22 22:10:53 +02:00
parent 7d3ba0587f
commit 83c61a7c53
2 changed files with 12 additions and 4 deletions

View File

@@ -64,6 +64,9 @@ QString ItemLibraryImport::sortingName() const
if (m_isUserSection) // user components always come first
return "_";
if (!hasCategories()) // imports with no categories are at the bottom of the list
return "zzzzz" + importName();
return importName();
}

View File

@@ -30,12 +30,13 @@
#include "itemlibraryitem.h"
#include "itemlibraryinfo.h"
#include <designermcumanager.h>
#include <model.h>
#include <nodehints.h>
#include <nodemetainfo.h>
#include <designermcumanager.h>
#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
#include "qmldesignerplugin.h"
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
@@ -190,9 +191,13 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model)
beginResetModel();
clearSections();
Utils::FilePath qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName();
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(qmlFileName);
QString projectName = project ? project->displayName() : "";
// create import sections
for (const Import &import : model->imports()) {
if (import.isLibraryImport()) {
if (import.isLibraryImport() && import.url() != projectName) {
ItemLibraryImport *itemLibImport = new ItemLibraryImport(import, this);
m_importList.append(itemLibImport);
itemLibImport->setImportExpanded(loadExpandedState(import.url()));