You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1231 lines
37 KiB
1231 lines
37 KiB
15 years ago
|
/*
|
||
|
* This file is part of KDE.
|
||
|
*
|
||
|
* Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org>
|
||
|
* Copyright (c) 2003 Waldo Bastian <bastian@kde.org>
|
||
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Library General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
|
* version 2 of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Library General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Library General Public License
|
||
|
* along with this library; see the file COPYING.LIB. If not, write to
|
||
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#ifndef _KCONFIGSKELETON_H
|
||
|
#define _KCONFIGSKELETON_H
|
||
|
|
||
15 years ago
|
#include <tqcolor.h>
|
||
|
#include <tqdatetime.h>
|
||
|
#include <tqfont.h>
|
||
|
#include <tqpoint.h>
|
||
|
#include <tqptrlist.h>
|
||
|
#include <tqdict.h>
|
||
|
#include <tqrect.h>
|
||
|
#include <tqsize.h>
|
||
|
#include <tqstringlist.h>
|
||
|
#include <tqvariant.h>
|
||
15 years ago
|
#include <kconfig.h>
|
||
|
#include <kglobalsettings.h>
|
||
|
|
||
|
/**
|
||
|
* @short Class for storing a preferences setting
|
||
|
* @author Cornelius Schumacher
|
||
|
* @see KConfigSkeleton
|
||
|
*
|
||
|
* This class represents one preferences setting as used by @ref KConfigSkeleton.
|
||
|
* Subclasses of KConfigSkeletonItem implement storage functions for a certain type of
|
||
|
* setting. Normally you don't have to use this class directly. Use the special
|
||
|
* addItem() functions of KConfigSkeleton instead. If you subclass this class you will
|
||
|
* have to register instances with the function KConfigSkeleton::addItem().
|
||
|
*/
|
||
|
class KDECORE_EXPORT KConfigSkeletonItem
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
typedef TQValueList < KConfigSkeletonItem * >List;
|
||
|
typedef TQDict < KConfigSkeletonItem > Dict;
|
||
|
typedef TQDictIterator < KConfigSkeletonItem > DictIterator;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Constructor.
|
||
|
*
|
||
|
* @param group Config file group.
|
||
|
* @param key Config file key.
|
||
|
*/
|
||
15 years ago
|
KConfigSkeletonItem(const TQString & group, const TQString & key)
|
||
15 years ago
|
:mGroup(group),mKey(key), mIsImmutable(true)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Destructor.
|
||
|
*/
|
||
|
virtual ~KConfigSkeletonItem()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Set config file group.
|
||
|
*/
|
||
15 years ago
|
void setGroup( const TQString &group )
|
||
15 years ago
|
{
|
||
|
mGroup = group;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return config file group.
|
||
|
*/
|
||
15 years ago
|
TQString group() const
|
||
15 years ago
|
{
|
||
|
return mGroup;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Set config file key.
|
||
|
*/
|
||
15 years ago
|
void setKey( const TQString &key )
|
||
15 years ago
|
{
|
||
|
mKey = key;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return config file key.
|
||
|
*/
|
||
15 years ago
|
TQString key() const
|
||
15 years ago
|
{
|
||
|
return mKey;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Set internal name of entry.
|
||
|
*/
|
||
15 years ago
|
void setName(const TQString &name)
|
||
15 years ago
|
{
|
||
|
mName = name;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return internal name of entry.
|
||
|
*/
|
||
15 years ago
|
TQString name() const
|
||
15 years ago
|
{
|
||
|
return mName;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
Set label providing a translated one-line description of the item.
|
||
|
*/
|
||
15 years ago
|
void setLabel( const TQString &l )
|
||
15 years ago
|
{
|
||
|
mLabel = l;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
Return label of item. See setLabel().
|
||
|
*/
|
||
15 years ago
|
TQString label() const
|
||
15 years ago
|
{
|
||
|
return mLabel;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
Set WhatsThis description og item.
|
||
|
*/
|
||
15 years ago
|
void setWhatsThis( const TQString &w )
|
||
15 years ago
|
{
|
||
|
mWhatsThis = w;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
Return WhatsThis description of item. See setWhatsThis().
|
||
|
*/
|
||
15 years ago
|
TQString whatsThis() const
|
||
15 years ago
|
{
|
||
|
return mWhatsThis;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* This function is called by @ref KConfigSkeleton to read the value for this setting
|
||
|
* from a config file.
|
||
|
* value.
|
||
|
*/
|
||
|
virtual void readConfig(KConfig *) = 0;
|
||
|
|
||
|
/**
|
||
|
* This function is called by @ref KConfigSkeleton to write the value of this setting
|
||
|
* to a config file.
|
||
|
*/
|
||
|
virtual void writeConfig(KConfig *) = 0;
|
||
|
|
||
|
/**
|
||
|
* Read global default value.
|
||
|
*/
|
||
|
virtual void readDefault(KConfig *) = 0;
|
||
|
|
||
|
/**
|
||
|
* Set item to @p p
|
||
|
*/
|
||
15 years ago
|
virtual void setProperty(const TQVariant &p) = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Return item as property
|
||
|
*/
|
||
15 years ago
|
virtual TQVariant property() const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Return minimum value of item or invalid if not specified
|
||
|
*/
|
||
15 years ago
|
virtual TQVariant minValue() const { return TQVariant(); }
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Return maximum value of item or invalid if not specified
|
||
|
*/
|
||
15 years ago
|
virtual TQVariant maxValue() const { return TQVariant(); }
|
||
15 years ago
|
|
||
|
/**
|
||
|
Sets the current value to the default value.
|
||
|
*/
|
||
|
virtual void setDefault() = 0;
|
||
|
|
||
|
/**
|
||
|
* Exchanges the current value with the default value
|
||
|
* Used by KConfigSkeleton::useDefaults(bool);
|
||
|
*/
|
||
|
virtual void swapDefault() = 0;
|
||
|
|
||
|
/**
|
||
|
* Return if the entry can be modified.
|
||
|
*/
|
||
|
bool isImmutable() const
|
||
|
{
|
||
|
return mIsImmutable;
|
||
|
}
|
||
|
|
||
|
protected:
|
||
|
/**
|
||
|
* sets mIsImmutable to true if mKey in config is immutable
|
||
|
* @param config KConfig to check if mKey is immutable in
|
||
|
*/
|
||
|
void readImmutability(KConfig *config);
|
||
|
|
||
15 years ago
|
TQString mGroup;
|
||
|
TQString mKey;
|
||
|
TQString mName;
|
||
15 years ago
|
|
||
|
private:
|
||
|
bool mIsImmutable;
|
||
|
|
||
15 years ago
|
TQString mLabel;
|
||
|
TQString mWhatsThis;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
template < typename T > class KConfigSkeletonGenericItem:public KConfigSkeletonItem
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
KConfigSkeletonGenericItem(const TQString & group, const TQString & key, T & reference,
|
||
15 years ago
|
T defaultValue)
|
||
|
: KConfigSkeletonItem(group, key), mReference(reference),
|
||
|
mDefault(defaultValue), mLoadedValue(defaultValue)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Set value of this KConfigSkeletonItem.
|
||
|
*/
|
||
|
void setValue(const T & v)
|
||
|
{
|
||
|
mReference = v;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return value of this KConfigSkeletonItem.
|
||
|
*/
|
||
|
T & value()
|
||
|
{
|
||
|
return mReference;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return const value of this KConfigSkeletonItem.
|
||
|
*/
|
||
|
const T & value() const
|
||
|
{
|
||
|
return mReference;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
Set default value for this item.
|
||
|
*/
|
||
|
virtual void setDefaultValue( const T &v )
|
||
|
{
|
||
|
mDefault = v;
|
||
|
}
|
||
|
|
||
|
virtual void setDefault()
|
||
|
{
|
||
|
mReference = mDefault;
|
||
|
}
|
||
|
|
||
|
virtual void writeConfig(KConfig * config)
|
||
|
{
|
||
|
if ( mReference != mLoadedValue ) // Is this needed?
|
||
|
{
|
||
|
config->setGroup(mGroup);
|
||
|
if ((mDefault == mReference) && !config->hasDefault( mKey))
|
||
|
config->revertToDefault( mKey );
|
||
|
else
|
||
|
config->writeEntry(mKey, mReference);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void readDefault(KConfig * config)
|
||
|
{
|
||
|
config->setReadDefaults(true);
|
||
|
readConfig(config);
|
||
|
config->setReadDefaults(false);
|
||
|
mDefault = mReference;
|
||
|
}
|
||
|
|
||
|
void swapDefault()
|
||
|
{
|
||
|
T tmp = mReference;
|
||
|
mReference = mDefault;
|
||
|
mDefault = tmp;
|
||
|
}
|
||
|
|
||
|
protected:
|
||
|
T & mReference;
|
||
|
T mDefault;
|
||
|
T mLoadedValue;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* @short Class for handling preferences settings for an application.
|
||
|
* @author Cornelius Schumacher
|
||
|
* @see KConfigSkeletonItem
|
||
|
*
|
||
|
* This class provides an interface to preferences settings. Preferences items
|
||
|
* can be registered by the addItem() function corresponding to the data type of
|
||
|
* the seetting. KConfigSkeleton then handles reading and writing of config files and
|
||
|
* setting of default values.
|
||
|
*
|
||
|
* Normally you will subclass KConfigSkeleton, add data members for the preferences
|
||
|
* settings and register the members in the constructor of the subclass.
|
||
|
*
|
||
|
* Example:
|
||
|
* \code
|
||
|
* class MyPrefs : public KConfigSkeleton
|
||
|
* {
|
||
|
* public:
|
||
|
* MyPrefs()
|
||
|
* {
|
||
|
* setCurrentGroup("MyGroup");
|
||
|
* addItemBool("MySetting1",mMyBool,false);
|
||
15 years ago
|
* addItemColor("MySetting2",mMyColor,TQColor(1,2,3));
|
||
15 years ago
|
*
|
||
|
* setCurrentGroup("MyOtherGroup");
|
||
15 years ago
|
* addItemFont("MySetting3",mMyFont,TQFont("helvetica",12));
|
||
15 years ago
|
* }
|
||
|
*
|
||
|
* bool mMyBool;
|
||
15 years ago
|
* TQColor mMyColor;
|
||
|
* TQFont mMyFont;
|
||
15 years ago
|
* }
|
||
|
* \endcode
|
||
|
*
|
||
|
* It might be convenient in many cases to make this subclass of KConfigSkeleton a
|
||
|
* singleton for global access from all over the application without passing
|
||
|
* references to the KConfigSkeleton object around.
|
||
|
*
|
||
|
* You can write the data to the configuration file by calling @ref writeConfig()
|
||
|
* and read the data from the configuration file by calling @ref readConfig().
|
||
|
*
|
||
|
* If you have items, which are not covered by the existing addItem() functions
|
||
|
* you can add customized code for reading, writing and default setting by
|
||
|
* implementing the functions @ref usrUseDefaults(), @ref usrReadConfig() and
|
||
|
* @ref usrWriteConfig().
|
||
|
*
|
||
|
* Internally preferences settings are stored in instances of subclasses of
|
||
|
* @ref KConfigSkeletonItem. You can also add KConfigSkeletonItem subclasses
|
||
|
* for your own types and call the generic @ref addItem() to register them.
|
||
|
*
|
||
|
* In many cases you don't have to write the specific KConfigSkeleton
|
||
|
* subclasses yourself, but you can use \ref kconfig_compiler to automatically
|
||
|
* generate the C++ code from an XML description of the configuration options.
|
||
|
*/
|
||
|
class KDECORE_EXPORT KConfigSkeleton
|
||
|
{
|
||
|
public:
|
||
|
|
||
|
/**
|
||
|
* Class for handling a string preferences item.
|
||
|
*/
|
||
15 years ago
|
class KDECORE_EXPORT ItemString:public KConfigSkeletonGenericItem < TQString >
|
||
15 years ago
|
{
|
||
|
public:
|
||
|
enum Type { Normal, Password, Path };
|
||
|
|
||
15 years ago
|
ItemString(const TQString & group, const TQString & key,
|
||
|
TQString & reference,
|
||
14 years ago
|
const TQString & defaultValue = TQString::tqfromLatin1(""), // NOT TQString::null !!
|
||
15 years ago
|
Type type = Normal);
|
||
|
|
||
|
void writeConfig(KConfig * config);
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
|
||
|
private:
|
||
|
Type mType;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Class for handling a password preferences item.
|
||
|
*/
|
||
|
class KDECORE_EXPORT ItemPassword:public ItemString
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
ItemPassword(const TQString & group, const TQString & key,
|
||
|
TQString & reference,
|
||
14 years ago
|
const TQString & defaultValue = TQString::tqfromLatin1("")); // NOT TQString::null !!
|
||
15 years ago
|
};
|
||
|
|
||
|
/**
|
||
|
* Class for handling a path preferences item.
|
||
|
*/
|
||
|
class KDECORE_EXPORT ItemPath:public ItemString
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
ItemPath(const TQString & group, const TQString & key,
|
||
|
TQString & reference,
|
||
|
const TQString & defaultValue = TQString::null);
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
15 years ago
|
* Class for handling a TQVariant preferences item.
|
||
15 years ago
|
*/
|
||
15 years ago
|
class KDECORE_EXPORT ItemProperty:public KConfigSkeletonGenericItem < TQVariant >
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
ItemProperty(const TQString & group, const TQString & key,
|
||
|
TQVariant & reference, TQVariant defaultValue = 0);
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Class for handling a bool preferences item.
|
||
|
*/
|
||
|
class KDECORE_EXPORT ItemBool:public KConfigSkeletonGenericItem < bool >
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
ItemBool(const TQString & group, const TQString & key, bool & reference,
|
||
15 years ago
|
bool defaultValue = true);
|
||
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Class for handling an integer preferences item.
|
||
|
*/
|
||
|
class KDECORE_EXPORT ItemInt:public KConfigSkeletonGenericItem < int >
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
ItemInt(const TQString & group, const TQString & key, int &reference,
|
||
15 years ago
|
int defaultValue = 0);
|
||
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
|
TQVariant minValue() const;
|
||
|
TQVariant maxValue() const;
|
||
15 years ago
|
|
||
|
void setMinValue(int);
|
||
|
void setMaxValue(int);
|
||
|
|
||
|
private:
|
||
|
bool mHasMin : 1;
|
||
|
bool mHasMax : 1;
|
||
|
int mMin;
|
||
|
int mMax;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Class for handling an 64-bit integer preferences item.
|
||
|
*/
|
||
14 years ago
|
class KDECORE_EXPORT ItemInt64:public KConfigSkeletonGenericItem < TQ_INT64 >
|
||
15 years ago
|
{
|
||
|
public:
|
||
14 years ago
|
ItemInt64(const TQString & group, const TQString & key, TQ_INT64 &reference,
|
||
|
TQ_INT64 defaultValue = 0);
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
|
||
15 years ago
|
TQVariant minValue() const;
|
||
|
TQVariant maxValue() const;
|
||
15 years ago
|
|
||
14 years ago
|
void setMinValue(TQ_INT64);
|
||
|
void setMaxValue(TQ_INT64);
|
||
15 years ago
|
|
||
|
private:
|
||
|
bool mHasMin : 1;
|
||
|
bool mHasMax : 1;
|
||
14 years ago
|
TQ_INT64 mMin;
|
||
|
TQ_INT64 mMax;
|
||
15 years ago
|
};
|
||
|
|
||
|
/**
|
||
|
* Class for handling enums.
|
||
|
*/
|
||
|
class KDECORE_EXPORT ItemEnum:public ItemInt
|
||
|
{
|
||
|
public:
|
||
|
struct Choice
|
||
|
{
|
||
15 years ago
|
TQString name;
|
||
|
TQString label;
|
||
|
TQString whatsThis;
|
||
15 years ago
|
};
|
||
|
|
||
15 years ago
|
ItemEnum(const TQString & group, const TQString & key, int &reference,
|
||
|
const TQValueList<Choice> &choices, int defaultValue = 0);
|
||
15 years ago
|
|
||
15 years ago
|
TQValueList<Choice> choices() const;
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
|
void writeConfig(KConfig * config);
|
||
|
|
||
|
private:
|
||
15 years ago
|
TQValueList<Choice> mChoices;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Class for handling an unsingend integer preferences item.
|
||
|
*/
|
||
|
class KDECORE_EXPORT ItemUInt:public KConfigSkeletonGenericItem < unsigned int >
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
ItemUInt(const TQString & group, const TQString & key,
|
||
15 years ago
|
unsigned int &reference, unsigned int defaultValue = 0);
|
||
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
|
TQVariant minValue() const;
|
||
|
TQVariant maxValue() const;
|
||
15 years ago
|
|
||
|
void setMinValue(unsigned int);
|
||
|
void setMaxValue(unsigned int);
|
||
|
|
||
|
private:
|
||
|
bool mHasMin : 1;
|
||
|
bool mHasMax : 1;
|
||
|
unsigned int mMin;
|
||
|
unsigned int mMax;
|
||
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Class for hanlding a long integer preferences item.
|
||
|
*/
|
||
|
class KDECORE_EXPORT ItemLong:public KConfigSkeletonGenericItem < long >
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
ItemLong(const TQString & group, const TQString & key, long &reference,
|
||
15 years ago
|
long defaultValue = 0);
|
||
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
|
TQVariant minValue() const;
|
||
|
TQVariant maxValue() const;
|
||
15 years ago
|
|
||
|
void setMinValue(long);
|
||
|
void setMaxValue(long);
|
||
|
|
||
|
private:
|
||
|
bool mHasMin : 1;
|
||
|
bool mHasMax : 1;
|
||
|
long mMin;
|
||
|
long mMax;
|
||
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Class for handling an unsigned long integer preferences item.
|
||
|
*/
|
||
|
class KDECORE_EXPORT ItemULong:public KConfigSkeletonGenericItem < unsigned long >
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
ItemULong(const TQString & group, const TQString & key,
|
||
15 years ago
|
unsigned long &reference, unsigned long defaultValue = 0);
|
||
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
|
TQVariant minValue() const;
|
||
|
TQVariant maxValue() const;
|
||
15 years ago
|
|
||
|
void setMinValue(unsigned long);
|
||
|
void setMaxValue(unsigned long);
|
||
|
|
||
|
private:
|
||
|
bool mHasMin : 1;
|
||
|
bool mHasMax : 1;
|
||
|
unsigned long mMin;
|
||
|
unsigned long mMax;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Class for handling unsigned 64-bit integer preferences item.
|
||
|
*/
|
||
14 years ago
|
class KDECORE_EXPORT ItemUInt64:public KConfigSkeletonGenericItem < TQ_UINT64 >
|
||
15 years ago
|
{
|
||
|
public:
|
||
14 years ago
|
ItemUInt64(const TQString & group, const TQString & key, TQ_UINT64 &reference,
|
||
|
TQ_UINT64 defaultValue = 0);
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
|
||
15 years ago
|
TQVariant minValue() const;
|
||
|
TQVariant maxValue() const;
|
||
15 years ago
|
|
||
14 years ago
|
void setMinValue(TQ_UINT64);
|
||
|
void setMaxValue(TQ_UINT64);
|
||
15 years ago
|
|
||
|
private:
|
||
|
bool mHasMin : 1;
|
||
|
bool mHasMax : 1;
|
||
14 years ago
|
TQ_UINT64 mMin;
|
||
|
TQ_UINT64 mMax;
|
||
15 years ago
|
};
|
||
|
|
||
|
/**
|
||
|
* Class for handling a floating point preference item.
|
||
|
*/
|
||
|
class KDECORE_EXPORT ItemDouble:public KConfigSkeletonGenericItem < double >
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
ItemDouble(const TQString & group, const TQString & key,
|
||
15 years ago
|
double &reference, double defaultValue = 0);
|
||
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
|
TQVariant minValue() const;
|
||
|
TQVariant maxValue() const;
|
||
15 years ago
|
|
||
|
void setMinValue(double);
|
||
|
void setMaxValue(double);
|
||
|
|
||
|
private:
|
||
|
bool mHasMin : 1;
|
||
|
bool mHasMax : 1;
|
||
|
double mMin;
|
||
|
double mMax;
|
||
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Class for handling a color preferences item.
|
||
|
*/
|
||
15 years ago
|
class KDECORE_EXPORT ItemColor:public KConfigSkeletonGenericItem < TQColor >
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
ItemColor(const TQString & group, const TQString & key,
|
||
|
TQColor & reference,
|
||
|
const TQColor & defaultValue = TQColor(128, 128, 128));
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Class for handling a font preferences item.
|
||
|
*/
|
||
15 years ago
|
class KDECORE_EXPORT ItemFont:public KConfigSkeletonGenericItem < TQFont >
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
ItemFont(const TQString & group, const TQString & key, TQFont & reference,
|
||
|
const TQFont & defaultValue = KGlobalSettings::generalFont());
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
15 years ago
|
* Class for handling a TQRect preferences item.
|
||
15 years ago
|
*/
|
||
15 years ago
|
class KDECORE_EXPORT ItemRect:public KConfigSkeletonGenericItem < TQRect >
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
ItemRect(const TQString & group, const TQString & key, TQRect & reference,
|
||
|
const TQRect & defaultValue = TQRect());
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
15 years ago
|
* Class for handling a TQPoint preferences item.
|
||
15 years ago
|
*/
|
||
15 years ago
|
class KDECORE_EXPORT ItemPoint:public KConfigSkeletonGenericItem < TQPoint >
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
ItemPoint(const TQString & group, const TQString & key, TQPoint & reference,
|
||
|
const TQPoint & defaultValue = TQPoint());
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
15 years ago
|
* Class for handling a TQSize preferences item.
|
||
15 years ago
|
*/
|
||
15 years ago
|
class KDECORE_EXPORT ItemSize:public KConfigSkeletonGenericItem < TQSize >
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
ItemSize(const TQString & group, const TQString & key, TQSize & reference,
|
||
|
const TQSize & defaultValue = TQSize());
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
15 years ago
|
* Class for handling a TQDateTime preferences item.
|
||
15 years ago
|
*/
|
||
15 years ago
|
class KDECORE_EXPORT ItemDateTime:public KConfigSkeletonGenericItem < TQDateTime >
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
ItemDateTime(const TQString & group, const TQString & key,
|
||
|
TQDateTime & reference,
|
||
|
const TQDateTime & defaultValue = TQDateTime());
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Class for handling a string list preferences item.
|
||
|
*/
|
||
15 years ago
|
class KDECORE_EXPORT ItemStringList:public KConfigSkeletonGenericItem < TQStringList >
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
ItemStringList(const TQString & group, const TQString & key,
|
||
|
TQStringList & reference,
|
||
|
const TQStringList & defaultValue = TQStringList());
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Class for handling a path list preferences item.
|
||
|
*/
|
||
|
class KDECORE_EXPORT ItemPathList:public ItemStringList
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
ItemPathList(const TQString & group, const TQString & key,
|
||
|
TQStringList & reference,
|
||
|
const TQStringList & defaultValue = TQStringList());
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
|
void writeConfig(KConfig * config);
|
||
|
};
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Class for handling an integer list preferences item.
|
||
|
*/
|
||
15 years ago
|
class KDECORE_EXPORT ItemIntList:public KConfigSkeletonGenericItem < TQValueList < int > >
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
ItemIntList(const TQString & group, const TQString & key,
|
||
|
TQValueList < int >&reference,
|
||
|
const TQValueList < int >&defaultValue = TQValueList < int >());
|
||
15 years ago
|
|
||
|
void readConfig(KConfig * config);
|
||
15 years ago
|
void setProperty(const TQVariant & p);
|
||
|
TQVariant property() const;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
public:
|
||
|
/**
|
||
|
* Constructor.
|
||
|
*
|
||
|
* @param configname name of config file. If no name is given, the default
|
||
|
* config file as returned by kapp()->config() is used.
|
||
|
*/
|
||
15 years ago
|
KConfigSkeleton(const TQString & configname = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Constructor.
|
||
|
*
|
||
|
* @param config configuration object to use.
|
||
|
*/
|
||
|
KConfigSkeleton(KSharedConfig::Ptr config);
|
||
|
|
||
|
/**
|
||
|
* Destructor
|
||
|
*/
|
||
|
virtual ~ KConfigSkeleton();
|
||
|
|
||
|
/**
|
||
|
Set all registered items to their default values.
|
||
|
*/
|
||
|
void setDefaults();
|
||
|
|
||
|
/**
|
||
|
* Read preferences from config file. All registered items are set to the
|
||
|
* values read from disk.
|
||
|
*/
|
||
|
void readConfig();
|
||
|
|
||
|
/**
|
||
|
* Write preferences to config file. The values of all registered items are
|
||
|
* written to disk.
|
||
|
*/
|
||
|
void writeConfig();
|
||
|
|
||
|
/**
|
||
|
* Set the config file group for subsequent addItem() calls. It is valid
|
||
|
* until setCurrentGroup() is called with a new argument. Call this before
|
||
|
* you add any items. The default value is "No Group".
|
||
|
*/
|
||
15 years ago
|
void setCurrentGroup(const TQString & group);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the current group used for addItem() calls.
|
||
|
*/
|
||
15 years ago
|
TQString currentGroup() // ### KDE 4.0: make const
|
||
15 years ago
|
{
|
||
|
return mCurrentGroup;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Register a custom @ref KConfigSkeletonItem with a given name. If the name
|
||
|
* parameter is null, take the name from KConfigSkeletonItem::key().
|
||
|
* Note that all names must be unique but that multiple entries can have
|
||
|
* the same key if they reside in different groups.
|
||
|
*/
|
||
15 years ago
|
void addItem(KConfigSkeletonItem *, const TQString & name = TQString::null );
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register an item of type TQString.
|
||
15 years ago
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemString *addItemString(const TQString & name, TQString & reference,
|
||
14 years ago
|
const TQString & defaultValue = TQString::tqfromLatin1(""), // NOT TQString::null !!
|
||
15 years ago
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register a password item of type TQString. The string value is written
|
||
15 years ago
|
* encrypted to the config file. Note that the current encryption scheme
|
||
|
* is very weak.
|
||
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemPassword *addItemPassword(const TQString & name, TQString & reference,
|
||
14 years ago
|
const TQString & defaultValue = TQString::tqfromLatin1(""),
|
||
15 years ago
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register a path item of type TQString. The string value is interpreted
|
||
15 years ago
|
* as a path. This means, dollar expension is activated for this value, so
|
||
|
* that e.g. $HOME gets expanded.
|
||
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemPath *addItemPath(const TQString & name, TQString & reference,
|
||
14 years ago
|
const TQString & defaultValue = TQString::tqfromLatin1(""),
|
||
15 years ago
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register a property item of type TQVariant. Note that only the following
|
||
|
* TQVariant types are allowed: String, StringList, Font, Point, Rect, Size,
|
||
15 years ago
|
* Color, Int, UInt, Bool, Double, DateTime and Date.
|
||
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemProperty *addItemProperty(const TQString & name, TQVariant & reference,
|
||
|
const TQVariant & defaultValue = TQVariant(),
|
||
|
const TQString & key = TQString::null);
|
||
15 years ago
|
/**
|
||
|
* Register an item of type bool.
|
||
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemBool *addItemBool(const TQString & name, bool & reference,
|
||
15 years ago
|
bool defaultValue = false,
|
||
15 years ago
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Register an item of type int.
|
||
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemInt *addItemInt(const TQString & name, int &reference, int defaultValue = 0,
|
||
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Register an item of type unsigned int.
|
||
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemUInt *addItemUInt(const TQString & name, unsigned int &reference,
|
||
15 years ago
|
unsigned int defaultValue = 0,
|
||
15 years ago
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Register an item of type long.
|
||
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemLong *addItemLong(const TQString & name, long &reference,
|
||
15 years ago
|
long defaultValue = 0,
|
||
15 years ago
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Register an item of type unsigned long.
|
||
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemULong *addItemULong(const TQString & name, unsigned long &reference,
|
||
15 years ago
|
unsigned long defaultValue = 0,
|
||
15 years ago
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
14 years ago
|
* Register an item of type TQ_INT64.
|
||
15 years ago
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
14 years ago
|
ItemInt64 *addItemInt64(const TQString & name, TQ_INT64 &reference,
|
||
|
TQ_INT64 defaultValue = 0,
|
||
15 years ago
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
14 years ago
|
* Register an item of type TQ_UINT64
|
||
15 years ago
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
14 years ago
|
ItemUInt64 *addItemUInt64(const TQString & name, TQ_UINT64 &reference,
|
||
|
TQ_UINT64 defaultValue = 0,
|
||
15 years ago
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Register an item of type double.
|
||
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemDouble *addItemDouble(const TQString & name, double &reference,
|
||
15 years ago
|
double defaultValue = 0.0,
|
||
15 years ago
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register an item of type TQColor.
|
||
15 years ago
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemColor *addItemColor(const TQString & name, TQColor & reference,
|
||
|
const TQColor & defaultValue = TQColor(128, 128, 128),
|
||
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register an item of type TQFont.
|
||
15 years ago
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemFont *addItemFont(const TQString & name, TQFont & reference,
|
||
|
const TQFont & defaultValue =
|
||
15 years ago
|
KGlobalSettings::generalFont(),
|
||
15 years ago
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register an item of type TQRect.
|
||
15 years ago
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemRect *addItemRect(const TQString & name, TQRect & reference,
|
||
|
const TQRect & defaultValue = TQRect(),
|
||
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register an item of type TQPoint.
|
||
15 years ago
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemPoint *addItemPoint(const TQString & name, TQPoint & reference,
|
||
|
const TQPoint & defaultValue = TQPoint(),
|
||
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register an item of type TQSize.
|
||
15 years ago
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemSize *addItemSize(const TQString & name, TQSize & reference,
|
||
|
const TQSize & defaultValue = TQSize(),
|
||
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register an item of type TQDateTime.
|
||
15 years ago
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemDateTime *addItemDateTime(const TQString & name, TQDateTime & reference,
|
||
|
const TQDateTime & defaultValue = TQDateTime(),
|
||
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register an item of type TQStringList.
|
||
15 years ago
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemStringList *addItemStringList(const TQString & name, TQStringList & reference,
|
||
|
const TQStringList & defaultValue = TQStringList(),
|
||
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Register an item of type TQValueList<int>.
|
||
15 years ago
|
*
|
||
|
* @param name Name used to indentify this setting. Names must be unique.
|
||
|
* @param reference Pointer to the variable, which is set by readConfig()
|
||
|
* calls and read by writeConfig() calls.
|
||
|
* @param defaultValue Default value, which is used when the config file
|
||
|
* does not yet contain the key of this item.
|
||
|
* @param key Key used in config file. If key is null, name is used as key.
|
||
|
* @return The created item
|
||
|
*/
|
||
15 years ago
|
ItemIntList *addItemIntList(const TQString & name, TQValueList < int >&reference,
|
||
|
const TQValueList < int >&defaultValue =
|
||
|
TQValueList < int >(),
|
||
|
const TQString & key = TQString::null);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Return the @ref KConfig object used for reading and writing the settings.
|
||
|
*/
|
||
|
KConfig *config() const;
|
||
|
|
||
|
/**
|
||
|
* Return list of items managed by this KConfigSkeleton object.
|
||
|
*/
|
||
|
KConfigSkeletonItem::List items() const
|
||
|
{
|
||
|
return mItems;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return whether a certain item is immutable
|
||
|
*/
|
||
15 years ago
|
bool isImmutable(const TQString & name);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Lookup item by name
|
||
|
*/
|
||
14 years ago
|
KConfigSkeletonItem * findItem(const TQString & name);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Indicate whether this object should reflect the actual
|
||
|
* values or the default values.
|
||
|
* @param b If true this object reflects the default values.
|
||
|
* @return The state prior to this call
|
||
|
*/
|
||
|
bool useDefaults(bool b);
|
||
|
|
||
|
protected:
|
||
|
/**
|
||
|
* Implemented by subclasses that use special defaults.
|
||
14 years ago
|
* It should replace the default values with the actual
|
||
15 years ago
|
* values and vice versa.
|
||
|
*/
|
||
|
virtual void usrUseDefaults(bool)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
virtual void usrSetDefaults()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Implemented by subclasses that read special config values.
|
||
|
*/
|
||
|
virtual void usrReadConfig()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Implemented by subclasses that write special config values.
|
||
|
*/
|
||
|
virtual void usrWriteConfig()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
private:
|
||
15 years ago
|
TQString mCurrentGroup;
|
||
15 years ago
|
|
||
|
KSharedConfig::Ptr mConfig; // pointer to KConfig object
|
||
|
|
||
|
KConfigSkeletonItem::List mItems;
|
||
|
KConfigSkeletonItem::Dict mItemDict;
|
||
|
|
||
|
bool mUseDefaults;
|
||
|
|
||
|
class Private;
|
||
|
Private *d;
|
||
|
|
||
|
};
|
||
|
|
||
|
#endif
|