summaryrefslogtreecommitdiff
path: root/qmake/tools/qsettings.cpp
Side-by-side diff
Diffstat (limited to 'qmake/tools/qsettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/tools/qsettings.cpp387
1 files changed, 246 insertions, 141 deletions
diff --git a/qmake/tools/qsettings.cpp b/qmake/tools/qsettings.cpp
index 5de105c..35fc039 100644
--- a/qmake/tools/qsettings.cpp
+++ b/qmake/tools/qsettings.cpp
@@ -5,3 +5,3 @@
**
-** Created: 2000.06.26
+** Created : 000626
**
@@ -65,25 +65,25 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
/*!
- \class QSettings
- \brief The QSettings class provides persistent platform-independent application settings.
-
- \ingroup io
- \ingroup misc
- \mainclass
-
- On Unix systems, QSettings uses text files to store settings. On Windows
- systems, QSettings uses the system registry. On Mac OS X, QSettings will
- behave as on Unix, and store to text files.
-
- Each setting comprises an identifying key and the data associated with
- the key. A key is a unicode string which consists of \e two or more
- subkeys. A subkey is a slash, '/', followed by one or more unicode
- characters (excluding slashes, newlines, carriage returns and equals,
- '=', signs). The associated data, called the entry or value, may be a
- boolean, an integer, a double, a string or a list of strings. Entry
- strings may contain any unicode characters.
-
- If you want to save and restore the entire desktop's settings, i.e.
- which applications are running, use QSettings to save the settings
- for each individual application and QSessionManager to save the
- desktop's session.
+ \class QSettings
+ \brief The QSettings class provides persistent platform-independent application settings.
+
+ \ingroup io
+ \ingroup misc
+ \mainclass
+
+ On Unix systems, QSettings uses text files to store settings. On Windows
+ systems, QSettings uses the system registry. On Mac OS X, QSettings uses
+ the Carbon preferences API.
+
+ Each setting comprises an identifying key and the data associated with
+ the key. A key is a unicode string which consists of \e two or more
+ subkeys. A subkey is a slash, '/', followed by one or more unicode
+ characters (excluding slashes, newlines, carriage returns and equals,
+ '=', signs). The associated data, called the entry or value, may be a
+ boolean, an integer, a double, a string or a list of strings. Entry
+ strings may contain any unicode characters.
+
+ If you want to save and restore the entire desktop's settings, i.e.
+ which applications are running, use QSettings to save the settings
+ for each individual application and QSessionManager to save the
+ desktop's session.
@@ -103,10 +103,9 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
- A typical usage pattern for application startup:
+ A typical usage pattern for reading application startup:
\code
QSettings settings;
- settings.insertSearchPath( QSettings::Windows, "/MyCompany" );
- // No search path needed for Unix; see notes further on.
- // Use default values if the keys don't exist
- QString bgColor = settings.readEntry( "/MyApplication/background color", "white" );
- int width = settings.readNumEntry( "/MyApplication/geometry/width", 640 );
+ settings.setPath( "MyCompany.com", "MyApplication" );
+
+ QString bgColor = settings.readEntry( "/colors/background", "white" );
+ int width = settings.readNumEntry( "/geometry/width", 640 );
// ...
@@ -117,6 +116,6 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
QSettings settings;
- settings.insertSearchPath( QSettings::Windows, "/MyCompany" );
- // No search path needed for Unix; see notes further on.
- settings.writeEntry( "/MyApplication/background color", bgColor );
- settings.writeEntry( "/MyApplication/geometry/width", width );
+ settings.setPath( "MyCompany.com", "MyApplication" );
+
+ settings.writeEntry( "/colors/background", bgColor );
+ settings.writeEntry( "/geometry/width", width );
// ...
@@ -124,2 +123,18 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
+ QSettings can build a key prefix that is prepended to all keys. To
+ build the key prefix, use beginGroup() and endGroup().
+ \code
+ QSettings settings;
+
+ settings.beginGroup( "/MainWindow" );
+ settings.beginGroup( "/Geometry" );
+ int x = settings.readEntry( "/x" );
+ // ...
+ settings.endGroup();
+ settings.beginGroup( "/Toolbars" );
+ // ...
+ settings.endGroup();
+ settings.endGroup();
+ \endcode
+
You can get a list of entry-holding keys by calling entryList(), and
@@ -141,6 +156,2 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
- If you wish to use a different search path call insertSearchPath()
- as often as necessary to add your preferred paths. Call
- removeSearchPath() to remove any unwanted paths.
-
Since settings for Windows are stored in the registry there are size
@@ -154,3 +165,21 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
- These limitations are not enforced on Unix.
+ These limitations are not enforced on Unix or Mac OS X.
+
+ If you wish to use a different search path call insertSearchPath()
+ as often as necessary to add your preferred paths. Call
+ removeSearchPath() to remove any unwanted paths.
+
+ \section1 Notes for Mac OS X Applications
+
+ Internal to the CFPreferences API it is not defined (for Mac OS 9
+ support) where the settings will ultimitely be stored. However, at the
+ time of this writing the settings will be stored (either on a global or
+ user basis, preferring locally) into a plist file in
+ $ROOT/System/Library/Preferences (in XML format). QSettings will create
+ an appropriate plist file (com.<first group name>.plist) out of the
+ full path to a key.
+
+ For further information on CFPreferences see also
+ \link http://developer.apple.com/techpubs/macosx/CoreFoundation/PreferenceServices/preferenceservices_carbon.html
+ Apple's Specifications\endlink
@@ -302,3 +331,3 @@ static HANDLE openlock( const QString &name, int /*type*/ )
- if ( !LockFile( fd, 0, 0, -1, -1 ) ) {
+ if ( !LockFile( fd, 0, 0, (DWORD)-1, (DWORD)-1 ) ) { // ### (DWORD)-1 ???
#ifdef QT_CHECK_STATE
@@ -310,3 +339,3 @@ static HANDLE openlock( const QString &name, int /*type*/ )
-void closelock( HANDLE fd )
+static void closelock( HANDLE fd )
{
@@ -315,3 +344,3 @@ void closelock( HANDLE fd )
- if ( !UnlockFile( fd, 0, 0, -1, -1 ) ) {
+ if ( !UnlockFile( fd, 0, 0, (DWORD)-1, (DWORD)-1 ) ) { // ### (DWORD)-1 ???
#ifdef QT_CHECK_STATE
@@ -457,5 +486,7 @@ QSettingsPrivate::QSettingsPrivate( QSettings::Format format )
{
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( format != QSettings::Ini )
return;
+#else
+ Q_UNUSED( format );
#endif
@@ -508,2 +539,4 @@ QSettingsPrivate::QSettingsPrivate( QSettings::Format format )
qWarning("QSettings: error creating %s", dir.path().latin1());
+#else
+ ;
#endif
@@ -532,2 +565,4 @@ QSettingsGroup QSettingsPrivate::readGroup()
QStringList::Iterator it = searchPaths.begin();
+ if ( !globalScope )
+ ++it;
while (it != searchPaths.end()) {
@@ -566,2 +601,4 @@ void QSettingsPrivate::removeGroup(const QString &key)
QStringList::Iterator it = searchPaths.begin();
+ if ( !globalScope )
+ ++it;
while (it != searchPaths.end()) {
@@ -617,2 +654,4 @@ void QSettingsPrivate::writeGroup(const QString &key, const QString &value)
QStringList::Iterator it = searchPaths.begin();
+ if ( !globalScope )
+ ++it;
while (it != searchPaths.end()) {
@@ -651,2 +690,4 @@ QDateTime QSettingsPrivate::modificationTime()
QStringList::Iterator it = searchPaths.begin();
+ if ( !globalScope )
+ ++it;
while (it != searchPaths.end()) {
@@ -660,3 +701,3 @@ QDateTime QSettingsPrivate::modificationTime()
-static bool verifyKey( const QString &key )
+bool qt_verify_key( const QString &key )
{
@@ -669,4 +710,10 @@ static inline QString groupKey( const QString &group, const QString &key )
{
- if ( group.endsWith( "/" ) || key.startsWith( "/" ) )
+ if ( group.isEmpty() || ( group.length() == 1 && group[0] == '/' ) ) {
+ // group is empty, or it contains a single '/', so we just return the key
+ if ( key.startsWith( "/" ) )
+ return key;
+ return "/" + key;
+ } else if ( group.endsWith( "/" ) || key.startsWith( "/" ) ) {
return group + key;
+ }
return group + "/" + key;
@@ -688,3 +735,3 @@ static inline QString groupKey( const QString &group, const QString &key )
first folder (listed below) to the last, returning the first
- settings found, and ignoring any folders for which the user doesn't
+ settings found, and ignoring any folders for which the user doesn't
have read permission.
@@ -712,3 +759,3 @@ static inline QString groupKey( const QString &group, const QString &key )
If a setting is found in the HKEY_CURRENT_USER space, this setting
- is overwritten independently of write permissions in the
+ is overwritten independently of write permissions in the
HKEY_LOCAL_MACHINE space.
@@ -759,3 +806,3 @@ void QSettings::insertSearchPath( System s, const QString &path)
{
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd ) {
@@ -766,3 +813,12 @@ void QSettings::insertSearchPath( System s, const QString &path)
- if ( !verifyKey( path ) ) {
+#if !defined(Q_WS_WIN)
+ if ( s == Windows )
+ return;
+#endif
+#if !defined(Q_WS_WIN)
+ if ( s == Mac )
+ return;
+#endif
+
+ if ( !qt_verify_key( path ) ) {
#if defined(QT_CHECK_STATE)
@@ -773,3 +829,3 @@ void QSettings::insertSearchPath( System s, const QString &path)
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd && s != Unix ) {
@@ -778,3 +834,3 @@ void QSettings::insertSearchPath( System s, const QString &path)
#endif
-#ifdef Q_OS_MAC
+#if !defined(QWS) && defined(Q_OS_MAC)
if(s != Mac) //mac is respected on the mac as well
@@ -784,5 +840,11 @@ void QSettings::insertSearchPath( System s, const QString &path)
+ QString realPath = path;
+#if defined(Q_WS_WIN)
+ QString defPath = d->globalScope ? d->searchPaths.first() : d->searchPaths.last();
+ realPath = defPath + path;
+#endif
+
QStringList::Iterator it = d->searchPaths.find(d->searchPaths.last());
if (it != d->searchPaths.end()) {
- d->searchPaths.insert(it, path);
+ d->searchPaths.insert(it, realPath);
}
@@ -800,3 +862,3 @@ void QSettings::removeSearchPath( System s, const QString &path)
{
- if ( !verifyKey( path ) ) {
+ if ( !qt_verify_key( path ) ) {
#if defined(QT_CHECK_STATE)
@@ -813,3 +875,3 @@ void QSettings::removeSearchPath( System s, const QString &path)
#endif
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd && s != Unix ) {
@@ -818,3 +880,3 @@ void QSettings::removeSearchPath( System s, const QString &path)
#endif
-#ifdef Q_OS_MAC
+#if !defined(QWS) && defined(Q_OS_MAC)
if(s != Mac) //mac is respected on the mac as well
@@ -839,3 +901,3 @@ QSettings::QSettings()
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
d->sysd = 0;
@@ -856,3 +918,3 @@ QSettings::QSettings( Format format )
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
d->sysd = 0;
@@ -874,3 +936,3 @@ QSettings::~QSettings()
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
@@ -889,3 +951,3 @@ bool QSettings::sync()
{
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
@@ -907,2 +969,4 @@ bool QSettings::sync()
QStringList::Iterator pit = d->searchPaths.begin();
+ if ( !d->globalScope )
+ ++pit;
while (pit != d->searchPaths.end()) {
@@ -919,5 +983,5 @@ bool QSettings::sync()
- it++;
+ ++it;
- if (file.name().isNull() || file.name().isEmpty()) {
+ if ( file.name().isEmpty() ) {
@@ -965,3 +1029,3 @@ bool QSettings::sync()
stream << grpit.key() << "=" << v << endl;
- grpit++;
+ ++grpit;
}
@@ -971,3 +1035,3 @@ bool QSettings::sync()
- hdit++;
+ ++hdit;
}
@@ -1010,3 +1074,3 @@ bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok )
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1020,9 +1084,8 @@ bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok )
- QString theKey = groupKey( group(), key );
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
- return d->sysReadBoolEntry( theKey, def, ok );
+ return d->sysReadBoolEntry( groupKey( group(), key ), def, ok );
#endif
- QString value = readEntry( theKey, ( def ? "true" : "false" ), ok );
+ QString value = readEntry( key, ( def ? "true" : "false" ), ok );
@@ -1062,3 +1125,3 @@ double QSettings::readDoubleEntry(const QString &key, double def, bool *ok )
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1072,9 +1135,8 @@ double QSettings::readDoubleEntry(const QString &key, double def, bool *ok )
- QString theKey = groupKey( group(), key );
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
- return d->sysReadDoubleEntry( theKey, def, ok );
+ return d->sysReadDoubleEntry( groupKey( group(), key ), def, ok );
#endif
- QString value = readEntry( theKey, QString::number(def), ok );
+ QString value = readEntry( key, QString::number(def), ok );
bool conv_ok;
@@ -1108,3 +1170,3 @@ int QSettings::readNumEntry(const QString &key, int def, bool *ok )
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1117,10 +1179,8 @@ int QSettings::readNumEntry(const QString &key, int def, bool *ok )
- QString theKey = groupKey( group(), key );
-
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
- return d->sysReadNumEntry( theKey, def, ok );
+ return d->sysReadNumEntry( groupKey( group(), key ), def, ok );
#endif
- QString value = readEntry( theKey, QString::number( def ), ok );
+ QString value = readEntry( key, QString::number( def ), ok );
bool conv_ok;
@@ -1154,3 +1214,3 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1166,3 +1226,3 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
@@ -1208,7 +1268,9 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
QSettingsGroup grp = d->readGroup();
- QString retval = grp[realkey];
- if ( retval.isNull() )
- retval = def;
- else if ( ok ) // everything is ok
- *ok = TRUE;
+ QSettingsGroup::const_iterator it = grp.find( realkey ), end = grp.end();
+ QString retval = def;
+ if ( it != end ) {
+ // found the value we needed
+ retval = *it;
+ if ( ok ) *ok = TRUE;
+ }
return retval;
@@ -1230,3 +1292,3 @@ bool QSettings::writeEntry(const QString &key, bool value)
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1237,10 +1299,8 @@ bool QSettings::writeEntry(const QString &key, bool value)
- QString theKey = groupKey( group(), key );
-
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
- return d->sysWriteEntry( theKey, value );
+ return d->sysWriteEntry( groupKey( group(), key ), value );
#endif
QString s(value ? "true" : "false");
- return writeEntry(theKey, s);
+ return writeEntry(key, s);
}
@@ -1262,3 +1322,3 @@ bool QSettings::writeEntry(const QString &key, double value)
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1269,10 +1329,8 @@ bool QSettings::writeEntry(const QString &key, double value)
- QString theKey = groupKey( group(), key );
-
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
- return d->sysWriteEntry( theKey, value );
+ return d->sysWriteEntry( groupKey( group(), key ), value );
#endif
QString s(QString::number(value));
- return writeEntry(theKey, s);
+ return writeEntry(key, s);
}
@@ -1293,3 +1351,3 @@ bool QSettings::writeEntry(const QString &key, int value)
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1300,10 +1358,8 @@ bool QSettings::writeEntry(const QString &key, int value)
- QString theKey = groupKey( group(), key );
-
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
- return d->sysWriteEntry( theKey, value );
+ return d->sysWriteEntry( groupKey( group(), key ), value );
#endif
QString s(QString::number(value));
- return writeEntry(theKey, s);
+ return writeEntry(key, s);
}
@@ -1329,3 +1385,3 @@ bool QSettings::writeEntry(const QString &key, const char *value)
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1336,5 +1392,3 @@ bool QSettings::writeEntry(const QString &key, const char *value)
- QString theKey = groupKey( group(), key );
-
- return writeEntry(theKey, QString(value));
+ return writeEntry(key, QString(value));
}
@@ -1356,3 +1410,3 @@ bool QSettings::writeEntry(const QString &key, const QString &value)
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1365,3 +1419,3 @@ bool QSettings::writeEntry(const QString &key, const QString &value)
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
@@ -1417,3 +1471,3 @@ bool QSettings::removeEntry(const QString &key)
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1426,3 +1480,3 @@ bool QSettings::removeEntry(const QString &key)
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
@@ -1496,3 +1550,3 @@ QStringList QSettings::entryList(const QString &key) const
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1505,3 +1559,3 @@ QStringList QSettings::entryList(const QString &key) const
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
@@ -1546,3 +1600,3 @@ QStringList QSettings::entryList(const QString &key) const
itkey = it.key();
- it++;
+ ++it;
@@ -1593,3 +1647,3 @@ QStringList QSettings::subkeyList(const QString &key) const
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1602,3 +1656,3 @@ QStringList QSettings::subkeyList(const QString &key) const
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
@@ -1608,2 +1662,3 @@ QStringList QSettings::subkeyList(const QString &key) const
QString realkey;
+ int subkeycount = 2;
if (theKey[0] == '/') {
@@ -1620,2 +1675,4 @@ QStringList QSettings::subkeyList(const QString &key) const
+ subkeycount = list.count();
+
if (list.count() == 1) {
@@ -1634,2 +1691,3 @@ QStringList QSettings::subkeyList(const QString &key) const
}
+
} else
@@ -1637,5 +1695,16 @@ QStringList QSettings::subkeyList(const QString &key) const
+ QStringList ret;
+ if ( subkeycount == 1 ) {
+ QMap<QString,QSettingsHeading>::Iterator it = d->headings.begin();
+ while ( it != d->headings.end() ) {
+ if ( it.key() != "General" && ! ret.contains( it.key() ) )
+ ret << it.key();
+ ++it;
+ }
+
+ return ret;
+ }
+
QSettingsGroup grp = d->readGroup();
QSettingsGroup::Iterator it = grp.begin();
- QStringList ret;
QString itkey;
@@ -1643,3 +1712,3 @@ QStringList QSettings::subkeyList(const QString &key) const
itkey = it.key();
- it++;
+ ++it;
@@ -1672,3 +1741,3 @@ QDateTime QSettings::lastModficationTime(const QString &key)
{
- if ( !verifyKey( key ) ) {
+ if ( !qt_verify_key( key ) ) {
#if defined(QT_CHECK_STATE)
@@ -1681,3 +1750,3 @@ QDateTime QSettings::lastModficationTime(const QString &key)
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
+#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
@@ -1717,5 +1786,13 @@ QDateTime QSettings::lastModficationTime(const QString &key)
by \a value. The list is stored as a sequence of strings separated
- by \a separator, so none of the strings in the list should contain
- the separator. If the list is empty or null the key's value will
- be an empty string.
+ by \a separator (using QStringList::join()), so none of the
+ strings in the list should contain the separator. If the list is
+ empty or null the key's value will be an empty string.
+
+ \warning The list should not contain empty or null strings, as
+ readListEntry() will use QStringList::split() to recreate the
+ list. As the documentation states, QStringList::split() will omit
+ empty strings from the list. Because of this, it is impossible to
+ retrieve identical list data that is stored with this function.
+ We recommend using the writeEntry() and readListEntry() overloads
+ that do not take a \a separator argument.
@@ -1770,2 +1847,9 @@ bool QSettings::writeEntry(const QString &key, const QStringList &value)
+ \warning As the documentation states, QStringList::split() will
+ omit empty strings from the list. Because of this, it is
+ impossible to retrieve identical list data with this function. We
+ recommend using the readListEntry() and writeEntry() overloads
+ that do not take a \a separator argument.
+
+
Note that if you want to iterate over the list, you should iterate
@@ -1849,15 +1933,22 @@ QStringList QSettings::readListEntry(const QString &key, bool *ok )
+#ifdef Q_OS_MAC
+void qt_setSettingsBasePath(const QString &); //qsettings_mac.cpp
+#endif
+
/*!
- Insert platform-dependent paths from platform-independent information.
+ Insert platform-dependent paths from platform-independent information.
+
+ The \a domain should be an Internet domain name
+ controlled by the producer of the software, eg. Trolltech products
+ use "trolltech.com".
- The \a domain should be an Internet domain name
- controlled by the producer of the software, eg. Trolltech products
- use "trolltech.com".
+ The \a product should be the official name of the product.
- The \a product should be the official name of the product.
+ The \a scope should be
+ QSettings::User for user-specific settings, or
+ QSettings::Global for system-wide settings (generally
+ these will be read-only to many users).
- The \a scope should be
- QSettings::User for user-specific settings, or
- QSettings::Global for system-wide settings (generally
- these will be read-only to many users).
+ Not all information is relevant on all systems (e.g. scoping is
+ currently used only if QSettings accesses the Windows registry).
*/
@@ -1875,3 +1966,3 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc
// scope.
-//
+//
// On MacOS X, if there is no "." in domain, append ".com", then reverse the
@@ -1882,2 +1973,4 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc
// scope.
+ d->globalScope = scope == Global;
+
QString actualSearchPath;
@@ -1888,7 +1981,7 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc
insertSearchPath( Windows, actualSearchPath );
-#elif defined(Q_WS_MAC)
+#elif !defined(QWS) && defined(Q_OS_MAC)
QString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + ".";
- if ( topLevelDomain.isEmpty() )
- topLevelDomain = "com.";
- actualSearchPath = "/" + topLevelDomain + domain.left( lastDot ) + product;
+ if ( !topLevelDomain.isEmpty() )
+ qt_setSettingsBasePath( topLevelDomain );
+ actualSearchPath = "/" + domain.left( lastDot ) + product;
insertSearchPath( Mac, actualSearchPath );
@@ -1898,4 +1991,2 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc
#endif
-
- d->globalScope = scope == Global;
}
@@ -1904,2 +1995,9 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc
Appends \a group to the current key prefix.
+
+ \code
+ QSettings settings;
+ settings.beginGroup( "/MainWindow" );
+ // read values
+ settings.endGroup();
+ \endcode
*/
@@ -1914,2 +2012,9 @@ void QSettings::beginGroup( const QString &group )
by a single call to endGroup().
+
+ \code
+ QSettings settings;
+ settings.beginGroup( "/MainWindow/Geometry" );
+ // read values
+ settings.endGroup();
+ \endcode
*/
@@ -1947,3 +2052,3 @@ QString QSettings::group() const
if ( group[0] != '/' )
- group = "/" + group;
+ group.prepend( "/" );
d->groupPrefix += group;