OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / designercore / model / modeltotextmerger.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef MODELTOTEXTMERGER_H
34 #define MODELTOTEXTMERGER_H
35
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>
45 #include <QMap>
46 #include <QSet>
47 #include <QHash>
48 #include <QVariant>
49
50 namespace QmlDesigner {
51
52 class CORESHARED_EXPORT RewriterView;
53
54 namespace Internal {
55
56 class ModelToTextMerger
57 {
58     typedef AbstractView::PropertyChangeFlags PropertyChangeFlags;
59     static QStringList m_propertyOrder;
60
61 public:
62     ModelToTextMerger(RewriterView *reWriterView);
63
64     /**
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
67      *  out.
68      */
69     void applyChanges();
70
71     bool hasNoPendingChanges() const
72     { return m_rewriteActions.isEmpty(); }
73
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);
82
83     void addImport(const Import &import);
84     void removeImport(const Import &import);
85
86 protected:
87     RewriterView *view();
88
89     void reindent(const QMap<int,int> &dirtyAreas) const;
90
91     void schedule(RewriteAction *action);
92     QList<RewriteAction *> scheduledRewriteActions() const
93     { return m_rewriteActions; }
94
95     static QmlDesigner::QmlRefactoring::PropertyType propertyType(const AbstractProperty &property, const QString &textValue = QString());
96     static QStringList getPropertyOrder();
97
98     static bool isInHierarchy(const AbstractProperty &property);
99
100     void dumpRewriteActions(const QString &msg);
101
102 private:
103     RewriterView *m_rewriterView;
104     QList<RewriteAction *> m_rewriteActions;
105 };
106
107 } //Internal
108 } //QmlDesigner
109
110 #endif // MODELTOTEXTMERGER_H