1 | /* |
2 | This file is part of the KDE Baloo Project |
3 | SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
6 | */ |
7 | |
8 | #ifndef EXTRACTIONRESULT_H |
9 | #define |
10 | |
11 | #include <KFileMetaData/ExtractionResult> |
12 | |
13 | #include "document.h" |
14 | #include "termgenerator.h" |
15 | |
16 | /** |
17 | * \class Result result.h |
18 | * |
19 | * \brief The result class is where all the data extracted by |
20 | * the KFileMetaData extractors is saved to. |
21 | * It implements the KFileMetaData::ExtractionResult interface. |
22 | * The results can be retrieved as a Baloo::Document using |
23 | * \c document() and stored in the database. |
24 | * |
25 | */ |
26 | class Result : public KFileMetaData::ExtractionResult |
27 | { |
28 | public: |
29 | Result(); |
30 | (const QString& url, const QString& mimetype, const Flags& flags = ExtractMetaData | ExtractPlainText); |
31 | |
32 | void add(KFileMetaData::Property::Property property, const QVariant& value) override; |
33 | void append(const QString& text) override; |
34 | void addType(KFileMetaData::Type::Type type) override; |
35 | |
36 | /** |
37 | * Can be used to add extraction results to an existing |
38 | * Baloo::Document. Has to be called before passing the |
39 | * Result to KFileMetaData::Extractor::extract(). |
40 | * \param doc The Baloo::Document |
41 | */ |
42 | void setDocument(const Baloo::Document& doc); |
43 | |
44 | /** |
45 | * Returns the Baloo document to which the results from the extractors |
46 | * are saved. |
47 | */ |
48 | Baloo::Document& document() { |
49 | return m_doc; |
50 | } |
51 | |
52 | /** |
53 | * Applies the finishing touches on the document, and makes |
54 | * it ready to be pushed into the db. |
55 | */ |
56 | void finish(); |
57 | |
58 | private: |
59 | /** |
60 | * The document that represents the file that is to be indexed. |
61 | */ |
62 | Baloo::Document m_doc; |
63 | /** |
64 | * Contains the position state of the metadata and adds it to the document. |
65 | */ |
66 | Baloo::TermGenerator m_termGen; |
67 | /** |
68 | * Contains the position state of plain text and adds it to the document. |
69 | */ |
70 | Baloo::TermGenerator m_termGenForText; |
71 | /** |
72 | * Contains all indexed property data from the extractors. |
73 | */ |
74 | KFileMetaData::PropertyMultiMap m_map; |
75 | }; |
76 | |
77 | #endif // EXTRACTIONRESULT_H |
78 | |