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 TEXTMODIFIER_H
34 #define TEXTMODIFIER_H
36 #include "corelib_global.h"
38 #include <qmljs/qmljsdocument.h>
40 #include <QtCore/QByteArray>
41 #include <QtCore/QObject>
42 #include <QtGui/QTextCursor>
43 #include <QtGui/QTextDocument>
45 namespace QmlDesigner {
47 class CORESHARED_EXPORT TextModifier: public QObject
52 TextModifier(const TextModifier &);
53 TextModifier &operator=(const TextModifier &);
59 int leadingCharsToRemove;
60 int trailingCharsToRemove;
63 QString prefixToInsert;
64 QString suffixToInsert;
66 MoveInfo(): objectStart(-1), objectEnd(-1), leadingCharsToRemove(0), trailingCharsToRemove(0), destination(-1) {}
71 virtual ~TextModifier() = 0;
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;
77 virtual int indentDepth() const = 0;
79 virtual void startGroup() = 0;
80 virtual void flushGroup() = 0;
81 virtual void commitGroup() = 0;
83 virtual QTextDocument *textDocument() const = 0;
84 virtual QString text() const = 0;
85 virtual QTextCursor textCursor() const = 0;
87 virtual void deactivateChangeSignals() = 0;
88 virtual void reactivateChangeSignals() = 0;
90 virtual QmlJS::Snapshot getSnapshot() const = 0;
91 virtual QStringList importPaths() const = 0;
93 virtual bool renameId(const QString &oldId, const QString &newId) = 0;
98 void replaced(int offset, int oldLength, int newLength);
99 void moved(const TextModifier::MoveInfo &moveInfo);
104 #endif // TEXTMODIFIER_H