| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Assistant of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #include "qhelpdatainterface_p.h" |
| 41 | |
| 42 | QT_BEGIN_NAMESPACE |
| 43 | |
| 44 | /*! |
| 45 | \internal |
| 46 | \class QHelpDataContentItem |
| 47 | \since 4.4 |
| 48 | \brief The QHelpDataContentItem class provides an item which represents |
| 49 | a topic or section of the contents. |
| 50 | |
| 51 | Every item holds several pieces of information, most notably the title |
| 52 | which can later be displayed in a contents overview. The reference is used |
| 53 | to store a relative file link to the corresponding section in the |
| 54 | documentation. |
| 55 | */ |
| 56 | |
| 57 | /*! |
| 58 | Constructs a new content item with \a parent as parent item. |
| 59 | The constucted item has the title \a title and links to the |
| 60 | location specified by \a reference. |
| 61 | */ |
| 62 | QHelpDataContentItem::QHelpDataContentItem(QHelpDataContentItem *parent, |
| 63 | const QString &title, const QString &reference) |
| 64 | : m_title(title), m_reference(reference) |
| 65 | { |
| 66 | if (parent) |
| 67 | parent->m_children.append(t: this); |
| 68 | } |
| 69 | |
| 70 | /*! |
| 71 | Destructs the item and its children. |
| 72 | */ |
| 73 | QHelpDataContentItem::~QHelpDataContentItem() |
| 74 | { |
| 75 | qDeleteAll(c: m_children); |
| 76 | } |
| 77 | |
| 78 | /*! |
| 79 | Returns the title of the item. |
| 80 | */ |
| 81 | QString QHelpDataContentItem::title() const |
| 82 | { |
| 83 | return m_title; |
| 84 | } |
| 85 | |
| 86 | /*! |
| 87 | Returns the file reference of the item. |
| 88 | */ |
| 89 | QString QHelpDataContentItem::reference() const |
| 90 | { |
| 91 | return m_reference; |
| 92 | } |
| 93 | |
| 94 | /*! |
| 95 | Returns a list of all its child items. |
| 96 | */ |
| 97 | QList<QHelpDataContentItem*> QHelpDataContentItem::children() const |
| 98 | { |
| 99 | return m_children; |
| 100 | } |
| 101 | |
| 102 | bool QHelpDataIndexItem::operator==(const QHelpDataIndexItem &other) const |
| 103 | { |
| 104 | return (other.name == name) && (other.reference == reference); |
| 105 | } |
| 106 | |
| 107 | /*! |
| 108 | \internal |
| 109 | \class QHelpDataFilterSection |
| 110 | \since 4.4 |
| 111 | */ |
| 112 | |
| 113 | /*! |
| 114 | Constructs a help data filter section. |
| 115 | */ |
| 116 | QHelpDataFilterSection::QHelpDataFilterSection() |
| 117 | { |
| 118 | d = new QHelpDataFilterSectionData(); |
| 119 | } |
| 120 | |
| 121 | /*! |
| 122 | Adds the filter attribute \a filter to the filter attributes of |
| 123 | this section. |
| 124 | */ |
| 125 | void QHelpDataFilterSection::addFilterAttribute(const QString &filter) |
| 126 | { |
| 127 | d->filterAttributes.append(t: filter); |
| 128 | } |
| 129 | |
| 130 | /*! |
| 131 | Returns a list of all filter attributes defined for this section. |
| 132 | */ |
| 133 | QStringList QHelpDataFilterSection::filterAttributes() const |
| 134 | { |
| 135 | return d->filterAttributes; |
| 136 | } |
| 137 | |
| 138 | /*! |
| 139 | Adds the index item \a index to the list of indices. |
| 140 | */ |
| 141 | void QHelpDataFilterSection::addIndex(const QHelpDataIndexItem &index) |
| 142 | { |
| 143 | d->indices.append(t: index); |
| 144 | } |
| 145 | |
| 146 | /*! |
| 147 | Sets the filter sections list of indices to \a indices. |
| 148 | */ |
| 149 | void QHelpDataFilterSection::setIndices(const QList<QHelpDataIndexItem> &indices) |
| 150 | { |
| 151 | d->indices = indices; |
| 152 | } |
| 153 | |
| 154 | /*! |
| 155 | Returns the list of indices. |
| 156 | */ |
| 157 | QList<QHelpDataIndexItem> QHelpDataFilterSection::indices() const |
| 158 | { |
| 159 | return d->indices; |
| 160 | } |
| 161 | |
| 162 | /*! |
| 163 | Adds the top level content item \a content to the filter section. |
| 164 | */ |
| 165 | void QHelpDataFilterSection::addContent(QHelpDataContentItem *content) |
| 166 | { |
| 167 | d->contents.append(t: content); |
| 168 | } |
| 169 | |
| 170 | /*! |
| 171 | Sets the list of top level content items of the filter section to |
| 172 | \a contents. |
| 173 | */ |
| 174 | void QHelpDataFilterSection::setContents(const QList<QHelpDataContentItem*> &contents) |
| 175 | { |
| 176 | qDeleteAll(c: d->contents); |
| 177 | d->contents = contents; |
| 178 | } |
| 179 | |
| 180 | /*! |
| 181 | Returns a list of top level content items. |
| 182 | */ |
| 183 | QList<QHelpDataContentItem*> QHelpDataFilterSection::contents() const |
| 184 | { |
| 185 | return d->contents; |
| 186 | } |
| 187 | |
| 188 | /*! |
| 189 | Adds the file \a file to the filter section. |
| 190 | */ |
| 191 | void QHelpDataFilterSection::addFile(const QString &file) |
| 192 | { |
| 193 | d->files.append(t: file); |
| 194 | } |
| 195 | |
| 196 | /*! |
| 197 | Set the list of files to \a files. |
| 198 | */ |
| 199 | void QHelpDataFilterSection::setFiles(const QStringList &files) |
| 200 | { |
| 201 | d->files = files; |
| 202 | } |
| 203 | |
| 204 | /*! |
| 205 | Returns the list of files. |
| 206 | */ |
| 207 | QStringList QHelpDataFilterSection::files() const |
| 208 | { |
| 209 | return d->files; |
| 210 | } |
| 211 | |
| 212 | /*! |
| 213 | \internal |
| 214 | \class QHelpDataInterface |
| 215 | \since 4.4 |
| 216 | */ |
| 217 | |
| 218 | /*! |
| 219 | \fn QHelpDataInterface::QHelpDataInterface() |
| 220 | |
| 221 | Constructs a new help data interface. |
| 222 | */ |
| 223 | |
| 224 | /*! |
| 225 | \fn QHelpDataInterface::~QHelpDataInterface() |
| 226 | |
| 227 | Destroys the help data interface. |
| 228 | */ |
| 229 | |
| 230 | /*! |
| 231 | \fn QString QHelpDataInterface::namespaceName() const = 0 |
| 232 | |
| 233 | Returns the namespace name of the help data set. |
| 234 | */ |
| 235 | |
| 236 | /*! |
| 237 | \fn QString QHelpDataInterface::virtualFolder() const = 0 |
| 238 | |
| 239 | Returns the virtual folder of the help data set. |
| 240 | */ |
| 241 | |
| 242 | /*! |
| 243 | \fn QList<QHelpDataCustomFilter> QHelpDataInterface::customFilters () const = 0 |
| 244 | |
| 245 | Returns a list of custom filters. Defining custom filters is optional. |
| 246 | */ |
| 247 | |
| 248 | /*! |
| 249 | \fn QList<QHelpDataFilterSection> QHelpDataInterface::filterSections() const = 0 |
| 250 | |
| 251 | Returns a list of filter sections. |
| 252 | */ |
| 253 | |
| 254 | /*! |
| 255 | \fn QMap<QString, QVariant> QHelpDataInterface::metaData() const = 0 |
| 256 | |
| 257 | Returns a map of meta data. A meta data item can hold almost any data |
| 258 | and is identified by its name. |
| 259 | */ |
| 260 | |
| 261 | /*! |
| 262 | \fn QString QHelpDataInterface::rootPath() const = 0 |
| 263 | |
| 264 | Returns the root file path of the documentation data. All referenced file |
| 265 | path or links of content items are relative to this path. |
| 266 | */ |
| 267 | |
| 268 | QT_END_NAMESPACE |
| 269 | |