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
5
6#include <QtCore/qstring.h>
7#include <QtCore/qurl.h>
8
10
19
20/*!
21 \class QHelpContentItem
22 \inmodule QtHelp
23 \brief The QHelpContentItem class provides an item for use with QHelpContentModel.
24 \since 4.4
25*/
26
27QHelpContentItem::QHelpContentItem(const QString &name, const QUrl &link, QHelpContentItem *parent)
28 : d(new QHelpContentItemPrivate{name, link, parent})
29{
30 if (parent)
31 parent->d->childItems.append(this);
32}
33
34/*!
35 Destroys the help content item.
36*/
37QHelpContentItem::~QHelpContentItem()
38{
39 qDeleteAll(d->childItems);
40 delete d;
41}
42
43/*!
44 Returns the child of the content item in the give \a row.
45
46 \sa parent()
47*/
48QHelpContentItem *QHelpContentItem::child(int row) const
49{
50 return d->childItems.value(row);
51}
52
53/*!
54 Returns the number of child items.
55*/
56int QHelpContentItem::childCount() const
57{
58 return d->childItems.size();
59}
60
61/*!
62 Returns the row of this item from its parents view.
63*/
64int QHelpContentItem::row() const
65{
66 // TODO: Optimize by keeping the index internally.
67 return d->parent ? d->parent->d->childItems.indexOf(const_cast<QHelpContentItem*>(this)) : 0;
68}
69
70/*!
71 Returns the title of the content item.
72*/
73QString QHelpContentItem::title() const
74{
75 return d->title;
76}
77
78/*!
79 Returns the URL of this content item.
80*/
81QUrl QHelpContentItem::url() const
82{
83 return d->link;
84}
85
86/*!
87 Returns the parent content item.
88*/
89QHelpContentItem *QHelpContentItem::parent() const
90{
91 return d->parent;
92}
93
94/*!
95 Returns the position of a given \a child.
96*/
97int QHelpContentItem::childPosition(QHelpContentItem *child) const
98{
99 return d->childItems.indexOf(child);
100}
101
102QT_END_NAMESPACE
QList< QHelpContentItem * > childItems
QHelpContentItem * parent