Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
link.cpp
Go to the documentation of this file.
1
// Copyright (C) 2025 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4
#
include
"link.h"
5
6
QT_BEGIN_NAMESPACE
7
8
using
namespace
Qt::Literals::StringLiterals;
9
10
namespace
IR
{
11
12
/*!
13
\struct IR::Link
14
\brief Intermediate representation for a resolved hyperlink.
15
16
Link represents a fully-resolved link in QDoc's intermediate representation
17
layer. All target resolution happens during the IR building phase, so templates
18
receive only pre-computed URLs and display text. This eliminates the need for
19
generators to perform database lookups during output generation.
20
21
\sa IR::Document
22
*/
23
24
/*!
25
\enum IR::Link::State
26
Indicates the resolution state of the link target.
27
28
\value Resolved Link target was found and resolved.
29
\value External Link points to an external resource.
30
\value Unresolved Target not found (will produce warning).
31
\value Broken Target explicitly marked as broken.
32
*/
33
34
35
/*!
36
Converts the Link to a QJsonObject for template rendering.
37
38
The JSON structure uses camelCase field names following the established
39
IR-to-JSON convention. The state is represented as a string for readability
40
in templates: "resolved", "external", "unresolved", or "broken".
41
42
Returns a QJsonObject containing all link data suitable for template
43
rendering via InjaBridge.
44
*/
45
QJsonObject
Link
::
toJson
()
const
46
{
47
QJsonObject json;
48
json[
"target"_L1
] = target;
49
json[
"text"_L1
] = text;
50
51
if
(!title.isEmpty())
52
json[
"title"_L1
] = title;
53
54
QString stateStr;
55
switch
(
state
) {
56
case
State
::
Resolved
:
57
stateStr =
"resolved"_L1
;
58
break
;
59
case
State
::
External
:
60
stateStr =
"external"_L1
;
61
break
;
62
case
State
::
Unresolved
:
63
stateStr =
"unresolved"_L1
;
64
break
;
65
case
State
::
Broken
:
66
stateStr =
"broken"_L1
;
67
break
;
68
}
69
json[
"state"_L1
] = stateStr;
70
71
json[
"isResolved"_L1
] = (state == State::Resolved);
72
json[
"isExternal"_L1
] = (state == State::External);
73
74
if
(!originalTarget.isEmpty() && originalTarget != target)
75
json[
"originalTarget"_L1
] = originalTarget;
76
77
return
json;
78
}
79
80
}
// namespace IR
81
82
QT_END_NAMESPACE
IR
Definition
builder.cpp:14
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
IR::Link
Intermediate representation for a resolved hyperlink.
Definition
link.h:15
IR::Link::state
State state
Definition
link.h:27
IR::Link::toJson
QJsonObject toJson() const
Converts the Link to a QJsonObject for template rendering.
Definition
link.cpp:45
IR::Link::State
State
Optional title/tooltip attribute.
Definition
link.h:20
IR::Link::State::Unresolved
@ Unresolved
Definition
link.h:23
IR::Link::State::External
@ External
Definition
link.h:22
IR::Link::State::Broken
@ Broken
Definition
link.h:24
IR::Link::State::Resolved
@ Resolved
Definition
link.h:21
qttools
src
qdoc
qdoc
src
qdoc
ir
link.cpp
Generated on
for Qt by
1.18.0