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
qquicktextutil_p.h
Go to the documentation of this file.
1
// Copyright (C) 2016 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 QQUICKTEXTUTIL_P_H
5
#define QQUICKTEXTUTIL_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 <QtQml/qqml.h>
19
#include <QtQml/qqmlincubator.h>
20
#include <QtQuick/qquickitem.h>
21
#include <QtQuick/qquickwindow.h>
22
#include <QtCore/private/qglobal_p.h>
23
24
QT_BEGIN_NAMESPACE
25
26
class
QQuickTextUtil
:
public
QObject
// For the benefit of translations.
27
{
28
Q_OBJECT
29
public
:
30
template
<
typename
Private>
static
void
setCursorDelegate
(
Private
*
d
,
QQmlComponent
*delegate);
31
template
<
typename
Private>
static
void
createCursor
(
Private
*
d
);
32
33
template
<
typename
T>
static
typename
T::RenderType
textRenderType
();
34
35
static
qreal
alignedX
(
qreal
textWidth,
qreal
itemWidth,
int
alignment
);
36
static
qreal
alignedY
(
qreal
textHeight,
qreal
itemHeight,
int
alignment
);
37
38
private
:
39
static
QQuickItem
*
createCursor
(
40
QQmlComponent
*
component
,
41
QQuickItem
*
parent
,
42
const
QRectF
&cursorRectangle,
43
const
char
*
className
);
44
45
};
46
47
template
<
typename
Private>
48
void
QQuickTextUtil::setCursorDelegate
(
Private
*
d
,
QQmlComponent
*delegate)
49
{
50
if
(
d
->cursorComponent == delegate)
51
return
;
52
53
typename
Private::Public *
parent
=
d
->q_func();
54
55
if
(
d
->cursorComponent) {
56
disconnect
(
d
->cursorComponent,
SIGNAL
(
statusChanged
(
QQmlComponent::Status
)),
57
parent
,
SLOT
(
createCursor
()));
58
}
59
60
delete
d
->cursorItem;
61
d
->cursorItem = 0;
62
d
->cursorPending =
true
;
63
64
d
->cursorComponent = delegate;
65
66
if
(
parent
->isCursorVisible() &&
parent
->isComponentComplete())
67
createCursor
(
d
);
68
69
Q_EMIT
parent
->cursorDelegateChanged();
70
}
71
72
template
<
typename
Private>
73
void
QQuickTextUtil::createCursor
(
Private
*
d
)
74
{
75
if
(!
d
->cursorPending)
76
return
;
77
78
d
->cursorPending =
false
;
79
80
typename
Private::Public *
parent
=
d
->q_func();
81
if
(
d
->cursorComponent) {
82
d
->cursorItem =
createCursor
(
83
d
->cursorComponent,
84
parent
,
85
parent
->cursorRectangle(),
86
Private::Public::staticMetaObject.className());
87
}
88
89
d
->setNativeCursorEnabled(!
d
->cursorItem);
90
d
->updateType = Private::UpdatePaintNode;
91
parent
->update();
92
}
93
94
template
<
typename
T>
95
typename
T::RenderType
QQuickTextUtil::textRenderType
()
96
{
97
switch
(QQuickWindow::textRenderType()) {
98
case
QQuickWindow::QtTextRendering:
99
return
T::QtRendering;
100
case
QQuickWindow::NativeTextRendering:
101
return
T::NativeRendering;
102
case
QQuickWindow::CurveTextRendering:
103
return
T::CurveRendering;
104
}
105
106
Q_UNREACHABLE_RETURN(T::QtRendering);
107
}
108
109
QT_END_NAMESPACE
110
111
#endif
QObject
\inmodule QtCore
Definition
qobject.h:103
QObject::parent
QObject * parent() const
Returns a pointer to the parent object.
Definition
qobject.h:346
QQmlComponent
The QQmlComponent class encapsulates a QML component definition.
Definition
qqmlcomponent.h:32
QQmlComponent::Status
Status
\qmltype Component \instantiates QQmlComponent\inqmlmodule QtQml
Definition
qqmlcomponent.h:56
QQuickItem
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition
qquickitem.h:63
QQuickTextUtil
Definition
qquicktextutil_p.h:27
QQuickTextUtil::alignedX
static qreal alignedX(qreal textWidth, qreal itemWidth, int alignment)
Definition
qquicktextutil.cpp:46
QQuickTextUtil::createCursor
static void createCursor(Private *d)
Definition
qquicktextutil_p.h:73
QQuickTextUtil::alignedY
static qreal alignedY(qreal textHeight, qreal itemHeight, int alignment)
Definition
qquicktextutil.cpp:63
QQuickTextUtil::textRenderType
static T::RenderType textRenderType()
Definition
qquicktextutil_p.h:95
QQuickTextUtil::setCursorDelegate
static void setCursorDelegate(Private *d, QQmlComponent *delegate)
Definition
qquicktextutil_p.h:48
QRectF
\inmodule QtCore\reentrant
Definition
qrect.h:484
statusChanged
void statusChanged(QQmlComponent::Status status)
[1]
Definition
qlogging.cpp:11
alignment
uint alignment
Definition
doc_src_styles.cpp:74
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
QT_END_NAMESPACE
Definition
qsharedpointer.cpp:1590
Access::Private
@ Private
SLOT
#define SLOT(a)
Definition
qobjectdefs.h:52
SIGNAL
#define SIGNAL(a)
Definition
qobjectdefs.h:53
component
static qreal component(const QPointF &point, unsigned int i)
Definition
qpathclipper.cpp:626
Q_OBJECT
#define Q_OBJECT
Definition
qtmetamacros.h:119
Q_EMIT
#define Q_EMIT
Definition
qtmetamacros.h:47
qreal
double qreal
Definition
qtypes.h:187
className
const char className[16]
[1]
Definition
qwizard.cpp:100
disconnect
myObject disconnect()
[26]
d
double d
Definition
src_corelib_text_qlocale.cpp:9
qtdeclarative
src
quick
items
qquicktextutil_p.h
Generated by
1.10.0