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

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.