1/* This file is part of the KDE project
2 Copyright 2008 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Library General Public License as published
6 by the Free Software Foundation; either version 2 of the License or
7 ( at your option ) version 3 or, at the discretion of KDE e.V.
8 ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KONQ_POPUPMENUINFORMATION_H
22#define KONQ_POPUPMENUINFORMATION_H
23
24#include "konq_fileitemcapabilities.h"
25#include <kurl.h>
26
27class KFileItemListProperties;
28class KonqPopupMenuInformationPrivate;
29class KFileItemList;
30class QWidget;
31
32/**
33 * Holds the information about the items shown by KonqPopupMenu.
34 * This information is used by KonqMenuActions to insert the appropriate
35 * actions (for user-defined services and for associated applications),
36 * and by KonqPopupMenuPlugin for plugins to decide what to show.
37 *
38 * KonqPopupMenuInformation is implicitly shared, i.e. it can be used as a value and copied around at almost no cost.
39 *
40 * This class exists only for KonqPopupMenu plugins.
41 * Everything else should use KFileItemListProperties since 4.3.
42 */
43class LIBKONQ_EXPORT KonqPopupMenuInformation
44{
45public:
46 /**
47 * Constructor
48 */
49 KonqPopupMenuInformation();
50
51 /**
52 * Copy constructor
53 */
54 KonqPopupMenuInformation(const KonqPopupMenuInformation&);
55
56 /**
57 * Destructor
58 */
59 ~KonqPopupMenuInformation();
60
61 KonqPopupMenuInformation & operator=(const KonqPopupMenuInformation& o);
62
63 /**
64 * Sets the list of fileitems which the actions apply to.
65 * @deprecated use setItemListProperties
66 */
67 KDE_DEPRECATED void setItems(const KFileItemList& items);
68
69 /**
70 * Sets a list of items and their properties
71 * @since 4.3
72 */
73 void setItemListProperties(const KFileItemListProperties& items);
74
75 /**
76 * Returns the list of items and their properties
77 * @since 4.3
78 */
79 KFileItemListProperties itemListProperties() const;
80
81 /**
82 * List of fileitems
83 */
84 KFileItemList items() const;
85
86 /**
87 * List of urls, gathered from the fileitems
88 */
89 KUrl::List urlList() const;
90
91 /**
92 * Returns the capabilities of the items.
93 * For instance, if they are readonly, then no action should modify those files.
94 */
95 KonqFileItemCapabilities capabilities() const;
96
97 /**
98 * @return true if all items are directories
99 */
100 bool isDirectory() const;
101
102 /**
103 * @return the mimetype of all items, if they all have the same, otherwise empty
104 */
105 QString mimeType() const;
106
107 /**
108 * @return the mimetype group (e.g. "text") of all items, if they all have the same, otherwise empty
109 */
110 QString mimeGroup() const;
111
112 /**
113 * Call this to set a parent widget (e.g. for error message boxes, open with dialog, etc.)
114 */
115 void setParentWidget(QWidget* parentWidget);
116
117 /**
118 * Parent widget (e.g. for error message boxes, open with dialog, etc.)
119 */
120 QWidget* parentWidget() const;
121
122private:
123 QSharedDataPointer<KonqPopupMenuInformationPrivate> d;
124};
125
126#endif /* KONQ_POPUPMENUINFORMATION_H */
127