QmlDesigner: Add item library tracing

Change-Id: I3c9c2130112e3bf8460bab6108435df553d1c3e9
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2025-05-30 12:21:14 +02:00
parent 13e00f1e2b
commit 89660dc715
15 changed files with 454 additions and 11 deletions

View File

@@ -44,6 +44,10 @@ env_with_default("QTC_ENABLE_NAVIGATOR_TRACING" ENV_QTC_ENABLE_NAVIGATOR_TRACING
option(ENABLE_NAVIGATOR_TRACING "Enable navigator tracing" ${ENV_QTC_ENABLE_NAVIGATOR_TRACING}) option(ENABLE_NAVIGATOR_TRACING "Enable navigator tracing" ${ENV_QTC_ENABLE_NAVIGATOR_TRACING})
add_feature_info("Navigator tracing" ${ENABLE_NAVIGATOR_TRACING} "") add_feature_info("Navigator tracing" ${ENABLE_NAVIGATOR_TRACING} "")
env_with_default("QTC_ENABLE_ITEM_LIBRARY_TRACING" ENV_QTC_ENABLE_ITEM_LIBRARY_TRACING OFF)
option(ENABLE_ITEM_LIBRARY_TRACING "Enable item library tracing" ${ENV_QTC_ENABLE_ITEM_LIBRARY_TRACING})
add_feature_info("Item library tracing" ${ENABLE_ITEM_LIBRARY_TRACING} "")
if(QDS_DESIGNVIEWER_USE_STAGING) if(QDS_DESIGNVIEWER_USE_STAGING)
add_definitions(-DQDS_DESIGNVIEWER_USE_STAGING) add_definitions(-DQDS_DESIGNVIEWER_USE_STAGING)
endif() endif()
@@ -354,6 +358,8 @@ extend_qtc_plugin(QmlDesigner
extend_qtc_plugin(QmlDesigner extend_qtc_plugin(QmlDesigner
SOURCES_PREFIX components/itemlibrary SOURCES_PREFIX components/itemlibrary
PUBLIC_DEFINES
$<$<BOOL:${ENABLE_ITEM_LIBRARY_TRACING}>:ENABLE_ITEM_LIBRARY_TRACING>
SOURCES SOURCES
itemlibrary.qrc itemlibrary.qrc
itemlibraryconstants.h itemlibraryconstants.h
@@ -362,6 +368,7 @@ extend_qtc_plugin(QmlDesigner
itemlibrarymodel.cpp itemlibrarymodel.h itemlibrarymodel.cpp itemlibrarymodel.h
itemlibrarycategory.cpp itemlibrarycategory.h itemlibrarycategory.cpp itemlibrarycategory.h
itemlibraryitemsmodel.cpp itemlibraryitemsmodel.h itemlibraryitemsmodel.cpp itemlibraryitemsmodel.h
itemlibrarytracing.cpp itemlibrarytracing.h
itemlibraryview.cpp itemlibraryview.h itemlibraryview.cpp itemlibraryview.h
itemlibrarywidget.cpp itemlibrarywidget.h itemlibrarywidget.cpp itemlibrarywidget.h
itemlibraryiconimageprovider.cpp itemlibraryiconimageprovider.h itemlibraryiconimageprovider.cpp itemlibraryiconimageprovider.h

View File

@@ -3,6 +3,7 @@
#include "itemlibraryaddimportmodel.h" #include "itemlibraryaddimportmodel.h"
#include "itemlibraryconstants.h" #include "itemlibraryconstants.h"
#include "itemlibrarytracing.h"
#include <designermcumanager.h> #include <designermcumanager.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
@@ -15,9 +16,13 @@
namespace QmlDesigner { namespace QmlDesigner {
static auto category = ItemLibraryTracing::category;
ItemLibraryAddImportModel::ItemLibraryAddImportModel(QObject *parent) ItemLibraryAddImportModel::ItemLibraryAddImportModel(QObject *parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)
{ {
NanotraceHR::Tracer tracer{"item library add import model constructor", category()};
// add role names // add role names
m_roleNames.insert(Qt::UserRole + 1, "importUrl"); m_roleNames.insert(Qt::UserRole + 1, "importUrl");
m_roleNames.insert(Qt::UserRole + 2, "importVisible"); m_roleNames.insert(Qt::UserRole + 2, "importVisible");
@@ -26,16 +31,20 @@ ItemLibraryAddImportModel::ItemLibraryAddImportModel(QObject *parent)
ItemLibraryAddImportModel::~ItemLibraryAddImportModel() ItemLibraryAddImportModel::~ItemLibraryAddImportModel()
{ {
NanotraceHR::Tracer tracer{"item library add import model destructor", category()};
} }
int ItemLibraryAddImportModel::rowCount(const QModelIndex & /*parent*/) const int ItemLibraryAddImportModel::rowCount(const QModelIndex & /*parent*/) const
{ {
NanotraceHR::Tracer tracer{"item library add import model row count", category()};
return m_importList.size(); return m_importList.size();
} }
QVariant ItemLibraryAddImportModel::data(const QModelIndex &index, int role) const QVariant ItemLibraryAddImportModel::data(const QModelIndex &index, int role) const
{ {
NanotraceHR::Tracer tracer{"item library add import model data", category()};
if (!index.isValid() || index.row() >= m_importList.size()) if (!index.isValid() || index.row() >= m_importList.size())
return {}; return {};
@@ -56,6 +65,8 @@ QVariant ItemLibraryAddImportModel::data(const QModelIndex &index, int role) con
QHash<int, QByteArray> ItemLibraryAddImportModel::roleNames() const QHash<int, QByteArray> ItemLibraryAddImportModel::roleNames() const
{ {
NanotraceHR::Tracer tracer{"item library add import model role names", category()};
return m_roleNames; return m_roleNames;
} }
@@ -69,6 +80,8 @@ bool isPriorityImport(QStringView importUrl)
void ItemLibraryAddImportModel::update(const Imports &possibleImports) void ItemLibraryAddImportModel::update(const Imports &possibleImports)
{ {
NanotraceHR::Tracer tracer{"item library add import model update", category()};
beginResetModel(); beginResetModel();
m_importList.clear(); m_importList.clear();
@@ -140,6 +153,8 @@ void ItemLibraryAddImportModel::update(const Imports &possibleImports)
Import ItemLibraryAddImportModel::getImport(const QString &importUrl) const Import ItemLibraryAddImportModel::getImport(const QString &importUrl) const
{ {
NanotraceHR::Tracer tracer{"item library add import model get import", category()};
for (const Import &import : std::as_const(m_importList)) for (const Import &import : std::as_const(m_importList))
if (import.url() == importUrl) if (import.url() == importUrl)
return import; return import;
@@ -149,6 +164,8 @@ Import ItemLibraryAddImportModel::getImport(const QString &importUrl) const
void ItemLibraryAddImportModel::setSearchText(const QString &searchText) void ItemLibraryAddImportModel::setSearchText(const QString &searchText)
{ {
NanotraceHR::Tracer tracer{"item library add import model set search text", category()};
QString lowerSearchText = searchText.toLower(); QString lowerSearchText = searchText.toLower();
if (m_searchText != lowerSearchText) { if (m_searchText != lowerSearchText) {
@@ -167,6 +184,8 @@ void ItemLibraryAddImportModel::setSearchText(const QString &searchText)
Import ItemLibraryAddImportModel::getImportAt(int index) const Import ItemLibraryAddImportModel::getImportAt(int index) const
{ {
NanotraceHR::Tracer tracer{"item library add import model get import at", category()};
return m_importList.at(index); return m_importList.at(index);
} }

View File

@@ -4,6 +4,7 @@
#include "itemlibrarycategoriesmodel.h" #include "itemlibrarycategoriesmodel.h"
#include "itemlibrarycategory.h" #include "itemlibrarycategory.h"
#include "itemlibrarymodel.h" #include "itemlibrarymodel.h"
#include "itemlibrarytracing.h"
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -15,23 +16,32 @@
namespace QmlDesigner { namespace QmlDesigner {
static auto category = ItemLibraryTracing::category;
ItemLibraryCategoriesModel::ItemLibraryCategoriesModel(QObject *parent) : ItemLibraryCategoriesModel::ItemLibraryCategoriesModel(QObject *parent) :
QAbstractListModel(parent) QAbstractListModel(parent)
{ {
NanotraceHR::Tracer tracer{"item library categories model constructor", category()};
addRoleNames(); addRoleNames();
} }
ItemLibraryCategoriesModel::~ItemLibraryCategoriesModel() ItemLibraryCategoriesModel::~ItemLibraryCategoriesModel()
{ {
NanotraceHR::Tracer tracer{"item library categories model destructor", category()};
} }
int ItemLibraryCategoriesModel::rowCount(const QModelIndex &) const int ItemLibraryCategoriesModel::rowCount(const QModelIndex &) const
{ {
NanotraceHR::Tracer tracer{"item library categories model row count", category()};
return m_categoryList.size(); return m_categoryList.size();
} }
QVariant ItemLibraryCategoriesModel::data(const QModelIndex &index, int role) const QVariant ItemLibraryCategoriesModel::data(const QModelIndex &index, int role) const
{ {
NanotraceHR::Tracer tracer{"item library categories model data", category()};
if (!index.isValid() || index.row() >= m_categoryList.size()) { if (!index.isValid() || index.row() >= m_categoryList.size()) {
qWarning() << Q_FUNC_INFO << "invalid index requested"; qWarning() << Q_FUNC_INFO << "invalid index requested";
return {}; return {};
@@ -53,6 +63,8 @@ QVariant ItemLibraryCategoriesModel::data(const QModelIndex &index, int role) co
bool ItemLibraryCategoriesModel::setData(const QModelIndex &index, const QVariant &value, int role) bool ItemLibraryCategoriesModel::setData(const QModelIndex &index, const QVariant &value, int role)
{ {
NanotraceHR::Tracer tracer{"item library categories model set data", category()};
// currently only categoryExpanded and categoryVisible properties is updatable // currently only categoryExpanded and categoryVisible properties is updatable
if (index.isValid() && m_roleNames.contains(role)) { if (index.isValid() && m_roleNames.contains(role)) {
QVariant currValue = m_categoryList.at(index.row())->property(m_roleNames.value(role)); QVariant currValue = m_categoryList.at(index.row())->property(m_roleNames.value(role));
@@ -76,11 +88,15 @@ bool ItemLibraryCategoriesModel::setData(const QModelIndex &index, const QVarian
QHash<int, QByteArray> ItemLibraryCategoriesModel::roleNames() const QHash<int, QByteArray> ItemLibraryCategoriesModel::roleNames() const
{ {
NanotraceHR::Tracer tracer{"item library categories model role names", category()};
return m_roleNames; return m_roleNames;
} }
void ItemLibraryCategoriesModel::expandCategories(bool expand) void ItemLibraryCategoriesModel::expandCategories(bool expand)
{ {
NanotraceHR::Tracer tracer{"item library categories model expand categories", category()};
int i = 0; int i = 0;
for (const auto &category : std::as_const(m_categoryList)) { for (const auto &category : std::as_const(m_categoryList)) {
if (category->categoryExpanded() != expand) { if (category->categoryExpanded() != expand) {
@@ -94,6 +110,9 @@ void ItemLibraryCategoriesModel::expandCategories(bool expand)
void ItemLibraryCategoriesModel::addCategory(ItemLibraryCategory *category) void ItemLibraryCategoriesModel::addCategory(ItemLibraryCategory *category)
{ {
NanotraceHR::Tracer tracer{"item library categories model add category",
ItemLibraryTracing::category()};
m_categoryList.append(category); m_categoryList.append(category);
category->setVisible(true); category->setVisible(true);
@@ -101,11 +120,15 @@ void ItemLibraryCategoriesModel::addCategory(ItemLibraryCategory *category)
const QList<QPointer<ItemLibraryCategory>> &ItemLibraryCategoriesModel::categorySections() const const QList<QPointer<ItemLibraryCategory>> &ItemLibraryCategoriesModel::categorySections() const
{ {
NanotraceHR::Tracer tracer{"item library categories model category sections", category()};
return m_categoryList; return m_categoryList;
} }
void ItemLibraryCategoriesModel::sortCategorySections() void ItemLibraryCategoriesModel::sortCategorySections()
{ {
NanotraceHR::Tracer tracer{"item library categories model sort category sections", category()};
auto categorySort = [](ItemLibraryCategory *first, ItemLibraryCategory *second) { auto categorySort = [](ItemLibraryCategory *first, ItemLibraryCategory *second) {
return QString::localeAwareCompare(first->sortingName(), second->sortingName()) < 0; return QString::localeAwareCompare(first->sortingName(), second->sortingName()) < 0;
}; };
@@ -118,12 +141,16 @@ void ItemLibraryCategoriesModel::sortCategorySections()
void ItemLibraryCategoriesModel::resetModel() void ItemLibraryCategoriesModel::resetModel()
{ {
NanotraceHR::Tracer tracer{"item library categories model reset model", category()};
beginResetModel(); beginResetModel();
endResetModel(); endResetModel();
} }
bool ItemLibraryCategoriesModel::isAllCategoriesHidden() const bool ItemLibraryCategoriesModel::isAllCategoriesHidden() const
{ {
NanotraceHR::Tracer tracer{"item library categories model is all categories hidden", category()};
for (const auto &category : std::as_const(m_categoryList)) { for (const auto &category : std::as_const(m_categoryList)) {
if (category->isCategoryVisible()) if (category->isCategoryVisible())
return false; return false;
@@ -134,6 +161,8 @@ bool ItemLibraryCategoriesModel::isAllCategoriesHidden() const
void ItemLibraryCategoriesModel::showAllCategories() void ItemLibraryCategoriesModel::showAllCategories()
{ {
NanotraceHR::Tracer tracer{"item library categories model show all categories", category()};
for (const auto &category : std::as_const(m_categoryList)) { for (const auto &category : std::as_const(m_categoryList)) {
if (!category->isCategoryVisible()) { if (!category->isCategoryVisible()) {
category->setCategoryVisible(true); category->setCategoryVisible(true);
@@ -147,6 +176,8 @@ void ItemLibraryCategoriesModel::showAllCategories()
void ItemLibraryCategoriesModel::hideCategory(const QString &categoryName) void ItemLibraryCategoriesModel::hideCategory(const QString &categoryName)
{ {
NanotraceHR::Tracer tracer{"item library categories model hide category", category()};
for (int i = 0; i < m_categoryList.size(); ++i) { for (int i = 0; i < m_categoryList.size(); ++i) {
const auto category = m_categoryList.at(i); const auto category = m_categoryList.at(i);
if (category->categoryName() == categoryName) { if (category->categoryName() == categoryName) {
@@ -161,6 +192,9 @@ void ItemLibraryCategoriesModel::hideCategory(const QString &categoryName)
int ItemLibraryCategoriesModel::selectFirstVisibleCategory() int ItemLibraryCategoriesModel::selectFirstVisibleCategory()
{ {
NanotraceHR::Tracer tracer{"item library categories model select first visible category",
category()};
for (int i = 0; i < m_categoryList.length(); ++i) { for (int i = 0; i < m_categoryList.length(); ++i) {
const auto category = m_categoryList.at(i); const auto category = m_categoryList.at(i);
@@ -176,6 +210,8 @@ int ItemLibraryCategoriesModel::selectFirstVisibleCategory()
void ItemLibraryCategoriesModel::clearSelectedCategory(int categoryIndex) void ItemLibraryCategoriesModel::clearSelectedCategory(int categoryIndex)
{ {
NanotraceHR::Tracer tracer{"item library categories model clear selected category", category()};
if (categoryIndex == -1 || m_categoryList.isEmpty()) if (categoryIndex == -1 || m_categoryList.isEmpty())
return; return;
@@ -185,6 +221,8 @@ void ItemLibraryCategoriesModel::clearSelectedCategory(int categoryIndex)
QPointer<ItemLibraryCategory> ItemLibraryCategoriesModel::selectCategory(int categoryIndex) QPointer<ItemLibraryCategory> ItemLibraryCategoriesModel::selectCategory(int categoryIndex)
{ {
NanotraceHR::Tracer tracer{"item library categories model select category", category()};
if (m_categoryList.isEmpty() || categoryIndex < 0 || categoryIndex >= m_categoryList.size()) if (m_categoryList.isEmpty() || categoryIndex < 0 || categoryIndex >= m_categoryList.size())
return nullptr; return nullptr;
@@ -200,6 +238,8 @@ QPointer<ItemLibraryCategory> ItemLibraryCategoriesModel::selectCategory(int cat
void ItemLibraryCategoriesModel::addRoleNames() void ItemLibraryCategoriesModel::addRoleNames()
{ {
NanotraceHR::Tracer tracer{"item library categories model add role names", category()};
int role = 0; int role = 0;
const QMetaObject meta = ItemLibraryCategory::staticMetaObject; const QMetaObject meta = ItemLibraryCategory::staticMetaObject;
for (int i = meta.propertyOffset(); i < meta.propertyCount(); ++i) for (int i = meta.propertyOffset(); i < meta.propertyCount(); ++i)

View File

@@ -4,41 +4,55 @@
#include "itemlibrarycategory.h" #include "itemlibrarycategory.h"
#include "itemlibraryitem.h" #include "itemlibraryitem.h"
#include "itemlibrarytracing.h"
#include "itemlibrarywidget.h" #include "itemlibrarywidget.h"
#include <QApplication> #include <QApplication>
namespace QmlDesigner { namespace QmlDesigner {
static auto category = ItemLibraryTracing::category;
ItemLibraryCategory::ItemLibraryCategory(const QString &groupName, QObject *parent) ItemLibraryCategory::ItemLibraryCategory(const QString &groupName, QObject *parent)
: QObject(parent), : QObject(parent),
m_ownerImport(qobject_cast<ItemLibraryImport *>(parent)), m_ownerImport(qobject_cast<ItemLibraryImport *>(parent)),
m_name(groupName) m_name(groupName)
{ {
NanotraceHR::Tracer tracer{"item library category constructor", category()};
} }
QString ItemLibraryCategory::categoryName() const QString ItemLibraryCategory::categoryName() const
{ {
NanotraceHR::Tracer tracer{"item library category name", category()};
return m_name; return m_name;
} }
QString ItemLibraryCategory::displayNMame() const QString ItemLibraryCategory::displayNMame() const
{ {
return QApplication::translate("itemlibrary", m_name.toUtf8()); NanotraceHR::Tracer tracer{"item library category display name", category()};
return QApplication::translate("itemlibrary", m_name.toUtf8());
} }
bool ItemLibraryCategory::categoryExpanded() const bool ItemLibraryCategory::categoryExpanded() const
{ {
NanotraceHR::Tracer tracer{"item library category expanded", category()};
return m_categoryExpanded; return m_categoryExpanded;
} }
bool ItemLibraryCategory::categorySelected() const bool ItemLibraryCategory::categorySelected() const
{ {
NanotraceHR::Tracer tracer{"item library category selected", category()};
return m_categorySelected; return m_categorySelected;
} }
QString ItemLibraryCategory::sortingName() const QString ItemLibraryCategory::sortingName() const
{ {
NanotraceHR::Tracer tracer{"item library category sorting name", category()};
if (ItemLibraryModel::categorySortingHash.contains(categoryName())) if (ItemLibraryModel::categorySortingHash.contains(categoryName()))
return ItemLibraryModel::categorySortingHash.value(categoryName()); return ItemLibraryModel::categorySortingHash.value(categoryName());
@@ -47,6 +61,8 @@ QString ItemLibraryCategory::sortingName() const
void ItemLibraryCategory::addItem(ItemLibraryItem *itemEntry) void ItemLibraryCategory::addItem(ItemLibraryItem *itemEntry)
{ {
NanotraceHR::Tracer tracer{"item library category add item", category()};
m_itemModel.addItem(itemEntry); m_itemModel.addItem(itemEntry);
} }
@@ -57,6 +73,8 @@ QObject *ItemLibraryCategory::itemModel()
bool ItemLibraryCategory::updateItemVisibility(const QString &searchText, bool *changed) bool ItemLibraryCategory::updateItemVisibility(const QString &searchText, bool *changed)
{ {
NanotraceHR::Tracer tracer{"item library category update item visibility", category()};
bool hasVisibleItems = false; bool hasVisibleItems = false;
*changed = false; *changed = false;
@@ -88,6 +106,8 @@ bool ItemLibraryCategory::updateItemVisibility(const QString &searchText, bool *
void ItemLibraryCategory::setCategoryVisible(bool isVisible) void ItemLibraryCategory::setCategoryVisible(bool isVisible)
{ {
NanotraceHR::Tracer tracer{"item library category set visible", category()};
if (isVisible != m_isVisible) { if (isVisible != m_isVisible) {
m_isVisible = isVisible; m_isVisible = isVisible;
emit categoryVisibilityChanged(); emit categoryVisibilityChanged();
@@ -96,6 +116,8 @@ void ItemLibraryCategory::setCategoryVisible(bool isVisible)
bool ItemLibraryCategory::setVisible(bool isVisible) bool ItemLibraryCategory::setVisible(bool isVisible)
{ {
NanotraceHR::Tracer tracer{"item library category set visible", category()};
if (isVisible != m_isVisible) { if (isVisible != m_isVisible) {
m_isVisible = isVisible; m_isVisible = isVisible;
return true; return true;
@@ -106,21 +128,29 @@ bool ItemLibraryCategory::setVisible(bool isVisible)
bool ItemLibraryCategory::isCategoryVisible() const bool ItemLibraryCategory::isCategoryVisible() const
{ {
NanotraceHR::Tracer tracer{"item library category is visible", category()};
return m_isVisible; return m_isVisible;
} }
void ItemLibraryCategory::sortItems() void ItemLibraryCategory::sortItems()
{ {
NanotraceHR::Tracer tracer{"item library category sort items", category()};
m_itemModel.sortItems(); m_itemModel.sortItems();
} }
void ItemLibraryCategory::setExpanded(bool expanded) void ItemLibraryCategory::setExpanded(bool expanded)
{ {
NanotraceHR::Tracer tracer{"item library category set expanded", category()};
m_categoryExpanded = expanded; m_categoryExpanded = expanded;
} }
void ItemLibraryCategory::setCategorySelected(bool selected) void ItemLibraryCategory::setCategorySelected(bool selected)
{ {
NanotraceHR::Tracer tracer{"item library category set category selected", category()};
m_categorySelected = selected; m_categorySelected = selected;
emit categorySelectedChanged(); emit categorySelectedChanged();
} }

View File

@@ -3,6 +3,8 @@
#include "itemlibraryiconimageprovider.h" #include "itemlibraryiconimageprovider.h"
#include "itemlibrarytracing.h"
#include <imagecache/imagecacheimageresponse.h> #include <imagecache/imagecacheimageresponse.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
@@ -13,9 +15,13 @@
namespace QmlDesigner { namespace QmlDesigner {
static auto category = ItemLibraryTracing::category;
QQuickImageResponse *ItemLibraryIconImageProvider::requestImageResponse(const QString &id, QQuickImageResponse *ItemLibraryIconImageProvider::requestImageResponse(const QString &id,
const QSize &) const QSize &)
{ {
NanotraceHR::Tracer tracer{"item library icon image provider request image response", category()};
auto response = std::make_unique<ImageCacheImageResponse>(QImage{ auto response = std::make_unique<ImageCacheImageResponse>(QImage{
Utils::StyleHelper::dpiSpecificImageFile(":/ItemLibrary/images/item-default-icon.png")}); Utils::StyleHelper::dpiSpecificImageFile(":/ItemLibrary/images/item-default-icon.png")});

View File

@@ -3,19 +3,26 @@
#include "itemlibraryimageprovider.h" #include "itemlibraryimageprovider.h"
#include "itemlibrarytracing.h"
#include <utils/stylehelper.h> #include <utils/stylehelper.h>
namespace QmlDesigner { namespace QmlDesigner {
static auto category = ItemLibraryTracing::category;
namespace Internal { namespace Internal {
ItemLibraryImageProvider::ItemLibraryImageProvider() : ItemLibraryImageProvider::ItemLibraryImageProvider() :
QQuickImageProvider(QQuickImageProvider::Pixmap) QQuickImageProvider(QQuickImageProvider::Pixmap)
{ {
NanotraceHR::Tracer tracer{"item library image provider constructor", category()};
} }
QPixmap ItemLibraryImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) QPixmap ItemLibraryImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
{ {
NanotraceHR::Tracer tracer{"item library image provider request pixmap", category()};
QPixmap pixmap(Utils::StyleHelper::dpiSpecificImageFile(id)); QPixmap pixmap(Utils::StyleHelper::dpiSpecificImageFile(id));
if (size) { if (size) {
size->setWidth(pixmap.width()); size->setWidth(pixmap.width());

View File

@@ -3,19 +3,26 @@
#include "itemlibraryimport.h" #include "itemlibraryimport.h"
#include "itemlibrarycategory.h" #include "itemlibrarycategory.h"
#include "itemlibrarytracing.h"
namespace QmlDesigner { namespace QmlDesigner {
static auto category = ItemLibraryTracing::category;
ItemLibraryImport::ItemLibraryImport(const Import &import, QObject *parent, SectionType sectionType) ItemLibraryImport::ItemLibraryImport(const Import &import, QObject *parent, SectionType sectionType)
: QObject(parent), : QObject(parent),
m_import(import), m_import(import),
m_sectionType(sectionType) m_sectionType(sectionType)
{ {
NanotraceHR::Tracer tracer{"item library import constructor", category()};
updateRemovable(); updateRemovable();
} }
QString ItemLibraryImport::importName() const QString ItemLibraryImport::importName() const
{ {
NanotraceHR::Tracer tracer{"item library import name", category()};
if (m_sectionType == SectionType::User) if (m_sectionType == SectionType::User)
return userComponentsTitle(); return userComponentsTitle();
@@ -33,6 +40,8 @@ QString ItemLibraryImport::importName() const
QString ItemLibraryImport::importUrl() const QString ItemLibraryImport::importUrl() const
{ {
NanotraceHR::Tracer tracer{"item library import URL", category()};
if (m_sectionType == SectionType::User) if (m_sectionType == SectionType::User)
return userComponentsTitle(); return userComponentsTitle();
@@ -47,11 +56,15 @@ QString ItemLibraryImport::importUrl() const
bool ItemLibraryImport::importExpanded() const bool ItemLibraryImport::importExpanded() const
{ {
NanotraceHR::Tracer tracer{"item library import expanded", category()};
return m_importExpanded; return m_importExpanded;
} }
QString ItemLibraryImport::sortingName() const QString ItemLibraryImport::sortingName() const
{ {
NanotraceHR::Tracer tracer{"item library import sorting name", category()};
if (m_sectionType == SectionType::User) if (m_sectionType == SectionType::User)
return "_"; // user components always come first return "_"; // user components always come first
@@ -66,21 +79,29 @@ QString ItemLibraryImport::sortingName() const
void ItemLibraryImport::addCategory(ItemLibraryCategory *category) void ItemLibraryImport::addCategory(ItemLibraryCategory *category)
{ {
NanotraceHR::Tracer tracer{"item library import add category", ItemLibraryTracing::category()};
m_categoryModel.addCategory(category); m_categoryModel.addCategory(category);
} }
QObject *ItemLibraryImport::categoryModel() QObject *ItemLibraryImport::categoryModel()
{ {
NanotraceHR::Tracer tracer{"item library import category model", category()};
return &m_categoryModel; return &m_categoryModel;
} }
void ItemLibraryImport::expandCategories(bool expand) void ItemLibraryImport::expandCategories(bool expand)
{ {
NanotraceHR::Tracer tracer{"item library import expand categories", category()};
m_categoryModel.expandCategories(expand); m_categoryModel.expandCategories(expand);
} }
bool ItemLibraryImport::updateCategoryVisibility(const QString &searchText, bool *changed) bool ItemLibraryImport::updateCategoryVisibility(const QString &searchText, bool *changed)
{ {
NanotraceHR::Tracer tracer{"item library import update category visibility", category()};
bool hasVisibleCategories = false; bool hasVisibleCategories = false;
*changed = false; *changed = false;
@@ -104,33 +125,45 @@ bool ItemLibraryImport::updateCategoryVisibility(const QString &searchText, bool
void ItemLibraryImport::showAllCategories() void ItemLibraryImport::showAllCategories()
{ {
NanotraceHR::Tracer tracer{"item library import show all categories", category()};
m_categoryModel.showAllCategories(); m_categoryModel.showAllCategories();
setAllCategoriesVisible(true); setAllCategoriesVisible(true);
} }
void ItemLibraryImport::hideCategory(const QString &categoryName) void ItemLibraryImport::hideCategory(const QString &categoryName)
{ {
NanotraceHR::Tracer tracer{"item library import hide category", category()};
m_categoryModel.hideCategory(categoryName); m_categoryModel.hideCategory(categoryName);
setAllCategoriesVisible(false); setAllCategoriesVisible(false);
} }
ItemLibraryCategory *ItemLibraryImport::selectCategory(int categoryIndex) ItemLibraryCategory *ItemLibraryImport::selectCategory(int categoryIndex)
{ {
NanotraceHR::Tracer tracer{"item library import select category", category()};
return m_categoryModel.selectCategory(categoryIndex); return m_categoryModel.selectCategory(categoryIndex);
} }
int ItemLibraryImport::selectFirstVisibleCategory() int ItemLibraryImport::selectFirstVisibleCategory()
{ {
NanotraceHR::Tracer tracer{"item library import select first visible category", category()};
return m_categoryModel.selectFirstVisibleCategory(); return m_categoryModel.selectFirstVisibleCategory();
} }
void ItemLibraryImport::clearSelectedCategory(int categoryIndex) void ItemLibraryImport::clearSelectedCategory(int categoryIndex)
{ {
NanotraceHR::Tracer tracer{"item library import clear selected category", category()};
m_categoryModel.clearSelectedCategory(categoryIndex); m_categoryModel.clearSelectedCategory(categoryIndex);
} }
bool ItemLibraryImport::isAllCategoriesHidden() const bool ItemLibraryImport::isAllCategoriesHidden() const
{ {
NanotraceHR::Tracer tracer{"item library import is all categories hidden", category()};
if (!m_isVisible) if (!m_isVisible)
return true; return true;
@@ -139,11 +172,15 @@ bool ItemLibraryImport::isAllCategoriesHidden() const
Import ItemLibraryImport::importEntry() const Import ItemLibraryImport::importEntry() const
{ {
NanotraceHR::Tracer tracer{"item library import entry", category()};
return m_import; return m_import;
} }
bool ItemLibraryImport::setVisible(bool isVisible) bool ItemLibraryImport::setVisible(bool isVisible)
{ {
NanotraceHR::Tracer tracer{"item library import set visible", category()};
if (isVisible != m_isVisible) { if (isVisible != m_isVisible) {
m_isVisible = isVisible; m_isVisible = isVisible;
emit importVisibleChanged(); emit importVisibleChanged();
@@ -155,11 +192,15 @@ bool ItemLibraryImport::setVisible(bool isVisible)
bool ItemLibraryImport::importVisible() const bool ItemLibraryImport::importVisible() const
{ {
NanotraceHR::Tracer tracer{"item library import is visible", category()};
return m_isVisible; return m_isVisible;
} }
void ItemLibraryImport::setImportUsed(bool importUsed) void ItemLibraryImport::setImportUsed(bool importUsed)
{ {
NanotraceHR::Tracer tracer{"item library import set used", category()};
if (importUsed != m_importUsed) { if (importUsed != m_importUsed) {
m_importUsed = importUsed; m_importUsed = importUsed;
updateRemovable(); updateRemovable();
@@ -169,31 +210,43 @@ void ItemLibraryImport::setImportUsed(bool importUsed)
bool ItemLibraryImport::importUsed() const bool ItemLibraryImport::importUsed() const
{ {
NanotraceHR::Tracer tracer{"item library import is used", category()};
return m_importUsed; return m_importUsed;
} }
bool ItemLibraryImport::importRemovable() const bool ItemLibraryImport::importRemovable() const
{ {
NanotraceHR::Tracer tracer{"item library import is removable", category()};
return m_importRemovable; return m_importRemovable;
} }
bool ItemLibraryImport::hasCategories() const bool ItemLibraryImport::hasCategories() const
{ {
NanotraceHR::Tracer tracer{"item library import has categories", category()};
return m_categoryModel.rowCount() > 0; return m_categoryModel.rowCount() > 0;
} }
bool ItemLibraryImport::hasSingleCategory() const bool ItemLibraryImport::hasSingleCategory() const
{ {
NanotraceHR::Tracer tracer{"item library import has single category", category()};
return m_categoryModel.rowCount() == 1; return m_categoryModel.rowCount() == 1;
} }
void ItemLibraryImport::sortCategorySections() void ItemLibraryImport::sortCategorySections()
{ {
NanotraceHR::Tracer tracer{"item library import sort category sections", category()};
m_categoryModel.sortCategorySections(); m_categoryModel.sortCategorySections();
} }
void ItemLibraryImport::setImportExpanded(bool expanded) void ItemLibraryImport::setImportExpanded(bool expanded)
{ {
NanotraceHR::Tracer tracer{"item library import set expanded", category()};
if (expanded != m_importExpanded) { if (expanded != m_importExpanded) {
m_importExpanded = expanded; m_importExpanded = expanded;
emit importExpandChanged(); emit importExpandChanged();
@@ -202,6 +255,8 @@ void ItemLibraryImport::setImportExpanded(bool expanded)
ItemLibraryCategory *ItemLibraryImport::getCategoryByName(const QString &categoryName) const ItemLibraryCategory *ItemLibraryImport::getCategoryByName(const QString &categoryName) const
{ {
NanotraceHR::Tracer tracer{"item library import get category by name", category()};
for (ItemLibraryCategory *catSec : std::as_const(m_categoryModel.categorySections())) { for (ItemLibraryCategory *catSec : std::as_const(m_categoryModel.categorySections())) {
if (catSec->categoryName() == categoryName) if (catSec->categoryName() == categoryName)
return catSec; return catSec;
@@ -212,6 +267,8 @@ ItemLibraryCategory *ItemLibraryImport::getCategoryByName(const QString &categor
ItemLibraryCategory *ItemLibraryImport::getCategoryAt(int categoryIndex) const ItemLibraryCategory *ItemLibraryImport::getCategoryAt(int categoryIndex) const
{ {
NanotraceHR::Tracer tracer{"item library import get category at index", category()};
const QList<QPointer<ItemLibraryCategory>> categories = m_categoryModel.categorySections(); const QList<QPointer<ItemLibraryCategory>> categories = m_categoryModel.categorySections();
if (categoryIndex != -1 && !categories.isEmpty()) if (categoryIndex != -1 && !categories.isEmpty())
@@ -223,22 +280,30 @@ ItemLibraryCategory *ItemLibraryImport::getCategoryAt(int categoryIndex) const
// static // static
QString ItemLibraryImport::userComponentsTitle() QString ItemLibraryImport::userComponentsTitle()
{ {
NanotraceHR::Tracer tracer{"item library import user components title", category()};
return tr("My Components"); return tr("My Components");
} }
// static // static
QString ItemLibraryImport::unimportedComponentsTitle() QString ItemLibraryImport::unimportedComponentsTitle()
{ {
NanotraceHR::Tracer tracer{"item library import unimported components title", category()};
return tr("All Other Components"); return tr("All Other Components");
} }
ItemLibraryImport::SectionType ItemLibraryImport::sectionType() const ItemLibraryImport::SectionType ItemLibraryImport::sectionType() const
{ {
NanotraceHR::Tracer tracer{"item library import section type", category()};
return m_sectionType; return m_sectionType;
} }
void ItemLibraryImport::updateRemovable() void ItemLibraryImport::updateRemovable()
{ {
NanotraceHR::Tracer tracer{"item library import update removable", category()};
#ifdef QDS_USE_PROJECTSTORAGE #ifdef QDS_USE_PROJECTSTORAGE
bool importRemovable = m_sectionType == SectionType::Default && m_import.url() != "QtQuick"; bool importRemovable = m_sectionType == SectionType::Default && m_import.url() != "QtQuick";
#else #else
@@ -253,11 +318,15 @@ void ItemLibraryImport::updateRemovable()
bool ItemLibraryImport::allCategoriesVisible() const bool ItemLibraryImport::allCategoriesVisible() const
{ {
NanotraceHR::Tracer tracer{"item library import all categories visible", category()};
return m_allCategoriesVisible; return m_allCategoriesVisible;
} }
void ItemLibraryImport::setAllCategoriesVisible(bool visible) void ItemLibraryImport::setAllCategoriesVisible(bool visible)
{ {
NanotraceHR::Tracer tracer{"item library import set all categories visible", category()};
m_allCategoriesVisible = visible; m_allCategoriesVisible = visible;
} }

View File

@@ -2,32 +2,45 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "itemlibraryitem.h" #include "itemlibraryitem.h"
#include "itemlibrarytracing.h"
#include <QApplication> #include <QApplication>
namespace QmlDesigner { namespace QmlDesigner {
static auto category = ItemLibraryTracing::category;
ItemLibraryItem::ItemLibraryItem(const ItemLibraryEntry &itemLibraryEntry, bool isUsable, QObject *parent) ItemLibraryItem::ItemLibraryItem(const ItemLibraryEntry &itemLibraryEntry, bool isUsable, QObject *parent)
: QObject(parent) : QObject(parent)
, m_itemLibraryEntry(itemLibraryEntry) , m_itemLibraryEntry(itemLibraryEntry)
, m_isUsable(isUsable) , m_isUsable(isUsable)
{ {
NanotraceHR::Tracer tracer{"item library item constructor", category()};
} }
ItemLibraryItem::~ItemLibraryItem() = default; ItemLibraryItem::~ItemLibraryItem()
{
NanotraceHR::Tracer tracer{"item library item destructor", category()};
}
QString ItemLibraryItem::itemName() const QString ItemLibraryItem::itemName() const
{ {
NanotraceHR::Tracer tracer{"item library item name", category()};
return QApplication::translate("itemlibrary", m_itemLibraryEntry.name().toUtf8()); return QApplication::translate("itemlibrary", m_itemLibraryEntry.name().toUtf8());
} }
QString ItemLibraryItem::typeName() const QString ItemLibraryItem::typeName() const
{ {
NanotraceHR::Tracer tracer{"item library item type name", category()};
return QString::fromUtf8(m_itemLibraryEntry.typeName()); return QString::fromUtf8(m_itemLibraryEntry.typeName());
} }
QString ItemLibraryItem::itemLibraryIconPath() const QString ItemLibraryItem::itemLibraryIconPath() const
{ {
NanotraceHR::Tracer tracer{"item library item icon path", category()};
if (m_itemLibraryEntry.customComponentSource().isEmpty() if (m_itemLibraryEntry.customComponentSource().isEmpty()
|| !m_itemLibraryEntry.libraryEntryIconPath().isEmpty()) { || !m_itemLibraryEntry.libraryEntryIconPath().isEmpty()) {
return QStringLiteral("image://qmldesigner_itemlibrary/") return QStringLiteral("image://qmldesigner_itemlibrary/")
@@ -40,26 +53,36 @@ QString ItemLibraryItem::itemLibraryIconPath() const
QString ItemLibraryItem::componentPath() const QString ItemLibraryItem::componentPath() const
{ {
NanotraceHR::Tracer tracer{"item library item component path", category()};
return m_itemLibraryEntry.customComponentSource(); return m_itemLibraryEntry.customComponentSource();
} }
QString ItemLibraryItem::requiredImport() const QString ItemLibraryItem::requiredImport() const
{ {
NanotraceHR::Tracer tracer{"item library item required import", category()};
return m_itemLibraryEntry.requiredImport(); return m_itemLibraryEntry.requiredImport();
} }
QString ItemLibraryItem::componentSource() const QString ItemLibraryItem::componentSource() const
{ {
NanotraceHR::Tracer tracer{"item library item component source", category()};
return m_itemLibraryEntry.customComponentSource(); return m_itemLibraryEntry.customComponentSource();
} }
QString ItemLibraryItem::toolTip() const QString ItemLibraryItem::toolTip() const
{ {
NanotraceHR::Tracer tracer{"item library item tool tip", category()};
return m_itemLibraryEntry.toolTip(); return m_itemLibraryEntry.toolTip();
} }
bool ItemLibraryItem::setVisible(bool isVisible) bool ItemLibraryItem::setVisible(bool isVisible)
{ {
NanotraceHR::Tracer tracer{"item library item set visible", category()};
if (isVisible != m_isVisible) { if (isVisible != m_isVisible) {
m_isVisible = isVisible; m_isVisible = isVisible;
emit visibilityChanged(); emit visibilityChanged();
@@ -71,16 +94,22 @@ bool ItemLibraryItem::setVisible(bool isVisible)
bool ItemLibraryItem::isVisible() const bool ItemLibraryItem::isVisible() const
{ {
NanotraceHR::Tracer tracer{"item library item is visible", category()};
return m_isVisible; return m_isVisible;
} }
bool ItemLibraryItem::isUsable() const bool ItemLibraryItem::isUsable() const
{ {
NanotraceHR::Tracer tracer{"item library item is usable", category()};
return m_isUsable; return m_isUsable;
} }
QVariant ItemLibraryItem::itemLibraryEntry() const QVariant ItemLibraryItem::itemLibraryEntry() const
{ {
NanotraceHR::Tracer tracer{"item library item library entry", category()};
return QVariant::fromValue(m_itemLibraryEntry); return QVariant::fromValue(m_itemLibraryEntry);
} }
} // namespace QmlDesigner } // namespace QmlDesigner

View File

@@ -3,29 +3,40 @@
#include "itemlibraryitemsmodel.h" #include "itemlibraryitemsmodel.h"
#include "itemlibraryitem.h" #include "itemlibraryitem.h"
#include "itemlibrarytracing.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QDebug> #include <QDebug>
#include <QMetaProperty> #include <QMetaProperty>
namespace QmlDesigner { namespace QmlDesigner {
static auto category = ItemLibraryTracing::category;
ItemLibraryItemsModel::ItemLibraryItemsModel(QObject *parent) : ItemLibraryItemsModel::ItemLibraryItemsModel(QObject *parent) :
QAbstractListModel(parent) QAbstractListModel(parent)
{ {
NanotraceHR::Tracer tracer{"item library items model constructor", category()};
addRoleNames(); addRoleNames();
} }
ItemLibraryItemsModel::~ItemLibraryItemsModel() ItemLibraryItemsModel::~ItemLibraryItemsModel()
{ {
NanotraceHR::Tracer tracer{"item library items model destructor", category()};
} }
int ItemLibraryItemsModel::rowCount(const QModelIndex &) const int ItemLibraryItemsModel::rowCount(const QModelIndex &) const
{ {
NanotraceHR::Tracer tracer{"item library items model row count", category()};
return m_itemList.size(); return m_itemList.size();
} }
QVariant ItemLibraryItemsModel::data(const QModelIndex &index, int role) const QVariant ItemLibraryItemsModel::data(const QModelIndex &index, int role) const
{ {
NanotraceHR::Tracer tracer{"item library items model data", category()};
if (!index.isValid() || index.row() >= m_itemList.count()) { if (!index.isValid() || index.row() >= m_itemList.count()) {
qDebug() << Q_FUNC_INFO << "invalid index requested"; qDebug() << Q_FUNC_INFO << "invalid index requested";
return {}; return {};
@@ -41,11 +52,15 @@ QVariant ItemLibraryItemsModel::data(const QModelIndex &index, int role) const
QHash<int, QByteArray> ItemLibraryItemsModel::roleNames() const QHash<int, QByteArray> ItemLibraryItemsModel::roleNames() const
{ {
NanotraceHR::Tracer tracer{"item library items model role names", category()};
return m_roleNames; return m_roleNames;
} }
void ItemLibraryItemsModel::addItem(ItemLibraryItem *element) void ItemLibraryItemsModel::addItem(ItemLibraryItem *element)
{ {
NanotraceHR::Tracer tracer{"item library items model add item", category()};
m_itemList.append(element); m_itemList.append(element);
element->setVisible(element->isUsable()); element->setVisible(element->isUsable());
@@ -53,11 +68,15 @@ void ItemLibraryItemsModel::addItem(ItemLibraryItem *element)
const QList<QPointer<ItemLibraryItem>> &ItemLibraryItemsModel::items() const const QList<QPointer<ItemLibraryItem>> &ItemLibraryItemsModel::items() const
{ {
NanotraceHR::Tracer tracer{"item library items model items", category()};
return m_itemList; return m_itemList;
} }
void ItemLibraryItemsModel::sortItems() void ItemLibraryItemsModel::sortItems()
{ {
NanotraceHR::Tracer tracer{"item library items model sort items", category()};
int nullPointerSectionCount = m_itemList.removeAll(QPointer<ItemLibraryItem>()); int nullPointerSectionCount = m_itemList.removeAll(QPointer<ItemLibraryItem>());
QTC_ASSERT(nullPointerSectionCount == 0,;); QTC_ASSERT(nullPointerSectionCount == 0,;);
auto itemSort = [](ItemLibraryItem *first, ItemLibraryItem *second) { auto itemSort = [](ItemLibraryItem *first, ItemLibraryItem *second) {
@@ -69,12 +88,16 @@ void ItemLibraryItemsModel::sortItems()
void ItemLibraryItemsModel::resetModel() void ItemLibraryItemsModel::resetModel()
{ {
NanotraceHR::Tracer tracer{"item library items model reset model", category()};
beginResetModel(); beginResetModel();
endResetModel(); endResetModel();
} }
void ItemLibraryItemsModel::addRoleNames() void ItemLibraryItemsModel::addRoleNames()
{ {
NanotraceHR::Tracer tracer{"item library items model add role names", category()};
int role = 0; int role = 0;
const QMetaObject meta = ItemLibraryItem::staticMetaObject; const QMetaObject meta = ItemLibraryItem::staticMetaObject;
for (int i = meta.propertyOffset(); i < meta.propertyCount(); ++i) for (int i = meta.propertyOffset(); i < meta.propertyCount(); ++i)

View File

@@ -7,6 +7,7 @@
#include "itemlibraryentry.h" #include "itemlibraryentry.h"
#include "itemlibraryimport.h" #include "itemlibraryimport.h"
#include "itemlibraryitem.h" #include "itemlibraryitem.h"
#include "itemlibrarytracing.h"
#include <designermcumanager.h> #include <designermcumanager.h>
#include <model.h> #include <model.h>
@@ -29,30 +30,41 @@
namespace QmlDesigner { namespace QmlDesigner {
static auto category = ItemLibraryTracing::category;
// sectionName can be an import url or a category name // sectionName can be an import url or a category name
void ItemLibraryModel::saveExpandedState(bool expanded, const QString &sectionName) void ItemLibraryModel::saveExpandedState(bool expanded, const QString &sectionName)
{ {
NanotraceHR::Tracer tracer{"item library model save expanded state", category()};
expandedStateHash.insert(sectionName, expanded); expandedStateHash.insert(sectionName, expanded);
} }
bool ItemLibraryModel::loadExpandedState(const QString &sectionName) bool ItemLibraryModel::loadExpandedState(const QString &sectionName)
{ {
NanotraceHR::Tracer tracer{"item library model load expanded state", category()};
return expandedStateHash.value(sectionName, true); return expandedStateHash.value(sectionName, true);
} }
void ItemLibraryModel::saveCategoryVisibleState(bool isVisible, const QString &categoryName, void ItemLibraryModel::saveCategoryVisibleState(bool isVisible, const QString &categoryName,
const QString &importName) const QString &importName)
{ {
NanotraceHR::Tracer tracer{"item library model save category visible state", category()};
categoryVisibleStateHash.insert(categoryName + '_' + importName, isVisible); categoryVisibleStateHash.insert(categoryName + '_' + importName, isVisible);
} }
bool ItemLibraryModel::loadCategoryVisibleState(const QString &categoryName, const QString &importName) bool ItemLibraryModel::loadCategoryVisibleState(const QString &categoryName, const QString &importName)
{ {
NanotraceHR::Tracer tracer{"item library model load category visible state", category()};
return categoryVisibleStateHash.value(categoryName + '_' + importName, true); return categoryVisibleStateHash.value(categoryName + '_' + importName, true);
} }
void ItemLibraryModel::selectImportCategory(const QString &importUrl, int categoryIndex) void ItemLibraryModel::selectImportCategory(const QString &importUrl, int categoryIndex)
{ {
NanotraceHR::Tracer tracer{"item library model select import category", category()};
clearSelectedCategory(); clearSelectedCategory();
m_selectedImportUrl = importUrl; m_selectedImportUrl = importUrl;
@@ -63,6 +75,8 @@ void ItemLibraryModel::selectImportCategory(const QString &importUrl, int catego
void ItemLibraryModel::clearSelectedCategory() void ItemLibraryModel::clearSelectedCategory()
{ {
NanotraceHR::Tracer tracer{"item library model clear selected category", category()};
if (m_selectedCategoryIndex != -1) { if (m_selectedCategoryIndex != -1) {
ItemLibraryImport *selectedImport = importByUrl(m_selectedImportUrl); ItemLibraryImport *selectedImport = importByUrl(m_selectedImportUrl);
if (selectedImport) if (selectedImport)
@@ -72,6 +86,8 @@ void ItemLibraryModel::clearSelectedCategory()
void ItemLibraryModel::selectImportFirstVisibleCategory() void ItemLibraryModel::selectImportFirstVisibleCategory()
{ {
NanotraceHR::Tracer tracer{"item library model select import first visible category", category()};
if (m_selectedCategoryIndex != -1) { if (m_selectedCategoryIndex != -1) {
ItemLibraryImport *selectedImport = importByUrl(m_selectedImportUrl); ItemLibraryImport *selectedImport = importByUrl(m_selectedImportUrl);
if (selectedImport) { if (selectedImport) {
@@ -110,11 +126,15 @@ void ItemLibraryModel::selectImportFirstVisibleCategory()
bool ItemLibraryModel::isAnyCategoryHidden() const bool ItemLibraryModel::isAnyCategoryHidden() const
{ {
NanotraceHR::Tracer tracer{"item library model is any category hidden", category()};
return m_isAnyCategoryHidden; return m_isAnyCategoryHidden;
} }
void ItemLibraryModel::setIsAnyCategoryHidden(bool state) void ItemLibraryModel::setIsAnyCategoryHidden(bool state)
{ {
NanotraceHR::Tracer tracer{"item library model set is any category hidden", category()};
if (state != m_isAnyCategoryHidden) { if (state != m_isAnyCategoryHidden) {
m_isAnyCategoryHidden = state; m_isAnyCategoryHidden = state;
emit isAnyCategoryHiddenChanged(); emit isAnyCategoryHiddenChanged();
@@ -123,11 +143,15 @@ void ItemLibraryModel::setIsAnyCategoryHidden(bool state)
bool ItemLibraryModel::importUnimportedSelected() const bool ItemLibraryModel::importUnimportedSelected() const
{ {
NanotraceHR::Tracer tracer{"item library model import unimported selected", category()};
return m_importUnimportedSelected; return m_importUnimportedSelected;
} }
void ItemLibraryModel::setImportUnimportedSelected(bool state) void ItemLibraryModel::setImportUnimportedSelected(bool state)
{ {
NanotraceHR::Tracer tracer{"item library model set import unimported selected", category()};
if (state != m_importUnimportedSelected) { if (state != m_importUnimportedSelected) {
m_importUnimportedSelected = state; m_importUnimportedSelected = state;
emit importUnimportedSelectedChanged(); emit importUnimportedSelectedChanged();
@@ -136,17 +160,23 @@ void ItemLibraryModel::setImportUnimportedSelected(bool state)
QObject *ItemLibraryModel::itemsModel() const QObject *ItemLibraryModel::itemsModel() const
{ {
NanotraceHR::Tracer tracer{"item library model items model", category()};
return m_itemsModel; return m_itemsModel;
} }
void ItemLibraryModel::setItemsModel(QObject *model) void ItemLibraryModel::setItemsModel(QObject *model)
{ {
NanotraceHR::Tracer tracer{"item library model set items model", category()};
m_itemsModel = model; m_itemsModel = model;
emit itemsModelChanged(); emit itemsModelChanged();
} }
void ItemLibraryModel::expandAll() void ItemLibraryModel::expandAll()
{ {
NanotraceHR::Tracer tracer{"item library model expand all", category()};
int i = 0; int i = 0;
for (const QPointer<ItemLibraryImport> &import : std::as_const(m_importList)) { for (const QPointer<ItemLibraryImport> &import : std::as_const(m_importList)) {
if (!import->importExpanded()) { if (!import->importExpanded()) {
@@ -161,6 +191,8 @@ void ItemLibraryModel::expandAll()
void ItemLibraryModel::collapseAll() void ItemLibraryModel::collapseAll()
{ {
NanotraceHR::Tracer tracer{"item library model collapse all", category()};
int i = 0; int i = 0;
for (const QPointer<ItemLibraryImport> &import : std::as_const(m_importList)) { for (const QPointer<ItemLibraryImport> &import : std::as_const(m_importList)) {
if (import->hasCategories() && import->importExpanded()) { if (import->hasCategories() && import->importExpanded()) {
@@ -174,6 +206,8 @@ void ItemLibraryModel::collapseAll()
void ItemLibraryModel::hideCategory(const QString &importUrl, const QString &categoryName) void ItemLibraryModel::hideCategory(const QString &importUrl, const QString &categoryName)
{ {
NanotraceHR::Tracer tracer{"item library model hide category", category()};
ItemLibraryImport *import = importByUrl(importUrl); ItemLibraryImport *import = importByUrl(importUrl);
if (!import) if (!import)
return; return;
@@ -186,6 +220,8 @@ void ItemLibraryModel::hideCategory(const QString &importUrl, const QString &cat
void ItemLibraryModel::showImportHiddenCategories(const QString &importUrl) void ItemLibraryModel::showImportHiddenCategories(const QString &importUrl)
{ {
NanotraceHR::Tracer tracer{"item library model show import hidden categories", category()};
ItemLibraryImport *targetImport = nullptr; ItemLibraryImport *targetImport = nullptr;
bool hiddenCatsExist = false; bool hiddenCatsExist = false;
for (const QPointer<ItemLibraryImport> &import : std::as_const(m_importList)) { for (const QPointer<ItemLibraryImport> &import : std::as_const(m_importList)) {
@@ -204,6 +240,8 @@ void ItemLibraryModel::showImportHiddenCategories(const QString &importUrl)
void ItemLibraryModel::showAllHiddenCategories() void ItemLibraryModel::showAllHiddenCategories()
{ {
NanotraceHR::Tracer tracer{"item library model show all hidden categories", category()};
for (const QPointer<ItemLibraryImport> &import : std::as_const(m_importList)) for (const QPointer<ItemLibraryImport> &import : std::as_const(m_importList))
import->showAllCategories(); import->showAllCategories();
@@ -214,27 +252,37 @@ void ItemLibraryModel::showAllHiddenCategories()
void ItemLibraryModel::setFlowMode(bool b) void ItemLibraryModel::setFlowMode(bool b)
{ {
NanotraceHR::Tracer tracer{"item library model set flow mode", category()};
m_flowMode = b; m_flowMode = b;
} }
ItemLibraryModel::ItemLibraryModel(QObject *parent) ItemLibraryModel::ItemLibraryModel(QObject *parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)
{ {
NanotraceHR::Tracer tracer{"item library model constructor", category()};
addRoleNames(); addRoleNames();
} }
ItemLibraryModel::~ItemLibraryModel() ItemLibraryModel::~ItemLibraryModel()
{ {
NanotraceHR::Tracer tracer{"item library model destructor", category()};
clearSections(); clearSections();
} }
int ItemLibraryModel::rowCount(const QModelIndex & /*parent*/) const int ItemLibraryModel::rowCount(const QModelIndex & /*parent*/) const
{ {
NanotraceHR::Tracer tracer{"item library model row count", category()};
return m_importList.size(); return m_importList.size();
} }
QVariant ItemLibraryModel::data(const QModelIndex &index, int role) const QVariant ItemLibraryModel::data(const QModelIndex &index, int role) const
{ {
NanotraceHR::Tracer tracer{"item library model data", category()};
if (!index.isValid() || index.row() >= m_importList.size()) if (!index.isValid() || index.row() >= m_importList.size())
return {}; return {};
@@ -255,6 +303,8 @@ QVariant ItemLibraryModel::data(const QModelIndex &index, int role) const
bool ItemLibraryModel::setData(const QModelIndex &index, const QVariant &value, int role) bool ItemLibraryModel::setData(const QModelIndex &index, const QVariant &value, int role)
{ {
NanotraceHR::Tracer tracer{"item library model set data", category()};
// currently only importExpanded property is updatable // currently only importExpanded property is updatable
if (index.isValid() && m_roleNames.contains(role)) { if (index.isValid() && m_roleNames.contains(role)) {
QVariant currValue = m_importList.at(index.row())->property(m_roleNames.value(role)); QVariant currValue = m_importList.at(index.row())->property(m_roleNames.value(role));
@@ -271,16 +321,22 @@ bool ItemLibraryModel::setData(const QModelIndex &index, const QVariant &value,
QHash<int, QByteArray> ItemLibraryModel::roleNames() const QHash<int, QByteArray> ItemLibraryModel::roleNames() const
{ {
NanotraceHR::Tracer tracer{"item library model role names", category()};
return m_roleNames; return m_roleNames;
} }
QString ItemLibraryModel::searchText() const QString ItemLibraryModel::searchText() const
{ {
NanotraceHR::Tracer tracer{"item library model search text", category()};
return m_searchText; return m_searchText;
} }
void ItemLibraryModel::setSearchText(const QString &searchText) void ItemLibraryModel::setSearchText(const QString &searchText)
{ {
NanotraceHR::Tracer tracer{"item library model set search text", category()};
QString lowerSearchText = searchText.toLower(); QString lowerSearchText = searchText.toLower();
if (m_searchText != lowerSearchText) { if (m_searchText != lowerSearchText) {
@@ -298,6 +354,8 @@ void ItemLibraryModel::setSearchText(const QString &searchText)
Import ItemLibraryModel::entryToImport(const ItemLibraryEntry &entry) Import ItemLibraryModel::entryToImport(const ItemLibraryEntry &entry)
{ {
NanotraceHR::Tracer tracer{"item library model entry to import", category()};
#ifndef QDS_USE_PROJECTSTORAGE #ifndef QDS_USE_PROJECTSTORAGE
if (entry.majorVersion() == -1 && entry.minorVersion() == -1) if (entry.majorVersion() == -1 && entry.minorVersion() == -1)
return Import::createFileImport(entry.requiredImport()); return Import::createFileImport(entry.requiredImport());
@@ -309,6 +367,8 @@ Import ItemLibraryModel::entryToImport(const ItemLibraryEntry &entry)
void ItemLibraryModel::update(Model *model) void ItemLibraryModel::update(Model *model)
{ {
NanotraceHR::Tracer tracer{"item library model update", category()};
if (!model) if (!model)
return; return;
@@ -489,6 +549,8 @@ void ItemLibraryModel::update(Model *model)
std::unique_ptr<QMimeData> ItemLibraryModel::getMimeData(const ItemLibraryEntry &itemLibraryEntry) std::unique_ptr<QMimeData> ItemLibraryModel::getMimeData(const ItemLibraryEntry &itemLibraryEntry)
{ {
NanotraceHR::Tracer tracer{"item library model get mime data", category()};
auto mimeData = std::make_unique<QMimeData>(); auto mimeData = std::make_unique<QMimeData>();
QByteArray data; QByteArray data;
@@ -503,12 +565,16 @@ std::unique_ptr<QMimeData> ItemLibraryModel::getMimeData(const ItemLibraryEntry
void ItemLibraryModel::clearSections() void ItemLibraryModel::clearSections()
{ {
NanotraceHR::Tracer tracer{"item library model clear sections", category()};
qDeleteAll(m_importList); qDeleteAll(m_importList);
m_importList.clear(); m_importList.clear();
} }
void ItemLibraryModel::updateSelection() void ItemLibraryModel::updateSelection()
{ {
NanotraceHR::Tracer tracer{"item library model update selection", category()};
if (m_selectedCategoryIndex != -1) { if (m_selectedCategoryIndex != -1) {
ItemLibraryImport *selectedImport = importByUrl(m_selectedImportUrl); ItemLibraryImport *selectedImport = importByUrl(m_selectedImportUrl);
if (selectedImport) { if (selectedImport) {
@@ -526,11 +592,15 @@ void ItemLibraryModel::updateSelection()
void ItemLibraryModel::registerQmlTypes() void ItemLibraryModel::registerQmlTypes()
{ {
NanotraceHR::Tracer tracer{"item library model register QML types", category()};
qmlRegisterAnonymousType<QmlDesigner::ItemLibraryModel>("ItemLibraryModel", 1); qmlRegisterAnonymousType<QmlDesigner::ItemLibraryModel>("ItemLibraryModel", 1);
} }
ItemLibraryImport *ItemLibraryModel::importByUrl(const QString &importUrl) const ItemLibraryImport *ItemLibraryModel::importByUrl(const QString &importUrl) const
{ {
NanotraceHR::Tracer tracer{"item library model import by URL", category()};
for (ItemLibraryImport *itemLibraryImport : std::as_const(m_importList)) { for (ItemLibraryImport *itemLibraryImport : std::as_const(m_importList)) {
if (itemLibraryImport->importUrl() == importUrl if (itemLibraryImport->importUrl() == importUrl
|| (importUrl.isEmpty() && itemLibraryImport->importUrl() == "QtQuick") || (importUrl.isEmpty() && itemLibraryImport->importUrl() == "QtQuick")
@@ -547,6 +617,8 @@ ItemLibraryImport *ItemLibraryModel::importByUrl(const QString &importUrl) const
void ItemLibraryModel::updateUsedImports(const Imports &usedImports) void ItemLibraryModel::updateUsedImports(const Imports &usedImports)
{ {
NanotraceHR::Tracer tracer{"item library model update used imports", category()};
// imports in the excludeList are not marked used and thus can always be removed even when in use. // imports in the excludeList are not marked used and thus can always be removed even when in use.
const QList<QString> excludeList = {"SimulinkConnector"}; const QList<QString> excludeList = {"SimulinkConnector"};
@@ -558,6 +630,8 @@ void ItemLibraryModel::updateUsedImports(const Imports &usedImports)
void ItemLibraryModel::updateVisibility(bool *changed) void ItemLibraryModel::updateVisibility(bool *changed)
{ {
NanotraceHR::Tracer tracer{"item library model update visibility", category()};
for (ItemLibraryImport *import : std::as_const(m_importList)) { for (ItemLibraryImport *import : std::as_const(m_importList)) {
bool categoryChanged = false; bool categoryChanged = false;
bool hasVisibleItems = import->updateCategoryVisibility(m_searchText, &categoryChanged); bool hasVisibleItems = import->updateCategoryVisibility(m_searchText, &categoryChanged);
@@ -574,6 +648,8 @@ void ItemLibraryModel::updateVisibility(bool *changed)
void ItemLibraryModel::addRoleNames() void ItemLibraryModel::addRoleNames()
{ {
NanotraceHR::Tracer tracer{"item library model add role names", category()};
int role = 0; int role = 0;
const QMetaObject meta = ItemLibraryImport::staticMetaObject; const QMetaObject meta = ItemLibraryImport::staticMetaObject;
for (int i = meta.propertyOffset(); i < meta.propertyCount(); ++i) for (int i = meta.propertyOffset(); i < meta.propertyCount(); ++i)
@@ -582,6 +658,8 @@ void ItemLibraryModel::addRoleNames()
void ItemLibraryModel::sortSections() void ItemLibraryModel::sortSections()
{ {
NanotraceHR::Tracer tracer{"item library model sort sections", category()};
auto sectionSort = [](ItemLibraryImport *first, ItemLibraryImport *second) { auto sectionSort = [](ItemLibraryImport *first, ItemLibraryImport *second) {
return QString::localeAwareCompare(first->sortingName(), second->sortingName()) < 0; return QString::localeAwareCompare(first->sortingName(), second->sortingName()) < 0;
}; };

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "itemlibrarytracing.h"
#include <tracing/qmldesignertracing.h>
#include <sqlitebasestatement.h>
namespace QmlDesigner::ItemLibraryTracing {
using namespace NanotraceHR::Literals;
namespace {
thread_local Category category_{"model",
Tracing::eventQueueWithStringArguments(),
Tracing::eventQueueWithoutArguments(),
category};
} // namespace
Category &category()
{
return category_;
}
} // namespace QmlDesigner::ItemLibraryTracing

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <qmldesignercomponents_global.h>
#include <nanotrace/nanotracehr.h>
#pragma once
namespace QmlDesigner::ItemLibraryTracing {
constexpr NanotraceHR::Tracing tracingStatus()
{
#ifdef ENABLE_ITEM_LIBRARY_TRACING
return NanotraceHR::Tracing::IsEnabled;
#else
return NanotraceHR::Tracing::IsDisabled;
#endif
}
using Category = NanotraceHR::StringViewWithStringArgumentsCategory<tracingStatus()>;
using SourceLocation = Category::SourceLocation;
[[gnu::pure]] QMLDESIGNERCOMPONENTS_EXPORT Category &category();
} // namespace QmlDesigner::ItemLibraryTracing

View File

@@ -2,14 +2,16 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "itemlibraryview.h" #include "itemlibraryview.h"
#include "itemlibrarytracing.h"
#include "itemlibrarywidget.h" #include "itemlibrarywidget.h"
#include "metainfo.h"
#include <asynchronousimagecache.h> #include <asynchronousimagecache.h>
#include <bindingproperty.h> #include <bindingproperty.h>
#include <componentcore_constants.h> #include <componentcore_constants.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <customnotifications.h> #include <customnotifications.h>
#include <import.h> #include <import.h>
#include <metainfo.h>
#include <nodelistproperty.h> #include <nodelistproperty.h>
#include <projectexplorer/kit.h> #include <projectexplorer/kit.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
@@ -24,23 +26,32 @@
namespace QmlDesigner { namespace QmlDesigner {
static auto category = ItemLibraryTracing::category;
ItemLibraryView::ItemLibraryView(AsynchronousImageCache &imageCache, ItemLibraryView::ItemLibraryView(AsynchronousImageCache &imageCache,
ExternalDependenciesInterface &externalDependencies) ExternalDependenciesInterface &externalDependencies)
: AbstractView(externalDependencies) : AbstractView(externalDependencies)
, m_imageCache(imageCache) , m_imageCache(imageCache)
{} {
NanotraceHR::Tracer tracer{"item library view constructor", category()};
}
ItemLibraryView::~ItemLibraryView() ItemLibraryView::~ItemLibraryView()
{ {
NanotraceHR::Tracer tracer{"item library view destructor", category()};
} }
bool ItemLibraryView::hasWidget() const bool ItemLibraryView::hasWidget() const
{ {
NanotraceHR::Tracer tracer{"item library view has widget", category()};
return true; return true;
} }
WidgetInfo ItemLibraryView::widgetInfo() WidgetInfo ItemLibraryView::widgetInfo()
{ {
NanotraceHR::Tracer tracer{"item library view widget info", category()};
if (m_widget.isNull()) if (m_widget.isNull())
m_widget = new ItemLibraryWidget{m_imageCache}; m_widget = new ItemLibraryWidget{m_imageCache};
@@ -53,6 +64,8 @@ WidgetInfo ItemLibraryView::widgetInfo()
void ItemLibraryView::modelAttached(Model *model) void ItemLibraryView::modelAttached(Model *model)
{ {
NanotraceHR::Tracer tracer{"item library view model attached", category()};
AbstractView::modelAttached(model); AbstractView::modelAttached(model);
m_widget->clearSearchFilter(); m_widget->clearSearchFilter();
@@ -67,6 +80,8 @@ void ItemLibraryView::modelAttached(Model *model)
void ItemLibraryView::modelAboutToBeDetached(Model *model) void ItemLibraryView::modelAboutToBeDetached(Model *model)
{ {
NanotraceHR::Tracer tracer{"item library view model about to be detached", category()};
AbstractView::modelAboutToBeDetached(model); AbstractView::modelAboutToBeDetached(model);
m_widget->setModel(nullptr); m_widget->setModel(nullptr);
@@ -74,22 +89,30 @@ void ItemLibraryView::modelAboutToBeDetached(Model *model)
void ItemLibraryView::importsChanged(const Imports &, const Imports &) void ItemLibraryView::importsChanged(const Imports &, const Imports &)
{ {
NanotraceHR::Tracer tracer{"item library view imports changed", category()};
updateImports(); updateImports();
m_widget->updatePossibleImports(model()->possibleImports()); m_widget->updatePossibleImports(model()->possibleImports());
} }
void ItemLibraryView::possibleImportsChanged(const Imports &possibleImports) void ItemLibraryView::possibleImportsChanged(const Imports &possibleImports)
{ {
NanotraceHR::Tracer tracer{"item library view possible imports changed", category()};
m_widget->updatePossibleImports(possibleImports); m_widget->updatePossibleImports(possibleImports);
} }
void ItemLibraryView::usedImportsChanged(const Imports &usedImports) void ItemLibraryView::usedImportsChanged(const Imports &usedImports)
{ {
NanotraceHR::Tracer tracer{"item library view used imports changed", category()};
m_widget->updateUsedImports(usedImports); m_widget->updateUsedImports(usedImports);
} }
void ItemLibraryView::documentMessagesChanged(const QList<DocumentMessage> &errors, const QList<DocumentMessage> &) void ItemLibraryView::documentMessagesChanged(const QList<DocumentMessage> &errors, const QList<DocumentMessage> &)
{ {
NanotraceHR::Tracer tracer{"item library view document messages changed", category()};
if (m_hasErrors && errors.isEmpty()) if (m_hasErrors && errors.isEmpty())
updateImports(); updateImports();
@@ -98,6 +121,8 @@ void ItemLibraryView::documentMessagesChanged(const QList<DocumentMessage> &erro
void ItemLibraryView::updateImports() void ItemLibraryView::updateImports()
{ {
NanotraceHR::Tracer tracer{"item library view update imports", category()};
m_widget->delayedUpdateModel(); m_widget->delayedUpdateModel();
} }
@@ -106,6 +131,8 @@ void ItemLibraryView::customNotification(const AbstractView *view,
const QList<ModelNode> &nodeList, const QList<ModelNode> &nodeList,
const QList<QVariant> &data) const QList<QVariant> &data)
{ {
NanotraceHR::Tracer tracer{"item library view custom notification", category()};
if (identifier == UpdateItemlibrary) if (identifier == UpdateItemlibrary)
updateImports(); updateImports();
else else

View File

@@ -6,16 +6,17 @@
#include "itemlibraryconstants.h" #include "itemlibraryconstants.h"
#include "itemlibraryiconimageprovider.h" #include "itemlibraryiconimageprovider.h"
#include "itemlibraryimport.h" #include "itemlibraryimport.h"
#include "itemlibrarytracing.h"
#include <theme.h> #include <theme.h>
#include "modelnodeoperations.h"
#include <designeractionmanager.h> #include <designeractionmanager.h>
#include <designermcumanager.h> #include <designermcumanager.h>
#include <documentmanager.h> #include <documentmanager.h>
#include <itemlibraryaddimportmodel.h> #include <itemlibraryaddimportmodel.h>
#include <itemlibraryentry.h> #include <itemlibraryentry.h>
#include <itemlibraryimageprovider.h> #include <itemlibraryimageprovider.h>
#include <modelnodeoperations.h>
#ifndef QDS_USE_PROJECTSTORAGE #ifndef QDS_USE_PROJECTSTORAGE
# include <itemlibraryinfo.h> # include <itemlibraryinfo.h>
#endif #endif
@@ -65,6 +66,8 @@
namespace QmlDesigner { namespace QmlDesigner {
static auto category = ItemLibraryTracing::category;
static QString propertyEditorResourcesPath() static QString propertyEditorResourcesPath()
{ {
#ifdef SHARE_QML_PATH #ifdef SHARE_QML_PATH
@@ -76,6 +79,8 @@ static QString propertyEditorResourcesPath()
bool ItemLibraryWidget::eventFilter(QObject *obj, QEvent *event) bool ItemLibraryWidget::eventFilter(QObject *obj, QEvent *event)
{ {
NanotraceHR::Tracer tracer{"item library widget event filter", category()};
auto document = QmlDesignerPlugin::instance()->currentDesignDocument(); auto document = QmlDesignerPlugin::instance()->currentDesignDocument();
Model *model = document ? document->documentModel() : nullptr; Model *model = document ? document->documentModel() : nullptr;
@@ -123,6 +128,8 @@ bool ItemLibraryWidget::eventFilter(QObject *obj, QEvent *event)
void ItemLibraryWidget::resizeEvent(QResizeEvent *event) void ItemLibraryWidget::resizeEvent(QResizeEvent *event)
{ {
NanotraceHR::Tracer tracer{"item library widget resize event", category()};
isHorizontalLayout = event->size().width() >= HORIZONTAL_LAYOUT_WIDTH_LIMIT; isHorizontalLayout = event->size().width() >= HORIZONTAL_LAYOUT_WIDTH_LIMIT;
} }
@@ -133,6 +140,8 @@ ItemLibraryWidget::ItemLibraryWidget(AsynchronousImageCache &imageCache)
, m_itemsWidget(Utils::makeUniqueObjectPtr<StudioQuickWidget>()) , m_itemsWidget(Utils::makeUniqueObjectPtr<StudioQuickWidget>())
, m_imageCache{imageCache} , m_imageCache{imageCache}
{ {
NanotraceHR::Tracer tracer{"item library widget constructor", category()};
m_compressionTimer.setInterval(1000); m_compressionTimer.setInterval(1000);
m_compressionTimer.setSingleShot(true); m_compressionTimer.setSingleShot(true);
ItemLibraryModel::registerQmlTypes(); ItemLibraryModel::registerQmlTypes();
@@ -149,7 +158,7 @@ ItemLibraryWidget::ItemLibraryWidget(AsynchronousImageCache &imageCache)
m_itemsWidget->setClearColor(Theme::getColor(Theme::Color::DSpanelBackground)); m_itemsWidget->setClearColor(Theme::getColor(Theme::Color::DSpanelBackground));
m_itemsWidget->engine()->addImageProvider(QStringLiteral("qmldesigner_itemlibrary"), m_itemsWidget->engine()->addImageProvider(QStringLiteral("qmldesigner_itemlibrary"),
new Internal::ItemLibraryImageProvider); new Internal::ItemLibraryImageProvider);
Theme::setupTheme(m_itemsWidget->engine()); Theme::setupTheme(m_itemsWidget->engine());
m_itemsWidget->quickWidget()->installEventFilter(this); m_itemsWidget->quickWidget()->installEventFilter(this);
@@ -169,7 +178,7 @@ ItemLibraryWidget::ItemLibraryWidget(AsynchronousImageCache &imageCache)
connect(&m_compressionTimer, &QTimer::timeout, this, &ItemLibraryWidget::updateModel); connect(&m_compressionTimer, &QTimer::timeout, this, &ItemLibraryWidget::updateModel);
m_itemsWidget->engine()->addImageProvider("itemlibrary_preview", m_itemsWidget->engine()->addImageProvider("itemlibrary_preview",
new ItemLibraryIconImageProvider{m_imageCache}); new ItemLibraryIconImageProvider{m_imageCache});
QmlDesignerPlugin::trackWidgetFocusTime(this, Constants::EVENT_ITEMLIBRARY_TIME); QmlDesignerPlugin::trackWidgetFocusTime(this, Constants::EVENT_ITEMLIBRARY_TIME);
@@ -189,7 +198,10 @@ ItemLibraryWidget::ItemLibraryWidget(AsynchronousImageCache &imageCache)
reloadQmlSource(); reloadQmlSource();
} }
ItemLibraryWidget::~ItemLibraryWidget() = default; ItemLibraryWidget::~ItemLibraryWidget()
{
NanotraceHR::Tracer tracer{"item library widget destructor", category()};
}
#ifndef QDS_USE_PROJECTSTORAGE #ifndef QDS_USE_PROJECTSTORAGE
void ItemLibraryWidget::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo) void ItemLibraryWidget::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo)
@@ -212,12 +224,16 @@ void ItemLibraryWidget::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo)
QList<QToolButton *> ItemLibraryWidget::createToolBarWidgets() QList<QToolButton *> ItemLibraryWidget::createToolBarWidgets()
{ {
NanotraceHR::Tracer tracer{"item library widget create toolbar widgets", category()};
return {}; return {};
} }
void ItemLibraryWidget::handleSearchFilterChanged(const QString &filterText) void ItemLibraryWidget::handleSearchFilterChanged(const QString &filterText)
{ {
NanotraceHR::Tracer tracer{"item library widget handle search filter changed", category()};
if (filterText != m_filterText) { if (filterText != m_filterText) {
m_filterText = filterText; m_filterText = filterText;
updateSearch(); updateSearch();
@@ -226,6 +242,8 @@ void ItemLibraryWidget::handleSearchFilterChanged(const QString &filterText)
QString ItemLibraryWidget::getDependencyImport(const Import &import) QString ItemLibraryWidget::getDependencyImport(const Import &import)
{ {
NanotraceHR::Tracer tracer{"item library widget get dependency import", category()};
static QStringList prefixDependencies = {"QtQuick3D"}; static QStringList prefixDependencies = {"QtQuick3D"};
const QStringList splitImport = import.url().split('.'); const QStringList splitImport = import.url().split('.');
@@ -240,6 +258,8 @@ QString ItemLibraryWidget::getDependencyImport(const Import &import)
void ItemLibraryWidget::handleAddImport(int index) void ItemLibraryWidget::handleAddImport(int index)
{ {
NanotraceHR::Tracer tracer{"item library widget handle add import", category()};
Import import = m_addModuleModel->getImportAt(index); Import import = m_addModuleModel->getImportAt(index);
if (import.isLibraryImport() && (import.url().startsWith("QtQuick") if (import.isLibraryImport() && (import.url().startsWith("QtQuick")
|| import.url().startsWith("SimulinkConnector"))) { || import.url().startsWith("SimulinkConnector"))) {
@@ -273,12 +293,18 @@ void ItemLibraryWidget::handleAddImport(int index)
void ItemLibraryWidget::goIntoComponent(const QString &source) void ItemLibraryWidget::goIntoComponent(const QString &source)
{ {
NanotraceHR::Tracer tracer{"item library widget go into component", category()};
DocumentManager::goIntoComponent(source); DocumentManager::goIntoComponent(source);
} }
void ItemLibraryWidget::delayedUpdateModel() void ItemLibraryWidget::delayedUpdateModel()
{ {
static bool disableTimer = QmlDesignerPlugin::settings().value(DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER).toBool(); NanotraceHR::Tracer tracer{"item library widget delayed update model", category()};
static bool disableTimer = QmlDesignerPlugin::settings()
.value(DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER)
.toBool();
if (disableTimer) if (disableTimer)
updateModel(); updateModel();
else else
@@ -287,6 +313,8 @@ void ItemLibraryWidget::delayedUpdateModel()
void ItemLibraryWidget::setModel(Model *model) void ItemLibraryWidget::setModel(Model *model)
{ {
NanotraceHR::Tracer tracer{"item library widget set model", category()};
m_model = model; m_model = model;
if (!model) { if (!model) {
m_itemToDrag = {}; m_itemToDrag = {};
@@ -310,6 +338,8 @@ void ItemLibraryWidget::setModel(Model *model)
QString ItemLibraryWidget::qmlSourcesPath() QString ItemLibraryWidget::qmlSourcesPath()
{ {
NanotraceHR::Tracer tracer{"item library widget qml sources path", category()};
#ifdef SHARE_QML_PATH #ifdef SHARE_QML_PATH
if (::Utils::qtcEnvironmentVariableIsSet("LOAD_QML_FROM_SOURCE")) if (::Utils::qtcEnvironmentVariableIsSet("LOAD_QML_FROM_SOURCE"))
return QLatin1String(SHARE_QML_PATH) + "/itemLibraryQmlSources"; return QLatin1String(SHARE_QML_PATH) + "/itemLibraryQmlSources";
@@ -319,16 +349,22 @@ QString ItemLibraryWidget::qmlSourcesPath()
void ItemLibraryWidget::clearSearchFilter() void ItemLibraryWidget::clearSearchFilter()
{ {
NanotraceHR::Tracer tracer{"item library widget clear search filter", category()};
QMetaObject::invokeMethod(m_itemsWidget->rootObject(), "clearSearchFilter"); QMetaObject::invokeMethod(m_itemsWidget->rootObject(), "clearSearchFilter");
} }
void ItemLibraryWidget::switchToComponentsView() void ItemLibraryWidget::switchToComponentsView()
{ {
NanotraceHR::Tracer tracer{"item library widget switch to components view", category()};
QMetaObject::invokeMethod(m_itemsWidget->rootObject(), "switchToComponentsView"); QMetaObject::invokeMethod(m_itemsWidget->rootObject(), "switchToComponentsView");
} }
void ItemLibraryWidget::reloadQmlSource() void ItemLibraryWidget::reloadQmlSource()
{ {
NanotraceHR::Tracer tracer{"item library widget reload qml source", category()};
const QString itemLibraryQmlPath = qmlSourcesPath() + "/ItemsView.qml"; const QString itemLibraryQmlPath = qmlSourcesPath() + "/ItemsView.qml";
QTC_ASSERT(QFileInfo::exists(itemLibraryQmlPath), return); QTC_ASSERT(QFileInfo::exists(itemLibraryQmlPath), return);
m_itemsWidget->setSource(QUrl::fromLocalFile(itemLibraryQmlPath)); m_itemsWidget->setSource(QUrl::fromLocalFile(itemLibraryQmlPath));
@@ -336,6 +372,8 @@ void ItemLibraryWidget::reloadQmlSource()
void ItemLibraryWidget::updateModel() void ItemLibraryWidget::updateModel()
{ {
NanotraceHR::Tracer tracer{"item library widget update model", category()};
QTC_ASSERT(m_itemLibraryModel, return); QTC_ASSERT(m_itemLibraryModel, return);
if (m_compressionTimer.isActive()) { if (m_compressionTimer.isActive()) {
@@ -356,17 +394,23 @@ void ItemLibraryWidget::updateModel()
void ItemLibraryWidget::updatePossibleImports(const Imports &possibleImports) void ItemLibraryWidget::updatePossibleImports(const Imports &possibleImports)
{ {
NanotraceHR::Tracer tracer{"item library widget update possible imports", category()};
m_addModuleModel->update(set_difference(possibleImports, m_model->imports())); m_addModuleModel->update(set_difference(possibleImports, m_model->imports()));
delayedUpdateModel(); delayedUpdateModel();
} }
void ItemLibraryWidget::updateUsedImports(const Imports &usedImports) void ItemLibraryWidget::updateUsedImports(const Imports &usedImports)
{ {
NanotraceHR::Tracer tracer{"item library widget update used imports", category()};
m_itemLibraryModel->updateUsedImports(usedImports); m_itemLibraryModel->updateUsedImports(usedImports);
} }
void ItemLibraryWidget::updateSearch() void ItemLibraryWidget::updateSearch()
{ {
NanotraceHR::Tracer tracer{"item library widget update search", category()};
m_itemLibraryModel->setSearchText(m_filterText); m_itemLibraryModel->setSearchText(m_filterText);
m_itemsWidget->update(); m_itemsWidget->update();
m_addModuleModel->setSearchText(m_filterText); m_addModuleModel->setSearchText(m_filterText);
@@ -374,6 +418,8 @@ void ItemLibraryWidget::updateSearch()
void ItemLibraryWidget::setIsDragging(bool val) void ItemLibraryWidget::setIsDragging(bool val)
{ {
NanotraceHR::Tracer tracer{"item library widget set is dragging", category()};
if (m_isDragging != val) { if (m_isDragging != val) {
m_isDragging = val; m_isDragging = val;
emit isDraggingChanged(); emit isDraggingChanged();
@@ -382,6 +428,8 @@ void ItemLibraryWidget::setIsDragging(bool val)
void ItemLibraryWidget::startDragAndDrop(const QVariant &itemLibEntry, const QPointF &mousePos) void ItemLibraryWidget::startDragAndDrop(const QVariant &itemLibEntry, const QPointF &mousePos)
{ {
NanotraceHR::Tracer tracer{"item library widget start drag and drop", category()};
// Actual drag is created after mouse has moved to avoid a QDrag bug that causes drag to stay // Actual drag is created after mouse has moved to avoid a QDrag bug that causes drag to stay
// active (and blocks mouse release) if mouse is released at the same spot of the drag start. // active (and blocks mouse release) if mouse is released at the same spot of the drag start.
m_itemToDrag = itemLibEntry; m_itemToDrag = itemLibEntry;
@@ -391,16 +439,22 @@ void ItemLibraryWidget::startDragAndDrop(const QVariant &itemLibEntry, const QPo
bool ItemLibraryWidget::subCompEditMode() const bool ItemLibraryWidget::subCompEditMode() const
{ {
NanotraceHR::Tracer tracer{"item library widget sub component edit mode", category()};
return m_subCompEditMode; return m_subCompEditMode;
} }
void ItemLibraryWidget::setFlowMode(bool b) void ItemLibraryWidget::setFlowMode(bool b)
{ {
NanotraceHR::Tracer tracer{"item library widget set flow mode", category()};
m_itemLibraryModel->setFlowMode(b); m_itemLibraryModel->setFlowMode(b);
} }
void ItemLibraryWidget::removeImport(const QString &importUrl) void ItemLibraryWidget::removeImport(const QString &importUrl)
{ {
NanotraceHR::Tracer tracer{"item library widget remove import", category()};
QTC_ASSERT(m_model, return); QTC_ASSERT(m_model, return);
ItemLibraryImport *importSection = m_itemLibraryModel->importByUrl(importUrl); ItemLibraryImport *importSection = m_itemLibraryModel->importByUrl(importUrl);
@@ -412,6 +466,8 @@ void ItemLibraryWidget::removeImport(const QString &importUrl)
void ItemLibraryWidget::addImportForItem(const QString &importUrl) void ItemLibraryWidget::addImportForItem(const QString &importUrl)
{ {
NanotraceHR::Tracer tracer{"item library widget add import for item", category()};
QTC_ASSERT(m_itemLibraryModel, return); QTC_ASSERT(m_itemLibraryModel, return);
QTC_ASSERT(m_model, return); QTC_ASSERT(m_model, return);

View File

@@ -49,7 +49,7 @@ extend_qtc_library(QmlDesignerCore
) )
extend_qtc_library(QmlDesignerCore extend_qtc_library(QmlDesignerCore
CONDITION ENABLE_PROJECT_STORAGE_TRACING OR ENABLE_SOURCE_PATH_STORAGE_TRACING OR ENABLE_IMAGE_CACHE_TRACING OR ENABLE_MODEL_TRACING OR ENABLE_FORM_EDITOR_TRACING OR ENABLE_PROPERTY_EDITOR_TRACING OR ENABLE_NAVIGATOR_TRACING CONDITION ENABLE_PROJECT_STORAGE_TRACING OR ENABLE_SOURCE_PATH_STORAGE_TRACING OR ENABLE_IMAGE_CACHE_TRACING OR ENABLE_MODEL_TRACING OR ENABLE_FORM_EDITOR_TRACING OR ENABLE_PROPERTY_EDITOR_TRACING OR ENABLE_NAVIGATOR_TRACING OR ENABLE_ITEM_LIBRARY_TRACING
PUBLIC_DEPENDS Nanotrace PUBLIC_DEPENDS Nanotrace
PUBLIC_DEFINES PUBLIC_DEFINES
ENABLE_QMLDESIGNER_TRACING ENABLE_QMLDESIGNER_TRACING