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

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.8.8
This website is maintained by Timothy Pearson.