forked from qt-creator/qt-creator
QmlDesigner: Add notification blocker
Change-Id: I9609437a7190f92cc208d56cff57c5b35ef57beb Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -284,6 +284,23 @@ public:
|
|||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
void setEnabled(bool b);
|
void setEnabled(bool b);
|
||||||
|
|
||||||
|
bool isBlockingNotifications() const { return m_isBlockingNotifications; }
|
||||||
|
|
||||||
|
class NotificationBlocker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NotificationBlocker(AbstractView *view)
|
||||||
|
: m_view{view}
|
||||||
|
{
|
||||||
|
m_view->m_isBlockingNotifications = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
~NotificationBlocker() { m_view->m_isBlockingNotifications = false; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
AbstractView *m_view;
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setModel(Model * model);
|
void setModel(Model * model);
|
||||||
void removeModel();
|
void removeModel();
|
||||||
@@ -296,10 +313,11 @@ protected:
|
|||||||
|
|
||||||
private: //functions
|
private: //functions
|
||||||
QList<ModelNode> toModelNodeList(const QList<Internal::InternalNodePointer> &nodeList) const;
|
QList<ModelNode> toModelNodeList(const QList<Internal::InternalNodePointer> &nodeList) const;
|
||||||
bool m_enabled = true;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<Model> m_model;
|
QPointer<Model> m_model;
|
||||||
|
bool m_enabled = true;
|
||||||
|
bool m_isBlockingNotifications = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
QMLDESIGNERCORE_EXPORT QList<Internal::InternalNodePointer> toInternalNodeList(const QList<ModelNode> &nodeList);
|
QMLDESIGNERCORE_EXPORT QList<Internal::InternalNodePointer> toInternalNodeList(const QList<ModelNode> &nodeList);
|
||||||
|
@@ -397,17 +397,19 @@ void ModelPrivate::notifyNodeInstanceViewLast(Callable call)
|
|||||||
QString description;
|
QString description;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (rewriterView())
|
if (rewriterView() && !rewriterView()->isBlockingNotifications())
|
||||||
call(rewriterView());
|
call(rewriterView());
|
||||||
} catch (const RewritingException &e) {
|
} catch (const RewritingException &e) {
|
||||||
description = e.description();
|
description = e.description();
|
||||||
resetModel = true;
|
resetModel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QPointer<AbstractView> view : enabledViews())
|
for (QPointer<AbstractView> view : enabledViews()) {
|
||||||
|
if (!view->isBlockingNotifications())
|
||||||
call(view.data());
|
call(view.data());
|
||||||
|
}
|
||||||
|
|
||||||
if (nodeInstanceView())
|
if (nodeInstanceView() && !nodeInstanceView()->isBlockingNotifications())
|
||||||
call(nodeInstanceView());
|
call(nodeInstanceView());
|
||||||
|
|
||||||
if (resetModel)
|
if (resetModel)
|
||||||
@@ -421,18 +423,20 @@ void ModelPrivate::notifyNormalViewsLast(Callable call)
|
|||||||
QString description;
|
QString description;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (rewriterView())
|
if (rewriterView() && !rewriterView()->isBlockingNotifications())
|
||||||
call(rewriterView());
|
call(rewriterView());
|
||||||
} catch (const RewritingException &e) {
|
} catch (const RewritingException &e) {
|
||||||
description = e.description();
|
description = e.description();
|
||||||
resetModel = true;
|
resetModel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeInstanceView())
|
if (nodeInstanceView() && !nodeInstanceView()->isBlockingNotifications())
|
||||||
call(nodeInstanceView());
|
call(nodeInstanceView());
|
||||||
|
|
||||||
for (QPointer<AbstractView> view : enabledViews())
|
for (QPointer<AbstractView> view : enabledViews()) {
|
||||||
|
if (!view->isBlockingNotifications())
|
||||||
call(view.data());
|
call(view.data());
|
||||||
|
}
|
||||||
|
|
||||||
if (resetModel)
|
if (resetModel)
|
||||||
resetModelByRewriter(description);
|
resetModelByRewriter(description);
|
||||||
@@ -441,9 +445,11 @@ void ModelPrivate::notifyNormalViewsLast(Callable call)
|
|||||||
template<typename Callable>
|
template<typename Callable>
|
||||||
void ModelPrivate::notifyInstanceChanges(Callable call)
|
void ModelPrivate::notifyInstanceChanges(Callable call)
|
||||||
{
|
{
|
||||||
for (QPointer<AbstractView> view : enabledViews())
|
for (QPointer<AbstractView> view : enabledViews()) {
|
||||||
|
if (!view->isBlockingNotifications())
|
||||||
call(view.data());
|
call(view.data());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ModelPrivate::notifyAuxiliaryDataChanged(const InternalNodePointer &internalNode,
|
void ModelPrivate::notifyAuxiliaryDataChanged(const InternalNodePointer &internalNode,
|
||||||
const PropertyName &name,
|
const PropertyName &name,
|
||||||
|
Reference in New Issue
Block a user