| 1 | // Copyright (C) 2018 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 | |
| 4 | #include "qhelpfilterdata.h" |
| 5 | |
| 6 | #include <QtCore/qversionnumber.h> |
| 7 | |
| 8 | QT_BEGIN_NAMESPACE |
| 9 | |
| 10 | class QHelpFilterDataPrivate : public QSharedData |
| 11 | { |
| 12 | public: |
| 13 | QHelpFilterDataPrivate() = default; |
| 14 | QHelpFilterDataPrivate(const QHelpFilterDataPrivate &other) |
| 15 | : QSharedData(other) |
| 16 | , m_components(other.m_components) |
| 17 | , m_versions(other.m_versions) |
| 18 | {} |
| 19 | |
| 20 | QStringList m_components; |
| 21 | QList<QVersionNumber> m_versions; |
| 22 | }; |
| 23 | |
| 24 | /*! |
| 25 | \class QHelpFilterData |
| 26 | \since 5.13 |
| 27 | \inmodule QtHelp |
| 28 | \brief The QHelpFilterData class provides details for the filters |
| 29 | used by QHelpFilterEngine. |
| 30 | |
| 31 | By using setComponents() you may constrain the search results to |
| 32 | documents that belong only to components specified on the given list. |
| 33 | By using setVersions() you may constrain the search results to |
| 34 | documents that belong only to versions specified on the given list. |
| 35 | |
| 36 | \sa QHelpFilterEngine |
| 37 | */ |
| 38 | |
| 39 | /*! |
| 40 | Constructs the empty filter. |
| 41 | */ |
| 42 | QHelpFilterData::QHelpFilterData() : d(new QHelpFilterDataPrivate) { } |
| 43 | |
| 44 | /*! |
| 45 | Constructs a copy of \a other. |
| 46 | */ |
| 47 | QHelpFilterData::QHelpFilterData(const QHelpFilterData &) = default; |
| 48 | |
| 49 | /*! |
| 50 | Move-constructs a QHelpFilterData instance, making it point at the same object that \a other was pointing to. |
| 51 | */ |
| 52 | QHelpFilterData::QHelpFilterData(QHelpFilterData &&) = default; |
| 53 | |
| 54 | /*! |
| 55 | Destroys the filter. |
| 56 | */ |
| 57 | QHelpFilterData::~QHelpFilterData() = default; |
| 58 | |
| 59 | /*! |
| 60 | Assigns \a other to this filter and returns a reference to this filter. |
| 61 | */ |
| 62 | QHelpFilterData &QHelpFilterData::operator=(const QHelpFilterData &) = default; |
| 63 | |
| 64 | /*! |
| 65 | Move-assigns \a other to this QHelpFilterData instance. |
| 66 | */ |
| 67 | QHelpFilterData &QHelpFilterData::operator=(QHelpFilterData &&) = default; |
| 68 | |
| 69 | /*! |
| 70 | \fn void QHelpFilterData::swap(QHelpFilterData &other) |
| 71 | |
| 72 | Swaps the filter \a other with this filter. This |
| 73 | operation is very fast and never fails. |
| 74 | */ |
| 75 | |
| 76 | bool QHelpFilterData::operator==(const QHelpFilterData &other) const |
| 77 | { |
| 78 | return (d->m_components == other.d->m_components && d->m_versions == other.d->m_versions); |
| 79 | } |
| 80 | |
| 81 | /*! |
| 82 | Specifies the component list that is used for filtering |
| 83 | the search results. Only results from components in the list |
| 84 | \a components shall be returned. |
| 85 | */ |
| 86 | void QHelpFilterData::setComponents(const QStringList &components) |
| 87 | { |
| 88 | d->m_components = components; |
| 89 | } |
| 90 | |
| 91 | /*! |
| 92 | Specifies the version list that is used for filtering |
| 93 | the search results. Only results from versions in the list |
| 94 | \a versions shall be returned. |
| 95 | */ |
| 96 | void QHelpFilterData::setVersions(const QList<QVersionNumber> &versions) |
| 97 | { |
| 98 | d->m_versions = versions; |
| 99 | } |
| 100 | |
| 101 | /*! |
| 102 | Returns the component list that is used for filtering |
| 103 | the search results. |
| 104 | */ |
| 105 | QStringList QHelpFilterData::components() const |
| 106 | { |
| 107 | return d->m_components; |
| 108 | } |
| 109 | |
| 110 | /*! |
| 111 | Returns the version list that is used for filtering |
| 112 | the search results. |
| 113 | */ |
| 114 | QList<QVersionNumber> QHelpFilterData::versions() const |
| 115 | { |
| 116 | return d->m_versions; |
| 117 | } |
| 118 | |
| 119 | QT_END_NAMESPACE |
| 120 |
