forked from qt-creator/qt-creator
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:
@@ -64,6 +64,9 @@ QString ItemLibraryImport::sortingName() const
|
|||||||
if (m_isUserSection) // user components always come first
|
if (m_isUserSection) // user components always come first
|
||||||
return "_";
|
return "_";
|
||||||
|
|
||||||
|
if (!hasCategories()) // imports with no categories are at the bottom of the list
|
||||||
|
return "zzzzz" + importName();
|
||||||
|
|
||||||
return importName();
|
return importName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,12 +30,13 @@
|
|||||||
#include "itemlibraryitem.h"
|
#include "itemlibraryitem.h"
|
||||||
#include "itemlibraryinfo.h"
|
#include "itemlibraryinfo.h"
|
||||||
|
|
||||||
|
#include <designermcumanager.h>
|
||||||
#include <model.h>
|
#include <model.h>
|
||||||
#include <nodehints.h>
|
#include <nodehints.h>
|
||||||
#include <nodemetainfo.h>
|
#include <nodemetainfo.h>
|
||||||
|
#include <projectexplorer/project.h>
|
||||||
#include <designermcumanager.h>
|
#include <projectexplorer/session.h>
|
||||||
|
#include "qmldesignerplugin.h"
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -190,9 +191,13 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model)
|
|||||||
beginResetModel();
|
beginResetModel();
|
||||||
clearSections();
|
clearSections();
|
||||||
|
|
||||||
|
Utils::FilePath qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName();
|
||||||
|
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(qmlFileName);
|
||||||
|
QString projectName = project ? project->displayName() : "";
|
||||||
|
|
||||||
// create import sections
|
// create import sections
|
||||||
for (const Import &import : model->imports()) {
|
for (const Import &import : model->imports()) {
|
||||||
if (import.isLibraryImport()) {
|
if (import.isLibraryImport() && import.url() != projectName) {
|
||||||
ItemLibraryImport *itemLibImport = new ItemLibraryImport(import, this);
|
ItemLibraryImport *itemLibImport = new ItemLibraryImport(import, this);
|
||||||
m_importList.append(itemLibImport);
|
m_importList.append(itemLibImport);
|
||||||
itemLibImport->setImportExpanded(loadExpandedState(import.url()));
|
itemLibImport->setImportExpanded(loadExpandedState(import.url()));
|
||||||
|
Reference in New Issue
Block a user