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

KDE's Doxygen guidelines are available online.