kutils Library API Documentation

KCModuleProxy Class Reference

Encapsulates a KCModule for embedding. More...

#include <kcmoduleproxy.h>

Inheritance diagram for KCModuleProxy:

QWidget List of all members.

Public Slots

void runAsRoot ()
void defaults ()
void deleteClient ()

Signals

void changed (bool state)
void changed (KCModuleProxy *mod)
void childClosed ()
void quickHelpChanged ()

Public Member Functions

 KCModuleProxy (const KCModuleInfo &info, bool withFallback=true, QWidget *parent=0, const char *name=0, const QStringList &args=QStringList())
 KCModuleProxy (const QString &serviceName, bool withFallback=true, QWidget *parent=0, const char *name=0, const QStringList &args=QStringList())
 KCModuleProxy (const KService::Ptr &service, bool withFallback=true, QWidget *parent=0, const char *name=0, const QStringList &args=QStringList())
 ~KCModuleProxy ()
void load ()
void save ()
QString quickHelp () const
const KAboutDataaboutData () const
int buttons () const
QString rootOnlyMsg () const
bool useRootOnlyMsg () const
KInstanceinstance () const
bool changed () const
bool rootMode () const
KCModulerealModule () const
const KCModuleInfomoduleInfo () const
QCString dcopName () const

Protected Member Functions

void showEvent (QShowEvent *)
void init (const KCModuleInfo &info)
void emitQuickHelpChanged ()

Friends

class KCModuleProxyRootCommunicatorImpl

Detailed Description

Encapsulates a KCModule for embedding.

KCModuleProxy is a wrapper for KCModule intended for cases where modules are to be displayed. It ensures layout is consistent, handles root/administrator modules and in general takes care of the details needed for making a module available in an interface. A KCModuleProxy can be treated as a QWidget, without worrying about the details specific for modules such as library loading. KCModuleProxy is not a sub class of KCModule but its API closely resembles KCModule's.
Usually, an instance is created by passing one of the constructors a KService::Ptr, KCModuleInfo or simply the name of the module and then added to the layout as any other widget.
When the user have changed the module, changed( bool ) as well as changed ( KCModuleProxy * ) is emitted. KCModuleProxy does not take care of prompting for saving - if the object is deleted while changes is not saved the changes will be lost. changed() returns true if changes are unsaved.

KCModuleProxy does not take care of authorization of KCModules.
KCModuleProxy do lazy loading, meaning the library will not be loaded or any other initialization done before its show() function is called. This means modules will only be loaded when they are actually needed as well as it is possible to load many KCModuleProxy without any speed penalty.

KCModuleProxy should be used in all cases where modules are embedded in order to promote code efficiency and usability consistency.

Author:
Frans Englich <frans.englich@telia.com>

Matthias Kretz <kretz@kde.org>

Definition at line 67 of file kcmoduleproxy.h.


Constructor & Destructor Documentation

KCModuleProxy::KCModuleProxy const KCModuleInfo info,
bool  withFallback = true,
QWidget parent = 0,
const char *  name = 0,
const QStringList args = QStringList()
 

Constructs a KCModuleProxy from a KCModuleInfo class.

Parameters:
info The KCModuleInfo to construct the module from.
withFallback If set to true and loading of the module fails, a alternative will be tried, resulting in the module appearing in its own window, if at all. The embedded module will be load()ed.
args This is used in the implementation and is internal. Use the default.

Definition at line 483 of file kcmoduleproxy.cpp.

References init().

KCModuleProxy::KCModuleProxy const QString serviceName,
bool  withFallback = true,
QWidget parent = 0,
const char *  name = 0,
const QStringList args = QStringList()
 

Constructs a KCModuleProxy from a module's service name, which is equivalent to the desktop file for the kcm without the ".desktop" part.

Otherwise equal to the one above.

Parameters:
serviceName The module's service name to construct from.

Definition at line 492 of file kcmoduleproxy.cpp.

References init().

KCModuleProxy::KCModuleProxy const KService::Ptr service,
bool  withFallback = true,
QWidget parent = 0,
const char *  name = 0,
const QStringList args = QStringList()
 

Constructs a KCModuleProxy from KService.

Otherwise equal to the one above.

Parameters:
service The KService to construct from.

Definition at line 474 of file kcmoduleproxy.cpp.

References init().

KCModuleProxy::~KCModuleProxy  ) 
 

Default destructor.

Definition at line 429 of file kcmoduleproxy.cpp.

References deleteClient(), and moduleInfo().


Member Function Documentation

void KCModuleProxy::load  ) 
 

Calling it will cause the contained module to run its load() routine.

Definition at line 516 of file kcmoduleproxy.cpp.

References realModule().

void KCModuleProxy::save  ) 
 

Calling it will cause the contained module to run its save() routine.

If the module was not modified, it will not be asked to save.

Definition at line 528 of file kcmoduleproxy.cpp.

References realModule().

QString KCModuleProxy::quickHelp  )  const
 

Returns:
the module's quickHelp();

Definition at line 560 of file kcmoduleproxy.cpp.

References endl(), kdDebug(), KCModule::quickHelp(), and realModule().

Referenced by realModule().

const KAboutData * KCModuleProxy::aboutData  )  const
 

Returns:
the module's aboutData()

Definition at line 589 of file kcmoduleproxy.cpp.

References KCModule::aboutData(), and realModule().

int KCModuleProxy::buttons  )  const
 

Returns:
what buttons the module needs

Definition at line 601 of file kcmoduleproxy.cpp.

References KCModule::buttons(), and realModule().

QString KCModuleProxy::rootOnlyMsg  )  const
 

Returns:
The module's custom root message, if it has one
Deprecated:

Definition at line 607 of file kcmoduleproxy.cpp.

References realModule(), and KCModule::rootOnlyMsg().

bool KCModuleProxy::useRootOnlyMsg  )  const
 

Returns:
If the module is a root module.
Deprecated:

Definition at line 612 of file kcmoduleproxy.cpp.

References realModule(), and KCModule::useRootOnlyMsg().

KInstance * KCModuleProxy::instance  )  const
 

Returns the embedded KCModule's KInstance.

Returns:
The module's KInstance.
Deprecated:

Definition at line 617 of file kcmoduleproxy.cpp.

References KCModule::instance(), and realModule().

bool KCModuleProxy::changed  )  const
 

Returns:
true if the module is modified and needs to be saved.

Definition at line 622 of file kcmoduleproxy.cpp.

Referenced by KCMultiDialog::addModule(), and realModule().

bool KCModuleProxy::rootMode  )  const
 

Returns whether the module is running in root mode.

A module is in root mode when runAsRoot() has been called. A session under root user will never reach root mode.

Note:
realModule() will return null when the module is running in root mode.
Returns:
true if the module is running with root privileges
Since:
3.4

Definition at line 632 of file kcmoduleproxy.cpp.

KCModule * KCModuleProxy::realModule  )  const
 

Access to the actual module.

However, if the module is running in root mode, see rootMode(), this function returns a NULL pointer, since the module is in another process. It may also return NULL if anything goes wrong.

Returns:
the encapsulated module.

Definition at line 140 of file kcmoduleproxy.cpp.

References changed(), endl(), KCModuleInfo::handle(), k_funcinfo, kdDebug(), moduleInfo(), and quickHelp().

Referenced by aboutData(), KCModuleContainer::addModule(), buttons(), defaults(), instance(), load(), quickHelp(), rootOnlyMsg(), save(), showEvent(), and useRootOnlyMsg().

const KCModuleInfo & KCModuleProxy::moduleInfo  )  const
 

Returns:
a KCModuleInfo for the encapsulated module

Definition at line 627 of file kcmoduleproxy.cpp.

Referenced by KCModuleContainer::addModule(), realModule(), runAsRoot(), and ~KCModuleProxy().

QCString KCModuleProxy::dcopName  )  const
 

Returns the DCOP the module's DCOPClient and DCOPObject has(they are identical).

Since:
3.4

Definition at line 637 of file kcmoduleproxy.cpp.

void KCModuleProxy::runAsRoot  )  [slot]
 

Calling this will cause the module to be run in "administrator mode".

Since:
3.4

Definition at line 298 of file kcmoduleproxy.cpp.

References deleteClient(), KStandardDirs::findExe(), moduleInfo(), and KCModuleInfo::service().

void KCModuleProxy::defaults  )  [slot]
 

Calling it will cause the contained module to load its default values.

Definition at line 552 of file kcmoduleproxy.cpp.

References realModule().

Referenced by KPluginSelector::defaults().

void KCModuleProxy::deleteClient  )  [slot]
 

Calling this, results in deleting the contained module, and unregistering from DCOP.

A similar result is achieved by deleting the KCModuleProxy itself.

Since:
3.4

Definition at line 437 of file kcmoduleproxy.cpp.

References endl(), and kdDebug().

Referenced by runAsRoot(), and ~KCModuleProxy().

void KCModuleProxy::changed KCModuleProxy mod  )  [signal]
 

This is emitted in the same situations as in the one above.

Practical when several KCModuleProxys are loaded.

Since:
3.4

void KCModuleProxy::childClosed  )  [signal]
 

When a module running with root privileges and exits, returns to normal mode, the childClosed() signal is emitted.

Since:
3.4

void KCModuleProxy::showEvent QShowEvent  )  [protected]
 

Reimplemented for internal purposes.

Makes sure the encapsulated module is loaded before the show event is taken care of.

Definition at line 284 of file kcmoduleproxy.cpp.

References endl(), k_funcinfo, kdDebug(), and realModule().

void KCModuleProxy::init const KCModuleInfo info  )  [protected]
 

Internal intialization function, called by the constructors.

Definition at line 502 of file kcmoduleproxy.cpp.

References endl(), k_funcinfo, and kdDebug().

Referenced by KCModuleProxy().

void KCModuleProxy::emitQuickHelpChanged  )  [protected]
 

Emits the quickHelpChanged signal.

Since:
3.4

Definition at line 642 of file kcmoduleproxy.cpp.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kutils Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Jul 21 13:14:48 2006 by doxygen 1.4.0 written by Dimitri van Heesch, © 1997-2003