1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef MODELTOTEXTMERGER_H
34 #define MODELTOTEXTMERGER_H
36 #include "corelib_global.h"
37 #include <modelnode.h>
38 #include "abstractview.h"
39 #include "nodeabstractproperty.h"
40 #include "variantproperty.h"
41 #include "nodelistproperty.h"
42 #include "bindingproperty.h"
43 #include "rewriteaction.h"
44 #include <filemanager/qmlrefactoring.h>
50 namespace QmlDesigner {
52 class CORESHARED_EXPORT RewriterView;
56 class ModelToTextMerger
58 typedef AbstractView::PropertyChangeFlags PropertyChangeFlags;
59 static QStringList m_propertyOrder;
62 ModelToTextMerger(RewriterView *reWriterView);
65 * Note: his method might throw exceptions, as the model works this way. So to
66 * handle rewriting failures, you will also need to catch any exception coming
71 bool hasNoPendingChanges() const
72 { return m_rewriteActions.isEmpty(); }
74 void nodeCreated(const ModelNode &createdNode);
75 void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange);
76 void propertiesRemoved(const QList<AbstractProperty>& propertyList);
77 void propertiesChanged(const QList<AbstractProperty>& propertyList, PropertyChangeFlags propertyChange);
78 void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
79 void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
80 void nodeSlidAround(const ModelNode &movingNode, const ModelNode &inFrontOfNode);
81 void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion);
83 void addImport(const Import &import);
84 void removeImport(const Import &import);
89 void reindent(const QMap<int,int> &dirtyAreas) const;
91 void schedule(RewriteAction *action);
92 QList<RewriteAction *> scheduledRewriteActions() const
93 { return m_rewriteActions; }
95 static QmlDesigner::QmlRefactoring::PropertyType propertyType(const AbstractProperty &property, const QString &textValue = QString());
96 static QStringList getPropertyOrder();
98 static bool isInHierarchy(const AbstractProperty &property);
100 void dumpRewriteActions(const QString &msg);
103 RewriterView *m_rewriterView;
104 QList<RewriteAction *> m_rewriteActions;
110 #endif // MODELTOTEXTMERGER_H