KComponentData
#include <kcomponentdata.h>

Public Types | |
enum | MainComponentRegistration { RegisterAsMainComponent, SkipMainComponentRegistration } |
Public Member Functions | |
KComponentData () | |
KComponentData (const K4AboutData &aboutData, MainComponentRegistration registerAsMain=RegisterAsMainComponent) | |
KComponentData (const K4AboutData *aboutData, MainComponentRegistration registerAsMain=RegisterAsMainComponent) | |
KComponentData (const KComponentData &) | |
KComponentData (const QByteArray &componentName, const QByteArray &catalogName=QByteArray(), MainComponentRegistration registerAsMain=RegisterAsMainComponent) | |
virtual | ~KComponentData () |
const K4AboutData * | aboutData () const |
QString | catalogName () const |
QString | componentName () const |
const KSharedConfig::Ptr & | config () const |
bool | isValid () const |
operator KAboutData () const | |
bool | operator!= (const KComponentData &rhs) const |
KComponentData & | operator= (const KComponentData &) |
bool | operator== (const KComponentData &) const |
void | setAboutData (const K4AboutData &aboutData) |
Static Public Member Functions | |
static const KComponentData & | activeComponent () |
static bool | hasMainComponent () |
static const KComponentData & | mainComponent () |
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().
- Note
- This class has been deprecated, you should port code away from it; see https://community.kde.org/Frameworks/Porting_Notes#KComponentData for porting notes.
Definition at line 54 of file kcomponentdata.h.
Constructor & Destructor Documentation
◆ KComponentData() [1/4]
KComponentData::KComponentData | ( | ) |
Creates an invalid KComponentData object.
- See also
- isValid()
Definition at line 41 of file kcomponentdata.cpp.
◆ KComponentData() [2/4]
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() [3/4]
|
explicit |
Constructor.
- Parameters
-
componentName the name of the component. catalogName the name of the translation catalog; if left empty componentName
is usedregisterAsMain whether 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() [4/4]
|
explicit |
Constructor.
A copy of the aboutData object is made.
- Parameters
-
aboutData data about this component registerAsMain whether to register the component as the main component of the application. This has no effect, if the application already has a main component.
Definition at line 156 of file kcomponentdata.cpp.
◆ ~KComponentData()
|
virtual |
Destructor.
Definition at line 171 of file kcomponentdata.cpp.
Member Function Documentation
◆ aboutData()
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.
◆ 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.
◆ catalogName()
QString KComponentData::catalogName | ( | ) | const |
Returns the name of the translation catalog.
- Returns
- The catalog name.
Definition at line 271 of file kcomponentdata.cpp.
◆ componentName()
QString KComponentData::componentName | ( | ) | const |
Returns the name of the component.
- Returns
- The component name.
Definition at line 265 of file kcomponentdata.cpp.
◆ config()
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.
◆ hasMainComponent()
|
static |
Returns whether a main KComponentData is available.
- Since
- 5.0
Definition at line 277 of file kcomponentdata.cpp.
◆ isValid()
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.
◆ mainComponent()
|
static |
Returns the global component data, if one was set.
- Since
- 5.0
Definition at line 283 of file kcomponentdata.cpp.
◆ operator KAboutData()
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.
◆ operator!=()
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.
◆ operator=()
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.
◆ operator==()
bool KComponentData::operator== | ( | const KComponentData & | rhs | ) | const |
Returns whether two KComponentData objects reference the same data.
Definition at line 68 of file kcomponentdata.cpp.
◆ setAboutData()
void KComponentData::setAboutData | ( | const K4AboutData & | aboutData | ) |
◆ setActiveComponent()
|
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.
◆ setConfigName()
|
protected |
Set name of default config file.
- Parameters
-
name the name of the default config file
Definition at line 248 of file kcomponentdata.cpp.
◆ virtual_hook()
|
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:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:02:02 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.