[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
Public Member Functions | List of all members
KLFPluginConfigAccess Class Reference

Utility class for plugins to access their configuration space in KLFConfig. More...

#include <klfconfig.h>

Public Member Functions

 KLFPluginConfigAccess ()
 
 KLFPluginConfigAccess (KLFConfig *configObject, const QString &pluginName)
 
 KLFPluginConfigAccess (const KLFPluginConfigAccess &other)
 
virtual ~KLFPluginConfigAccess ()
 
virtual QString homeConfigDir () const
 
virtual QString globalShareDir () const
 
virtual QString tempDir () const
 
virtual QString homeConfigPluginDataDir (bool createIfNeeded=true) const
 
virtual QVariant readValue (const QString &key) const
 read a value in the config More...
 
virtual QVariant makeDefaultValue (const QString &key, const QVariant &defaultValue)
 write the value if inexistant in config More...
 
virtual void writeValue (const QString &key, const QVariant &value)
 write a value to settings More...
 

Detailed Description

Utility class for plugins to access their configuration space in KLFConfig.

KLatexFormula stores its configuration via KLFConfig and the global klfconfig object. That structure relies on the config structure being known in advance and the named fields to appear publicly in the KLFConfig class. This scheme is obviously NOT possible for plugins, so a different approach is taken.

Plugins are given a pointer to a KLFPluginConfigAccess object, which is an interface to access a special part of KLFConfig that stores plugin-related configuration in the form of QVariantMaps. (themselves written in an INI-based config file inside the plugin's local directory, at ~/.klatexformula/plugindata/<plugin>/<plugin>.conf)

KLFConfig transparently takes care of reading the config for plugins at the beginning when launching KLatexFormula and storing the plugin configurations in their respective locations when quitting.

Plugins can read values they have set in earlier sessions with readValue(). Default values can be defined with makeDefaultValue().

Plugins can write changed settings with writeValue().

Definition at line 61 of file klfconfig.h.

Constructor & Destructor Documentation

KLFPluginConfigAccess::KLFPluginConfigAccess ( )

Definition at line 724 of file klfconfig.cpp.

KLFPluginConfigAccess::KLFPluginConfigAccess ( KLFConfig configObject,
const QString pluginName 
)

Definition at line 741 of file klfconfig.cpp.

References KLFConfig::homeConfigDir, and klfDbg.

KLFPluginConfigAccess::KLFPluginConfigAccess ( const KLFPluginConfigAccess other)

Definition at line 729 of file klfconfig.cpp.

References KLFConfig::homeConfigDir, and klfDbg.

KLFPluginConfigAccess::~KLFPluginConfigAccess ( )
virtual

Definition at line 737 of file klfconfig.cpp.

Member Function Documentation

QString KLFPluginConfigAccess::globalShareDir ( ) const
virtual

Returns the directory (not necessarily existing) in which installed data that is shared among different users is stored. eg. system-wide installations of plugins/extensions can be placed in: share-dir/rccresources/*.rcc.

Definition at line 764 of file klfconfig.cpp.

References KLFConfig::globalShareDir.

QString KLFPluginConfigAccess::homeConfigDir ( ) const
virtual

Returns the root directory in which KLatexFormula stores its stuff, usually ~/.klatexformula.

Definition at line 754 of file klfconfig.cpp.

References KLFConfig::homeConfigDir, and klfDbg.

QString KLFPluginConfigAccess::homeConfigPluginDataDir ( bool  createIfNeeded = true) const
virtual

Returns a path to a directory in which plugins can manage their data as they want.

If the createIfNeeded argument is TRUE, then the directory is garanteed to exist, and an empty string is returned if, for whatever reason, the directory can't be created.

If the createIfNeeded argument is FALSE, then the directory path is returned regardless of whether the directory exists or not.

Note that a file named pluginName.conf is created to store the plugin's settings in that directory (the settings are stored automatically).

Definition at line 784 of file klfconfig.cpp.

References KLFConfig::homeConfigDirPluginData, klfDbg, and klfEnsureDir().

QVariant KLFPluginConfigAccess::makeDefaultValue ( const QString key,
const QVariant defaultValue 
)
virtual

write the value if inexistant in config

equivalent to

if (readValue(key).isNull())
writeValue(key, defaultValue);
Returns
the value this key has after this function call, ie. defaultValue if no existing value was found, or the existing value if one already exists. A null QVariant is returned upon error.

Definition at line 814 of file klfconfig.cpp.

References QMap::contains(), KLFConfig::pluginConfig, and KLFConfig::Plugins.

QVariant KLFPluginConfigAccess::readValue ( const QString key) const
virtual

read a value in the config

Returns the value of the entry with key key. If no such entry exists, it is not created and an invalid QVariant() is returned.

Definition at line 801 of file klfconfig.cpp.

References QMap::contains(), KLFConfig::pluginConfig, and KLFConfig::Plugins.

QString KLFPluginConfigAccess::tempDir ( ) const
virtual

Returns a directory in which we can read/write temporary files, eg. "/tmp".

This is actually the value of klfconfig.BackendSettings.tempDir

Definition at line 774 of file klfconfig.cpp.

References KLFConfig::BackendSettings, and KLFConfig::tempDir.

void KLFPluginConfigAccess::writeValue ( const QString key,
const QVariant value 
)
virtual

write a value to settings

Saves the value of a setting, referenced by key, to the given value.

If key hasn't been previously set, creates an entry for key with the given value.

Definition at line 827 of file klfconfig.cpp.

References QSettings::beginGroup(), QSettings::childGroups(), QSettings::childKeys(), QSettings::endGroup(), KLFConfig::pluginConfig, KLFConfig::Plugins, settings_read_list(), settings_read_QTextCharFormat(), and QSettings::value().


The documentation for this class was generated from the following files:

Generated by doxygen 1.8.11