KFileMetaData

extractionresult.h
1/*
2 SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef _KFILEMETADATA_EXTRACTIONRESULT_H
8#define _KFILEMETADATA_EXTRACTIONRESULT_H
9
10#include <QString>
11#include <QVariant>
12
13#include <memory>
14
15#include "kfilemetadata_export.h"
16#include "embeddedimagedata.h"
17#include "properties.h"
18#include "types.h"
19
20namespace KFileMetaData {
21class ExtractionResultPrivate;
22/**
23 * \class ExtractionResult extractionresult.h <KFileMetaData/ExtractionResult>
24 *
25 * \brief The ExtractionResult class is where all the data extracted by
26 * the indexer is saved. This class acts as a base class which should be
27 * derived from and then passed to the relevant plugins.
28 *
29 * The derived class needs to implement 3 pure virtual functions through
30 * which it receives the extracted data.
31 *
32 * \author Vishesh Handa <me@vhanda.in>
33 */
34class KFILEMETADATA_EXPORT ExtractionResult
35{
36public:
37 /**
38 * @see Flags
39 */
40 enum Flag {
41 ExtractNothing = 0,
42 ExtractMetaData = 1,
43 ExtractPlainText = 2,
44 ExtractImageData = 4, ///< @since 5.76
45 };
46 /**
47 * Stores a combination of #Flag values.
48 */
49 Q_DECLARE_FLAGS(Flags, Flag)
50
51 /**
52 * Create an ExtractionResult which can be passed be to Extractors. The
53 * extractors use the \p url, \p mimetype and \p flags in order to determine
54 * which file the data should be extracted from and which data should
55 * be extracted.
56 */
57 ExtractionResult(const QString& url, const QString& mimetype = QString(), const Flags& flags = Flags{ExtractPlainText | ExtractMetaData});
59 virtual ~ExtractionResult();
60
61 /**
62 * The input url which the plugins will use to locate the file
63 */
64 QString inputUrl() const;
65
66 /**
67 * The input mimetype. This mimetype should correspond with the
68 * mimetypes supported with the relevant plugin when it is being
69 * passed to the Extractor, or be a subtype thereof.
70 *
71 * \sa ExtractorCollection::fetchExtractors
72 * \sa ExtractorPlugin::supportedMimeType
73 */
74 QString inputMimetype() const;
75
76 /**
77 * The flags which the extraction plugin should considering following
78 * when extracting metadata from the file
79 */
80 Flags inputFlags() const;
81
82 /**
83 * This function is called by plugins when they wish for some plain
84 * text to be indexed without any property. This generally corresponds
85 * to the text content in a file
86 */
87 virtual void append(const QString& text) = 0;
88
89 /**
90 * This function is called by the plugins when they wish to
91 * add a key value pair which should be indexed. This function may be
92 * called multiple times for the same key.
93 *
94 * \p property This specifies a property name. It should be one of the
95 * properties from the global list of properties.
96 *
97 * \p value The value of the property
98 */
99 virtual void add(Property::Property property, const QVariant& value) = 0;
100
101 /**
102 * This function is called by the plugins.
103 * A type is a higher level classification of the file. A file can
104 * have multiple types, but mostly when it does, those types are related.
105 * Eg - Document and Presentation.
106 *
107 * Please choose one type from the list of available types
108 */
109 virtual void addType(Type::Type type) = 0;
110
111 /**
112 * This function is called by the plugins.
113 *
114 * \p images The images to add
115 * \sa EmbeddedImageData
116 * @since 5.76
117 */
118 void addImageData(QMap<EmbeddedImageData::ImageType, QByteArray>&& images);
119
120 /**
121 * Return embedded image data
122 *
123 * \sa Flags::ExtractImageData
124 * @since 5.76
125 */
127
128private:
129 const std::unique_ptr<ExtractionResultPrivate> d;
130};
131
132Q_DECLARE_OPERATORS_FOR_FLAGS(ExtractionResult::Flags)
133
134} // namespace KFileMetaData
135
138
139#endif // _KFILEMETADATA_EXTRACTIONRESULT_H
The ExtractionResult class is where all the data extracted by the indexer is saved.
virtual void addType(Type::Type type)=0
This function is called by the plugins.
virtual void add(Property::Property property, const QVariant &value)=0
This function is called by the plugins when they wish to add a key value pair which should be indexed...
virtual void append(const QString &text)=0
This function is called by plugins when they wish for some plain text to be indexed without any prope...
<KFileMetaData/Properties>
Property
The Property enum contains all files property types that KFileMetaData manipulates.
Definition properties.h:23
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:53 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.