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
locationplanlookup.cpp
Go to the documentation of this file.
1
// Copyright (C) 2026 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
"locationplan.h"
5
6
#
include
<
QtCore
/
qdir
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
using
namespace
Qt::StringLiterals;
11
12
LocationPlan
::
LocationPlan
(
LocationRules
rules, EntityLocations entities)
13
:
m_rules
(
std
::
move
(
rules
)),
m_entities
(
std
::
move
(
entities
))
14
{
15
}
16
17
LocationPlan
::LocationPlan(
LocationRules
rules) :
LocationPlan
(
std
::move(rules), {}) { }
18
19
/*!
20
Returns the planned location of \a node. Returns no value when the entity
21
is not published; querying the plan never invents a publication location.
22
*/
23
std
::optional<
PublicationLocation
>
LocationPlan
::
entity
(
const
Node
*node)
const
24
{
25
if
(
const
auto
it = m_entities.constFind(node); it != m_entities.constEnd())
26
return
it.value();
27
return
std
::nullopt;
28
}
29
30
QString
PublicationLocation
::
href
()
const
31
{
32
return
explicitUrl || fragment.isEmpty() ? path : path + u'#' + fragment;
33
}
34
35
/*!
36
Returns the location of \a node as one link target, or an empty string
37
when the entity is not published. This is the form the index export writes.
38
*/
39
QString
LocationPlan
::
documentLocation
(
const
Node
*node)
const
40
{
41
const
auto
location = entity(node);
42
return
location ? location->href() : QString();
43
}
44
45
/*!
46
Adds a published \a format at \a outputDir, with its completed \a plan.
47
Finish building the set before handing it to renderers.
48
*/
49
void
LocationPlanSet
::add(QString format, QString outputDir,
LocationPlan
plan)
50
{
51
m_publications.insert_or_assign(std::move(format),
52
Publication{ std::move(outputDir), std::move(plan) });
53
}
54
55
const
LocationPlan
*
LocationPlanSet
::plan(
const
QString &format)
const
56
{
57
const
auto
it = m_publications.find(format);
58
return
it == m_publications.end() ?
nullptr
: &it->second.plan;
59
}
60
61
/*!
62
Resolves \a node in \a format, then in published HTML. The result is relative
63
to \a relativeDir. Explicit URLs retain their original spelling. Neither
64
lookup nor path relativization requires output files to exist.
65
*/
66
std
::optional<
PublicationLocation
>
LocationPlanSet
::entity(
const
Node
*node,
67
const
QString &format,
68
const
QString &relativeDir)
const
69
{
70
const
auto
lookup = [&](
const
QString &candidate) ->
std
::optional<
PublicationLocation
> {
71
const
auto
it = m_publications.find(candidate);
72
if
(it == m_publications.end())
73
return
std::nullopt;
74
auto
location = it->second.plan.entity(node);
75
if
(location && !location->explicitUrl) {
76
const
QString path = QDir(it->second.outputDir).absoluteFilePath(location->path);
77
location->path = QDir(relativeDir).relativeFilePath(path);
78
}
79
return
location;
80
};
81
if
(
auto
location = lookup(format))
82
return
location;
83
return
format ==
"HTML"_L1
? std::nullopt : lookup(u"HTML"_s);
84
}
85
86
QT_END_NAMESPACE
LocationPlanSet
Definition
locationplan.h:78
LocationPlan
\variable PublicationLocation::path
Definition
locationplan.h:45
LocationPlan::LocationPlan
LocationPlan(LocationRules rules, EntityLocations entities)
Definition
locationplanlookup.cpp:12
LocationPlan::documentLocation
QString documentLocation(const Node *node) const
Returns the location of node as one link target, or an empty string when the entity is not published.
Definition
locationplanlookup.cpp:39
LocationPlan::entity
std::optional< PublicationLocation > entity(const Node *node) const
Returns the planned location of node.
Definition
locationplanlookup.cpp:23
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
LocationRules
Holds the configuration a format needs to name its published files.
Definition
locationplan.h:23
Node
The Node class is the base class for all the nodes in QDoc's parse tree.
Definition
src_corelib_text_qstring.cpp:10
PublicationLocation
\variable LocationRules::fileExtension
Definition
locationplan.h:36
PublicationLocation::href
QString href() const
Definition
locationplanlookup.cpp:30
qttools
src
qdoc
qdoc
src
qdoc
locationplanlookup.cpp
Generated on
for Qt by
1.18.0