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() ), 0 );
433 case TQVariant::Double:
435 case TQVariant::DateTime:
437 case TQVariant::Date:
438 return TQVariant(TQT_TQDATE_OBJECT(
readDateTimeEntry( pKey, &tmp.asDateTime() ).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:
455 case TQVariant::ByteArray:
457 case TQVariant::BitArray:
458 case TQVariant::KeySequence:
461 case TQVariant::Char:
463 case TQVariant::Locale:
464 case TQVariant::RectF:
465 case TQVariant::SizeF:
466 case TQVariant::Line:
467 case TQVariant::LineF:
468 case TQVariant::PointF:
469 case TQVariant::RegExp:
470 case TQVariant::Hash:
471 case TQVariant::TextLength:
472 case QVariant::TextFormat:
473 case TQVariant::Matrix:
474 case TQVariant::Transform:
475 case TQVariant::Matrix4x4:
476 case TQVariant::Vector2D:
477 case TQVariant::Vector3D:
478 case TQVariant::Vector4D:
479 case TQVariant::Quaternion:
480 case TQVariant::UserType:
490 TQStrList &list,
char sep )
const 496 TQStrList &list,
char sep )
const 501 TQCString str_list = readEntryUtf8( pKey );
502 if (str_list.isEmpty())
506 TQCString value =
"";
507 int len = str_list.length();
509 for (
int i = 0; i < len; i++) {
510 if (str_list[i] != sep && str_list[i] !=
'\\') {
511 value += str_list[i];
514 if (str_list[i] ==
'\\') {
517 value += str_list[i];
525 list.append( value );
529 if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] ==
'\\' ) )
530 list.append( value );
547 if( str_list.isEmpty() )
549 TQString value(emptyString);
550 int len = str_list.length();
552 value.reserve( len );
553 for(
int i = 0; i < len; i++ )
555 if( str_list[i] != sep && str_list[i] !=
'\\' )
557 value += str_list[i];
560 if( str_list[i] ==
'\\' )
564 value += str_list[i];
567 TQString finalvalue( value );
568 finalvalue.squeeze();
569 list.append( finalvalue );
572 if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] ==
'\\' ) )
575 list.append( value );
597 TQValueList<int> list;
598 TQStringList::ConstIterator end(strlist.end());
599 for (TQStringList::ConstIterator it = strlist.begin(); it != end; ++it)
602 list << (*it).toInt();
614 const bool bExpandSave = bExpand;
616 TQString aValue =
readEntry( pKey, pDefault );
617 bExpand = bExpandSave;
628 const bool bExpandSave = bExpand;
631 bExpand = bExpandSave;
642 TQCString aValue = readEntryUtf8( pKey );
643 if( aValue.isNull() )
645 else if( aValue ==
"true" || aValue ==
"on" || aValue ==
"yes" )
650 int rc = aValue.toInt( &ok );
651 return( ok ? rc : nDefault );
663 TQCString aValue = readEntryUtf8( pKey );
664 if( aValue.isNull() )
669 unsigned int rc = aValue.toUInt( &ok );
670 return( ok ? rc : nDefault );
682 TQCString aValue = readEntryUtf8( pKey );
683 if( aValue.isNull() )
688 long rc = aValue.toLong( &ok );
689 return( ok ? rc : nDefault );
701 TQCString aValue = readEntryUtf8( pKey );
702 if( aValue.isNull() )
707 unsigned long rc = aValue.toULong( &ok );
708 return( ok ? rc : nDefault );
721 if( aValue.isNull() )
726 TQ_INT64 rc = aValue.toLongLong( &ok );
727 return( ok ? rc : nDefault );
741 if( aValue.isNull() )
746 TQ_UINT64 rc = aValue.toULongLong( &ok );
747 return( ok ? rc : nDefault );
758 TQCString aValue = readEntryUtf8( pKey );
759 if( aValue.isNull() )
764 double rc = aValue.toDouble( &ok );
765 return( ok ? rc : nDefault );
777 TQCString aValue = readEntryUtf8( pKey );
779 if( aValue.isNull() )
783 if( aValue ==
"true" || aValue ==
"on" || aValue ==
"yes" || aValue ==
"1" )
788 int val = aValue.toInt( &bOK );
789 if( bOK && val != 0 )
807 if( !aValue.isNull() ) {
808 if ( aValue.contains(
',' ) > 5 ) {
810 if ( !aRetFont.fromString( aValue ) && pDefault )
811 aRetFont = *pDefault;
817 int nIndex = aValue.find(
',' );
820 aRetFont = *pDefault;
823 aRetFont.setFamily( aValue.left( nIndex ) );
826 int nOldIndex = nIndex;
827 nIndex = aValue.find(
',', nOldIndex+1 );
830 aRetFont = *pDefault;
834 aRetFont.setPointSize( aValue.mid( nOldIndex+1,
835 nIndex-nOldIndex-1 ).toInt() );
839 nIndex = aValue.find(
',', nOldIndex+1 );
843 aRetFont = *pDefault;
847 aRetFont.setStyleHint( (TQFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() );
851 nIndex = aValue.find(
',', nOldIndex+1 );
855 aRetFont = *pDefault;
859 TQString chStr=aValue.mid( nOldIndex+1,
860 nIndex-nOldIndex-1 );
863 nIndex = aValue.find(
',', nOldIndex+1 );
867 aRetFont = *pDefault;
871 aRetFont.setWeight( aValue.mid( nOldIndex+1,
872 nIndex-nOldIndex-1 ).toUInt() );
875 uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt();
877 aRetFont.setItalic( nFontBits & 0x01 );
878 aRetFont.setUnderline( nFontBits & 0x02 );
879 aRetFont.setStrikeOut( nFontBits & 0x04 );
880 aRetFont.setFixedPitch( nFontBits & 0x08 );
881 aRetFont.setRawMode( nFontBits & 0x20 );
887 aRetFont = *pDefault;
901 TQCString aValue = readEntryUtf8(pKey);
903 if (!aValue.isEmpty())
905 int left, top, width, height;
907 if (sscanf(aValue.data(),
"%d,%d,%d,%d", &left, &top, &width, &height) == 4)
909 return TQRect(left, top, width, height);
919 const TQPoint* pDefault )
const 925 const TQPoint* pDefault )
const 927 TQCString aValue = readEntryUtf8(pKey);
929 if (!aValue.isEmpty())
933 if (sscanf(aValue.data(),
"%d,%d", &x, &y) == 2)
944 const TQSize* pDefault )
const 950 const TQSize* pDefault )
const 952 TQCString aValue = readEntryUtf8(pKey);
954 if (!aValue.isEmpty())
958 if (sscanf(aValue.data(),
"%d,%d", &width, &height) == 2)
960 return TQSize(width, height);
970 const TQColor* pDefault )
const 976 const TQColor* pDefault )
const 979 int nRed = 0, nGreen = 0, nBlue = 0;
982 if( !aValue.isEmpty() )
984 if ( aValue.at(0) == (QChar)
'#' )
986 aRetColor.setNamedColor(aValue);
994 int nIndex = aValue.find(
',' );
999 aRetColor = *pDefault;
1003 nRed = aValue.left( nIndex ).toInt( &bOK );
1006 int nOldIndex = nIndex;
1007 nIndex = aValue.find(
',', nOldIndex+1 );
1012 aRetColor = *pDefault;
1015 nGreen = aValue.mid( nOldIndex+1,
1016 nIndex-nOldIndex-1 ).toInt( &bOK );
1019 nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK );
1021 aRetColor.setRgb( nRed, nGreen, nBlue );
1027 aRetColor = *pDefault;
1035 const TQDateTime* pDefault )
const 1042 const TQDateTime* pDefault )
const 1049 return TQDateTime::currentDateTime();
1055 TQDate date( atoi( list.at( 0 ) ), atoi( list.at( 1 ) ),
1056 atoi( list.at( 2 ) ) );
1057 TQTime time( atoi( list.at( 3 ) ), atoi( list.at( 4 ) ),
1058 atoi( list.at( 5 ) ) );
1060 return TQDateTime( date, time );
1063 return TQDateTime::currentDateTime();
1071 writeEntry(pKey.utf8().data(), value, bPersistent, bGlobal, bNLS);
1079 writeEntry(pKey, value, bPersistent, bGlobal, bNLS,
false);
1103 aEntryData.mValue = value.utf8();
1105 aEntryData.
bNLS = bNLS;
1109 aEntryData.
bDirty =
true;
1112 putData(entryKey, aEntryData,
true);
1116 bool bPersistent,
bool bGlobal,
1119 writePathEntry(pKey.utf8().data(), path, bPersistent, bGlobal, bNLS);
1123 static bool cleanHomeDirPath( TQString &path,
const TQString &homeDir )
1125 #ifdef Q_WS_WIN //safer 1126 if (!TQDir::convertSeparators(path).startsWith(TQDir::convertSeparators(homeDir)))
1129 if (!path.startsWith(homeDir))
1133 unsigned int len = homeDir.length();
1135 if (len && (path.length() == len || path[len] ==
'/')) {
1136 path.replace(0, len, TQString::fromLatin1(
"$HOME"));
1142 static TQString translatePath( TQString path )
1148 path.replace(
'$',
"$$");
1150 bool startsWithFile = path.startsWith(
"file:",
false);
1154 if (((!startsWithFile) && (path[0] !=
'/')) || (startsWithFile && (path[5] !=
'/'))) {
1158 if (startsWithFile) {
1163 while (path[0] ==
'/' && path[1] ==
'/') {
1171 TQString homeDir0 = TQFile::decodeName(getenv(
"HOME"));
1172 TQString homeDir1 = TQDir::homeDirPath();
1173 TQString homeDir2 = TQDir(homeDir1).canonicalPath();
1174 if (cleanHomeDirPath(path, homeDir0) ||
1175 cleanHomeDirPath(path, homeDir1) ||
1176 cleanHomeDirPath(path, homeDir2) ) {
1181 path.prepend(
"file://" );
1187 bool bPersistent,
bool bGlobal,
1190 writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS,
true);
1194 bool bPersistent,
bool bGlobal,
1195 bool bNLS,
bool expand)
1197 writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS, expand);
1201 char sep ,
bool bPersistent,
1202 bool bGlobal,
bool bNLS )
1204 writePathEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1208 char sep ,
bool bPersistent,
1209 bool bGlobal,
bool bNLS )
1211 if( list.isEmpty() )
1213 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1216 TQStringList new_list;
1217 TQStringList::ConstIterator it = list.begin();
1218 for( ; it != list.end(); ++it )
1220 TQString value = *it;
1221 new_list.append( translatePath(value) );
1223 writeEntry( pKey, new_list, sep, bPersistent, bGlobal, bNLS,
true );
1251 aEntryData.
bNLS = bNLS;
1252 aEntryData.
bDirty =
true;
1256 putData(entryKey, aEntryData,
true);
1265 return aEntryMap.isEmpty();
1269 bool checkGroup =
true;
1271 KEntryMapIterator aIt;
1272 for (aIt = aEntryMap.begin(); aIt != aEntryMap.end(); ++aIt)
1274 if (!aIt.key().mKey.isEmpty() && !aIt.key().bDefault && !(*aIt).bDeleted)
1276 (*aIt).bDeleted =
true;
1277 (*aIt).bDirty =
true;
1278 (*aIt).bGlobal = bGlobal;
1280 putData(aIt.key(), *aIt, checkGroup);
1292 bool bGlobal,
bool bNLS )
1294 writeEntry(pKey.utf8().data(), prop, bPersistent, bGlobal, bNLS);
1299 bool bGlobal,
bool bNLS )
1301 switch( prop.type() )
1303 case TQVariant::Invalid:
1304 writeEntry( pKey,
"", bPersistent, bGlobal, bNLS );
1306 case TQVariant::String:
1307 writeEntry( pKey, prop.toString(), bPersistent, bGlobal, bNLS );
1309 case TQVariant::StringList:
1310 writeEntry( pKey, prop.toStringList(),
',', bPersistent, bGlobal, bNLS );
1312 case TQVariant::List: {
1313 TQValueList<TQVariant> list = prop.toList();
1314 TQValueList<TQVariant>::ConstIterator it = list.begin();
1315 TQValueList<TQVariant>::ConstIterator end = list.end();
1316 TQStringList strList;
1318 for (; it != end; ++it )
1319 strList.append( (*it).toString() );
1321 writeEntry( pKey, strList,
',', bPersistent, bGlobal, bNLS );
1325 case TQVariant::Font:
1326 writeEntry( pKey, prop.toFont(), bPersistent, bGlobal, bNLS );
1328 case TQVariant::Point:
1329 writeEntry( pKey, prop.toPoint(), bPersistent, bGlobal, bNLS );
1331 case TQVariant::Rect:
1332 writeEntry( pKey, prop.toRect(), bPersistent, bGlobal, bNLS );
1334 case TQVariant::Size:
1335 writeEntry( pKey, prop.toSize(), bPersistent, bGlobal, bNLS );
1337 case TQVariant::Color:
1338 writeEntry( pKey, prop.toColor(), bPersistent, bGlobal, bNLS );
1340 case TQVariant::Int:
1341 writeEntry( pKey, prop.toInt(), bPersistent, bGlobal, bNLS );
1343 case TQVariant::UInt:
1344 writeEntry( pKey, prop.toUInt(), bPersistent, bGlobal, bNLS );
1346 case TQVariant::LongLong:
1347 writeEntry( pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS );
1349 case TQVariant::ULongLong:
1350 writeEntry( pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS );
1352 case TQVariant::Bool:
1353 writeEntry( pKey, prop.toBool(), bPersistent, bGlobal, bNLS );
1355 case TQVariant::Double:
1356 writeEntry( pKey, prop.toDouble(), bPersistent, bGlobal,
'g', 6, bNLS );
1358 case TQVariant::DateTime:
1359 writeEntry( pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS);
1361 case TQVariant::Date:
1362 writeEntry( pKey, TQDateTime(prop.toDate()), bPersistent, bGlobal, bNLS);
1365 case TQVariant::Pixmap:
1366 case TQVariant::Image:
1367 case TQVariant::Brush:
1368 case TQVariant::Palette:
1369 case TQVariant::ColorGroup:
1370 case TQVariant::Map:
1371 case TQVariant::IconSet:
1372 case TQVariant::CString:
1373 case TQVariant::PointArray:
1374 case TQVariant::Region:
1375 case TQVariant::Bitmap:
1376 case TQVariant::Cursor:
1377 case TQVariant::SizePolicy:
1378 case TQVariant::Time:
1380 case TQVariant::ByteArray:
1382 case TQVariant::BitArray:
1383 case TQVariant::KeySequence:
1384 case TQVariant::Pen:
1386 case TQVariant::Char:
1387 case TQVariant::Url:
1388 case TQVariant::Locale:
1389 case TQVariant::RectF:
1390 case TQVariant::SizeF:
1391 case TQVariant::Line:
1392 case TQVariant::LineF:
1393 case TQVariant::PointF:
1394 case TQVariant::RegExp:
1395 case TQVariant::Hash:
1396 case TQVariant::TextLength:
1397 case QVariant::TextFormat:
1398 case TQVariant::Matrix:
1399 case TQVariant::Transform:
1400 case TQVariant::Matrix4x4:
1401 case TQVariant::Vector2D:
1402 case TQVariant::Vector3D:
1403 case TQVariant::Vector4D:
1404 case TQVariant::Quaternion:
1405 case TQVariant::UserType:
1414 char sep ,
bool bPersistent,
1415 bool bGlobal,
bool bNLS )
1417 writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1421 char sep ,
bool bPersistent,
1422 bool bGlobal,
bool bNLS )
1424 if( list.isEmpty() )
1426 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1430 TQStrListIterator it( list );
1431 for( ; it.current(); ++it )
1439 uint strLengh(value.length());
1440 for( i = 0; i < strLengh; i++ )
1442 if( value[i] == sep || value[i] ==
'\\' )
1444 str_list += value[i];
1448 if( str_list.at(str_list.length() - 1) == (QChar)sep )
1449 str_list.truncate( str_list.length() -1 );
1450 writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS );
1454 char sep ,
bool bPersistent,
1455 bool bGlobal,
bool bNLS )
1457 writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1461 char sep ,
bool bPersistent,
1462 bool bGlobal,
bool bNLS )
1464 writeEntry(pKey, list, sep, bPersistent, bGlobal, bNLS,
false);
1468 char sep,
bool bPersistent,
1469 bool bGlobal,
bool bNLS,
bool bExpand )
1471 if( list.isEmpty() )
1473 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1477 str_list.reserve( 4096 );
1478 TQStringList::ConstIterator it = list.begin();
1479 for( ; it != list.end(); ++it )
1481 TQString value = *it;
1483 uint strLength(value.length());
1484 for( i = 0; i < strLength; i++ )
1486 if( value[i] == sep || value[i] ==
'\\' )
1488 str_list += value[i];
1492 if( str_list.at(str_list.length() - 1) == (QChar)sep )
1493 str_list.truncate( str_list.length() -1 );
1494 writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS, bExpand );
1498 bool bPersistent,
bool bGlobal,
bool bNLS )
1500 writeEntry(pKey.utf8().data(), list, bPersistent, bGlobal, bNLS);
1504 bool bPersistent,
bool bGlobal,
bool bNLS )
1506 TQStringList strlist;
1507 TQValueList<int>::ConstIterator end = list.end();
1508 for (TQValueList<int>::ConstIterator it = list.begin(); it != end; it++)
1509 strlist << TQString::number(*it);
1510 writeEntry(pKey, strlist,
',', bPersistent, bGlobal, bNLS );
1514 bool bPersistent,
bool bGlobal,
1517 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1521 bool bPersistent,
bool bGlobal,
1524 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 );
1559 bool bPersistent,
bool bGlobal,
1562 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1566 bool bPersistent,
bool bGlobal,
1569 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1573 bool bPersistent,
bool bGlobal,
1576 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1580 bool bPersistent,
bool bGlobal,
1583 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1588 bool bPersistent,
bool bGlobal,
1591 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1595 bool bPersistent,
bool bGlobal,
1598 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1602 bool bPersistent,
bool bGlobal,
1603 char format,
int precision,
1606 writeEntry( pKey, TQString::number(nValue, format, precision),
1607 bPersistent, bGlobal, bNLS );
1611 bool bPersistent,
bool bGlobal,
1612 char format,
int precision,
1615 writeEntry( pKey, TQString::number(nValue, format, precision),
1616 bPersistent, bGlobal, bNLS );
1625 writeEntry(pKey.utf8().data(), bValue, bPersistent, bGlobal, bNLS);
1640 writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1645 bool bPersistent,
bool bGlobal,
1648 writeEntry(pKey.utf8().data(), rFont, bPersistent, bGlobal, bNLS);
1652 bool bPersistent,
bool bGlobal,
1655 writeEntry( pKey, TQString(rFont.toString()), bPersistent, bGlobal, bNLS );
1660 bool bPersistent,
bool bGlobal,
1663 writeEntry(pKey.utf8().data(), rRect, bPersistent, bGlobal, bNLS);
1667 bool bPersistent,
bool bGlobal,
1672 list.insert( 0, tempstr.setNum( rRect.left() ) );
1673 list.insert( 1, tempstr.setNum( rRect.top() ) );
1674 list.insert( 2, tempstr.setNum( rRect.width() ) );
1675 list.insert( 3, tempstr.setNum( rRect.height() ) );
1677 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1682 bool bPersistent,
bool bGlobal,
1685 writeEntry(pKey.utf8().data(), rPoint, bPersistent, bGlobal, bNLS);
1689 bool bPersistent,
bool bGlobal,
1694 list.insert( 0, tempstr.setNum( rPoint.x() ) );
1695 list.insert( 1, tempstr.setNum( rPoint.y() ) );
1697 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1702 bool bPersistent,
bool bGlobal,
1705 writeEntry(pKey.utf8().data(), rSize, bPersistent, bGlobal, bNLS);
1709 bool bPersistent,
bool bGlobal,
1714 list.insert( 0, tempstr.setNum( rSize.width() ) );
1715 list.insert( 1, tempstr.setNum( rSize.height() ) );
1717 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1725 writeEntry( pKey.utf8().data(), rColor, bPersistent, bGlobal, bNLS);
1734 if (rColor.isValid())
1735 aValue.sprintf(
"%d,%d,%d", rColor.red(), rColor.green(), rColor.blue() );
1739 writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1743 bool bPersistent,
bool bGlobal,
1746 writeEntry(pKey.utf8().data(), rDateTime, bPersistent, bGlobal, bNLS);
1750 bool bPersistent,
bool bGlobal,
1756 TQTime time = TQT_TQTIME_OBJECT(rDateTime.time());
1757 TQDate date = TQT_TQDATE_OBJECT(rDateTime.date());
1759 list.insert( 0, tempstr.setNum( date.year() ) );
1760 list.insert( 1, tempstr.setNum( date.month() ) );
1761 list.insert( 2, tempstr.setNum( date.day() ) );
1763 list.insert( 3, tempstr.setNum( time.hour() ) );
1764 list.insert( 4, tempstr.setNum( time.minute() ) );
1765 list.insert( 5, tempstr.setNum( time.second() ) );
1767 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1772 if (!bLocaleInitialized && TDEGlobal::_locale) {
1810 d =
new TDEConfigBasePrivate();
1813 d->readDefaults = b;
1818 return (d && d->readDefaults);
1828 if (!
locale().isNull()) {
1830 aEntryKey.bLocal =
true;
1832 if (entry.mValue.isNull())
1836 putData(aEntryKey, entry,
true);
1837 aEntryKey.bLocal =
false;
1842 if (entry.mValue.isNull())
1845 putData(aEntryKey, entry,
true);
1853 if (!
locale().isNull()) {
1855 aEntryKey.bLocal =
true;
1857 if (!entry.mValue.isNull())
1860 aEntryKey.bLocal =
false;
1865 if (!entry.mValue.isNull())
1877 bLocaleInitialized =
true;
1878 bReadOnly = mMaster->bReadOnly;
1890 bLocaleInitialized =
true;
1891 bReadOnly = mMaster->bReadOnly;
1903 bLocaleInitialized =
true;
1904 bReadOnly = mMaster->bReadOnly;
1924 mMaster->setDirty(_bDirty);
1929 mMaster->putData(_key, _data, _checkGroup);
1934 return mMaster->lookupData(_key);
1942 void TDEConfigBase::virtual_hook(
int,
void* )
1945 void TDEConfigGroup::virtual_hook(
int id,
void* data )
1946 { TDEConfigBase::virtual_hook(
id, data ); }
1956 #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...