\section{KConfig Class Reference}
\label{classKConfig}\index{KConfig@{KConfig}}
Access {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} Configuration entries. {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} Configuration Management class.  


{\tt \#include $<$kconfig.h$>$}

Inheritance diagram for KConfig:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=156pt]{classKConfig__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KConfig:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=206pt]{classKConfig__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KConfig} (const {\bf QString} \&file\-Name=QString::null, bool b\-Read\-Only=false, bool b\-Use\-KDEGlobals=true, const char $\ast$res\-Type=\char`\"{}config\char`\"{})
\item 
{\bf KConfig} ({\bf KConfig\-Back\-End} $\ast${\bf back\-End}, bool b\-Read\-Only=false)\label{classKConfig_a1}

\item 
virtual {\bf $\sim$KConfig} ()
\item 
virtual void {\bf rollback} (bool b\-Deep=true)
\item 
virtual {\bf QString\-List} {\bf group\-List} () const 
\item 
virtual {\bf QMap}$<$ {\bf QString}, {\bf QString} $>$ {\bf entry\-Map} (const {\bf QString} \&p\-Group) const 
\item 
virtual void {\bf reparse\-Configuration} ()
\item 
void {\bf set\-File\-Write\-Mode} (int mode)
\item 
void {\bf set\-Force\-Global} (bool force)
\item 
bool {\bf force\-Global} () const 
\item 
void {\bf check\-Update} (const {\bf QString} \&id, const {\bf QString} \&update\-File)
\item 
{\bf KConfig} $\ast$ {\bf copy\-To} (const {\bf QString} \&file, {\bf KConfig} $\ast$config=0) const 
\item 
{\bf KLock\-File::Ptr} {\bf lock\-File} (bool b\-Global=false)
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual bool {\bf internal\-Has\-Group} (const {\bf QCString} \&group) const 
\item 
virtual KEntry\-Map {\bf internal\-Entry\-Map} (const {\bf QString} \&p\-Group) const 
\item 
virtual KEntry\-Map {\bf internal\-Entry\-Map} () const 
\item 
virtual void {\bf put\-Data} (const {\bf KEntry\-Key} \&\_\-key, const {\bf KEntry} \&\_\-data, bool \_\-check\-Group=true)
\item 
virtual {\bf KEntry} {\bf lookup\-Data} (const {\bf KEntry\-Key} \&\_\-key) const 
\item 
virtual void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKConfig_b5}

\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
KEntry\-Map {\bf a\-Entry\-Map}
\end{CompactItemize}


\subsection{Detailed Description}
Access {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} Configuration entries. {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} Configuration Management class. 

This class implements KDE's default configuration system.

\begin{Desc}
\item[Author:]Kalle Dalheimer $<${\tt kalle@kde.org}$>$, Preston Brown $<${\tt pbrown@kde.org}$>$ \end{Desc}
\begin{Desc}
\item[See also:]{\bf KGlobal::config()}{\rm (p.\,\pageref{classKGlobal_e2})}, {\bf KConfig\-Base}{\rm (p.\,\pageref{classKConfigBase})}, {\bf KSimple\-Config}{\rm (p.\,\pageref{classKSimpleConfig})} \end{Desc}




Definition at line 43 of file kconfig.h.

\subsection{Constructor \& Destructor Documentation}
\index{KConfig@{KConfig}!KConfig@{KConfig}}
\index{KConfig@{KConfig}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KConfig::KConfig (const {\bf QString} \& {\em file\-Name} = {\tt QString::null}, bool {\em b\-Read\-Only} = {\tt false}, bool {\em b\-Use\-KDEGlobals} = {\tt true}, const char $\ast$ {\em res\-Type} = {\tt \char`\"{}config\char`\"{}})}\label{classKConfig_a0}


Constructs a KConfig object. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em file\-Name}]A file to parse in addition to the system-wide file(s). If it is not provided, only global {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} configuration data will be read (depending on the value of {\tt b\-Use\-KDEGlobals}). \item[{\em b\-Read\-Only}]Set the config object's read-only status. Note that the object will automatically become read-only if either the user does not have write permission to {\tt file\-Name} or if no file was specified. \item[{\em b\-Use\-KDEGlobals}]Toggle reading the global {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} configuration file. \item[{\em res\-Type}]the place to look in (config, data, etc) See {\bf KStandard\-Dirs}{\rm (p.\,\pageref{classKStandardDirs})}. \end{description}
\end{Desc}


Definition at line 44 of file kconfig.cpp.

References reparse\-Configuration(), and KConfig\-Base::set\-Read\-Only().

Referenced by copy\-To().\index{KConfig@{KConfig}!~KConfig@{$\sim$KConfig}}
\index{~KConfig@{$\sim$KConfig}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KConfig::$\sim${\bf KConfig} ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKConfig_a2}


Destructs the KConfig object. 

Writes back any dirty configuration entries, and destroys dynamically created objects. 

Definition at line 87 of file kconfig.cpp.

References KConfig\-Base::sync().

\subsection{Member Function Documentation}
\index{KConfig@{KConfig}!rollback@{rollback}}
\index{rollback@{rollback}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KConfig::rollback (bool {\em b\-Deep} = {\tt true})\hspace{0.3cm}{\tt  [virtual]}}\label{classKConfig_a3}


Clears all entries out of the {\tt dirty\-Entry\-Map}, so the values will not be written to disk on a later call to {\bf sync()}{\rm (p.\,\pageref{classKConfigBase_a105})}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em b\-Deep}]If true, the dirty map is actually emptied. otherwise, the config object's global dirty flag is set to false, but the dirty entries remain in the dirty entry map.\end{description}
\end{Desc}
\begin{Desc}
\item[See also:]{\bf KConfig\-Base::rollback}{\rm (p.\,\pageref{classKConfigBase_a104})} \end{Desc}


Reimplemented from {\bf KConfig\-Base} {\rm (p.\,\pageref{classKConfigBase_a104})}.

Definition at line 94 of file kconfig.cpp.

References a\-Entry\-Map, and KConfig\-Base::rollback().

Referenced by KSimple\-Config::sync().\index{KConfig@{KConfig}!groupList@{groupList}}
\index{groupList@{groupList}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString\-List} KConfig::group\-List () const\hspace{0.3cm}{\tt  [virtual]}}\label{classKConfig_a4}


Returns a list of groups that are known. 

\begin{Desc}
\item[Returns:]a list of of groups \end{Desc}


Implements {\bf KConfig\-Base} {\rm (p.\,\pageref{classKConfigBase_a6})}.

Definition at line 107 of file kconfig.cpp.

References a\-Entry\-Map.

Referenced by copy\-To().\index{KConfig@{KConfig}!entryMap@{entryMap}}
\index{entryMap@{entryMap}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QMap}$<$ {\bf QString}, {\bf QString} $>$ KConfig::entry\-Map (const {\bf QString} \& {\em p\-Group}) const\hspace{0.3cm}{\tt  [virtual]}}\label{classKConfig_a5}


Returns a map (tree) of entries for all entries in a particular group. 

Only the actual entry string is returned, none of the other internal data should be included.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em p\-Group}]A group to get keys from. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A map of entries in the group specified, indexed by key. The returned map may be empty if the group is not found. \end{Desc}


Implements {\bf KConfig\-Base} {\rm (p.\,\pageref{classKConfigBase_a110})}.

Definition at line 141 of file kconfig.cpp.

References a\-Entry\-Map, QMap::find(), QString::from\-Utf8(), and QMap::insert().

Referenced by copy\-To().\index{KConfig@{KConfig}!reparseConfiguration@{reparseConfiguration}}
\index{reparseConfiguration@{reparseConfiguration}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KConfig::reparse\-Configuration ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKConfig_a6}


Clears all internal data structures and then reread configuration information from disk. 



Implements {\bf KConfig\-Base} {\rm (p.\,\pageref{classKConfigBase_a111})}.

Definition at line 161 of file kconfig.cpp.

References a\-Entry\-Map, KConfig\-Base::is\-Read\-Only(), KConfig\-Base::parse\-Config\-Files(), and KConfig\-Back\-End::sync().

Referenced by check\-Update(), KInstance::config(), KInstance::dirs(), KConfig(), KDesktop\-File::KDesktop\-File(), KSimple\-Config::KSimple\-Config(), and KApplication::x11Event\-Filter().\index{KConfig@{KConfig}!setFileWriteMode@{setFileWriteMode}}
\index{setFileWriteMode@{setFileWriteMode}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KConfig::set\-File\-Write\-Mode (int {\em mode})}\label{classKConfig_a7}


Set the file mode for newly created files. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em mode}]the mode for new files as described in chmod(2) \end{description}
\end{Desc}
\begin{Desc}
\item[See also:]man:chmod(2) for a description of {\tt mode} \end{Desc}


Definition at line 275 of file kconfig.cpp.

References KConfig\-Back\-End::set\-File\-Write\-Mode().\index{KConfig@{KConfig}!setForceGlobal@{setForceGlobal}}
\index{setForceGlobal@{setForceGlobal}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KConfig::set\-Force\-Global (bool {\em force})\hspace{0.3cm}{\tt  [inline]}}\label{classKConfig_a8}


Forces all following write-operations being performed on kdeglobals, independent of the b\-Global flag in {\bf write\-Entry()}{\rm (p.\,\pageref{classKConfigBase_a55})}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em force}]true to force writing in kdeglobals \end{description}
\end{Desc}
\begin{Desc}
\item[See also:]{\bf force\-Global}{\rm (p.\,\pageref{classKConfig_a9})} \end{Desc}


Definition at line 129 of file kconfig.h.\index{KConfig@{KConfig}!forceGlobal@{forceGlobal}}
\index{forceGlobal@{forceGlobal}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KConfig::force\-Global () const\hspace{0.3cm}{\tt  [inline]}}\label{classKConfig_a9}


Returns true if all entries are being written into kdeglobals. 

\begin{Desc}
\item[Returns:]true if all entries are being written into kdeglobals \end{Desc}
\begin{Desc}
\item[See also:]{\bf set\-Force\-Global}{\rm (p.\,\pageref{classKConfig_a8})} \end{Desc}


Definition at line 136 of file kconfig.h.\index{KConfig@{KConfig}!checkUpdate@{checkUpdate}}
\index{checkUpdate@{checkUpdate}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KConfig::check\-Update (const {\bf QString} \& {\em id}, const {\bf QString} \& {\em update\-File})}\label{classKConfig_a10}


Checks whether the config file contains the update {\tt id} as contained in {\tt update\-File}. 

If not, it runs kconf\_\-update to update the config file.

If you install config update files with critical fixes you may wish to use this method to verify that a critical update has indeed been performed to catch the case where a user restores an old config file from backup that has not been updated yet. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em id}]the update to check \item[{\em update\-File}]the file containing the update \end{description}
\end{Desc}
\begin{Desc}
\item[Since:]3.1 \end{Desc}


Definition at line 287 of file kconfig.cpp.

References KConfig\-Base::group(), KApplication::kdeinit\-Exec\-Wait(), KConfig\-Base::read\-List\-Entry(), reparse\-Configuration(), and KConfig\-Base::set\-Group().\index{KConfig@{KConfig}!copyTo@{copyTo}}
\index{copyTo@{copyTo}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KConfig} $\ast$ KConfig::copy\-To (const {\bf QString} \& {\em file}, {\bf KConfig} $\ast$ {\em config} = {\tt 0}) const}\label{classKConfig_a11}


Copies all entries from this config object to a new config object that will save itself to {\tt file}. 

Actual saving to {\tt file} happens when the returned object is destructed or when {\bf sync()}{\rm (p.\,\pageref{classKConfigBase_a105})} is called upon it.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em file}]the new config object will save itself to. \item[{\em config}]optional config object to reuse \end{description}
\end{Desc}
\begin{Desc}
\item[Since:]3.2 \end{Desc}


Definition at line 303 of file kconfig.cpp.

References KConfig\-Base::back\-End, QMap::begin(), KConfig\-Back\-End::b\-File\-Immutable, KConfig\-Back\-End::change\-File\-Name(), QMap::end(), entry\-Map(), group\-List(), KConfig(), and KConfig\-Back\-End::m\-Config\-State.

Referenced by KDesktop\-File::copy\-To().\index{KConfig@{KConfig}!lockFile@{lockFile}}
\index{lockFile@{lockFile}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KLock\-File::Ptr} KConfig::lock\-File (bool {\em b\-Global} = {\tt false})}\label{classKConfig_a12}


Returns a lock file object for the configuration file or 0 if the backend does not support locking. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em b\-Global}]if true, return the lock file for the global config file\end{description}
\end{Desc}
NOTE: {\bf KConfig::sync()}{\rm (p.\,\pageref{classKConfigBase_a105})} requires a lock on both the normal and global config file. When calling {\bf KConfig::sync()}{\rm (p.\,\pageref{classKConfigBase_a105})} while having a lock on the global config file, the normal config file MUST be locked AS WELL and the normal config file MUST be locked BEFORE the global config file! Otherwise there is a risk of deadlock. \begin{Desc}
\item[Since:]3.3 \end{Desc}


Definition at line 280 of file kconfig.cpp.

References KConfig\-Back\-End::lock\-File().\index{KConfig@{KConfig}!internalHasGroup@{internalHasGroup}}
\index{internalHasGroup@{internalHasGroup}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KConfig::internal\-Has\-Group (const {\bf QCString} \& {\em group}) const\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKConfig_b0}


Returns true if the specified group is known. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em group}]The group to search for. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if the group exists. \end{Desc}


Implements {\bf KConfig\-Base} {\rm (p.\,\pageref{classKConfigBase})}.

Definition at line 254 of file kconfig.cpp.

References a\-Entry\-Map.\index{KConfig@{KConfig}!internalEntryMap@{internalEntryMap}}
\index{internalEntryMap@{internalEntryMap}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KEntry\-Map KConfig::internal\-Entry\-Map (const {\bf QString} \& {\em p\-Group}) const\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKConfig_b1}


Returns a map (tree) of the entries in the specified group. 

This may or may not return all entries that belong to the config object. The only guarantee that you are given is that any entries that are dirty (i.e. modified and not yet written back to the disk) will be contained in the map. Some derivative classes may choose to return everything.

Do not use this function, the implementation / return type are subject to change.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em p\-Group}]The group to provide a KEntry\-Map for. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The map of the entries in the group. \end{Desc}


Implements {\bf KConfig\-Base} {\rm (p.\,\pageref{classKConfigBase_b3})}.

Definition at line 178 of file kconfig.cpp.

References a\-Entry\-Map.\index{KConfig@{KConfig}!internalEntryMap@{internalEntryMap}}
\index{internalEntryMap@{internalEntryMap}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual KEntry\-Map KConfig::internal\-Entry\-Map () const\hspace{0.3cm}{\tt  [inline, protected, virtual]}}\label{classKConfig_b2}


Returns a map (tree) of the entries in the tree. 

Do not use this function, the implementation / return type are subject to change.

\begin{Desc}
\item[Returns:]A map of the entries in the tree. \end{Desc}


Implements {\bf KConfig\-Base} {\rm (p.\,\pageref{classKConfigBase_b4})}.

Definition at line 212 of file kconfig.h.\index{KConfig@{KConfig}!putData@{putData}}
\index{putData@{putData}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KConfig::put\-Data (const {\bf KEntry\-Key} \& {\em \_\-key}, const {\bf KEntry} \& {\em \_\-data}, bool {\em \_\-check\-Group} = {\tt true})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKConfig_b3}


Inserts a (key, value) pair into the internal storage mechanism of the configuration object. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-key}]The key to insert. It contains information both on the group of the key and the key itself. If the key already exists, the old value will be replaced. \item[{\em \_\-data}]the {\bf KEntry}{\rm (p.\,\pageref{structKEntry})} that is to be stored. \item[{\em \_\-check\-Group}]When false, assume that the group already exists. \end{description}
\end{Desc}


Implements {\bf KConfig\-Base} {\rm (p.\,\pageref{classKConfigBase_b5})}.

Definition at line 202 of file kconfig.cpp.

References a\-Entry\-Map, KEntry\-Key::b\-Default, KEntry::b\-Global, and KEntry::b\-Immutable.\index{KConfig@{KConfig}!lookupData@{lookupData}}
\index{lookupData@{lookupData}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KEntry} KConfig::lookup\-Data (const {\bf KEntry\-Key} \& {\em \_\-key}) const\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKConfig_b4}


Looks up an entry in the config object's internal structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-key}]The key to look up It contains information both on the group of the key and the entry's key itself. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]the {\bf KEntry}{\rm (p.\,\pageref{structKEntry})} value (data) found for the key. KEntry.a\-Value will be the null string if nothing was located. \end{Desc}


Implements {\bf KConfig\-Base} {\rm (p.\,\pageref{classKConfigBase_b6})}.

Definition at line 238 of file kconfig.cpp.

References a\-Entry\-Map, and KEntry::b\-Deleted.

\subsection{Member Data Documentation}
\index{KConfig@{KConfig}!aEntryMap@{aEntryMap}}
\index{aEntryMap@{aEntryMap}!KConfig@{KConfig}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KEntry\-Map {\bf KConfig::a\-Entry\-Map}\hspace{0.3cm}{\tt  [protected]}}\label{classKConfig_p0}


Contains all key,value entries, as well as some \char`\"{}special\char`\"{} keys which indicate the start of a group of entries. 

These special keys will have the .key portion of their {\bf KEntry\-Key}{\rm (p.\,\pageref{structKEntryKey})} set to QString::null. 

Definition at line 243 of file kconfig.h.

Referenced by entry\-Map(), group\-List(), internal\-Entry\-Map(), internal\-Has\-Group(), lookup\-Data(), put\-Data(), reparse\-Configuration(), and rollback().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
kconfig.h\item 
kconfig.cpp\end{CompactItemize}
