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
6
7#include <QtCore/qstring.h>
8#include <QtCore/qurl.h>
9
11
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
28QHelpContentItem::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*/
38QHelpContentItem::~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*/
49QHelpContentItem *QHelpContentItem::child(int row) const
50{
51 return d->childItems.value(row);
52}
53
54/*!
55 Returns the number of child items.
56*/
57int QHelpContentItem::childCount() const
58{
59 return d->childItems.size();
60}
61
62/*!
63 Returns the row of this item from its parents view.
64*/
65int 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*/
74QString QHelpContentItem::title() const
75{
76 return d->title;
77}
78
79/*!
80 Returns the URL of this content item.
81*/
82QUrl QHelpContentItem::url() const
83{
84 return d->link;
85}
86
87/*!
88 Returns the parent content item.
89*/
90QHelpContentItem *QHelpContentItem::parent() const
91{
92 return d->parent;
93}
94
95/*!
96 Returns the position of a given \a child.
97*/
98int QHelpContentItem::childPosition(QHelpContentItem *child) const
99{
100 return d->childItems.indexOf(child);
101}
102
103QT_END_NAMESPACE
QList< QHelpContentItem * > childItems
QHelpContentItem * parent
Combined button and popup list for selecting options.