KIO

kfileitemlistproperties.h
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 2008 Peter Penz <[email protected]>
4  SPDX-FileCopyrightText: 2008 George Goldberg <[email protected]>
5  SPDX-FileCopyrightText: 2009 David Faure <[email protected]>
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 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  * @since 4.3
38  */
39 class KIOCORE_EXPORT KFileItemListProperties
40 {
41 public:
42  /**
43  * @brief Default constructor. Use setItems to specify the items.
44  */
46  /**
47  * @brief Constructor that takes a KFileItemList and sets the capabilities
48  * supported by all the FileItems as true.
49  * @param items The list of items that are to have their supported
50  * capabilities checked.
51  */
53  /**
54  * @brief Copy constructor
55  */
57  /**
58  * @brief Destructor
59  */
60  virtual ~KFileItemListProperties();
61  /**
62  * @brief Assignment operator
63  */
64  KFileItemListProperties &operator=(const KFileItemListProperties &other);
65  /**
66  * Sets the items that are to have their supported capabilities checked.
67  */
68  void setItems(const KFileItemList &items);
69 
70  /**
71  * @brief Check if reading capability is supported
72  * @return true if all the FileItems can be read, otherwise false.
73  */
74  bool supportsReading() const;
75  /**
76  * @brief Check if deleting capability is supported
77  * @return true if all the FileItems can be deleted, otherwise false.
78  */
79  bool supportsDeleting() const;
80  /**
81  * @brief Check if writing capability is supported
82  * (file managers use this mostly for directories)
83  * @return true if all the FileItems can be written to, otherwise false.
84  */
85  bool supportsWriting() const;
86  /**
87  * @brief Check if moving capability is supported
88  * @return true if all the FileItems can be moved, otherwise false.
89  */
90  bool supportsMoving() const;
91  /**
92  * @brief Check if files are local
93  * @return true if all the FileItems are local, otherwise there is one or more
94  * remote file, so false.
95  */
96  bool isLocal() const;
97 
98  /**
99  * List of fileitems passed to the constructor or to setItems().
100  */
101  KFileItemList items() const;
102 
103  /**
104  * List of urls, gathered from the fileitems
105  */
106  QList<QUrl> urlList() const;
107 
108  /**
109  * @return true if all items are directories
110  */
111  bool isDirectory() const;
112 
113  /**
114  * @return Whether all items are files, as reported by KFileItem::isFile().
115  * @since 5.47
116  */
117  bool isFile() const;
118 
119  /**
120  * @return the MIME type of all items, if they all have the same, otherwise an empty string
121  */
122  QString mimeType() const;
123 
124  /**
125  * @return the MIME type group (e.g. "text") of all items, if they all have the same, otherwise an empty string
126  */
127  QString mimeGroup() const;
128 
129 private:
130  /** @brief d-pointer */
132 };
133 
134 #endif /* KFILEITEMLISTPROPERTIES_H */
Provides information about the common properties of a group of KFileItem objects.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 03:55:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.