Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* This file is part of the KDE project
2 Copyright 2007 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KSERVICEACTION_H
21#define KSERVICEACTION_H
22
23#include <kdecore_export.h>
24#include <QtCore/QSharedDataPointer>
25class QVariant;
26class KServiceActionPrivate;
27
28/**
29 * Represents an action in a .desktop file
30 * Actions are defined with the config key Actions in the [Desktop Entry]
31 * group, followed by one group per action, as per the desktop entry standard.
32 * @see KService::actions
33 */
34class KDECORE_EXPORT KServiceAction
35{
36public:
37 /**
38 * Creates a KServiceAction.
39 * Normally you don't have to do this, KService creates the actions
40 * when parsing the .desktop file.
41 */
42 KServiceAction(const QString& name, const QString& text,
43 const QString& icon, const QString& exec,
44 bool noDisplay = false);
45 /**
46 * @internal
47 * Needed for operator>>
48 */
49 KServiceAction();
50 /**
51 * Destroys a KServiceAction.
52 */
53 ~KServiceAction();
54
55 /**
56 * Copy constructor
57 */
58 KServiceAction(const KServiceAction& other);
59 /**
60 * Assignment operator
61 */
62 KServiceAction& operator=(const KServiceAction& other);
63
64 /**
65 * Sets the action's internal data to the given @p userData.
66 */
67 void setData( const QVariant& userData );
68 /**
69 * @return the action's internal data.
70 */
71 QVariant data() const;
72
73 /**
74 * @return the action's internal name
75 * For instance Actions=Setup;... and the group [Desktop Action Setup]
76 * define an action with the name "Setup".
77 */
78 QString name() const;
79
80 /**
81 * @return the action's text, as defined by the Name key in the desktop action group
82 */
83 QString text() const;
84
85 /**
86 * @return the action's icon, as defined by the Icon key in the desktop action group
87 */
88 QString icon() const;
89
90 /**
91 * @return the action's exec command, as defined by the Exec key in the desktop action group
92 */
93 QString exec() const;
94
95 /**
96 * Returns whether the action should be suppressed in menus.
97 * This is useful for having actions with a known name that the code
98 * looks for explicitly, like Setup and Root for kscreensaver actions,
99 * and which should not appear in popup menus.
100 * @return true to suppress this service
101 */
102 bool noDisplay() const;
103
104 /**
105 * Returns whether the action is a separator.
106 * This is true when the Actions key contains "_SEPARATOR_".
107 */
108 bool isSeparator() const;
109
110private:
111 QSharedDataPointer<KServiceActionPrivate> d;
112 friend KDECORE_EXPORT QDataStream& operator>>( QDataStream& str, KServiceAction& act );
113 friend KDECORE_EXPORT QDataStream& operator<<( QDataStream& str, const KServiceAction& act );
114};
115
116KDECORE_EXPORT QDataStream& operator>>( QDataStream& str, KServiceAction& act );
117KDECORE_EXPORT QDataStream& operator<<( QDataStream& str, const KServiceAction& act );
118
119#endif /* KSERVICEACTION_H */
120
121

Warning: That file was not part of the compilation database. It may have many parsing errors.