1 | /* This file is part of the KDE project |
2 | Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at> |
3 | Copyright (C) 2008 by George Goldberg <grundleborg@googlemail.com> |
4 | Copyright 2009 David Faure <faure@kde.org> |
5 | |
6 | This library is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU Library General Public License as published |
8 | by the Free Software Foundation; either version 2 of the License or |
9 | ( at your option ) version 3 or, at the discretion of KDE e.V. |
10 | ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. |
11 | |
12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #ifndef KFILEITEMLISTPROPERTIES_H |
24 | #define KFILEITEMLISTPROPERTIES_H |
25 | |
26 | #include <kio/kio_export.h> |
27 | |
28 | #include <kurl.h> |
29 | #include <QtCore/QSharedDataPointer> |
30 | |
31 | class KFileItemListPropertiesPrivate; |
32 | class KFileItemList; |
33 | |
34 | /** |
35 | * @brief Provides information about the common properties of a group of |
36 | * KFileItem objects. |
37 | * |
38 | * Given a list of KFileItems, this class can determine (and cache) the common |
39 | * mimetype for all items, whether all items are directories, whether all items |
40 | * are readable, writable, etc. |
41 | * As soon as one file item does not support a specific capability (read, write etc.), |
42 | * it is marked as unsupported for all items. |
43 | * |
44 | * This class is implicitly shared, which means it can be used as a value and |
45 | * copied around at almost no cost. |
46 | * |
47 | * @since 4.3 |
48 | */ |
49 | class KIO_EXPORT KFileItemListProperties |
50 | { |
51 | public: |
52 | /** |
53 | * @brief Default constructor. Use setItems to specify the items. |
54 | */ |
55 | KFileItemListProperties(); |
56 | /** |
57 | * @brief Constructor that takes a KFileItemList and sets the capabilities |
58 | * supported by all the FileItems as true. |
59 | * @param items The list of items that are to have their supported |
60 | * capabilities checked. |
61 | */ |
62 | KFileItemListProperties(const KFileItemList& items); |
63 | /** |
64 | * @brief Copy constructor |
65 | */ |
66 | KFileItemListProperties(const KFileItemListProperties&); |
67 | /** |
68 | * @brief Destructor |
69 | */ |
70 | virtual ~KFileItemListProperties(); |
71 | /** |
72 | * @brief Assignment operator |
73 | */ |
74 | KFileItemListProperties& operator=(const KFileItemListProperties& other); |
75 | /** |
76 | * Sets the items that are to have their supported capabilities checked. |
77 | */ |
78 | void setItems(const KFileItemList& items); |
79 | |
80 | /** |
81 | * @brief Check if reading capability is supported |
82 | * @return true if all the FileItems can be read, otherwise false. |
83 | */ |
84 | bool supportsReading() const; |
85 | /** |
86 | * @brief Check if deleting capability is supported |
87 | * @return true if all the FileItems can be deleted, otherwise false. |
88 | */ |
89 | bool supportsDeleting() const; |
90 | /** |
91 | * @brief Check if writing capability is supported |
92 | * (file managers use this mostly for directories) |
93 | * @return true if all the FileItems can be written to, otherwise false. |
94 | */ |
95 | bool supportsWriting() const; |
96 | /** |
97 | * @brief Check if moving capability is supported |
98 | * @return true if all the FileItems can be moved, otherwise false. |
99 | */ |
100 | bool supportsMoving() const; |
101 | /** |
102 | * @brief Check if files are local |
103 | * @return true if all the FileItems are local, otherwise there is one or more |
104 | * remote file, so false. |
105 | */ |
106 | bool isLocal() const; |
107 | |
108 | /** |
109 | * List of fileitems passed to the constructor or to setItems(). |
110 | */ |
111 | KFileItemList items() const; |
112 | |
113 | /** |
114 | * List of urls, gathered from the fileitems |
115 | */ |
116 | KUrl::List urlList() const; |
117 | |
118 | /** |
119 | * @return true if all items are directories |
120 | */ |
121 | bool isDirectory() const; |
122 | |
123 | /** |
124 | * @return the mimetype of all items, if they all have the same, otherwise empty |
125 | */ |
126 | QString mimeType() const; |
127 | |
128 | /** |
129 | * @return the mimetype group (e.g. "text") of all items, if they all have the same, otherwise empty |
130 | */ |
131 | QString mimeGroup() const; |
132 | |
133 | private: |
134 | /** @brief d-pointer */ |
135 | QSharedDataPointer<KFileItemListPropertiesPrivate> d; |
136 | }; |
137 | |
138 | #endif /* KFILEITEMLISTPROPERTIES_H */ |
139 | |
140 | |