KFileMetaData

extractionresult.h
1 /*
2  SPDX-FileCopyrightText: 2013 Vishesh Handa <[email protected]>
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 
20 namespace KFileMetaData {
21 class 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 <[email protected]>
33  */
34 class KFILEMETADATA_EXPORT ExtractionResult
35 {
36 public:
37  /**
38  * @see Flags
39  */
40  enum Flag {
41  ExtractNothing = 0,
42  ExtractMetaData = 1,
43  ExtractPlainText = 2,
44  ExtractImageData = 4, ///< @since 5.76
45 #if KFILEMETADATA_ENABLE_DEPRECATED_SINCE(5, 76)
46  /// @deprecated since 5.76, specify explicitly
47  ExtractEverything KFILEMETADATA_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 76, "Specify flags explicitly") = (ExtractMetaData | ExtractPlainText)
48 #endif
49  };
50  /**
51  * Stores a combination of #Flag values.
52  */
53  Q_DECLARE_FLAGS(Flags, Flag)
54 
55  /**
56  * Create an ExtractionResult which can be passed be to Extractors. The
57  * extractors use the \p url, \p mimetype and \p flags in order to determine
58  * which file the data should be extracted from and which data should
59  * be extracted.
60  */
61  ExtractionResult(const QString& url, const QString& mimetype = QString(), const Flags& flags = Flags{ExtractPlainText | ExtractMetaData});
63  virtual ~ExtractionResult();
64 
65  /**
66  * The input url which the plugins will use to locate the file
67  */
68  QString inputUrl() const;
69 
70  /**
71  * The input mimetype. This mimetype should correspond with the
72  * mimetypes supported with the relevant plugin when it is being
73  * passed to the Extractor, or be a subtype thereof.
74  *
75  * \sa ExtractorCollection::fetchExtractors
76  * \sa ExtractorPlugin::supportedMimeType
77  */
78  QString inputMimetype() const;
79 
80  /**
81  * The flags which the extraction plugin should considering following
82  * when extracting metadata from the file
83  */
84  Flags inputFlags() const;
85 
86  /**
87  * This function is called by plugins when they wish for some plain
88  * text to be indexed without any property. This generally corresponds
89  * to the text content in a file
90  */
91  virtual void append(const QString& text) = 0;
92 
93  /**
94  * This function is called by the plugins when they wish to
95  * add a key value pair which should be indexed. This function may be
96  * called multiple times for the same key.
97  *
98  * \p property This specifies a property name. It should be one of the
99  * properties from the global list of properties.
100  *
101  * \p value The value of the property
102  */
103  virtual void add(Property::Property property, const QVariant& value) = 0;
104 
105  /**
106  * This function is called by the plugins.
107  * A type is a higher level classification of the file. A file can
108  * have multiple types, but mostly when it does, those types are related.
109  * Eg - Document and Presentation.
110  *
111  * Please choose one type from the list of available types
112  */
113  virtual void addType(Type::Type type) = 0;
114 
115  /**
116  * This function is called by the plugins.
117  *
118  * \p images The images to add
119  * \sa EmbeddedImageData
120  * @since 5.76
121  */
122  void addImageData(QMap<EmbeddedImageData::ImageType, QByteArray>&& images);
123 
124  /**
125  * Return embedded image data
126  *
127  * \sa Flags::ExtractImageData
128  * @since 5.76
129  */
131 
132 private:
133  const std::unique_ptr<ExtractionResultPrivate> d;
134 };
135 
136 Q_DECLARE_OPERATORS_FOR_FLAGS(ExtractionResult::Flags)
137 
138 }
139 
140 #endif // _KFILEMETADATA_EXTRACTIONRESULT_H
The ExtractionResult class is where all the data extracted by the indexer is saved....
QFlags< Flag > Flags
Stores a combination of Flag values.
Property
The Property enum contains all files property types that KFileMetaData manipulates.
Definition: properties.h:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 04:10:29 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.