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;
|
||||
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:
|
||||
void setModel(Model * model);
|
||||
void removeModel();
|
||||
@@ -296,10 +313,11 @@ protected:
|
||||
|
||||
private: //functions
|
||||
QList<ModelNode> toModelNodeList(const QList<Internal::InternalNodePointer> &nodeList) const;
|
||||
bool m_enabled = true;
|
||||
|
||||
private:
|
||||
QPointer<Model> m_model;
|
||||
bool m_enabled = true;
|
||||
bool m_isBlockingNotifications = false;
|
||||
};
|
||||
|
||||
QMLDESIGNERCORE_EXPORT QList<Internal::InternalNodePointer> toInternalNodeList(const QList<ModelNode> &nodeList);
|
||||
|
@@ -397,17 +397,19 @@ void ModelPrivate::notifyNodeInstanceViewLast(Callable call)
|
||||
QString description;
|
||||
|
||||
try {
|
||||
if (rewriterView())
|
||||
if (rewriterView() && !rewriterView()->isBlockingNotifications())
|
||||
call(rewriterView());
|
||||
} catch (const RewritingException &e) {
|
||||
description = e.description();
|
||||
resetModel = true;
|
||||
}
|
||||
|
||||
for (QPointer<AbstractView> view : enabledViews())
|
||||
for (QPointer<AbstractView> view : enabledViews()) {
|
||||
if (!view->isBlockingNotifications())
|
||||
call(view.data());
|
||||
}
|
||||
|
||||
if (nodeInstanceView())
|
||||
if (nodeInstanceView() && !nodeInstanceView()->isBlockingNotifications())
|
||||
call(nodeInstanceView());
|
||||
|
||||
if (resetModel)
|
||||
@@ -421,18 +423,20 @@ void ModelPrivate::notifyNormalViewsLast(Callable call)
|
||||
QString description;
|
||||
|
||||
try {
|
||||
if (rewriterView())
|
||||
if (rewriterView() && !rewriterView()->isBlockingNotifications())
|
||||
call(rewriterView());
|
||||
} catch (const RewritingException &e) {
|
||||
description = e.description();
|
||||
resetModel = true;
|
||||
}
|
||||
|
||||
if (nodeInstanceView())
|
||||
if (nodeInstanceView() && !nodeInstanceView()->isBlockingNotifications())
|
||||
call(nodeInstanceView());
|
||||
|
||||
for (QPointer<AbstractView> view : enabledViews())
|
||||
for (QPointer<AbstractView> view : enabledViews()) {
|
||||
if (!view->isBlockingNotifications())
|
||||
call(view.data());
|
||||
}
|
||||
|
||||
if (resetModel)
|
||||
resetModelByRewriter(description);
|
||||
@@ -441,9 +445,11 @@ void ModelPrivate::notifyNormalViewsLast(Callable call)
|
||||
template<typename Callable>
|
||||
void ModelPrivate::notifyInstanceChanges(Callable call)
|
||||
{
|
||||
for (QPointer<AbstractView> view : enabledViews())
|
||||
for (QPointer<AbstractView> view : enabledViews()) {
|
||||
if (!view->isBlockingNotifications())
|
||||
call(view.data());
|
||||
}
|
||||
}
|
||||
|
||||
void ModelPrivate::notifyAuxiliaryDataChanged(const InternalNodePointer &internalNode,
|
||||
const PropertyName &name,
|
||||
|
Reference in New Issue
Block a user