Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qhelpcontentitem.cpp
Go to the documentation of this file.
1
// Copyright (C) 2024 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
// Qt-Security score:significant reason:default
4
5
#
include
"qhelpcontentitem.h"
6
7
#
include
<
QtCore
/
qstring
.
h
>
8
#
include
<
QtCore
/
qurl
.
h
>
9
10
QT_BEGIN_NAMESPACE
11
12
class
QHelpContentItemPrivate
13
{
14
public
:
15
QString
title
;
16
QUrl
link
;
17
QHelpContentItem
*
parent
;
18
QList
<
QHelpContentItem
*>
childItems
= {};
19
};
20
21
/*!
22
\class QHelpContentItem
23
\inmodule QtHelp
24
\brief The QHelpContentItem class provides an item for use with QHelpContentModel.
25
\since 4.4
26
*/
27
28
QHelpContentItem::QHelpContentItem(
const
QString &name,
const
QUrl &link, QHelpContentItem *parent)
29
: d(
new
QHelpContentItemPrivate{name, link, parent})
30
{
31
if
(parent)
32
parent->d->childItems.append(
this
);
33
}
34
35
/*!
36
Destroys the help content item.
37
*/
38
QHelpContentItem::~QHelpContentItem()
39
{
40
qDeleteAll(d->childItems);
41
delete
d;
42
}
43
44
/*!
45
Returns the child of the content item in the give \a row.
46
47
\sa parent()
48
*/
49
QHelpContentItem *QHelpContentItem::child(
int
row)
const
50
{
51
return
d->childItems.value(row);
52
}
53
54
/*!
55
Returns the number of child items.
56
*/
57
int
QHelpContentItem::childCount()
const
58
{
59
return
d->childItems.size();
60
}
61
62
/*!
63
Returns the row of this item from its parents view.
64
*/
65
int
QHelpContentItem::row()
const
66
{
67
// TODO: Optimize by keeping the index internally.
68
return
d->parent ? d->parent->d->childItems.indexOf(
const_cast
<QHelpContentItem*>(
this
)) : 0;
69
}
70
71
/*!
72
Returns the title of the content item.
73
*/
74
QString QHelpContentItem::title()
const
75
{
76
return
d->title;
77
}
78
79
/*!
80
Returns the URL of this content item.
81
*/
82
QUrl QHelpContentItem::url()
const
83
{
84
return
d->link;
85
}
86
87
/*!
88
Returns the parent content item.
89
*/
90
QHelpContentItem *QHelpContentItem::parent()
const
91
{
92
return
d->parent;
93
}
94
95
/*!
96
Returns the position of a given \a child.
97
*/
98
int
QHelpContentItem::childPosition(QHelpContentItem *child)
const
99
{
100
return
d->childItems.indexOf(child);
101
}
102
103
QT_END_NAMESPACE
QHelpContentItemPrivate
Definition
qhelpcontentitem.cpp:13
QHelpContentItemPrivate::childItems
QList< QHelpContentItem * > childItems
Definition
qhelpcontentitem.cpp:18
QHelpContentItemPrivate::link
QUrl link
Definition
qhelpcontentitem.cpp:16
QHelpContentItemPrivate::parent
QHelpContentItem * parent
Definition
qhelpcontentitem.cpp:17
QHelpContentItemPrivate::title
QString title
Definition
qhelpcontentitem.cpp:15
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
qttools
src
assistant
help
qhelpcontentitem.cpp
Generated on
for Qt by
1.16.1