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

tdecore

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

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.1
This website is maintained by Timothy Pearson.