Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtextdocument_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QTEXTDOCUMENT_P_H
6#define QTEXTDOCUMENT_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qtextblock_p.h"
20
21#include <QtCore/qchar.h>
22#include <QtCore/qvector.h>
23#include <QtCore/qscopedpointer.h>
24#include <QtCore/qmutex.h>
25
26#include <optional>
27
28QT_BEGIN_NAMESPACE
29
30namespace Utils {
31
32class TextBlockUserData;
33
35{
36public:
37 TextDocument() = default;
38 explicit TextDocument(const QString &text);
39
40 TextBlock findBlockByNumber(int blockNumber) const;
41 TextBlock findBlockByLineNumber(int lineNumber) const;
42 QChar characterAt(int pos) const;
43 int characterCount() const;
44 TextBlock begin() const;
45 TextBlock firstBlock() const;
46 TextBlock lastBlock() const;
47
48 std::optional<int> version() const;
49 void setVersion(std::optional<int>);
50
51 QString toPlainText() const;
52 void setPlainText(const QString &text);
53
54 bool isModified() const;
55 void setModified(bool modified);
56
57 void setUndoRedoEnabled(bool enable);
58
59 void clear();
60
61 void setUserState(int blockNumber, int state);
62 int userState(int blockNumber) const;
63 QMutex *mutex() const;
64
65private:
66 struct Block
67 {
68 TextBlock textBlock;
69 int userState = -1;
70 };
71
72 QVector<Block> m_blocks;
73
74 QString m_content;
75 bool m_modified = false;
76 std::optional<int> m_version;
77 mutable QMutex m_mutex;
78};
79} // namespace Utils
80
81QT_END_NAMESPACE
82
83#endif // TEXTDOCUMENT_P_H
TextBlock next() const
int length() const
bool isValid() const
int position() const
int blockNumber() const
int selectionEnd() const
bool movePosition(MoveOperation op, MoveMode=MoveAnchor, int n=1)
TextCursor(TextDocument *document)
int blockNumber() const
bool hasSelection() const
int positionInBlock() const
TextBlock block() const
TextCursor(const TextBlock &block)
int anchor() const
void insertText(const QString &text)
int position() const
TextDocument * document() const
QString selectedText() const
void setPosition(int pos, MoveMode mode=MoveAnchor)
void select(SelectionType selection)
bool isNull() const
void setModified(bool modified)
void setPlainText(const QString &text)
void setUserState(int blockNumber, int state)
TextBlock lastBlock() const
TextBlock findBlockByLineNumber(int lineNumber) const
TextBlock firstBlock() const
TextDocument(const QString &text)
int userState(int blockNumber) const
QString toPlainText() const
void setVersion(std::optional< int >)
void setUndoRedoEnabled(bool enable)
QChar characterAt(int pos) const
QMutex * mutex() const
std::optional< int > version() const
TextBlock begin() const
int characterCount() const
TextDocument()=default
TextBlock findBlockByNumber(int blockNumber) const