28 #include <tqtextstream.h> 30 #include <tdeapplication.h> 31 #include <tdeglobalsettings.h> 32 #include <tdeglobal.h> 34 #include <kcharsets.h> 36 #include "tdeconfigbase.h" 37 #include "tdeconfigbackend.h" 39 #include "kstandarddirs.h" 40 #include "kstringhandler.h" 42 class TDEConfigBase::TDEConfigBasePrivate
53 bReadOnly(false), bExpand(false), d(0)
65 bLocaleInitialized =
true;
82 if ( group.isEmpty() )
95 if ( group.isEmpty() )
102 return TQString::fromUtf8(
mGroup);
112 return hasKey(key.utf8().data());
118 aEntryKey.c_key = pKey;
125 if (!entry.mValue.isNull())
132 return !entry.mValue.isNull();
135 bool TDEConfigBase::hasTranslatedKey(
const char* pKey)
const 138 aEntryKey.c_key = pKey;
145 if (!entry.mValue.isNull())
155 return internalHasGroup( group.utf8());
160 return internalHasGroup( TQCString(_pGroup));
165 return internalHasGroup( _pGroup);
180 return entry.bImmutable;
193 TQCString utf8_key = key.utf8();
194 entryKey.c_key = utf8_key.data();
206 const TQString& aDefault )
const 213 const TQString& aDefault )
const 215 TQCString result = readEntryUtf8(pKey);
218 return TQString::fromUtf8(result);
223 const TQString& aDefault )
const 229 const TQString& aDefault )
const 235 if (!bLocaleInitialized && TDEGlobal::_locale) {
248 entryKey.c_key = pKey;
252 if (!aEntryData.mValue.isNull()) {
259 if (!aEntryData.mValue.isNull()) {
260 aValue = TQString::fromUtf8(aEntryData.mValue.data());
264 aValue = emptyString;
273 if( expand || bExpand )
276 int nDollarPos = aValue.find(
'$' );
278 while( nDollarPos != -1 && (nDollarPos + 1) < static_cast<int>(aValue.length())) {
280 if( aValue[nDollarPos+1] !=
'$' ) {
281 uint nEndPos = nDollarPos+1;
284 if (aValue[nEndPos]==
'{')
286 while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!=
'}') )
289 aVarName = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 );
293 while ( nEndPos <= aValue.length() && (aValue[nEndPos].isNumber()
294 || aValue[nEndPos].isLetter() || aValue[nEndPos]==
'_' ) )
296 aVarName = aValue.mid( nDollarPos+1, nEndPos-nDollarPos-1 );
298 const char *pEnv = 0;
299 if (!aVarName.isEmpty())
300 pEnv = getenv( aVarName.ascii() );
307 else if (aVarName.length() > 8 && aVarName.startsWith(
"XDG_") && aVarName.endsWith(
"_DIR")) {
309 if (aVarName ==
"XDG_DESKTOP_DIR") {
312 else if (aVarName ==
"XDG_DOCUMENTS_DIR") {
315 else if (aVarName ==
"XDG_DOWNLOAD_DIR") {
318 else if (aVarName ==
"XDG_MUSIC_DIR") {
321 else if (aVarName ==
"XDG_PICTURES_DIR") {
324 else if (aVarName ==
"XDG_PUBLICSHARE_DIR") {
327 else if (aVarName ==
"XDG_TEMPLATES_DIR") {
330 else if (aVarName ==
"XDG_VIDEOS_DIR") {
333 aValue.replace( nDollarPos, nEndPos-nDollarPos, result );
336 aValue.remove( nDollarPos, nEndPos-nDollarPos );
341 aValue.remove( nDollarPos, 1 );
344 nDollarPos = aValue.find(
'$', nDollarPos );
351 TQCString TDEConfigBase::readEntryUtf8(
const char *pKey)
const 356 entryKey.c_key = pKey;
361 return readEntry(pKey, TQString::null).utf8();
363 return aEntryData.mValue;
367 TQVariant::Type type )
const 373 TQVariant::Type type )
const 376 if ( !
hasKey( pKey ) )
return va;
382 const TQVariant &aDefault )
const 388 const TQVariant &aDefault )
const 390 if ( !
hasKey( pKey ) )
return aDefault;
392 TQVariant tmp = aDefault;
394 switch( aDefault.type() )
396 case TQVariant::Invalid:
398 case TQVariant::String:
399 return TQVariant(
readEntry( pKey, aDefault.toString() ) );
400 case TQVariant::StringList:
402 case TQVariant::List: {
404 TQStringList::ConstIterator it = strList.begin();
405 TQStringList::ConstIterator end = strList.end();
406 TQValueList<TQVariant> list;
408 for (; it != end; ++it ) {
412 return TQVariant( list );
414 case TQVariant::Font:
416 case TQVariant::Point:
418 case TQVariant::Rect:
420 case TQVariant::Size:
422 case TQVariant::Color:
425 return TQVariant(
readNumEntry( pKey, aDefault.toInt() ) );
426 case TQVariant::UInt:
428 case TQVariant::LongLong:
429 return TQVariant(
readNum64Entry( pKey, aDefault.toLongLong() ) );
430 case TQVariant::ULongLong:
432 case TQVariant::Bool:
433 return TQVariant(
readBoolEntry( pKey, aDefault.toBool() ), 0 );
434 case TQVariant::Double:
436 case TQVariant::DateTime:
438 case TQVariant::Date:
439 return TQVariant(TQT_TQDATE_OBJECT(
readDateTimeEntry( pKey, &tmp.asDateTime() ).date()));
441 case TQVariant::Pixmap:
442 case TQVariant::Image:
443 case TQVariant::Brush:
444 case TQVariant::Palette:
445 case TQVariant::ColorGroup:
447 case TQVariant::IconSet:
448 case TQVariant::CString:
449 case TQVariant::PointArray:
450 case TQVariant::Region:
451 case TQVariant::Bitmap:
452 case TQVariant::Cursor:
453 case TQVariant::SizePolicy:
454 case TQVariant::Time:
456 case TQVariant::ByteArray:
458 case TQVariant::BitArray:
459 case TQVariant::KeySequence:
462 case TQVariant::Char:
464 case TQVariant::Locale:
465 case TQVariant::RectF:
466 case TQVariant::SizeF:
467 case TQVariant::Line:
468 case TQVariant::LineF:
469 case TQVariant::PointF:
470 case TQVariant::RegExp:
471 case TQVariant::Hash:
472 case TQVariant::TextLength:
473 case QVariant::TextFormat:
474 case TQVariant::Matrix:
475 case TQVariant::Transform:
476 case TQVariant::Matrix4x4:
477 case TQVariant::Vector2D:
478 case TQVariant::Vector3D:
479 case TQVariant::Vector4D:
480 case TQVariant::Quaternion:
481 case TQVariant::UserType:
491 TQStrList &list,
char sep )
const 497 TQStrList &list,
char sep )
const 502 TQCString str_list = readEntryUtf8( pKey );
503 if (str_list.isEmpty())
507 TQCString value =
"";
508 int len = str_list.length();
510 for (
int i = 0; i < len; i++) {
511 if (str_list[i] != sep && str_list[i] !=
'\\') {
512 value += str_list[i];
515 if (str_list[i] ==
'\\') {
518 value += str_list[i];
526 list.append( value );
530 if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] ==
'\\' ) )
531 list.append( value );
548 if( str_list.isEmpty() )
550 TQString value(emptyString);
551 int len = str_list.length();
553 value.reserve( len );
554 for(
int i = 0; i < len; i++ )
556 if( str_list[i] != sep && str_list[i] !=
'\\' )
558 value += str_list[i];
561 if( str_list[i] ==
'\\' )
565 value += str_list[i];
568 TQString finalvalue( value );
569 finalvalue.squeeze();
570 list.append( finalvalue );
573 if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] ==
'\\' ) )
576 list.append( value );
598 TQValueList<int> list;
599 TQStringList::ConstIterator end(strlist.end());
600 for (TQStringList::ConstIterator it = strlist.begin(); it != end; ++it)
603 list << (*it).toInt();
615 const bool bExpandSave = bExpand;
617 TQString aValue =
readEntry( pKey, pDefault );
618 bExpand = bExpandSave;
629 const bool bExpandSave = bExpand;
632 bExpand = bExpandSave;
643 TQCString aValue = readEntryUtf8( pKey );
644 if( aValue.isNull() )
646 else if( aValue ==
"true" || aValue ==
"on" || aValue ==
"yes" )
651 int rc = aValue.toInt( &ok );
652 return( ok ? rc : nDefault );
664 TQCString aValue = readEntryUtf8( pKey );
665 if( aValue.isNull() )
670 unsigned int rc = aValue.toUInt( &ok );
671 return( ok ? rc : nDefault );
683 TQCString aValue = readEntryUtf8( pKey );
684 if( aValue.isNull() )
689 long rc = aValue.toLong( &ok );
690 return( ok ? rc : nDefault );
702 TQCString aValue = readEntryUtf8( pKey );
703 if( aValue.isNull() )
708 unsigned long rc = aValue.toULong( &ok );
709 return( ok ? rc : nDefault );
722 if( aValue.isNull() )
727 TQ_INT64 rc = aValue.toLongLong( &ok );
728 return( ok ? rc : nDefault );
742 if( aValue.isNull() )
747 TQ_UINT64 rc = aValue.toULongLong( &ok );
748 return( ok ? rc : nDefault );
759 TQCString aValue = readEntryUtf8( pKey );
760 if( aValue.isNull() )
765 double rc = aValue.toDouble( &ok );
766 return( ok ? rc : nDefault );
778 TQCString aValue = readEntryUtf8( pKey );
780 if( aValue.isNull() )
784 if( aValue ==
"true" || aValue ==
"on" || aValue ==
"yes" || aValue ==
"1" )
789 int val = aValue.toInt( &bOK );
790 if( bOK && val != 0 )
808 if( !aValue.isNull() ) {
809 if ( aValue.contains(
',' ) > 5 ) {
811 if ( !aRetFont.fromString( aValue ) && pDefault )
812 aRetFont = *pDefault;
818 int nIndex = aValue.find(
',' );
821 aRetFont = *pDefault;
824 aRetFont.setFamily( aValue.left( nIndex ) );
827 int nOldIndex = nIndex;
828 nIndex = aValue.find(
',', nOldIndex+1 );
831 aRetFont = *pDefault;
835 aRetFont.setPointSize( aValue.mid( nOldIndex+1,
836 nIndex-nOldIndex-1 ).toInt() );
840 nIndex = aValue.find(
',', nOldIndex+1 );
844 aRetFont = *pDefault;
848 aRetFont.setStyleHint( (TQFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() );
852 nIndex = aValue.find(
',', nOldIndex+1 );
856 aRetFont = *pDefault;
860 TQString chStr=aValue.mid( nOldIndex+1,
861 nIndex-nOldIndex-1 );
864 nIndex = aValue.find(
',', nOldIndex+1 );
868 aRetFont = *pDefault;
872 aRetFont.setWeight( aValue.mid( nOldIndex+1,
873 nIndex-nOldIndex-1 ).toUInt() );
876 uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt();
878 aRetFont.setItalic( nFontBits & 0x01 );
879 aRetFont.setUnderline( nFontBits & 0x02 );
880 aRetFont.setStrikeOut( nFontBits & 0x04 );
881 aRetFont.setFixedPitch( nFontBits & 0x08 );
882 aRetFont.setRawMode( nFontBits & 0x20 );
888 aRetFont = *pDefault;
902 TQCString aValue = readEntryUtf8(pKey);
904 if (!aValue.isEmpty())
906 int left, top, width, height;
908 if (sscanf(aValue.data(),
"%d,%d,%d,%d", &left, &top, &width, &height) == 4)
910 return TQRect(left, top, width, height);
920 const TQPoint* pDefault )
const 926 const TQPoint* pDefault )
const 928 TQCString aValue = readEntryUtf8(pKey);
930 if (!aValue.isEmpty())
934 if (sscanf(aValue.data(),
"%d,%d", &x, &y) == 2)
945 const TQSize* pDefault )
const 951 const TQSize* pDefault )
const 953 TQCString aValue = readEntryUtf8(pKey);
955 if (!aValue.isEmpty())
959 if (sscanf(aValue.data(),
"%d,%d", &width, &height) == 2)
961 return TQSize(width, height);
971 const TQColor* pDefault )
const 977 const TQColor* pDefault )
const 980 int nRed = 0, nGreen = 0, nBlue = 0;
983 if( !aValue.isEmpty() )
985 if ( aValue.at(0) == (QChar)
'#' )
987 aRetColor.setNamedColor(aValue);
995 int nIndex = aValue.find(
',' );
1000 aRetColor = *pDefault;
1004 nRed = aValue.left( nIndex ).toInt( &bOK );
1007 int nOldIndex = nIndex;
1008 nIndex = aValue.find(
',', nOldIndex+1 );
1013 aRetColor = *pDefault;
1016 nGreen = aValue.mid( nOldIndex+1,
1017 nIndex-nOldIndex-1 ).toInt( &bOK );
1020 nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK );
1022 aRetColor.setRgb( nRed, nGreen, nBlue );
1028 aRetColor = *pDefault;
1036 const TQDateTime* pDefault )
const 1043 const TQDateTime* pDefault )
const 1050 return TQDateTime::currentDateTime();
1056 TQDate date( atoi( list.at( 0 ) ), atoi( list.at( 1 ) ),
1057 atoi( list.at( 2 ) ) );
1058 TQTime time( atoi( list.at( 3 ) ), atoi( list.at( 4 ) ),
1059 atoi( list.at( 5 ) ) );
1061 return TQDateTime( date, time );
1064 return TQDateTime::currentDateTime();
1072 writeEntry(pKey.utf8().data(), value, bPersistent, bGlobal, bNLS);
1080 writeEntry(pKey, value, bPersistent, bGlobal, bNLS,
false);
1104 aEntryData.mValue = value.utf8();
1106 aEntryData.
bNLS = bNLS;
1110 aEntryData.
bDirty =
true;
1113 putData(entryKey, aEntryData,
true);
1117 bool bPersistent,
bool bGlobal,
1120 writePathEntry(pKey.utf8().data(), path, bPersistent, bGlobal, bNLS);
1124 static bool cleanHomeDirPath( TQString &path,
const TQString &homeDir )
1126 #ifdef Q_WS_WIN //safer 1127 if (!TQDir::convertSeparators(path).startsWith(TQDir::convertSeparators(homeDir)))
1130 if (!path.startsWith(homeDir))
1134 unsigned int len = homeDir.length();
1136 if (len && (path.length() == len || path[len] ==
'/')) {
1137 path.replace(0, len, TQString::fromLatin1(
"$HOME"));
1143 static TQString translatePath( TQString path )
1149 path.replace(
'$',
"$$");
1151 bool startsWithFile = path.startsWith(
"file:",
false);
1155 if (((!startsWithFile) && (path[0] !=
'/')) || (startsWithFile && (path[5] !=
'/'))) {
1159 if (startsWithFile) {
1164 while (path[0] ==
'/' && path[1] ==
'/') {
1172 TQString homeDir0 = TQFile::decodeName(getenv(
"HOME"));
1173 TQString homeDir1 = TQDir::homeDirPath();
1174 TQString homeDir2 = TQDir(homeDir1).canonicalPath();
1175 if (cleanHomeDirPath(path, homeDir0) ||
1176 cleanHomeDirPath(path, homeDir1) ||
1177 cleanHomeDirPath(path, homeDir2) ) {
1182 path.prepend(
"file://" );
1188 bool bPersistent,
bool bGlobal,
1191 writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS,
true);
1195 bool bPersistent,
bool bGlobal,
1196 bool bNLS,
bool expand)
1198 writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS, expand);
1202 char sep ,
bool bPersistent,
1203 bool bGlobal,
bool bNLS )
1205 writePathEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1209 char sep ,
bool bPersistent,
1210 bool bGlobal,
bool bNLS )
1212 if( list.isEmpty() )
1214 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1217 TQStringList new_list;
1218 TQStringList::ConstIterator it = list.begin();
1219 for( ; it != list.end(); ++it )
1221 TQString value = *it;
1222 new_list.append( translatePath(value) );
1224 writeEntry( pKey, new_list, sep, bPersistent, bGlobal, bNLS,
true );
1252 aEntryData.
bNLS = bNLS;
1253 aEntryData.
bDirty =
true;
1257 putData(entryKey, aEntryData,
true);
1266 return aEntryMap.isEmpty();
1270 bool checkGroup =
true;
1272 KEntryMapIterator aIt;
1273 for (aIt = aEntryMap.begin(); aIt != aEntryMap.end(); ++aIt)
1275 if (!aIt.key().mKey.isEmpty() && !aIt.key().bDefault && !(*aIt).bDeleted)
1277 (*aIt).bDeleted =
true;
1278 (*aIt).bDirty =
true;
1279 (*aIt).bGlobal = bGlobal;
1281 putData(aIt.key(), *aIt, checkGroup);
1293 bool bGlobal,
bool bNLS )
1295 writeEntry(pKey.utf8().data(), prop, bPersistent, bGlobal, bNLS);
1300 bool bGlobal,
bool bNLS )
1302 switch( prop.type() )
1304 case TQVariant::Invalid:
1305 writeEntry( pKey,
"", bPersistent, bGlobal, bNLS );
1307 case TQVariant::String:
1308 writeEntry( pKey, prop.toString(), bPersistent, bGlobal, bNLS );
1310 case TQVariant::StringList:
1311 writeEntry( pKey, prop.toStringList(),
',', bPersistent, bGlobal, bNLS );
1313 case TQVariant::List: {
1314 TQValueList<TQVariant> list = prop.toList();
1315 TQValueList<TQVariant>::ConstIterator it = list.begin();
1316 TQValueList<TQVariant>::ConstIterator end = list.end();
1317 TQStringList strList;
1319 for (; it != end; ++it )
1320 strList.append( (*it).toString() );
1322 writeEntry( pKey, strList,
',', bPersistent, bGlobal, bNLS );
1326 case TQVariant::Font:
1327 writeEntry( pKey, prop.toFont(), bPersistent, bGlobal, bNLS );
1329 case TQVariant::Point:
1330 writeEntry( pKey, prop.toPoint(), bPersistent, bGlobal, bNLS );
1332 case TQVariant::Rect:
1333 writeEntry( pKey, prop.toRect(), bPersistent, bGlobal, bNLS );
1335 case TQVariant::Size:
1336 writeEntry( pKey, prop.toSize(), bPersistent, bGlobal, bNLS );
1338 case TQVariant::Color:
1339 writeEntry( pKey, prop.toColor(), bPersistent, bGlobal, bNLS );
1341 case TQVariant::Int:
1342 writeEntry( pKey, prop.toInt(), bPersistent, bGlobal, bNLS );
1344 case TQVariant::UInt:
1345 writeEntry( pKey, prop.toUInt(), bPersistent, bGlobal, bNLS );
1347 case TQVariant::LongLong:
1348 writeEntry( pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS );
1350 case TQVariant::ULongLong:
1351 writeEntry( pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS );
1353 case TQVariant::Bool:
1354 writeEntry( pKey, prop.toBool(), bPersistent, bGlobal, bNLS );
1356 case TQVariant::Double:
1357 writeEntry( pKey, prop.toDouble(), bPersistent, bGlobal,
'g', 6, bNLS );
1359 case TQVariant::DateTime:
1360 writeEntry( pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS);
1362 case TQVariant::Date:
1363 writeEntry( pKey, TQDateTime(prop.toDate()), bPersistent, bGlobal, bNLS);
1366 case TQVariant::Pixmap:
1367 case TQVariant::Image:
1368 case TQVariant::Brush:
1369 case TQVariant::Palette:
1370 case TQVariant::ColorGroup:
1371 case TQVariant::Map:
1372 case TQVariant::IconSet:
1373 case TQVariant::CString:
1374 case TQVariant::PointArray:
1375 case TQVariant::Region:
1376 case TQVariant::Bitmap:
1377 case TQVariant::Cursor:
1378 case TQVariant::SizePolicy:
1379 case TQVariant::Time:
1381 case TQVariant::ByteArray:
1383 case TQVariant::BitArray:
1384 case TQVariant::KeySequence:
1385 case TQVariant::Pen:
1387 case TQVariant::Char:
1388 case TQVariant::Url:
1389 case TQVariant::Locale:
1390 case TQVariant::RectF:
1391 case TQVariant::SizeF:
1392 case TQVariant::Line:
1393 case TQVariant::LineF:
1394 case TQVariant::PointF:
1395 case TQVariant::RegExp:
1396 case TQVariant::Hash:
1397 case TQVariant::TextLength:
1398 case QVariant::TextFormat:
1399 case TQVariant::Matrix:
1400 case TQVariant::Transform:
1401 case TQVariant::Matrix4x4:
1402 case TQVariant::Vector2D:
1403 case TQVariant::Vector3D:
1404 case TQVariant::Vector4D:
1405 case TQVariant::Quaternion:
1406 case TQVariant::UserType:
1415 char sep ,
bool bPersistent,
1416 bool bGlobal,
bool bNLS )
1418 writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1422 char sep ,
bool bPersistent,
1423 bool bGlobal,
bool bNLS )
1425 if( list.isEmpty() )
1427 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1431 TQStrListIterator it( list );
1432 for( ; it.current(); ++it )
1440 uint strLengh(value.length());
1441 for( i = 0; i < strLengh; i++ )
1443 if( value[i] == sep || value[i] ==
'\\' )
1445 str_list += value[i];
1449 if( str_list.at(str_list.length() - 1) == (QChar)sep )
1450 str_list.truncate( str_list.length() -1 );
1451 writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS );
1455 char sep ,
bool bPersistent,
1456 bool bGlobal,
bool bNLS )
1458 writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1462 char sep ,
bool bPersistent,
1463 bool bGlobal,
bool bNLS )
1465 writeEntry(pKey, list, sep, bPersistent, bGlobal, bNLS,
false);
1469 char sep,
bool bPersistent,
1470 bool bGlobal,
bool bNLS,
bool bExpand )
1472 if( list.isEmpty() )
1474 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1478 str_list.reserve( 4096 );
1479 TQStringList::ConstIterator it = list.begin();
1480 for( ; it != list.end(); ++it )
1482 TQString value = *it;
1484 uint strLength(value.length());
1485 for( i = 0; i < strLength; i++ )
1487 if( value[i] == sep || value[i] ==
'\\' )
1489 str_list += value[i];
1493 if( str_list.at(str_list.length() - 1) == (QChar)sep )
1494 str_list.truncate( str_list.length() -1 );
1495 writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS, bExpand );
1499 bool bPersistent,
bool bGlobal,
bool bNLS )
1501 writeEntry(pKey.utf8().data(), list, bPersistent, bGlobal, bNLS);
1505 bool bPersistent,
bool bGlobal,
bool bNLS )
1507 TQStringList strlist;
1508 TQValueList<int>::ConstIterator end = list.end();
1509 for (TQValueList<int>::ConstIterator it = list.begin(); it != end; it++)
1510 strlist << TQString::number(*it);
1511 writeEntry(pKey, strlist,
',', bPersistent, bGlobal, bNLS );
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 );
1530 bool bPersistent,
bool bGlobal,
1533 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1537 bool bPersistent,
bool bGlobal,
1540 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1545 bool bPersistent,
bool bGlobal,
1548 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1552 bool bPersistent,
bool bGlobal,
1555 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1560 bool bPersistent,
bool bGlobal,
1563 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1567 bool bPersistent,
bool bGlobal,
1570 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1574 bool bPersistent,
bool bGlobal,
1577 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1581 bool bPersistent,
bool bGlobal,
1584 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1589 bool bPersistent,
bool bGlobal,
1592 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1596 bool bPersistent,
bool bGlobal,
1599 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1603 bool bPersistent,
bool bGlobal,
1604 char format,
int precision,
1607 writeEntry( pKey, TQString::number(nValue, format, precision),
1608 bPersistent, bGlobal, bNLS );
1612 bool bPersistent,
bool bGlobal,
1613 char format,
int precision,
1616 writeEntry( pKey, TQString::number(nValue, format, precision),
1617 bPersistent, bGlobal, bNLS );
1626 writeEntry(pKey.utf8().data(), bValue, bPersistent, bGlobal, bNLS);
1641 writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1646 bool bPersistent,
bool bGlobal,
1649 writeEntry(pKey.utf8().data(), rFont, bPersistent, bGlobal, bNLS);
1653 bool bPersistent,
bool bGlobal,
1656 writeEntry( pKey, TQString(rFont.toString()), bPersistent, bGlobal, bNLS );
1661 bool bPersistent,
bool bGlobal,
1664 writeEntry(pKey.utf8().data(), rRect, bPersistent, bGlobal, bNLS);
1668 bool bPersistent,
bool bGlobal,
1673 list.insert( 0, tempstr.setNum( rRect.left() ) );
1674 list.insert( 1, tempstr.setNum( rRect.top() ) );
1675 list.insert( 2, tempstr.setNum( rRect.width() ) );
1676 list.insert( 3, tempstr.setNum( rRect.height() ) );
1678 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1683 bool bPersistent,
bool bGlobal,
1686 writeEntry(pKey.utf8().data(), rPoint, bPersistent, bGlobal, bNLS);
1690 bool bPersistent,
bool bGlobal,
1695 list.insert( 0, tempstr.setNum( rPoint.x() ) );
1696 list.insert( 1, tempstr.setNum( rPoint.y() ) );
1698 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1703 bool bPersistent,
bool bGlobal,
1706 writeEntry(pKey.utf8().data(), rSize, bPersistent, bGlobal, bNLS);
1710 bool bPersistent,
bool bGlobal,
1715 list.insert( 0, tempstr.setNum( rSize.width() ) );
1716 list.insert( 1, tempstr.setNum( rSize.height() ) );
1718 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1726 writeEntry( pKey.utf8().data(), rColor, bPersistent, bGlobal, bNLS);
1735 if (rColor.isValid())
1736 aValue.sprintf(
"%d,%d,%d", rColor.red(), rColor.green(), rColor.blue() );
1740 writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1744 bool bPersistent,
bool bGlobal,
1747 writeEntry(pKey.utf8().data(), rDateTime, bPersistent, bGlobal, bNLS);
1751 bool bPersistent,
bool bGlobal,
1757 TQTime time = TQT_TQTIME_OBJECT(rDateTime.time());
1758 TQDate date = TQT_TQDATE_OBJECT(rDateTime.date());
1760 list.insert( 0, tempstr.setNum( date.year() ) );
1761 list.insert( 1, tempstr.setNum( date.month() ) );
1762 list.insert( 2, tempstr.setNum( date.day() ) );
1764 list.insert( 3, tempstr.setNum( time.hour() ) );
1765 list.insert( 4, tempstr.setNum( time.minute() ) );
1766 list.insert( 5, tempstr.setNum( time.second() ) );
1768 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1773 if (!bLocaleInitialized && TDEGlobal::_locale) {
1811 d =
new TDEConfigBasePrivate();
1814 d->readDefaults = b;
1819 return (d && d->readDefaults);
1829 if (!
locale().isNull()) {
1831 aEntryKey.bLocal =
true;
1833 if (entry.mValue.isNull())
1837 putData(aEntryKey, entry,
true);
1838 aEntryKey.bLocal =
false;
1843 if (entry.mValue.isNull())
1846 putData(aEntryKey, entry,
true);
1854 if (!
locale().isNull()) {
1856 aEntryKey.bLocal =
true;
1858 if (!entry.mValue.isNull())
1861 aEntryKey.bLocal =
false;
1866 if (!entry.mValue.isNull())
1878 bLocaleInitialized =
true;
1879 bReadOnly = mMaster->bReadOnly;
1891 bLocaleInitialized =
true;
1892 bReadOnly = mMaster->bReadOnly;
1904 bLocaleInitialized =
true;
1905 bReadOnly = mMaster->bReadOnly;
1925 mMaster->setDirty(_bDirty);
1930 mMaster->putData(_key, _data, _checkGroup);
1935 return mMaster->lookupData(_key);
1943 void TDEConfigBase::virtual_hook(
int,
void* )
1946 void TDEConfigGroup::virtual_hook(
int id,
void* data )
1947 { TDEConfigBase::virtual_hook(
id, data ); }
1957 #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...