27 #include <tqtextstream.h> 29 #include <tdeapplication.h> 30 #include <tdeglobalsettings.h> 31 #include <tdeglobal.h> 33 #include <kcharsets.h> 35 #include "tdeconfigbase.h" 36 #include "tdeconfigbackend.h" 38 #include "kstandarddirs.h" 39 #include "kstringhandler.h" 41 class TDEConfigBase::TDEConfigBasePrivate
52 bReadOnly(false), bExpand(false), d(0)
64 bLocaleInitialized =
true;
81 if ( group.isEmpty() )
94 if ( group.isEmpty() )
101 return TQString::fromUtf8(
mGroup);
111 return hasKey(key.utf8().data());
117 aEntryKey.c_key = pKey;
124 if (!entry.mValue.isNull())
131 return !entry.mValue.isNull();
134 bool TDEConfigBase::hasTranslatedKey(
const char* pKey)
const 137 aEntryKey.c_key = pKey;
144 if (!entry.mValue.isNull())
154 return internalHasGroup( group.utf8());
159 return internalHasGroup( TQCString(_pGroup));
164 return internalHasGroup( _pGroup);
179 return entry.bImmutable;
192 TQCString utf8_key = key.utf8();
193 entryKey.c_key = utf8_key.data();
205 const TQString& aDefault )
const 212 const TQString& aDefault )
const 214 TQCString result = readEntryUtf8(pKey);
217 return TQString::fromUtf8(result);
222 const TQString& aDefault )
const 228 const TQString& aDefault )
const 234 if (!bLocaleInitialized && TDEGlobal::_locale) {
247 entryKey.c_key = pKey;
251 if (!aEntryData.mValue.isNull()) {
258 if (!aEntryData.mValue.isNull()) {
259 aValue = TQString::fromUtf8(aEntryData.mValue.data());
263 aValue = emptyString;
272 if( expand || bExpand )
275 int nDollarPos = aValue.find(
'$' );
277 while( nDollarPos != -1 && (nDollarPos + 1) < static_cast<int>(aValue.length())) {
279 if( aValue[nDollarPos+1] !=
'$' ) {
280 uint nEndPos = nDollarPos+1;
283 if (aValue[nEndPos]==
'{')
285 while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!=
'}') )
288 aVarName = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 );
292 while ( nEndPos <= aValue.length() && (aValue[nEndPos].isNumber()
293 || aValue[nEndPos].isLetter() || aValue[nEndPos]==
'_' ) )
295 aVarName = aValue.mid( nDollarPos+1, nEndPos-nDollarPos-1 );
297 const char *pEnv = 0;
298 if (!aVarName.isEmpty())
299 pEnv = getenv( aVarName.ascii() );
306 else if (aVarName.length() > 8 && aVarName.startsWith(
"XDG_") && aVarName.endsWith(
"_DIR")) {
308 if (aVarName ==
"XDG_DESKTOP_DIR") {
311 else if (aVarName ==
"XDG_DOCUMENTS_DIR") {
314 else if (aVarName ==
"XDG_DOWNLOAD_DIR") {
317 else if (aVarName ==
"XDG_MUSIC_DIR") {
320 else if (aVarName ==
"XDG_PICTURES_DIR") {
323 else if (aVarName ==
"XDG_PUBLICSHARE_DIR") {
326 else if (aVarName ==
"XDG_TEMPLATES_DIR") {
329 else if (aVarName ==
"XDG_VIDEOS_DIR") {
332 aValue.replace( nDollarPos, nEndPos-nDollarPos, result );
335 aValue.remove( nDollarPos, nEndPos-nDollarPos );
340 aValue.remove( nDollarPos, 1 );
343 nDollarPos = aValue.find(
'$', nDollarPos );
350 TQCString TDEConfigBase::readEntryUtf8(
const char *pKey)
const 355 entryKey.c_key = pKey;
360 return readEntry(pKey, TQString::null).utf8();
362 return aEntryData.mValue;
366 TQVariant::Type type )
const 372 TQVariant::Type type )
const 375 if ( !
hasKey( pKey ) )
return va;
381 const TQVariant &aDefault )
const 387 const TQVariant &aDefault )
const 389 if ( !
hasKey( pKey ) )
return aDefault;
391 TQVariant tmp = aDefault;
393 switch( aDefault.type() )
395 case TQVariant::Invalid:
397 case TQVariant::String:
398 return TQVariant(
readEntry( pKey, aDefault.toString() ) );
399 case TQVariant::StringList:
401 case TQVariant::List: {
403 TQStringList::ConstIterator it = strList.begin();
404 TQStringList::ConstIterator end = strList.end();
405 TQValueList<TQVariant> list;
407 for (; it != end; ++it ) {
411 return TQVariant( list );
413 case TQVariant::Font:
415 case TQVariant::Point:
417 case TQVariant::Rect:
419 case TQVariant::Size:
421 case TQVariant::Color:
424 return TQVariant(
readNumEntry( pKey, aDefault.toInt() ) );
425 case TQVariant::UInt:
427 case TQVariant::LongLong:
428 return TQVariant(
readNum64Entry( pKey, aDefault.toLongLong() ) );
429 case TQVariant::ULongLong:
431 case TQVariant::Bool:
432 return TQVariant(
readBoolEntry( pKey, aDefault.toBool() ) );
433 case TQVariant::Double:
435 case TQVariant::DateTime:
437 case TQVariant::Date:
440 case TQVariant::Pixmap:
441 case TQVariant::Image:
442 case TQVariant::Brush:
443 case TQVariant::Palette:
444 case TQVariant::ColorGroup:
446 case TQVariant::IconSet:
447 case TQVariant::CString:
448 case TQVariant::PointArray:
449 case TQVariant::Region:
450 case TQVariant::Bitmap:
451 case TQVariant::Cursor:
452 case TQVariant::SizePolicy:
453 case TQVariant::Time:
454 case TQVariant::ByteArray:
455 case TQVariant::BitArray:
456 case TQVariant::KeySequence:
468 TQStrList &list,
char sep )
const 474 TQStrList &list,
char sep )
const 479 TQCString str_list = readEntryUtf8( pKey );
480 if (str_list.isEmpty())
484 TQCString value =
"";
485 int len = str_list.length();
487 for (
int i = 0; i < len; i++) {
488 if (str_list[i] != sep && str_list[i] !=
'\\') {
489 value += str_list[i];
492 if (str_list[i] ==
'\\') {
495 value += str_list[i];
503 list.append( value );
507 if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] ==
'\\' ) )
508 list.append( value );
525 if( str_list.isEmpty() )
527 TQString value(emptyString);
528 int len = str_list.length();
530 value.reserve( len );
531 for(
int i = 0; i < len; i++ )
533 if( str_list[i] != sep && str_list[i] !=
'\\' )
535 value += str_list[i];
538 if( str_list[i] ==
'\\' )
542 value += str_list[i];
545 TQString finalvalue( value );
546 finalvalue.squeeze();
547 list.append( finalvalue );
550 if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] ==
'\\' ) )
553 list.append( value );
575 TQValueList<int> list;
576 TQStringList::ConstIterator end(strlist.end());
577 for (TQStringList::ConstIterator it = strlist.begin(); it != end; ++it)
580 list << (*it).toInt();
592 const bool bExpandSave = bExpand;
594 TQString aValue =
readEntry( pKey, pDefault );
595 bExpand = bExpandSave;
606 const bool bExpandSave = bExpand;
609 bExpand = bExpandSave;
620 TQCString aValue = readEntryUtf8( pKey );
621 if( aValue.isNull() )
623 else if( aValue ==
"true" || aValue ==
"on" || aValue ==
"yes" )
628 int rc = aValue.toInt( &ok );
629 return( ok ? rc : nDefault );
641 TQCString aValue = readEntryUtf8( pKey );
642 if( aValue.isNull() )
647 unsigned int rc = aValue.toUInt( &ok );
648 return( ok ? rc : nDefault );
660 TQCString aValue = readEntryUtf8( pKey );
661 if( aValue.isNull() )
666 long rc = aValue.toLong( &ok );
667 return( ok ? rc : nDefault );
679 TQCString aValue = readEntryUtf8( pKey );
680 if( aValue.isNull() )
685 unsigned long rc = aValue.toULong( &ok );
686 return( ok ? rc : nDefault );
699 if( aValue.isNull() )
704 TQ_INT64 rc = aValue.toLongLong( &ok );
705 return( ok ? rc : nDefault );
719 if( aValue.isNull() )
724 TQ_UINT64 rc = aValue.toULongLong( &ok );
725 return( ok ? rc : nDefault );
736 TQCString aValue = readEntryUtf8( pKey );
737 if( aValue.isNull() )
742 double rc = aValue.toDouble( &ok );
743 return( ok ? rc : nDefault );
755 TQCString aValue = readEntryUtf8( pKey );
757 if( aValue.isNull() )
761 if( aValue ==
"true" || aValue ==
"on" || aValue ==
"yes" || aValue ==
"1" )
766 int val = aValue.toInt( &bOK );
767 if( bOK && val != 0 )
785 if( !aValue.isNull() ) {
786 if ( aValue.contains(
',' ) > 5 ) {
788 if ( !aRetFont.fromString( aValue ) && pDefault )
789 aRetFont = *pDefault;
795 int nIndex = aValue.find(
',' );
798 aRetFont = *pDefault;
801 aRetFont.setFamily( aValue.left( nIndex ) );
804 int nOldIndex = nIndex;
805 nIndex = aValue.find(
',', nOldIndex+1 );
808 aRetFont = *pDefault;
812 aRetFont.setPointSize( aValue.mid( nOldIndex+1,
813 nIndex-nOldIndex-1 ).toInt() );
817 nIndex = aValue.find(
',', nOldIndex+1 );
821 aRetFont = *pDefault;
825 aRetFont.setStyleHint( (TQFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() );
829 nIndex = aValue.find(
',', nOldIndex+1 );
833 aRetFont = *pDefault;
837 TQString chStr=aValue.mid( nOldIndex+1,
838 nIndex-nOldIndex-1 );
841 nIndex = aValue.find(
',', nOldIndex+1 );
845 aRetFont = *pDefault;
849 aRetFont.setWeight( aValue.mid( nOldIndex+1,
850 nIndex-nOldIndex-1 ).toUInt() );
853 uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt();
855 aRetFont.setItalic( nFontBits & 0x01 );
856 aRetFont.setUnderline( nFontBits & 0x02 );
857 aRetFont.setStrikeOut( nFontBits & 0x04 );
858 aRetFont.setFixedPitch( nFontBits & 0x08 );
859 aRetFont.setRawMode( nFontBits & 0x20 );
865 aRetFont = *pDefault;
879 TQCString aValue = readEntryUtf8(pKey);
881 if (!aValue.isEmpty())
883 int left, top, width, height;
885 if (sscanf(aValue.data(),
"%d,%d,%d,%d", &left, &top, &width, &height) == 4)
887 return TQRect(left, top, width, height);
897 const TQPoint* pDefault )
const 903 const TQPoint* pDefault )
const 905 TQCString aValue = readEntryUtf8(pKey);
907 if (!aValue.isEmpty())
911 if (sscanf(aValue.data(),
"%d,%d", &x, &y) == 2)
922 const TQSize* pDefault )
const 928 const TQSize* pDefault )
const 930 TQCString aValue = readEntryUtf8(pKey);
932 if (!aValue.isEmpty())
936 if (sscanf(aValue.data(),
"%d,%d", &width, &height) == 2)
938 return TQSize(width, height);
948 const TQColor* pDefault )
const 954 const TQColor* pDefault )
const 957 int nRed = 0, nGreen = 0, nBlue = 0;
960 if( !aValue.isEmpty() )
962 if ( aValue.at(0) == (TQChar)
'#' )
964 aRetColor.setNamedColor(aValue);
972 int nIndex = aValue.find(
',' );
977 aRetColor = *pDefault;
981 nRed = aValue.left( nIndex ).toInt( &bOK );
984 int nOldIndex = nIndex;
985 nIndex = aValue.find(
',', nOldIndex+1 );
990 aRetColor = *pDefault;
993 nGreen = aValue.mid( nOldIndex+1,
994 nIndex-nOldIndex-1 ).toInt( &bOK );
997 nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK );
999 aRetColor.setRgb( nRed, nGreen, nBlue );
1005 aRetColor = *pDefault;
1013 const TQDateTime* pDefault )
const 1020 const TQDateTime* pDefault )
const 1027 return TQDateTime::currentDateTime();
1033 TQDate date( atoi( list.at( 0 ) ), atoi( list.at( 1 ) ),
1034 atoi( list.at( 2 ) ) );
1035 TQTime time( atoi( list.at( 3 ) ), atoi( list.at( 4 ) ),
1036 atoi( list.at( 5 ) ) );
1038 return TQDateTime( date, time );
1041 return TQDateTime::currentDateTime();
1049 writeEntry(pKey.utf8().data(), value, bPersistent, bGlobal, bNLS);
1057 writeEntry(pKey, value, bPersistent, bGlobal, bNLS,
false);
1081 aEntryData.mValue = value.utf8();
1083 aEntryData.
bNLS = bNLS;
1087 aEntryData.
bDirty =
true;
1090 putData(entryKey, aEntryData,
true);
1094 bool bPersistent,
bool bGlobal,
1097 writePathEntry(pKey.utf8().data(), path, bPersistent, bGlobal, bNLS);
1101 static bool cleanHomeDirPath( TQString &path,
const TQString &homeDir )
1103 #ifdef TQ_WS_WIN //safer 1104 if (!TQDir::convertSeparators(path).startsWith(TQDir::convertSeparators(homeDir)))
1107 if (!path.startsWith(homeDir))
1111 unsigned int len = homeDir.length();
1113 if (len && (path.length() == len || path[len] ==
'/')) {
1114 path.replace(0, len, TQString::fromLatin1(
"$HOME"));
1120 static TQString translatePath( TQString path )
1126 path.replace(
'$',
"$$");
1128 bool startsWithFile = path.startsWith(
"file:",
false);
1132 if (((!startsWithFile) && (path[0] !=
'/')) || (startsWithFile && (path[5] !=
'/'))) {
1136 if (startsWithFile) {
1141 while (path[0] ==
'/' && path[1] ==
'/') {
1149 TQString homeDir0 = TQFile::decodeName(getenv(
"HOME"));
1150 TQString homeDir1 = TQDir::homeDirPath();
1151 TQString homeDir2 = TQDir(homeDir1).canonicalPath();
1152 if (cleanHomeDirPath(path, homeDir0) ||
1153 cleanHomeDirPath(path, homeDir1) ||
1154 cleanHomeDirPath(path, homeDir2) ) {
1159 path.prepend(
"file://" );
1165 bool bPersistent,
bool bGlobal,
1168 writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS,
true);
1172 bool bPersistent,
bool bGlobal,
1173 bool bNLS,
bool expand)
1175 writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS, expand);
1179 char sep ,
bool bPersistent,
1180 bool bGlobal,
bool bNLS )
1182 writePathEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1186 char sep ,
bool bPersistent,
1187 bool bGlobal,
bool bNLS )
1189 if( list.isEmpty() )
1191 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1194 TQStringList new_list;
1195 TQStringList::ConstIterator it = list.begin();
1196 for( ; it != list.end(); ++it )
1198 TQString value = *it;
1199 new_list.append( translatePath(value) );
1201 writeEntry( pKey, new_list, sep, bPersistent, bGlobal, bNLS,
true );
1229 aEntryData.
bNLS = bNLS;
1230 aEntryData.
bDirty =
true;
1234 putData(entryKey, aEntryData,
true);
1243 return aEntryMap.isEmpty();
1247 bool checkGroup =
true;
1249 KEntryMapIterator aIt;
1250 for (aIt = aEntryMap.begin(); aIt != aEntryMap.end(); ++aIt)
1252 if (!aIt.key().mKey.isEmpty() && !aIt.key().bDefault && !(*aIt).bDeleted)
1254 (*aIt).bDeleted =
true;
1255 (*aIt).bDirty =
true;
1256 (*aIt).bGlobal = bGlobal;
1258 putData(aIt.key(), *aIt, checkGroup);
1270 bool bGlobal,
bool bNLS )
1272 writeEntry(pKey.utf8().data(), prop, bPersistent, bGlobal, bNLS);
1277 bool bGlobal,
bool bNLS )
1279 switch( prop.type() )
1281 case TQVariant::Invalid:
1282 writeEntry( pKey,
"", bPersistent, bGlobal, bNLS );
1284 case TQVariant::String:
1285 writeEntry( pKey, prop.toString(), bPersistent, bGlobal, bNLS );
1287 case TQVariant::StringList:
1288 writeEntry( pKey, prop.toStringList(),
',', bPersistent, bGlobal, bNLS );
1290 case TQVariant::List: {
1291 TQValueList<TQVariant> list = prop.toList();
1292 TQValueList<TQVariant>::ConstIterator it = list.begin();
1293 TQValueList<TQVariant>::ConstIterator end = list.end();
1294 TQStringList strList;
1296 for (; it != end; ++it )
1297 strList.append( (*it).toString() );
1299 writeEntry( pKey, strList,
',', bPersistent, bGlobal, bNLS );
1303 case TQVariant::Font:
1304 writeEntry( pKey, prop.toFont(), bPersistent, bGlobal, bNLS );
1306 case TQVariant::Point:
1307 writeEntry( pKey, prop.toPoint(), bPersistent, bGlobal, bNLS );
1309 case TQVariant::Rect:
1310 writeEntry( pKey, prop.toRect(), bPersistent, bGlobal, bNLS );
1312 case TQVariant::Size:
1313 writeEntry( pKey, prop.toSize(), bPersistent, bGlobal, bNLS );
1315 case TQVariant::Color:
1316 writeEntry( pKey, prop.toColor(), bPersistent, bGlobal, bNLS );
1318 case TQVariant::Int:
1319 writeEntry( pKey, prop.toInt(), bPersistent, bGlobal, bNLS );
1321 case TQVariant::UInt:
1322 writeEntry( pKey, prop.toUInt(), bPersistent, bGlobal, bNLS );
1324 case TQVariant::LongLong:
1325 writeEntry( pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS );
1327 case TQVariant::ULongLong:
1328 writeEntry( pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS );
1330 case TQVariant::Bool:
1331 writeEntry( pKey, prop.toBool(), bPersistent, bGlobal, bNLS );
1333 case TQVariant::Double:
1334 writeEntry( pKey, prop.toDouble(), bPersistent, bGlobal,
'g', 6, bNLS );
1336 case TQVariant::DateTime:
1337 writeEntry( pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS);
1339 case TQVariant::Date:
1340 writeEntry( pKey, TQDateTime(prop.toDate()), bPersistent, bGlobal, bNLS);
1343 case TQVariant::Pixmap:
1344 case TQVariant::Image:
1345 case TQVariant::Brush:
1346 case TQVariant::Palette:
1347 case TQVariant::ColorGroup:
1348 case TQVariant::Map:
1349 case TQVariant::IconSet:
1350 case TQVariant::CString:
1351 case TQVariant::PointArray:
1352 case TQVariant::Region:
1353 case TQVariant::Bitmap:
1354 case TQVariant::Cursor:
1355 case TQVariant::SizePolicy:
1356 case TQVariant::Time:
1357 case TQVariant::ByteArray:
1358 case TQVariant::BitArray:
1359 case TQVariant::KeySequence:
1360 case TQVariant::Pen:
1370 char sep ,
bool bPersistent,
1371 bool bGlobal,
bool bNLS )
1373 writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1377 char sep ,
bool bPersistent,
1378 bool bGlobal,
bool bNLS )
1380 if( list.isEmpty() )
1382 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1386 TQStrListIterator it( list );
1387 for( ; it.current(); ++it )
1395 uint strLengh(value.length());
1396 for( i = 0; i < strLengh; i++ )
1398 if( value[i] == sep || value[i] ==
'\\' )
1400 str_list += value[i];
1404 if( str_list.at(str_list.length() - 1) == (TQChar)sep )
1405 str_list.truncate( str_list.length() -1 );
1406 writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS );
1410 char sep ,
bool bPersistent,
1411 bool bGlobal,
bool bNLS )
1413 writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1417 char sep ,
bool bPersistent,
1418 bool bGlobal,
bool bNLS )
1420 writeEntry(pKey, list, sep, bPersistent, bGlobal, bNLS,
false);
1424 char sep,
bool bPersistent,
1425 bool bGlobal,
bool bNLS,
bool bExpand )
1427 if( list.isEmpty() )
1429 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1433 str_list.reserve( 4096 );
1434 TQStringList::ConstIterator it = list.begin();
1435 for( ; it != list.end(); ++it )
1437 TQString value = *it;
1439 uint strLength(value.length());
1440 for( i = 0; i < strLength; i++ )
1442 if( value[i] == sep || value[i] ==
'\\' )
1444 str_list += value[i];
1448 if( str_list.at(str_list.length() - 1) == (TQChar)sep )
1449 str_list.truncate( str_list.length() -1 );
1450 writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS, bExpand );
1454 bool bPersistent,
bool bGlobal,
bool bNLS )
1456 writeEntry(pKey.utf8().data(), list, bPersistent, bGlobal, bNLS);
1460 bool bPersistent,
bool bGlobal,
bool bNLS )
1462 TQStringList strlist;
1463 TQValueList<int>::ConstIterator end = list.end();
1464 for (TQValueList<int>::ConstIterator it = list.begin(); it != end; it++)
1465 strlist << TQString::number(*it);
1466 writeEntry(pKey, strlist,
',', bPersistent, bGlobal, bNLS );
1470 bool bPersistent,
bool bGlobal,
1473 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1477 bool bPersistent,
bool bGlobal,
1480 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1485 bool bPersistent,
bool bGlobal,
1488 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1492 bool bPersistent,
bool bGlobal,
1495 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1500 bool bPersistent,
bool bGlobal,
1503 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1507 bool bPersistent,
bool bGlobal,
1510 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1515 bool bPersistent,
bool bGlobal,
1518 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1522 bool bPersistent,
bool bGlobal,
1525 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1529 bool bPersistent,
bool bGlobal,
1532 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1536 bool bPersistent,
bool bGlobal,
1539 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1544 bool bPersistent,
bool bGlobal,
1547 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1551 bool bPersistent,
bool bGlobal,
1554 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1558 bool bPersistent,
bool bGlobal,
1559 char format,
int precision,
1562 writeEntry( pKey, TQString::number(nValue, format, precision),
1563 bPersistent, bGlobal, bNLS );
1567 bool bPersistent,
bool bGlobal,
1568 char format,
int precision,
1571 writeEntry( pKey, TQString::number(nValue, format, precision),
1572 bPersistent, bGlobal, bNLS );
1581 writeEntry(pKey.utf8().data(), bValue, bPersistent, bGlobal, bNLS);
1596 writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1601 bool bPersistent,
bool bGlobal,
1604 writeEntry(pKey.utf8().data(), rFont, bPersistent, bGlobal, bNLS);
1608 bool bPersistent,
bool bGlobal,
1611 writeEntry( pKey, TQString(rFont.toString()), bPersistent, bGlobal, bNLS );
1616 bool bPersistent,
bool bGlobal,
1619 writeEntry(pKey.utf8().data(), rRect, bPersistent, bGlobal, bNLS);
1623 bool bPersistent,
bool bGlobal,
1628 list.insert( 0, tempstr.setNum( rRect.left() ) );
1629 list.insert( 1, tempstr.setNum( rRect.top() ) );
1630 list.insert( 2, tempstr.setNum( rRect.width() ) );
1631 list.insert( 3, tempstr.setNum( rRect.height() ) );
1633 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1638 bool bPersistent,
bool bGlobal,
1641 writeEntry(pKey.utf8().data(), rPoint, bPersistent, bGlobal, bNLS);
1645 bool bPersistent,
bool bGlobal,
1650 list.insert( 0, tempstr.setNum( rPoint.x() ) );
1651 list.insert( 1, tempstr.setNum( rPoint.y() ) );
1653 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1658 bool bPersistent,
bool bGlobal,
1661 writeEntry(pKey.utf8().data(), rSize, bPersistent, bGlobal, bNLS);
1665 bool bPersistent,
bool bGlobal,
1670 list.insert( 0, tempstr.setNum( rSize.width() ) );
1671 list.insert( 1, tempstr.setNum( rSize.height() ) );
1673 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1681 writeEntry( pKey.utf8().data(), rColor, bPersistent, bGlobal, bNLS);
1690 if (rColor.isValid())
1691 aValue.sprintf(
"%d,%d,%d", rColor.red(), rColor.green(), rColor.blue() );
1695 writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1699 bool bPersistent,
bool bGlobal,
1702 writeEntry(pKey.utf8().data(), rDateTime, bPersistent, bGlobal, bNLS);
1706 bool bPersistent,
bool bGlobal,
1712 TQTime time = rDateTime.time();
1713 TQDate date = rDateTime.date();
1715 list.insert( 0, tempstr.setNum( date.year() ) );
1716 list.insert( 1, tempstr.setNum( date.month() ) );
1717 list.insert( 2, tempstr.setNum( date.day() ) );
1719 list.insert( 3, tempstr.setNum( time.hour() ) );
1720 list.insert( 4, tempstr.setNum( time.minute() ) );
1721 list.insert( 5, tempstr.setNum( time.second() ) );
1723 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1728 if (!bLocaleInitialized && TDEGlobal::_locale) {
1766 d =
new TDEConfigBasePrivate();
1769 d->readDefaults = b;
1774 return (d && d->readDefaults);
1784 if (!
locale().isNull()) {
1786 aEntryKey.bLocal =
true;
1788 if (entry.mValue.isNull())
1792 putData(aEntryKey, entry,
true);
1793 aEntryKey.bLocal =
false;
1798 if (entry.mValue.isNull())
1801 putData(aEntryKey, entry,
true);
1809 if (!
locale().isNull()) {
1811 aEntryKey.bLocal =
true;
1813 if (!entry.mValue.isNull())
1816 aEntryKey.bLocal =
false;
1821 if (!entry.mValue.isNull())
1833 bLocaleInitialized =
true;
1834 bReadOnly = mMaster->bReadOnly;
1846 bLocaleInitialized =
true;
1847 bReadOnly = mMaster->bReadOnly;
1859 bLocaleInitialized =
true;
1860 bReadOnly = mMaster->bReadOnly;
1880 mMaster->setDirty(_bDirty);
1885 mMaster->putData(_key, _data, _checkGroup);
1890 return mMaster->lookupData(_key);
1898 void TDEConfigBase::virtual_hook(
int,
void* )
1901 void TDEConfigGroup::virtual_hook(
int id,
void* data )
1902 { TDEConfigBase::virtual_hook(
id, data ); }
1912 #include "tdeconfigbase.moc" TQString readPathEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads a path.
long readLongNumEntry(const TQString &pKey, long nDefault=0) const
Reads a numerical value.
bool groupIsImmutable(const TQString &group) const
Checks whether it is possible to change the given group.
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...
virtual KEntry lookupData(const KEntryKey &_key) const
Looks up an entry in the config object's internal structure.
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage...
unsigned int readUnsignedNumEntry(const TQString &pKey, unsigned int nDefault=0) const
Reads an unsigned numerical value.
virtual KEntryMap internalEntryMap() const =0
Returns a map (tree) of the entries in the tree.
double readDoubleNumEntry(const TQString &pKey, double nDefault=0.0) const
Reads a floating point value.
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
Reads a boolean entry.
static TQString downloadPath()
The path where documents are stored of the current user.
bool bDeleted
Entry has been deleted.
TQColor readColorEntry(const TQString &pKey, const TQColor *pDefault=0L) const
Reads a TQColor entry.
map/dict/list config node entry.
virtual ~TDEConfigBase()
Destructs the TDEConfigBase object.
TQValueList< int > readIntListEntry(const TQString &pKey) const
Reads a list of Integers.
TQRect readRectEntry(const TQString &pKey, const TQRect *pDefault=0L) const
Reads a TQRect entry.
void setGroup(const TQString &group)
Specifies the group in which keys will be read and written.
void deleteGroup(bool bGlobal=false)
Delete all entries in the entire group.
virtual TDEConfigBase::ConfigState getConfigState() const
Returns the state of the app-config object.
TQCString aLocaleString
The locale to retrieve keys under if possible, i.e en_US or fr.
void setDesktopGroup()
Sets the group to the "Desktop Entry" group used for desktop configuration files for applications...
bool bDefault
Entry indicates if this is a default value.
TQString language() const
Returns the language used by this object.
virtual void setDirty(bool _bDirty=true)
Sets the global dirty flag of the config object.
TQFont readFontEntry(const TQString &pKey, const TQFont *pDefault=0L) const
Reads a TQFont value.
static TQString defaultLanguage()
Returns the name of the internal language.
static TQString picturesPath()
The path where documents are stored of the current user.
TQ_UINT64 readUnsignedNum64Entry(const TQString &pKey, TQ_UINT64 nDefault=0) const
Read an 64-bit unsigned numerical value.
bool readDefaults() const
static TQString from8Bit(const char *str)
Construct TQString from a c string, guessing whether it is UTF8- or Local8Bit-encoded.
TQSize readSizeEntry(const TQString &pKey, const TQSize *pDefault=0L) const
Reads a TQSize entry.
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...
void setLocale()
Reads the locale and put in the configuration data struct.
int readListEntry(const TQString &pKey, TQStrList &list, char sep=',') const
Reads a list of strings.
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
TDEConfigBase()
Construct a TDEConfigBase object.
TQString locale() const
Returns a the current locale.
bool bImmutable
Entry can not be modified.
KDE Configuration Management abstract base class.
key structure holding both the actual key and the the group to which it belongs.
virtual bool parseConfigFiles()=0
Parses all configuration files for a configuration object.
static TQString videosPath()
The path where documents are stored of the current user.
virtual void rollback(bool bDeep=true)
Mark the config object as "clean," i.e.
TQVariant readPropertyEntry(const TQString &pKey, TQVariant::Type) const
Reads the value of an entry specified by pKey in the current group.
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a key/value pair.
static TQString desktopPath()
The path to the desktop directory of the current user.
bool deleteGroup(const TQString &group, bool bDeep=true, bool bGlobal=false)
Deletes a configuration entry group.
virtual void parseConfigFiles()
Parses all configuration files for a configuration object.
static TQString templatesPath()
The path where templates are stored of the current user.
TQ_INT64 readNum64Entry(const TQString &pKey, TQ_INT64 nDefault=0) const
Reads a 64-bit numerical value.
bool bLocal
Entry is localised or not.
virtual void setDirty(bool _bDirty)
Sets the global dirty flag of the config object.
TDEConfigGroup(TDEConfigBase *master, const TQCString &group)
Construct a config group corresponding to group in master.
unsigned long readUnsignedLongNumEntry(const TQString &pKey, unsigned long nDefault=0) const
Read an unsigned numerical value.
static TQString publicSharePath()
The path of the public share of the current user.
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
ConfigState
Possible return values for getConfigState().
static const TQString & staticQString(const char *str)
Creates a static TQString.
TQStringList readPathListEntry(const TQString &pKey, char sep=',') const
Reads a list of string paths.
bool hasKey(const TQString &key) const
Checks whether the key has an entry in the currently active group.
void setLocaleString(const TQCString &_localeString)
Set the locale string that defines the current language.
virtual void sync(bool bMerge=true)=0
Writes configuration data to file(s).
bool bGlobal
Entry should be written to the global config file.
void writePathEntry(const TQString &pKey, const TQString &path, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a file path.
static TDELocale * locale()
Returns the global locale object.
bool hasGroup(const TQString &group) const
Returns true if the specified group is known about.
TQDateTime readDateTimeEntry(const TQString &pKey, const TQDateTime *pDefault=0L) const
Reads a TQDateTime entry.
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
bool bNLS
Entry should be written with locale tag.
bool isReadOnly() const
Returns the read-only status of the config object.
bool hasDefault(const TQString &key) const
Returns whether a default is specified for an entry in either the system wide configuration file or t...
bool entryIsImmutable(const TQString &key) const
Checks whether it is possible to change the given entry.
TDEConfigBackEnd * backEnd
A back end for loading/saving to disk in a particular format.
TQPoint readPointEntry(const TQString &pKey, const TQPoint *pDefault=0L) const
Reads a TQPoint entry.
ConfigState getConfigState() const
Returns the state of the app-config object.
void deleteEntry(const TQString &pKey, bool bNLS=false, bool bGlobal=false)
Deletes the entry specified by pKey in the current group.
virtual KEntry lookupData(const KEntryKey &_key) const =0
Looks up an entry in the config object's internal structure.
bool isImmutable() const
Checks whether this configuration file can be modified.
TQString group() const
Returns the name of the group in which we are searching for keys and from which we are retrieving ent...
void revertToDefault(const TQString &key)
Reverts the entry with key key in the current group in the application specific config file to either...
static TQString musicPath()
The path where documents are stored of the current user.
void setReadDefaults(bool b)
When set, all readEntry and readXXXEntry calls return the system wide (default) values instead of the...
int readNumEntry(const TQString &pKey, int nDefault=0) const
Reads a numerical value.
TQCString mGroup
The currently selected group.
bool bExpand
Whether to apply dollar expansion or not.
static TQString documentPath()
The path where documents are stored of the current user.
bool bDirty
Indicates whether there are any dirty entries in the config object that need to be written back to di...
bool groupIsImmutable() const
Checks whether it is possible to change this group.
bool bDirty
Must the entry be written back to disk?
TQString readEntryUntranslated(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage...