1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2010 Dawit Alemayehu <adawit@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KPARTS_FILEINFOEXTENSION_H
9#define KPARTS_FILEINFOEXTENSION_H
10
11#include <kparts/kparts_export.h>
12
13#include <KFileItem>
14#include <QObject>
15#include <memory>
16
17class KFileItemList;
18
19namespace KParts
20{
21class ReadOnlyPart;
22class FileInfoExtensionPrivate;
23
24/*!
25 * \class KParts::FileInfoExtension
26 * \inheaderfile KParts/FileInfoExtension
27 * \inmodule KParts
28 *
29 * \brief An extension for obtaining file information from the part.
30 *
31 * This extension provides information about file and directory resources
32 * that are present in the part the implements it.
33 *
34 * The main purpose of for this extension is to provide information about
35 * files and directories located on remote servers so that download managers
36 * such as kget can easily retrieve these resources.
37 *
38 * \since 4.6
39 */
40class KPARTS_EXPORT FileInfoExtension : public QObject
41{
42 Q_OBJECT
43
44public:
45 /*!
46 * Supported file information retrieval modes.
47 *
48 * \value None Querying for file information is NOT possible
49 * \value AllItems Retrieve or can retrieve file information for all items
50 * \value SelectedItems Retrieve or can retrieve file information for selected items
51 */
52 enum QueryMode {
53 None = 0x00,
54 AllItems = 0x01,
55 SelectedItems = 0x02,
56 };
57 Q_DECLARE_FLAGS(QueryModes, QueryMode)
58
59 /*!
60 *
61 */
62 explicit FileInfoExtension(KParts::ReadOnlyPart *parent);
63
64 ~FileInfoExtension() override;
65
66 /*!
67 * Queries \a obj for a child object which inherits from this class.
68 */
69 static FileInfoExtension *childObject(QObject *obj);
70
71 /*!
72 * Returns \c true if any of the items in the current view of the part that
73 * implements this extension are selected.
74 *
75 * By default this function returns \c false.
76 */
77 virtual bool hasSelection() const;
78
79 /*!
80 * Returns the file information retrieve modes supported by the part
81 * that implements this extension.
82 *
83 * By default this function returns None.
84 */
85 virtual QueryModes supportedQueryModes() const;
86
87 /*!
88 * Returns a information for files that match the specified query \a mode.
89 *
90 * If the mode specified by \a mode is not supported or cannot be
91 * handled, then an empty list is returned.
92 */
93 virtual KFileItemList queryFor(QueryMode mode) const = 0;
94
95private:
96 std::unique_ptr<FileInfoExtensionPrivate> const d;
97};
98
99Q_DECLARE_OPERATORS_FOR_FLAGS(FileInfoExtension::QueryModes)
100
101}
102
103#endif /* KPARTS_FILEINFOEXTENSION_H */
104

source code of kparts/src/fileinfoextension.h