• 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() ), 0 );
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(TQT_TQDATE_OBJECT(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 #ifdef USE_QT3
455  case TQVariant::ByteArray:
456 #endif // USE_QT3
457  case TQVariant::BitArray:
458  case TQVariant::KeySequence:
459  case TQVariant::Pen:
460 #ifdef USE_QT4
461  case TQVariant::Char:
462  case TQVariant::Url:
463  case TQVariant::Locale:
464  case TQVariant::RectF:
465  case TQVariant::SizeF:
466  case TQVariant::Line:
467  case TQVariant::LineF:
468  case TQVariant::PointF:
469  case TQVariant::RegExp:
470  case TQVariant::Hash:
471  case TQVariant::TextLength:
472  case QVariant::TextFormat:
473  case TQVariant::Matrix:
474  case TQVariant::Transform:
475  case TQVariant::Matrix4x4:
476  case TQVariant::Vector2D:
477  case TQVariant::Vector3D:
478  case TQVariant::Vector4D:
479  case TQVariant::Quaternion:
480  case TQVariant::UserType:
481 #endif // USE_QT4
482  break;
483  }
484 
485  Q_ASSERT( 0 );
486  return TQVariant();
487 }
488 
489 int TDEConfigBase::readListEntry( const TQString& pKey,
490  TQStrList &list, char sep ) const
491 {
492  return readListEntry(pKey.utf8().data(), list, sep);
493 }
494 
495 int TDEConfigBase::readListEntry( const char *pKey,
496  TQStrList &list, char sep ) const
497 {
498  if( !hasKey( pKey ) )
499  return 0;
500 
501  TQCString str_list = readEntryUtf8( pKey );
502  if (str_list.isEmpty())
503  return 0;
504 
505  list.clear();
506  TQCString value = "";
507  int len = str_list.length();
508 
509  for (int i = 0; i < len; i++) {
510  if (str_list[i] != sep && str_list[i] != '\\') {
511  value += str_list[i];
512  continue;
513  }
514  if (str_list[i] == '\\') {
515  i++;
516  if ( i < len )
517  value += str_list[i];
518  continue;
519  }
520  // if we fell through to here, we are at a separator. Append
521  // contents of value to the list
522  // !!! Sergey A. Sukiyazov <corwin@micom.don.ru> !!!
523  // A TQStrList may contain values in 8bit locale cpecified
524  // encoding
525  list.append( value );
526  value.truncate(0);
527  }
528 
529  if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] == '\\' ) )
530  list.append( value );
531  return list.count();
532 }
533 
534 TQStringList TDEConfigBase::readListEntry( const TQString& pKey, char sep ) const
535 {
536  return readListEntry(pKey.utf8().data(), sep);
537 }
538 
539 TQStringList TDEConfigBase::readListEntry( const char *pKey, char sep ) const
540 {
541  static const TQString& emptyString = TDEGlobal::staticQString("");
542 
543  TQStringList list;
544  if( !hasKey( pKey ) )
545  return list;
546  TQString str_list = readEntry( pKey );
547  if( str_list.isEmpty() )
548  return list;
549  TQString value(emptyString);
550  int len = str_list.length();
551  // obviously too big, but faster than letting each += resize the string.
552  value.reserve( len );
553  for( int i = 0; i < len; i++ )
554  {
555  if( str_list[i] != sep && str_list[i] != '\\' )
556  {
557  value += str_list[i];
558  continue;
559  }
560  if( str_list[i] == '\\' )
561  {
562  i++;
563  if ( i < len )
564  value += str_list[i];
565  continue;
566  }
567  TQString finalvalue( value );
568  finalvalue.squeeze();
569  list.append( finalvalue );
570  value.truncate( 0 );
571  }
572  if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] == '\\' ) )
573  {
574  value.squeeze();
575  list.append( value );
576  }
577  return list;
578 }
579 
580 TQStringList TDEConfigBase::readListEntry( const char* pKey, const TQStringList& aDefault,
581  char sep ) const
582 {
583  if ( !hasKey( pKey ) )
584  return aDefault;
585  else
586  return readListEntry( pKey, sep );
587 }
588 
589 TQValueList<int> TDEConfigBase::readIntListEntry( const TQString& pKey ) const
590 {
591  return readIntListEntry(pKey.utf8().data());
592 }
593 
594 TQValueList<int> TDEConfigBase::readIntListEntry( const char *pKey ) const
595 {
596  TQStringList strlist = readListEntry(pKey);
597  TQValueList<int> list;
598  TQStringList::ConstIterator end(strlist.end());
599  for (TQStringList::ConstIterator it = strlist.begin(); it != end; ++it)
600  // I do not check if the toInt failed because I consider the number of items
601  // more important than their value
602  list << (*it).toInt();
603 
604  return list;
605 }
606 
607 TQString TDEConfigBase::readPathEntry( const TQString& pKey, const TQString& pDefault ) const
608 {
609  return readPathEntry(pKey.utf8().data(), pDefault);
610 }
611 
612 TQString TDEConfigBase::readPathEntry( const char *pKey, const TQString& pDefault ) const
613 {
614  const bool bExpandSave = bExpand;
615  bExpand = true;
616  TQString aValue = readEntry( pKey, pDefault );
617  bExpand = bExpandSave;
618  return aValue;
619 }
620 
621 TQStringList TDEConfigBase::readPathListEntry( const TQString& pKey, char sep ) const
622 {
623  return readPathListEntry(pKey.utf8().data(), sep);
624 }
625 
626 TQStringList TDEConfigBase::readPathListEntry( const char *pKey, char sep ) const
627 {
628  const bool bExpandSave = bExpand;
629  bExpand = true;
630  TQStringList aValue = readListEntry( pKey, sep );
631  bExpand = bExpandSave;
632  return aValue;
633 }
634 
635 int TDEConfigBase::readNumEntry( const TQString& pKey, int nDefault) const
636 {
637  return readNumEntry(pKey.utf8().data(), nDefault);
638 }
639 
640 int TDEConfigBase::readNumEntry( const char *pKey, int nDefault) const
641 {
642  TQCString aValue = readEntryUtf8( pKey );
643  if( aValue.isNull() )
644  return nDefault;
645  else if( aValue == "true" || aValue == "on" || aValue == "yes" )
646  return 1;
647  else
648  {
649  bool ok;
650  int rc = aValue.toInt( &ok );
651  return( ok ? rc : nDefault );
652  }
653 }
654 
655 
656 unsigned int TDEConfigBase::readUnsignedNumEntry( const TQString& pKey, unsigned int nDefault) const
657 {
658  return readUnsignedNumEntry(pKey.utf8().data(), nDefault);
659 }
660 
661 unsigned int TDEConfigBase::readUnsignedNumEntry( const char *pKey, unsigned int nDefault) const
662 {
663  TQCString aValue = readEntryUtf8( pKey );
664  if( aValue.isNull() )
665  return nDefault;
666  else
667  {
668  bool ok;
669  unsigned int rc = aValue.toUInt( &ok );
670  return( ok ? rc : nDefault );
671  }
672 }
673 
674 
675 long TDEConfigBase::readLongNumEntry( const TQString& pKey, long nDefault) const
676 {
677  return readLongNumEntry(pKey.utf8().data(), nDefault);
678 }
679 
680 long TDEConfigBase::readLongNumEntry( const char *pKey, long nDefault) const
681 {
682  TQCString aValue = readEntryUtf8( pKey );
683  if( aValue.isNull() )
684  return nDefault;
685  else
686  {
687  bool ok;
688  long rc = aValue.toLong( &ok );
689  return( ok ? rc : nDefault );
690  }
691 }
692 
693 
694 unsigned long TDEConfigBase::readUnsignedLongNumEntry( const TQString& pKey, unsigned long nDefault) const
695 {
696  return readUnsignedLongNumEntry(pKey.utf8().data(), nDefault);
697 }
698 
699 unsigned long TDEConfigBase::readUnsignedLongNumEntry( const char *pKey, unsigned long nDefault) const
700 {
701  TQCString aValue = readEntryUtf8( pKey );
702  if( aValue.isNull() )
703  return nDefault;
704  else
705  {
706  bool ok;
707  unsigned long rc = aValue.toULong( &ok );
708  return( ok ? rc : nDefault );
709  }
710 }
711 
712 TQ_INT64 TDEConfigBase::readNum64Entry( const TQString& pKey, TQ_INT64 nDefault) const
713 {
714  return readNum64Entry(pKey.utf8().data(), nDefault);
715 }
716 
717 TQ_INT64 TDEConfigBase::readNum64Entry( const char *pKey, TQ_INT64 nDefault) const
718 {
719  // Note that TQCString::toLongLong() is missing, we muse use a TQString instead.
720  TQString aValue = readEntry( pKey );
721  if( aValue.isNull() )
722  return nDefault;
723  else
724  {
725  bool ok;
726  TQ_INT64 rc = aValue.toLongLong( &ok );
727  return( ok ? rc : nDefault );
728  }
729 }
730 
731 
732 TQ_UINT64 TDEConfigBase::readUnsignedNum64Entry( const TQString& pKey, TQ_UINT64 nDefault) const
733 {
734  return readUnsignedNum64Entry(pKey.utf8().data(), nDefault);
735 }
736 
737 TQ_UINT64 TDEConfigBase::readUnsignedNum64Entry( const char *pKey, TQ_UINT64 nDefault) const
738 {
739  // Note that TQCString::toULongLong() is missing, we muse use a TQString instead.
740  TQString aValue = readEntry( pKey );
741  if( aValue.isNull() )
742  return nDefault;
743  else
744  {
745  bool ok;
746  TQ_UINT64 rc = aValue.toULongLong( &ok );
747  return( ok ? rc : nDefault );
748  }
749 }
750 
751 double TDEConfigBase::readDoubleNumEntry( const TQString& pKey, double nDefault) const
752 {
753  return readDoubleNumEntry(pKey.utf8().data(), nDefault);
754 }
755 
756 double TDEConfigBase::readDoubleNumEntry( const char *pKey, double nDefault) const
757 {
758  TQCString aValue = readEntryUtf8( pKey );
759  if( aValue.isNull() )
760  return nDefault;
761  else
762  {
763  bool ok;
764  double rc = aValue.toDouble( &ok );
765  return( ok ? rc : nDefault );
766  }
767 }
768 
769 
770 bool TDEConfigBase::readBoolEntry( const TQString& pKey, bool bDefault ) const
771 {
772  return readBoolEntry(pKey.utf8().data(), bDefault);
773 }
774 
775 bool TDEConfigBase::readBoolEntry( const char *pKey, bool bDefault ) const
776 {
777  TQCString aValue = readEntryUtf8( pKey );
778 
779  if( aValue.isNull() )
780  return bDefault;
781  else
782  {
783  if( aValue == "true" || aValue == "on" || aValue == "yes" || aValue == "1" )
784  return true;
785  else
786  {
787  bool bOK;
788  int val = aValue.toInt( &bOK );
789  if( bOK && val != 0 )
790  return true;
791  else
792  return false;
793  }
794  }
795 }
796 
797 TQFont TDEConfigBase::readFontEntry( const TQString& pKey, const TQFont* pDefault ) const
798 {
799  return readFontEntry(pKey.utf8().data(), pDefault);
800 }
801 
802 TQFont TDEConfigBase::readFontEntry( const char *pKey, const TQFont* pDefault ) const
803 {
804  TQFont aRetFont;
805 
806  TQString aValue = readEntry( pKey );
807  if( !aValue.isNull() ) {
808  if ( aValue.contains( ',' ) > 5 ) {
809  // KDE3 and upwards entry
810  if ( !aRetFont.fromString( aValue ) && pDefault )
811  aRetFont = *pDefault;
812  }
813  else {
814  // backward compatibility with older font formats
815  // ### remove KDE 3.1 ?
816  // find first part (font family)
817  int nIndex = aValue.find( ',' );
818  if( nIndex == -1 ){
819  if( pDefault )
820  aRetFont = *pDefault;
821  return aRetFont;
822  }
823  aRetFont.setFamily( aValue.left( nIndex ) );
824 
825  // find second part (point size)
826  int nOldIndex = nIndex;
827  nIndex = aValue.find( ',', nOldIndex+1 );
828  if( nIndex == -1 ){
829  if( pDefault )
830  aRetFont = *pDefault;
831  return aRetFont;
832  }
833 
834  aRetFont.setPointSize( aValue.mid( nOldIndex+1,
835  nIndex-nOldIndex-1 ).toInt() );
836 
837  // find third part (style hint)
838  nOldIndex = nIndex;
839  nIndex = aValue.find( ',', nOldIndex+1 );
840 
841  if( nIndex == -1 ){
842  if( pDefault )
843  aRetFont = *pDefault;
844  return aRetFont;
845  }
846 
847  aRetFont.setStyleHint( (TQFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() );
848 
849  // find fourth part (char set)
850  nOldIndex = nIndex;
851  nIndex = aValue.find( ',', nOldIndex+1 );
852 
853  if( nIndex == -1 ){
854  if( pDefault )
855  aRetFont = *pDefault;
856  return aRetFont;
857  }
858 
859  TQString chStr=aValue.mid( nOldIndex+1,
860  nIndex-nOldIndex-1 );
861  // find fifth part (weight)
862  nOldIndex = nIndex;
863  nIndex = aValue.find( ',', nOldIndex+1 );
864 
865  if( nIndex == -1 ){
866  if( pDefault )
867  aRetFont = *pDefault;
868  return aRetFont;
869  }
870 
871  aRetFont.setWeight( aValue.mid( nOldIndex+1,
872  nIndex-nOldIndex-1 ).toUInt() );
873 
874  // find sixth part (font bits)
875  uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt();
876 
877  aRetFont.setItalic( nFontBits & 0x01 );
878  aRetFont.setUnderline( nFontBits & 0x02 );
879  aRetFont.setStrikeOut( nFontBits & 0x04 );
880  aRetFont.setFixedPitch( nFontBits & 0x08 );
881  aRetFont.setRawMode( nFontBits & 0x20 );
882  }
883  }
884  else
885  {
886  if( pDefault )
887  aRetFont = *pDefault;
888  }
889 
890  return aRetFont;
891 }
892 
893 
894 TQRect TDEConfigBase::readRectEntry( const TQString& pKey, const TQRect* pDefault ) const
895 {
896  return readRectEntry(pKey.utf8().data(), pDefault);
897 }
898 
899 TQRect TDEConfigBase::readRectEntry( const char *pKey, const TQRect* pDefault ) const
900 {
901  TQCString aValue = readEntryUtf8(pKey);
902 
903  if (!aValue.isEmpty())
904  {
905  int left, top, width, height;
906 
907  if (sscanf(aValue.data(), "%d,%d,%d,%d", &left, &top, &width, &height) == 4)
908  {
909  return TQRect(left, top, width, height);
910  }
911  }
912  if (pDefault)
913  return *pDefault;
914  return TQRect();
915 }
916 
917 
918 TQPoint TDEConfigBase::readPointEntry( const TQString& pKey,
919  const TQPoint* pDefault ) const
920 {
921  return readPointEntry(pKey.utf8().data(), pDefault);
922 }
923 
924 TQPoint TDEConfigBase::readPointEntry( const char *pKey,
925  const TQPoint* pDefault ) const
926 {
927  TQCString aValue = readEntryUtf8(pKey);
928 
929  if (!aValue.isEmpty())
930  {
931  int x,y;
932 
933  if (sscanf(aValue.data(), "%d,%d", &x, &y) == 2)
934  {
935  return TQPoint(x,y);
936  }
937  }
938  if (pDefault)
939  return *pDefault;
940  return TQPoint();
941 }
942 
943 TQSize TDEConfigBase::readSizeEntry( const TQString& pKey,
944  const TQSize* pDefault ) const
945 {
946  return readSizeEntry(pKey.utf8().data(), pDefault);
947 }
948 
949 TQSize TDEConfigBase::readSizeEntry( const char *pKey,
950  const TQSize* pDefault ) const
951 {
952  TQCString aValue = readEntryUtf8(pKey);
953 
954  if (!aValue.isEmpty())
955  {
956  int width,height;
957 
958  if (sscanf(aValue.data(), "%d,%d", &width, &height) == 2)
959  {
960  return TQSize(width, height);
961  }
962  }
963  if (pDefault)
964  return *pDefault;
965  return TQSize();
966 }
967 
968 
969 TQColor TDEConfigBase::readColorEntry( const TQString& pKey,
970  const TQColor* pDefault ) const
971 {
972  return readColorEntry(pKey.utf8().data(), pDefault);
973 }
974 
975 TQColor TDEConfigBase::readColorEntry( const char *pKey,
976  const TQColor* pDefault ) const
977 {
978  TQColor aRetColor;
979  int nRed = 0, nGreen = 0, nBlue = 0;
980 
981  TQString aValue = readEntry( pKey );
982  if( !aValue.isEmpty() )
983  {
984  if ( aValue.at(0) == (QChar)'#' )
985  {
986  aRetColor.setNamedColor(aValue);
987  }
988  else
989  {
990 
991  bool bOK;
992 
993  // find first part (red)
994  int nIndex = aValue.find( ',' );
995 
996  if( nIndex == -1 ){
997  // return a sensible default -- Bernd
998  if( pDefault )
999  aRetColor = *pDefault;
1000  return aRetColor;
1001  }
1002 
1003  nRed = aValue.left( nIndex ).toInt( &bOK );
1004 
1005  // find second part (green)
1006  int nOldIndex = nIndex;
1007  nIndex = aValue.find( ',', nOldIndex+1 );
1008 
1009  if( nIndex == -1 ){
1010  // return a sensible default -- Bernd
1011  if( pDefault )
1012  aRetColor = *pDefault;
1013  return aRetColor;
1014  }
1015  nGreen = aValue.mid( nOldIndex+1,
1016  nIndex-nOldIndex-1 ).toInt( &bOK );
1017 
1018  // find third part (blue)
1019  nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK );
1020 
1021  aRetColor.setRgb( nRed, nGreen, nBlue );
1022  }
1023  }
1024  else {
1025 
1026  if( pDefault )
1027  aRetColor = *pDefault;
1028  }
1029 
1030  return aRetColor;
1031 }
1032 
1033 
1034 TQDateTime TDEConfigBase::readDateTimeEntry( const TQString& pKey,
1035  const TQDateTime* pDefault ) const
1036 {
1037  return readDateTimeEntry(pKey.utf8().data(), pDefault);
1038 }
1039 
1040 // ### currentDateTime() as fallback ? (Harri)
1041 TQDateTime TDEConfigBase::readDateTimeEntry( const char *pKey,
1042  const TQDateTime* pDefault ) const
1043 {
1044  if( !hasKey( pKey ) )
1045  {
1046  if( pDefault )
1047  return *pDefault;
1048  else
1049  return TQDateTime::currentDateTime();
1050  }
1051 
1052  TQStrList list;
1053  int count = readListEntry( pKey, list, ',' );
1054  if( count == 6 ) {
1055  TQDate date( atoi( list.at( 0 ) ), atoi( list.at( 1 ) ),
1056  atoi( list.at( 2 ) ) );
1057  TQTime time( atoi( list.at( 3 ) ), atoi( list.at( 4 ) ),
1058  atoi( list.at( 5 ) ) );
1059 
1060  return TQDateTime( date, time );
1061  }
1062 
1063  return TQDateTime::currentDateTime();
1064 }
1065 
1066 void TDEConfigBase::writeEntry( const TQString& pKey, const TQString& value,
1067  bool bPersistent,
1068  bool bGlobal,
1069  bool bNLS )
1070 {
1071  writeEntry(pKey.utf8().data(), value, bPersistent, bGlobal, bNLS);
1072 }
1073 
1074 void TDEConfigBase::writeEntry( const char *pKey, const TQString& value,
1075  bool bPersistent,
1076  bool bGlobal,
1077  bool bNLS )
1078 {
1079  writeEntry(pKey, value, bPersistent, bGlobal, bNLS, false);
1080 }
1081 
1082 void TDEConfigBase::writeEntry( const char *pKey, const TQString& value,
1083  bool bPersistent,
1084  bool bGlobal,
1085  bool bNLS,
1086  bool bExpand )
1087 {
1088  // the TDEConfig object is dirty now
1089  // set this before any IO takes place so that if any derivative
1090  // classes do caching, they won't try and flush the cache out
1091  // from under us before we read. A race condition is still
1092  // possible but minimized.
1093  if( bPersistent )
1094  setDirty(true);
1095 
1096  if (!bLocaleInitialized && TDEGlobal::locale())
1097  setLocale();
1098 
1099  KEntryKey entryKey(mGroup, pKey);
1100  entryKey.bLocal = bNLS;
1101 
1102  KEntry aEntryData;
1103  aEntryData.mValue = value.utf8(); // set new value
1104  aEntryData.bGlobal = bGlobal;
1105  aEntryData.bNLS = bNLS;
1106  aEntryData.bExpand = bExpand;
1107 
1108  if (bPersistent)
1109  aEntryData.bDirty = true;
1110 
1111  // rewrite the new value
1112  putData(entryKey, aEntryData, true);
1113 }
1114 
1115 void TDEConfigBase::writePathEntry( const TQString& pKey, const TQString & path,
1116  bool bPersistent, bool bGlobal,
1117  bool bNLS)
1118 {
1119  writePathEntry(pKey.utf8().data(), path, bPersistent, bGlobal, bNLS);
1120 }
1121 
1122 
1123 static bool cleanHomeDirPath( TQString &path, const TQString &homeDir )
1124 {
1125 #ifdef Q_WS_WIN //safer
1126  if (!TQDir::convertSeparators(path).startsWith(TQDir::convertSeparators(homeDir)))
1127  return false;
1128 #else
1129  if (!path.startsWith(homeDir))
1130  return false;
1131 #endif
1132 
1133  unsigned int len = homeDir.length();
1134  // replace by "$HOME" if possible
1135  if (len && (path.length() == len || path[len] == '/')) {
1136  path.replace(0, len, TQString::fromLatin1("$HOME"));
1137  return true;
1138  } else
1139  return false;
1140 }
1141 
1142 static TQString translatePath( TQString path )
1143 {
1144  if (path.isEmpty())
1145  return path;
1146 
1147  // only "our" $HOME should be interpreted
1148  path.replace('$', "$$");
1149 
1150  bool startsWithFile = path.startsWith("file:", false);
1151 
1152  // return original path, if it refers to another type of URL (e.g. http:/), or
1153  // if the path is already relative to another directory
1154  if (((!startsWithFile) && (path[0] != '/')) || (startsWithFile && (path[5] != '/'))) {
1155  return path;
1156  }
1157 
1158  if (startsWithFile) {
1159  path.remove(0,5); // strip leading "file:/" off the string
1160  }
1161 
1162  // keep only one single '/' at the beginning - needed for cleanHomeDirPath()
1163  while (path[0] == '/' && path[1] == '/') {
1164  path.remove(0,1);
1165  }
1166 
1167  // we can not use TDEGlobal::dirs()->relativeLocation("home", path) here,
1168  // since it would not recognize paths without a trailing '/'.
1169  // All of the 3 following functions to return the user's home directory
1170  // can return different paths. We have to test all them.
1171  TQString homeDir0 = TQFile::decodeName(getenv("HOME"));
1172  TQString homeDir1 = TQDir::homeDirPath();
1173  TQString homeDir2 = TQDir(homeDir1).canonicalPath();
1174  if (cleanHomeDirPath(path, homeDir0) ||
1175  cleanHomeDirPath(path, homeDir1) ||
1176  cleanHomeDirPath(path, homeDir2) ) {
1177  // kdDebug() << "Path was replaced\n";
1178  }
1179 
1180  if (startsWithFile)
1181  path.prepend( "file://" );
1182 
1183  return path;
1184 }
1185 
1186 void TDEConfigBase::writePathEntry( const char *pKey, const TQString & path,
1187  bool bPersistent, bool bGlobal,
1188  bool bNLS)
1189 {
1190  writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS, true);
1191 }
1192 
1193 void TDEConfigBase::writePathEntry( const char *pKey, const TQString & path,
1194  bool bPersistent, bool bGlobal,
1195  bool bNLS, bool expand)
1196 {
1197  writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS, expand);
1198 }
1199 
1200 void TDEConfigBase::writePathEntry ( const TQString& pKey, const TQStringList &list,
1201  char sep , bool bPersistent,
1202  bool bGlobal, bool bNLS )
1203 {
1204  writePathEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1205 }
1206 
1207 void TDEConfigBase::writePathEntry ( const char *pKey, const TQStringList &list,
1208  char sep , bool bPersistent,
1209  bool bGlobal, bool bNLS )
1210 {
1211  if( list.isEmpty() )
1212  {
1213  writeEntry( pKey, TQString::fromLatin1(""), bPersistent );
1214  return;
1215  }
1216  TQStringList new_list;
1217  TQStringList::ConstIterator it = list.begin();
1218  for( ; it != list.end(); ++it )
1219  {
1220  TQString value = *it;
1221  new_list.append( translatePath(value) );
1222  }
1223  writeEntry( pKey, new_list, sep, bPersistent, bGlobal, bNLS, true );
1224 }
1225 
1226 void TDEConfigBase::deleteEntry( const TQString& pKey,
1227  bool bNLS,
1228  bool bGlobal)
1229 {
1230  deleteEntry(pKey.utf8().data(), bNLS, bGlobal);
1231 }
1232 
1233 void TDEConfigBase::deleteEntry( const char *pKey,
1234  bool bNLS,
1235  bool bGlobal)
1236 {
1237  // the TDEConfig object is dirty now
1238  // set this before any IO takes place so that if any derivative
1239  // classes do caching, they won't try and flush the cache out
1240  // from under us before we read. A race condition is still
1241  // possible but minimized.
1242  setDirty(true);
1243 
1244  if (!bLocaleInitialized && TDEGlobal::locale())
1245  setLocale();
1246 
1247  KEntryKey entryKey(mGroup, pKey);
1248  KEntry aEntryData;
1249 
1250  aEntryData.bGlobal = bGlobal;
1251  aEntryData.bNLS = bNLS;
1252  aEntryData.bDirty = true;
1253  aEntryData.bDeleted = true;
1254 
1255  // rewrite the new value
1256  putData(entryKey, aEntryData, true);
1257 }
1258 
1259 bool TDEConfigBase::deleteGroup( const TQString& group, bool bDeep, bool bGlobal )
1260 {
1261  KEntryMap aEntryMap = internalEntryMap(group);
1262 
1263  if (!bDeep) {
1264  // Check if it empty
1265  return aEntryMap.isEmpty();
1266  }
1267 
1268  bool dirty = false;
1269  bool checkGroup = true;
1270  // we want to remove all entries in the group
1271  KEntryMapIterator aIt;
1272  for (aIt = aEntryMap.begin(); aIt != aEntryMap.end(); ++aIt)
1273  {
1274  if (!aIt.key().mKey.isEmpty() && !aIt.key().bDefault && !(*aIt).bDeleted)
1275  {
1276  (*aIt).bDeleted = true;
1277  (*aIt).bDirty = true;
1278  (*aIt).bGlobal = bGlobal;
1279  (*aIt).mValue = 0;
1280  putData(aIt.key(), *aIt, checkGroup);
1281  checkGroup = false;
1282  dirty = true;
1283  }
1284  }
1285  if (dirty)
1286  setDirty(true);
1287  return true;
1288 }
1289 
1290 void TDEConfigBase::writeEntry ( const TQString& pKey, const TQVariant &prop,
1291  bool bPersistent,
1292  bool bGlobal, bool bNLS )
1293 {
1294  writeEntry(pKey.utf8().data(), prop, bPersistent, bGlobal, bNLS);
1295 }
1296 
1297 void TDEConfigBase::writeEntry ( const char *pKey, const TQVariant &prop,
1298  bool bPersistent,
1299  bool bGlobal, bool bNLS )
1300 {
1301  switch( prop.type() )
1302  {
1303  case TQVariant::Invalid:
1304  writeEntry( pKey, "", bPersistent, bGlobal, bNLS );
1305  return;
1306  case TQVariant::String:
1307  writeEntry( pKey, prop.toString(), bPersistent, bGlobal, bNLS );
1308  return;
1309  case TQVariant::StringList:
1310  writeEntry( pKey, prop.toStringList(), ',', bPersistent, bGlobal, bNLS );
1311  return;
1312  case TQVariant::List: {
1313  TQValueList<TQVariant> list = prop.toList();
1314  TQValueList<TQVariant>::ConstIterator it = list.begin();
1315  TQValueList<TQVariant>::ConstIterator end = list.end();
1316  TQStringList strList;
1317 
1318  for (; it != end; ++it )
1319  strList.append( (*it).toString() );
1320 
1321  writeEntry( pKey, strList, ',', bPersistent, bGlobal, bNLS );
1322 
1323  return;
1324  }
1325  case TQVariant::Font:
1326  writeEntry( pKey, prop.toFont(), bPersistent, bGlobal, bNLS );
1327  return;
1328  case TQVariant::Point:
1329  writeEntry( pKey, prop.toPoint(), bPersistent, bGlobal, bNLS );
1330  return;
1331  case TQVariant::Rect:
1332  writeEntry( pKey, prop.toRect(), bPersistent, bGlobal, bNLS );
1333  return;
1334  case TQVariant::Size:
1335  writeEntry( pKey, prop.toSize(), bPersistent, bGlobal, bNLS );
1336  return;
1337  case TQVariant::Color:
1338  writeEntry( pKey, prop.toColor(), bPersistent, bGlobal, bNLS );
1339  return;
1340  case TQVariant::Int:
1341  writeEntry( pKey, prop.toInt(), bPersistent, bGlobal, bNLS );
1342  return;
1343  case TQVariant::UInt:
1344  writeEntry( pKey, prop.toUInt(), bPersistent, bGlobal, bNLS );
1345  return;
1346  case TQVariant::LongLong:
1347  writeEntry( pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS );
1348  return;
1349  case TQVariant::ULongLong:
1350  writeEntry( pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS );
1351  return;
1352  case TQVariant::Bool:
1353  writeEntry( pKey, prop.toBool(), bPersistent, bGlobal, bNLS );
1354  return;
1355  case TQVariant::Double:
1356  writeEntry( pKey, prop.toDouble(), bPersistent, bGlobal, 'g', 6, bNLS );
1357  return;
1358  case TQVariant::DateTime:
1359  writeEntry( pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS);
1360  return;
1361  case TQVariant::Date:
1362  writeEntry( pKey, TQDateTime(prop.toDate()), bPersistent, bGlobal, bNLS);
1363  return;
1364 
1365  case TQVariant::Pixmap:
1366  case TQVariant::Image:
1367  case TQVariant::Brush:
1368  case TQVariant::Palette:
1369  case TQVariant::ColorGroup:
1370  case TQVariant::Map:
1371  case TQVariant::IconSet:
1372  case TQVariant::CString:
1373  case TQVariant::PointArray:
1374  case TQVariant::Region:
1375  case TQVariant::Bitmap:
1376  case TQVariant::Cursor:
1377  case TQVariant::SizePolicy:
1378  case TQVariant::Time:
1379 #ifdef USE_QT3
1380  case TQVariant::ByteArray:
1381 #endif // USE_QT3
1382  case TQVariant::BitArray:
1383  case TQVariant::KeySequence:
1384  case TQVariant::Pen:
1385 #ifdef USE_QT4
1386  case TQVariant::Char:
1387  case TQVariant::Url:
1388  case TQVariant::Locale:
1389  case TQVariant::RectF:
1390  case TQVariant::SizeF:
1391  case TQVariant::Line:
1392  case TQVariant::LineF:
1393  case TQVariant::PointF:
1394  case TQVariant::RegExp:
1395  case TQVariant::Hash:
1396  case TQVariant::TextLength:
1397  case QVariant::TextFormat:
1398  case TQVariant::Matrix:
1399  case TQVariant::Transform:
1400  case TQVariant::Matrix4x4:
1401  case TQVariant::Vector2D:
1402  case TQVariant::Vector3D:
1403  case TQVariant::Vector4D:
1404  case TQVariant::Quaternion:
1405  case TQVariant::UserType:
1406 #endif // USE_QT4
1407  break;
1408  }
1409 
1410  Q_ASSERT( 0 );
1411 }
1412 
1413 void TDEConfigBase::writeEntry ( const TQString& pKey, const TQStrList &list,
1414  char sep , bool bPersistent,
1415  bool bGlobal, bool bNLS )
1416 {
1417  writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1418 }
1419 
1420 void TDEConfigBase::writeEntry ( const char *pKey, const TQStrList &list,
1421  char sep , bool bPersistent,
1422  bool bGlobal, bool bNLS )
1423 {
1424  if( list.isEmpty() )
1425  {
1426  writeEntry( pKey, TQString::fromLatin1(""), bPersistent );
1427  return;
1428  }
1429  TQString str_list;
1430  TQStrListIterator it( list );
1431  for( ; it.current(); ++it )
1432  {
1433  uint i;
1434  TQString value;
1435  // !!! Sergey A. Sukiyazov <corwin@micom.don.ru> !!!
1436  // A TQStrList may contain values in 8bit locale cpecified
1437  // encoding or in UTF8 encoding.
1438  value = KStringHandler::from8Bit(it.current());
1439  uint strLengh(value.length());
1440  for( i = 0; i < strLengh; 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) == (QChar)sep )
1449  str_list.truncate( str_list.length() -1 );
1450  writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS );
1451 }
1452 
1453 void TDEConfigBase::writeEntry ( const TQString& pKey, const TQStringList &list,
1454  char sep , bool bPersistent,
1455  bool bGlobal, bool bNLS )
1456 {
1457  writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1458 }
1459 
1460 void TDEConfigBase::writeEntry ( const char *pKey, const TQStringList &list,
1461  char sep , bool bPersistent,
1462  bool bGlobal, bool bNLS )
1463 {
1464  writeEntry(pKey, list, sep, bPersistent, bGlobal, bNLS, false);
1465 }
1466 
1467 void TDEConfigBase::writeEntry ( const char *pKey, const TQStringList &list,
1468  char sep, bool bPersistent,
1469  bool bGlobal, bool bNLS, bool bExpand )
1470 {
1471  if( list.isEmpty() )
1472  {
1473  writeEntry( pKey, TQString::fromLatin1(""), bPersistent );
1474  return;
1475  }
1476  TQString str_list;
1477  str_list.reserve( 4096 );
1478  TQStringList::ConstIterator it = list.begin();
1479  for( ; it != list.end(); ++it )
1480  {
1481  TQString value = *it;
1482  uint i;
1483  uint strLength(value.length());
1484  for( i = 0; i < strLength; i++ )
1485  {
1486  if( value[i] == sep || value[i] == '\\' )
1487  str_list += '\\';
1488  str_list += value[i];
1489  }
1490  str_list += sep;
1491  }
1492  if( str_list.at(str_list.length() - 1) == (QChar)sep )
1493  str_list.truncate( str_list.length() -1 );
1494  writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS, bExpand );
1495 }
1496 
1497 void TDEConfigBase::writeEntry ( const TQString& pKey, const TQValueList<int> &list,
1498  bool bPersistent, bool bGlobal, bool bNLS )
1499 {
1500  writeEntry(pKey.utf8().data(), list, bPersistent, bGlobal, bNLS);
1501 }
1502 
1503 void TDEConfigBase::writeEntry ( const char *pKey, const TQValueList<int> &list,
1504  bool bPersistent, bool bGlobal, bool bNLS )
1505 {
1506  TQStringList strlist;
1507  TQValueList<int>::ConstIterator end = list.end();
1508  for (TQValueList<int>::ConstIterator it = list.begin(); it != end; it++)
1509  strlist << TQString::number(*it);
1510  writeEntry(pKey, strlist, ',', bPersistent, bGlobal, bNLS );
1511 }
1512 
1513 void TDEConfigBase::writeEntry( const TQString& pKey, int nValue,
1514  bool bPersistent, bool bGlobal,
1515  bool bNLS )
1516 {
1517  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1518 }
1519 
1520 void TDEConfigBase::writeEntry( const char *pKey, int nValue,
1521  bool bPersistent, bool bGlobal,
1522  bool bNLS )
1523 {
1524  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1525 }
1526 
1527 
1528 void TDEConfigBase::writeEntry( const TQString& pKey, unsigned int 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, unsigned int 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, long 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, long nValue,
1551  bool bPersistent, bool bGlobal,
1552  bool bNLS )
1553 {
1554  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1555 }
1556 
1557 
1558 void TDEConfigBase::writeEntry( const TQString& pKey, unsigned long nValue,
1559  bool bPersistent, bool bGlobal,
1560  bool bNLS )
1561 {
1562  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1563 }
1564 
1565 void TDEConfigBase::writeEntry( const char *pKey, unsigned long nValue,
1566  bool bPersistent, bool bGlobal,
1567  bool bNLS )
1568 {
1569  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1570 }
1571 
1572 void TDEConfigBase::writeEntry( const TQString& pKey, TQ_INT64 nValue,
1573  bool bPersistent, bool bGlobal,
1574  bool bNLS )
1575 {
1576  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1577 }
1578 
1579 void TDEConfigBase::writeEntry( const char *pKey, TQ_INT64 nValue,
1580  bool bPersistent, bool bGlobal,
1581  bool bNLS )
1582 {
1583  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1584 }
1585 
1586 
1587 void TDEConfigBase::writeEntry( const TQString& pKey, TQ_UINT64 nValue,
1588  bool bPersistent, bool bGlobal,
1589  bool bNLS )
1590 {
1591  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1592 }
1593 
1594 void TDEConfigBase::writeEntry( const char *pKey, TQ_UINT64 nValue,
1595  bool bPersistent, bool bGlobal,
1596  bool bNLS )
1597 {
1598  writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1599 }
1600 
1601 void TDEConfigBase::writeEntry( const TQString& pKey, double nValue,
1602  bool bPersistent, bool bGlobal,
1603  char format, int precision,
1604  bool bNLS )
1605 {
1606  writeEntry( pKey, TQString::number(nValue, format, precision),
1607  bPersistent, bGlobal, bNLS );
1608 }
1609 
1610 void TDEConfigBase::writeEntry( const char *pKey, double nValue,
1611  bool bPersistent, bool bGlobal,
1612  char format, int precision,
1613  bool bNLS )
1614 {
1615  writeEntry( pKey, TQString::number(nValue, format, precision),
1616  bPersistent, bGlobal, bNLS );
1617 }
1618 
1619 
1620 void TDEConfigBase::writeEntry( const TQString& pKey, bool bValue,
1621  bool bPersistent,
1622  bool bGlobal,
1623  bool bNLS )
1624 {
1625  writeEntry(pKey.utf8().data(), bValue, bPersistent, bGlobal, bNLS);
1626 }
1627 
1628 void TDEConfigBase::writeEntry( const char *pKey, bool bValue,
1629  bool bPersistent,
1630  bool bGlobal,
1631  bool bNLS )
1632 {
1633  TQString aValue;
1634 
1635  if( bValue )
1636  aValue = "true";
1637  else
1638  aValue = "false";
1639 
1640  writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1641 }
1642 
1643 
1644 void TDEConfigBase::writeEntry( const TQString& pKey, const TQFont& rFont,
1645  bool bPersistent, bool bGlobal,
1646  bool bNLS )
1647 {
1648  writeEntry(pKey.utf8().data(), rFont, bPersistent, bGlobal, bNLS);
1649 }
1650 
1651 void TDEConfigBase::writeEntry( const char *pKey, const TQFont& rFont,
1652  bool bPersistent, bool bGlobal,
1653  bool bNLS )
1654 {
1655  writeEntry( pKey, TQString(rFont.toString()), bPersistent, bGlobal, bNLS );
1656 }
1657 
1658 
1659 void TDEConfigBase::writeEntry( const TQString& pKey, const TQRect& rRect,
1660  bool bPersistent, bool bGlobal,
1661  bool bNLS )
1662 {
1663  writeEntry(pKey.utf8().data(), rRect, bPersistent, bGlobal, bNLS);
1664 }
1665 
1666 void TDEConfigBase::writeEntry( const char *pKey, const TQRect& rRect,
1667  bool bPersistent, bool bGlobal,
1668  bool bNLS )
1669 {
1670  TQStrList list;
1671  TQCString tempstr;
1672  list.insert( 0, tempstr.setNum( rRect.left() ) );
1673  list.insert( 1, tempstr.setNum( rRect.top() ) );
1674  list.insert( 2, tempstr.setNum( rRect.width() ) );
1675  list.insert( 3, tempstr.setNum( rRect.height() ) );
1676 
1677  writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
1678 }
1679 
1680 
1681 void TDEConfigBase::writeEntry( const TQString& pKey, const TQPoint& rPoint,
1682  bool bPersistent, bool bGlobal,
1683  bool bNLS )
1684 {
1685  writeEntry(pKey.utf8().data(), rPoint, bPersistent, bGlobal, bNLS);
1686 }
1687 
1688 void TDEConfigBase::writeEntry( const char *pKey, const TQPoint& rPoint,
1689  bool bPersistent, bool bGlobal,
1690  bool bNLS )
1691 {
1692  TQStrList list;
1693  TQCString tempstr;
1694  list.insert( 0, tempstr.setNum( rPoint.x() ) );
1695  list.insert( 1, tempstr.setNum( rPoint.y() ) );
1696 
1697  writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
1698 }
1699 
1700 
1701 void TDEConfigBase::writeEntry( const TQString& pKey, const TQSize& rSize,
1702  bool bPersistent, bool bGlobal,
1703  bool bNLS )
1704 {
1705  writeEntry(pKey.utf8().data(), rSize, bPersistent, bGlobal, bNLS);
1706 }
1707 
1708 void TDEConfigBase::writeEntry( const char *pKey, const TQSize& rSize,
1709  bool bPersistent, bool bGlobal,
1710  bool bNLS )
1711 {
1712  TQStrList list;
1713  TQCString tempstr;
1714  list.insert( 0, tempstr.setNum( rSize.width() ) );
1715  list.insert( 1, tempstr.setNum( rSize.height() ) );
1716 
1717  writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
1718 }
1719 
1720 void TDEConfigBase::writeEntry( const TQString& pKey, const TQColor& rColor,
1721  bool bPersistent,
1722  bool bGlobal,
1723  bool bNLS )
1724 {
1725  writeEntry( pKey.utf8().data(), rColor, bPersistent, bGlobal, bNLS);
1726 }
1727 
1728 void TDEConfigBase::writeEntry( const char *pKey, const TQColor& rColor,
1729  bool bPersistent,
1730  bool bGlobal,
1731  bool bNLS )
1732 {
1733  TQString aValue;
1734  if (rColor.isValid())
1735  aValue.sprintf( "%d,%d,%d", rColor.red(), rColor.green(), rColor.blue() );
1736  else
1737  aValue = "invalid";
1738 
1739  writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1740 }
1741 
1742 void TDEConfigBase::writeEntry( const TQString& pKey, const TQDateTime& rDateTime,
1743  bool bPersistent, bool bGlobal,
1744  bool bNLS )
1745 {
1746  writeEntry(pKey.utf8().data(), rDateTime, bPersistent, bGlobal, bNLS);
1747 }
1748 
1749 void TDEConfigBase::writeEntry( const char *pKey, const TQDateTime& rDateTime,
1750  bool bPersistent, bool bGlobal,
1751  bool bNLS )
1752 {
1753  TQStrList list;
1754  TQCString tempstr;
1755 
1756  TQTime time = TQT_TQTIME_OBJECT(rDateTime.time());
1757  TQDate date = TQT_TQDATE_OBJECT(rDateTime.date());
1758 
1759  list.insert( 0, tempstr.setNum( date.year() ) );
1760  list.insert( 1, tempstr.setNum( date.month() ) );
1761  list.insert( 2, tempstr.setNum( date.day() ) );
1762 
1763  list.insert( 3, tempstr.setNum( time.hour() ) );
1764  list.insert( 4, tempstr.setNum( time.minute() ) );
1765  list.insert( 5, tempstr.setNum( time.second() ) );
1766 
1767  writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
1768 }
1769 
1770 void TDEConfigBase::parseConfigFiles()
1771 {
1772  if (!bLocaleInitialized && TDEGlobal::_locale) {
1773  setLocale();
1774  }
1775  if (backEnd)
1776  {
1777  backEnd->parseConfigFiles();
1778  bReadOnly = (backEnd->getConfigState() == ReadOnly);
1779  }
1780 }
1781 
1782 void TDEConfigBase::sync()
1783 {
1784  if (isReadOnly())
1785  return;
1786 
1787  if (backEnd)
1788  backEnd->sync();
1789  if (bDirty)
1790  rollback();
1791 }
1792 
1793 TDEConfigBase::ConfigState TDEConfigBase::getConfigState() const {
1794  if (backEnd)
1795  return backEnd->getConfigState();
1796  return ReadOnly;
1797 }
1798 
1799 void TDEConfigBase::rollback( bool /*bDeep = true*/ )
1800 {
1801  bDirty = false;
1802 }
1803 
1804 
1805 void TDEConfigBase::setReadDefaults(bool b)
1806 {
1807  if (!d)
1808  {
1809  if (!b) return;
1810  d = new TDEConfigBasePrivate();
1811  }
1812 
1813  d->readDefaults = b;
1814 }
1815 
1816 bool TDEConfigBase::readDefaults() const
1817 {
1818  return (d && d->readDefaults);
1819 }
1820 
1821 void TDEConfigBase::revertToDefault(const TQString &key)
1822 {
1823  setDirty(true);
1824 
1825  KEntryKey aEntryKey(mGroup, key.utf8());
1826  aEntryKey.bDefault = true;
1827 
1828  if (!locale().isNull()) {
1829  // try the localized key first
1830  aEntryKey.bLocal = true;
1831  KEntry entry = lookupData(aEntryKey);
1832  if (entry.mValue.isNull())
1833  entry.bDeleted = true;
1834 
1835  entry.bDirty = true;
1836  putData(aEntryKey, entry, true); // Revert
1837  aEntryKey.bLocal = false;
1838  }
1839 
1840  // try the non-localized version
1841  KEntry entry = lookupData(aEntryKey);
1842  if (entry.mValue.isNull())
1843  entry.bDeleted = true;
1844  entry.bDirty = true;
1845  putData(aEntryKey, entry, true); // Revert
1846 }
1847 
1848 bool TDEConfigBase::hasDefault(const TQString &key) const
1849 {
1850  KEntryKey aEntryKey(mGroup, key.utf8());
1851  aEntryKey.bDefault = true;
1852 
1853  if (!locale().isNull()) {
1854  // try the localized key first
1855  aEntryKey.bLocal = true;
1856  KEntry entry = lookupData(aEntryKey);
1857  if (!entry.mValue.isNull())
1858  return true;
1859 
1860  aEntryKey.bLocal = false;
1861  }
1862 
1863  // try the non-localized version
1864  KEntry entry = lookupData(aEntryKey);
1865  if (!entry.mValue.isNull())
1866  return true;
1867 
1868  return false;
1869 }
1870 
1871 
1872 
1873 TDEConfigGroup::TDEConfigGroup(TDEConfigBase *master, const TQString &group)
1874 {
1875  mMaster = master;
1876  backEnd = mMaster->backEnd; // Needed for getConfigState()
1877  bLocaleInitialized = true;
1878  bReadOnly = mMaster->bReadOnly;
1879  bExpand = false;
1880  bDirty = false; // Not used
1881  mGroup = group.utf8();
1882  aLocaleString = mMaster->aLocaleString;
1883  setReadDefaults(mMaster->readDefaults());
1884 }
1885 
1886 TDEConfigGroup::TDEConfigGroup(TDEConfigBase *master, const TQCString &group)
1887 {
1888  mMaster = master;
1889  backEnd = mMaster->backEnd; // Needed for getConfigState()
1890  bLocaleInitialized = true;
1891  bReadOnly = mMaster->bReadOnly;
1892  bExpand = false;
1893  bDirty = false; // Not used
1894  mGroup = group;
1895  aLocaleString = mMaster->aLocaleString;
1896  setReadDefaults(mMaster->readDefaults());
1897 }
1898 
1899 TDEConfigGroup::TDEConfigGroup(TDEConfigBase *master, const char * group)
1900 {
1901  mMaster = master;
1902  backEnd = mMaster->backEnd; // Needed for getConfigState()
1903  bLocaleInitialized = true;
1904  bReadOnly = mMaster->bReadOnly;
1905  bExpand = false;
1906  bDirty = false; // Not used
1907  mGroup = group;
1908  aLocaleString = mMaster->aLocaleString;
1909  setReadDefaults(mMaster->readDefaults());
1910 }
1911 
1912 void TDEConfigGroup::deleteGroup(bool bGlobal)
1913 {
1914  mMaster->deleteGroup(TDEConfigBase::group(), true, bGlobal);
1915 }
1916 
1917 bool TDEConfigGroup::groupIsImmutable() const
1918 {
1919  return mMaster->groupIsImmutable(TDEConfigBase::group());
1920 }
1921 
1922 void TDEConfigGroup::setDirty(bool _bDirty)
1923 {
1924  mMaster->setDirty(_bDirty);
1925 }
1926 
1927 void TDEConfigGroup::putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup)
1928 {
1929  mMaster->putData(_key, _data, _checkGroup);
1930 }
1931 
1932 KEntry TDEConfigGroup::lookupData(const KEntryKey &_key) const
1933 {
1934  return mMaster->lookupData(_key);
1935 }
1936 
1937 void TDEConfigGroup::sync()
1938 {
1939  mMaster->sync();
1940 }
1941 
1942 void TDEConfigBase::virtual_hook( int, void* )
1943 { /*BASE::virtual_hook( id, data );*/ }
1944 
1945 void TDEConfigGroup::virtual_hook( int id, void* data )
1946 { TDEConfigBase::virtual_hook( id, data ); }
1947 
1948 bool TDEConfigBase::checkConfigFilesWritable(bool warnUser)
1949 {
1950  if (backEnd)
1951  return backEnd->checkConfigFilesWritable(warnUser);
1952  else
1953  return false;
1954 }
1955 
1956 #include "tdeconfigbase.moc"
TDEConfigBase::readPathEntry
TQString readPathEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads a path.
Definition: tdeconfigbase.cpp:607
TDEConfigBase::readLongNumEntry
long readLongNumEntry(const TQString &pKey, long nDefault=0) const
Reads a numerical value.
Definition: tdeconfigbase.cpp:675
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...
TDEConfigGroup::lookupData
virtual KEntry lookupData(const KEntryKey &_key) const
Looks up an entry in the config object&#39;s internal structure.
Definition: tdeconfigbase.cpp:1932
TDEConfigGroup::sync
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage...
Definition: tdeconfigbase.cpp:1937
TDEConfigBase::readUnsignedNumEntry
unsigned int readUnsignedNumEntry(const TQString &pKey, unsigned int nDefault=0) const
Reads an unsigned numerical value.
Definition: tdeconfigbase.cpp:656
TDEConfigBase::internalEntryMap
virtual KEntryMap internalEntryMap() const =0
Returns a map (tree) of the entries in the tree.
TDEConfigBase::readDoubleNumEntry
double readDoubleNumEntry(const TQString &pKey, double nDefault=0.0) const
Reads a floating point value.
Definition: tdeconfigbase.cpp:751
TDEConfigBase::readBoolEntry
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
Reads a boolean entry.
Definition: tdeconfigbase.cpp:770
TDEGlobalSettings::downloadPath
static TQString downloadPath()
The path where documents are stored of the current user.
Definition: tdeglobalsettings.h:260
KEntry::bDeleted
bool bDeleted
Entry has been deleted.
Definition: tdeconfigdata.h:57
TDEConfigBase::readColorEntry
TQColor readColorEntry(const TQString &pKey, const TQColor *pDefault=0L) const
Reads a TQColor entry.
Definition: tdeconfigbase.cpp:969
KEntry
map/dict/list config node entry.
Definition: tdeconfigdata.h:32
TDEConfigBase::~TDEConfigBase
virtual ~TDEConfigBase()
Destructs the TDEConfigBase object.
Definition: tdeconfigbase.cpp:57
TDEConfigBase::readIntListEntry
TQValueList< int > readIntListEntry(const TQString &pKey) const
Reads a list of Integers.
Definition: tdeconfigbase.cpp:589
TDEConfigBase::readRectEntry
TQRect readRectEntry(const TQString &pKey, const TQRect *pDefault=0L) const
Reads a TQRect entry.
Definition: tdeconfigbase.cpp:894
TDEConfigBase::setGroup
void setGroup(const TQString &group)
Specifies the group in which keys will be read and written.
Definition: tdeconfigbase.cpp:79
TDEConfigGroup::deleteGroup
void deleteGroup(bool bGlobal=false)
Delete all entries in the entire group.
Definition: tdeconfigbase.cpp:1912
TDEConfigBackEnd::getConfigState
virtual TDEConfigBase::ConfigState getConfigState() const
Returns the state of the app-config object.
Definition: tdeconfigbackend.h:113
TDEConfigBase::aLocaleString
TQCString aLocaleString
The locale to retrieve keys under if possible, i.e en_US or fr.
Definition: tdeconfigbase.h:2020
TDEConfigBase::setDesktopGroup
void setDesktopGroup()
Sets the group to the "Desktop Entry" group used for desktop configuration files for applications...
Definition: tdeconfigbase.cpp:104
KEntryKey::bDefault
bool bDefault
Entry indicates if this is a default value.
Definition: tdeconfigdata.h:90
TDELocale::language
TQString language() const
Returns the language used by this object.
Definition: tdelocale.cpp:553
TDEConfigBase::setDirty
virtual void setDirty(bool _bDirty=true)
Sets the global dirty flag of the config object.
Definition: tdeconfigbase.h:1922
TDEConfigBase::readFontEntry
TQFont readFontEntry(const TQString &pKey, const TQFont *pDefault=0L) const
Reads a TQFont value.
Definition: tdeconfigbase.cpp:797
TDELocale::defaultLanguage
static TQString defaultLanguage()
Returns the name of the internal language.
Definition: tdelocale.cpp:2265
TDEGlobalSettings::picturesPath
static TQString picturesPath()
The path where documents are stored of the current user.
Definition: tdeglobalsettings.h:272
TDEConfigBase::readUnsignedNum64Entry
TQ_UINT64 readUnsignedNum64Entry(const TQString &pKey, TQ_UINT64 nDefault=0) const
Read an 64-bit unsigned numerical value.
Definition: tdeconfigbase.cpp:732
TDEConfigBase::readDefaults
bool readDefaults() const
Definition: tdeconfigbase.cpp:1816
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
TDEConfigBase::readSizeEntry
TQSize readSizeEntry(const TQString &pKey, const TQSize *pDefault=0L) const
Reads a TQSize entry.
Definition: tdeconfigbase.cpp:943
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:1927
TDEConfigBase::setLocale
void setLocale()
Reads the locale and put in the configuration data struct.
Definition: tdeconfigbase.cpp:62
TDEConfigBase::readListEntry
int readListEntry(const TQString &pKey, TQStrList &list, char sep=',') const
Reads a list of strings.
Definition: tdeconfigbase.cpp:489
TDEConfigBase::checkConfigFilesWritable
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
Definition: tdeconfigbase.cpp:1948
TDEConfigBase::TDEConfigBase
TDEConfigBase()
Construct a TDEConfigBase object.
Definition: tdeconfigbase.cpp:50
TDEConfigBase::locale
TQString locale() const
Returns a the current locale.
Definition: tdeconfigbase.cpp:74
KEntry::bImmutable
bool bImmutable
Entry can not be modified.
Definition: tdeconfigdata.h:53
TDEConfigBase
KDE Configuration Management abstract base class.
Definition: tdeconfigbase.h:70
KEntryKey
key structure holding both the actual key and the the group to which it belongs.
Definition: tdeconfigdata.h:69
TDEConfigBackEnd::parseConfigFiles
virtual bool parseConfigFiles()=0
Parses all configuration files for a configuration object.
TDEGlobalSettings::videosPath
static TQString videosPath()
The path where documents are stored of the current user.
Definition: tdeglobalsettings.h:290
TDEConfigBase::rollback
virtual void rollback(bool bDeep=true)
Mark the config object as "clean," i.e.
Definition: tdeconfigbase.cpp:1799
tdelocale.h
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::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:1066
TDEGlobalSettings::desktopPath
static TQString desktopPath()
The path to the desktop directory of the current user.
Definition: tdeglobalsettings.h:248
TDEConfigBase::deleteGroup
bool deleteGroup(const TQString &group, bool bDeep=true, bool bGlobal=false)
Deletes a configuration entry group.
Definition: tdeconfigbase.cpp:1259
TDEConfigBase::parseConfigFiles
virtual void parseConfigFiles()
Parses all configuration files for a configuration object.
Definition: tdeconfigbase.cpp:1770
TDEGlobalSettings::templatesPath
static TQString templatesPath()
The path where templates are stored of the current user.
Definition: tdeglobalsettings.h:284
TDEConfigBase::readNum64Entry
TQ_INT64 readNum64Entry(const TQString &pKey, TQ_INT64 nDefault=0) const
Reads a 64-bit numerical value.
Definition: tdeconfigbase.cpp:712
KEntryKey::bLocal
bool bLocal
Entry is localised or not.
Definition: tdeconfigdata.h:86
TDEConfigGroup::setDirty
virtual void setDirty(bool _bDirty)
Sets the global dirty flag of the config object.
Definition: tdeconfigbase.cpp:1922
TDEConfigGroup::TDEConfigGroup
TDEConfigGroup(TDEConfigBase *master, const TQCString &group)
Construct a config group corresponding to group in master.
Definition: tdeconfigbase.cpp:1886
TDEConfigBase::readUnsignedLongNumEntry
unsigned long readUnsignedLongNumEntry(const TQString &pKey, unsigned long nDefault=0) const
Read an unsigned numerical value.
Definition: tdeconfigbase.cpp:694
TDEGlobalSettings::publicSharePath
static TQString publicSharePath()
The path of the public share of the current user.
Definition: tdeglobalsettings.h:278
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::ConfigState
ConfigState
Possible return values for getConfigState().
Definition: tdeconfigbase.h:1828
TDEGlobal::staticQString
static const TQString & staticQString(const char *str)
Creates a static TQString.
Definition: tdeglobal.cpp:148
TDEConfigBase::readPathListEntry
TQStringList readPathListEntry(const TQString &pKey, char sep=',') const
Reads a list of string paths.
Definition: tdeconfigbase.cpp:621
TDEConfigBase::hasKey
bool hasKey(const TQString &key) const
Checks whether the key has an entry in the currently active group.
Definition: tdeconfigbase.cpp:109
TDEConfigBackEnd::setLocaleString
void setLocaleString(const TQCString &_localeString)
Set the locale string that defines the current language.
Definition: tdeconfigbackend.h:133
TDEConfigBackEnd::sync
virtual void sync(bool bMerge=true)=0
Writes configuration data to file(s).
KEntry::bGlobal
bool bGlobal
Entry should be written to the global config file.
Definition: tdeconfigdata.h:49
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:1115
TDEGlobal::locale
static TDELocale * locale()
Returns the global locale object.
Definition: tdeglobal.cpp:108
TDEConfigBase::hasGroup
bool hasGroup(const TQString &group) const
Returns true if the specified group is known about.
Definition: tdeconfigbase.cpp:152
TDEConfigBase::readDateTimeEntry
TQDateTime readDateTimeEntry(const TQString &pKey, const TQDateTime *pDefault=0L) const
Reads a TQDateTime entry.
Definition: tdeconfigbase.cpp:1034
TDEConfigBackEnd::checkConfigFilesWritable
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
Definition: tdeconfigbackend.cpp:1155
KEntry::bNLS
bool bNLS
Entry should be written with locale tag.
Definition: tdeconfigdata.h:45
TDEConfigBase::isReadOnly
bool isReadOnly() const
Returns the read-only status of the config object.
Definition: tdeconfigbase.h:1762
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:1848
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::readPointEntry
TQPoint readPointEntry(const TQString &pKey, const TQPoint *pDefault=0L) const
Reads a TQPoint entry.
Definition: tdeconfigbase.cpp:918
TDEConfigBase::getConfigState
ConfigState getConfigState() const
Returns the state of the app-config object.
Definition: tdeconfigbase.cpp:1793
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:1226
TDEConfigBase::lookupData
virtual KEntry lookupData(const KEntryKey &_key) const =0
Looks up an entry in the config object&#39;s internal structure.
TDEConfigBase::isImmutable
bool isImmutable() const
Checks whether this configuration file can be modified.
Definition: tdeconfigbase.cpp:167
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::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:1821
TDEGlobalSettings::musicPath
static TQString musicPath()
The path where documents are stored of the current user.
Definition: tdeglobalsettings.h:266
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:1805
TDEConfigBase::readNumEntry
int readNumEntry(const TQString &pKey, int nDefault=0) const
Reads a numerical value.
Definition: tdeconfigbase.cpp:635
TDEConfigBase::mGroup
TQCString mGroup
The currently selected group.
Definition: tdeconfigbase.h:2016
KEntry::bExpand
bool bExpand
Whether to apply dollar expansion or not.
Definition: tdeconfigdata.h:61
TDEGlobalSettings::documentPath
static TQString documentPath()
The path where documents are stored of the current user.
Definition: tdeglobalsettings.h:254
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
TDEConfigGroup::groupIsImmutable
bool groupIsImmutable() const
Checks whether it is possible to change this group.
Definition: tdeconfigbase.cpp:1917
KEntry::bDirty
bool bDirty
Must the entry be written back to disk?
Definition: tdeconfigdata.h:41
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::sync
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage...
Definition: tdeconfigbase.cpp:1782

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.8.13
This website is maintained by Timothy Pearson.