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
51 : backEnd(0L), bDirty(false), bLocaleInitialized(false),
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;
122 aEntryKey.bLocal =
true;
124 if (!entry.mValue.isNull())
126 aEntryKey.bLocal =
false;
131 return !entry.mValue.isNull();
134 bool TDEConfigBase::hasTranslatedKey(
const char* pKey)
const
137 aEntryKey.c_key = pKey;
142 aEntryKey.bLocal =
true;
144 if (!entry.mValue.isNull())
146 aEntryKey.bLocal =
false;
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:
492 TQStrList &list,
char sep )
const
498 TQStrList &list,
char sep )
const
503 TQCString str_list = readEntryUtf8( pKey );
504 if (str_list.isEmpty())
508 TQCString value =
"";
509 int len = str_list.length();
511 for (
int i = 0; i < len; i++) {
512 if (str_list[i] != sep && str_list[i] !=
'\\') {
513 value += str_list[i];
516 if (str_list[i] ==
'\\') {
519 value += str_list[i];
527 list.append( value );
531 if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] ==
'\\' ) )
532 list.append( value );
549 if( str_list.isEmpty() )
551 TQString value(emptyString);
552 int len = str_list.length();
554 value.reserve( len );
555 for(
int i = 0; i < len; i++ )
557 if( str_list[i] != sep && str_list[i] !=
'\\' )
559 value += str_list[i];
562 if( str_list[i] ==
'\\' )
566 value += str_list[i];
569 TQString finalvalue( value );
570 finalvalue.squeeze();
571 list.append( finalvalue );
574 if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] ==
'\\' ) )
577 list.append( value );
599 TQValueList<int> list;
600 TQStringList::ConstIterator end(strlist.end());
601 for (TQStringList::ConstIterator it = strlist.begin(); it != end; ++it)
604 list << (*it).toInt();
616 const bool bExpandSave = bExpand;
618 TQString aValue =
readEntry( pKey, pDefault );
619 bExpand = bExpandSave;
630 const bool bExpandSave = bExpand;
633 bExpand = bExpandSave;
644 TQCString aValue = readEntryUtf8( pKey );
645 if( aValue.isNull() )
647 else if( aValue ==
"true" || aValue ==
"on" || aValue ==
"yes" )
652 int rc = aValue.toInt( &ok );
653 return( ok ? rc : nDefault );
665 TQCString aValue = readEntryUtf8( pKey );
666 if( aValue.isNull() )
671 unsigned int rc = aValue.toUInt( &ok );
672 return( ok ? rc : nDefault );
684 TQCString aValue = readEntryUtf8( pKey );
685 if( aValue.isNull() )
690 long rc = aValue.toLong( &ok );
691 return( ok ? rc : nDefault );
703 TQCString aValue = readEntryUtf8( pKey );
704 if( aValue.isNull() )
709 unsigned long rc = aValue.toULong( &ok );
710 return( ok ? rc : nDefault );
723 if( aValue.isNull() )
728 TQ_INT64 rc = aValue.toLongLong( &ok );
729 return( ok ? rc : nDefault );
743 if( aValue.isNull() )
748 TQ_UINT64 rc = aValue.toULongLong( &ok );
749 return( ok ? rc : nDefault );
760 TQCString aValue = readEntryUtf8( pKey );
761 if( aValue.isNull() )
766 double rc = aValue.toDouble( &ok );
767 return( ok ? rc : nDefault );
779 TQCString aValue = readEntryUtf8( pKey );
781 if( aValue.isNull() )
785 if( aValue ==
"true" || aValue ==
"on" || aValue ==
"yes" || aValue ==
"1" )
790 int val = aValue.toInt( &bOK );
791 if( bOK && val != 0 )
809 if( !aValue.isNull() ) {
810 if ( aValue.contains(
',' ) > 5 ) {
812 if ( !aRetFont.fromString( aValue ) && pDefault )
813 aRetFont = *pDefault;
819 int nIndex = aValue.find(
',' );
822 aRetFont = *pDefault;
825 aRetFont.setFamily( aValue.left( nIndex ) );
828 int nOldIndex = nIndex;
829 nIndex = aValue.find(
',', nOldIndex+1 );
832 aRetFont = *pDefault;
836 aRetFont.setPointSize( aValue.mid( nOldIndex+1,
837 nIndex-nOldIndex-1 ).toInt() );
841 nIndex = aValue.find(
',', nOldIndex+1 );
845 aRetFont = *pDefault;
849 aRetFont.setStyleHint( (TQFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() );
853 nIndex = aValue.find(
',', nOldIndex+1 );
857 aRetFont = *pDefault;
861 TQString chStr=aValue.mid( nOldIndex+1,
862 nIndex-nOldIndex-1 );
865 nIndex = aValue.find(
',', nOldIndex+1 );
869 aRetFont = *pDefault;
873 aRetFont.setWeight( aValue.mid( nOldIndex+1,
874 nIndex-nOldIndex-1 ).toUInt() );
877 uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt();
879 aRetFont.setItalic( nFontBits & 0x01 );
880 aRetFont.setUnderline( nFontBits & 0x02 );
881 aRetFont.setStrikeOut( nFontBits & 0x04 );
882 aRetFont.setFixedPitch( nFontBits & 0x08 );
883 aRetFont.setRawMode( nFontBits & 0x20 );
889 aRetFont = *pDefault;
903 TQCString aValue = readEntryUtf8(pKey);
905 if (!aValue.isEmpty())
907 int left, top, width, height;
909 if (sscanf(aValue.data(),
"%d,%d,%d,%d", &left, &top, &width, &height) == 4)
911 return TQRect(left, top, width, height);
921 const TQPoint* pDefault )
const
927 const TQPoint* pDefault )
const
929 TQCString aValue = readEntryUtf8(pKey);
931 if (!aValue.isEmpty())
935 if (sscanf(aValue.data(),
"%d,%d", &x, &y) == 2)
946 const TQSize* pDefault )
const
952 const TQSize* pDefault )
const
954 TQCString aValue = readEntryUtf8(pKey);
956 if (!aValue.isEmpty())
960 if (sscanf(aValue.data(),
"%d,%d", &width, &height) == 2)
962 return TQSize(width, height);
972 const TQColor* pDefault )
const
978 const TQColor* pDefault )
const
981 int nRed = 0, nGreen = 0, nBlue = 0;
984 if( !aValue.isEmpty() )
986 if ( aValue.at(0) == (QChar)
'#' )
988 aRetColor.setNamedColor(aValue);
996 int nIndex = aValue.find(
',' );
1001 aRetColor = *pDefault;
1005 nRed = aValue.left( nIndex ).toInt( &bOK );
1008 int nOldIndex = nIndex;
1009 nIndex = aValue.find(
',', nOldIndex+1 );
1014 aRetColor = *pDefault;
1017 nGreen = aValue.mid( nOldIndex+1,
1018 nIndex-nOldIndex-1 ).toInt( &bOK );
1021 nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK );
1023 aRetColor.setRgb( nRed, nGreen, nBlue );
1029 aRetColor = *pDefault;
1037 const TQDateTime* pDefault )
const
1044 const TQDateTime* pDefault )
const
1051 return TQDateTime::currentDateTime();
1057 TQDate date( atoi( list.at( 0 ) ), atoi( list.at( 1 ) ),
1058 atoi( list.at( 2 ) ) );
1059 TQTime time( atoi( list.at( 3 ) ), atoi( list.at( 4 ) ),
1060 atoi( list.at( 5 ) ) );
1062 return TQDateTime( date, time );
1065 return TQDateTime::currentDateTime();
1073 writeEntry(pKey.utf8().data(), value, bPersistent, bGlobal, bNLS);
1081 writeEntry(pKey, value, bPersistent, bGlobal, bNLS,
false);
1102 entryKey.bLocal = bNLS;
1105 aEntryData.mValue = value.utf8();
1107 aEntryData.
bNLS = bNLS;
1111 aEntryData.
bDirty =
true;
1114 putData(entryKey, aEntryData,
true);
1118 bool bPersistent,
bool bGlobal,
1121 writePathEntry(pKey.utf8().data(), path, bPersistent, bGlobal, bNLS);
1125 static bool cleanHomeDirPath( TQString &path,
const TQString &homeDir )
1127 #ifdef Q_WS_WIN //safer
1128 if (!TQDir::convertSeparators(path).startsWith(TQDir::convertSeparators(homeDir)))
1131 if (!path.startsWith(homeDir))
1135 unsigned int len = homeDir.length();
1137 if (len && (path.length() == len || path[len] ==
'/')) {
1138 path.replace(0, len, TQString::fromLatin1(
"$HOME"));
1144 static TQString translatePath( TQString path )
1150 path.replace(
'$',
"$$");
1152 bool startsWithFile = path.startsWith(
"file:",
false);
1156 if (((!startsWithFile) && (path[0] !=
'/')) || (startsWithFile && (path[5] !=
'/'))) {
1160 if (startsWithFile) {
1165 while (path[0] ==
'/' && path[1] ==
'/') {
1173 TQString homeDir0 = TQFile::decodeName(getenv(
"HOME"));
1174 TQString homeDir1 = TQDir::homeDirPath();
1175 TQString homeDir2 = TQDir(homeDir1).canonicalPath();
1176 if (cleanHomeDirPath(path, homeDir0) ||
1177 cleanHomeDirPath(path, homeDir1) ||
1178 cleanHomeDirPath(path, homeDir2) ) {
1183 path.prepend(
"file://" );
1189 bool bPersistent,
bool bGlobal,
1192 writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS,
true);
1196 bool bPersistent,
bool bGlobal,
1197 bool bNLS,
bool expand)
1199 writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS, expand);
1203 char sep ,
bool bPersistent,
1204 bool bGlobal,
bool bNLS )
1206 writePathEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1210 char sep ,
bool bPersistent,
1211 bool bGlobal,
bool bNLS )
1213 if( list.isEmpty() )
1215 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1218 TQStringList new_list;
1219 TQStringList::ConstIterator it = list.begin();
1220 for( ; it != list.end(); ++it )
1222 TQString value = *it;
1223 new_list.append( translatePath(value) );
1225 writeEntry( pKey, new_list, sep, bPersistent, bGlobal, bNLS,
true );
1253 aEntryData.
bNLS = bNLS;
1254 aEntryData.
bDirty =
true;
1258 putData(entryKey, aEntryData,
true);
1267 return aEntryMap.isEmpty();
1271 bool checkGroup =
true;
1273 KEntryMapIterator aIt;
1274 for (aIt = aEntryMap.begin(); aIt != aEntryMap.end(); ++aIt)
1276 if (!aIt.key().mKey.isEmpty() && !aIt.key().bDefault && !(*aIt).bDeleted)
1278 (*aIt).bDeleted =
true;
1279 (*aIt).bDirty =
true;
1280 (*aIt).bGlobal = bGlobal;
1282 putData(aIt.key(), *aIt, checkGroup);
1294 bool bGlobal,
bool bNLS )
1296 writeEntry(pKey.utf8().data(), prop, bPersistent, bGlobal, bNLS);
1301 bool bGlobal,
bool bNLS )
1303 switch( prop.type() )
1305 case TQVariant::Invalid:
1306 writeEntry( pKey,
"", bPersistent, bGlobal, bNLS );
1308 case TQVariant::String:
1309 writeEntry( pKey, prop.toString(), bPersistent, bGlobal, bNLS );
1311 case TQVariant::StringList:
1312 writeEntry( pKey, prop.toStringList(),
',', bPersistent, bGlobal, bNLS );
1314 case TQVariant::List: {
1315 TQValueList<TQVariant> list = prop.toList();
1316 TQValueList<TQVariant>::ConstIterator it = list.begin();
1317 TQValueList<TQVariant>::ConstIterator end = list.end();
1318 TQStringList strList;
1320 for (; it != end; ++it )
1321 strList.append( (*it).toString() );
1323 writeEntry( pKey, strList,
',', bPersistent, bGlobal, bNLS );
1327 case TQVariant::Font:
1328 writeEntry( pKey, prop.toFont(), bPersistent, bGlobal, bNLS );
1330 case TQVariant::Point:
1331 writeEntry( pKey, prop.toPoint(), bPersistent, bGlobal, bNLS );
1333 case TQVariant::Rect:
1334 writeEntry( pKey, prop.toRect(), bPersistent, bGlobal, bNLS );
1336 case TQVariant::Size:
1337 writeEntry( pKey, prop.toSize(), bPersistent, bGlobal, bNLS );
1339 case TQVariant::Color:
1340 writeEntry( pKey, prop.toColor(), bPersistent, bGlobal, bNLS );
1342 case TQVariant::Int:
1343 writeEntry( pKey, prop.toInt(), bPersistent, bGlobal, bNLS );
1345 case TQVariant::UInt:
1346 writeEntry( pKey, prop.toUInt(), bPersistent, bGlobal, bNLS );
1348 case TQVariant::LongLong:
1349 writeEntry( pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS );
1351 case TQVariant::ULongLong:
1352 writeEntry( pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS );
1354 case TQVariant::Bool:
1355 writeEntry( pKey, prop.toBool(), bPersistent, bGlobal, bNLS );
1357 case TQVariant::Double:
1358 writeEntry( pKey, prop.toDouble(), bPersistent, bGlobal,
'g', 6, bNLS );
1360 case TQVariant::DateTime:
1361 writeEntry( pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS);
1363 case TQVariant::Date:
1364 writeEntry( pKey, TQDateTime(prop.toDate()), bPersistent, bGlobal, bNLS);
1367 case TQVariant::Pixmap:
1368 case TQVariant::Image:
1369 case TQVariant::Brush:
1370 case TQVariant::Palette:
1371 case TQVariant::ColorGroup:
1372 case TQVariant::Map:
1373 case TQVariant::IconSet:
1374 case TQVariant::CString:
1375 case TQVariant::PointArray:
1376 case TQVariant::Region:
1377 case TQVariant::Bitmap:
1378 case TQVariant::Cursor:
1379 case TQVariant::SizePolicy:
1380 case TQVariant::Time:
1382 case TQVariant::ByteArray:
1384 case TQVariant::BitArray:
1385 case TQVariant::KeySequence:
1386 case TQVariant::Pen:
1388 case TQVariant::Char:
1389 case TQVariant::Url:
1390 case TQVariant::Locale:
1391 case TQVariant::RectF:
1392 case TQVariant::SizeF:
1393 case TQVariant::Line:
1394 case TQVariant::LineF:
1395 case TQVariant::PointF:
1396 case TQVariant::RegExp:
1397 case TQVariant::Hash:
1398 case TQVariant::TextLength:
1399 case QVariant::TextFormat:
1400 case TQVariant::Matrix:
1401 case TQVariant::Transform:
1402 case TQVariant::Matrix4x4:
1403 case TQVariant::Vector2D:
1404 case TQVariant::Vector3D:
1405 case TQVariant::Vector4D:
1406 case TQVariant::Quaternion:
1407 case TQVariant::UserType:
1418 char sep ,
bool bPersistent,
1419 bool bGlobal,
bool bNLS )
1421 writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1425 char sep ,
bool bPersistent,
1426 bool bGlobal,
bool bNLS )
1428 if( list.isEmpty() )
1430 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1434 TQStrListIterator it( list );
1435 for( ; it.current(); ++it )
1443 uint strLengh(value.length());
1444 for( i = 0; i < strLengh; i++ )
1446 if( value[i] == sep || value[i] ==
'\\' )
1448 str_list += value[i];
1452 if( str_list.at(str_list.length() - 1) == (QChar)sep )
1453 str_list.truncate( str_list.length() -1 );
1454 writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS );
1458 char sep ,
bool bPersistent,
1459 bool bGlobal,
bool bNLS )
1461 writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1465 char sep ,
bool bPersistent,
1466 bool bGlobal,
bool bNLS )
1468 writeEntry(pKey, list, sep, bPersistent, bGlobal, bNLS,
false);
1472 char sep,
bool bPersistent,
1473 bool bGlobal,
bool bNLS,
bool bExpand )
1475 if( list.isEmpty() )
1477 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1481 str_list.reserve( 4096 );
1482 TQStringList::ConstIterator it = list.begin();
1483 for( ; it != list.end(); ++it )
1485 TQString value = *it;
1487 uint strLength(value.length());
1488 for( i = 0; i < strLength; i++ )
1490 if( value[i] == sep || value[i] ==
'\\' )
1492 str_list += value[i];
1496 if( str_list.at(str_list.length() - 1) == (QChar)sep )
1497 str_list.truncate( str_list.length() -1 );
1498 writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS, bExpand );
1502 bool bPersistent,
bool bGlobal,
bool bNLS )
1504 writeEntry(pKey.utf8().data(), list, bPersistent, bGlobal, bNLS);
1508 bool bPersistent,
bool bGlobal,
bool bNLS )
1510 TQStringList strlist;
1511 TQValueList<int>::ConstIterator end = list.end();
1512 for (TQValueList<int>::ConstIterator it = list.begin(); it != end; it++)
1513 strlist << TQString::number(*it);
1514 writeEntry(pKey, strlist,
',', bPersistent, bGlobal, bNLS );
1518 bool bPersistent,
bool bGlobal,
1521 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1525 bool bPersistent,
bool bGlobal,
1528 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1533 bool bPersistent,
bool bGlobal,
1536 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1540 bool bPersistent,
bool bGlobal,
1543 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1548 bool bPersistent,
bool bGlobal,
1551 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1555 bool bPersistent,
bool bGlobal,
1558 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1563 bool bPersistent,
bool bGlobal,
1566 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1570 bool bPersistent,
bool bGlobal,
1573 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1577 bool bPersistent,
bool bGlobal,
1580 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1584 bool bPersistent,
bool bGlobal,
1587 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1592 bool bPersistent,
bool bGlobal,
1595 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1599 bool bPersistent,
bool bGlobal,
1602 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1606 bool bPersistent,
bool bGlobal,
1607 char format,
int precision,
1610 writeEntry( pKey, TQString::number(nValue, format, precision),
1611 bPersistent, bGlobal, bNLS );
1615 bool bPersistent,
bool bGlobal,
1616 char format,
int precision,
1619 writeEntry( pKey, TQString::number(nValue, format, precision),
1620 bPersistent, bGlobal, bNLS );
1629 writeEntry(pKey.utf8().data(), bValue, bPersistent, bGlobal, bNLS);
1644 writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1649 bool bPersistent,
bool bGlobal,
1652 writeEntry(pKey.utf8().data(), rFont, bPersistent, bGlobal, bNLS);
1656 bool bPersistent,
bool bGlobal,
1659 writeEntry( pKey, TQString(rFont.toString()), bPersistent, bGlobal, bNLS );
1664 bool bPersistent,
bool bGlobal,
1667 writeEntry(pKey.utf8().data(), rRect, bPersistent, bGlobal, bNLS);
1671 bool bPersistent,
bool bGlobal,
1676 list.insert( 0, tempstr.setNum( rRect.left() ) );
1677 list.insert( 1, tempstr.setNum( rRect.top() ) );
1678 list.insert( 2, tempstr.setNum( rRect.width() ) );
1679 list.insert( 3, tempstr.setNum( rRect.height() ) );
1681 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1686 bool bPersistent,
bool bGlobal,
1689 writeEntry(pKey.utf8().data(), rPoint, bPersistent, bGlobal, bNLS);
1693 bool bPersistent,
bool bGlobal,
1698 list.insert( 0, tempstr.setNum( rPoint.x() ) );
1699 list.insert( 1, tempstr.setNum( rPoint.y() ) );
1701 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1706 bool bPersistent,
bool bGlobal,
1709 writeEntry(pKey.utf8().data(), rSize, bPersistent, bGlobal, bNLS);
1713 bool bPersistent,
bool bGlobal,
1718 list.insert( 0, tempstr.setNum( rSize.width() ) );
1719 list.insert( 1, tempstr.setNum( rSize.height() ) );
1721 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1729 writeEntry( pKey.utf8().data(), rColor, bPersistent, bGlobal, bNLS);
1738 if (rColor.isValid())
1739 aValue.sprintf(
"%d,%d,%d", rColor.red(), rColor.green(), rColor.blue() );
1743 writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1747 bool bPersistent,
bool bGlobal,
1750 writeEntry(pKey.utf8().data(), rDateTime, bPersistent, bGlobal, bNLS);
1754 bool bPersistent,
bool bGlobal,
1760 TQTime time = TQT_TQTIME_OBJECT(rDateTime.time());
1761 TQDate date = TQT_TQDATE_OBJECT(rDateTime.date());
1763 list.insert( 0, tempstr.setNum( date.year() ) );
1764 list.insert( 1, tempstr.setNum( date.month() ) );
1765 list.insert( 2, tempstr.setNum( date.day() ) );
1767 list.insert( 3, tempstr.setNum( time.hour() ) );
1768 list.insert( 4, tempstr.setNum( time.minute() ) );
1769 list.insert( 5, tempstr.setNum( time.second() ) );
1771 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1776 if (!bLocaleInitialized && TDEGlobal::_locale) {
1814 d =
new TDEConfigBasePrivate();
1817 d->readDefaults = b;
1822 return (d && d->readDefaults);
1832 if (!
locale().isNull()) {
1834 aEntryKey.bLocal =
true;
1836 if (entry.mValue.isNull())
1840 putData(aEntryKey, entry,
true);
1841 aEntryKey.bLocal =
false;
1846 if (entry.mValue.isNull())
1849 putData(aEntryKey, entry,
true);
1857 if (!
locale().isNull()) {
1859 aEntryKey.bLocal =
true;
1861 if (!entry.mValue.isNull())
1864 aEntryKey.bLocal =
false;
1869 if (!entry.mValue.isNull())
1881 bLocaleInitialized =
true;
1882 bReadOnly = mMaster->bReadOnly;
1894 bLocaleInitialized =
true;
1895 bReadOnly = mMaster->bReadOnly;
1907 bLocaleInitialized =
true;
1908 bReadOnly = mMaster->bReadOnly;
1933 mMaster->
putData(_key, _data, _checkGroup);
1946 void TDEConfigBase::virtual_hook(
int,
void* )
1949 void TDEConfigGroup::virtual_hook(
int id,
void* data )
1950 { TDEConfigBase::virtual_hook(
id, data ); }
1960 #include "tdeconfigbase.moc"
bool groupIsImmutable() const
Checks whether it is possible to change this 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 TDEConfigBase::ConfigState getConfigState() const
Returns the state of the app-config object.
TQString language() const
Returns the language used by this object.
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage...
TQValueList< int > readIntListEntry(const TQString &pKey) const
Reads a list of Integers.
virtual KEntryMap internalEntryMap() const =0
Returns a map (tree) of the entries in the tree.
static TQString downloadPath()
The path where documents are stored of the current user.
bool hasKey(const TQString &key) const
Checks whether the key has an entry in the currently active group.
bool bDeleted
Entry has been deleted.
TQString readEntryUntranslated(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
map/dict/list config node entry.
virtual ~TDEConfigBase()
Destructs the TDEConfigBase object.
TQFont readFontEntry(const TQString &pKey, const TQFont *pDefault=0L) const
Reads a TQFont value.
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.
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.
virtual void setDirty(bool _bDirty=true)
Sets the global dirty flag of the config object.
static TQString defaultLanguage()
Returns the name of the internal language.
static TQString picturesPath()
The path where documents are stored of the current user.
bool groupIsImmutable(const TQString &group) const
Checks whether it is possible to change the given group.
int readListEntry(const TQString &pKey, TQStrList &list, char sep= ',') const
Reads a list of strings.
static TQString from8Bit(const char *str)
Construct TQString from a c string, guessing whether it is UTF8- or Local8Bit-encoded.
TQStringList readPathListEntry(const TQString &pKey, char sep= ',') const
Reads a list of string paths.
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.
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
TDEConfigBase()
Construct a TDEConfigBase object.
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 KEntry lookupData(const KEntryKey &_key) const
Looks up an entry in the config object's internal structure.
virtual void rollback(bool bDeep=true)
Mark the config object as "clean," i.e.
bool readDefaults() const
TQString locale() const
Returns a the current locale.
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.
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
Reads a boolean entry.
virtual void parseConfigFiles()
Parses all configuration files for a configuration object.
TQPoint readPointEntry(const TQString &pKey, const TQPoint *pDefault=0L) const
Reads a TQPoint entry.
static TQString templatesPath()
The path where templates are stored of the current user.
bool bLocal
Entry is localised or not.
virtual void setDirty(bool _bDirty)
Sets the global dirty flag of the config object.
TQSize readSizeEntry(const TQString &pKey, const TQSize *pDefault=0L) const
Reads a TQSize entry.
TDEConfigGroup(TDEConfigBase *master, const TQCString &group)
Construct a config group corresponding to group in master.
static TQString publicSharePath()
The path of the public share of the current user.
unsigned int readUnsignedNumEntry(const TQString &pKey, unsigned int nDefault=0) const
Reads an unsigned numerical value.
ConfigState
Possible return values for getConfigState().
TQDateTime readDateTimeEntry(const TQString &pKey, const TQDateTime *pDefault=0L) const
Reads a TQDateTime entry.
static const TQString & staticQString(const char *str)
Creates a static TQString.
void setLocaleString(const TQCString &_localeString)
Set the locale string that defines the current language.
bool hasDefault(const TQString &key) const
Returns whether a default is specified for an entry in either the system wide configuration file or t...
unsigned long readUnsignedLongNumEntry(const TQString &pKey, unsigned long nDefault=0) const
Read an unsigned numerical value.
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 entryIsImmutable(const TQString &key) const
Checks whether it is possible to change the given entry.
TQRect readRectEntry(const TQString &pKey, const TQRect *pDefault=0L) const
Reads a TQRect entry.
double readDoubleNumEntry(const TQString &pKey, double nDefault=0.0) const
Reads a floating point value.
TQ_UINT64 readUnsignedNum64Entry(const TQString &pKey, TQ_UINT64 nDefault=0) const
Read an 64-bit unsigned numerical value.
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
bool bNLS
Entry should be written with locale tag.
TQString group() const
Returns the name of the group in which we are searching for keys and from which we are retrieving ent...
TQColor readColorEntry(const TQString &pKey, const TQColor *pDefault=0L) const
Reads a TQColor entry.
TDEConfigBackEnd * backEnd
A back end for loading/saving to disk in a particular format.
TQ_INT64 readNum64Entry(const TQString &pKey, TQ_INT64 nDefault=0) const
Reads a 64-bit numerical value.
bool hasGroup(const TQString &group) const
Returns true if the specified group is known about.
bool isImmutable() const
Checks whether this configuration file can be modified.
TQString readPathEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads a path.
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.
TQVariant readPropertyEntry(const TQString &pKey, TQVariant::Type) const
Reads the value of an entry specified by pKey in the current group.
void revertToDefault(const TQString &key)
Reverts the entry with key key in the current group in the application specific config file to either...
long readLongNumEntry(const TQString &pKey, long nDefault=0) const
Reads a numerical value.
static TQString musicPath()
The path where documents are stored 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.
void setReadDefaults(bool b)
When set, all readEntry and readXXXEntry calls return the system wide (default) values instead of the...
TQCString mGroup
The currently selected group.
bool bExpand
Whether to apply dollar expansion or not.
bool isReadOnly() const
Returns the read-only status of the config object.
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 bDirty
Must the entry be written back to disk?
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage...
int readNumEntry(const TQString &pKey, int nDefault=0) const
Reads a numerical value.
ConfigState getConfigState() const
Returns the state of the app-config object.