KComponentData

#include <kcomponentdata.h>

Inheritance diagram for KComponentData:

Public Types

enum  MainComponentRegistration { RegisterAsMainComponent, SkipMainComponentRegistration }
 

Public Member Functions

 KComponentData ()
 
 KComponentData (const KComponentData &)
 
 KComponentData (const QByteArray &componentName, const QByteArray &catalogName=QByteArray(), MainComponentRegistration registerAsMain=RegisterAsMainComponent)
 
 KComponentData (const K4AboutData &aboutData, MainComponentRegistration registerAsMain=RegisterAsMainComponent)
 
 KComponentData (const K4AboutData *aboutData, MainComponentRegistration registerAsMain=RegisterAsMainComponent)
 
virtual ~KComponentData ()
 
const K4AboutDataaboutData () const
 
QString catalogName () const
 
QString componentName () const
 
const KSharedConfig::Ptr & config () const
 
bool isValid () const
 
 operator KAboutData () const
 
bool operator!= (const KComponentData &rhs) const
 
KComponentDataoperator= (const KComponentData &)
 
bool operator== (const KComponentData &) const
 
void setAboutData (const K4AboutData &aboutData)
 

Static Public Member Functions

static const KComponentDataactiveComponent ()
 
static bool hasMainComponent ()
 
static const KComponentDatamainComponent ()
 
static void setActiveComponent (const KComponentData &d)
 

Protected Member Functions

void setConfigName (const QString &name)
 
virtual void virtual_hook (int id, void *data)
 

Detailed Description

Per component data.

This class holds a K4AboutData object or only a component name, and a KSharedConfig object. Those objects normally are different per component but the same per instance of one component.

The application component data can always be accessed using KComponentData::mainComponent() (or the convenience function KGlobal::dirs() and KSharedConfig::openConfig()) while the component data of the currently active component (mainly used for KParts) can be accessed using KGlobal::activeComponent().

Author
Torben Weis
Matthias Kretz kretz[email protected]@kde[email protected].org

Definition at line 51 of file kcomponentdata.h.

Constructor & Destructor Documentation

KComponentData::KComponentData ( )

Creates an invalid KComponentData object.

See also
isValid()

Definition at line 41 of file kcomponentdata.cpp.

KComponentData::KComponentData ( const KComponentData rhs)

Copy constructor.

It does not copy the data. The data is shared between the old and new objects.

Definition at line 46 of file kcomponentdata.cpp.

KComponentData::KComponentData ( const QByteArray componentName,
const QByteArray catalogName = QByteArray(),
MainComponentRegistration  registerAsMain = RegisterAsMainComponent 
)
explicit

Constructor.

Parameters
componentNamethe name of the component.
catalogNamethe name of the translation catalog; if left empty componentName is used
registerAsMainwhether to register the component as the main component of the application. This has no effect, if the application already has a main component.
See also
KComponentData::mainComponent
KComponentData::KComponentData ( const K4AboutData aboutData,
MainComponentRegistration  registerAsMain = RegisterAsMainComponent 
)
explicit

Constructor.

A copy of the aboutData object is made.

Parameters
aboutDatadata about this component
registerAsMainwhether to register the component as the main component of the application. This has no effect, if the application already has a main component.
See also
KComponentData::mainComponent
K4AboutData

Definition at line 156 of file kcomponentdata.cpp.

KComponentData::~KComponentData ( )
virtual

Destructor.

Definition at line 171 of file kcomponentdata.cpp.

Member Function Documentation

const K4AboutData * KComponentData::aboutData ( ) const

Returns the about data of this component.

Returns
The about data of the component. If none has been set in the constructor but a component name was set, a default constructed K4AboutData object is returned.

Definition at line 254 of file kcomponentdata.cpp.

const KComponentData & KComponentData::activeComponent ( )
static

The component currently active (useful in a multi-component application, such as a KParts application).

Don't use this - it was mainly for KAboutDialog and KBugReport.

They now use KAboutData::applicationData() by default, or a specific KAboutData can be given to them. KHelpMenu always creates them with the application data. So this is now obsolete, the about-app and bug-report dialog simply use the app data rather than the active plugin data.

Since
5.0 (moved from KGlobal, but later on KComponentData was deprecated anyway)

Definition at line 289 of file kcomponentdata.cpp.

QString KComponentData::catalogName ( ) const

Returns the name of the translation catalog.

Returns
The catalog name.

Definition at line 271 of file kcomponentdata.cpp.

QString KComponentData::componentName ( ) const

Returns the name of the component.

Returns
The component name.

Definition at line 265 of file kcomponentdata.cpp.

const KSharedConfig::Ptr & KComponentData::config ( ) const

Returns the general config object ("appnamerc").

Returns
the KConfig object for the component.

Definition at line 240 of file kcomponentdata.cpp.

bool KComponentData::hasMainComponent ( )
static

Returns whether a main KComponentData is available.

Since
5.0

Definition at line 277 of file kcomponentdata.cpp.

bool KComponentData::isValid ( ) const

Returns whether this is a valid object.

Don't call any functions on invalid objects, that will crash. Assignment (and of course destruction) is the only valid operation you may do.

Definition at line 179 of file kcomponentdata.cpp.

const KComponentData & KComponentData::mainComponent ( )
static

Returns the global component data, if one was set.

Since
5.0

Definition at line 283 of file kcomponentdata.cpp.

KComponentData::operator KAboutData ( ) const

Implicit conversion to KAboutData, to be able to call setComponentData(myComponentData) even if the method is now setComponentData(const KAboutData &)

Definition at line 305 of file kcomponentdata.cpp.

bool KComponentData::operator!= ( const KComponentData rhs) const

Returns whether two KComponentData objects do not reference the same data.

Definition at line 73 of file kcomponentdata.cpp.

KComponentData & KComponentData::operator= ( const KComponentData rhs)

Assignment operator.

It does not copy the data. The data is shared between the old and new objects.

If the data of the left hand side object was only referenced from this object and no referenced KSharedConfig object needs it anymore, it is deleted

Definition at line 54 of file kcomponentdata.cpp.

bool KComponentData::operator== ( const KComponentData rhs) const

Returns whether two KComponentData objects reference the same data.

Definition at line 68 of file kcomponentdata.cpp.

void KComponentData::setAboutData ( const K4AboutData aboutData)

Sets the about data of this component.

Since
4.5

Definition at line 260 of file kcomponentdata.cpp.

void KComponentData::setActiveComponent ( const KComponentData d)
static

Set the active component for use by KAboutDialog and KBugReport.

To be used only by a multi-component (KParts) application.

Since 5.0, KAboutDialog and KBugReport don't look at this anymore, so consider just removing the call. See activeComponent() for more details.

See also
activeComponent()
Since
5.0 (moved from KGlobal, but later on KComponentData was deprecated anyway)

Definition at line 295 of file kcomponentdata.cpp.

void KComponentData::setConfigName ( const QString name)
protected

Set name of default config file.

Parameters
namethe name of the default config file

Definition at line 248 of file kcomponentdata.cpp.

void KComponentData::virtual_hook ( int  id,
void *  data 
)
protectedvirtual

Standard trick to add virtuals later.

Definition at line 310 of file kcomponentdata.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jul 10 2020 22:56:49 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.