forked from qt-creator/qt-creator
QmlDesigner: Extend tracing points to the views
Task-number: QDS-15148 Change-Id: I54ac7f8e63dd2fa2bc32e22a0b1bff09ca817a7e Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
committed by
hancerliqt
parent
98f0c59dd1
commit
a9dae5ea7a
@@ -58,6 +58,10 @@ struct TracerLiteral
|
|||||||
: text{text}
|
: text{text}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
consteval TracerLiteral(const char *text)
|
||||||
|
: text{text}
|
||||||
|
{}
|
||||||
|
|
||||||
template<std::size_t size>
|
template<std::size_t size>
|
||||||
consteval TracerLiteral(const char (&text)[size])
|
consteval TracerLiteral(const char (&text)[size])
|
||||||
: text{text}
|
: text{text}
|
||||||
|
@@ -67,9 +67,11 @@ public:
|
|||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(PropertyChangeFlags, PropertyChangeFlag)
|
Q_DECLARE_FLAGS(PropertyChangeFlags, PropertyChangeFlag)
|
||||||
|
|
||||||
AbstractView(ExternalDependenciesInterface &externalDependencies)
|
AbstractView(ExternalDependenciesInterface &externalDependencies,
|
||||||
|
NanotraceHR::TracerLiteral functionName = __builtin_FUNCTION())
|
||||||
: m_externalDependencies{externalDependencies}
|
: m_externalDependencies{externalDependencies}
|
||||||
, m_action{Utils::makeUniqueObjectPtr<AbstractViewAction>(*this)}
|
, m_action{Utils::makeUniqueObjectPtr<AbstractViewAction>(*this)}
|
||||||
|
, m_name(functionName)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void setWidgetRegistration(WidgetRegistrationInterface *interface);
|
void setWidgetRegistration(WidgetRegistrationInterface *interface);
|
||||||
@@ -287,6 +289,14 @@ public:
|
|||||||
AbstractView *m_view;
|
AbstractView *m_view;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename String>
|
||||||
|
friend void convertToString(String &string, const AbstractView *view)
|
||||||
|
{
|
||||||
|
convertToString(string, view->m_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto &name() const { return m_name; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setModel(Model *model);
|
void setModel(Model *model);
|
||||||
void removeModel();
|
void removeModel();
|
||||||
@@ -310,6 +320,8 @@ private:
|
|||||||
bool m_isBlockingNotifications = false;
|
bool m_isBlockingNotifications = false;
|
||||||
Kind m_kind = Kind::Other;
|
Kind m_kind = Kind::Other;
|
||||||
WidgetRegistrationInterface *m_widgetRegistration = nullptr;
|
WidgetRegistrationInterface *m_widgetRegistration = nullptr;
|
||||||
|
|
||||||
|
NanotraceHR::TracerLiteral m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
QMLDESIGNERCORE_EXPORT QList<ModelNode> toModelNodeList(
|
QMLDESIGNERCORE_EXPORT QList<ModelNode> toModelNodeList(
|
||||||
|
@@ -546,15 +546,16 @@ bool ModelPrivate::propertyNameIsValid(PropertyNameView propertyName)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Callable>
|
void ModelPrivate::notifyNodeInstanceViewLast(const std::invocable<AbstractView *> auto &call)
|
||||||
void ModelPrivate::notifyNodeInstanceViewLast(Callable call)
|
|
||||||
{
|
{
|
||||||
bool resetModel = false;
|
bool resetModel = false;
|
||||||
QString description;
|
QString description;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (m_rewriterView && !m_rewriterView->isBlockingNotifications())
|
if (m_rewriterView && !m_rewriterView->isBlockingNotifications()) {
|
||||||
|
NanotraceHR::Tracer tracer{m_rewriterView->name(), ModelTracing::category()};
|
||||||
call(m_rewriterView);
|
call(m_rewriterView);
|
||||||
|
}
|
||||||
} catch (const RewritingException &e) {
|
} catch (const RewritingException &e) {
|
||||||
description = e.description();
|
description = e.description();
|
||||||
resetModel = true;
|
resetModel = true;
|
||||||
@@ -562,52 +563,62 @@ void ModelPrivate::notifyNodeInstanceViewLast(Callable call)
|
|||||||
|
|
||||||
for (const QPointer<AbstractView> &view : std::as_const(m_viewList)) {
|
for (const QPointer<AbstractView> &view : std::as_const(m_viewList)) {
|
||||||
try {
|
try {
|
||||||
if (!view->isBlockingNotifications())
|
if (!view->isBlockingNotifications()) {
|
||||||
|
NanotraceHR::Tracer tracer{view->name(), ModelTracing::category()};
|
||||||
call(view.data());
|
call(view.data());
|
||||||
|
}
|
||||||
} catch (const Exception &e) {
|
} catch (const Exception &e) {
|
||||||
e.showException(tr("Exception thrown by view %1.").arg(view->widgetInfo().tabName));
|
e.showException(tr("Exception thrown by view %1.").arg(view->widgetInfo().tabName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeInstanceView() && !nodeInstanceView()->isBlockingNotifications())
|
if (m_nodeInstanceView && !m_nodeInstanceView->isBlockingNotifications()) {
|
||||||
call(nodeInstanceView());
|
NanotraceHR::Tracer tracer{m_nodeInstanceView->name(), ModelTracing::category()};
|
||||||
|
call(m_nodeInstanceView);
|
||||||
|
}
|
||||||
|
|
||||||
if (resetModel)
|
if (resetModel)
|
||||||
resetModelByRewriter(description);
|
resetModelByRewriter(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Callable>
|
void ModelPrivate::notifyNormalViewsLast(const std::invocable<AbstractView *> auto &call)
|
||||||
void ModelPrivate::notifyNormalViewsLast(Callable call)
|
|
||||||
{
|
{
|
||||||
bool resetModel = false;
|
bool resetModel = false;
|
||||||
QString description;
|
QString description;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (m_rewriterView && !m_rewriterView->isBlockingNotifications())
|
if (m_rewriterView && !m_rewriterView->isBlockingNotifications()) {
|
||||||
|
NanotraceHR::Tracer tracer{m_rewriterView->name(), ModelTracing::category()};
|
||||||
call(m_rewriterView);
|
call(m_rewriterView);
|
||||||
|
}
|
||||||
} catch (const RewritingException &e) {
|
} catch (const RewritingException &e) {
|
||||||
description = e.description();
|
description = e.description();
|
||||||
resetModel = true;
|
resetModel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeInstanceView() && !nodeInstanceView()->isBlockingNotifications())
|
if (m_nodeInstanceView && !m_nodeInstanceView->isBlockingNotifications()) {
|
||||||
call(nodeInstanceView());
|
NanotraceHR::Tracer tracer{m_nodeInstanceView->name(), ModelTracing::category()};
|
||||||
|
call(m_nodeInstanceView);
|
||||||
|
}
|
||||||
|
|
||||||
for (const QPointer<AbstractView> &view : std::as_const(m_viewList)) {
|
for (const QPointer<AbstractView> &view : std::as_const(m_viewList)) {
|
||||||
if (!view->isBlockingNotifications())
|
if (!view->isBlockingNotifications()) {
|
||||||
|
NanotraceHR::Tracer tracer{view->name(), ModelTracing::category()};
|
||||||
call(view.data());
|
call(view.data());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resetModel)
|
if (resetModel)
|
||||||
resetModelByRewriter(description);
|
resetModelByRewriter(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Callable>
|
void ModelPrivate::notifyInstanceChanges(const std::invocable<AbstractView *> auto &call)
|
||||||
void ModelPrivate::notifyInstanceChanges(Callable call)
|
|
||||||
{
|
{
|
||||||
for (const QPointer<AbstractView> &view : std::as_const(m_viewList)) {
|
for (const QPointer<AbstractView> &view : std::as_const(m_viewList)) {
|
||||||
if (!view->isBlockingNotifications())
|
if (!view->isBlockingNotifications()) {
|
||||||
|
NanotraceHR::Tracer tracer{view->name(), ModelTracing::category()};
|
||||||
call(view.data());
|
call(view.data());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,6 +626,7 @@ void ModelPrivate::notifyAuxiliaryDataChanged(const InternalNodePointer &node,
|
|||||||
AuxiliaryDataKeyView key,
|
AuxiliaryDataKeyView key,
|
||||||
const QVariant &data)
|
const QVariant &data)
|
||||||
{
|
{
|
||||||
|
NanotraceHR::Tracer tracer{"notify auxiliary data changed", ModelTracing::category()};
|
||||||
notifyNodeInstanceViewLast([&](AbstractView *view) {
|
notifyNodeInstanceViewLast([&](AbstractView *view) {
|
||||||
ModelNode modelNode(node, m_model, view);
|
ModelNode modelNode(node, m_model, view);
|
||||||
view->auxiliaryDataChanged(modelNode, key, data);
|
view->auxiliaryDataChanged(modelNode, key, data);
|
||||||
@@ -809,8 +821,10 @@ void ModelPrivate::notifyCustomNotification(const AbstractView *senderView,
|
|||||||
void ModelPrivate::notifyCustomNotificationTo(AbstractView *view,
|
void ModelPrivate::notifyCustomNotificationTo(AbstractView *view,
|
||||||
const CustomNotificationPackage &package)
|
const CustomNotificationPackage &package)
|
||||||
{
|
{
|
||||||
if (view)
|
if (view) {
|
||||||
|
NanotraceHR::Tracer tracer{view->name(), ModelTracing::category()};
|
||||||
view->customNotification(package);
|
view->customNotification(package);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelPrivate::notifyPropertiesRemoved(const QList<PropertyPair> &propertyPairList)
|
void ModelPrivate::notifyPropertiesRemoved(const QList<PropertyPair> &propertyPairList)
|
||||||
@@ -832,6 +846,8 @@ void ModelPrivate::notifyPropertiesAboutToBeRemoved(const QList<InternalProperty
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (m_rewriterView) {
|
if (m_rewriterView) {
|
||||||
|
NanotraceHR::Tracer tracer{m_rewriterView->name(), ModelTracing::category()};
|
||||||
|
|
||||||
QList<AbstractProperty> propertyList;
|
QList<AbstractProperty> propertyList;
|
||||||
for (InternalProperty *property : internalPropertyList) {
|
for (InternalProperty *property : internalPropertyList) {
|
||||||
AbstractProperty newProperty(property->name(),
|
AbstractProperty newProperty(property->name(),
|
||||||
@@ -849,6 +865,7 @@ void ModelPrivate::notifyPropertiesAboutToBeRemoved(const QList<InternalProperty
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const QPointer<AbstractView> &view : std::as_const(m_viewList)) {
|
for (const QPointer<AbstractView> &view : std::as_const(m_viewList)) {
|
||||||
|
NanotraceHR::Tracer tracer{view->name(), ModelTracing::category()};
|
||||||
QList<AbstractProperty> propertyList;
|
QList<AbstractProperty> propertyList;
|
||||||
Q_ASSERT(view != nullptr);
|
Q_ASSERT(view != nullptr);
|
||||||
for (auto property : internalPropertyList) {
|
for (auto property : internalPropertyList) {
|
||||||
@@ -864,14 +881,18 @@ void ModelPrivate::notifyPropertiesAboutToBeRemoved(const QList<InternalProperty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeInstanceView()) {
|
if (m_nodeInstanceView) {
|
||||||
|
NanotraceHR::Tracer tracer{m_nodeInstanceView->name(), ModelTracing::category()};
|
||||||
QList<AbstractProperty> propertyList;
|
QList<AbstractProperty> propertyList;
|
||||||
for (auto property : internalPropertyList) {
|
for (auto property : internalPropertyList) {
|
||||||
AbstractProperty newProperty(property->name(), property->propertyOwner(), m_model, nodeInstanceView());
|
AbstractProperty newProperty(property->name(),
|
||||||
|
property->propertyOwner(),
|
||||||
|
m_model,
|
||||||
|
m_nodeInstanceView);
|
||||||
propertyList.append(newProperty);
|
propertyList.append(newProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeInstanceView()->propertiesAboutToBeRemoved(propertyList);
|
m_nodeInstanceView->propertiesAboutToBeRemoved(propertyList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resetModel)
|
if (resetModel)
|
||||||
|
@@ -137,12 +137,9 @@ public:
|
|||||||
void detachView(AbstractView *view, bool notifyView);
|
void detachView(AbstractView *view, bool notifyView);
|
||||||
void detachAllViews();
|
void detachAllViews();
|
||||||
|
|
||||||
template<typename Callable>
|
void notifyNodeInstanceViewLast(const std::invocable<AbstractView *> auto &call);
|
||||||
void notifyNodeInstanceViewLast(Callable call);
|
void notifyNormalViewsLast(const std::invocable<AbstractView *> auto &call);
|
||||||
template<typename Callable>
|
void notifyInstanceChanges(const std::invocable<AbstractView *> auto &call);
|
||||||
void notifyNormalViewsLast(Callable call);
|
|
||||||
template<typename Callable>
|
|
||||||
void notifyInstanceChanges(Callable call);
|
|
||||||
|
|
||||||
void notifyNodeCreated(const InternalNodePointer &newNode);
|
void notifyNodeCreated(const InternalNodePointer &newNode);
|
||||||
void notifyNodeAboutToBeReparent(const InternalNodePointer &node,
|
void notifyNodeAboutToBeReparent(const InternalNodePointer &node,
|
||||||
|
Reference in New Issue
Block a user