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
qtextblock.cpp
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#include "qtextblock_p.h"
5#include "qtextdocument_p.h"
6
7#include <QtCore/qstring.h>
8
9namespace Utils {
10
12{
13 return m_document;
14}
15
16void TextBlock::setBlockNumber(int blockNumber)
17{
18 m_blockNumber = blockNumber;
19}
20
22{
23 return m_blockNumber;
24}
25
27{
28 m_position = position;
29}
30
32{
33 return m_position;
34}
35
37{
38 m_length = length;
39}
40
42{
43 return m_length;
44}
45
47{
48 return m_document->findBlockByNumber(m_blockNumber + 1);
49}
50
52{
53 return m_document->findBlockByNumber(m_blockNumber - 1);
54}
55
57{
58 return m_document->userState(m_blockNumber);
59}
60
62{
63 m_document->setUserState(m_blockNumber, state);
64}
65
67{
68 m_document = document;
69}
70
72{
73 return m_document;
74}
75
77{
78 return document()->toPlainText().mid(position(), length());
79}
80
82{
83 return m_revision;
84}
85
87{
88 m_revision = rev;
89}
90
91bool operator==(const TextBlock &t1, const TextBlock &t2)
92{
93 return t1.document() == t2.document() && t1.blockNumber() == t2.blockNumber();
94}
95
96bool operator!=(const TextBlock &t1, const TextBlock &t2)
97{
98 return !(t1 == t2);
99}
100
101} // namespace Utils
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString mid(qsizetype position, qsizetype n=-1) const &
Definition qstring.cpp:5300
TextBlock next() const
int userState() const
int length() const
void setLength(int length)
void setRevision(int rev)
void setDocument(TextDocument *document)
bool isValid() const
TextDocument * document() const
int revision() const
int position() const
void setUserState(int state)
void setPosition(int position)
int blockNumber() const
void setBlockNumber(int blockNumber)
TextBlock previous() const
QString text() const
void setUserState(int blockNumber, int state)
int userState(int blockNumber) const
QString toPlainText() const
TextBlock findBlockByNumber(int blockNumber) const
else opt state
[0]
bool operator!=(const TextBlock &t1, const TextBlock &t2)
bool operator==(const TextBlock &t1, const TextBlock &t2)
GLenum GLuint GLenum GLsizei length
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define t2