summaryrefslogtreecommitdiff
path: root/qmake/tools/qsettings.cpp
Unidiff
Diffstat (limited to 'qmake/tools/qsettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/tools/qsettings.cpp371
1 files changed, 191 insertions, 180 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,11 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2**
3** 3**
4** Implementation of QSettings class 4** Implementation of QSettings class
5** 5**
6** Created : 000626 6** Created : 000626
7** 7**
8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 2000-2003 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
@@ -60,7 +60,9 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
60#include "qtextstream.h" 60#include "qtextstream.h"
61#include "qregexp.h" 61#include "qregexp.h"
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
65/*! 67/*!
66 \class QSettings 68 \class QSettings
@@ -101,7 +103,8 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
101 \endcode 103 \endcode
102 Each line above is a complete key, made up of subkeys. 104 Each line above is a complete key, made up of subkeys.
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
106 QSettings settings; 109 QSettings settings;
107 settings.setPath( "MyCompany.com", "MyApplication" ); 110 settings.setPath( "MyCompany.com", "MyApplication" );
@@ -111,7 +114,8 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
111 // ... 114 // ...
112 \endcode 115 \endcode
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
116 QSettings settings; 120 QSettings settings;
117 settings.setPath( "MyCompany.com", "MyApplication" ); 121 settings.setPath( "MyCompany.com", "MyApplication" );
@@ -121,8 +125,9 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
121 // ... 125 // ...
122 \endcode 126 \endcode
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
127 QSettings settings; 132 QSettings settings;
128 133
@@ -154,8 +159,8 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
154 // subkeys is empty. 159 // subkeys is empty.
155 \endcode 160 \endcode
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
160 \i A subkey may not exceed 255 characters. 165 \i A subkey may not exceed 255 characters.
161 \i An entry's value may not exceed 16,300 characters. 166 \i An entry's value may not exceed 16,300 characters.
@@ -165,22 +170,23 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
165 170
166 These limitations are not enforced on Unix or Mac OS X. 171 These limitations are not enforced on Unix or Mac OS X.
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
172 \section1 Notes for Mac OS X Applications 177 \section1 Notes for Mac OS X Applications
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
185 191
186 \section1 Notes for Unix Applications 192 \section1 Notes for Unix Applications
@@ -189,10 +195,10 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
189 settings under Unix. In the examples the settings file will be 195 settings under Unix. In the examples the settings file will be
190 searched for in the following directories: 196 searched for in the following directories:
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
197 When reading settings the files are searched in the order shown 203 When reading settings the files are searched in the order shown
198 above, with later settings overriding earlier settings. Files for 204 above, with later settings overriding earlier settings. Files for
@@ -217,8 +223,8 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
217 \c{$HOME/.qt/myapplicationrc} (assuming that the application is 223 \c{$HOME/.qt/myapplicationrc} (assuming that the application is
218 being run by an ordinary user, i.e. not by root). 224 being run by an ordinary user, i.e. not by root).
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*/
223 229
224/*! 230/*!
@@ -310,45 +316,6 @@ static void closelock( HANDLE fd )
310 316
311 close( fd ); 317 close( fd );
312} 318}
313#elif defined(Q_WS_WIN)
314#define Q_LOCKREAD 1
315#define Q_LOCKWRITE 2
316
317static 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
340static 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
353 320
354 321
@@ -365,7 +332,9 @@ void QSettingsHeading::read(const QString &filename)
365 if (! QFileInfo(filename).exists()) 332 if (! QFileInfo(filename).exists())
366 return; 333 return;
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
370 QFile file(filename); 339 QFile file(filename);
371 if (! file.open(IO_ReadOnly)) { 340 if (! file.open(IO_ReadOnly)) {
@@ -386,7 +355,9 @@ void QSettingsHeading::read(const QString &filename)
386 355
387 file.close(); 356 file.close();
388 357
358#ifndef Q_WS_WIN
389 closelock( lockfd ); 359 closelock( lockfd );
360#endif
390} 361}
391 362
392 363
@@ -404,7 +375,7 @@ void QSettingsHeading::parseLine(QTextStream &stream)
404 if (line[0] == QChar('[')) { 375 if (line[0] == QChar('[')) {
405 QString gname = line; 376 QString gname = line;
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(']'))
409 gname = gname.remove(gname.length() - 1, 1); 380 gname = gname.remove(gname.length() - 1, 1);
410 381
@@ -526,11 +497,7 @@ QSettingsPrivate::QSettingsPrivate( QSettings::Format format )
526 } ); 497 } );
527#endif // Q_OS_TEMP 498#endif // Q_OS_TEMP
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
535 QDir dir(appSettings); 502 QDir dir(appSettings);
536 if (! dir.exists()) { 503 if (! dir.exists()) {
@@ -701,27 +668,32 @@ QDateTime QSettingsPrivate::modificationTime()
701 668
702bool qt_verify_key( const QString &key ) 669bool 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;
706 return TRUE; 673 return TRUE;
707} 674}
708 675
709static inline QString groupKey( const QString &group, const QString &key ) 676static 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] == '/' ) ) {
712 // group is empty, or it contains a single '/', so we just return the key 680 // group is empty, or it contains a single '/', so we just return the 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}
721 692
722/*! 693/*!
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
726 When \a s is \e Windows and the execution environment is \e not 698 When \a s is \e Windows and the execution environment is \e not
727 Windows the function does nothing. Similarly when \a s is \e Unix and 699 Windows the function does nothing. Similarly when \a s is \e Unix and
@@ -766,8 +738,9 @@ static inline QString groupKey( const QString &group, const QString &key )
766 two entries in the search path: 738 two entries in the search path:
767 739
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
772 745
773 All insertions into the search path will go before $HOME/.qt/. 746 All insertions into the search path will go before $HOME/.qt/.
@@ -780,7 +753,7 @@ static inline QString groupKey( const QString &group, const QString &key )
780 \endcode 753 \endcode
781 Will result in a search path of: 754 Will result in a search path of:
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
785 \i /opt/MyCompany/share/MyApplication/etc 758 \i /opt/MyCompany/share/MyApplication/etc
786 \i $HOME/.qt 759 \i $HOME/.qt
@@ -791,6 +764,9 @@ static inline QString groupKey( const QString &group, const QString &key )
791 settings QSettings works in the order shown above, writing 764 settings QSettings works in the order shown above, writing
792 to the first settings file for which the user has write permission. 765 to the first settings file for which the user has write permission.
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
795 first subkey of the key (not including the search path). The algorithm 771 first subkey of the key (not including the search path). The algorithm
796 for creating names is essentially: lowercase the first subkey, replace 772 for creating names is essentially: lowercase the first subkey, replace
@@ -815,7 +791,7 @@ void QSettings::insertSearchPath( System s, const QString &path)
815 if ( s == Windows ) 791 if ( s == Windows )
816 return; 792 return;
817#endif 793#endif
818#if !defined(Q_WS_WIN) 794#if !defined(Q_OS_MAC)
819 if ( s == Mac ) 795 if ( s == Mac )
820 return; 796 return;
821#endif 797#endif
@@ -964,7 +940,7 @@ bool QSettings::sync()
964 // determine filename 940 // determine filename
965 QSettingsHeading hd(*it); 941 QSettingsHeading hd(*it);
966 QSettingsHeading::Iterator hdit = hd.begin(); 942 QSettingsHeading::Iterator hdit = hd.begin();
967 QFile file; 943 QString filename;
968 944
969 QStringList::Iterator pit = d->searchPaths.begin(); 945 QStringList::Iterator pit = d->searchPaths.begin();
970 if ( !d->globalScope ) 946 if ( !d->globalScope )
@@ -972,18 +948,29 @@ bool QSettings::sync()
972 while (pit != d->searchPaths.end()) { 948 while (pit != d->searchPaths.end()) {
973 QString filebase = it.key().lower().replace(QRegExp("\\s+"), "_"); 949 QString filebase = it.key().lower().replace(QRegExp("\\s+"), "_");
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");
976 957
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;
981 } 968 }
982 } 969 }
983 970
984 ++it; 971 ++it;
985 972
986 if ( file.name().isEmpty() ) { 973 if ( filename.isEmpty() ) {
987 974
988#ifdef QT_CHECK_STATE 975#ifdef QT_CHECK_STATE
989 qWarning("QSettings::sync: filename is null/empty"); 976 qWarning("QSettings::sync: filename is null/empty");
@@ -993,8 +980,11 @@ bool QSettings::sync()
993 continue; 980 continue;
994 } 981 }
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)) {
999 989
1000#ifdef QT_CHECK_STATE 990#ifdef QT_CHECK_STATE
@@ -1047,7 +1037,26 @@ bool QSettings::sync()
1047 1037
1048 file.close(); 1038 file.close();
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 }
1052 1061
1053 d->modified = FALSE; 1062 d->modified = FALSE;
@@ -1072,9 +1081,10 @@ bool QSettings::sync()
1072*/ 1081*/
1073bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok ) 1082bool 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
1079 if ( ok ) 1089 if ( ok )
1080 *ok = FALSE; 1090 *ok = FALSE;
@@ -1084,7 +1094,7 @@ bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok )
1084 1094
1085#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) 1095#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
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
1089 1099
1090 QString value = readEntry( key, ( def ? "true" : "false" ), ok ); 1100 QString value = readEntry( key, ( def ? "true" : "false" ), ok );
@@ -1123,9 +1133,10 @@ bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok )
1123*/ 1133*/
1124double QSettings::readDoubleEntry(const QString &key, double def, bool *ok ) 1134double 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
1130 if ( ok ) 1141 if ( ok )
1131 *ok = FALSE; 1142 *ok = FALSE;
@@ -1135,7 +1146,7 @@ double QSettings::readDoubleEntry(const QString &key, double def, bool *ok )
1135 1146
1136#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) 1147#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
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
1140 1151
1141 QString value = readEntry( key, QString::number(def), ok ); 1152 QString value = readEntry( key, QString::number(def), ok );
@@ -1168,9 +1179,10 @@ double QSettings::readDoubleEntry(const QString &key, double def, bool *ok )
1168*/ 1179*/
1169int QSettings::readNumEntry(const QString &key, int def, bool *ok ) 1180int 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
1175 if ( ok ) 1187 if ( ok )
1176 *ok = FALSE; 1188 *ok = FALSE;
@@ -1179,7 +1191,7 @@ int QSettings::readNumEntry(const QString &key, int def, bool *ok )
1179 1191
1180#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) 1192#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
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
1184 1196
1185 QString value = readEntry( key, QString::number( def ), ok ); 1197 QString value = readEntry( key, QString::number( def ), ok );
@@ -1212,9 +1224,10 @@ int QSettings::readNumEntry(const QString &key, int def, bool *ok )
1212*/ 1224*/
1213QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) 1225QString 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
1219 if ( ok ) 1232 if ( ok )
1220 *ok = FALSE; 1233 *ok = FALSE;
@@ -1222,11 +1235,9 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
1222 return def; 1235 return def;
1223 } 1236 }
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
1231 1242
1232 if ( ok ) // no, everything is not ok 1243 if ( ok ) // no, everything is not ok
@@ -1234,13 +1245,13 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
1234 1245
1235 QString realkey; 1246 QString realkey;
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
1241 if (list.count() < 2) { 1252 if (list.count() < 2) {
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
1245 if ( ok ) 1256 if ( ok )
1246 *ok = FALSE; 1257 *ok = FALSE;
@@ -1262,8 +1273,9 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
1262 1273
1263 realkey = list.join("/"); 1274 realkey = list.join("/");
1264 } 1275 }
1265 } else 1276 } else {
1266 realkey = theKey; 1277 realkey = grp_key;
1278 }
1267 1279
1268 QSettingsGroup grp = d->readGroup(); 1280 QSettingsGroup grp = d->readGroup();
1269 QSettingsGroup::const_iterator it = grp.find( realkey ), end = grp.end(); 1281 QSettingsGroup::const_iterator it = grp.find( realkey ), end = grp.end();
@@ -1290,16 +1302,17 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
1290*/ 1302*/
1291bool QSettings::writeEntry(const QString &key, bool value) 1303bool 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
1297 return FALSE; 1310 return FALSE;
1298 } 1311 }
1299 1312
1300#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) 1313#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
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
1304 QString s(value ? "true" : "false"); 1317 QString s(value ? "true" : "false");
1305 return writeEntry(key, s); 1318 return writeEntry(key, s);
@@ -1320,16 +1333,17 @@ bool QSettings::writeEntry(const QString &key, bool value)
1320*/ 1333*/
1321bool QSettings::writeEntry(const QString &key, double value) 1334bool 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
1327 return FALSE; 1341 return FALSE;
1328 } 1342 }
1329 1343
1330#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) 1344#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
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
1334 QString s(QString::number(value)); 1348 QString s(QString::number(value));
1335 return writeEntry(key, s); 1349 return writeEntry(key, s);
@@ -1349,16 +1363,17 @@ bool QSettings::writeEntry(const QString &key, double value)
1349*/ 1363*/
1350bool QSettings::writeEntry(const QString &key, int value) 1364bool 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
1356 return FALSE; 1371 return FALSE;
1357 } 1372 }
1358 1373
1359#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) 1374#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
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
1363 QString s(QString::number(value)); 1378 QString s(QString::number(value));
1364 return writeEntry(key, s); 1379 return writeEntry(key, s);
@@ -1383,13 +1398,6 @@ bool QSettings::writeEntry(const QString &key, int value)
1383*/ 1398*/
1384bool QSettings::writeEntry(const QString &key, const char *value) 1399bool 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));
1394} 1402}
1395 1403
@@ -1408,30 +1416,29 @@ bool QSettings::writeEntry(const QString &key, const char *value)
1408*/ 1416*/
1409bool QSettings::writeEntry(const QString &key, const QString &value) 1417bool 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
1415 return FALSE; 1424 return FALSE;
1416 } 1425 }
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
1424 // NOTE: we *do* allow value to be a null/empty string 1431 // NOTE: we *do* allow value to be a null/empty string
1425 1432
1426 QString realkey; 1433 QString realkey;
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
1432 if (list.count() < 2) { 1439 if (list.count() < 2) {
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
1436 1443
1437 return FALSE; 1444 return FALSE;
@@ -1452,8 +1459,9 @@ bool QSettings::writeEntry(const QString &key, const QString &value)
1452 1459
1453 realkey = list.join("/"); 1460 realkey = list.join("/");
1454 } 1461 }
1455 } else 1462 } else {
1456 realkey = theKey; 1463 realkey = grp_key;
1464 }
1457 1465
1458 d->writeGroup(realkey, value); 1466 d->writeGroup(realkey, value);
1459 return TRUE; 1467 return TRUE;
@@ -1469,29 +1477,27 @@ bool QSettings::writeEntry(const QString &key, const QString &value)
1469*/ 1477*/
1470bool QSettings::removeEntry(const QString &key) 1478bool 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
1476 return FALSE; 1485 return FALSE;
1477 } 1486 }
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
1485 1492
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
1492 if (list.count() < 2) { 1498 if (list.count() < 2) {
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
1496 1502
1497 return FALSE; 1503 return FALSE;
@@ -1512,8 +1518,9 @@ bool QSettings::removeEntry(const QString &key)
1512 1518
1513 realkey = list.join("/"); 1519 realkey = list.join("/");
1514 } 1520 }
1515 } else 1521 } else {
1516 realkey = theKey; 1522 realkey = grp_key;
1523 }
1517 1524
1518 d->removeGroup(realkey); 1525 d->removeGroup(realkey);
1519 return TRUE; 1526 return TRUE;
@@ -1548,28 +1555,27 @@ bool QSettings::removeEntry(const QString &key)
1548*/ 1555*/
1549QStringList QSettings::entryList(const QString &key) const 1556QStringList 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
1555 return QStringList(); 1563 return QStringList();
1556 } 1564 }
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
1564 1570
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
1570 if (list.count() < 1) { 1576 if (list.count() < 1) {
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
1574 1580
1575 return QStringList(); 1581 return QStringList();
@@ -1590,7 +1596,7 @@ QStringList QSettings::entryList(const QString &key) const
1590 realkey = list.join("/"); 1596 realkey = list.join("/");
1591 } 1597 }
1592 } else 1598 } else
1593 realkey = theKey; 1599 realkey = grp_key;
1594 1600
1595 QSettingsGroup grp = d->readGroup(); 1601 QSettingsGroup grp = d->readGroup();
1596 QSettingsGroup::Iterator it = grp.begin(); 1602 QSettingsGroup::Iterator it = grp.begin();
@@ -1645,29 +1651,28 @@ QStringList QSettings::entryList(const QString &key) const
1645*/ 1651*/
1646QStringList QSettings::subkeyList(const QString &key) const 1652QStringList 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
1652 return QStringList(); 1659 return QStringList();
1653 } 1660 }
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
1661 1666
1662 QString realkey; 1667 QString realkey;
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
1668 if (list.count() < 1) { 1673 if (list.count() < 1) {
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
1672 1677
1673 return QStringList(); 1678 return QStringList();
@@ -1691,7 +1696,7 @@ QStringList QSettings::subkeyList(const QString &key) const
1691 } 1696 }
1692 1697
1693 } else 1698 } else
1694 realkey = theKey; 1699 realkey = grp_key;
1695 1700
1696 QStringList ret; 1701 QStringList ret;
1697 if ( subkeycount == 1 ) { 1702 if ( subkeycount == 1 ) {
@@ -1737,29 +1742,28 @@ QStringList QSettings::subkeyList(const QString &key) const
1737 1742
1738 This function returns the time of last modification for \a key. 1743 This function returns the time of last modification for \a key.
1739*/ 1744*/
1740QDateTime QSettings::lastModficationTime(const QString &key) 1745QDateTime 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
1746 return QDateTime(); 1752 return QDateTime();
1747 } 1753 }
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))
1752 if ( d->sysd ) 1756 if ( d->sysd )
1753 return QDateTime(); 1757 return QDateTime();
1754#endif 1758#endif
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
1760 if (list.count() < 2) { 1764 if (list.count() < 2) {
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
1764 1768
1765 return QDateTime(); 1769 return QDateTime();
@@ -1780,6 +1784,7 @@ QDateTime QSettings::lastModficationTime(const QString &key)
1780 1784
1781/*! 1785/*!
1782 \overload 1786 \overload
1787 \obsolete
1783 1788
1784 Writes the string list entry \a value into key \a key. The \a key 1789 Writes the string list entry \a value into key \a key. The \a key
1785 is created if it doesn't exist. Any previous value is overwritten 1790 is created if it doesn't exist. Any previous value is overwritten
@@ -1796,10 +1801,11 @@ QDateTime QSettings::lastModficationTime(const QString &key)
1796 We recommend using the writeEntry() and readListEntry() overloads 1801 We recommend using the writeEntry() and readListEntry() overloads
1797 that do not take a \a separator argument. 1802 that do not take a \a separator argument.
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
1800 returned; otherwise returns TRUE. 1806 returned; otherwise returns TRUE.
1801 1807
1802 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() 1808 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry(), QStringList::join()
1803*/ 1809*/
1804bool QSettings::writeEntry(const QString &key, const QStringList &value, 1810bool QSettings::writeEntry(const QString &key, const QStringList &value,
1805 const QChar &separator) 1811 const QChar &separator)
@@ -1839,11 +1845,12 @@ bool QSettings::writeEntry(const QString &key, const QStringList &value)
1839 1845
1840/*! 1846/*!
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
1843 Reads the entry specified by \a key as a string. The \a separator 1850 Reads the entry specified by \a key as a string. The \a separator
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
1848 \warning As the documentation states, QStringList::split() will 1855 \warning As the documentation states, QStringList::split() will
1849 omit empty strings from the list. Because of this, it is 1856 omit empty strings from the list. Because of this, it is
@@ -1851,7 +1858,6 @@ bool QSettings::writeEntry(const QString &key, const QStringList &value)
1851 recommend using the readListEntry() and writeEntry() overloads 1858 recommend using the readListEntry() and writeEntry() overloads
1852 that do not take a \a separator argument. 1859 that do not take a \a separator argument.
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
1856 over a copy, e.g. 1862 over a copy, e.g.
1857 \code 1863 \code
@@ -1949,8 +1955,7 @@ void qt_setSettingsBasePath(const QString &); //qsettings_mac.cpp
1949 QSettings::Global for system-wide settings (generally 1955 QSettings::Global for system-wide settings (generally
1950 these will be read-only to many users). 1956 these will be read-only to many users).
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*/
1955 1960
1956void QSettings::setPath( const QString &domain, const QString &product, Scope scope ) 1961void QSettings::setPath( const QString &domain, const QString &product, Scope scope )
@@ -1980,13 +1985,19 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc
1980 actualSearchPath = "/" + domain.mid( 0, lastDot ) + "/" + product; 1985 actualSearchPath = "/" + domain.mid( 0, lastDot ) + "/" + product;
1981 insertSearchPath( Windows, actualSearchPath ); 1986 insertSearchPath( Windows, actualSearchPath );
1982#elif !defined(QWS) && defined(Q_OS_MAC) 1987#elif !defined(QWS) && defined(Q_OS_MAC)
1983 QString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + "."; 1988 if(lastDot != -1) {
1984 if ( !topLevelDomain.isEmpty() ) 1989 QString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + ".";
1985 qt_setSettingsBasePath( topLevelDomain ); 1990 if ( !topLevelDomain.isEmpty() )
1986 actualSearchPath = "/" + domain.left( lastDot ) + product; 1991 qt_setSettingsBasePath( topLevelDomain );
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 );
1991#endif 2002#endif
1992} 2003}