Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#ifndef QTEXTDOCUMENT_P_H
5#define QTEXTDOCUMENT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qtextblock_p.h"
19
20#include <QtCore/qchar.h>
21#include <QtCore/qvector.h>
22#include <QtCore/qscopedpointer.h>
23#include <QtCore/qmutex.h>
24
25#include <optional>
26
27namespace Utils {
28
29class TextBlockUserData;
30
32{
33public:
34 TextDocument() = default;
35 explicit TextDocument(const QString &text);
36
37 TextBlock findBlockByNumber(int blockNumber) const;
38 TextBlock findBlockByLineNumber(int lineNumber) const;
39 QChar characterAt(int pos) const;
40 int characterCount() const;
41 TextBlock begin() const;
42 TextBlock firstBlock() const;
43 TextBlock lastBlock() const;
44
45 std::optional<int> version() const;
46 void setVersion(std::optional<int>);
47
48 QString toPlainText() const;
49 void setPlainText(const QString &text);
50
51 bool isModified() const;
52 void setModified(bool modified);
53
55
56 void clear();
57
58 void setUserState(int blockNumber, int state);
59 int userState(int blockNumber) const;
60 QMutex *mutex() const;
61
62private:
63 struct Block
64 {
65 TextBlock textBlock;
66 int userState = -1;
67 };
68
69 QVector<Block> m_blocks;
70
71 QString m_content;
72 bool m_modified = false;
73 std::optional<int> m_version;
74 mutable QMutex m_mutex;
75};
76} // namespace Utils
77
78#endif // TEXTDOCUMENT_P_H
\inmodule QtCore
\inmodule QtCore
Definition qmutex.h:281
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
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
int userState(int blockNumber) const
QString toPlainText() const
void setVersion(std::optional< int >)
void setUndoRedoEnabled(bool enable)
bool isModified() const
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
QString text
else opt state
[0]
GLboolean enable