28 #include <tqtextstream.h>
30 #include <kapplication.h>
31 #include <kglobalsettings.h>
34 #include <kcharsets.h>
36 #include "kconfigbase.h"
37 #include "kconfigbackend.h"
39 #include "kstandarddirs.h"
40 #include "kstringhandler.h"
42 class KConfigBase::KConfigBasePrivate
52 : backEnd(0L), bDirty(false), bLocaleInitialized(false),
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;
123 aEntryKey.bLocal =
true;
125 if (!entry.mValue.isNull())
127 aEntryKey.bLocal =
false;
132 return !entry.mValue.isNull();
135 bool KConfigBase::hasTranslatedKey(
const char* pKey)
const
138 aEntryKey.c_key = pKey;
143 aEntryKey.bLocal =
true;
145 if (!entry.mValue.isNull())
147 aEntryKey.bLocal =
false;
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 && KGlobal::_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 KConfigBase::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);
1101 entryKey.bLocal = bNLS;
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 char sep ,
bool bPersistent,
1196 bool bGlobal,
bool bNLS )
1198 writePathEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1202 char sep ,
bool bPersistent,
1203 bool bGlobal,
bool bNLS )
1205 if( list.isEmpty() )
1207 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1210 TQStringList new_list;
1211 TQStringList::ConstIterator it = list.begin();
1212 for( ; it != list.end(); ++it )
1214 TQString value = *it;
1215 new_list.append( translatePath(value) );
1217 writeEntry( pKey, new_list, sep, bPersistent, bGlobal, bNLS,
true );
1245 aEntryData.
bNLS = bNLS;
1246 aEntryData.
bDirty =
true;
1250 putData(entryKey, aEntryData,
true);
1259 return aEntryMap.isEmpty();
1263 bool checkGroup =
true;
1265 KEntryMapIterator aIt;
1266 for (aIt = aEntryMap.begin(); aIt != aEntryMap.end(); ++aIt)
1268 if (!aIt.key().mKey.isEmpty() && !aIt.key().bDefault && !(*aIt).bDeleted)
1270 (*aIt).bDeleted =
true;
1271 (*aIt).bDirty =
true;
1272 (*aIt).bGlobal = bGlobal;
1274 putData(aIt.key(), *aIt, checkGroup);
1286 bool bGlobal,
bool bNLS )
1288 writeEntry(pKey.utf8().data(), prop, bPersistent, bGlobal, bNLS);
1293 bool bGlobal,
bool bNLS )
1295 switch( prop.type() )
1297 case TQVariant::Invalid:
1298 writeEntry( pKey,
"", bPersistent, bGlobal, bNLS );
1300 case TQVariant::String:
1301 writeEntry( pKey, prop.toString(), bPersistent, bGlobal, bNLS );
1303 case TQVariant::StringList:
1304 writeEntry( pKey, prop.toStringList(),
',', bPersistent, bGlobal, bNLS );
1306 case TQVariant::List: {
1307 TQValueList<TQVariant> list = prop.toList();
1308 TQValueList<TQVariant>::ConstIterator it = list.begin();
1309 TQValueList<TQVariant>::ConstIterator end = list.end();
1310 TQStringList strList;
1312 for (; it != end; ++it )
1313 strList.append( (*it).toString() );
1315 writeEntry( pKey, strList,
',', bPersistent, bGlobal, bNLS );
1319 case TQVariant::Font:
1320 writeEntry( pKey, prop.toFont(), bPersistent, bGlobal, bNLS );
1322 case TQVariant::Point:
1323 writeEntry( pKey, prop.toPoint(), bPersistent, bGlobal, bNLS );
1325 case TQVariant::Rect:
1326 writeEntry( pKey, prop.toRect(), bPersistent, bGlobal, bNLS );
1328 case TQVariant::Size:
1329 writeEntry( pKey, prop.toSize(), bPersistent, bGlobal, bNLS );
1331 case TQVariant::Color:
1332 writeEntry( pKey, prop.toColor(), bPersistent, bGlobal, bNLS );
1334 case TQVariant::Int:
1335 writeEntry( pKey, prop.toInt(), bPersistent, bGlobal, bNLS );
1337 case TQVariant::UInt:
1338 writeEntry( pKey, prop.toUInt(), bPersistent, bGlobal, bNLS );
1340 case TQVariant::LongLong:
1341 writeEntry( pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS );
1343 case TQVariant::ULongLong:
1344 writeEntry( pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS );
1346 case TQVariant::Bool:
1347 writeEntry( pKey, prop.toBool(), bPersistent, bGlobal, bNLS );
1349 case TQVariant::Double:
1350 writeEntry( pKey, prop.toDouble(), bPersistent, bGlobal,
'g', 6, bNLS );
1352 case TQVariant::DateTime:
1353 writeEntry( pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS);
1355 case TQVariant::Date:
1356 writeEntry( pKey, TQDateTime(prop.toDate()), bPersistent, bGlobal, bNLS);
1359 case TQVariant::Pixmap:
1360 case TQVariant::Image:
1361 case TQVariant::Brush:
1362 case TQVariant::Palette:
1363 case TQVariant::ColorGroup:
1364 case TQVariant::Map:
1365 case TQVariant::IconSet:
1366 case TQVariant::CString:
1367 case TQVariant::PointArray:
1368 case TQVariant::Region:
1369 case TQVariant::Bitmap:
1370 case TQVariant::Cursor:
1371 case TQVariant::SizePolicy:
1372 case TQVariant::Time:
1374 case TQVariant::ByteArray:
1376 case TQVariant::BitArray:
1377 case TQVariant::KeySequence:
1378 case TQVariant::Pen:
1380 case TQVariant::Char:
1381 case TQVariant::Url:
1382 case TQVariant::Locale:
1383 case TQVariant::RectF:
1384 case TQVariant::SizeF:
1385 case TQVariant::Line:
1386 case TQVariant::LineF:
1387 case TQVariant::PointF:
1388 case TQVariant::RegExp:
1389 case TQVariant::Hash:
1390 case TQVariant::TextLength:
1391 case QVariant::TextFormat:
1392 case TQVariant::Matrix:
1393 case TQVariant::Transform:
1394 case TQVariant::Matrix4x4:
1395 case TQVariant::Vector2D:
1396 case TQVariant::Vector3D:
1397 case TQVariant::Vector4D:
1398 case TQVariant::Quaternion:
1399 case TQVariant::UserType:
1408 char sep ,
bool bPersistent,
1409 bool bGlobal,
bool bNLS )
1411 writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1415 char sep ,
bool bPersistent,
1416 bool bGlobal,
bool bNLS )
1418 if( list.isEmpty() )
1420 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1424 TQStrListIterator it( list );
1425 for( ; it.current(); ++it )
1433 uint strLengh(value.length());
1434 for( i = 0; i < strLengh; i++ )
1436 if( value[i] == sep || value[i] ==
'\\' )
1438 str_list += value[i];
1442 if( str_list.at(str_list.length() - 1) == (QChar)sep )
1443 str_list.truncate( str_list.length() -1 );
1444 writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS );
1448 char sep ,
bool bPersistent,
1449 bool bGlobal,
bool bNLS )
1451 writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS);
1455 char sep ,
bool bPersistent,
1456 bool bGlobal,
bool bNLS )
1458 writeEntry(pKey, list, sep, bPersistent, bGlobal, bNLS,
false);
1462 char sep,
bool bPersistent,
1463 bool bGlobal,
bool bNLS,
bool bExpand )
1465 if( list.isEmpty() )
1467 writeEntry( pKey, TQString::fromLatin1(
""), bPersistent );
1471 str_list.reserve( 4096 );
1472 TQStringList::ConstIterator it = list.begin();
1473 for( ; it != list.end(); ++it )
1475 TQString value = *it;
1477 uint strLength(value.length());
1478 for( i = 0; i < strLength; i++ )
1480 if( value[i] == sep || value[i] ==
'\\' )
1482 str_list += value[i];
1486 if( str_list.at(str_list.length() - 1) == (QChar)sep )
1487 str_list.truncate( str_list.length() -1 );
1488 writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS, bExpand );
1492 bool bPersistent,
bool bGlobal,
bool bNLS )
1494 writeEntry(pKey.utf8().data(), list, bPersistent, bGlobal, bNLS);
1498 bool bPersistent,
bool bGlobal,
bool bNLS )
1500 TQStringList strlist;
1501 TQValueList<int>::ConstIterator end = list.end();
1502 for (TQValueList<int>::ConstIterator it = list.begin(); it != end; it++)
1503 strlist << TQString::number(*it);
1504 writeEntry(pKey, strlist,
',', bPersistent, bGlobal, bNLS );
1508 bool bPersistent,
bool bGlobal,
1511 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1515 bool bPersistent,
bool bGlobal,
1518 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1523 bool bPersistent,
bool bGlobal,
1526 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1530 bool bPersistent,
bool bGlobal,
1533 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1538 bool bPersistent,
bool bGlobal,
1541 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1545 bool bPersistent,
bool bGlobal,
1548 writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS );
1553 bool bPersistent,
bool bGlobal,
1556 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 );
1582 bool bPersistent,
bool bGlobal,
1585 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,
1597 char format,
int precision,
1600 writeEntry( pKey, TQString::number(nValue, format, precision),
1601 bPersistent, bGlobal, bNLS );
1605 bool bPersistent,
bool bGlobal,
1606 char format,
int precision,
1609 writeEntry( pKey, TQString::number(nValue, format, precision),
1610 bPersistent, bGlobal, bNLS );
1619 writeEntry(pKey.utf8().data(), bValue, bPersistent, bGlobal, bNLS);
1634 writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1639 bool bPersistent,
bool bGlobal,
1642 writeEntry(pKey.utf8().data(), rFont, bPersistent, bGlobal, bNLS);
1646 bool bPersistent,
bool bGlobal,
1649 writeEntry( pKey, TQString(rFont.toString()), bPersistent, bGlobal, bNLS );
1654 bool bPersistent,
bool bGlobal,
1657 writeEntry(pKey.utf8().data(), rRect, bPersistent, bGlobal, bNLS);
1661 bool bPersistent,
bool bGlobal,
1666 list.insert( 0, tempstr.setNum( rRect.left() ) );
1667 list.insert( 1, tempstr.setNum( rRect.top() ) );
1668 list.insert( 2, tempstr.setNum( rRect.width() ) );
1669 list.insert( 3, tempstr.setNum( rRect.height() ) );
1671 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1676 bool bPersistent,
bool bGlobal,
1679 writeEntry(pKey.utf8().data(), rPoint, bPersistent, bGlobal, bNLS);
1683 bool bPersistent,
bool bGlobal,
1688 list.insert( 0, tempstr.setNum( rPoint.x() ) );
1689 list.insert( 1, tempstr.setNum( rPoint.y() ) );
1691 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1696 bool bPersistent,
bool bGlobal,
1699 writeEntry(pKey.utf8().data(), rSize, bPersistent, bGlobal, bNLS);
1703 bool bPersistent,
bool bGlobal,
1708 list.insert( 0, tempstr.setNum( rSize.width() ) );
1709 list.insert( 1, tempstr.setNum( rSize.height() ) );
1711 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1719 writeEntry( pKey.utf8().data(), rColor, bPersistent, bGlobal, bNLS);
1728 if (rColor.isValid())
1729 aValue.sprintf(
"%d,%d,%d", rColor.red(), rColor.green(), rColor.blue() );
1733 writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
1737 bool bPersistent,
bool bGlobal,
1740 writeEntry(pKey.utf8().data(), rDateTime, bPersistent, bGlobal, bNLS);
1744 bool bPersistent,
bool bGlobal,
1750 TQTime time = TQT_TQTIME_OBJECT(rDateTime.time());
1751 TQDate date = TQT_TQDATE_OBJECT(rDateTime.date());
1753 list.insert( 0, tempstr.setNum( date.year() ) );
1754 list.insert( 1, tempstr.setNum( date.month() ) );
1755 list.insert( 2, tempstr.setNum( date.day() ) );
1757 list.insert( 3, tempstr.setNum( time.hour() ) );
1758 list.insert( 4, tempstr.setNum( time.minute() ) );
1759 list.insert( 5, tempstr.setNum( time.second() ) );
1761 writeEntry( pKey, list,
',', bPersistent, bGlobal, bNLS );
1766 if (!bLocaleInitialized && KGlobal::_locale) {
1804 d =
new KConfigBasePrivate();
1807 d->readDefaults = b;
1812 return (d && d->readDefaults);
1822 if (!
locale().isNull()) {
1824 aEntryKey.bLocal =
true;
1826 if (entry.mValue.isNull())
1830 putData(aEntryKey, entry,
true);
1831 aEntryKey.bLocal =
false;
1836 if (entry.mValue.isNull())
1839 putData(aEntryKey, entry,
true);
1847 if (!
locale().isNull()) {
1849 aEntryKey.bLocal =
true;
1851 if (!entry.mValue.isNull())
1854 aEntryKey.bLocal =
false;
1859 if (!entry.mValue.isNull())
1871 bLocaleInitialized =
true;
1872 bReadOnly = mMaster->bReadOnly;
1884 bLocaleInitialized =
true;
1885 bReadOnly = mMaster->bReadOnly;
1897 bLocaleInitialized =
true;
1898 bReadOnly = mMaster->bReadOnly;
1923 mMaster->
putData(_key, _data, _checkGroup);
1936 void KConfigBase::virtual_hook(
int,
void* )
1939 void KConfigGroup::virtual_hook(
int id,
void* data )
1940 { KConfigBase::virtual_hook(
id, data ); }
1950 #include "kconfigbase.moc"
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...
TQ_INT64 readNum64Entry(const TQString &pKey, TQ_INT64 nDefault=0) const
Reads a 64-bit numerical value.
void deleteEntry(const TQString &pKey, bool bNLS=false, bool bGlobal=false)
Deletes the entry specified by pKey in the current group.
long readLongNumEntry(const TQString &pKey, long nDefault=0) const
Reads a numerical value.
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
bool readDefaults() const
static KLocale * locale()
Returns the global locale object.
bool entryIsImmutable(const TQString &key) const
Checks whether it is possible to change the given entry.
static TQString musicPath()
The path where documents are stored of the current user.
TQRect readRectEntry(const TQString &pKey, const TQRect *pDefault=0L) const
Reads a TQRect entry.
ConfigState
Possible return values for getConfigState().
virtual KEntryMap internalEntryMap() const =0
Returns a map (tree) of the entries in the tree.
bool bDeleted
Entry has been deleted.
TQStringList readPathListEntry(const TQString &pKey, char sep= ',') const
Reads a list of string paths.
map/dict/list config node entry.
static TQString downloadPath()
The path where documents are stored of the current user.
bool isReadOnly() const
Returns the read-only status of the config object.
double readDoubleNumEntry(const TQString &pKey, double nDefault=0.0) const
Reads a floating point value.
unsigned long readUnsignedLongNumEntry(const TQString &pKey, unsigned long nDefault=0) const
Read an unsigned numerical value.
static const TQString & staticQString(const char *str)
Creates a static TQString.
bool bDefault
Entry indicates if this is a default value.
virtual void setDirty(bool _bDirty)
Sets the global dirty flag of the config object.
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a key/value pair.
static TQString from8Bit(const char *str)
Construct TQString from a c string, guessing whether it is UTF8- or Local8Bit-encoded.
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...
TQColor readColorEntry(const TQString &pKey, const TQColor *pDefault=0L) const
Reads a TQColor entry.
TQValueList< int > readIntListEntry(const TQString &pKey) const
Reads a list of Integers.
TQString locale() const
Returns a the current locale.
void setGroup(const TQString &group)
Specifies the group in which keys will be read and written.
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
virtual ~KConfigBase()
Destructs the KConfigBase object.
TQString readPathEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads a path.
TQString group() const
Returns the name of the group in which we are searching for keys and from which we are retrieving ent...
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
static TQString picturesPath()
The path where documents are stored of the current user.
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...
bool groupIsImmutable() const
Checks whether it is possible to change this group.
TQCString mGroup
The currently selected group.
virtual void setDirty(bool _bDirty=true)
Sets the global dirty flag of the config object.
virtual bool parseConfigFiles()=0
Parses all configuration files for a configuration object.
TQ_UINT64 readUnsignedNum64Entry(const TQString &pKey, TQ_UINT64 nDefault=0) const
Read an 64-bit unsigned numerical value.
bool groupIsImmutable(const TQString &group) const
Checks whether it is possible to change the given group.
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
Reads a boolean entry.
bool bImmutable
Entry can not be modified.
key structure holding both the actual key and the the group to which it belongs.
void setReadDefaults(bool b)
When set, all readEntry and readXXXEntry calls return the system wide (default) values instead of the...
TQString language() const
Returns the language used by this object.
void deleteGroup(bool bGlobal=false)
Delete all entries in the entire group.
static TQString desktopPath()
The path to the desktop directory of the current user.
bool bLocal
Entry is localised or not.
virtual void parseConfigFiles()
Parses all configuration files for a configuration object.
virtual KEntry lookupData(const KEntryKey &_key) const =0
Looks up an entry in the config object's internal structure.
static TQString publicSharePath()
The path of the public share of the current user.
KConfigBackEnd * backEnd
A back end for loading/saving to disk in a particular format.
bool deleteGroup(const TQString &group, bool bDeep=true, bool bGlobal=false)
Deletes a configuration entry group.
void setDesktopGroup()
Sets the group to the "Desktop Entry" group used for desktop configuration files for applications...
KDE Configuration Management abstract base class.
TQPoint readPointEntry(const TQString &pKey, const TQPoint *pDefault=0L) const
Reads a TQPoint entry.
static TQString documentPath()
The path where documents are stored of the current user.
KConfigGroup(KConfigBase *master, const TQCString &group)
Construct a config group corresponding to group in master.
TQDateTime readDateTimeEntry(const TQString &pKey, const TQDateTime *pDefault=0L) const
Reads a TQDateTime entry.
void setLocale()
Reads the locale and put in the configuration data struct.
TQSize readSizeEntry(const TQString &pKey, const TQSize *pDefault=0L) const
Reads a TQSize entry.
TQString readEntryUntranslated(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
static TQString videosPath()
The path where documents are stored of the current user.
virtual KConfigBase::ConfigState getConfigState() const
Returns the state of the app-config object.
bool bGlobal
Entry should be written to the global config file.
static TQString defaultLanguage()
Returns the name of the internal language.
bool hasKey(const TQString &key) const
Checks whether the key has an entry in the currently active group.
int readNumEntry(const TQString &pKey, int nDefault=0) const
Reads a numerical value.
bool bNLS
Entry should be written with locale tag.
virtual void sync(bool bMerge=true)=0
Writes configuration data to file(s).
static TQString templatesPath()
The path where templates are stored of the current user.
ConfigState getConfigState() const
Returns the state of the app-config object.
TQFont readFontEntry(const TQString &pKey, const TQFont *pDefault=0L) const
Reads a TQFont value.
virtual void rollback(bool bDeep=true)
Mark the config object as "clean," i.e.
TQCString aLocaleString
The locale to retrieve keys under if possible, i.e en_US or fr.
void writePathEntry(const TQString &pKey, const TQString &path, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a file path.
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage...
bool bDirty
Indicates whether there are any dirty entries in the config object that need to be written back to di...
unsigned int readUnsignedNumEntry(const TQString &pKey, unsigned int nDefault=0) const
Reads an unsigned numerical value.
void revertToDefault(const TQString &key)
Reverts the entry with key key in the current group in the application specific config file to either...
TQVariant readPropertyEntry(const TQString &pKey, TQVariant::Type) const
Reads the value of an entry specified by pKey in the current group.
bool hasGroup(const TQString &group) const
Returns true if the specified group is known about.
bool bExpand
Whether to apply dollar expansion or not.
void setLocaleString(const TQCString &_localeString)
Set the locale string that defines the current language.
bool bDirty
Must the entry be written back to disk?
int readListEntry(const TQString &pKey, TQStrList &list, char sep= ',') const
Reads a list of strings.
bool isImmutable() const
Checks whether this configuration file can be modified.
bool hasDefault(const TQString &key) const
Returns whether a default is specified for an entry in either the system wide configuration file or t...
KConfigBase()
Construct a KConfigBase object.