- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qtextcursor.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QTEXTCURSOR_H
    00043 #define QTEXTCURSOR_H
    00044
    00045 #include <QtCore/qstring.h>
    00046 #include <QtCore/qshareddata.h>
    00047 #include <QtGui/qtextformat.h>
    00048
    00049 QT_BEGIN_HEADER
    00050
    00051 QT_BEGIN_NAMESPACE
    00052
    00053 QT_MODULE(Gui)
    00054
    00055 class QTextDocument;
    00056 class QTextCursorPrivate;
    00057 class QTextDocumentFragment;
    00058 class QTextCharFormat;
    00059 class QTextBlockFormat;
    00060 class QTextListFormat;
    00061 class QTextTableFormat;
    00062 class QTextFrameFormat;
    00063 class QTextImageFormat;
    00064 class QTextDocumentPrivate;
    00065 class QTextList;
    00066 class QTextTable;
    00067 class QTextFrame;
    00068 class QTextBlock;
    00069
    00070 class Q_GUI_EXPORT QTextCursor
    00071 {
    00072 public:
    00073     QTextCursor();
    00074     explicit QTextCursor(QTextDocument *document);
    00075     QTextCursor(QTextDocumentPrivate *p, int pos);
    00076     explicit QTextCursor(QTextFrame *frame);
    00077     explicit QTextCursor(const QTextBlock &block);
    00078     explicit QTextCursor(QTextCursorPrivate *d);
    00079     QTextCursor(const QTextCursor &cursor);
    00080     QTextCursor &operator=(const QTextCursor &other);
    00081     ~QTextCursor();
    00082
    00083     bool isNull() const;
    00084
    00085     enum MoveMode {
    00086         MoveAnchor,
    00087         KeepAnchor
    00088     };
    00089
    00090     void setPosition(int pos, MoveMode mode = MoveAnchor);
    00091     int position() const;
    00092     int positionInBlock() const;
    00093
    00094     int anchor() const;
    00095
    00096     void insertText(const QString &text);
    00097     void insertText(const QString &text, const QTextCharFormat &format);
    00098
    00099     enum MoveOperation {
    00100         NoMove,
    00101
    00102         Start,
    00103         Up,
    00104         StartOfLine,
    00105         StartOfBlock,
    00106         StartOfWord,
    00107         PreviousBlock,
    00108         PreviousCharacter,
    00109         PreviousWord,
    00110         Left,
    00111         WordLeft,
    00112
    00113         End,
    00114         Down,
    00115         EndOfLine,
    00116         EndOfWord,
    00117         EndOfBlock,
    00118         NextBlock,
    00119         NextCharacter,
    00120         NextWord,
    00121         Right,
    00122         WordRight,
    00123
    00124         NextCell,
    00125         PreviousCell,
    00126         NextRow,
    00127         PreviousRow
    00128     };
    00129
    00130     bool movePosition(MoveOperation op, MoveMode = MoveAnchor, int n = 1);
    00131
    00132     bool visualNavigation() const;
    00133     void setVisualNavigation(bool b);
    00134
    00135     void setVerticalMovementX(int x);
    00136     int verticalMovementX() const;
    00137
    00138     void setKeepPositionOnInsert(bool b);
    00139     bool keepPositionOnInsert() const;
    00140
    00141     void deleteChar();
    00142     void deletePreviousChar();
    00143
    00144     enum SelectionType {
    00145         WordUnderCursor,
    00146         LineUnderCursor,
    00147         BlockUnderCursor,
    00148         Document
    00149     };
    00150     void select(SelectionType selection);
    00151
    00152     bool hasSelection() const;
    00153     bool hasComplexSelection() const;
    00154     void removeSelectedText();
    00155     void clearSelection();
    00156     int selectionStart() const;
    00157     int selectionEnd() const;
    00158
    00159     QString selectedText() const;
    00160     QTextDocumentFragment selection() const;
    00161     void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const;
    00162
    00163     QTextBlock block() const;
    00164
    00165     QTextCharFormat charFormat() const;
    00166     void setCharFormat(const QTextCharFormat &format);
    00167     void mergeCharFormat(const QTextCharFormat &modifier);
    00168
    00169     QTextBlockFormat blockFormat() const;
    00170     void setBlockFormat(const QTextBlockFormat &format);
    00171     void mergeBlockFormat(const QTextBlockFormat &modifier);
    00172
    00173     QTextCharFormat blockCharFormat() const;
    00174     void setBlockCharFormat(const QTextCharFormat &format);
    00175     void mergeBlockCharFormat(const QTextCharFormat &modifier);
    00176
    00177     bool atBlockStart() const;
    00178     bool atBlockEnd() const;
    00179     bool atStart() const;
    00180     bool atEnd() const;
    00181
    00182     void insertBlock();
    00183     void insertBlock(const QTextBlockFormat &format);
    00184     void insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat);
    00185
    00186     QTextList *insertList(const QTextListFormat &format);
    00187     QTextList *insertList(QTextListFormat::Style style);
    00188
    00189     QTextList *createList(const QTextListFormat &format);
    00190     QTextList *createList(QTextListFormat::Style style);
    00191     QTextList *currentList() const;
    00192
    00193     QTextTable *insertTable(int rows, int cols, const QTextTableFormat &format);
    00194     QTextTable *insertTable(int rows, int cols);
    00195     QTextTable *currentTable() const;
    00196
    00197     QTextFrame *insertFrame(const QTextFrameFormat &format);
    00198     QTextFrame *currentFrame() const;
    00199
    00200     void insertFragment(const QTextDocumentFragment &fragment);
    00201
    00202 #ifndef QT_NO_TEXTHTMLPARSER
    00203     void insertHtml(const QString &html);
    00204 #endif // QT_NO_TEXTHTMLPARSER
    00205
    00206     void insertImage(const QTextImageFormat &format, QTextFrameFormat::Position alignment);
    00207     void insertImage(const QTextImageFormat &format);
    00208     void insertImage(const QString &name);
    00209     void insertImage(const QImage &image, const QString &name = QString());
    00210
    00211     void beginEditBlock();
    00212     void joinPreviousEditBlock();
    00213     void endEditBlock();
    00214
    00215     bool operator!=(const QTextCursor &rhs) const;
    00216     bool operator<(const QTextCursor &rhs) const;
    00217     bool operator<=(const QTextCursor &rhs) const;
    00218     bool operator==(const QTextCursor &rhs) const;
    00219     bool operator>=(const QTextCursor &rhs) const;
    00220     bool operator>(const QTextCursor &rhs) const;
    00221
    00222     bool isCopyOf(const QTextCursor &other) const;
    00223
    00224     int blockNumber() const;
    00225     int columnNumber() const;
    00226
    00227     QTextDocument *document() const;
    00228
    00229 private:
    00230     QSharedDataPointer<QTextCursorPrivate> d;
    00231     friend class QTextDocumentFragmentPrivate;
    00232     friend class QTextCopyHelper;
    00233 };
    00234
    00235 QT_END_NAMESPACE
    00236
    00237 QT_END_HEADER
    00238
    00239 #endif // QTEXTCURSOR_H