File indexing completed on 2024-04-28 15:29:20
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2010 Dawit Alemayehu <adawit@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KPARTS_FILEINFOEXTENSION_H 0009 #define KPARTS_FILEINFOEXTENSION_H 0010 0011 #include <kparts/kparts_export.h> 0012 0013 #include <KFileItem> 0014 #include <QObject> 0015 #include <memory> 0016 0017 class KFileItemList; 0018 0019 namespace KParts 0020 { 0021 class ReadOnlyPart; 0022 class FileInfoExtensionPrivate; 0023 0024 /** 0025 * @class FileInfoExtension fileinfoextension.h <KParts/FileInfoExtension> 0026 * 0027 * @short An extension for obtaining file information from the part. 0028 * 0029 * This extension provides information about file and directory resources 0030 * that are present in the part the implements it. 0031 * 0032 * The main purpose of for this extension is to provide information about 0033 * files and directories located on remote servers so that download managers 0034 * such as kget can easily retrieve these resources. 0035 * 0036 * @since 4.6 0037 */ 0038 class KPARTS_EXPORT FileInfoExtension : public QObject 0039 { 0040 Q_OBJECT 0041 0042 public: 0043 /** 0044 * Supported file information retrieval modes. 0045 * @see QueryModes 0046 */ 0047 enum QueryMode { 0048 None = 0x00, /*!< Querying for file information is NOT possible */ 0049 AllItems = 0x01, /*!< Retrieve or can retrieve file information for all items.*/ 0050 SelectedItems = 0x02, /*!< Retrieve or can retrieve file information for selected items.*/ 0051 }; 0052 0053 /** 0054 * Stores a combination of #QueryMode values. 0055 */ 0056 Q_DECLARE_FLAGS(QueryModes, QueryMode) 0057 0058 /*! Constructor */ 0059 explicit FileInfoExtension(KParts::ReadOnlyPart *parent); 0060 0061 /*! Destructor */ 0062 ~FileInfoExtension() override; 0063 0064 /** 0065 * Queries @p obj for a child object which inherits from this class. 0066 */ 0067 static FileInfoExtension *childObject(QObject *obj); 0068 0069 /** 0070 * Returns true if any of the items in the current view of the part that 0071 * implements this extension are selected. 0072 * 0073 * By default this function returns false. 0074 */ 0075 virtual bool hasSelection() const; 0076 0077 /** 0078 * Returns the file information retrieve modes supported by the part 0079 * that implements this extension. 0080 * 0081 * By default this function returns None. 0082 */ 0083 virtual QueryModes supportedQueryModes() const; 0084 0085 /** 0086 * Returns a information for files that match the specified query @p mode. 0087 * 0088 * If the mode specified by @p mode is not supported or cannot be 0089 * handled, then an empty list is returned. 0090 */ 0091 virtual KFileItemList queryFor(QueryMode mode) const = 0; 0092 0093 private: 0094 std::unique_ptr<FileInfoExtensionPrivate> const d; 0095 }; 0096 0097 Q_DECLARE_OPERATORS_FOR_FLAGS(FileInfoExtension::QueryModes) 0098 0099 } 0100 0101 #endif /* KPARTS_FILEINFOEXTENSION_H */