summaryrefslogtreecommitdiffstats
path: root/kutils/tdecmoduleinfo.h
blob: 0bd7c44e36080d5e82a381c40c4fbcbe62a984c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/*
  Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
  Copyright (c) 2000 Matthias Elter <elter@kde.org>
  Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
  Copyright (c) 2003 Matthias Kretz <kretz@kde.org>

  This file is part of the KDE project

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public
  License version 2, as published by the Free Software Foundation.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.

  You should have received a copy of the GNU Library General Public License
  along with this library; see the file COPYING.LIB.  If not, write to
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA 02110-1301, USA.
*/

#ifndef KCMODULEINFO_H
#define KCMODULEINFO_H

#include <kservice.h>

class TQPixmap;
class TQString;
class TQStringList;

/**
 * @ingroup tdecmodule
 * A class that provides information about a TDECModule
 *
 * TDECModuleInfo provides various technical information, such as icon, library
 * etc. about a TDECModule.n
 * @note Any values set with the set* functions is not
 * written back with TDECModuleInfo it only reads value from the desktop file.
 *
 * @internal
 * @author Matthias Hoelzer-Kluepfel <mhk@kde.org>
 * @author Matthias Elter <elter@kde.org>
 * @author Daniel Molkentin <molkentin@kde.org>
 * @since 3.2
 *
 */
class KUTILS_EXPORT TDECModuleInfo
{

public:

  /**
   * Constructs a TDECModuleInfo.
   * @note a TDECModuleInfo object will have to be manually deleted, it is not
   * done automatically for you.
   * @param desktopFile the desktop file representing the module, or
   * the name of the module.
   */
  TDECModuleInfo(const TQString& desktopFile);

  /**
   * Same as above but takes a KService::Ptr as argument.
   *
   * @note @p moduleInfo must be a valid pointer.
   *
   * @param moduleInfo specifies the module
   */
  TDECModuleInfo( KService::Ptr moduleInfo );


  /**
   * Same as above but takes a TDECModuleInfo as argument.
   *
   * @param rhs specifies the module
   */
  TDECModuleInfo( const TDECModuleInfo &rhs );

  /**
   * Same as above but creates an empty TDECModuleInfo.
   * You should not normally call this.
   * @since 3.4
   */
  TDECModuleInfo();

  /**
   * Assignment operator
   */
  TDECModuleInfo &operator=( const TDECModuleInfo &rhs );

  /**
   * Equal operator
   *
   * @return true if @p rhs equals itself
   */

  bool operator==( const TDECModuleInfo &rhs ) const;

  /**
   * @return true if @p rhs is not equal itself
   */
  bool operator!=( const TDECModuleInfo &rhs ) const;

  /**
   * Default destructor.
   */
  ~TDECModuleInfo();

  /**
   * @return the filename of the .desktop file that describes the KCM
   */
  TQString fileName() const { return _fileName; }

  /**
   * @return the keywords associated with this KCM.
   */
  const TQStringList &keywords() const { return _keywords; }

  /**
   * Returns the module's factory name, if it's set. If not, the library
   * name is returned.
   * @returns the module's factory name
   * @since 3.4
   */
  TQString factoryName() const;

  /**
   * @return the module\'s (translated) name
   */
  TQString moduleName() const { return _name; }
  // changed from name() to avoid ambiguity with TQObject::name() on multiple inheritance

  /**
   * @return a KSharedPtr to KService created from the modules .desktop file
   */
  KService::Ptr service() const { return _service; }

  /**
   * @return the module's (translated) comment field
   */
  TQString comment() const { return _comment; }

  /**
   * @return the module's icon name
   */
  TQString icon() const { return _icon; }

  /**
   * @return the path of the module's documentation
   */
  TQString docPath() const;

  /**
   * @return the library name
   */
  TQString library() const { return _lib; }

  /**
   * @return a handle (usually the contents of the FactoryName field)
   */
  TQString handle() const;

  /**
   * @return the weight of the module which determines the order of the pages in
   * the KCMultiDialog. It's set by the X-TDE-Weight field.
   */
  int weight() const;

  /**
   * @return whether the module might require root permissions
   */
  bool needsRootPrivileges() const;

  /**
   * @deprecated
   * @return the isHiddenByDefault attribute.
   */
  bool isHiddenByDefault() const KDE_DEPRECATED;


  /**
   * @returns true if the module should be conditionally
   * loaded.
   * @since 3.4
   */
  bool needsTest() const;


protected:

  /**
   * Sets the object's keywords.
   * @param keyword the new keywords
   */
  void setKeywords(const TQStringList &keyword) { _keywords = keyword; }

  /**
   * Sets the object's name.
   * @param name the new name
   */
  void setName(const TQString &name) { _name = name; }

  /**
   * Sets the object's name.
   * @param comment the new comment
   */
  void setComment(const TQString &comment) { _comment = comment; }

  /**
   * Sets the object's icon.
   * @param icon the name of the new icon
   */
  void setIcon(const TQString &icon) { _icon = icon; }

  /**
   * Set the object's library
   * @param lib the name of the new library without any extensions or prefixs.
   */
  void setLibrary(const TQString &lib) { _lib = lib; }

  /**
   * Sets the factory name
   * @param handle The new factory name
   */
  void setHandle(const TQString &handle) { _handle = handle; }

  /**
   * Sets the object's weight property which determines in what
   * order modules will be displayed. Default is 100.
   *
   * @param weight the new weight
   */
  void setWeight(int weight) { _weight = weight; }


  /**
   * Sets if the module should be tested for loading.
   * @param val the value to set
   * @since 3.4
   */
  void setNeedsTest( bool val );

  /**
   * Toggles whether the represented module needs root privileges.
   * Use with caution.
   * @param needsRootPrivileges if module needs root privilges
   */
  void setNeedsRootPrivileges(bool needsRootPrivileges)
  { _needsRootPrivileges = needsRootPrivileges; }

  /**
   * @deprecated
   */
  void setIsHiddenByDefault(bool isHiddenByDefault)
  { _isHiddenByDefault = isHiddenByDefault; }

  /**
   * Sets the object's documentation path
   * @param p the new documentation path
   */
  void setDocPath(const TQString &p) { _doc = p; }

  /**
   * Reads the service entries specific for TDECModule from the desktop file.
   * The usual desktop entries are read in init.
   */
  void loadAll();

private:

  /**
   * Reads the service entries. Called by the constructors.
   */
  void init(KService::Ptr s);

private:

  // KDE4 These needs to be moved to TDECModuleInfoPrivate
  TQStringList _keywords;
  TQString     _name, _icon, _lib, _handle, _fileName, _doc, _comment;
  bool        _needsRootPrivileges : 1;
  bool        _isHiddenByDefault : 1;
  bool        _allLoaded : 1;
  int         _weight;

  KService::Ptr _service;

  class TDECModuleInfoPrivate;
  TDECModuleInfoPrivate *d;

};

#endif // KCMODULEINFO_H

// vim: ts=2 sw=2 et