1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtGui module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 #include <QtCore/qstring.h>
46 #include <QtCore/qshareddata.h>
47 #include <QtGui/qtextformat.h>
55 class QTextCursorPrivate;
56 class QTextDocumentFragment;
57 class QTextCharFormat;
58 class QTextBlockFormat;
59 class QTextListFormat;
60 class QTextTableFormat;
61 class QTextFrameFormat;
62 class QTextImageFormat;
63 class QTextDocumentPrivate;
69 class Q_GUI_EXPORT QTextCursor
73 explicit QTextCursor(QTextDocument *document);
74 QTextCursor(QTextDocumentPrivate *p, int pos);
75 explicit QTextCursor(QTextFrame *frame);
76 explicit QTextCursor(const QTextBlock &block);
77 explicit QTextCursor(QTextCursorPrivate *d);
78 QTextCursor(const QTextCursor &cursor);
79 QTextCursor &operator=(const QTextCursor &other);
89 void setPosition(int pos, MoveMode mode = MoveAnchor);
91 int positionInBlock() const;
95 void insertText(const QString &text);
96 void insertText(const QString &text, const QTextCharFormat &format);
129 bool movePosition(MoveOperation op, MoveMode = MoveAnchor, int n = 1);
131 bool visualNavigation() const;
132 void setVisualNavigation(bool b);
134 void setVerticalMovementX(int x);
135 int verticalMovementX() const;
137 void setKeepPositionOnInsert(bool b);
138 bool keepPositionOnInsert() const;
141 void deletePreviousChar();
149 void select(SelectionType selection);
151 bool hasSelection() const;
152 bool hasComplexSelection() const;
153 void removeSelectedText();
154 void clearSelection();
155 int selectionStart() const;
156 int selectionEnd() const;
158 QString selectedText() const;
159 QTextDocumentFragment selection() const;
160 void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const;
162 QTextBlock block() const;
164 QTextCharFormat charFormat() const;
165 void setCharFormat(const QTextCharFormat &format);
166 void mergeCharFormat(const QTextCharFormat &modifier);
168 QTextBlockFormat blockFormat() const;
169 void setBlockFormat(const QTextBlockFormat &format);
170 void mergeBlockFormat(const QTextBlockFormat &modifier);
172 QTextCharFormat blockCharFormat() const;
173 void setBlockCharFormat(const QTextCharFormat &format);
174 void mergeBlockCharFormat(const QTextCharFormat &modifier);
176 bool atBlockStart() const;
177 bool atBlockEnd() const;
178 bool atStart() const;
182 void insertBlock(const QTextBlockFormat &format);
183 void insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat);
185 QTextList *insertList(const QTextListFormat &format);
186 QTextList *insertList(QTextListFormat::Style style);
188 QTextList *createList(const QTextListFormat &format);
189 QTextList *createList(QTextListFormat::Style style);
190 QTextList *currentList() const;
192 QTextTable *insertTable(int rows, int cols, const QTextTableFormat &format);
193 QTextTable *insertTable(int rows, int cols);
194 QTextTable *currentTable() const;
196 QTextFrame *insertFrame(const QTextFrameFormat &format);
197 QTextFrame *currentFrame() const;
199 void insertFragment(const QTextDocumentFragment &fragment);
201 #ifndef QT_NO_TEXTHTMLPARSER
202 void insertHtml(const QString &html);
203 #endif // QT_NO_TEXTHTMLPARSER
205 void insertImage(const QTextImageFormat &format, QTextFrameFormat::Position alignment);
206 void insertImage(const QTextImageFormat &format);
207 void insertImage(const QString &name);
208 void insertImage(const QImage &image, const QString &name = QString());
210 void beginEditBlock();
211 void joinPreviousEditBlock();
214 bool operator!=(const QTextCursor &rhs) const;
215 bool operator<(const QTextCursor &rhs) const;
216 bool operator<=(const QTextCursor &rhs) const;
217 bool operator==(const QTextCursor &rhs) const;
218 bool operator>=(const QTextCursor &rhs) const;
219 bool operator>(const QTextCursor &rhs) const;
221 bool isCopyOf(const QTextCursor &other) const;
223 int blockNumber() const;
224 int columnNumber() const;
226 QTextDocument *document() const;
229 QSharedDataPointer<QTextCursorPrivate> d;
230 friend class QTextCursorPrivate;
231 friend class QTextDocumentFragmentPrivate;
232 friend class QTextCopyHelper;
233 friend class QWidgetTextControlPrivate;
240 #endif // QTEXTCURSOR_H