Commit 613529b3 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.Model: Allowing the model to hold a TextModifer

We have a one to one relationship between models and TextModifiers.
With this patch the model keeps track of its own TextModifer and
does set it to the rewriter if attached.

The model does not take ownership, since it does also not take
ownership of its views.

Change-Id: Ied02666debf6aad76666b0d9d22e8ba2f72be666
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent a37fbaef
......@@ -58,6 +58,7 @@ class NodeAnchors;
class AbstractProperty;
class RewriterView;
class NodeInstanceView;
class TextModifier;
typedef QList<QPair<PropertyName, QVariant> > PropertyListType;
......@@ -107,6 +108,9 @@ public:
Model *metaInfoProxyModel();
TextModifier *textModifier() const;
void setTextModifier(TextModifier *textModifier);
protected:
Model();
......
......@@ -57,6 +57,7 @@
#include "rewriterview.h"
#include "rewritingexception.h"
#include "invalididexception.h"
#include "textmodifier.h"
/*!
\defgroup CoreModel
......@@ -1798,6 +1799,16 @@ Model *Model::metaInfoProxyModel()
return this;
}
TextModifier *Model::textModifier() const
{
return d->m_textModifier.data();
}
void Model::setTextModifier(TextModifier *textModifier)
{
d->m_textModifier = textModifier;
}
#if 0
/*!
\brief Creates a new empty model
......
......@@ -246,6 +246,7 @@ private:
QUrl m_fileUrl;
QWeakPointer<RewriterView> m_rewriterView;
QWeakPointer<NodeInstanceView> m_nodeInstanceView;
QWeakPointer<TextModifier> m_textModifier;
QWeakPointer<Model> m_metaInfoProxyModel;
bool m_writeLock;
qint32 m_internalIdCounter;
......
......@@ -149,6 +149,9 @@ Internal::TextToModelMerger *RewriterView::textToModelMerger() const
void RewriterView::modelAttached(Model *model)
{
if (model && model->textModifier())
setTextModifier(model->textModifier());
AbstractView::modelAttached(model);
ModelAmender differenceHandler(m_textToModelMerger.data());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment