Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

KateConfig Class Reference

The KateConfig class provides for saving application cofniguration state. More...

#include </home/clem/local/src/opie/noncore/apps/tinykate/libkate/kateconfig.h>

Collaboration diagram for KateConfig:

Collaboration graph
[legend]
List of all members.

Public Types

typedef QMap< QString, QStringKateConfigGroup
enum  Domain { File, User }

Public Member Functions

 KateConfig (const QString &name, Domain domain=User)
 ~KateConfig ()
bool operator== (const KateConfig &other) const
bool operator!= (const KateConfig &other) const
bool isValid () const
bool hasKey (const QString &key) const
bool hasGroup (const QString &gname) const
QStringList groupList () const
void setGroup (const QString &gname)
void writeEntry (const QString &key, const char *value)
void writeEntry (const QString &key, const QString &value)
void writeEntryCrypt (const QString &key, const QString &value)
void writeEntry (const QString &key, int num)
void writeEntry (const QString &key, unsigned int num)
void writeEntry (const QString &key, const QStringList &lst, const QChar &sep)
void writeEntry (const QString &key, const QColor &)
void writeEntry (const QString &key, const QFont &)
void removeEntry (const QString &key)
QString readEntry (const QString &key, const QString &deflt=QString::null) const
QString readEntryCrypt (const QString &key, const QString &deflt=QString::null) const
QString readEntryDirect (const QString &key, const QString &deflt=QString::null) const
int readNumEntry (const QString &key, int deflt=-1) const
bool readBoolEntry (const QString &key, bool deflt=FALSE) const
QStringList readListEntry (const QString &key, const QChar &sep) const
QColor readColorEntry (const QString &, const QColor &) const
QFont readFontEntry (const QString &, const QFont &) const
QValueList< int > readIntListEntry (const QString &key) const
QString readEntry (const QString &key, const QString &deflt)
QString readEntryCrypt (const QString &key, const QString &deflt)
QString readEntryDirect (const QString &key, const QString &deflt)
int readNumEntry (const QString &key, int deflt)
bool readBoolEntry (const QString &key, bool deflt)
QStringList readListEntry (const QString &key, const QChar &sep)
void clearGroup ()
void write (const QString &fn=QString::null)

Protected Member Functions

void read ()
bool parse (const QString &line)

Static Protected Member Functions

static QString configFilename (const QString &name, Domain)

Protected Attributes

QMap< QString, KateConfigGroupgroups
QMap< QString, KateConfigGroup
>::Iterator 
git
QString filename
QString lang
QString glang
bool changed
KateConfigPrivate * d

Private Member Functions

 KateConfig (const QString &name, bool what)

Detailed Description

The KateConfig class provides for saving application cofniguration state.

You should keep a KateConfig in existence only while you do not want others to be able to change the state. There is no locking currently, but there may be in the future.

Definition at line 32 of file kateconfig.h.


Member Typedef Documentation

typedef QMap< QString, QString > KateConfig::KateConfigGroup
 

For internal use only.

Definition at line 35 of file kateconfig.h.


Member Enumeration Documentation

enum KateConfig::Domain
 

File User

See KateConfig for details.

Enumeration values:
File 
User 

Definition at line 37 of file kateconfig.h.


Constructor & Destructor Documentation

KateConfig::KateConfig const QString name,
Domain  domain = User
 

Constructs a config that will load or create a configuration with the given name in the given domain.

You must call setGroup() before doing much else with the KateConfig.

In the default Domain, User, the configuration is user-specific. name should not contain "/" in this case, and in general should be the name of the C++ class that is primarily responsible for maintaining the configuration.

In the File Domain, name is an absolute filename.

Definition at line 99 of file kateconfig.cpp.

References QMap< Key, T >::end(), git, glang, groups, l, lang, oendl, owarn, and read().

KateConfig::~KateConfig  ) 
 

Writes any changes to disk and destroys the in-memory object.

Definition at line 125 of file kateconfig.cpp.

References changed, oendl, owarn, and write().

KateConfig::KateConfig const QString name,
bool  what
[private]
 

Definition at line 112 of file kateconfig.cpp.

References QMap< Key, T >::end(), git, glang, groups, l, lang, and read().


Member Function Documentation

void KateConfig::clearGroup  ) 
 

Removes all entries from the current group.

Definition at line 506 of file kateconfig.cpp.

References changed, QMap< Key, T >::end(), git, groups, oendl, owarn, and TRUE.

QString KateConfig::configFilename const QString name,
Domain  d
[static, protected]
 

For internal use only.

Definition at line 48 of file kateconfig.cpp.

References QDir::exists(), File, QDir::path(), and User.

QStringList KateConfig::groupList  )  const [inline]
 

Definition at line 49 of file kateconfig.h.

References begin, end, and groups.

bool KateConfig::hasGroup const QString gname  )  const [inline]
 

Definition at line 48 of file kateconfig.h.

References end, and groups.

Referenced by SyntaxDocument::setupModeList().

bool KateConfig::hasKey const QString key  )  const
 

Returns whether the current group has an entry called key.

Definition at line 135 of file kateconfig.cpp.

References QMap< Key, T >::end(), FALSE, git, and groups.

bool KateConfig::isValid  )  const
 

Returns whether the KateConfig is in a valid state.

Definition at line 568 of file kateconfig.cpp.

References QMap< Key, T >::end(), git, and groups.

bool KateConfig::operator!= const KateConfig other  )  const [inline]
 

Tests for inequality with other. KateConfig objects are equal if they refer to the same filename.

Definition at line 42 of file kateconfig.h.

References filename.

bool KateConfig::operator== const KateConfig other  )  const [inline]
 

Tests for equality with other. KateConfig objects are equal if they refer to the same filename.

Definition at line 41 of file kateconfig.h.

References filename.

bool KateConfig::parse const QString l  )  [protected]
 

For internal use only.

Definition at line 613 of file kateconfig.cpp.

References QMap< Key, T >::end(), FALSE, QString::find(), git, groups, QMap< Key, T >::insert(), QString::isEmpty(), QString::left(), QString::length(), QString::mid(), QString::remove(), and TRUE.

Referenced by read().

void KateConfig::read void   )  [protected]
 

For internal use only.

Definition at line 576 of file kateconfig.cpp.

References QValueList< T >::begin(), changed, QTextCodec::codecForMib(), QValueList< T >::end(), QMap< Key, T >::end(), f, FALSE, filename, git, groups, IO_ReadOnly, list, QFile::open(), parse(), QTextStream::read(), s, QTextStream::setCodec(), QTextStream::setEncoding(), QStringList::split(), and QTextStream::UnicodeUTF8.

Referenced by KateConfig().

bool KateConfig::readBoolEntry const QString key,
bool  deflt
 

For internal use only.

For compatibility, non-const version.

Definition at line 443 of file kateconfig.cpp.

References QString::isEmpty(), readEntry(), and QString::toInt().

bool KateConfig::readBoolEntry const QString key,
bool  deflt = FALSE
const [inline]
 

Reads a bool entry stored with key, defaulting to deflt if there is no entry.

Definition at line 112 of file kateconfig.h.

Referenced by KateDocument::readConfig().

QColor KateConfig::readColorEntry const QString ,
const QColor & 
const
 

Definition at line 470 of file kateconfig.cpp.

References QValueList< T >::count(), list, and readListEntry().

Referenced by KateDocument::readConfig().

QString KateConfig::readEntry const QString key,
const QString deflt
 

For internal use only.

For compatibility, non-const version.

Definition at line 359 of file kateconfig.cpp.

References glang, QString::isEmpty(), QString::isNull(), lang, and readEntryDirect().

QString KateConfig::readEntry const QString key,
const QString deflt = QString::null
const [inline]
 

Reads a string entry stored with key, defaulting to deflt if there is no entry.

Definition at line 104 of file kateconfig.h.

Referenced by Highlight::getData(), Highlight::getItemDataList(), Highlight::getMimetypes(), Highlight::getWildcards(), readBoolEntry(), KateDocument::readConfig(), readIntListEntry(), readListEntry(), readNumEntry(), and SyntaxDocument::setupModeList().

QString KateConfig::readEntryCrypt const QString key,
const QString deflt
 

For internal use only.

For compatibility, non-const version.

Definition at line 382 of file kateconfig.cpp.

References decipher(), glang, QString::isEmpty(), QString::isNull(), lang, QString::null, and readEntryDirect().

QString KateConfig::readEntryCrypt const QString key,
const QString deflt = QString::null
const [inline]
 

Reads an encrypted string entry stored with key, defaulting to deflt if there is no entry.

Definition at line 106 of file kateconfig.h.

QString KateConfig::readEntryDirect const QString key,
const QString deflt
 

For internal use only.

For compatibility, non-const version.

Definition at line 403 of file kateconfig.cpp.

References QMap< Key, T >::end(), git, and groups.

QString KateConfig::readEntryDirect const QString key,
const QString deflt = QString::null
const [inline]
 

For internal use only.

Definition at line 108 of file kateconfig.h.

Referenced by readEntry(), and readEntryCrypt().

QFont KateConfig::readFontEntry const QString ,
const QFont & 
const
 

Definition at line 479 of file kateconfig.cpp.

References QValueList< T >::count(), list, and readListEntry().

Referenced by KateDocument::readConfig().

QValueList< int > KateConfig::readIntListEntry const QString key  )  const
 

Definition at line 488 of file kateconfig.cpp.

References QValueList< T >::append(), QValueList< T >::begin(), QValueList< T >::end(), QString::isEmpty(), l, readEntry(), and QStringList::split().

QStringList KateConfig::readListEntry const QString key,
const QChar sep
 

For internal use only.

For compatibility, non-const version.

Definition at line 461 of file kateconfig.cpp.

References QString::isEmpty(), readEntry(), and QStringList::split().

QStringList KateConfig::readListEntry const QString key,
const QChar sep
const [inline]
 

Reads a string list entry stored with key, and with sep as the separator.

Definition at line 114 of file kateconfig.h.

Referenced by readColorEntry(), and readFontEntry().

int KateConfig::readNumEntry const QString key,
int  deflt
 

For internal use only.

For compatibility, non-const version.

Definition at line 425 of file kateconfig.cpp.

References QString::isEmpty(), readEntry(), and QString::toInt().

int KateConfig::readNumEntry const QString key,
int  deflt = -1
const [inline]
 

Reads a numeric entry stored with key, defaulting to deflt if there is no entry.

Definition at line 110 of file kateconfig.h.

Referenced by KateView::readConfig(), and KateDocument::readConfig().

void KateConfig::removeEntry const QString key  ) 
 

Removes the key entry from the current group. Does nothing if there is no such entry.

Definition at line 327 of file kateconfig.cpp.

References changed, QMap< Key, T >::end(), git, groups, oendl, owarn, and TRUE.

void KateConfig::setGroup const QString gname  ) 
 

Sets the current group for subsequent reading and writing of entries to gname. Grouping allows the application to partition the namespace.

This function must be called prior to any reading or writing of entries.

The gname must not be empty.

Definition at line 152 of file kateconfig.cpp.

References changed, QMap< Key, T >::end(), QMap< Key, T >::find(), git, groups, QMap< Key, T >::insert(), and TRUE.

Referenced by HlManager::defaultHl(), Highlight::getKateConfig(), KateView::readConfig(), KateDocument::readConfig(), SyntaxDocument::setupModeList(), KateView::writeConfig(), and KateDocument::writeConfig().

void KateConfig::write const QString fn = QString::null  ) 
 

For internal use only.

Definition at line 521 of file kateconfig.cpp.

References QMap< Key, T >::begin(), QFile::close(), QMap< Key, T >::end(), f, filename, git, groups, IO_Raw, IO_WriteOnly, QString::isEmpty(), QString::latin1(), QCString::length(), oendl, QFile::open(), owarn, QFile::remove(), str, tr, QString::utf8(), and QFile::writeBlock().

Referenced by SyntaxDocument::setupModeList(), and ~KateConfig().

void KateConfig::writeEntry const QString key,
const QFont & 
 

Definition at line 310 of file kateconfig.cpp.

References QValueList< T >::append(), l, and writeEntry().

void KateConfig::writeEntry const QString key,
const QColor & 
 

Definition at line 300 of file kateconfig.cpp.

References QValueList< T >::append(), l, and writeEntry().

void KateConfig::writeEntry const QString key,
const QStringList lst,
const QChar sep
 

Writes a (key, lst) entry to the current group. The list is separated by sep, so the strings must not contain that character.

See also:
readListEntry()

Definition at line 291 of file kateconfig.cpp.

References QValueList< T >::begin(), QValueList< T >::end(), and writeEntry().

void KateConfig::writeEntry const QString key,
unsigned int  num
 

Definition at line 263 of file kateconfig.cpp.

References s, QString::setNum(), and writeEntry().

void KateConfig::writeEntry const QString key,
int  num
 

Writes a (key, num) entry to the current group.

See also:
readNumEntry()

Definition at line 256 of file kateconfig.cpp.

References s, QString::setNum(), and writeEntry().

void KateConfig::writeEntry const QString key,
const QString value
 

Writes a (key, value) entry to the current group.

See also:
readEntry()

Definition at line 178 of file kateconfig.cpp.

References changed, QMap< Key, T >::end(), git, groups, oendl, owarn, and TRUE.

void KateConfig::writeEntry const QString key,
const char *  value
 

Writes a (key, value) entry to the current group.

See also:
readEntry()

Definition at line 168 of file kateconfig.cpp.

Referenced by Highlight::setData(), Highlight::setItemDataList(), SyntaxDocument::setupModeList(), KateView::writeConfig(), KateDocument::writeConfig(), writeEntry(), and KateView::writeSessionConfig().

void KateConfig::writeEntryCrypt const QString key,
const QString value
 

Writes an encrypted (key, value) entry to the current group.

Note that the degree of protection offered by the encryption is only sufficient to avoid the most casual observation of the configuration files.

See also:
readEntry()

Definition at line 238 of file kateconfig.cpp.

References changed, encipher(), QMap< Key, T >::end(), git, groups, oendl, owarn, and TRUE.


Member Data Documentation

bool KateConfig::changed [protected]
 

Definition at line 96 of file kateconfig.h.

Referenced by clearGroup(), read(), removeEntry(), setGroup(), writeEntry(), writeEntryCrypt(), and ~KateConfig().

KateConfigPrivate* KateConfig::d [protected]
 

Definition at line 97 of file kateconfig.h.

QString KateConfig::filename [protected]
 

Definition at line 93 of file kateconfig.h.

Referenced by operator!=(), operator==(), read(), and write().

QMap< QString, KateConfigGroup >::Iterator KateConfig::git [protected]
 

Definition at line 92 of file kateconfig.h.

Referenced by clearGroup(), hasKey(), isValid(), KateConfig(), parse(), read(), readEntryDirect(), removeEntry(), setGroup(), write(), writeEntry(), and writeEntryCrypt().

QString KateConfig::glang [protected]
 

Definition at line 95 of file kateconfig.h.

Referenced by KateConfig(), readEntry(), and readEntryCrypt().

QMap< QString, KateConfigGroup > KateConfig::groups [protected]
 

Definition at line 91 of file kateconfig.h.

Referenced by clearGroup(), groupList(), hasGroup(), hasKey(), isValid(), KateConfig(), parse(), read(), readEntryDirect(), removeEntry(), setGroup(), write(), writeEntry(), and writeEntryCrypt().

QString KateConfig::lang [protected]
 

Definition at line 94 of file kateconfig.h.

Referenced by KateConfig(), readEntry(), and readEntryCrypt().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:37:14 2005 for OPIE by  doxygen 1.4.2