-rw-r--r-- | qmake/tools/qsettings.cpp | 365 |
1 files changed, 188 insertions, 177 deletions
diff --git a/qmake/tools/qsettings.cpp b/qmake/tools/qsettings.cpp index 35fc039..598e94b 100644 --- a/qmake/tools/qsettings.cpp +++ b/qmake/tools/qsettings.cpp | |||
@@ -1,3 +1,3 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** |
3 | ** | 3 | ** |
@@ -7,3 +7,3 @@ | |||
7 | ** | 7 | ** |
8 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. |
9 | ** | 9 | ** |
@@ -62,3 +62,5 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
62 | #include <private/qsettings_p.h> | 62 | #include <private/qsettings_p.h> |
63 | #ifndef NO_ERRNO_H | ||
63 | #include <errno.h> | 64 | #include <errno.h> |
65 | #endif | ||
64 | 66 | ||
@@ -103,3 +105,4 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
103 | 105 | ||
104 | A typical usage pattern for reading application startup: | 106 | A typical usage pattern for reading settings at application |
107 | startup: | ||
105 | \code | 108 | \code |
@@ -113,3 +116,4 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
113 | 116 | ||
114 | A typical usage pattern for application exit or 'save preferences': | 117 | A typical usage pattern for saving settings at application exit or |
118 | 'save preferences': | ||
115 | \code | 119 | \code |
@@ -123,4 +127,5 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
123 | 127 | ||
124 | QSettings can build a key prefix that is prepended to all keys. To | 128 | A key prefix can be prepended to all keys using beginGroup(). The |
125 | build the key prefix, use beginGroup() and endGroup(). | 129 | application of the prefix is stopped using endGroup(). For |
130 | example: | ||
126 | \code | 131 | \code |
@@ -156,4 +161,4 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
156 | 161 | ||
157 | Since settings for Windows are stored in the registry there are size | 162 | Since settings for Windows are stored in the registry there are |
158 | limits as follows: | 163 | some size limitations as follows: |
159 | \list | 164 | \list |
@@ -167,5 +172,5 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
167 | 172 | ||
168 | If you wish to use a different search path call insertSearchPath() | 173 | \warning Creating multiple, simultaneous instances of QSettings writing |
169 | as often as necessary to add your preferred paths. Call | 174 | to a text file may lead to data loss! This is a known issue which will |
170 | removeSearchPath() to remove any unwanted paths. | 175 | be fixed in a future release of Qt. |
171 | 176 | ||
@@ -173,12 +178,13 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
173 | 178 | ||
174 | Internal to the CFPreferences API it is not defined (for Mac OS 9 | 179 | The location where settings are stored is not formally defined by |
175 | support) where the settings will ultimitely be stored. However, at the | 180 | the CFPreferences API. |
176 | time of this writing the settings will be stored (either on a global or | 181 | |
177 | user basis, preferring locally) into a plist file in | 182 | At the time of writing settings are stored (either on a global or |
178 | $ROOT/System/Library/Preferences (in XML format). QSettings will create | 183 | user basis, preferring locally) into a plist file in \c |
179 | an appropriate plist file (com.<first group name>.plist) out of the | 184 | $ROOT/System/Library/Preferences (in XML format). QSettings will |
180 | full path to a key. | 185 | create an appropriate plist file (\c{com.<first group name>.plist}) |
186 | out of the full path to a key. | ||
181 | 187 | ||
182 | For further information on CFPreferences see also | 188 | For further information on CFPreferences see |
183 | \link http://developer.apple.com/techpubs/macosx/CoreFoundation/PreferenceServices/preferenceservices_carbon.html | 189 | \link http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFPreferences/index.html |
184 | Apple's Specifications\endlink | 190 | Apple's Specifications\endlink |
@@ -191,6 +197,6 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
191 | \list 1 | 197 | \list 1 |
192 | \i INSTALL/etc/settings | 198 | \i \c SYSCONF - the default value is \c INSTALL/etc/settings |
193 | \i /opt/MyCompany/share/etc | 199 | \i \c /opt/MyCompany/share/etc |
194 | \i /opt/MyCompany/share/MyApplication/etc | 200 | \i \c /opt/MyCompany/share/MyApplication/etc |
195 | \i $HOME/.qt | 201 | \i \c $HOME/.qt |
196 | \endlist | 202 | \endlist |
@@ -219,4 +225,4 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
219 | 225 | ||
220 | For cross-platform applications you should ensure that the Windows | 226 | For cross-platform applications you should ensure that the |
221 | size limitations are not exceeded. | 227 | \link #sizelimit Windows size limitations \endlink are not exceeded. |
222 | */ | 228 | */ |
@@ -312,41 +318,2 @@ static void closelock( HANDLE fd ) | |||
312 | } | 318 | } |
313 | #elif defined(Q_WS_WIN) | ||
314 | #define Q_LOCKREAD 1 | ||
315 | #define Q_LOCKWRITE 2 | ||
316 | |||
317 | static HANDLE openlock( const QString &name, int /*type*/ ) | ||
318 | { | ||
319 | if ( !QFile::exists( name ) ) | ||
320 | return 0; | ||
321 | |||
322 | return 0; | ||
323 | |||
324 | HANDLE fd = 0; | ||
325 | |||
326 | QT_WA( { | ||
327 | fd = CreateFileW( (TCHAR*)name.ucs2(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); | ||
328 | } , { | ||
329 | fd = CreateFileA( name.local8Bit(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); | ||
330 | } ); | ||
331 | |||
332 | if ( !LockFile( fd, 0, 0, (DWORD)-1, (DWORD)-1 ) ) { // ### (DWORD)-1 ??? | ||
333 | #ifdef QT_CHECK_STATE | ||
334 | qWarning( "QSettings: openlock failed!" ); | ||
335 | #endif | ||
336 | } | ||
337 | return fd; | ||
338 | } | ||
339 | |||
340 | static void closelock( HANDLE fd ) | ||
341 | { | ||
342 | if ( !fd ) | ||
343 | return; | ||
344 | |||
345 | if ( !UnlockFile( fd, 0, 0, (DWORD)-1, (DWORD)-1 ) ) { // ### (DWORD)-1 ??? | ||
346 | #ifdef QT_CHECK_STATE | ||
347 | qWarning( "QSettings: closelock failed!"); | ||
348 | #endif | ||
349 | } | ||
350 | CloseHandle( fd ); | ||
351 | } | ||
352 | #endif | 319 | #endif |
@@ -367,3 +334,5 @@ void QSettingsHeading::read(const QString &filename) | |||
367 | 334 | ||
335 | #ifndef Q_WS_WIN | ||
368 | HANDLE lockfd = openlock( filename, Q_LOCKREAD ); | 336 | HANDLE lockfd = openlock( filename, Q_LOCKREAD ); |
337 | #endif | ||
369 | 338 | ||
@@ -388,3 +357,5 @@ void QSettingsHeading::read(const QString &filename) | |||
388 | 357 | ||
358 | #ifndef Q_WS_WIN | ||
389 | closelock( lockfd ); | 359 | closelock( lockfd ); |
360 | #endif | ||
390 | } | 361 | } |
@@ -406,3 +377,3 @@ void QSettingsHeading::parseLine(QTextStream &stream) | |||
406 | 377 | ||
407 | gname = gname.remove(0, 1); | 378 | gname = gname.remove((uint)0, 1); |
408 | if (gname[(int)gname.length() - 1] == QChar(']')) | 379 | if (gname[(int)gname.length() - 1] == QChar(']')) |
@@ -528,7 +499,3 @@ QSettingsPrivate::QSettingsPrivate( QSettings::Format format ) | |||
528 | #else | 499 | #else |
529 | // for now | 500 | defPath = qInstallPathSysconf(); |
530 | #define QSETTINGS_DEFAULT_PATH_SUFFIX "/etc/settings" | ||
531 | |||
532 | defPath = qInstallPath(); | ||
533 | defPath += QSETTINGS_DEFAULT_PATH_SUFFIX; | ||
534 | #endif | 501 | #endif |
@@ -703,3 +670,3 @@ bool qt_verify_key( const QString &key ) | |||
703 | { | 670 | { |
704 | if ( key.isEmpty() || key[0] != '/' || key.contains( QRegExp("[=\\\\r\\\\n" ) ) ) | 671 | if ( key.isEmpty() || key[0] != '/' || key.contains( QRegExp("[=\\r\\n]" ) ) ) |
705 | return FALSE; | 672 | return FALSE; |
@@ -708,4 +675,5 @@ bool qt_verify_key( const QString &key ) | |||
708 | 675 | ||
709 | static inline QString groupKey( const QString &group, const QString &key ) | 676 | static QString groupKey( const QString &group, const QString &key ) |
710 | { | 677 | { |
678 | QString grp_key; | ||
711 | if ( group.isEmpty() || ( group.length() == 1 && group[0] == '/' ) ) { | 679 | if ( group.isEmpty() || ( group.length() == 1 && group[0] == '/' ) ) { |
@@ -713,8 +681,11 @@ static inline QString groupKey( const QString &group, const QString &key ) | |||
713 | if ( key.startsWith( "/" ) ) | 681 | if ( key.startsWith( "/" ) ) |
714 | return key; | 682 | grp_key = key; |
715 | return "/" + key; | 683 | else |
684 | grp_key = "/" + key; | ||
716 | } else if ( group.endsWith( "/" ) || key.startsWith( "/" ) ) { | 685 | } else if ( group.endsWith( "/" ) || key.startsWith( "/" ) ) { |
717 | return group + key; | 686 | grp_key = group + key; |
687 | } else { | ||
688 | grp_key = group + "/" + key; | ||
718 | } | 689 | } |
719 | return group + "/" + key; | 690 | return grp_key; |
720 | } | 691 | } |
@@ -723,3 +694,4 @@ static inline QString groupKey( const QString &group, const QString &key ) | |||
723 | Inserts \a path into the settings search path. The semantics of \a | 694 | Inserts \a path into the settings search path. The semantics of \a |
724 | path depends on the system \a s. | 695 | path depends on the system \a s. It is usually easier and better to |
696 | use setPath() instead of this function. | ||
725 | 697 | ||
@@ -768,4 +740,5 @@ static inline QString groupKey( const QString &group, const QString &key ) | |||
768 | \list 1 | 740 | \list 1 |
769 | \i INSTALL/etc - where \c INSTALL is the directory where Qt was installed. | 741 | \i \c SYSCONF - where \c SYSCONF is a directory specified when |
770 | \i $HOME/.qt/ - where \c $HOME is the user's home directory. | 742 | configuring Qt; by default it is INSTALL/etc/settings. |
743 | \i \c $HOME/.qt/ - where \c $HOME is the user's home directory. | ||
771 | \endlist | 744 | \endlist |
@@ -782,3 +755,3 @@ static inline QString groupKey( const QString &group, const QString &key ) | |||
782 | \list 1 | 755 | \list 1 |
783 | \i INSTALL/etc | 756 | \i SYSCONF |
784 | \i /opt/MyCompany/share/etc | 757 | \i /opt/MyCompany/share/etc |
@@ -793,2 +766,5 @@ static inline QString groupKey( const QString &group, const QString &key ) | |||
793 | 766 | ||
767 | Note that paths in the file system are not created by this | ||
768 | function, so they must already exist to be useful. | ||
769 | |||
794 | Settings under Unix are stored in files whose names are based on the | 770 | Settings under Unix are stored in files whose names are based on the |
@@ -817,3 +793,3 @@ void QSettings::insertSearchPath( System s, const QString &path) | |||
817 | #endif | 793 | #endif |
818 | #if !defined(Q_WS_WIN) | 794 | #if !defined(Q_OS_MAC) |
819 | if ( s == Mac ) | 795 | if ( s == Mac ) |
@@ -966,3 +942,3 @@ bool QSettings::sync() | |||
966 | QSettingsHeading::Iterator hdit = hd.begin(); | 942 | QSettingsHeading::Iterator hdit = hd.begin(); |
967 | QFile file; | 943 | QString filename; |
968 | 944 | ||
@@ -974,2 +950,7 @@ bool QSettings::sync() | |||
974 | QFileInfo di(*pit); | 950 | QFileInfo di(*pit); |
951 | if ( !di.exists() ) { | ||
952 | QDir dir; | ||
953 | dir.mkdir( *pit ); | ||
954 | } | ||
955 | |||
975 | QFileInfo fi((*pit++) + "/" + filebase + "rc"); | 956 | QFileInfo fi((*pit++) + "/" + filebase + "rc"); |
@@ -977,4 +958,10 @@ bool QSettings::sync() | |||
977 | if ((fi.exists() && fi.isFile() && fi.isWritable()) || | 958 | if ((fi.exists() && fi.isFile() && fi.isWritable()) || |
978 | (! fi.exists() && di.isDir() && di.isWritable())) { | 959 | (! fi.exists() && di.isDir() |
979 | file.setName(fi.filePath()); | 960 | #ifndef Q_WS_WIN |
961 | && di.isWritable() | ||
962 | #else | ||
963 | && ((qWinVersion()&Qt::WV_NT_based) > Qt::WV_2000 || di.isWritable()) | ||
964 | #endif | ||
965 | )) { | ||
966 | filename = fi.filePath(); | ||
980 | break; | 967 | break; |
@@ -985,3 +972,3 @@ bool QSettings::sync() | |||
985 | 972 | ||
986 | if ( file.name().isEmpty() ) { | 973 | if ( filename.isEmpty() ) { |
987 | 974 | ||
@@ -995,4 +982,7 @@ bool QSettings::sync() | |||
995 | 982 | ||
996 | HANDLE lockfd = openlock( file.name(), Q_LOCKWRITE ); | 983 | #ifndef Q_WS_WIN |
984 | HANDLE lockfd = openlock( filename, Q_LOCKWRITE ); | ||
985 | #endif | ||
997 | 986 | ||
987 | QFile file( filename + ".tmp" ); | ||
998 | if (! file.open(IO_WriteOnly)) { | 988 | if (! file.open(IO_WriteOnly)) { |
@@ -1049,3 +1039,22 @@ bool QSettings::sync() | |||
1049 | 1039 | ||
1040 | if ( success ) { | ||
1041 | QDir dir( QFileInfo( file ).dir( TRUE ) ); | ||
1042 | if ( dir.exists( filename ) && !dir.remove( filename ) || | ||
1043 | !dir.rename( file.name(), filename, TRUE ) ) { | ||
1044 | |||
1045 | #ifdef QT_CHECK_STATE | ||
1046 | qWarning( "QSettings::sync: error writing file '%s'", | ||
1047 | QFile::encodeName( filename ).data() ); | ||
1048 | #endif // QT_CHECK_STATE | ||
1049 | |||
1050 | success = FALSE; | ||
1051 | } | ||
1052 | } | ||
1053 | |||
1054 | // remove temporary file | ||
1055 | file.remove(); | ||
1056 | |||
1057 | #ifndef Q_WS_WIN | ||
1050 | closelock( lockfd ); | 1058 | closelock( lockfd ); |
1059 | #endif | ||
1051 | } | 1060 | } |
@@ -1074,5 +1083,6 @@ bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok ) | |||
1074 | { | 1083 | { |
1075 | if ( !qt_verify_key( key ) ) { | 1084 | QString grp_key( groupKey( group(), key ) ); |
1085 | if ( !qt_verify_key( grp_key ) ) { | ||
1076 | #if defined(QT_CHECK_STATE) | 1086 | #if defined(QT_CHECK_STATE) |
1077 | qWarning( "QSettings::readBoolEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1087 | qWarning( "QSettings::readBoolEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1078 | #endif | 1088 | #endif |
@@ -1086,3 +1096,3 @@ bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok ) | |||
1086 | if ( d->sysd ) | 1096 | if ( d->sysd ) |
1087 | return d->sysReadBoolEntry( groupKey( group(), key ), def, ok ); | 1097 | return d->sysReadBoolEntry( grp_key, def, ok ); |
1088 | #endif | 1098 | #endif |
@@ -1125,5 +1135,6 @@ double QSettings::readDoubleEntry(const QString &key, double def, bool *ok ) | |||
1125 | { | 1135 | { |
1126 | if ( !qt_verify_key( key ) ) { | 1136 | QString grp_key( groupKey( group(), key ) ); |
1137 | if ( !qt_verify_key( grp_key ) ) { | ||
1127 | #if defined(QT_CHECK_STATE) | 1138 | #if defined(QT_CHECK_STATE) |
1128 | qWarning( "QSettings::readDoubleEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1139 | qWarning( "QSettings::readDoubleEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1129 | #endif | 1140 | #endif |
@@ -1137,3 +1148,3 @@ double QSettings::readDoubleEntry(const QString &key, double def, bool *ok ) | |||
1137 | if ( d->sysd ) | 1148 | if ( d->sysd ) |
1138 | return d->sysReadDoubleEntry( groupKey( group(), key ), def, ok ); | 1149 | return d->sysReadDoubleEntry( grp_key, def, ok ); |
1139 | #endif | 1150 | #endif |
@@ -1170,5 +1181,6 @@ int QSettings::readNumEntry(const QString &key, int def, bool *ok ) | |||
1170 | { | 1181 | { |
1171 | if ( !qt_verify_key( key ) ) { | 1182 | QString grp_key( groupKey( group(), key ) ); |
1183 | if ( !qt_verify_key( grp_key ) ) { | ||
1172 | #if defined(QT_CHECK_STATE) | 1184 | #if defined(QT_CHECK_STATE) |
1173 | qWarning( "QSettings::readNumEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1185 | qWarning( "QSettings::readNumEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1174 | #endif | 1186 | #endif |
@@ -1181,3 +1193,3 @@ int QSettings::readNumEntry(const QString &key, int def, bool *ok ) | |||
1181 | if ( d->sysd ) | 1193 | if ( d->sysd ) |
1182 | return d->sysReadNumEntry( groupKey( group(), key ), def, ok ); | 1194 | return d->sysReadNumEntry( grp_key, def, ok ); |
1183 | #endif | 1195 | #endif |
@@ -1214,5 +1226,6 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) | |||
1214 | { | 1226 | { |
1215 | if ( !qt_verify_key( key ) ) { | 1227 | QString grp_key( groupKey( group(), key ) ); |
1228 | if ( !qt_verify_key( grp_key ) ) { | ||
1216 | #if defined(QT_CHECK_STATE) | 1229 | #if defined(QT_CHECK_STATE) |
1217 | qWarning( "QSettings::readEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1230 | qWarning( "QSettings::readEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1218 | #endif | 1231 | #endif |
@@ -1224,7 +1237,5 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) | |||
1224 | 1237 | ||
1225 | QString theKey = groupKey( group(), key ); | ||
1226 | |||
1227 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) | 1238 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1228 | if ( d->sysd ) | 1239 | if ( d->sysd ) |
1229 | return d->sysReadEntry( theKey, def, ok ); | 1240 | return d->sysReadEntry( grp_key, def, ok ); |
1230 | #endif | 1241 | #endif |
@@ -1236,5 +1247,5 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) | |||
1236 | 1247 | ||
1237 | if (theKey[0] == '/') { | 1248 | if (grp_key[0] == '/') { |
1238 | // parse our key | 1249 | // parse our key |
1239 | QStringList list(QStringList::split('/', theKey)); | 1250 | QStringList list(QStringList::split('/', grp_key)); |
1240 | 1251 | ||
@@ -1242,3 +1253,3 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) | |||
1242 | #ifdef QT_CHECK_STATE | 1253 | #ifdef QT_CHECK_STATE |
1243 | qWarning("QSettings::readEntry: invalid key '%s'", theKey.latin1()); | 1254 | qWarning("QSettings::readEntry: invalid key '%s'", grp_key.latin1()); |
1244 | #endif // QT_CHECK_STATE | 1255 | #endif // QT_CHECK_STATE |
@@ -1264,4 +1275,5 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) | |||
1264 | } | 1275 | } |
1265 | } else | 1276 | } else { |
1266 | realkey = theKey; | 1277 | realkey = grp_key; |
1278 | } | ||
1267 | 1279 | ||
@@ -1292,5 +1304,6 @@ bool QSettings::writeEntry(const QString &key, bool value) | |||
1292 | { | 1304 | { |
1293 | if ( !qt_verify_key( key ) ) { | 1305 | QString grp_key( groupKey( group(), key ) ); |
1306 | if ( !qt_verify_key( grp_key ) ) { | ||
1294 | #if defined(QT_CHECK_STATE) | 1307 | #if defined(QT_CHECK_STATE) |
1295 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1308 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1296 | #endif | 1309 | #endif |
@@ -1301,3 +1314,3 @@ bool QSettings::writeEntry(const QString &key, bool value) | |||
1301 | if ( d->sysd ) | 1314 | if ( d->sysd ) |
1302 | return d->sysWriteEntry( groupKey( group(), key ), value ); | 1315 | return d->sysWriteEntry( grp_key, value ); |
1303 | #endif | 1316 | #endif |
@@ -1322,5 +1335,6 @@ bool QSettings::writeEntry(const QString &key, double value) | |||
1322 | { | 1335 | { |
1323 | if ( !qt_verify_key( key ) ) { | 1336 | QString grp_key( groupKey( group(), key ) ); |
1337 | if ( !qt_verify_key( grp_key ) ) { | ||
1324 | #if defined(QT_CHECK_STATE) | 1338 | #if defined(QT_CHECK_STATE) |
1325 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1339 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1326 | #endif | 1340 | #endif |
@@ -1331,3 +1345,3 @@ bool QSettings::writeEntry(const QString &key, double value) | |||
1331 | if ( d->sysd ) | 1345 | if ( d->sysd ) |
1332 | return d->sysWriteEntry( groupKey( group(), key ), value ); | 1346 | return d->sysWriteEntry( grp_key, value ); |
1333 | #endif | 1347 | #endif |
@@ -1351,5 +1365,6 @@ bool QSettings::writeEntry(const QString &key, int value) | |||
1351 | { | 1365 | { |
1352 | if ( !qt_verify_key( key ) ) { | 1366 | QString grp_key( groupKey( group(), key ) ); |
1367 | if ( !qt_verify_key( grp_key ) ) { | ||
1353 | #if defined(QT_CHECK_STATE) | 1368 | #if defined(QT_CHECK_STATE) |
1354 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1369 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1355 | #endif | 1370 | #endif |
@@ -1360,3 +1375,3 @@ bool QSettings::writeEntry(const QString &key, int value) | |||
1360 | if ( d->sysd ) | 1375 | if ( d->sysd ) |
1361 | return d->sysWriteEntry( groupKey( group(), key ), value ); | 1376 | return d->sysWriteEntry( grp_key, value ); |
1362 | #endif | 1377 | #endif |
@@ -1385,9 +1400,2 @@ bool QSettings::writeEntry(const QString &key, const char *value) | |||
1385 | { | 1400 | { |
1386 | if ( !qt_verify_key( key ) ) { | ||
1387 | #if defined(QT_CHECK_STATE) | ||
1388 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | ||
1389 | #endif | ||
1390 | return FALSE; | ||
1391 | } | ||
1392 | |||
1393 | return writeEntry(key, QString(value)); | 1401 | return writeEntry(key, QString(value)); |
@@ -1410,5 +1418,6 @@ bool QSettings::writeEntry(const QString &key, const QString &value) | |||
1410 | { | 1418 | { |
1411 | if ( !qt_verify_key( key ) ) { | 1419 | QString grp_key( groupKey( group(), key ) ); |
1420 | if ( !qt_verify_key( grp_key ) ) { | ||
1412 | #if defined(QT_CHECK_STATE) | 1421 | #if defined(QT_CHECK_STATE) |
1413 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1422 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1414 | #endif | 1423 | #endif |
@@ -1417,7 +1426,5 @@ bool QSettings::writeEntry(const QString &key, const QString &value) | |||
1417 | 1426 | ||
1418 | QString theKey = groupKey( group(), key ); | ||
1419 | |||
1420 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) | 1427 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1421 | if ( d->sysd ) | 1428 | if ( d->sysd ) |
1422 | return d->sysWriteEntry( theKey, value ); | 1429 | return d->sysWriteEntry( grp_key, value ); |
1423 | #endif | 1430 | #endif |
@@ -1427,5 +1434,5 @@ bool QSettings::writeEntry(const QString &key, const QString &value) | |||
1427 | 1434 | ||
1428 | if (theKey[0] == '/') { | 1435 | if (grp_key[0] == '/') { |
1429 | // parse our key | 1436 | // parse our key |
1430 | QStringList list(QStringList::split('/', theKey)); | 1437 | QStringList list(QStringList::split('/', grp_key)); |
1431 | 1438 | ||
@@ -1433,3 +1440,3 @@ bool QSettings::writeEntry(const QString &key, const QString &value) | |||
1433 | #ifdef QT_CHECK_STATE | 1440 | #ifdef QT_CHECK_STATE |
1434 | qWarning("QSettings::writeEntry: invalid key '%s'", theKey.latin1()); | 1441 | qWarning("QSettings::writeEntry: invalid key '%s'", grp_key.latin1()); |
1435 | #endif // QT_CHECK_STATE | 1442 | #endif // QT_CHECK_STATE |
@@ -1454,4 +1461,5 @@ bool QSettings::writeEntry(const QString &key, const QString &value) | |||
1454 | } | 1461 | } |
1455 | } else | 1462 | } else { |
1456 | realkey = theKey; | 1463 | realkey = grp_key; |
1464 | } | ||
1457 | 1465 | ||
@@ -1471,5 +1479,6 @@ bool QSettings::removeEntry(const QString &key) | |||
1471 | { | 1479 | { |
1472 | if ( !qt_verify_key( key ) ) { | 1480 | QString grp_key( groupKey( group(), key ) ); |
1481 | if ( !qt_verify_key( grp_key ) ) { | ||
1473 | #if defined(QT_CHECK_STATE) | 1482 | #if defined(QT_CHECK_STATE) |
1474 | qWarning( "QSettings::removeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1483 | qWarning( "QSettings::removeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1475 | #endif | 1484 | #endif |
@@ -1478,7 +1487,5 @@ bool QSettings::removeEntry(const QString &key) | |||
1478 | 1487 | ||
1479 | QString theKey = groupKey( group(), key ); | ||
1480 | |||
1481 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) | 1488 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1482 | if ( d->sysd ) | 1489 | if ( d->sysd ) |
1483 | return d->sysRemoveEntry( theKey ); | 1490 | return d->sysRemoveEntry( grp_key ); |
1484 | #endif | 1491 | #endif |
@@ -1486,6 +1493,5 @@ bool QSettings::removeEntry(const QString &key) | |||
1486 | QString realkey; | 1493 | QString realkey; |
1487 | 1494 | if (grp_key[0] == '/') { | |
1488 | if (theKey[0] == '/') { | ||
1489 | // parse our key | 1495 | // parse our key |
1490 | QStringList list(QStringList::split('/', theKey)); | 1496 | QStringList list(QStringList::split('/', grp_key)); |
1491 | 1497 | ||
@@ -1493,3 +1499,3 @@ bool QSettings::removeEntry(const QString &key) | |||
1493 | #ifdef QT_CHECK_STATE | 1499 | #ifdef QT_CHECK_STATE |
1494 | qWarning("QSettings::removeEntry: invalid key '%s'", theKey.latin1()); | 1500 | qWarning("QSettings::removeEntry: invalid key '%s'", grp_key.latin1()); |
1495 | #endif // QT_CHECK_STATE | 1501 | #endif // QT_CHECK_STATE |
@@ -1514,4 +1520,5 @@ bool QSettings::removeEntry(const QString &key) | |||
1514 | } | 1520 | } |
1515 | } else | 1521 | } else { |
1516 | realkey = theKey; | 1522 | realkey = grp_key; |
1523 | } | ||
1517 | 1524 | ||
@@ -1550,5 +1557,6 @@ QStringList QSettings::entryList(const QString &key) const | |||
1550 | { | 1557 | { |
1551 | if ( !qt_verify_key( key ) ) { | 1558 | QString grp_key( groupKey( group(), key ) ); |
1559 | if ( !qt_verify_key( grp_key ) ) { | ||
1552 | #if defined(QT_CHECK_STATE) | 1560 | #if defined(QT_CHECK_STATE) |
1553 | qWarning( "QSettings::entryList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() ); | 1561 | qWarning( "QSettings::entryList: Invalid key: %s", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1554 | #endif | 1562 | #endif |
@@ -1557,7 +1565,5 @@ QStringList QSettings::entryList(const QString &key) const | |||
1557 | 1565 | ||
1558 | QString theKey = groupKey( group(), key ); | ||
1559 | |||
1560 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) | 1566 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1561 | if ( d->sysd ) | 1567 | if ( d->sysd ) |
1562 | return d->sysEntryList( theKey ); | 1568 | return d->sysEntryList( grp_key ); |
1563 | #endif | 1569 | #endif |
@@ -1565,5 +1571,5 @@ QStringList QSettings::entryList(const QString &key) const | |||
1565 | QString realkey; | 1571 | QString realkey; |
1566 | if (theKey[0] == '/') { | 1572 | if (grp_key[0] == '/') { |
1567 | // parse our key | 1573 | // parse our key |
1568 | QStringList list(QStringList::split('/', theKey)); | 1574 | QStringList list(QStringList::split('/', grp_key)); |
1569 | 1575 | ||
@@ -1571,3 +1577,3 @@ QStringList QSettings::entryList(const QString &key) const | |||
1571 | #ifdef QT_CHECK_STATE | 1577 | #ifdef QT_CHECK_STATE |
1572 | qWarning("QSettings::listEntries: invalid key '%s'", theKey.latin1()); | 1578 | qWarning("QSettings::listEntries: invalid key '%s'", grp_key.latin1()); |
1573 | #endif // QT_CHECK_STATE | 1579 | #endif // QT_CHECK_STATE |
@@ -1592,3 +1598,3 @@ QStringList QSettings::entryList(const QString &key) const | |||
1592 | } else | 1598 | } else |
1593 | realkey = theKey; | 1599 | realkey = grp_key; |
1594 | 1600 | ||
@@ -1647,5 +1653,6 @@ QStringList QSettings::subkeyList(const QString &key) const | |||
1647 | { | 1653 | { |
1648 | if ( !qt_verify_key( key ) ) { | 1654 | QString grp_key( groupKey( group(), key ) ); |
1655 | if ( !qt_verify_key( grp_key ) ) { | ||
1649 | #if defined(QT_CHECK_STATE) | 1656 | #if defined(QT_CHECK_STATE) |
1650 | qWarning( "QSettings::subkeyList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() ); | 1657 | qWarning( "QSettings::subkeyList: Invalid key: %s", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1651 | #endif | 1658 | #endif |
@@ -1654,7 +1661,5 @@ QStringList QSettings::subkeyList(const QString &key) const | |||
1654 | 1661 | ||
1655 | QString theKey = groupKey( group(), key ); | ||
1656 | |||
1657 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) | 1662 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1658 | if ( d->sysd ) | 1663 | if ( d->sysd ) |
1659 | return d->sysSubkeyList( theKey ); | 1664 | return d->sysSubkeyList( grp_key ); |
1660 | #endif | 1665 | #endif |
@@ -1663,5 +1668,5 @@ QStringList QSettings::subkeyList(const QString &key) const | |||
1663 | int subkeycount = 2; | 1668 | int subkeycount = 2; |
1664 | if (theKey[0] == '/') { | 1669 | if (grp_key[0] == '/') { |
1665 | // parse our key | 1670 | // parse our key |
1666 | QStringList list(QStringList::split('/', theKey)); | 1671 | QStringList list(QStringList::split('/', grp_key)); |
1667 | 1672 | ||
@@ -1669,3 +1674,3 @@ QStringList QSettings::subkeyList(const QString &key) const | |||
1669 | #ifdef QT_CHECK_STATE | 1674 | #ifdef QT_CHECK_STATE |
1670 | qWarning("QSettings::subkeyList: invalid key '%s'", theKey.latin1()); | 1675 | qWarning("QSettings::subkeyList: invalid key '%s'", grp_key.latin1()); |
1671 | #endif // QT_CHECK_STATE | 1676 | #endif // QT_CHECK_STATE |
@@ -1693,3 +1698,3 @@ QStringList QSettings::subkeyList(const QString &key) const | |||
1693 | } else | 1698 | } else |
1694 | realkey = theKey; | 1699 | realkey = grp_key; |
1695 | 1700 | ||
@@ -1739,7 +1744,8 @@ QStringList QSettings::subkeyList(const QString &key) const | |||
1739 | */ | 1744 | */ |
1740 | QDateTime QSettings::lastModficationTime(const QString &key) | 1745 | QDateTime QSettings::lastModificationTime( const QString &key ) |
1741 | { | 1746 | { |
1742 | if ( !qt_verify_key( key ) ) { | 1747 | QString grp_key( groupKey( group(), key ) ); |
1748 | if ( !qt_verify_key( grp_key ) ) { | ||
1743 | #if defined(QT_CHECK_STATE) | 1749 | #if defined(QT_CHECK_STATE) |
1744 | qWarning( "QSettings::lastModficationTime: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1750 | qWarning( "QSettings::lastModificationTime: Invalid key '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); |
1745 | #endif | 1751 | #endif |
@@ -1748,4 +1754,2 @@ QDateTime QSettings::lastModficationTime(const QString &key) | |||
1748 | 1754 | ||
1749 | QString theKey = groupKey( group(), key ); | ||
1750 | |||
1751 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) | 1755 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
@@ -1755,5 +1759,5 @@ QDateTime QSettings::lastModficationTime(const QString &key) | |||
1755 | 1759 | ||
1756 | if (theKey[0] == '/') { | 1760 | if (grp_key[0] == '/') { |
1757 | // parse our key | 1761 | // parse our key |
1758 | QStringList list(QStringList::split('/', theKey)); | 1762 | QStringList list(QStringList::split('/', grp_key)); |
1759 | 1763 | ||
@@ -1761,3 +1765,3 @@ QDateTime QSettings::lastModficationTime(const QString &key) | |||
1761 | #ifdef QT_CHECK_STATE | 1765 | #ifdef QT_CHECK_STATE |
1762 | qWarning("QSettings::lastModficationTime: invalid key '%s'", theKey.latin1()); | 1766 | qWarning("QSettings::lastModificationTime: Invalid key '%s'", grp_key.latin1()); |
1763 | #endif // QT_CHECK_STATE | 1767 | #endif // QT_CHECK_STATE |
@@ -1782,2 +1786,3 @@ QDateTime QSettings::lastModficationTime(const QString &key) | |||
1782 | \overload | 1786 | \overload |
1787 | \obsolete | ||
1783 | 1788 | ||
@@ -1798,2 +1803,3 @@ QDateTime QSettings::lastModficationTime(const QString &key) | |||
1798 | 1803 | ||
1804 | |||
1799 | If an error occurs the settings are left unchanged and FALSE is | 1805 | If an error occurs the settings are left unchanged and FALSE is |
@@ -1801,3 +1807,3 @@ QDateTime QSettings::lastModficationTime(const QString &key) | |||
1801 | 1807 | ||
1802 | \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() | 1808 | \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry(), QStringList::join() |
1803 | */ | 1809 | */ |
@@ -1841,2 +1847,3 @@ bool QSettings::writeEntry(const QString &key, const QStringList &value) | |||
1841 | \overload QStringList QSettings::readListEntry(const QString &key, const QChar &separator, bool *ok ) const | 1847 | \overload QStringList QSettings::readListEntry(const QString &key, const QChar &separator, bool *ok ) const |
1848 | \obsolete | ||
1842 | 1849 | ||
@@ -1844,4 +1851,4 @@ bool QSettings::writeEntry(const QString &key, const QStringList &value) | |||
1844 | is used to create a QStringList by calling QStringList::split(\a | 1851 | is used to create a QStringList by calling QStringList::split(\a |
1845 | separator, entry). If \a ok is not 0: \a *ok is set to TRUE if the | 1852 | separator, entry). If \a ok is not 0: \a *ok is set to TRUE |
1846 | key was read, otherwise \a *ok is set to FALSE. | 1853 | if the key was read, otherwise \a *ok is set to FALSE. |
1847 | 1854 | ||
@@ -1853,3 +1860,2 @@ bool QSettings::writeEntry(const QString &key, const QStringList &value) | |||
1853 | 1860 | ||
1854 | |||
1855 | Note that if you want to iterate over the list, you should iterate | 1861 | Note that if you want to iterate over the list, you should iterate |
@@ -1951,4 +1957,3 @@ void qt_setSettingsBasePath(const QString &); //qsettings_mac.cpp | |||
1951 | 1957 | ||
1952 | Not all information is relevant on all systems (e.g. scoping is | 1958 | Not all information is relevant on all systems. |
1953 | currently used only if QSettings accesses the Windows registry). | ||
1954 | */ | 1959 | */ |
@@ -1982,2 +1987,3 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc | |||
1982 | #elif !defined(QWS) && defined(Q_OS_MAC) | 1987 | #elif !defined(QWS) && defined(Q_OS_MAC) |
1988 | if(lastDot != -1) { | ||
1983 | QString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + "."; | 1989 | QString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + "."; |
@@ -1985,6 +1991,11 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc | |||
1985 | qt_setSettingsBasePath( topLevelDomain ); | 1991 | qt_setSettingsBasePath( topLevelDomain ); |
1986 | actualSearchPath = "/" + domain.left( lastDot ) + product; | 1992 | } |
1993 | actualSearchPath = "/" + domain.left( lastDot ) + "." + product; | ||
1987 | insertSearchPath( Mac, actualSearchPath ); | 1994 | insertSearchPath( Mac, actualSearchPath ); |
1988 | #else | 1995 | #else |
1989 | actualSearchPath = "/" + domain.mid( 0, lastDot ) + "/" + product; | 1996 | if (scope == User) |
1997 | actualSearchPath = QDir::homeDirPath() + "/."; | ||
1998 | else | ||
1999 | actualSearchPath = QString(qInstallPathSysconf()) + "/"; | ||
2000 | actualSearchPath += domain.mid( 0, lastDot ) + "/" + product; | ||
1990 | insertSearchPath( Unix, actualSearchPath ); | 2001 | insertSearchPath( Unix, actualSearchPath ); |