KService

kservicetype.h
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 1998, 1999 Torben Weis <[email protected]>
4  SPDX-FileCopyrightText: 1999 Waldo Bastian <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #ifndef __kservicetype_h__
10 #define __kservicetype_h__
11 
12 #include <ksycocaentry.h>
13 
14 #include <QMap>
15 #include <QString>
16 #include <QStringList>
17 #include <QVariant>
18 
19 #include <KConfig>
20 
21 class KDesktopFile;
22 class KServiceTypePrivate;
23 
24 /**
25  * @class KServiceType kservicetype.h <KServiceType>
26  *
27  * A service type is, well, a type of service, where a service is an application or plugin.
28  * For instance, "KOfficeFilter", which is the type of all koffice filters, is a service type.
29  * In order to discover services of a given type, using KServiceTypeTrader.
30  * Service types are stored as desktop files in $KDEDIR/share/servicetypes.
31  * @see KService, KServiceTypeTrader
32  * @deprecated Since 5.90, this class is an implementation detail of KService.
33  * Use @ref KService or @ref KApplicationTrader instead.
34  */
35 class KSERVICE_EXPORT KServiceType : public KSycocaEntry // TODO KDE5: inherit kshared, but move KSycocaEntry to KServiceTypePrivate
36 {
37 public:
38  /**
39  * A shared data pointer for KServiceType.
40  */
42  /**
43  * A list of shared data pointers for KServiceType.
44  */
45  typedef QList<Ptr> List;
46 
47  /**
48  * Construct a service type and take all information from a desktop file.
49  * @param config the configuration file
50  * @deprecated Since 5.90, see class API docs
51  */
52  KSERVICE_DEPRECATED_VERSION(5, 90, "See class API docs")
53  explicit KServiceType(KDesktopFile *config);
54 
55  ~KServiceType() override;
56 
57  /**
58  * Returns the descriptive comment associated, if any.
59  * @return the comment, or QString()
60  */
61  QString comment() const;
62 
63  /**
64  * Checks whether this service type inherits another one.
65  * @return true if this service type inherits another one
66  * @see parentServiceType()
67  */
68  bool isDerived() const;
69 
70  /**
71  * If this service type inherits from another service type,
72  * return the name of the parent.
73  * @return the parent service type, or QString:: null if not set
74  * @see isDerived()
75  */
76  QString parentServiceType() const;
77 
78  /**
79  * Checks whether this service type is or inherits from @p servTypeName.
80  * @return true if this servicetype is or inherits from @p servTypeName
81  */
82  bool inherits(const QString &servTypeName) const;
83 
84  /**
85  * Returns the type of the property definition with the given @p _name.
86  *
87  * @param _name the name of the property
88  * @return the property type, or null if not found
89  * @see propertyDefNames
90  */
91  QVariant::Type propertyDef(const QString &_name) const;
92 
93  /**
94  * Returns the list of all property definitions for this servicetype.
95  * Those are properties of the services implementing this servicetype.
96  * For instance,
97  * @code
98  * [PropertyDef::X-KDevelop-Version]
99  * Type=int
100  * @endcode
101  * means that all kdevelop plugins have in their .desktop file a line like
102  * @code
103  * X-KDevelop-Version=<some value>
104  * @endcode
105  */
106  QStringList propertyDefNames() const;
107 
108  /// @internal (for KBuildServiceTypeFactory)
109  QMap<QString, QVariant::Type> propertyDefs() const;
110 
111  /**
112  * @internal
113  * Pointer to parent service type
114  */
115  Ptr parentType();
116  /**
117  * @internal only used by kbuildsycoca
118  * Register offset into offers list
119  */
120  void setServiceOffersOffset(int offset);
121  /**
122  * @internal
123  */
124  int serviceOffersOffset() const;
125 
126  /**
127  * Returns a pointer to the servicetype '_name' or @c nullptr if the
128  * service type is unknown.
129  * VERY IMPORTANT : don't store the result in a KServiceType * !
130  * @param _name the name of the service type to search
131  * @return the pointer to the service type, or @c nullptr
132  */
133  static Ptr serviceType(const QString &_name);
134 
135  /**
136  * Returns a list of all the supported servicetypes. Useful for
137  * showing the list of available servicetypes in a listbox,
138  * for example.
139  * More memory consuming than the ones above, don't use unless
140  * really necessary.
141  * @return the list of all services
142  */
143  static List allServiceTypes();
144 
145 private:
146  friend class KServiceTypeFactory;
147  /**
148  * @internal construct a service from a stream.
149  * The stream must already be positioned at the correct offset
150  */
151  KServiceType(QDataStream &_str, int offset);
152 
153  Q_DECLARE_PRIVATE(KServiceType)
154 };
155 
156 // QDataStream& operator>>( QDataStream& _str, KServiceType& s );
157 // QDataStream& operator<<( QDataStream& _str, KServiceType& s );
158 
159 #endif
A service type is, well, a type of service, where a service is an application or plugin.
Definition: kservicetype.h:35
Base class for all Sycoca entries.
Definition: ksycocaentry.h:32
QExplicitlySharedDataPointer< KServiceType > Ptr
A shared data pointer for KServiceType.
Definition: kservicetype.h:41
QList< Ptr > List
A list of shared data pointers for KServiceType.
Definition: kservicetype.h:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jan 20 2022 22:43:38 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.