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

tdecore

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

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.