home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kcmoduleinfo.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-10-08  |  7.0 KB  |  297 lines

  1. /*
  2.   Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
  3.   Copyright (c) 2000 Matthias Elter <elter@kde.org>
  4.   Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
  5.   Copyright (c) 2003 Matthias Kretz <kretz@kde.org>
  6.  
  7.   This file is part of the KDE project
  8.  
  9.   This library is free software; you can redistribute it and/or
  10.   modify it under the terms of the GNU Library General Public
  11.   License version 2, as published by the Free Software Foundation.
  12.  
  13.   This library is distributed in the hope that it will be useful,
  14.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.   Library General Public License for more details.
  17.  
  18.   You should have received a copy of the GNU Library General Public License
  19.   along with this library; see the file COPYING.LIB.  If not, write to
  20.   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21.   Boston, MA 02110-1301, USA.
  22. */
  23.  
  24. #ifndef KCMODULEINFO_H
  25. #define KCMODULEINFO_H
  26.  
  27. #include <kservice.h>
  28.  
  29. class QPixmap;
  30. class QString;
  31. class QStringList;
  32.  
  33. /**
  34.  * @ingroup kcmodule
  35.  * A class that provides information about a KCModule
  36.  *
  37.  * KCModuleInfo provides various technical information, such as icon, library
  38.  * etc. about a KCModule.n
  39.  * @note Any values set with the set* functions is not
  40.  * written back with KCModuleInfo it only reads value from the desktop file.
  41.  *
  42.  * @internal
  43.  * @author Matthias Hoelzer-Kluepfel <mhk@kde.org>
  44.  * @author Matthias Elter <elter@kde.org>
  45.  * @author Daniel Molkentin <molkentin@kde.org>
  46.  * @since 3.2
  47.  *
  48.  */
  49. class KUTILS_EXPORT KCModuleInfo
  50. {
  51.  
  52. public:
  53.  
  54.   /**
  55.    * Constructs a KCModuleInfo.
  56.    * @note a KCModuleInfo object will have to be manually deleted, it is not
  57.    * done automatically for you.
  58.    * @param desktopFile the desktop file representing the module, or
  59.    * the name of the module.
  60.    */
  61.   KCModuleInfo(const QString& desktopFile);
  62.  
  63.   /**
  64.    * Same as above but takes a KService::Ptr as argument.
  65.    *
  66.    * @note @p moduleInfo must be a valid pointer.
  67.    *
  68.    * @param moduleInfo specifies the module
  69.    */
  70.   KCModuleInfo( KService::Ptr moduleInfo );
  71.  
  72.  
  73.   /**
  74.    * Same as above but takes a KCModuleInfo as argument.
  75.    *
  76.    * @param rhs specifies the module
  77.    */
  78.   KCModuleInfo( const KCModuleInfo &rhs );
  79.  
  80.   /**
  81.    * Same as above but creates an empty KCModuleInfo.
  82.    * You should not normally call this.
  83.    * @since 3.4
  84.    */
  85.   KCModuleInfo();
  86.  
  87.   /**
  88.    * Assignment operator
  89.    */
  90.   KCModuleInfo &operator=( const KCModuleInfo &rhs );
  91.  
  92.   /**
  93.    * Equal operator
  94.    *
  95.    * @return true if @p rhs equals itself
  96.    */
  97.  
  98.   bool operator==( const KCModuleInfo &rhs ) const;
  99.  
  100.   /**
  101.    * @return true if @p rhs is not equal itself
  102.    */
  103.   bool operator!=( const KCModuleInfo &rhs ) const;
  104.  
  105.   /**
  106.    * Default destructor.
  107.    */
  108.   ~KCModuleInfo();
  109.  
  110.   /**
  111.    * @return the filename of the .desktop file that describes the KCM
  112.    */
  113.   QString fileName() const { return _fileName; }
  114.  
  115.   /**
  116.    * @return the keywords associated with this KCM.
  117.    */
  118.   const QStringList &keywords() const { return _keywords; }
  119.  
  120.   /**
  121.    * Returns the module's factory name, if it's set. If not, the library
  122.    * name is returned.
  123.    * @returns the module's factory name
  124.    * @since 3.4
  125.    */
  126.   QString factoryName() const;
  127.  
  128.   /**
  129.    * @return the module\'s (translated) name
  130.    */
  131.   QString moduleName() const { return _name; }
  132.   // changed from name() to avoid ambiguity with QObject::name() on multiple inheritance
  133.  
  134.   /**
  135.    * @return a KSharedPtr to KService created from the modules .desktop file
  136.    */
  137.   KService::Ptr service() const { return _service; }
  138.  
  139.   /**
  140.    * @return the module's (translated) comment field
  141.    */
  142.   QString comment() const { return _comment; }
  143.  
  144.   /**
  145.    * @return the module's icon name
  146.    */
  147.   QString icon() const { return _icon; }
  148.  
  149.   /**
  150.    * @return the path of the module's documentation
  151.    */
  152.   QString docPath() const;
  153.  
  154.   /**
  155.    * @return the library name
  156.    */
  157.   QString library() const { return _lib; }
  158.  
  159.   /**
  160.    * @return a handle (usually the contents of the FactoryName field)
  161.    */
  162.   QString handle() const;
  163.  
  164.   /**
  165.    * @return the weight of the module which determines the order of the pages in
  166.    * the KCMultiDialog. It's set by the X-KDE-Weight field.
  167.    */
  168.   int weight() const;
  169.  
  170.   /**
  171.    * @return whether the module might require root permissions
  172.    */
  173.   bool needsRootPrivileges() const;
  174.  
  175.   /**
  176.    * @deprecated
  177.    * @return the isHiddenByDefault attribute.
  178.    */
  179.   bool isHiddenByDefault() const KDE_DEPRECATED;
  180.  
  181.  
  182.   /**
  183.    * @returns true if the module should be conditionally
  184.    * loaded.
  185.    * @since 3.4
  186.    */
  187.   bool needsTest() const;
  188.  
  189.  
  190. protected:
  191.  
  192.   /**
  193.    * Sets the object's keywords.
  194.    * @param keyword the new keywords
  195.    */
  196.   void setKeywords(const QStringList &keyword) { _keywords = keyword; }
  197.  
  198.   /**
  199.    * Sets the object's name.
  200.    * @param name the new name
  201.    */
  202.   void setName(const QString &name) { _name = name; }
  203.  
  204.   /**
  205.    * Sets the object's name.
  206.    * @param comment the new comment
  207.    */
  208.   void setComment(const QString &comment) { _comment = comment; }
  209.  
  210.   /**
  211.    * Sets the object's icon.
  212.    * @param icon the name of the new icon
  213.    */
  214.   void setIcon(const QString &icon) { _icon = icon; }
  215.  
  216.   /**
  217.    * Set the object's library
  218.    * @param lib the name of the new library without any extensions or prefixs.
  219.    */
  220.   void setLibrary(const QString &lib) { _lib = lib; }
  221.  
  222.   /**
  223.    * Sets the factory name
  224.    * @param handle The new factory name
  225.    */
  226.   void setHandle(const QString &handle) { _handle = handle; }
  227.  
  228.   /**
  229.    * Sets the object's weight property which determines in what
  230.    * order modules will be displayed. Default is 100.
  231.    *
  232.    * @param weight the new weight
  233.    */
  234.   void setWeight(int weight) { _weight = weight; }
  235.  
  236.  
  237.   /**
  238.    * Sets if the module should be tested for loading.
  239.    * @param val the value to set
  240.    * @since 3.4
  241.    */
  242.   void setNeedsTest( bool val );
  243.  
  244.   /**
  245.    * Toggles whether the represented module needs root privileges.
  246.    * Use with caution.
  247.    * @param needsRootPrivileges if module needs root privilges
  248.    */
  249.   void setNeedsRootPrivileges(bool needsRootPrivileges)
  250.   { _needsRootPrivileges = needsRootPrivileges; }
  251.  
  252.   /**
  253.    * @deprecated
  254.    */
  255.   void setIsHiddenByDefault(bool isHiddenByDefault)
  256.   { _isHiddenByDefault = isHiddenByDefault; }
  257.  
  258.   /**
  259.    * Sets the object's documentation path
  260.    * @param p the new documentation path
  261.    */
  262.   void setDocPath(const QString &p) { _doc = p; }
  263.  
  264.   /**
  265.    * Reads the service entries specific for KCModule from the desktop file.
  266.    * The usual desktop entries are read in init.
  267.    */
  268.   void loadAll();
  269.  
  270. private:
  271.  
  272.   /**
  273.    * Reads the service entries. Called by the constructors.
  274.    */
  275.   void init(KService::Ptr s);
  276.  
  277. private:
  278.  
  279.   // KDE4 These needs to be moved to KCModuleInfoPrivate
  280.   QStringList _keywords;
  281.   QString     _name, _icon, _lib, _handle, _fileName, _doc, _comment;
  282.   bool        _needsRootPrivileges : 1;
  283.   bool        _isHiddenByDefault : 1;
  284.   bool        _allLoaded : 1;
  285.   int         _weight;
  286.  
  287.   KService::Ptr _service;
  288.  
  289.   class KCModuleInfoPrivate;
  290.   KCModuleInfoPrivate *d;
  291.  
  292. };
  293.  
  294. #endif // KCMODULEINFO_H
  295.  
  296. // vim: ts=2 sw=2 et
  297.