• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdecore
 

kdecore

  • kdecore
kconfigbase.cpp
1 // -*- c-basic-offset: 2 -*-
2 /*
3  This file is part of the KDE libraries
4  Copyright (c) 1999 Preston Brown <pbrown@kde.org>
5  Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #include <stdlib.h>
24 #include <string.h>
25 
26 #include <tqfile.h>
27 #include <tqdir.h>
28 #include <tqtextstream.h>
29 
30 #include <kapplication.h>
31 #include <kglobalsettings.h>
32 #include <kglobal.h>
33 #include <klocale.h>
34 #include <kcharsets.h>
35 
36 #include "kconfigbase.h"
37 #include "kconfigbackend.h"
38 #include "kdebug.h"
39 #include "kstandarddirs.h"
40 #include "kstringhandler.h"
41 
42 class KConfigBase::KConfigBasePrivate
43 {
44 public:
45  KConfigBasePrivate() : readDefaults(false) { };
46 
47 public:
48  bool readDefaults;
49 };
50 
51 KConfigBase::KConfigBase()
52  : backEnd(0L), bDirty(false), bLocaleInitialized(false),
53  bReadOnly(false), bExpand(false), d(0)
54 {
55  setGroup(TQString::null);
56 }
57 
58 KConfigBase::~KConfigBase()
59 {
60  delete d;
61 }
62 
63 void KConfigBase::setLocale()
64 {
65  bLocaleInitialized = true;
66 
67  if (KGlobal::locale())
68  aLocaleString = KGlobal::locale()->language().utf8();
69  else
70  aLocaleString = KLocale::defaultLanguage().utf8();
71  if (backEnd)
72  backEnd->setLocaleString(aLocaleString);
73 }
74 
75 TQString KConfigBase::locale() const
76 {
77  return TQString::fromUtf8(aLocaleString);
78 }
79 
80 void KConfigBase::setGroup( const TQString& group )
81 {
82  if ( group.isEmpty() )
83  mGroup = "<default>";
84  else
85  mGroup = group.utf8();
86 }
87 
88 void KConfigBase::setGroup( const char *pGroup )
89 {
90  setGroup(TQCString(pGroup));
91 }
92 
93 void KConfigBase::setGroup( const TQCString &group )
94 {
95  if ( group.isEmpty() )
96  mGroup = "<default>";
97  else
98  mGroup = group;
99 }
100 
101 TQString KConfigBase::group() const {
102  return TQString::fromUtf8(mGroup);
103 }
104 
105 void KConfigBase::setDesktopGroup()
106 {
107  mGroup = "Desktop Entry";
108 }
109 
110 bool KConfigBase::hasKey(const TQString &key) const
111 {
112  return hasKey(key.utf8().data());
113 }
114 
115 bool KConfigBase::hasKey(const char *pKey) const
116 {
117  KEntryKey aEntryKey(mGroup, 0);
118  aEntryKey.c_key = pKey;
119  aEntryKey.bDefault = readDefaults();
120 
121  if (!locale().isNull()) {
122  // try the localized key first
123  aEntryKey.bLocal = true;
124  KEntry entry = lookupData(aEntryKey);
125  if (!entry.mValue.isNull())
126  return true;
127  aEntryKey.bLocal = false;
128  }
129 
130  // try the non-localized version
131  KEntry entry = lookupData(aEntryKey);
132  return !entry.mValue.isNull();
133 }
134 
135 bool KConfigBase::hasTranslatedKey(const char* pKey) const
136 {
137  KEntryKey aEntryKey(mGroup, 0);
138  aEntryKey.c_key = pKey;
139  aEntryKey.bDefault = readDefaults();
140 
141  if (!locale().isNull()) {
142  // try the localized key first
143  aEntryKey.bLocal = true;
144  KEntry entry = lookupData(aEntryKey);
145  if (!entry.mValue.isNull())
146  return true;
147  aEntryKey.bLocal = false;
148  }
149 
150  return false;
151 }
152 
153 bool KConfigBase::hasGroup(const TQString &group) const
154 {
155  return internalHasGroup( group.utf8());
156 }
157 
158 bool KConfigBase::hasGroup(const char *_pGroup) const
159 {
160  return internalHasGroup( TQCString(_pGroup));
161 }
162 
163 bool KConfigBase::hasGroup(const TQCString &_pGroup) const
164 {
165  return internalHasGroup( _pGroup);
166 }
167 
168 bool KConfigBase::isImmutable() const
169 {
170  return (getConfigState() != ReadWrite);
171 }
172 
173 bool KConfigBase::groupIsImmutable(const TQString &group) const
174 {
175  if (getConfigState() != ReadWrite)
176  return true;
177 
178  KEntryKey groupKey(group.utf8(), 0);
179  KEntry entry = lookupData(groupKey);
180  return entry.bImmutable;
181 }
182 
183 bool KConfigBase::entryIsImmutable(const TQString &key) const
184 {
185  if (getConfigState() != ReadWrite)
186  return true;
187 
188  KEntryKey entryKey(mGroup, 0);
189  KEntry aEntryData = lookupData(entryKey); // Group
190  if (aEntryData.bImmutable)
191  return true;
192 
193  TQCString utf8_key = key.utf8();
194  entryKey.c_key = utf8_key.data();
195  aEntryData = lookupData(entryKey); // Normal entry
196  if (aEntryData.bImmutable)
197  return true;
198 
199  entryKey.bLocal = true;
200  aEntryData = lookupData(entryKey); // Localized entry
201  return aEntryData.bImmutable;
202 }
203 
204 
205 TQString KConfigBase::readEntryUntranslated( const TQString& pKey,
206  const TQString& aDefault ) const
207 {
208  return KConfigBase::readEntryUntranslated(pKey.utf8().data(), aDefault);
209 }
210 
211 
212 TQString KConfigBase::readEntryUntranslated( const char *pKey,
213  const TQString& aDefault ) const
214 {
215  TQCString result = readEntryUtf8(pKey);
216  if (result.isNull())
217  return aDefault;
218  return TQString::fromUtf8(result);
219 }
220 
221 
222 TQString KConfigBase::readEntry( const TQString& pKey,
223  const TQString& aDefault ) const
224 {
225  return KConfigBase::readEntry(pKey.utf8().data(), aDefault);
226 }
227 
228 TQString KConfigBase::readEntry( const char *pKey,
229  const TQString& aDefault ) const
230 {
231  // we need to access _locale instead of the method locale()
232  // because calling locale() will create a locale object if it
233  // doesn't exist, which requires KConfig, which will create a infinite
234  // loop, and nobody likes those.
235  if (!bLocaleInitialized && KGlobal::_locale) {
236  // get around const'ness.
237  KConfigBase *that = const_cast<KConfigBase *>(this);
238  that->setLocale();
239  }
240 
241  TQString aValue;
242 
243  bool expand = false;
244  // construct a localized version of the key
245  // try the localized key first
246  KEntry aEntryData;
247  KEntryKey entryKey(mGroup, 0);
248  entryKey.c_key = pKey;
249  entryKey.bDefault = readDefaults();
250  entryKey.bLocal = true;
251  aEntryData = lookupData(entryKey);
252  if (!aEntryData.mValue.isNull()) {
253  // for GNOME .desktop
254  aValue = KStringHandler::from8Bit( aEntryData.mValue.data() );
255  expand = aEntryData.bExpand;
256  } else {
257  entryKey.bLocal = false;
258  aEntryData = lookupData(entryKey);
259  if (!aEntryData.mValue.isNull()) {
260  aValue = TQString::fromUtf8(aEntryData.mValue.data());
261  if (aValue.isNull())
262  {
263  static const TQString &emptyString = KGlobal::staticQString("");
264  aValue = emptyString;
265  }
266  expand = aEntryData.bExpand;
267  } else {
268  aValue = aDefault;
269  }
270  }
271 
272  // only do dollar expansion if so desired
273  if( expand || bExpand )
274  {
275  // check for environment variables and make necessary translations
276  int nDollarPos = aValue.find( '$' );
277 
278  while( nDollarPos != -1 && (nDollarPos + 1) < static_cast<int>(aValue.length())) {
279  // there is at least one $
280  if( aValue[nDollarPos+1] != '$' ) {
281  uint nEndPos = nDollarPos+1;
282  // the next character is no $
283  TQString aVarName;
284  if (aValue[nEndPos]=='{')
285  {
286  while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!='}') )
287  nEndPos++;
288  nEndPos++;
289  aVarName = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 );
290  }
291  else
292  {
293  while ( nEndPos <= aValue.length() && (aValue[nEndPos].isNumber()
294  || aValue[nEndPos].isLetter() || aValue[nEndPos]=='_' ) )
295  nEndPos++;
296  aVarName = aValue.mid( nDollarPos+1, nEndPos-nDollarPos-1 );
297  }
298  const char *pEnv = 0;
299  if (!aVarName.isEmpty())
300  pEnv = getenv( aVarName.ascii() );
301  if (pEnv) {
302  // !!! Sergey A. Sukiyazov <corwin@micom.don.ru> !!!
303  // A environment variables may contain values in 8bit
304  // locale cpecified encoding or in UTF8 encoding.
305  aValue.replace( nDollarPos, nEndPos-nDollarPos, KStringHandler::from8Bit( pEnv ) );
306  }
307  else if (aVarName.length() > 8 && aVarName.startsWith("XDG_") && aVarName.endsWith("_DIR")) {
308  TQString result;
309  if (aVarName == "XDG_DESKTOP_DIR") {
310  result = KGlobalSettings::desktopPath();
311  }
312  else if (aVarName == "XDG_DOCUMENTS_DIR") {
313  result = KGlobalSettings::documentPath();
314  }
315  else if (aVarName == "XDG_DOWNLOAD_DIR") {
316  result = KGlobalSettings::downloadPath();
317  }
318  else if (aVarName == "XDG_MUSIC_DIR") {
319  result = KGlobalSettings::musicPath();
320  }
321  else if (aVarName == "XDG_PICTURES_DIR") {
322  result = KGlobalSettings::picturesPath();
323  }
324  else if (aVarName == "XDG_PUBLICSHARE_DIR") {
325  result = KGlobalSettings::publicSharePath();
326  }
327  else if (aVarName == "XDG_TEMPLATES_DIR") {
328  result = KGlobalSettings::templatesPath();
329  }
330  else if (aVarName == "XDG_VIDEOS_DIR") {
331  result = KGlobalSettings::videosPath();
332  }
333  aValue.replace( nDollarPos, nEndPos-nDollarPos, result );
334  }
335  else {
336  aValue.remove( nDollarPos, nEndPos-nDollarPos );
337  }
338  }
339  else {
340  // remove one of the dollar signs
341  aValue.remove( nDollarPos, 1 );
342  nDollarPos++;
343  }
344  nDollarPos = aValue.find( '$', nDollarPos );
345  }
346  }
347 
348  return aValue;
349 }
350 
351 TQCString KConfigBase::readEntryUtf8( const char *pKey) const
352 {
353  // We don't try the localized key
354  KEntryKey entryKey(mGroup, 0);
355  entryKey.bDefault = readDefaults();
356  entryKey.c_key = pKey;
357  KEntry aEntryData = lookupData(entryKey);
358  if (aEntryData.bExpand)
359  {
360  // We need to do fancy, take the slow route.
361  return readEntry(pKey, TQString::null).utf8();
362  }
363  return aEntryData.mValue;
364 }
365 
366 TQVariant KConfigBase::readPropertyEntry( const TQString& pKey,
367  TQVariant::Type type ) const
368 {
369  return readPropertyEntry(pKey.utf8().data(), type);
370 }
371 
372 TQVariant KConfigBase::readPropertyEntry( const char *pKey,
373  TQVariant::Type type ) const
374 {
375  TQVariant va;
376  if ( !hasKey( pKey ) ) return va;
377  (void)va.cast(type);
378  return readPropertyEntry(pKey, va);
379 }
380 
381 TQVariant KConfigBase::readPropertyEntry( const TQString& pKey,
382  const TQVariant &aDefault ) const
383 {
384  return readPropertyEntry(pKey.utf8().data(), aDefault);
385 }
386 
387 TQVariant KConfigBase::readPropertyEntry( const char *pKey,
388  const TQVariant &aDefault ) const
389 {
390  if ( !hasKey( pKey ) ) return aDefault;
391 
392  TQVariant tmp = aDefault;
393 
394  switch( aDefault.type() )
395  {
396  case TQVariant::Invalid:
397  return TQVariant();
398  case TQVariant::String:
399  return TQVariant( readEntry( pKey, aDefault.toString() ) );
400  case TQVariant::StringList:
401  return TQVariant( readListEntry( pKey ) );
402  case TQVariant::List: {
403  TQStringList strList = readListEntry( pKey );
404  TQStringList::ConstIterator it = strList.begin();
405  TQStringList::ConstIterator end = strList.end();
406  TQValueList<TQVariant> list;
407 
408  for (; it != end; ++it ) {
409  tmp = *it;
410  list.append( tmp );
411  }
412  return TQVariant( list );
413  }
414  case TQVariant::Font:
415  return TQVariant( readFontEntry( pKey, &tmp.asFont() ) );
416  case TQVariant::Point:
417  return TQVariant( readPointEntry( pKey, &tmp.asPoint() ) );
418  case TQVariant::Rect:
419  return TQVariant( readRectEntry( pKey, &tmp.asRect() ) );
420  case TQVariant::Size:
421  return TQVariant( readSizeEntry( pKey, &tmp.asSize() ) );
422  case TQVariant::Color:
423  return TQVariant( readColorEntry( pKey, &tmp.asColor() ) );
424  case TQVariant::Int:
425  return TQVariant( readNumEntry( pKey, aDefault.toInt() ) );
426  case TQVariant::UInt:
427  return TQVariant( readUnsignedNumEntry( pKey, aDefault.toUInt() ) );
428  case TQVariant::LongLong:
429  return TQVariant( readNum64Entry( pKey, aDefault.toLongLong() ) );
430  case TQVariant::ULongLong:
431  return TQVariant( readUnsignedNum64Entry( pKey, aDefault.toULongLong() ) );
432  case TQVariant::Bool:
433  return TQVariant( readBoolEntry( pKey, aDefault.toBool() ), 0 );
434  case TQVariant::Double:
435  return TQVariant( readDoubleNumEntry( pKey, aDefault.toDouble() ) );
436  case TQVariant::DateTime:
437  return TQVariant( readDateTimeEntry( pKey, &tmp.asDateTime() ) );
438  case TQVariant::Date:
439  return TQVariant(TQT_TQDATE_OBJECT(readDateTimeEntry( pKey, &tmp.asDateTime() ).date()));
440 
441  case TQVariant::Pixmap:
442  case TQVariant::Image:
443  case TQVariant::Brush:
444  case TQVariant::Palette:
445  case TQVariant::ColorGroup:
446  case TQVariant::Map:
447  case TQVariant::IconSet:
448  case TQVariant::CString:
449  case TQVariant::PointArray:
450  case TQVariant::Region:
451  case TQVariant::Bitmap:
452  case TQVariant::Cursor:
453  case TQVariant::SizePolicy:
454  case TQVariant::Time:
455 #ifdef USE_QT3
456  case TQVariant::ByteArray:
457 #endif // USE_QT3
458  case TQVariant::BitArray:
459  case TQVariant::KeySequence:
460  case TQVariant::Pen:
461 #ifdef USE_QT4
462  case TQVariant::Char:
463  case TQVariant::Url:
464  case TQVariant::Locale:
465  case TQVariant::RectF:
466  case TQVariant::SizeF:
467  case TQVariant::Line:
468  case TQVariant::LineF:
469  case TQVariant::PointF:
470  case TQVariant::RegExp:
471  case TQVariant::Hash:
472  case TQVariant::TextLength:
473  case QVariant::TextFormat:
474  case TQVariant::Matrix:
475  case TQVariant::Transform:
476  case TQVariant::Matrix4x4:
477  case TQVariant::Vector2D:
478  case TQVariant::Vector3D:
479  case TQVariant::Vector4D:
480  case TQVariant::Quaternion:
481  case TQVariant::UserType:
482 #endif // USE_QT4
483  break;
484  }
485 
486  Q_ASSERT( 0 );
487  return TQVariant();
488 }
489 
490 int KConfigBase::readListEntry( const TQString& pKey,
491  TQStrList &list, char sep ) const
492 {
493  return readListEntry(pKey.utf8().data(), list, sep);
494 }
495 
496 int KConfigBase::readListEntry( const char *pKey,
497  TQStrList &list, char sep ) const
498 {
499  if( !hasKey( pKey ) )
500  return 0;
501 
502  TQCString str_list = readEntryUtf8( pKey );
503  if (str_list.isEmpty())
504  return 0;
505 
506  list.clear();
507  TQCString value = "";
508  int len = str_list.length();
509 
510  for (int i = 0; i < len; i++) {
511  if (str_list[i] != sep && str_list[i] != '\\') {
512  value += str_list[i];
513  continue;
514  }
515  if (str_list[i] == '\\') {
516  i++;
517  if ( i < len )
518  value += str_list[i];
519  continue;
520  }
521  // if we fell through to here, we are at a separator. Append
522  // contents of value to the list
523  // !!! Sergey A. Sukiyazov <corwin@micom.don.ru> !!!
524  // A TQStrList may contain values in 8bit locale cpecified
525  // encoding
526  list.append( value );
527  value.truncate(0);
528  }
529 
530  if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] == '\\' ) )
531  list.append( value );
532  return list.count();
533 }
534 
535 TQStringList KConfigBase::readListEntry( const TQString& pKey, char sep ) const
536 {
537  return readListEntry(pKey.utf8().data(), sep);
538 }
539 
540 TQStringList KConfigBase::readListEntry( const char *pKey, char sep ) const
541 {
542  static const TQString& emptyString = KGlobal::staticQString("");
543 
544  TQStringList list;
545  if( !hasKey( pKey ) )
546  return list;
547  TQString str_list = readEntry( pKey );
548  if( str_list.isEmpty() )
549  return list;
550  TQString value(emptyString);
551  int len = str_list.length();
552  // obviously too big, but faster than letting each += resize the string.
553  value.reserve( len );
554  for( int i = 0; i < len; i++ )
555  {
556  if( str_list[i] != sep && str_list[i] != '\\' )
557  {
558  value += str_list[i];
559  continue;
560  }
561  if( str_list[i] == '\\' )
562  {
563  i++;
564  if ( i < len )
565  value += str_list[i];
566  continue;
567  }
568  TQString finalvalue( value );
569  finalvalue.squeeze();
570  list.append( finalvalue );
571  value.truncate( 0 );
572  }
573  if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] == '\\' ) )
574  {
575  value.squeeze();
576  list.append( value );
577  }
578  return list;
579 }
580 
581 TQStringList KConfigBase::readListEntry( const char* pKey, const TQStringList& aDefault,
582  char sep ) const
583 {
584  if ( !hasKey( pKey ) )
585  return aDefault;
586  else
587  return readListEntry( pKey, sep );
588 }
589 
590 TQValueList<int> KConfigBase::readIntListEntry( const TQString& pKey ) const
591 {
592  return readIntListEntry(pKey.utf8().data());
593 }
594 
595 TQValueList<int> KConfigBase::readIntListEntry( const char *pKey ) const
596 {
597  TQStringList strlist = readListEntry(pKey);
598  TQValueList<int> list;
599  TQStringList::ConstIterator end(strlist.end());
600  for (TQStringList::ConstIterator it = strlist.begin(); it != end; ++it)
601  // I do not check if the toInt failed because I consider the number of items
602  // more important than their value
603  list << (*it).toInt();
604 
605  return list;
606 }
607 
608 TQString KConfigBase::readPathEntry( const TQString& pKey, const TQString& pDefault ) const
609 {
610  return readPathEntry(pKey.utf8().data(), pDefault);
611 }
612 
613 TQString KConfigBase::readPathEntry( const char *pKey, const TQString& pDefault ) const
614 {
615  const bool bExpandSave = bExpand;
616  bExpand = true;
617  TQString aValue = readEntry( pKey, pDefault );
618  bExpand = bExpandSave;
619  return aValue;
620 }
621 
622 TQStringList KConfigBase::readPathListEntry( const TQString& pKey, char sep ) const
623 {
624  return readPathListEntry(pKey.utf8().data(), sep);
625 }
626 
627 TQStringList KConfigBase::readPathListEntry( const char *pKey, char sep ) const
628 {
629  const bool bExpandSave = bExpand;
630  bExpand = true;
631  TQStringList aValue = readListEntry( pKey, sep );
632  bExpand = bExpandSave;
633  return aValue;
634 }
635 
636 int KConfigBase::readNumEntry( const TQString& pKey, int nDefault) const
637 {
638  return readNumEntry(pKey.utf8().data(), nDefault);
639 }
640 
641 int KConfigBase::readNumEntry( const char *pKey, int nDefault) const
642 {
643  TQCString aValue = readEntryUtf8( pKey );
644  if( aValue.isNull() )
645  return nDefault;
646  else if( aValue == "true" || aValue == "on" || aValue == "yes" )
647  return 1;
648  else
649  {
650  bool ok;
651  int rc = aValue.toInt( &ok );
652  return( ok ? rc : nDefault );
653  }
654 }
655 
656 
657 unsigned int KConfigBase::readUnsignedNumEntry( const TQString& pKey, unsigned int nDefault) const
658 {
659  return readUnsignedNumEntry(pKey.utf8().data(), nDefault);
660 }
661 
662 unsigned int KConfigBase::readUnsignedNumEntry( const char *pKey, unsigned int nDefault) const
663 {
664  TQCString aValue = readEntryUtf8( pKey );
665  if( aValue.isNull() )
666  return nDefault;
667  else
668  {
669  bool ok;
670  unsigned int rc = aValue.toUInt( &ok );
671  return( ok ? rc : nDefault );
672  }
673 }
674 
675 
676 long KConfigBase::readLongNumEntry( const TQString& pKey, long nDefault) const
677 {
678  return readLongNumEntry(pKey.utf8().data(), nDefault);
679 }
680 
681 long KConfigBase::readLongNumEntry( const char *pKey, long nDefault) const
682 {
683  TQCString aValue = readEntryUtf8( pKey );
684  if( aValue.isNull() )
685  return nDefault;
686  else
687  {
688  bool ok;
689  long rc = aValue.toLong( &ok );
690  return( ok ? rc : nDefault );
691  }
692 }
693 
694 
695 unsigned long KConfigBase::readUnsignedLongNumEntry( const TQString& pKey, unsigned long nDefault) const
696 {
697  return readUnsignedLongNumEntry(pKey.utf8().data(), nDefault);
698 }
699 
700 unsigned long KConfigBase::readUnsignedLongNumEntry( const char *pKey, unsigned long nDefault) const
701 {
702  TQCString aValue = readEntryUtf8( pKey );
703  if( aValue.isNull() )
704  return nDefault;
705  else
706  {
707  bool ok;
708  unsigned long rc = aValue.toULong( &ok );
709  return( ok ? rc : nDefault );
710  }
711 }
712 
713 TQ_INT64 KConfigBase::readNum64Entry( const TQString& pKey, TQ_INT64 nDefault) const
714 {
715  return readNum64Entry(pKey.utf8().data(), nDefault);
716 }
717 
718 TQ_INT64 KConfigBase::readNum64Entry( const char *pKey, TQ_INT64 nDefault) const
719 {
720  // Note that TQCString::toLongLong() is missing, we muse use a TQString instead.
721  TQString aValue = readEntry( pKey );
722  if( aValue.isNull() )
723  return nDefault;
724  else
725  {
726  bool ok;
727  TQ_INT64 rc = aValue.toLongLong( &ok );
728  return( ok ? rc : nDefault );
729  }
730 }
731 
732 
733 TQ_UINT64 KConfigBase::readUnsignedNum64Entry( const TQString& pKey, TQ_UINT64 nDefault) const
734 {
735  return readUnsignedNum64Entry(pKey.utf8().data(), nDefault);
736 }
737 
738 TQ_UINT64 KConfigBase::readUnsignedNum64Entry( const char *pKey, TQ_UINT64 nDefault) const
739 {
740  // Note that TQCString::toULongLong() is missing, we muse use a TQString instead.
741  TQString aValue = readEntry( pKey );
742  if( aValue.isNull() )
743  return nDefault;
744  else
745  {
746  bool ok;
747  TQ_UINT64 rc = aValue.toULongLong( &ok );
748  return( ok ? rc : nDefault );
749  }
750 }
751 
752 double KConfigBase::readDoubleNumEntry( const TQString& pKey, double nDefault) const
753 {
754  return readDoubleNumEntry(pKey.utf8().data(), nDefault);
755 }
756 
757 double KConfigBase::readDoubleNumEntry( const char *pKey, double nDefault) const
758 {
759  TQCString aValue = readEntryUtf8( pKey );
760  if( aValue.isNull() )
761  return nDefault;
762  else
763  {
764  bool ok;
765  double rc = aValue.toDouble( &ok );
766  return( ok ? rc : nDefault );
767  }
768 }
769 
770 
771 bool KConfigBase::readBoolEntry( const TQString& pKey, bool bDefault ) const
772 {
773  return readBoolEntry(pKey.utf8().data(), bDefault);
774 }
775 
776 bool KConfigBase::readBoolEntry( const char *pKey, bool bDefault ) const
777 {
778  TQCString aValue = readEntryUtf8( pKey );
779 
780  if( aValue.isNull() )
781  return bDefault;
782  else
783  {
784  if( aValue == "true" || aValue == "on" || aValue == "yes" || aValue == "1" )
785  return true;
786  else
787  {
788  bool bOK;
789  int val = aValue.toInt( &bOK );
790  if( bOK && val != 0 )
791  return true;
792  else
793  return false;
794  }
795  }
796 }
797 
798 TQFont KConfigBase::readFontEntry( const TQString& pKey, const TQFont* pDefault ) const
799 {
800  return readFontEntry(pKey.utf8().data(), pDefault);
801 }
802 
803 TQFont KConfigBase::readFontEntry( const char *pKey, const TQFont* pDefault ) const
804 {
805  TQFont aRetFont;
806 
807  TQString aValue = readEntry( pKey );
808  if( !aValue.isNull() ) {
809  if ( aValue.contains( ',' ) > 5 ) {
810  // KDE3 and upwards entry
811  if ( !aRetFont.fromString( aValue ) && pDefault )
812  aRetFont = *pDefault;
813  }
814  else {
815  // backward compatibility with older font formats
816  // ### remove KDE 3.1 ?
817  // find first part (font family)
818  int nIndex = aValue.find( ',' );
819  if( nIndex == -1 ){
820  if( pDefault )
821  aRetFont = *pDefault;
822  return aRetFont;
823  }
824  aRetFont.setFamily( aValue.left( nIndex ) );
825 
826  // find second part (point size)
827  int nOldIndex = nIndex;
828  nIndex = aValue.find( ',', nOldIndex+1 );
829  if( nIndex == -1 ){
830  if( pDefault )
831  aRetFont = *pDefault;
832  return aRetFont;
833  }
834 
835  aRetFont.setPointSize( aValue.mid( nOldIndex+1,
836  nIndex-nOldIndex-1 ).toInt() );
837 
838  // find third part (style hint)
839  nOldIndex = nIndex;
840  nIndex = aValue.find( ',', nOldIndex+1 );
841 
842  if( nIndex == -1 ){
843  if( pDefault )
844  aRetFont = *pDefault;
845  return aRetFont;
846  }
847 
848  aRetFont.setStyleHint( (TQFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() );
849 
850  // find fourth part (char set)
851  nOldIndex = nIndex;
852  nIndex = aValue.find( ',', nOldIndex+1 );
853 
854  if( nIndex == -1 ){
855  if( pDefault )
856  aRetFont = *pDefault;
857  return aRetFont;
858  }
859 
860  TQString chStr=aValue.mid( nOldIndex+1,
861  nIndex-nOldIndex-1 );
862  // find fifth part (weight)
863  nOldIndex = nIndex;
864  nIndex = aValue.find( ',', nOldIndex+1 );
865 
866  if( nIndex == -1 ){
867  if( pDefault )
868  aRetFont = *pDefault;
869  return aRetFont;
870  }
871 
872  aRetFont.setWeight( aValue.mid( nOldIndex+1,
873  nIndex-nOldIndex-1 ).toUInt() );
874 
875  // find sixth part (font bits)
876  uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt();
877 
878  aRetFont.setItalic( nFontBits & 0x01 );
879  aRetFont.setUnderline( nFontBits & 0x02 );
880  aRetFont.setStrikeOut( nFontBits & 0x04 );
881  aRetFont.setFixedPitch( nFontBits & 0x08 );
882  aRetFont.setRawMode( nFontBits & 0x20 );
883  }
884  }
885  else
886  {
887  if( pDefault )
888  aRetFont = *pDefault;
889  }
890 
891  return aRetFont;
892 }
893 
894 
895 TQRect KConfigBase::readRectEntry( const TQString& pKey, const TQRect* pDefault ) const
896 {
897  return readRectEntry(pKey.utf8().data(), pDefault);
898 }
899 
900 TQRect KConfigBase::readRectEntry( const char *pKey, const TQRect* pDefault ) const
901 {
902  TQCString aValue = readEntryUtf8(pKey);
903 
904  if (!aValue.isEmpty())
905  {
906  int left, top, width, height;
907 
908  if (sscanf(aValue.data(), "%d,%d,%d,%d", &left, &top, &width, &height) == 4)
909  {
910  return TQRect(left, top, width, height);
911  }
912  }
913  if (pDefault)
914  return *pDefault;
915  return TQRect();
916 }
917 
918 
919 TQPoint KConfigBase::readPointEntry( const TQString& pKey,
920  const TQPoint* pDefault ) const
921 {
922  return readPointEntry(pKey.utf8().data(), pDefault);
923 }
924 
925 TQPoint KConfigBase::readPointEntry( const char *pKey,
926  const TQPoint* pDefault ) const
927 {
928  TQCString aValue = readEntryUtf8(pKey);
929 
930  if (!aValue.isEmpty())
931  {
932  int x,y;
933 
934  if (sscanf(aValue.data(), "%d,%d", &x, &y) == 2)
935  {
936  return TQPoint(x,y);
937  }
938  }
939  if (pDefault)
940  return *pDefault;
941  return TQPoint();
942 }
943 
944 TQSize KConfigBase::readSizeEntry( const TQString& pKey,
945  const TQSize* pDefault ) const
946 {
947  return readSizeEntry(pKey.utf8().data(), pDefault);
948 }
949 
950 TQSize KConfigBase::readSizeEntry( const char *pKey,
951  const TQSize* pDefault ) const
952 {
953  TQCString aValue = readEntryUtf8(pKey);
954 
955  if (!aValue.isEmpty())
956  {
957  int width,height;
958 
959  if (sscanf(aValue.data(), "%d,%d", &width, &height) == 2)
960  {
961  return TQSize(width, height);
962  }
963  }
964  if (pDefault)
965  return *pDefault;
966  return TQSize();
967 }
968 
969 
970 TQColor KConfigBase::readColorEntry( const TQString& pKey,
971  const TQColor* pDefault ) const
972 {
973  return readColorEntry(pKey.utf8().data(), pDefault);
974 }
975 
976 TQColor KConfigBase::readColorEntry( const char *pKey,
977  const TQColor* pDefault ) const
978 {
979  TQColor aRetColor;
980  int nRed = 0, nGreen = 0, nBlue = 0;
981 
982  TQString aValue = readEntry( pKey );
983  if( !aValue.isEmpty() )
984  {
985  if ( aValue.at(0) == (QChar)'#' )
986  {
987  aRetColor.setNamedColor(aValue);
988  }
989  else
990  {
991 
992  bool bOK;
993 
994  // find first part (red)
995  int nIndex = aValue.find( ',' );
996 
997  if( nIndex == -1 ){
998  // return a sensible default -- Bernd
999  if( pDefault )
1000  aRetColor = *pDefault;
1001  return aRetColor;
1002  }
1003 
1004  nRed = aValue.left( nIndex ).toInt( &bOK );
1005 
1006  // find second part (green)
1007  int nOldIndex = nIndex;
1008  nIndex = aValue.find( ',', nOldIndex+1 );
1009 
1010  if( nIndex == -1 ){
1011  // return a sensible default -- Bernd
1012  if( pDefault )
1013  aRetColor = *pDefault;
1014  return aRetColor;
1015  }
1016  nGreen = aValue.mid( nOldIndex+1,
1017  nIndex-nOldIndex-1 ).toInt( &bOK );
1018 
1019  // find third part (blue)
1020  nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK );
1021 
1022  aRetColor.setRgb( nRed, nGreen, nBlue );
1023  }
1024  }
1025  else {
1026 
1027  if( pDefault )
1028  aRetColor = *pDefault;
1029  }
1030 
1031  return aRetColor;
1032 }
1033 
1034 
1035 TQDateTime KConfigBase::readDateTimeEntry( const TQString& pKey,
1036  const TQDateTime* pDefault ) const
1037 {
1038  return readDateTimeEntry(pKey.utf8().data(), pDefault);
1039 }
1040 
1041 // ### currentDateTime() as fallback ? (Harri)
1042 TQDateTime KConfigBase::readDateTimeEntry( const char *pKey,
1043  const TQDateTime* pDefault ) const
1044 {
1045  if( !hasKey( pKey ) )
1046  {
1047  if( pDefault )
1048  return *pDefault;
1049  else
1050  return TQDateTime::currentDateTime();
1051  }
1052 
1053  TQStrList list;
1054  int count = readListEntry( pKey, list, ',' );
1055  if( count == 6 ) {
1056  TQDate date( atoi( list.at( 0 ) ), atoi( list.at( 1 ) ),
1057  atoi( list.at( 2 ) ) );
1058  TQTime time( atoi( list.at( 3 ) ), atoi( list.at( 4 ) ),
1059  atoi( list.at( 5 ) ) );
1060 
1061  return TQDateTime( date, time );
1062  }
1063 
1064  return TQDateTime::currentDateTime();
1065 }
1066 
1067 void KConfigBase::writeEntry( const TQString& pKey, const TQString& value,
1068  bool bPersistent,
1069  bool bGlobal,
1070  bool bNLS )
1071 {
1072  writeEntry(pKey.utf8().data(), value, bPersistent, bGlobal, bNLS);
1073 }
1074 
1075 void KConfigBase::writeEntry( const char *pKey, const TQString& value,
1076  bool bPersistent,
1077  bool bGlobal,
1078  bool bNLS )
1079 {
1080  writeEntry(pKey, value, bPersistent, bGlobal, bNLS, false);
1081 }
1082 
1083 void KConfigBase::writeEntry( const char *pKey, const TQString& value,
1084  bool bPersistent,
1085  bool bGlobal,
1086  bool bNLS,
1087  bool bExpand )
1088 {
1089  // the KConfig object is dirty now
1090  // set this before any IO takes place so that if any derivative
1091  // classes do caching, they won't try and flush the cache out
1092  // from under us before we read. A race condition is still
1093  // possible but minimized.
1094  if( bPersistent )
1095  setDirty(true);
1096 
1097  if (!bLocaleInitialized && KGlobal::locale())
1098  setLocale();
1099 
1100  KEntryKey entryKey(mGroup, pKey);
1101  entryKey.bLocal = bNLS;
1102 
1103  KEntry aEntryData;
1104  aEntryData.mValue = value.utf8(); // set new value
1105  aEntryData.bGlobal = bGlobal;
1106  aEntryData.bNLS = bNLS;
1107  aEntryData.bExpand = bExpand;
1108 
1109  if (bPersistent)
1110  aEntryData.bDirty = true;
1111 
1112  // rewrite the new value
1113  putData(entryKey, aEntryData, true);
1114 }
1115 
1116 void KConfigBase::writePathEntry( const TQString& pKey, const TQString & path,
1117  bool bPersistent, bool bGlobal,
1118  bool bNLS)
1119 {
1120  writePathEntry(pKey.utf8().data(), path, bPersistent, bGlobal, bNLS);
1121 }
1122 
1123 
1124 static bool cleanHomeDirPath( TQString &path, const TQString &homeDir )
1125 {
1126 #ifdef Q_WS_WIN //safer
1127  if (!TQDir::convertSeparators(path).startsWith(TQDir::convertSeparators(homeDir)))
1128  return false;
1129 #else
1130  if (!path.startsWith(homeDir))
1131  return false;
1132 #endif
1133 
1134  unsigned int len = homeDir.length();
1135  // replace by "$HOME" if possible
1136  if (len && (path.length() == len || path[len] == '/')) {
1137  path.replace(0, len, TQString::fromLatin1("$HOME"));
1138  return true;
1139  } else
1140  return false;
1141 }
1142 
1143 static TQString translatePath( TQString path )
1144 {
1145  if (path.isEmpty())
1146  return path;
1147 
1148  // only "our" $HOME should be interpreted
1149  path.replace('$', "$$");
1150 
1151  bool startsWithFile = path.startsWith("file:", false);
1152 
1153  // return original path, if it refers to another type of URL (e.g. http:/), or
1154  // if the path is already relative to another directory
1155  if (((!startsWithFile) && (path[0] != '/')) || (startsWithFile && (path[5] != '/'))) {
1156  return path;
1157  }
1158 
1159  if (startsWithFile) {
1160  path.remove(0,5); // strip leading "file:/" off the string
1161  }
1162 
1163  // keep only one single '/' at the beginning - needed for cleanHomeDirPath()
1164  while (path[0] == '/' && path[1] == '/') {
1165  path.remove(0,1);
1166  }
1167 
1168  // we can not use KGlobal::dirs()->relativeLocation("home", path) here,
1169  // since it would not recognize paths without a trailing '/'.
1170  // All of the 3 following functions to return the user's home directory
1171  // can return different paths. We have to test all them.
1172  TQString homeDir0 = TQFile::decodeName(getenv("HOME"));
1173  TQString homeDir1 = TQDir::homeDirPath();
1174  TQString homeDir2 = TQDir(homeDir1).canonicalPath();
1175  if (cleanHomeDirPath(path, homeDir0) ||
1176  cleanHomeDirPath(path, homeDir1) ||
1177  cleanHomeDirPath(path, homeDir2) ) {
1178  // kdDebug() << "Path was replaced\n";
1179  }
1180 
1181  if (startsWithFile)
1182  path.prepend( "file://" );
1183 
1184  return path;
1185 }
1186 
1187 void KConfigBase::writePathEntry( const char *pKey, const TQString & path,
1188  bool bPersistent, bool bGlobal,
1189  bool bNLS)
1190 {
1191  writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS, true);
1192 }
1193 
1194 void KConfigBase::writePathEntry ( const TQString& pKey, const TQStringList &list,
1195  char sep , bool bPersistent,
1196  bool bGlobal, bool bNLS )
1197 {
1198  writePathEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1199 }
1200 
1201 void KConfigBase::writePathEntry ( const char *pKey, const TQStringList &list,
1202  char sep , bool bPersistent,
1203  bool bGlobal, bool bNLS )
1204 {
1205  if( list.isEmpty() )
1206  {
1207  writeEntry( pKey, TQString::fromLatin1(""), bPersistent );
1208  return;
1209  }
1210  TQStringList new_list;
1211  TQStringList::ConstIterator it = list.begin();
1212  for( ; it != list.end(); ++it )
1213  {
1214  TQString value = *it;
1215  new_list.append( translatePath(value) );
1216  }
1217  writeEntry( pKey, new_list, sep, bPersistent, bGlobal, bNLS, true );
1218 }
1219 
1220 void KConfigBase::deleteEntry( const TQString& pKey,
1221  bool bNLS,
1222  bool bGlobal)
1223 {
1224  deleteEntry(pKey.utf8().data(), bNLS, bGlobal);
1225 }
1226 
1227 void KConfigBase::deleteEntry( const char *pKey,
1228  bool bNLS,
1229  bool bGlobal)
1230 {
1231  // the KConfig object is dirty now
1232  // set this before any IO takes place so that if any derivative
1233  // classes do caching, they won't try and flush the cache out
1234  // from under us before we read. A race condition is still
1235  // possible but minimized.
1236  setDirty(true);
1237 
1238  if (!bLocaleInitialized && KGlobal::locale())
1239  setLocale();
1240 
1241  KEntryKey entryKey(mGroup, pKey);
1242  KEntry aEntryData;
1243 
1244  aEntryData.bGlobal = bGlobal;
1245  aEntryData.bNLS = bNLS;
1246  aEntryData.bDirty = true;
1247  aEntryData.bDeleted = true;
1248 
1249  // rewrite the new value
1250  putData(entryKey, aEntryData, true);
1251 }
1252 
1253 bool KConfigBase::deleteGroup( const TQString& group, bool bDeep, bool bGlobal )
1254 {
1255  KEntryMap aEntryMap = internalEntryMap(group);
1256 
1257  if (!bDeep) {
1258  // Check if it empty
1259  return aEntryMap.isEmpty();
1260  }
1261 
1262  bool dirty = false;
1263  bool checkGroup = true;
1264  // we want to remove all entries in the group
1265  KEntryMapIterator aIt;
1266  for (aIt = aEntryMap.begin(); aIt != aEntryMap.end(); ++aIt)
1267  {
1268  if (!aIt.key().mKey.isEmpty() && !aIt.key().bDefault && !(*aIt).bDeleted)
1269  {
1270  (*aIt).bDeleted = true;
1271  (*aIt).bDirty = true;
1272  (*aIt).bGlobal = bGlobal;
1273  (*aIt).mValue = 0;
1274  putData(aIt.key(), *aIt, checkGroup);
1275  checkGroup = false;
1276  dirty = true;
1277  }
1278  }
1279  if (dirty)
1280  setDirty(true);
1281  return true;
1282 }
1283 
1284 void KConfigBase::writeEntry ( const TQString& pKey, const TQVariant &prop,
1285  bool bPersistent,
1286  bool bGlobal, bool bNLS )
1287 {
1288  writeEntry(pKey.utf8().data(), prop, bPersistent, bGlobal, bNLS);
1289 }
1290 
1291 void KConfigBase::writeEntry ( const char *pKey, const TQVariant &prop,
1292  bool bPersistent,
1293  bool bGlobal, bool bNLS )
1294 {
1295  switch( prop.type() )
1296  {
1297  case TQVariant::Invalid:
1298  writeEntry( pKey, "", bPersistent, bGlobal, bNLS );
1299  return;
1300  case TQVariant::String:
1301  writeEntry( pKey, prop.toString(), bPersistent, bGlobal, bNLS );
1302  return;
1303  case TQVariant::StringList:
1304  writeEntry( pKey, prop.toStringList(), ',', bPersistent, bGlobal, bNLS );
1305  return;
1306  case TQVariant::List: {
1307  TQValueList<TQVariant> list = prop.toList();
1308  TQValueList<TQVariant>::ConstIterator it = list.begin();
1309  TQValueList<TQVariant>::ConstIterator end = list.end();
1310  TQStringList strList;
1311 
1312  for (; it != end; ++it )
1313  strList.append( (*it).toString() );
1314 
1315  writeEntry( pKey, strList, ',', bPersistent, bGlobal, bNLS );
1316 
1317  return;
1318  }
1319  case TQVariant::Font:
1320  writeEntry( pKey, prop.toFont(), bPersistent, bGlobal, bNLS );
1321  return;
1322  case TQVariant::Point:
1323  writeEntry( pKey, prop.toPoint(), bPersistent, bGlobal, bNLS );
1324  return;
1325  case TQVariant::Rect:
1326  writeEntry( pKey, prop.toRect(), bPersistent, bGlobal, bNLS );
1327  return;
1328  case TQVariant::Size:
1329  writeEntry( pKey, prop.toSize(), bPersistent, bGlobal, bNLS );
1330  return;
1331  case TQVariant::Color:
1332  writeEntry( pKey, prop.toColor(), bPersistent, bGlobal, bNLS );
1333  return;
1334  case TQVariant::Int:
1335  writeEntry( pKey, prop.toInt(), bPersistent, bGlobal, bNLS );
1336  return;
1337  case TQVariant::UInt:
1338  writeEntry( pKey, prop.toUInt(), bPersistent, bGlobal, bNLS );
1339  return;
1340  case TQVariant::LongLong:
1341  writeEntry( pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS );
1342  return;
1343  case TQVariant::ULongLong:
1344  writeEntry( pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS );
1345  return;
1346  case TQVariant::Bool:
1347  writeEntry( pKey, prop.toBool(), bPersistent, bGlobal, bNLS );
1348  return;
1349  case TQVariant::Double:
1350  writeEntry( pKey, prop.toDouble(), bPersistent, bGlobal, 'g', 6, bNLS );
1351  return;
1352  case TQVariant::DateTime:
1353  writeEntry( pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS);
1354  return;
1355  case TQVariant::Date:
1356  writeEntry( pKey, TQDateTime(prop.toDate()), bPersistent, bGlobal, bNLS);
1357  return;
1358 
1359  case TQVariant::Pixmap:
1360  case TQVariant::Image:
1361  case TQVariant::Brush:
1362  case TQVariant::Palette:
1363  case TQVariant::ColorGroup:
1364  case TQVariant::Map:
1365  case TQVariant::IconSet:
1366  case TQVariant::CString:
1367  case TQVariant::PointArray:
1368  case TQVariant::Region:
1369  case TQVariant::Bitmap:
1370  case TQVariant::Cursor:
1371  case TQVariant::SizePolicy:
1372  case TQVariant::Time:
1373 #ifdef USE_QT3
1374  case TQVariant::ByteArray:
1375 #endif // USE_QT3
1376  case TQVariant::BitArray:
1377  case TQVariant::KeySequence:
1378  case TQVariant::Pen:
1379 #ifdef USE_QT4
1380  case TQVariant::Char:
1381  case TQVariant::Url:
1382  case TQVariant::Locale:
1383  case TQVariant::RectF:
1384  case TQVariant::SizeF:
1385  case TQVariant::Line:
1386  case TQVariant::LineF:
1387  case TQVariant::PointF:
1388  case TQVariant::RegExp:
1389  case TQVariant::Hash:
1390  case TQVariant::TextLength:
1391  case QVariant::TextFormat:
1392  case TQVariant::Matrix:
1393  case TQVariant::Transform:
1394  case TQVariant::Matrix4x4:
1395  case TQVariant::Vector2D:
1396  case TQVariant::Vector3D:
1397  case TQVariant::Vector4D:
1398  case TQVariant::Quaternion:
1399  case TQVariant::UserType:
1400 #endif // USE_QT4
1401  break;
1402  }
1403 
1404  Q_ASSERT( 0 );
1405 }
1406 
1407 void KConfigBase::writeEntry ( const TQString& pKey, const TQStrList &list,
1408  char sep , bool bPersistent,
1409  bool bGlobal, bool bNLS )
1410 {
1411  writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1412 }
1413 
1414 void KConfigBase::writeEntry ( const char *pKey, const TQStrList &list,
1415  char sep , bool bPersistent,
1416  bool bGlobal, bool bNLS )
1417 {
1418  if( list.isEmpty() )
1419  {
1420  writeEntry( pKey, TQString::fromLatin1(""), bPersistent );
1421  return;
1422  }
1423  TQString str_list;
1424  TQStrListIterator it( list );
1425  for( ; it.current(); ++it )
1426  {
1427  uint i;
1428  TQString value;
1429  // !!! Sergey A. Sukiyazov <corwin@micom.don.ru> !!!
1430  // A TQStrList may contain values in 8bit locale cpecified
1431  // encoding or in UTF8 encoding.
1432  value = KStringHandler::from8Bit(it.current());
1433  uint strLengh(value.length());
1434  for( i = 0; i < strLengh; i++ )
1435  {
1436  if( value[i] == sep || value[i] == '\\' )
1437  str_list += '\\';
1438  str_list += value[i];
1439  }
1440  str_list += sep;
1441  }
1442  if( str_list.at(str_list.length() - 1) == (QChar)sep )
1443  str_list.truncate( str_list.length() -1 );
1444  writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS );
1445 }
1446 
1447 void KConfigBase::writeEntry ( const TQString& pKey, const TQStringList &list,
1448  char sep , bool bPersistent,
1449  bool bGlobal, bool bNLS )
1450 {
1451  writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1452 }
1453 
1454 void KConfigBase::writeEntry ( const char *pKey, const TQStringList &list,
1455  char sep , bool bPersistent,
1456  bool bGlobal, bool bNLS )
1457 {
1458  writeEntry(pKey, list, sep, bPersistent, bGlobal, bNLS, false);
1459 }
1460 
1461 void KConfigBase::writeEntry ( const char *pKey, const TQStringList &list,
1462  char sep, bool bPersistent,
1463  bool bGlobal, bool bNLS, bool bExpand )
1464 {
1465  if( list.isEmpty() )
1466  {
1467  writeEntry( pKey, TQString::fromLatin1(""), bPersistent );
1468  return;
1469  }
1470  TQString str_list;
1471  str_list.reserve( 4096 );
1472  TQStringList::ConstIterator it = list.begin();
1473  for( ; it != list.end(); ++it )
1474  {
1475  TQString value = *it;
1476  uint i;
1477  uint strLength(value.length());
1478  for( i = 0; i < strLength; i++ )
1479  {
1480  if( value[i] == sep || value[i] == '\\' )
1481  str_list += '\\';
1482  str_list += value[i];
1483  }
1484  str_list += sep;
1485  }
1486  if( str_list.at(str_list.length() - 1) == (QChar)sep )
1487  str_list.truncate( str_list.length() -1 );
1488  writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS, bExpand );
1489 }
1490 
1491 void KConfigBase::writeEntry ( const TQString& pKey, const TQValueList<int> &list,
1492  bool bPersistent, bool bGlobal, bool bNLS )
1493 {
1494  writeEntry(pKey.utf8().data(), list, bPersistent, bGlobal, bNLS);
1495 }
1496 
1497 void KConfigBase::writeEntry ( const char *pKey, const TQValueList<int> &list,
1498  bool bPersistent, bool bGlobal, bool bNLS )
1499 {
1500  TQStringList strlist;
1501  TQValueList<int>::ConstIterator end = list.end();
1502  for (TQValueList<int>::ConstIterator it = list.begin(); it != end; it++)
1503  strlist << TQString::number(*it);
1504  writeEntry(pKey, strlist, ',', bPersistent, bGlobal, bNLS );
1505 }
1506 
1507 void KConfigBase::writeEntry( const TQString& pKey, int nValue,
1508  bool bPersistent, bool bGlobal,
1509  bool bNLS )
1510 {
1511  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1512 }
1513 
1514 void KConfigBase::writeEntry( const char *pKey, int nValue,
1515  bool bPersistent, bool bGlobal,
1516  bool bNLS )
1517 {
1518  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1519 }
1520 
1521 
1522 void KConfigBase::writeEntry( const TQString& pKey, unsigned int nValue,
1523  bool bPersistent, bool bGlobal,
1524  bool bNLS )
1525 {
1526  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1527 }
1528 
1529 void KConfigBase::writeEntry( const char *pKey, unsigned int nValue,
1530  bool bPersistent, bool bGlobal,
1531  bool bNLS )
1532 {
1533  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1534 }
1535 
1536 
1537 void KConfigBase::writeEntry( const TQString& pKey, long nValue,
1538  bool bPersistent, bool bGlobal,
1539  bool bNLS )
1540 {
1541  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1542 }
1543 
1544 void KConfigBase::writeEntry( const char *pKey, long nValue,
1545  bool bPersistent, bool bGlobal,
1546  bool bNLS )
1547 {
1548  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1549 }
1550 
1551 
1552 void KConfigBase::writeEntry( const TQString& pKey, unsigned long nValue,
1553  bool bPersistent, bool bGlobal,
1554  bool bNLS )
1555 {
1556  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1557 }
1558 
1559 void KConfigBase::writeEntry( const char *pKey, unsigned long nValue,
1560  bool bPersistent, bool bGlobal,
1561  bool bNLS )
1562 {
1563  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1564 }
1565 
1566 void KConfigBase::writeEntry( const TQString& pKey, TQ_INT64 nValue,
1567  bool bPersistent, bool bGlobal,
1568  bool bNLS )
1569 {
1570  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1571 }
1572 
1573 void KConfigBase::writeEntry( const char *pKey, TQ_INT64 nValue,
1574  bool bPersistent, bool bGlobal,
1575  bool bNLS )
1576 {
1577  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1578 }
1579 
1580 
1581 void KConfigBase::writeEntry( const TQString& pKey, TQ_UINT64 nValue,
1582  bool bPersistent, bool bGlobal,
1583  bool bNLS )
1584 {
1585  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1586 }
1587 
1588 void KConfigBase::writeEntry( const char *pKey, TQ_UINT64 nValue,
1589  bool bPersistent, bool bGlobal,
1590  bool bNLS )
1591 {
1592  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1593 }
1594 
1595 void KConfigBase::writeEntry( const TQString& pKey, double nValue,
1596  bool bPersistent, bool bGlobal,
1597  char format, int precision,
1598  bool bNLS )
1599 {
1600  writeEntry( pKey, TQString::number(nValue, format, precision),
1601  bPersistent, bGlobal, bNLS );
1602 }
1603 
1604 void KConfigBase::writeEntry( const char *pKey, double nValue,
1605  bool bPersistent, bool bGlobal,
1606  char format, int precision,
1607  bool bNLS )
1608 {
1609  writeEntry( pKey, TQString::number(nValue, format, precision),
1610  bPersistent, bGlobal, bNLS );
1611 }
1612 
1613 
1614 void KConfigBase::writeEntry( const TQString& pKey, bool bValue,
1615  bool bPersistent,
1616  bool bGlobal,
1617  bool bNLS )
1618 {
1619  writeEntry(pKey.utf8().data(), bValue, bPersistent, bGlobal, bNLS);
1620 }
1621 
1622 void KConfigBase::writeEntry( const char *pKey, bool bValue,
1623  bool bPersistent,
1624  bool bGlobal,
1625  bool bNLS )
1626 {
1627  TQString aValue;
1628 
1629  if( bValue )
1630  aValue = "true";
1631  else
1632  aValue = "false";
1633 
1634  writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1635 }
1636 
1637 
1638 void KConfigBase::writeEntry( const TQString& pKey, const TQFont& rFont,
1639  bool bPersistent, bool bGlobal,
1640  bool bNLS )
1641 {
1642  writeEntry(pKey.utf8().data(), rFont, bPersistent, bGlobal, bNLS);
1643 }
1644 
1645 void KConfigBase::writeEntry( const char *pKey, const TQFont& rFont,
1646  bool bPersistent, bool bGlobal,
1647  bool bNLS )
1648 {
1649  writeEntry( pKey, TQString(rFont.toString()), bPersistent, bGlobal, bNLS );
1650 }
1651 
1652 
1653 void KConfigBase::writeEntry( const TQString& pKey, const TQRect& rRect,
1654  bool bPersistent, bool bGlobal,
1655  bool bNLS )
1656 {
1657  writeEntry(pKey.utf8().data(), rRect, bPersistent, bGlobal, bNLS);
1658 }
1659 
1660 void KConfigBase::writeEntry( const char *pKey, const TQRect& rRect,
1661  bool bPersistent, bool bGlobal,
1662  bool bNLS )
1663 {
1664  TQStrList list;
1665  TQCString tempstr;
1666  list.insert( 0, tempstr.setNum( rRect.left() ) );
1667  list.insert( 1, tempstr.setNum( rRect.top() ) );
1668  list.insert( 2, tempstr.setNum( rRect.width() ) );
1669  list.insert( 3, tempstr.setNum( rRect.height() ) );
1670 
1671  writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
1672 }
1673 
1674 
1675 void KConfigBase::writeEntry( const TQString& pKey, const TQPoint& rPoint,
1676  bool bPersistent, bool bGlobal,
1677  bool bNLS )
1678 {
1679  writeEntry(pKey.utf8().data(), rPoint, bPersistent, bGlobal, bNLS);
1680 }
1681 
1682 void KConfigBase::writeEntry( const char *pKey, const TQPoint& rPoint,
1683  bool bPersistent, bool bGlobal,
1684  bool bNLS )
1685 {
1686  TQStrList list;
1687  TQCString tempstr;
1688  list.insert( 0, tempstr.setNum( rPoint.x() ) );
1689  list.insert( 1, tempstr.setNum( rPoint.y() ) );
1690 
1691  writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
1692 }
1693 
1694 
1695 void KConfigBase::writeEntry( const TQString& pKey, const TQSize& rSize,
1696  bool bPersistent, bool bGlobal,
1697  bool bNLS )
1698 {
1699  writeEntry(pKey.utf8().data(), rSize, bPersistent, bGlobal, bNLS);
1700 }
1701 
1702 void KConfigBase::writeEntry( const char *pKey, const TQSize& rSize,
1703  bool bPersistent, bool bGlobal,
1704  bool bNLS )
1705 {
1706  TQStrList list;
1707  TQCString tempstr;
1708  list.insert( 0, tempstr.setNum( rSize.width() ) );
1709  list.insert( 1, tempstr.setNum( rSize.height() ) );
1710 
1711  writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
1712 }
1713 
1714 void KConfigBase::writeEntry( const TQString& pKey, const TQColor& rColor,
1715  bool bPersistent,
1716  bool bGlobal,
1717  bool bNLS )
1718 {
1719  writeEntry( pKey.utf8().data(), rColor, bPersistent, bGlobal, bNLS);
1720 }
1721 
1722 void KConfigBase::writeEntry( const char *pKey, const TQColor& rColor,
1723  bool bPersistent,
1724  bool bGlobal,
1725  bool bNLS )
1726 {
1727  TQString aValue;
1728  if (rColor.isValid())
1729  aValue.sprintf( "%d,%d,%d", rColor.red(), rColor.green(), rColor.blue() );
1730  else
1731  aValue = "invalid";
1732 
1733  writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1734 }
1735 
1736 void KConfigBase::writeEntry( const TQString& pKey, const TQDateTime& rDateTime,
1737  bool bPersistent, bool bGlobal,
1738  bool bNLS )
1739 {
1740  writeEntry(pKey.utf8().data(), rDateTime, bPersistent, bGlobal, bNLS);
1741 }
1742 
1743 void KConfigBase::writeEntry( const char *pKey, const TQDateTime& rDateTime,
1744  bool bPersistent, bool bGlobal,
1745  bool bNLS )
1746 {
1747  TQStrList list;
1748  TQCString tempstr;
1749 
1750  TQTime time = TQT_TQTIME_OBJECT(rDateTime.time());
1751  TQDate date = TQT_TQDATE_OBJECT(rDateTime.date());
1752 
1753  list.insert( 0, tempstr.setNum( date.year() ) );
1754  list.insert( 1, tempstr.setNum( date.month() ) );
1755  list.insert( 2, tempstr.setNum( date.day() ) );
1756 
1757  list.insert( 3, tempstr.setNum( time.hour() ) );
1758  list.insert( 4, tempstr.setNum( time.minute() ) );
1759  list.insert( 5, tempstr.setNum( time.second() ) );
1760 
1761  writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
1762 }
1763 
1764 void KConfigBase::parseConfigFiles()
1765 {
1766  if (!bLocaleInitialized && KGlobal::_locale) {
1767  setLocale();
1768  }
1769  if (backEnd)
1770  {
1771  backEnd->parseConfigFiles();
1772  bReadOnly = (backEnd->getConfigState() == ReadOnly);
1773  }
1774 }
1775 
1776 void KConfigBase::sync()
1777 {
1778  if (isReadOnly())
1779  return;
1780 
1781  if (backEnd)
1782  backEnd->sync();
1783  if (bDirty)
1784  rollback();
1785 }
1786 
1787 KConfigBase::ConfigState KConfigBase::getConfigState() const {
1788  if (backEnd)
1789  return backEnd->getConfigState();
1790  return ReadOnly;
1791 }
1792 
1793 void KConfigBase::rollback( bool /*bDeep = true*/ )
1794 {
1795  bDirty = false;
1796 }
1797 
1798 
1799 void KConfigBase::setReadDefaults(bool b)
1800 {
1801  if (!d)
1802  {
1803  if (!b) return;
1804  d = new KConfigBasePrivate();
1805  }
1806 
1807  d->readDefaults = b;
1808 }
1809 
1810 bool KConfigBase::readDefaults() const
1811 {
1812  return (d && d->readDefaults);
1813 }
1814 
1815 void KConfigBase::revertToDefault(const TQString &key)
1816 {
1817  setDirty(true);
1818 
1819  KEntryKey aEntryKey(mGroup, key.utf8());
1820  aEntryKey.bDefault = true;
1821 
1822  if (!locale().isNull()) {
1823  // try the localized key first
1824  aEntryKey.bLocal = true;
1825  KEntry entry = lookupData(aEntryKey);
1826  if (entry.mValue.isNull())
1827  entry.bDeleted = true;
1828 
1829  entry.bDirty = true;
1830  putData(aEntryKey, entry, true); // Revert
1831  aEntryKey.bLocal = false;
1832  }
1833 
1834  // try the non-localized version
1835  KEntry entry = lookupData(aEntryKey);
1836  if (entry.mValue.isNull())
1837  entry.bDeleted = true;
1838  entry.bDirty = true;
1839  putData(aEntryKey, entry, true); // Revert
1840 }
1841 
1842 bool KConfigBase::hasDefault(const TQString &key) const
1843 {
1844  KEntryKey aEntryKey(mGroup, key.utf8());
1845  aEntryKey.bDefault = true;
1846 
1847  if (!locale().isNull()) {
1848  // try the localized key first
1849  aEntryKey.bLocal = true;
1850  KEntry entry = lookupData(aEntryKey);
1851  if (!entry.mValue.isNull())
1852  return true;
1853 
1854  aEntryKey.bLocal = false;
1855  }
1856 
1857  // try the non-localized version
1858  KEntry entry = lookupData(aEntryKey);
1859  if (!entry.mValue.isNull())
1860  return true;
1861 
1862  return false;
1863 }
1864 
1865 
1866 
1867 KConfigGroup::KConfigGroup(KConfigBase *master, const TQString &group)
1868 {
1869  mMaster = master;
1870  backEnd = mMaster->backEnd; // Needed for getConfigState()
1871  bLocaleInitialized = true;
1872  bReadOnly = mMaster->bReadOnly;
1873  bExpand = false;
1874  bDirty = false; // Not used
1875  mGroup = group.utf8();
1876  aLocaleString = mMaster->aLocaleString;
1877  setReadDefaults(mMaster->readDefaults());
1878 }
1879 
1880 KConfigGroup::KConfigGroup(KConfigBase *master, const TQCString &group)
1881 {
1882  mMaster = master;
1883  backEnd = mMaster->backEnd; // Needed for getConfigState()
1884  bLocaleInitialized = true;
1885  bReadOnly = mMaster->bReadOnly;
1886  bExpand = false;
1887  bDirty = false; // Not used
1888  mGroup = group;
1889  aLocaleString = mMaster->aLocaleString;
1890  setReadDefaults(mMaster->readDefaults());
1891 }
1892 
1893 KConfigGroup::KConfigGroup(KConfigBase *master, const char * group)
1894 {
1895  mMaster = master;
1896  backEnd = mMaster->backEnd; // Needed for getConfigState()
1897  bLocaleInitialized = true;
1898  bReadOnly = mMaster->bReadOnly;
1899  bExpand = false;
1900  bDirty = false; // Not used
1901  mGroup = group;
1902  aLocaleString = mMaster->aLocaleString;
1903  setReadDefaults(mMaster->readDefaults());
1904 }
1905 
1906 void KConfigGroup::deleteGroup(bool bGlobal)
1907 {
1908  mMaster->deleteGroup(KConfigBase::group(), true, bGlobal);
1909 }
1910 
1911 bool KConfigGroup::groupIsImmutable() const
1912 {
1913  return mMaster->groupIsImmutable(KConfigBase::group());
1914 }
1915 
1916 void KConfigGroup::setDirty(bool _bDirty)
1917 {
1918  mMaster->setDirty(_bDirty);
1919 }
1920 
1921 void KConfigGroup::putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup)
1922 {
1923  mMaster->putData(_key, _data, _checkGroup);
1924 }
1925 
1926 KEntry KConfigGroup::lookupData(const KEntryKey &_key) const
1927 {
1928  return mMaster->lookupData(_key);
1929 }
1930 
1931 void KConfigGroup::sync()
1932 {
1933  mMaster->sync();
1934 }
1935 
1936 void KConfigBase::virtual_hook( int, void* )
1937 { /*BASE::virtual_hook( id, data );*/ }
1938 
1939 void KConfigGroup::virtual_hook( int id, void* data )
1940 { KConfigBase::virtual_hook( id, data ); }
1941 
1942 bool KConfigBase::checkConfigFilesWritable(bool warnUser)
1943 {
1944  if (backEnd)
1945  return backEnd->checkConfigFilesWritable(warnUser);
1946  else
1947  return false;
1948 }
1949 
1950 #include "kconfigbase.moc"
KConfigBase::putData
virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup=true)=0
Inserts a (key/value) pair into the internal storage mechanism of the configuration object...
KConfigBase::readNum64Entry
TQ_INT64 readNum64Entry(const TQString &pKey, TQ_INT64 nDefault=0) const
Reads a 64-bit numerical value.
Definition: kconfigbase.cpp:713
KConfigBase::deleteEntry
void deleteEntry(const TQString &pKey, bool bNLS=false, bool bGlobal=false)
Deletes the entry specified by pKey in the current group.
Definition: kconfigbase.cpp:1220
KConfigBase::readLongNumEntry
long readLongNumEntry(const TQString &pKey, long nDefault=0) const
Reads a numerical value.
Definition: kconfigbase.cpp:676
KConfigBase::checkConfigFilesWritable
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
Definition: kconfigbase.cpp:1942
KConfigBase::readDefaults
bool readDefaults() const
Definition: kconfigbase.cpp:1810
KGlobal::locale
static KLocale * locale()
Returns the global locale object.
Definition: kglobal.cpp:88
KConfigBase::entryIsImmutable
bool entryIsImmutable(const TQString &key) const
Checks whether it is possible to change the given entry.
Definition: kconfigbase.cpp:183
KGlobalSettings::musicPath
static TQString musicPath()
The path where documents are stored of the current user.
Definition: kglobalsettings.h:266
KConfigBase::readRectEntry
TQRect readRectEntry(const TQString &pKey, const TQRect *pDefault=0L) const
Reads a TQRect entry.
Definition: kconfigbase.cpp:895
KConfigBase::ConfigState
ConfigState
Possible return values for getConfigState().
Definition: kconfigbase.h:1805
KConfigBase::internalEntryMap
virtual KEntryMap internalEntryMap() const =0
Returns a map (tree) of the entries in the tree.
KEntry::bDeleted
bool bDeleted
Entry has been deleted.
Definition: kconfigdata.h:57
KConfigBase::readPathListEntry
TQStringList readPathListEntry(const TQString &pKey, char sep= ',') const
Reads a list of string paths.
Definition: kconfigbase.cpp:622
KEntry
map/dict/list config node entry.
Definition: kconfigdata.h:32
KGlobalSettings::downloadPath
static TQString downloadPath()
The path where documents are stored of the current user.
Definition: kglobalsettings.h:260
KConfigBase::isReadOnly
bool isReadOnly() const
Returns the read-only status of the config object.
Definition: kconfigbase.h:1739
KConfigBase::readDoubleNumEntry
double readDoubleNumEntry(const TQString &pKey, double nDefault=0.0) const
Reads a floating point value.
Definition: kconfigbase.cpp:752
KConfigBase::readUnsignedLongNumEntry
unsigned long readUnsignedLongNumEntry(const TQString &pKey, unsigned long nDefault=0) const
Read an unsigned numerical value.
Definition: kconfigbase.cpp:695
KGlobal::staticQString
static const TQString & staticQString(const char *str)
Creates a static TQString.
Definition: kglobal.cpp:128
KEntryKey::bDefault
bool bDefault
Entry indicates if this is a default value.
Definition: kconfigdata.h:90
KConfigGroup::setDirty
virtual void setDirty(bool _bDirty)
Sets the global dirty flag of the config object.
Definition: kconfigbase.cpp:1916
KConfigBase::writeEntry
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a key/value pair.
Definition: kconfigbase.cpp:1067
KStringHandler::from8Bit
static TQString from8Bit(const char *str)
Construct TQString from a c string, guessing whether it is UTF8- or Local8Bit-encoded.
Definition: kstringhandler.cpp:652
KConfigGroup::lookupData
virtual KEntry lookupData(const KEntryKey &_key) const
Looks up an entry in the config object&#39;s internal structure.
Definition: kconfigbase.cpp:1926
KConfigBase::sync
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage...
Definition: kconfigbase.cpp:1776
KConfigBase::readColorEntry
TQColor readColorEntry(const TQString &pKey, const TQColor *pDefault=0L) const
Reads a TQColor entry.
Definition: kconfigbase.cpp:970
klocale.h
KConfigBase::readIntListEntry
TQValueList< int > readIntListEntry(const TQString &pKey) const
Reads a list of Integers.
Definition: kconfigbase.cpp:590
KConfigBase::locale
TQString locale() const
Returns a the current locale.
Definition: kconfigbase.cpp:75
KConfigBase::setGroup
void setGroup(const TQString &group)
Specifies the group in which keys will be read and written.
Definition: kconfigbase.cpp:80
KConfigBackEnd::checkConfigFilesWritable
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
Definition: kconfigbackend.cpp:1155
KConfigBase::~KConfigBase
virtual ~KConfigBase()
Destructs the KConfigBase object.
Definition: kconfigbase.cpp:58
KConfigBase::readPathEntry
TQString readPathEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads a path.
Definition: kconfigbase.cpp:608
KConfigBase::group
TQString group() const
Returns the name of the group in which we are searching for keys and from which we are retrieving ent...
Definition: kconfigbase.cpp:101
KConfigBase::readEntry
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
Definition: kconfigbase.cpp:222
KGlobalSettings::picturesPath
static TQString picturesPath()
The path where documents are stored of the current user.
Definition: kglobalsettings.h:272
KConfigGroup::putData
virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup=true)
Inserts a (key/value) pair into the internal storage mechanism of the configuration object...
Definition: kconfigbase.cpp:1921
KConfigGroup::groupIsImmutable
bool groupIsImmutable() const
Checks whether it is possible to change this group.
Definition: kconfigbase.cpp:1911
KConfigBase::mGroup
TQCString mGroup
The currently selected group.
Definition: kconfigbase.h:1993
KConfigBase::setDirty
virtual void setDirty(bool _bDirty=true)
Sets the global dirty flag of the config object.
Definition: kconfigbase.h:1899
KConfigBackEnd::parseConfigFiles
virtual bool parseConfigFiles()=0
Parses all configuration files for a configuration object.
KConfigBase::readUnsignedNum64Entry
TQ_UINT64 readUnsignedNum64Entry(const TQString &pKey, TQ_UINT64 nDefault=0) const
Read an 64-bit unsigned numerical value.
Definition: kconfigbase.cpp:733
KConfigBase::groupIsImmutable
bool groupIsImmutable(const TQString &group) const
Checks whether it is possible to change the given group.
Definition: kconfigbase.cpp:173
KConfigBase::readBoolEntry
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
Reads a boolean entry.
Definition: kconfigbase.cpp:771
KEntry::bImmutable
bool bImmutable
Entry can not be modified.
Definition: kconfigdata.h:53
KEntryKey
key structure holding both the actual key and the the group to which it belongs.
Definition: kconfigdata.h:69
KConfigBase::setReadDefaults
void setReadDefaults(bool b)
When set, all readEntry and readXXXEntry calls return the system wide (default) values instead of the...
Definition: kconfigbase.cpp:1799
KLocale::language
TQString language() const
Returns the language used by this object.
Definition: klocale.cpp:554
KConfigGroup::deleteGroup
void deleteGroup(bool bGlobal=false)
Delete all entries in the entire group.
Definition: kconfigbase.cpp:1906
KGlobalSettings::desktopPath
static TQString desktopPath()
The path to the desktop directory of the current user.
Definition: kglobalsettings.h:248
KEntryKey::bLocal
bool bLocal
Entry is localised or not.
Definition: kconfigdata.h:86
KConfigBase::parseConfigFiles
virtual void parseConfigFiles()
Parses all configuration files for a configuration object.
Definition: kconfigbase.cpp:1764
KConfigBase::lookupData
virtual KEntry lookupData(const KEntryKey &_key) const =0
Looks up an entry in the config object&#39;s internal structure.
KGlobalSettings::publicSharePath
static TQString publicSharePath()
The path of the public share of the current user.
Definition: kglobalsettings.h:278
KConfigBase::backEnd
KConfigBackEnd * backEnd
A back end for loading/saving to disk in a particular format.
Definition: kconfigbase.h:1976
KConfigBase::deleteGroup
bool deleteGroup(const TQString &group, bool bDeep=true, bool bGlobal=false)
Deletes a configuration entry group.
Definition: kconfigbase.cpp:1253
KConfigBase::setDesktopGroup
void setDesktopGroup()
Sets the group to the "Desktop Entry" group used for desktop configuration files for applications...
Definition: kconfigbase.cpp:105
KConfigBase
KDE Configuration Management abstract base class.
Definition: kconfigbase.h:70
KConfigBase::readPointEntry
TQPoint readPointEntry(const TQString &pKey, const TQPoint *pDefault=0L) const
Reads a TQPoint entry.
Definition: kconfigbase.cpp:919
KGlobalSettings::documentPath
static TQString documentPath()
The path where documents are stored of the current user.
Definition: kglobalsettings.h:254
KConfigGroup::KConfigGroup
KConfigGroup(KConfigBase *master, const TQCString &group)
Construct a config group corresponding to group in master.
Definition: kconfigbase.cpp:1880
KConfigBase::readDateTimeEntry
TQDateTime readDateTimeEntry(const TQString &pKey, const TQDateTime *pDefault=0L) const
Reads a TQDateTime entry.
Definition: kconfigbase.cpp:1035
KConfigBase::setLocale
void setLocale()
Reads the locale and put in the configuration data struct.
Definition: kconfigbase.cpp:63
KConfigBase::readSizeEntry
TQSize readSizeEntry(const TQString &pKey, const TQSize *pDefault=0L) const
Reads a TQSize entry.
Definition: kconfigbase.cpp:944
KConfigBase::readEntryUntranslated
TQString readEntryUntranslated(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
Definition: kconfigbase.cpp:205
KGlobalSettings::videosPath
static TQString videosPath()
The path where documents are stored of the current user.
Definition: kglobalsettings.h:290
KConfigBackEnd::getConfigState
virtual KConfigBase::ConfigState getConfigState() const
Returns the state of the app-config object.
Definition: kconfigbackend.h:113
KEntry::bGlobal
bool bGlobal
Entry should be written to the global config file.
Definition: kconfigdata.h:49
KLocale::defaultLanguage
static TQString defaultLanguage()
Returns the name of the internal language.
Definition: klocale.cpp:2266
KConfigBase::hasKey
bool hasKey(const TQString &key) const
Checks whether the key has an entry in the currently active group.
Definition: kconfigbase.cpp:110
KConfigBase::readNumEntry
int readNumEntry(const TQString &pKey, int nDefault=0) const
Reads a numerical value.
Definition: kconfigbase.cpp:636
KEntry::bNLS
bool bNLS
Entry should be written with locale tag.
Definition: kconfigdata.h:45
KConfigBackEnd::sync
virtual void sync(bool bMerge=true)=0
Writes configuration data to file(s).
KGlobalSettings::templatesPath
static TQString templatesPath()
The path where templates are stored of the current user.
Definition: kglobalsettings.h:284
KConfigBase::getConfigState
ConfigState getConfigState() const
Returns the state of the app-config object.
Definition: kconfigbase.cpp:1787
KConfigBase::readFontEntry
TQFont readFontEntry(const TQString &pKey, const TQFont *pDefault=0L) const
Reads a TQFont value.
Definition: kconfigbase.cpp:798
KConfigBase::rollback
virtual void rollback(bool bDeep=true)
Mark the config object as "clean," i.e.
Definition: kconfigbase.cpp:1793
KConfigBase::aLocaleString
TQCString aLocaleString
The locale to retrieve keys under if possible, i.e en_US or fr.
Definition: kconfigbase.h:1997
KConfigBase::writePathEntry
void writePathEntry(const TQString &pKey, const TQString &path, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a file path.
Definition: kconfigbase.cpp:1116
KConfigGroup::sync
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage...
Definition: kconfigbase.cpp:1931
KConfigBase::bDirty
bool bDirty
Indicates whether there are any dirty entries in the config object that need to be written back to di...
Definition: kconfigbase.h:2002
KConfigBase::readUnsignedNumEntry
unsigned int readUnsignedNumEntry(const TQString &pKey, unsigned int nDefault=0) const
Reads an unsigned numerical value.
Definition: kconfigbase.cpp:657
KConfigBase::revertToDefault
void revertToDefault(const TQString &key)
Reverts the entry with key key in the current group in the application specific config file to either...
Definition: kconfigbase.cpp:1815
KConfigBase::readPropertyEntry
TQVariant readPropertyEntry(const TQString &pKey, TQVariant::Type) const
Reads the value of an entry specified by pKey in the current group.
Definition: kconfigbase.cpp:366
KConfigBase::hasGroup
bool hasGroup(const TQString &group) const
Returns true if the specified group is known about.
Definition: kconfigbase.cpp:153
KEntry::bExpand
bool bExpand
Whether to apply dollar expansion or not.
Definition: kconfigdata.h:61
KConfigBackEnd::setLocaleString
void setLocaleString(const TQCString &_localeString)
Set the locale string that defines the current language.
Definition: kconfigbackend.h:133
KEntry::bDirty
bool bDirty
Must the entry be written back to disk?
Definition: kconfigdata.h:41
KConfigBase::readListEntry
int readListEntry(const TQString &pKey, TQStrList &list, char sep= ',') const
Reads a list of strings.
Definition: kconfigbase.cpp:490
KConfigBase::isImmutable
bool isImmutable() const
Checks whether this configuration file can be modified.
Definition: kconfigbase.cpp:168
KConfigBase::hasDefault
bool hasDefault(const TQString &key) const
Returns whether a default is specified for an entry in either the system wide configuration file or t...
Definition: kconfigbase.cpp:1842
KConfigBase::KConfigBase
KConfigBase()
Construct a KConfigBase object.
Definition: kconfigbase.cpp:51

kdecore

Skip menu "kdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.11
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |