OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / designercore / include / textmodifier.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 TEXTMODIFIER_H
34 #define TEXTMODIFIER_H
35
36 #include "corelib_global.h"
37
38 #include <qmljs/qmljsdocument.h>
39
40 #include <QtCore/QByteArray>
41 #include <QtCore/QObject>
42 #include <QtGui/QTextCursor>
43 #include <QtGui/QTextDocument>
44
45 namespace QmlDesigner {
46
47 class CORESHARED_EXPORT TextModifier: public QObject
48 {
49     Q_OBJECT
50
51 private:
52     TextModifier(const TextModifier &);
53     TextModifier &operator=(const TextModifier &);
54
55 public:
56     struct MoveInfo {
57         int objectStart;
58         int objectEnd;
59         int leadingCharsToRemove;
60         int trailingCharsToRemove;
61
62         int destination;
63         QString prefixToInsert;
64         QString suffixToInsert;
65
66         MoveInfo(): objectStart(-1), objectEnd(-1), leadingCharsToRemove(0), trailingCharsToRemove(0), destination(-1) {}
67     };
68
69 public:
70     TextModifier() {}
71     virtual ~TextModifier() = 0;
72
73     virtual void replace(int offset, int length, const QString& replacement) = 0;
74     virtual void move(const MoveInfo &moveInfo) = 0;
75     virtual void indent(int offset, int length) = 0;
76
77     virtual int indentDepth() const = 0;
78
79     virtual void startGroup() = 0;
80     virtual void flushGroup() = 0;
81     virtual void commitGroup() = 0;
82
83     virtual QTextDocument *textDocument() const = 0;
84     virtual QString text() const = 0;
85     virtual QTextCursor textCursor() const = 0;
86
87     virtual void deactivateChangeSignals() = 0;
88     virtual void reactivateChangeSignals() = 0;
89
90     virtual QmlJS::Snapshot getSnapshot() const = 0;
91     virtual QStringList importPaths() const = 0;
92
93     virtual bool renameId(const QString &oldId, const QString &newId) = 0;
94
95 signals:
96     void textChanged();
97
98     void replaced(int offset, int oldLength, int newLength);
99     void moved(const TextModifier::MoveInfo &moveInfo);
100 };
101
102 }
103
104 #endif // TEXTMODIFIER_H