| 1 | /* |
| 2 | This file is part of the KDE project |
| 3 | SPDX-FileCopyrightText: 2008 Peter Penz <peter.penz@gmx.at> |
| 4 | SPDX-FileCopyrightText: 2008 George Goldberg <grundleborg@googlemail.com> |
| 5 | SPDX-FileCopyrightText: 2009 David Faure <faure@kde.org> |
| 6 | |
| 7 | SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 8 | */ |
| 9 | |
| 10 | #ifndef KFILEITEMLISTPROPERTIES_H |
| 11 | #define KFILEITEMLISTPROPERTIES_H |
| 12 | |
| 13 | #include "kiocore_export.h" |
| 14 | |
| 15 | #include <QList> |
| 16 | #include <QSharedDataPointer> |
| 17 | #include <QUrl> |
| 18 | |
| 19 | class KFileItemListPropertiesPrivate; |
| 20 | class KFileItemList; |
| 21 | |
| 22 | /*! |
| 23 | * \class KFileItemListProperties |
| 24 | * \inmodule KIOCore |
| 25 | * |
| 26 | * \brief Provides information about the common properties of a group of |
| 27 | * KFileItem objects. |
| 28 | * |
| 29 | * Given a list of KFileItems, this class can determine (and cache) the common |
| 30 | * MIME type for all items, whether all items are directories, whether all items |
| 31 | * are readable, writable, etc. |
| 32 | * As soon as one file item does not support a specific capability (read, write etc.), |
| 33 | * it is marked as unsupported for all items. |
| 34 | * |
| 35 | * This class is implicitly shared, which means it can be used as a value and |
| 36 | * copied around at almost no cost. |
| 37 | */ |
| 38 | class KIOCORE_EXPORT KFileItemListProperties |
| 39 | { |
| 40 | public: |
| 41 | /*! |
| 42 | * Default constructor. Use setItems to specify the items. |
| 43 | */ |
| 44 | KFileItemListProperties(); |
| 45 | |
| 46 | /*! |
| 47 | * Constructor that takes a KFileItemList and sets the capabilities |
| 48 | * supported by all the FileItems as true. |
| 49 | * |
| 50 | * \a items The list of items that are to have their supported |
| 51 | * capabilities checked. |
| 52 | */ |
| 53 | KFileItemListProperties(const KFileItemList &items); |
| 54 | |
| 55 | /*! |
| 56 | * Copy constructor |
| 57 | */ |
| 58 | KFileItemListProperties(const KFileItemListProperties &); |
| 59 | |
| 60 | virtual ~KFileItemListProperties(); |
| 61 | |
| 62 | KFileItemListProperties &operator=(const KFileItemListProperties &other); |
| 63 | |
| 64 | /*! |
| 65 | * Sets the items that are to have their supported capabilities checked. |
| 66 | */ |
| 67 | void setItems(const KFileItemList &items); |
| 68 | |
| 69 | /*! |
| 70 | * Check if reading capability is supported |
| 71 | * |
| 72 | * Returns \c true if all the FileItems can be read, otherwise false. |
| 73 | */ |
| 74 | bool supportsReading() const; |
| 75 | |
| 76 | /*! |
| 77 | * Check if deleting capability is supported |
| 78 | * |
| 79 | * Returns \c true if all the FileItems can be deleted, otherwise false. |
| 80 | */ |
| 81 | bool supportsDeleting() const; |
| 82 | |
| 83 | /*! |
| 84 | * Check if writing capability is supported |
| 85 | * (file managers use this mostly for directories) |
| 86 | * |
| 87 | * Returns \c true if all the FileItems can be written to, otherwise false. |
| 88 | */ |
| 89 | bool supportsWriting() const; |
| 90 | |
| 91 | /*! |
| 92 | * Check if moving capability is supported |
| 93 | * |
| 94 | * Returns \c true if all the FileItems can be moved, otherwise false. |
| 95 | */ |
| 96 | bool supportsMoving() const; |
| 97 | |
| 98 | /*! |
| 99 | * Check if files are local |
| 100 | * |
| 101 | * Returns \c true if all the FileItems are local, otherwise there is one or more |
| 102 | * remote file, so false. |
| 103 | */ |
| 104 | bool isLocal() const; |
| 105 | |
| 106 | /*! |
| 107 | * List of fileitems passed to the constructor or to setItems(). |
| 108 | */ |
| 109 | KFileItemList items() const; |
| 110 | |
| 111 | /*! |
| 112 | * List of urls, gathered from the fileitems |
| 113 | */ |
| 114 | QList<QUrl> urlList() const; |
| 115 | |
| 116 | /*! |
| 117 | * Returns \c true if all items are directories |
| 118 | */ |
| 119 | bool isDirectory() const; |
| 120 | |
| 121 | /*! |
| 122 | * Returns whether all items are files, as reported by KFileItem::isFile(). |
| 123 | * \since 5.47 |
| 124 | */ |
| 125 | bool isFile() const; |
| 126 | |
| 127 | /*! |
| 128 | * Returns the MIME type of all items, if they all have the same, otherwise an empty string |
| 129 | */ |
| 130 | QString mimeType() const; |
| 131 | |
| 132 | /*! |
| 133 | * Returns the MIME type group (e.g. "text") of all items, if they all have the same, otherwise an empty string |
| 134 | */ |
| 135 | QString mimeGroup() const; |
| 136 | |
| 137 | private: |
| 138 | QSharedDataPointer<KFileItemListPropertiesPrivate> d; |
| 139 | }; |
| 140 | |
| 141 | #endif /* KFILEITEMLISTPROPERTIES_H */ |
| 142 | |