QtBase  v6.3.1
qtextcursor.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QTEXTCURSOR_H
41 #define QTEXTCURSOR_H
42 
43 #include <QtGui/qtguiglobal.h>
44 #include <QtCore/qstring.h>
45 #include <QtCore/qshareddata.h>
46 #include <QtGui/qtextformat.h>
47 
49 
50 
51 class QTextDocument;
52 class QTextCursorPrivate;
54 class QTextCharFormat;
55 class QTextBlockFormat;
56 class QTextListFormat;
57 class QTextTableFormat;
58 class QTextFrameFormat;
59 class QTextImageFormat;
61 class QTextList;
62 class QTextTable;
63 class QTextFrame;
64 class QTextBlock;
65 
66 class Q_GUI_EXPORT QTextCursor
67 {
68 public:
69  QTextCursor();
72  explicit QTextCursor(QTextCursorPrivate *d);
73  explicit QTextCursor(QTextFrame *frame);
74  explicit QTextCursor(const QTextBlock &block);
77  QTextCursor &operator=(const QTextCursor &other);
78  ~QTextCursor();
79 
80  void swap(QTextCursor &other) noexcept { d.swap(other.d); }
81 
82  bool isNull() const;
83 
84  enum MoveMode {
86  KeepAnchor
87  };
88 
89  void setPosition(int pos, MoveMode mode = MoveAnchor);
90  int position() const;
91  int positionInBlock() const;
92 
93  int anchor() const;
94 
95  void insertText(const QString &text);
96  void insertText(const QString &text, const QTextCharFormat &format);
97 
100 
102  Up,
111 
122 
126  PreviousRow
127  };
128 
129  bool movePosition(MoveOperation op, MoveMode = MoveAnchor, int n = 1);
130 
131  bool visualNavigation() const;
132  void setVisualNavigation(bool b);
133 
134  void setVerticalMovementX(int x);
135  int verticalMovementX() const;
136 
137  void setKeepPositionOnInsert(bool b);
138  bool keepPositionOnInsert() const;
139 
140  void deleteChar();
141  void deletePreviousChar();
142 
147  Document
148  };
149  void select(SelectionType selection);
150 
151  bool hasSelection() const;
152  bool hasComplexSelection() const;
153  void removeSelectedText();
154  void clearSelection();
155  int selectionStart() const;
156  int selectionEnd() const;
157 
158  QString selectedText() const;
160  void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const;
161 
162  QTextBlock block() const;
163 
164  QTextCharFormat charFormat() const;
165  void setCharFormat(const QTextCharFormat &format);
166  void mergeCharFormat(const QTextCharFormat &modifier);
167 
168  QTextBlockFormat blockFormat() const;
169  void setBlockFormat(const QTextBlockFormat &format);
170  void mergeBlockFormat(const QTextBlockFormat &modifier);
171 
172  QTextCharFormat blockCharFormat() const;
173  void setBlockCharFormat(const QTextCharFormat &format);
174  void mergeBlockCharFormat(const QTextCharFormat &modifier);
175 
176  bool atBlockStart() const;
177  bool atBlockEnd() const;
178  bool atStart() const;
179  bool atEnd() const;
180 
181  void insertBlock();
182  void insertBlock(const QTextBlockFormat &format);
183  void insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat);
184 
185  QTextList *insertList(const QTextListFormat &format);
187 
190  QTextList *currentList() const;
191 
192  QTextTable *insertTable(int rows, int cols, const QTextTableFormat &format);
193  QTextTable *insertTable(int rows, int cols);
194  QTextTable *currentTable() const;
195 
196  QTextFrame *insertFrame(const QTextFrameFormat &format);
197  QTextFrame *currentFrame() const;
198 
199  void insertFragment(const QTextDocumentFragment &fragment);
200 
201 #ifndef QT_NO_TEXTHTMLPARSER
202  void insertHtml(const QString &html);
203 #endif // QT_NO_TEXTHTMLPARSER
204 
206  void insertImage(const QTextImageFormat &format);
207  void insertImage(const QString &name);
208  void insertImage(const QImage &image, const QString &name = QString());
209 
210  void beginEditBlock();
211  void joinPreviousEditBlock();
212  void endEditBlock();
213 
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;
220 
221  bool isCopyOf(const QTextCursor &other) const;
222 
223  int blockNumber() const;
224  int columnNumber() const;
225 
226  QTextDocument *document() const;
227 
228 private:
230  friend class QTextCursorPrivate;
231  friend class QTextDocumentPrivate;
233  friend class QTextCopyHelper;
235 };
236 
238 
240 
241 #endif // QTEXTCURSOR_H
Arabic default style
Definition: afstyles.h:94
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:73
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument....
Definition: qtextformat.h:640
The QTextBlock class provides a container for text fragments in a QTextDocument. \inmodule QtGui.
Definition: qtextobject.h:193
The QTextCharFormat class provides formatting information for characters in a QTextDocument....
Definition: qtextformat.h:416
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:67
void swap(QTextCursor &other) noexcept
Definition: qtextcursor.h:80
The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument.
The QTextDocument class holds formatted text.
Definition: qtextdocument.h:93
The QTextFrameFormat class provides formatting information for frames in a QTextDocument....
Definition: qtextformat.h:859
The QTextFrame class represents a frame in a QTextDocument. \inmodule QtGui.
Definition: qtextobject.h:117
The QTextImageFormat class provides formatting information for images in a QTextDocument....
Definition: qtextformat.h:811
The QTextListFormat class provides formatting information for lists in a QTextDocument....
Definition: qtextformat.h:757
The QTextList class provides a decorated list of items in a QTextDocument. \inmodule QtGui.
Definition: qtextlist.h:54
The QTextTableFormat class provides formatting information for tables in a QTextDocument....
Definition: qtextformat.h:978
The QTextTable class represents a table in a QTextDocument. \inmodule QtGui.
Definition: qtexttable.h:99
QDomDocument document
[0]
QCursor cursor
uint alignment
JOCTET JCOEFPTR block
Definition: jsimd.h:109
QT_BEGIN_NAMESPACE bool operator<(const QMimeType &t1, const QMimeType &t2)
QHighDpiScaling::Point position(T, QHighDpiScaling::Point::Kind)
Definition: image.cpp:51
#define QString()
Definition: parse-defines.h:51
set set set set set set set macro pixldst1 op
constexpr bool operator!=(const timespec &t1, const timespec &t2)
Definition: qcore_unix_p.h:124
constexpr bool operator>(const QFixed &f, int i)
Definition: qfixed_p.h:182
#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(Class)
Definition: qglobal.h:563
@ text
bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLenum mode
GLuint name
GLfloat n
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
#define Q_DECLARE_SHARED(TYPE)
Definition: qtypeinfo.h:197
bool operator<=(const QUuid &lhs, const QUuid &rhs) noexcept
Definition: quuid.h:216
bool operator>=(const QUuid &lhs, const QUuid &rhs) noexcept
Definition: quuid.h:218
QSharedPointer< T > other(t)
[5]
QItemSelection * selection
[0]
selection select(topLeft, bottomRight)
QFrame frame
[0]
content text html
QList< int > createList(int listSize)
#define rhs