23 #ifndef _KCONFIGSKELETON_H
24 #define _KCONFIGSKELETON_H
27 #include <tqdatetime.h>
30 #include <tqptrlist.h>
34 #include <tqstringlist.h>
35 #include <tqvariant.h>
37 #include <kglobalsettings.h>
53 typedef TQValueList < KConfigSkeletonItem * >List;
54 typedef TQDict < KConfigSkeletonItem > Dict;
55 typedef TQDictIterator < KConfigSkeletonItem > DictIterator;
64 :mGroup(group),mKey(key), mIsImmutable(true)
186 virtual TQVariant
minValue()
const {
return TQVariant(); }
191 virtual TQVariant
maxValue()
const {
return TQVariant(); }
217 void readImmutability(
KConfig *config);
234 KConfigSkeletonGenericItem(
const TQString & group,
const TQString & key, T & reference,
237 mDefault(defaultValue), mLoadedValue(defaultValue)
244 void setValue(
const T & v)
260 const T & value()
const
268 virtual void setDefaultValue(
const T &v )
275 mReference = mDefault;
280 if ( mReference != mLoadedValue )
283 if ((mDefault == mReference) && !config->
hasDefault( mKey))
295 mDefault = mReference;
301 mReference = mDefault;
372 class KDECORE_EXPORT
ItemString:
public KConfigSkeletonGenericItem < TQString >
375 enum Type { Normal, Password, Path };
377 ItemString(
const TQString & group,
const TQString & key,
378 TQString & reference,
379 const TQString & defaultValue = TQString::fromLatin1(
""),
382 void writeConfig(
KConfig * config);
383 void readConfig(
KConfig * config);
384 void setProperty(
const TQVariant & p);
385 TQVariant property()
const;
397 ItemPassword(
const TQString & group,
const TQString & key,
398 TQString & reference,
399 const TQString & defaultValue = TQString::fromLatin1(
""));
408 ItemPath(
const TQString & group,
const TQString & key,
409 TQString & reference,
410 const TQString & defaultValue = TQString::null);
417 class KDECORE_EXPORT
ItemProperty:
public KConfigSkeletonGenericItem < TQVariant >
420 ItemProperty(
const TQString & group,
const TQString & key,
421 TQVariant & reference, TQVariant defaultValue = 0);
423 void readConfig(
KConfig * config);
424 void setProperty(
const TQVariant & p);
425 TQVariant property()
const;
432 class KDECORE_EXPORT
ItemBool:
public KConfigSkeletonGenericItem < bool >
435 ItemBool(
const TQString & group,
const TQString & key,
bool & reference,
436 bool defaultValue =
true);
438 void readConfig(
KConfig * config);
439 void setProperty(
const TQVariant & p);
440 TQVariant property()
const;
447 class KDECORE_EXPORT
ItemInt:
public KConfigSkeletonGenericItem < int >
450 ItemInt(
const TQString & group,
const TQString & key,
int &reference,
451 int defaultValue = 0);
453 void readConfig(
KConfig * config);
454 void setProperty(
const TQVariant & p);
455 TQVariant property()
const;
456 TQVariant minValue()
const;
457 TQVariant maxValue()
const;
459 void setMinValue(
int);
460 void setMaxValue(
int);
472 class KDECORE_EXPORT
ItemInt64:
public KConfigSkeletonGenericItem < TQ_INT64 >
475 ItemInt64(
const TQString & group,
const TQString & key, TQ_INT64 &reference,
476 TQ_INT64 defaultValue = 0);
478 void readConfig(
KConfig * config);
479 void setProperty(
const TQVariant & p);
480 TQVariant property()
const;
482 TQVariant minValue()
const;
483 TQVariant maxValue()
const;
485 void setMinValue(TQ_INT64);
486 void setMaxValue(TQ_INT64);
508 ItemEnum(
const TQString & group,
const TQString & key,
int &reference,
509 const TQValueList<Choice> &choices,
int defaultValue = 0);
511 TQValueList<Choice> choices()
const;
513 void readConfig(
KConfig * config);
514 void writeConfig(
KConfig * config);
517 TQValueList<Choice> mChoices;
524 class KDECORE_EXPORT
ItemUInt:
public KConfigSkeletonGenericItem < unsigned int >
527 ItemUInt(
const TQString & group,
const TQString & key,
528 unsigned int &reference,
unsigned int defaultValue = 0);
530 void readConfig(
KConfig * config);
531 void setProperty(
const TQVariant & p);
532 TQVariant property()
const;
533 TQVariant minValue()
const;
534 TQVariant maxValue()
const;
536 void setMinValue(
unsigned int);
537 void setMaxValue(
unsigned int);
550 class KDECORE_EXPORT
ItemLong:
public KConfigSkeletonGenericItem < long >
553 ItemLong(
const TQString & group,
const TQString & key,
long &reference,
554 long defaultValue = 0);
556 void readConfig(
KConfig * config);
557 void setProperty(
const TQVariant & p);
558 TQVariant property()
const;
559 TQVariant minValue()
const;
560 TQVariant maxValue()
const;
562 void setMinValue(
long);
563 void setMaxValue(
long);
576 class KDECORE_EXPORT
ItemULong:
public KConfigSkeletonGenericItem < unsigned long >
579 ItemULong(
const TQString & group,
const TQString & key,
580 unsigned long &reference,
unsigned long defaultValue = 0);
582 void readConfig(
KConfig * config);
583 void setProperty(
const TQVariant & p);
584 TQVariant property()
const;
585 TQVariant minValue()
const;
586 TQVariant maxValue()
const;
588 void setMinValue(
unsigned long);
589 void setMaxValue(
unsigned long);
601 class KDECORE_EXPORT
ItemUInt64:
public KConfigSkeletonGenericItem < TQ_UINT64 >
604 ItemUInt64(
const TQString & group,
const TQString & key, TQ_UINT64 &reference,
605 TQ_UINT64 defaultValue = 0);
607 void readConfig(
KConfig * config);
608 void setProperty(
const TQVariant & p);
609 TQVariant property()
const;
611 TQVariant minValue()
const;
612 TQVariant maxValue()
const;
614 void setMinValue(TQ_UINT64);
615 void setMaxValue(TQ_UINT64);
627 class KDECORE_EXPORT
ItemDouble:
public KConfigSkeletonGenericItem < double >
630 ItemDouble(
const TQString & group,
const TQString & key,
631 double &reference,
double defaultValue = 0);
633 void readConfig(
KConfig * config);
634 void setProperty(
const TQVariant & p);
635 TQVariant property()
const;
636 TQVariant minValue()
const;
637 TQVariant maxValue()
const;
639 void setMinValue(
double);
640 void setMaxValue(
double);
653 class KDECORE_EXPORT
ItemColor:
public KConfigSkeletonGenericItem < TQColor >
656 ItemColor(
const TQString & group,
const TQString & key,
658 const TQColor & defaultValue = TQColor(128, 128, 128));
660 void readConfig(
KConfig * config);
661 void setProperty(
const TQVariant & p);
662 TQVariant property()
const;
669 class KDECORE_EXPORT
ItemFont:
public KConfigSkeletonGenericItem < TQFont >
672 ItemFont(
const TQString & group,
const TQString & key, TQFont & reference,
675 void readConfig(
KConfig * config);
676 void setProperty(
const TQVariant & p);
677 TQVariant property()
const;
684 class KDECORE_EXPORT
ItemRect:
public KConfigSkeletonGenericItem < TQRect >
687 ItemRect(
const TQString & group,
const TQString & key, TQRect & reference,
688 const TQRect & defaultValue = TQRect());
690 void readConfig(
KConfig * config);
691 void setProperty(
const TQVariant & p);
692 TQVariant property()
const;
699 class KDECORE_EXPORT
ItemPoint:
public KConfigSkeletonGenericItem < TQPoint >
702 ItemPoint(
const TQString & group,
const TQString & key, TQPoint & reference,
703 const TQPoint & defaultValue = TQPoint());
705 void readConfig(
KConfig * config);
706 void setProperty(
const TQVariant & p);
707 TQVariant property()
const;
714 class KDECORE_EXPORT
ItemSize:
public KConfigSkeletonGenericItem < TQSize >
717 ItemSize(
const TQString & group,
const TQString & key, TQSize & reference,
718 const TQSize & defaultValue = TQSize());
720 void readConfig(
KConfig * config);
721 void setProperty(
const TQVariant & p);
722 TQVariant property()
const;
729 class KDECORE_EXPORT
ItemDateTime:
public KConfigSkeletonGenericItem < TQDateTime >
732 ItemDateTime(
const TQString & group,
const TQString & key,
733 TQDateTime & reference,
734 const TQDateTime & defaultValue = TQDateTime());
736 void readConfig(
KConfig * config);
737 void setProperty(
const TQVariant & p);
738 TQVariant property()
const;
745 class KDECORE_EXPORT
ItemStringList:
public KConfigSkeletonGenericItem < TQStringList >
749 TQStringList & reference,
750 const TQStringList & defaultValue = TQStringList());
752 void readConfig(
KConfig * config);
753 void setProperty(
const TQVariant & p);
754 TQVariant property()
const;
764 ItemPathList(
const TQString & group,
const TQString & key,
765 TQStringList & reference,
766 const TQStringList & defaultValue = TQStringList());
768 void readConfig(
KConfig * config);
769 void writeConfig(
KConfig * config);
776 class KDECORE_EXPORT
ItemIntList:
public KConfigSkeletonGenericItem < TQValueList < int > >
779 ItemIntList(
const TQString & group,
const TQString & key,
780 TQValueList < int >&reference,
781 const TQValueList < int >&defaultValue = TQValueList < int >());
783 void readConfig(
KConfig * config);
784 void setProperty(
const TQVariant & p);
785 TQVariant property()
const;
832 void setCurrentGroup(
const TQString & group);
839 return mCurrentGroup;
861 ItemString *addItemString(
const TQString & name, TQString & reference,
862 const TQString & defaultValue = TQString::fromLatin1(
""),
863 const TQString & key = TQString::null);
878 ItemPassword *addItemPassword(
const TQString & name, TQString & reference,
879 const TQString & defaultValue = TQString::fromLatin1(
""),
880 const TQString & key = TQString::null);
895 ItemPath *addItemPath(
const TQString & name, TQString & reference,
896 const TQString & defaultValue = TQString::fromLatin1(
""),
897 const TQString & key = TQString::null);
912 ItemProperty *addItemProperty(
const TQString & name, TQVariant & reference,
913 const TQVariant & defaultValue = TQVariant(),
914 const TQString & key = TQString::null);
926 ItemBool *addItemBool(
const TQString & name,
bool & reference,
927 bool defaultValue =
false,
928 const TQString & key = TQString::null);
941 ItemInt *addItemInt(
const TQString & name,
int &reference,
int defaultValue = 0,
942 const TQString & key = TQString::null);
955 ItemUInt *addItemUInt(
const TQString & name,
unsigned int &reference,
956 unsigned int defaultValue = 0,
957 const TQString & key = TQString::null);
970 ItemLong *addItemLong(
const TQString & name,
long &reference,
971 long defaultValue = 0,
972 const TQString & key = TQString::null);
985 ItemULong *addItemULong(
const TQString & name,
unsigned long &reference,
986 unsigned long defaultValue = 0,
987 const TQString & key = TQString::null);
1000 ItemInt64 *addItemInt64(
const TQString & name, TQ_INT64 &reference,
1001 TQ_INT64 defaultValue = 0,
1002 const TQString & key = TQString::null);
1015 ItemUInt64 *addItemUInt64(
const TQString & name, TQ_UINT64 &reference,
1016 TQ_UINT64 defaultValue = 0,
1017 const TQString & key = TQString::null);
1030 ItemDouble *addItemDouble(
const TQString & name,
double &reference,
1031 double defaultValue = 0.0,
1032 const TQString & key = TQString::null);
1045 ItemColor *addItemColor(
const TQString & name, TQColor & reference,
1046 const TQColor & defaultValue = TQColor(128, 128, 128),
1047 const TQString & key = TQString::null);
1060 ItemFont *addItemFont(
const TQString & name, TQFont & reference,
1061 const TQFont & defaultValue =
1063 const TQString & key = TQString::null);
1076 ItemRect *addItemRect(
const TQString & name, TQRect & reference,
1077 const TQRect & defaultValue = TQRect(),
1078 const TQString & key = TQString::null);
1091 ItemPoint *addItemPoint(
const TQString & name, TQPoint & reference,
1092 const TQPoint & defaultValue = TQPoint(),
1093 const TQString & key = TQString::null);
1106 ItemSize *addItemSize(
const TQString & name, TQSize & reference,
1107 const TQSize & defaultValue = TQSize(),
1108 const TQString & key = TQString::null);
1121 ItemDateTime *addItemDateTime(
const TQString & name, TQDateTime & reference,
1122 const TQDateTime & defaultValue = TQDateTime(),
1123 const TQString & key = TQString::null);
1136 ItemStringList *addItemStringList(
const TQString & name, TQStringList & reference,
1137 const TQStringList & defaultValue = TQStringList(),
1138 const TQString & key = TQString::null);
1151 ItemIntList *addItemIntList(
const TQString & name, TQValueList < int >&reference,
1152 const TQValueList < int >&defaultValue =
1153 TQValueList < int >(),
1154 const TQString & key = TQString::null);
1172 bool isImmutable(
const TQString & name);
1185 bool useDefaults(
bool b);
1197 virtual void usrSetDefaults()
1216 TQString mCurrentGroup;
1220 KConfigSkeletonItem::List mItems;
1221 KConfigSkeletonItem::Dict mItemDict;
void revertToDefault(const TQString &key)
Reverts the entry with key key in the current group in the application specific config file to either...
bool hasDefault(const TQString &key) const
Returns whether a default is specified for an entry in either the system wide configuration file or t...
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a key/value pair.
void setGroup(const TQString &group)
Specifies the group in which keys will be read and written.
void setReadDefaults(bool b)
When set, all readEntry and readXXXEntry calls return the system wide (default) values instead of the...
Class for storing a preferences setting.
TQString name() const
Return internal name of entry.
bool isImmutable() const
Return if the entry can be modified.
virtual void writeConfig(KConfig *)=0
This function is called by KConfigSkeleton to write the value of this setting to a config file.
void setName(const TQString &name)
Set internal name of entry.
void setLabel(const TQString &l)
Set label providing a translated one-line description of the item.
TQString whatsThis() const
Return WhatsThis description of item.
TQString group() const
Return config file group.
void setKey(const TQString &key)
Set config file key.
TQString key() const
Return config file key.
virtual void swapDefault()=0
Exchanges the current value with the default value Used by KConfigSkeleton::useDefaults(bool);.
virtual void readDefault(KConfig *)=0
Read global default value.
void setGroup(const TQString &group)
Set config file group.
KConfigSkeletonItem(const TQString &group, const TQString &key)
Constructor.
virtual TQVariant property() const =0
Return item as property.
virtual TQVariant minValue() const
Return minimum value of item or invalid if not specified.
virtual void setDefault()=0
Sets the current value to the default value.
virtual void readConfig(KConfig *)=0
This function is called by KConfigSkeleton to read the value for this setting from a config file.
virtual void setProperty(const TQVariant &p)=0
Set item to p.
virtual TQVariant maxValue() const
Return maximum value of item or invalid if not specified.
void setWhatsThis(const TQString &w)
Set WhatsThis description og item.
virtual ~KConfigSkeletonItem()
Destructor.
TQString label() const
Return label of item.
Class for handling a bool preferences item.
Class for handling a color preferences item.
Class for handling a TQDateTime preferences item.
Class for handling a floating point preference item.
Class for handling a font preferences item.
Class for handling an 64-bit integer preferences item.
Class for handling an integer list preferences item.
Class for handling an integer preferences item.
Class for hanlding a long integer preferences item.
Class for handling a password preferences item.
Class for handling a path list preferences item.
Class for handling a path preferences item.
Class for handling a TQPoint preferences item.
Class for handling a TQVariant preferences item.
Class for handling a TQRect preferences item.
Class for handling a TQSize preferences item.
Class for handling a string list preferences item.
Class for handling a string preferences item.
Class for handling unsigned 64-bit integer preferences item.
Class for handling an unsingend integer preferences item.
Class for handling an unsigned long integer preferences item.
Class for handling preferences settings for an application.
virtual void usrReadConfig()
Implemented by subclasses that read special config values.
KConfigSkeletonItem::List items() const
Return list of items managed by this KConfigSkeleton object.
TQString currentGroup()
Returns the current group used for addItem() calls.
virtual void usrWriteConfig()
Implemented by subclasses that write special config values.
virtual ~ KConfigSkeleton()
Destructor.
virtual void usrUseDefaults(bool)
Implemented by subclasses that use special defaults.
Access KDE Configuration entries.
static TQFont generalFont()
Returns the default general font.