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
19class KFileItemListPropertiesPrivate;
20class KFileItemList;
21
22/**
23 * @class KFileItemListProperties kfileitemlistproperties.h <KFileItemListProperties>
24 *
25 * @brief Provides information about the common properties of a group of
26 * KFileItem objects.
27 *
28 * Given a list of KFileItems, this class can determine (and cache) the common
29 * MIME type for all items, whether all items are directories, whether all items
30 * are readable, writable, etc.
31 * As soon as one file item does not support a specific capability (read, write etc.),
32 * it is marked as unsupported for all items.
33 *
34 * This class is implicitly shared, which means it can be used as a value and
35 * copied around at almost no cost.
36 *
37 */
38class KIOCORE_EXPORT KFileItemListProperties
39{
40public:
41 /**
42 * @brief Default constructor. Use setItems to specify the items.
43 */
44 KFileItemListProperties();
45 /**
46 * @brief Constructor that takes a KFileItemList and sets the capabilities
47 * supported by all the FileItems as true.
48 * @param items The list of items that are to have their supported
49 * capabilities checked.
50 */
51 KFileItemListProperties(const KFileItemList &items);
52 /**
53 * @brief Copy constructor
54 */
55 KFileItemListProperties(const KFileItemListProperties &);
56 /**
57 * @brief Destructor
58 */
59 virtual ~KFileItemListProperties();
60 /**
61 * @brief Assignment operator
62 */
63 KFileItemListProperties &operator=(const KFileItemListProperties &other);
64 /**
65 * Sets the items that are to have their supported capabilities checked.
66 */
67 void setItems(const KFileItemList &items);
68
69 /**
70 * @brief Check if reading capability is supported
71 * @return true if all the FileItems can be read, otherwise false.
72 */
73 bool supportsReading() const;
74 /**
75 * @brief Check if deleting capability is supported
76 * @return true if all the FileItems can be deleted, otherwise false.
77 */
78 bool supportsDeleting() const;
79 /**
80 * @brief Check if writing capability is supported
81 * (file managers use this mostly for directories)
82 * @return true if all the FileItems can be written to, otherwise false.
83 */
84 bool supportsWriting() const;
85 /**
86 * @brief Check if moving capability is supported
87 * @return true if all the FileItems can be moved, otherwise false.
88 */
89 bool supportsMoving() const;
90 /**
91 * @brief Check if files are local
92 * @return true if all the FileItems are local, otherwise there is one or more
93 * remote file, so false.
94 */
95 bool isLocal() const;
96
97 /**
98 * List of fileitems passed to the constructor or to setItems().
99 */
100 KFileItemList items() const;
101
102 /**
103 * List of urls, gathered from the fileitems
104 */
105 QList<QUrl> urlList() const;
106
107 /**
108 * @return true if all items are directories
109 */
110 bool isDirectory() const;
111
112 /**
113 * @return Whether all items are files, as reported by KFileItem::isFile().
114 * @since 5.47
115 */
116 bool isFile() const;
117
118 /**
119 * @return the MIME type of all items, if they all have the same, otherwise an empty string
120 */
121 QString mimeType() const;
122
123 /**
124 * @return the MIME type group (e.g. "text") of all items, if they all have the same, otherwise an empty string
125 */
126 QString mimeGroup() const;
127
128private:
129 /** @brief d-pointer */
130 QSharedDataPointer<KFileItemListPropertiesPrivate> d;
131};
132
133#endif /* KFILEITEMLISTPROPERTIES_H */
134

source code of kio/src/core/kfileitemlistproperties.h