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
4#include "qhelpsearchresult.h"
5
6#include <QtCore/qstring.h>
7#include <QtCore/qurl.h>
8
9QT_BEGIN_NAMESPACE
10
11class QHelpSearchResultData : public QSharedData
12{
13public:
14 QUrl m_url;
15 QString m_title;
16 QString m_snippet;
17};
18
19/*!
20 \class QHelpSearchResult
21 \since 5.9
22 \inmodule QtHelp
23 \brief The QHelpSearchResult class provides the data associated with the
24 search result.
25
26 The QHelpSearchResult object is a data object that describes a single search result.
27 The vector of search result objects is returned by QHelpSearchEngine::searchResults().
28 The description of the search result contains the document title and URL
29 that the search input matched. It also contains the snippet from
30 the document content containing the best match of the search input.
31 \sa QHelpSearchEngine
32*/
33
34/*!
35 Constructs a new empty QHelpSearchResult.
36*/
37QHelpSearchResult::QHelpSearchResult() : d(new QHelpSearchResultData) { }
38
39/*!
40 Constructs a copy of \a other.
41*/
42QHelpSearchResult::QHelpSearchResult(const QHelpSearchResult &other) = default;
43
44/*!
45 Constructs the search result containing \a url, \a title and \a snippet
46 as the description of the result.
47*/
48QHelpSearchResult::QHelpSearchResult(const QUrl &url, const QString &title, const QString &snippet)
49 : d(new QHelpSearchResultData)
50{
51 d->m_url = url;
52 d->m_title = title;
53 d->m_snippet = snippet;
54}
55
56/*!
57 Destroys the search result.
58*/
59QHelpSearchResult::~QHelpSearchResult() = default;
60
61/*!
62 Assigns \a other to this search result and returns a reference to this search result.
63*/
64QHelpSearchResult &QHelpSearchResult::operator=(const QHelpSearchResult &other) = default;
65
66/*!
67 Returns the document title of the search result.
68*/
69QString QHelpSearchResult::title() const
70{
71 return d->m_title;
72}
73
74/*!
75 Returns the document URL of the search result.
76*/
77QUrl QHelpSearchResult::url() const
78{
79 return d->m_url;
80}
81
82/*!
83 Returns the document snippet containing the search phrase of the search result.
84*/
85QString QHelpSearchResult::snippet() const
86{
87 return d->m_snippet;
88}
89
90QT_END_NAMESPACE
91

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qttools/src/assistant/help/qhelpsearchresult.cpp