-rw-r--r-- | qmake/tools/qsettings.cpp | 321 |
1 files changed, 213 insertions, 108 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 | |||
@@ -4,5 +4,5 @@ | |||
4 | ** Implementation of QSettings class | 4 | ** Implementation of QSettings class |
5 | ** | 5 | ** |
6 | ** Created: 2000.06.26 | 6 | ** Created : 000626 |
7 | ** | 7 | ** |
8 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
@@ -72,6 +72,6 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
72 | 72 | ||
73 | On Unix systems, QSettings uses text files to store settings. On Windows | 73 | On Unix systems, QSettings uses text files to store settings. On Windows |
74 | systems, QSettings uses the system registry. On Mac OS X, QSettings will | 74 | systems, QSettings uses the system registry. On Mac OS X, QSettings uses |
75 | behave as on Unix, and store to text files. | 75 | the Carbon preferences API. |
76 | 76 | ||
77 | Each setting comprises an identifying key and the data associated with | 77 | Each setting comprises an identifying key and the data associated with |
@@ -102,12 +102,11 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
102 | Each line above is a complete key, made up of subkeys. | 102 | Each line above is a complete key, made up of subkeys. |
103 | 103 | ||
104 | A typical usage pattern for application startup: | 104 | A typical usage pattern for reading application startup: |
105 | \code | 105 | \code |
106 | QSettings settings; | 106 | QSettings settings; |
107 | settings.insertSearchPath( QSettings::Windows, "/MyCompany" ); | 107 | settings.setPath( "MyCompany.com", "MyApplication" ); |
108 | // No search path needed for Unix; see notes further on. | 108 | |
109 | // Use default values if the keys don't exist | 109 | QString bgColor = settings.readEntry( "/colors/background", "white" ); |
110 | QString bgColor = settings.readEntry( "/MyApplication/background color", "white" ); | 110 | int width = settings.readNumEntry( "/geometry/width", 640 ); |
111 | int width = settings.readNumEntry( "/MyApplication/geometry/width", 640 ); | ||
112 | // ... | 111 | // ... |
113 | \endcode | 112 | \endcode |
@@ -116,9 +115,25 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
116 | \code | 115 | \code |
117 | QSettings settings; | 116 | QSettings settings; |
118 | settings.insertSearchPath( QSettings::Windows, "/MyCompany" ); | 117 | settings.setPath( "MyCompany.com", "MyApplication" ); |
119 | // No search path needed for Unix; see notes further on. | 118 | |
120 | settings.writeEntry( "/MyApplication/background color", bgColor ); | 119 | settings.writeEntry( "/colors/background", bgColor ); |
121 | settings.writeEntry( "/MyApplication/geometry/width", width ); | 120 | settings.writeEntry( "/geometry/width", width ); |
121 | // ... | ||
122 | \endcode | ||
123 | |||
124 | QSettings can build a key prefix that is prepended to all keys. To | ||
125 | build the key prefix, use beginGroup() and endGroup(). | ||
126 | \code | ||
127 | QSettings settings; | ||
128 | |||
129 | settings.beginGroup( "/MainWindow" ); | ||
130 | settings.beginGroup( "/Geometry" ); | ||
131 | int x = settings.readEntry( "/x" ); | ||
132 | // ... | ||
133 | settings.endGroup(); | ||
134 | settings.beginGroup( "/Toolbars" ); | ||
122 | // ... | 135 | // ... |
136 | settings.endGroup(); | ||
137 | settings.endGroup(); | ||
123 | \endcode | 138 | \endcode |
124 | 139 | ||
@@ -140,8 +155,4 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
140 | \endcode | 155 | \endcode |
141 | 156 | ||
142 | If you wish to use a different search path call insertSearchPath() | ||
143 | as often as necessary to add your preferred paths. Call | ||
144 | removeSearchPath() to remove any unwanted paths. | ||
145 | |||
146 | Since settings for Windows are stored in the registry there are size | 157 | Since settings for Windows are stored in the registry there are size |
147 | limits as follows: | 158 | limits as follows: |
@@ -153,5 +164,23 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) | |||
153 | \endlist | 164 | \endlist |
154 | 165 | ||
155 | These limitations are not enforced on Unix. | 166 | These limitations are not enforced on Unix or Mac OS X. |
167 | |||
168 | If you wish to use a different search path call insertSearchPath() | ||
169 | as often as necessary to add your preferred paths. Call | ||
170 | removeSearchPath() to remove any unwanted paths. | ||
171 | |||
172 | \section1 Notes for Mac OS X Applications | ||
173 | |||
174 | Internal to the CFPreferences API it is not defined (for Mac OS 9 | ||
175 | support) where the settings will ultimitely be stored. However, at the | ||
176 | time of this writing the settings will be stored (either on a global or | ||
177 | user basis, preferring locally) into a plist file in | ||
178 | $ROOT/System/Library/Preferences (in XML format). QSettings will create | ||
179 | an appropriate plist file (com.<first group name>.plist) out of the | ||
180 | full path to a key. | ||
181 | |||
182 | For further information on CFPreferences see also | ||
183 | \link http://developer.apple.com/techpubs/macosx/CoreFoundation/PreferenceServices/preferenceservices_carbon.html | ||
184 | Apple's Specifications\endlink | ||
156 | 185 | ||
157 | \section1 Notes for Unix Applications | 186 | \section1 Notes for Unix Applications |
@@ -301,5 +330,5 @@ static HANDLE openlock( const QString &name, int /*type*/ ) | |||
301 | } ); | 330 | } ); |
302 | 331 | ||
303 | if ( !LockFile( fd, 0, 0, -1, -1 ) ) { | 332 | if ( !LockFile( fd, 0, 0, (DWORD)-1, (DWORD)-1 ) ) { // ### (DWORD)-1 ??? |
304 | #ifdef QT_CHECK_STATE | 333 | #ifdef QT_CHECK_STATE |
305 | qWarning( "QSettings: openlock failed!" ); | 334 | qWarning( "QSettings: openlock failed!" ); |
@@ -309,10 +338,10 @@ static HANDLE openlock( const QString &name, int /*type*/ ) | |||
309 | } | 338 | } |
310 | 339 | ||
311 | void closelock( HANDLE fd ) | 340 | static void closelock( HANDLE fd ) |
312 | { | 341 | { |
313 | if ( !fd ) | 342 | if ( !fd ) |
314 | return; | 343 | return; |
315 | 344 | ||
316 | if ( !UnlockFile( fd, 0, 0, -1, -1 ) ) { | 345 | if ( !UnlockFile( fd, 0, 0, (DWORD)-1, (DWORD)-1 ) ) { // ### (DWORD)-1 ??? |
317 | #ifdef QT_CHECK_STATE | 346 | #ifdef QT_CHECK_STATE |
318 | qWarning( "QSettings: closelock failed!"); | 347 | qWarning( "QSettings: closelock failed!"); |
@@ -456,7 +485,9 @@ QSettingsPrivate::QSettingsPrivate( QSettings::Format format ) | |||
456 | : groupDirty( TRUE ), modified(FALSE), globalScope(TRUE) | 485 | : groupDirty( TRUE ), modified(FALSE), globalScope(TRUE) |
457 | { | 486 | { |
458 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 487 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
459 | if ( format != QSettings::Ini ) | 488 | if ( format != QSettings::Ini ) |
460 | return; | 489 | return; |
490 | #else | ||
491 | Q_UNUSED( format ); | ||
461 | #endif | 492 | #endif |
462 | 493 | ||
@@ -507,4 +538,6 @@ QSettingsPrivate::QSettingsPrivate( QSettings::Format format ) | |||
507 | #if defined(QT_CHECK_STATE) | 538 | #if defined(QT_CHECK_STATE) |
508 | qWarning("QSettings: error creating %s", dir.path().latin1()); | 539 | qWarning("QSettings: error creating %s", dir.path().latin1()); |
540 | #else | ||
541 | ; | ||
509 | #endif | 542 | #endif |
510 | } | 543 | } |
@@ -531,4 +564,6 @@ QSettingsGroup QSettingsPrivate::readGroup() | |||
531 | if (grpit == hd.end()) { | 564 | if (grpit == hd.end()) { |
532 | QStringList::Iterator it = searchPaths.begin(); | 565 | QStringList::Iterator it = searchPaths.begin(); |
566 | if ( !globalScope ) | ||
567 | ++it; | ||
533 | while (it != searchPaths.end()) { | 568 | while (it != searchPaths.end()) { |
534 | QString filebase = heading.lower().replace(QRegExp("\\s+"), "_"); | 569 | QString filebase = heading.lower().replace(QRegExp("\\s+"), "_"); |
@@ -565,4 +600,6 @@ void QSettingsPrivate::removeGroup(const QString &key) | |||
565 | if (grpit == hd.end()) { | 600 | if (grpit == hd.end()) { |
566 | QStringList::Iterator it = searchPaths.begin(); | 601 | QStringList::Iterator it = searchPaths.begin(); |
602 | if ( !globalScope ) | ||
603 | ++it; | ||
567 | while (it != searchPaths.end()) { | 604 | while (it != searchPaths.end()) { |
568 | QString filebase = heading.lower().replace(QRegExp("\\s+"), "_"); | 605 | QString filebase = heading.lower().replace(QRegExp("\\s+"), "_"); |
@@ -616,4 +653,6 @@ void QSettingsPrivate::writeGroup(const QString &key, const QString &value) | |||
616 | if (grpit == hd.end()) { | 653 | if (grpit == hd.end()) { |
617 | QStringList::Iterator it = searchPaths.begin(); | 654 | QStringList::Iterator it = searchPaths.begin(); |
655 | if ( !globalScope ) | ||
656 | ++it; | ||
618 | while (it != searchPaths.end()) { | 657 | while (it != searchPaths.end()) { |
619 | QString filebase = heading.lower().replace(QRegExp("\\s+"), "_"); | 658 | QString filebase = heading.lower().replace(QRegExp("\\s+"), "_"); |
@@ -650,4 +689,6 @@ QDateTime QSettingsPrivate::modificationTime() | |||
650 | 689 | ||
651 | QStringList::Iterator it = searchPaths.begin(); | 690 | QStringList::Iterator it = searchPaths.begin(); |
691 | if ( !globalScope ) | ||
692 | ++it; | ||
652 | while (it != searchPaths.end()) { | 693 | while (it != searchPaths.end()) { |
653 | QFileInfo fi((*it++) + "/" + heading + "rc"); | 694 | QFileInfo fi((*it++) + "/" + heading + "rc"); |
@@ -659,5 +700,5 @@ QDateTime QSettingsPrivate::modificationTime() | |||
659 | } | 700 | } |
660 | 701 | ||
661 | static bool verifyKey( const QString &key ) | 702 | bool qt_verify_key( const QString &key ) |
662 | { | 703 | { |
663 | if ( key.isEmpty() || key[0] != '/' || key.contains( QRegExp("[=\\\\r\\\\n" ) ) ) | 704 | if ( key.isEmpty() || key[0] != '/' || key.contains( QRegExp("[=\\\\r\\\\n" ) ) ) |
@@ -668,6 +709,12 @@ static bool verifyKey( const QString &key ) | |||
668 | static inline QString groupKey( const QString &group, const QString &key ) | 709 | static inline QString groupKey( const QString &group, const QString &key ) |
669 | { | 710 | { |
670 | if ( group.endsWith( "/" ) || key.startsWith( "/" ) ) | 711 | if ( group.isEmpty() || ( group.length() == 1 && group[0] == '/' ) ) { |
712 | // group is empty, or it contains a single '/', so we just return the key | ||
713 | if ( key.startsWith( "/" ) ) | ||
714 | return key; | ||
715 | return "/" + key; | ||
716 | } else if ( group.endsWith( "/" ) || key.startsWith( "/" ) ) { | ||
671 | return group + key; | 717 | return group + key; |
718 | } | ||
672 | return group + "/" + key; | 719 | return group + "/" + key; |
673 | } | 720 | } |
@@ -758,5 +805,5 @@ static inline QString groupKey( const QString &group, const QString &key ) | |||
758 | void QSettings::insertSearchPath( System s, const QString &path) | 805 | void QSettings::insertSearchPath( System s, const QString &path) |
759 | { | 806 | { |
760 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 807 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
761 | if ( d->sysd ) { | 808 | if ( d->sysd ) { |
762 | d->sysInsertSearchPath( s, path ); | 809 | d->sysInsertSearchPath( s, path ); |
@@ -765,5 +812,14 @@ void QSettings::insertSearchPath( System s, const QString &path) | |||
765 | #endif | 812 | #endif |
766 | 813 | ||
767 | if ( !verifyKey( path ) ) { | 814 | #if !defined(Q_WS_WIN) |
815 | if ( s == Windows ) | ||
816 | return; | ||
817 | #endif | ||
818 | #if !defined(Q_WS_WIN) | ||
819 | if ( s == Mac ) | ||
820 | return; | ||
821 | #endif | ||
822 | |||
823 | if ( !qt_verify_key( path ) ) { | ||
768 | #if defined(QT_CHECK_STATE) | 824 | #if defined(QT_CHECK_STATE) |
769 | qWarning( "QSettings::insertSearchPath: Invalid key: '%s'", path.isNull() ? "(null)" : path.latin1() ); | 825 | qWarning( "QSettings::insertSearchPath: Invalid key: '%s'", path.isNull() ? "(null)" : path.latin1() ); |
@@ -772,10 +828,10 @@ void QSettings::insertSearchPath( System s, const QString &path) | |||
772 | } | 828 | } |
773 | 829 | ||
774 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 830 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
775 | if ( d->sysd && s != Unix ) { | 831 | if ( d->sysd && s != Unix ) { |
776 | #else | 832 | #else |
777 | if ( s != Unix ) { | 833 | if ( s != Unix ) { |
778 | #endif | 834 | #endif |
779 | #ifdef Q_OS_MAC | 835 | #if !defined(QWS) && defined(Q_OS_MAC) |
780 | if(s != Mac) //mac is respected on the mac as well | 836 | if(s != Mac) //mac is respected on the mac as well |
781 | #endif | 837 | #endif |
@@ -783,7 +839,13 @@ void QSettings::insertSearchPath( System s, const QString &path) | |||
783 | } | 839 | } |
784 | 840 | ||
841 | QString realPath = path; | ||
842 | #if defined(Q_WS_WIN) | ||
843 | QString defPath = d->globalScope ? d->searchPaths.first() : d->searchPaths.last(); | ||
844 | realPath = defPath + path; | ||
845 | #endif | ||
846 | |||
785 | QStringList::Iterator it = d->searchPaths.find(d->searchPaths.last()); | 847 | QStringList::Iterator it = d->searchPaths.find(d->searchPaths.last()); |
786 | if (it != d->searchPaths.end()) { | 848 | if (it != d->searchPaths.end()) { |
787 | d->searchPaths.insert(it, path); | 849 | d->searchPaths.insert(it, realPath); |
788 | } | 850 | } |
789 | } | 851 | } |
@@ -799,5 +861,5 @@ void QSettings::insertSearchPath( System s, const QString &path) | |||
799 | void QSettings::removeSearchPath( System s, const QString &path) | 861 | void QSettings::removeSearchPath( System s, const QString &path) |
800 | { | 862 | { |
801 | if ( !verifyKey( path ) ) { | 863 | if ( !qt_verify_key( path ) ) { |
802 | #if defined(QT_CHECK_STATE) | 864 | #if defined(QT_CHECK_STATE) |
803 | qWarning( "QSettings::insertSearchPath: Invalid key: '%s'", path.isNull() ? "(null)" : path.latin1() ); | 865 | qWarning( "QSettings::insertSearchPath: Invalid key: '%s'", path.isNull() ? "(null)" : path.latin1() ); |
@@ -812,10 +874,10 @@ void QSettings::removeSearchPath( System s, const QString &path) | |||
812 | } | 874 | } |
813 | #endif | 875 | #endif |
814 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 876 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
815 | if ( d->sysd && s != Unix ) { | 877 | if ( d->sysd && s != Unix ) { |
816 | #else | 878 | #else |
817 | if ( s != Unix ) { | 879 | if ( s != Unix ) { |
818 | #endif | 880 | #endif |
819 | #ifdef Q_OS_MAC | 881 | #if !defined(QWS) && defined(Q_OS_MAC) |
820 | if(s != Mac) //mac is respected on the mac as well | 882 | if(s != Mac) //mac is respected on the mac as well |
821 | #endif | 883 | #endif |
@@ -838,5 +900,5 @@ QSettings::QSettings() | |||
838 | Q_CHECK_PTR(d); | 900 | Q_CHECK_PTR(d); |
839 | 901 | ||
840 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 902 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
841 | d->sysd = 0; | 903 | d->sysd = 0; |
842 | d->sysInit(); | 904 | d->sysInit(); |
@@ -855,5 +917,5 @@ QSettings::QSettings( Format format ) | |||
855 | Q_CHECK_PTR(d); | 917 | Q_CHECK_PTR(d); |
856 | 918 | ||
857 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 919 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
858 | d->sysd = 0; | 920 | d->sysd = 0; |
859 | if ( format == Native ) | 921 | if ( format == Native ) |
@@ -873,5 +935,5 @@ QSettings::~QSettings() | |||
873 | sync(); | 935 | sync(); |
874 | 936 | ||
875 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 937 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
876 | if ( d->sysd ) | 938 | if ( d->sysd ) |
877 | d->sysClear(); | 939 | d->sysClear(); |
@@ -888,5 +950,5 @@ QSettings::~QSettings() | |||
888 | bool QSettings::sync() | 950 | bool QSettings::sync() |
889 | { | 951 | { |
890 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 952 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
891 | if ( d->sysd ) | 953 | if ( d->sysd ) |
892 | return d->sysSync(); | 954 | return d->sysSync(); |
@@ -906,4 +968,6 @@ bool QSettings::sync() | |||
906 | 968 | ||
907 | QStringList::Iterator pit = d->searchPaths.begin(); | 969 | QStringList::Iterator pit = d->searchPaths.begin(); |
970 | if ( !d->globalScope ) | ||
971 | ++pit; | ||
908 | while (pit != d->searchPaths.end()) { | 972 | while (pit != d->searchPaths.end()) { |
909 | QString filebase = it.key().lower().replace(QRegExp("\\s+"), "_"); | 973 | QString filebase = it.key().lower().replace(QRegExp("\\s+"), "_"); |
@@ -918,7 +982,7 @@ bool QSettings::sync() | |||
918 | } | 982 | } |
919 | 983 | ||
920 | it++; | 984 | ++it; |
921 | 985 | ||
922 | if (file.name().isNull() || file.name().isEmpty()) { | 986 | if ( file.name().isEmpty() ) { |
923 | 987 | ||
924 | #ifdef QT_CHECK_STATE | 988 | #ifdef QT_CHECK_STATE |
@@ -964,5 +1028,5 @@ bool QSettings::sync() | |||
964 | 1028 | ||
965 | stream << grpit.key() << "=" << v << endl; | 1029 | stream << grpit.key() << "=" << v << endl; |
966 | grpit++; | 1030 | ++grpit; |
967 | } | 1031 | } |
968 | 1032 | ||
@@ -970,5 +1034,5 @@ bool QSettings::sync() | |||
970 | } | 1034 | } |
971 | 1035 | ||
972 | hdit++; | 1036 | ++hdit; |
973 | } | 1037 | } |
974 | 1038 | ||
@@ -1009,5 +1073,5 @@ bool QSettings::sync() | |||
1009 | bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok ) | 1073 | bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok ) |
1010 | { | 1074 | { |
1011 | if ( !verifyKey( key ) ) { | 1075 | if ( !qt_verify_key( key ) ) { |
1012 | #if defined(QT_CHECK_STATE) | 1076 | #if defined(QT_CHECK_STATE) |
1013 | qWarning( "QSettings::readBoolEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1077 | qWarning( "QSettings::readBoolEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1019,11 +1083,10 @@ bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok ) | |||
1019 | } | 1083 | } |
1020 | 1084 | ||
1021 | QString theKey = groupKey( group(), key ); | 1085 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1022 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | ||
1023 | if ( d->sysd ) | 1086 | if ( d->sysd ) |
1024 | return d->sysReadBoolEntry( theKey, def, ok ); | 1087 | return d->sysReadBoolEntry( groupKey( group(), key ), def, ok ); |
1025 | #endif | 1088 | #endif |
1026 | 1089 | ||
1027 | QString value = readEntry( theKey, ( def ? "true" : "false" ), ok ); | 1090 | QString value = readEntry( key, ( def ? "true" : "false" ), ok ); |
1028 | 1091 | ||
1029 | if (value.lower() == "true") | 1092 | if (value.lower() == "true") |
@@ -1061,5 +1124,5 @@ bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok ) | |||
1061 | double QSettings::readDoubleEntry(const QString &key, double def, bool *ok ) | 1124 | double QSettings::readDoubleEntry(const QString &key, double def, bool *ok ) |
1062 | { | 1125 | { |
1063 | if ( !verifyKey( key ) ) { | 1126 | if ( !qt_verify_key( key ) ) { |
1064 | #if defined(QT_CHECK_STATE) | 1127 | #if defined(QT_CHECK_STATE) |
1065 | qWarning( "QSettings::readDoubleEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1128 | qWarning( "QSettings::readDoubleEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1071,11 +1134,10 @@ double QSettings::readDoubleEntry(const QString &key, double def, bool *ok ) | |||
1071 | } | 1134 | } |
1072 | 1135 | ||
1073 | QString theKey = groupKey( group(), key ); | 1136 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1074 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | ||
1075 | if ( d->sysd ) | 1137 | if ( d->sysd ) |
1076 | return d->sysReadDoubleEntry( theKey, def, ok ); | 1138 | return d->sysReadDoubleEntry( groupKey( group(), key ), def, ok ); |
1077 | #endif | 1139 | #endif |
1078 | 1140 | ||
1079 | QString value = readEntry( theKey, QString::number(def), ok ); | 1141 | QString value = readEntry( key, QString::number(def), ok ); |
1080 | bool conv_ok; | 1142 | bool conv_ok; |
1081 | double retval = value.toDouble( &conv_ok ); | 1143 | double retval = value.toDouble( &conv_ok ); |
@@ -1107,5 +1169,5 @@ double QSettings::readDoubleEntry(const QString &key, double def, bool *ok ) | |||
1107 | int QSettings::readNumEntry(const QString &key, int def, bool *ok ) | 1169 | int QSettings::readNumEntry(const QString &key, int def, bool *ok ) |
1108 | { | 1170 | { |
1109 | if ( !verifyKey( key ) ) { | 1171 | if ( !qt_verify_key( key ) ) { |
1110 | #if defined(QT_CHECK_STATE) | 1172 | #if defined(QT_CHECK_STATE) |
1111 | qWarning( "QSettings::readNumEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1173 | qWarning( "QSettings::readNumEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1116,12 +1178,10 @@ int QSettings::readNumEntry(const QString &key, int def, bool *ok ) | |||
1116 | } | 1178 | } |
1117 | 1179 | ||
1118 | QString theKey = groupKey( group(), key ); | 1180 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1119 | |||
1120 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | ||
1121 | if ( d->sysd ) | 1181 | if ( d->sysd ) |
1122 | return d->sysReadNumEntry( theKey, def, ok ); | 1182 | return d->sysReadNumEntry( groupKey( group(), key ), def, ok ); |
1123 | #endif | 1183 | #endif |
1124 | 1184 | ||
1125 | QString value = readEntry( theKey, QString::number( def ), ok ); | 1185 | QString value = readEntry( key, QString::number( def ), ok ); |
1126 | bool conv_ok; | 1186 | bool conv_ok; |
1127 | int retval = value.toInt( &conv_ok ); | 1187 | int retval = value.toInt( &conv_ok ); |
@@ -1153,5 +1213,5 @@ int QSettings::readNumEntry(const QString &key, int def, bool *ok ) | |||
1153 | QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) | 1213 | QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) |
1154 | { | 1214 | { |
1155 | if ( !verifyKey( key ) ) { | 1215 | if ( !qt_verify_key( key ) ) { |
1156 | #if defined(QT_CHECK_STATE) | 1216 | #if defined(QT_CHECK_STATE) |
1157 | qWarning( "QSettings::readEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1217 | qWarning( "QSettings::readEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1165,5 +1225,5 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) | |||
1165 | QString theKey = groupKey( group(), key ); | 1225 | QString theKey = groupKey( group(), key ); |
1166 | 1226 | ||
1167 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 1227 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1168 | if ( d->sysd ) | 1228 | if ( d->sysd ) |
1169 | return d->sysReadEntry( theKey, def, ok ); | 1229 | return d->sysReadEntry( theKey, def, ok ); |
@@ -1207,9 +1267,11 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) | |||
1207 | 1267 | ||
1208 | QSettingsGroup grp = d->readGroup(); | 1268 | QSettingsGroup grp = d->readGroup(); |
1209 | QString retval = grp[realkey]; | 1269 | QSettingsGroup::const_iterator it = grp.find( realkey ), end = grp.end(); |
1210 | if ( retval.isNull() ) | 1270 | QString retval = def; |
1211 | retval = def; | 1271 | if ( it != end ) { |
1212 | else if ( ok ) // everything is ok | 1272 | // found the value we needed |
1213 | *ok = TRUE; | 1273 | retval = *it; |
1274 | if ( ok ) *ok = TRUE; | ||
1275 | } | ||
1214 | return retval; | 1276 | return retval; |
1215 | } | 1277 | } |
@@ -1229,5 +1291,5 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) | |||
1229 | bool QSettings::writeEntry(const QString &key, bool value) | 1291 | bool QSettings::writeEntry(const QString &key, bool value) |
1230 | { | 1292 | { |
1231 | if ( !verifyKey( key ) ) { | 1293 | if ( !qt_verify_key( key ) ) { |
1232 | #if defined(QT_CHECK_STATE) | 1294 | #if defined(QT_CHECK_STATE) |
1233 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1295 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1236,12 +1298,10 @@ bool QSettings::writeEntry(const QString &key, bool value) | |||
1236 | } | 1298 | } |
1237 | 1299 | ||
1238 | QString theKey = groupKey( group(), key ); | 1300 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1239 | |||
1240 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | ||
1241 | if ( d->sysd ) | 1301 | if ( d->sysd ) |
1242 | return d->sysWriteEntry( theKey, value ); | 1302 | return d->sysWriteEntry( groupKey( group(), key ), value ); |
1243 | #endif | 1303 | #endif |
1244 | QString s(value ? "true" : "false"); | 1304 | QString s(value ? "true" : "false"); |
1245 | return writeEntry(theKey, s); | 1305 | return writeEntry(key, s); |
1246 | } | 1306 | } |
1247 | #endif | 1307 | #endif |
@@ -1261,5 +1321,5 @@ bool QSettings::writeEntry(const QString &key, bool value) | |||
1261 | bool QSettings::writeEntry(const QString &key, double value) | 1321 | bool QSettings::writeEntry(const QString &key, double value) |
1262 | { | 1322 | { |
1263 | if ( !verifyKey( key ) ) { | 1323 | if ( !qt_verify_key( key ) ) { |
1264 | #if defined(QT_CHECK_STATE) | 1324 | #if defined(QT_CHECK_STATE) |
1265 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1325 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1268,12 +1328,10 @@ bool QSettings::writeEntry(const QString &key, double value) | |||
1268 | } | 1328 | } |
1269 | 1329 | ||
1270 | QString theKey = groupKey( group(), key ); | 1330 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1271 | |||
1272 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | ||
1273 | if ( d->sysd ) | 1331 | if ( d->sysd ) |
1274 | return d->sysWriteEntry( theKey, value ); | 1332 | return d->sysWriteEntry( groupKey( group(), key ), value ); |
1275 | #endif | 1333 | #endif |
1276 | QString s(QString::number(value)); | 1334 | QString s(QString::number(value)); |
1277 | return writeEntry(theKey, s); | 1335 | return writeEntry(key, s); |
1278 | } | 1336 | } |
1279 | 1337 | ||
@@ -1292,5 +1350,5 @@ bool QSettings::writeEntry(const QString &key, double value) | |||
1292 | bool QSettings::writeEntry(const QString &key, int value) | 1350 | bool QSettings::writeEntry(const QString &key, int value) |
1293 | { | 1351 | { |
1294 | if ( !verifyKey( key ) ) { | 1352 | if ( !qt_verify_key( key ) ) { |
1295 | #if defined(QT_CHECK_STATE) | 1353 | #if defined(QT_CHECK_STATE) |
1296 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1354 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1299,12 +1357,10 @@ bool QSettings::writeEntry(const QString &key, int value) | |||
1299 | } | 1357 | } |
1300 | 1358 | ||
1301 | QString theKey = groupKey( group(), key ); | 1359 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1302 | |||
1303 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | ||
1304 | if ( d->sysd ) | 1360 | if ( d->sysd ) |
1305 | return d->sysWriteEntry( theKey, value ); | 1361 | return d->sysWriteEntry( groupKey( group(), key ), value ); |
1306 | #endif | 1362 | #endif |
1307 | QString s(QString::number(value)); | 1363 | QString s(QString::number(value)); |
1308 | return writeEntry(theKey, s); | 1364 | return writeEntry(key, s); |
1309 | } | 1365 | } |
1310 | 1366 | ||
@@ -1328,5 +1384,5 @@ bool QSettings::writeEntry(const QString &key, int value) | |||
1328 | bool QSettings::writeEntry(const QString &key, const char *value) | 1384 | bool QSettings::writeEntry(const QString &key, const char *value) |
1329 | { | 1385 | { |
1330 | if ( !verifyKey( key ) ) { | 1386 | if ( !qt_verify_key( key ) ) { |
1331 | #if defined(QT_CHECK_STATE) | 1387 | #if defined(QT_CHECK_STATE) |
1332 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1388 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1335,7 +1391,5 @@ bool QSettings::writeEntry(const QString &key, const char *value) | |||
1335 | } | 1391 | } |
1336 | 1392 | ||
1337 | QString theKey = groupKey( group(), key ); | 1393 | return writeEntry(key, QString(value)); |
1338 | |||
1339 | return writeEntry(theKey, QString(value)); | ||
1340 | } | 1394 | } |
1341 | 1395 | ||
@@ -1355,5 +1409,5 @@ bool QSettings::writeEntry(const QString &key, const char *value) | |||
1355 | bool QSettings::writeEntry(const QString &key, const QString &value) | 1409 | bool QSettings::writeEntry(const QString &key, const QString &value) |
1356 | { | 1410 | { |
1357 | if ( !verifyKey( key ) ) { | 1411 | if ( !qt_verify_key( key ) ) { |
1358 | #if defined(QT_CHECK_STATE) | 1412 | #if defined(QT_CHECK_STATE) |
1359 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1413 | qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1364,5 +1418,5 @@ bool QSettings::writeEntry(const QString &key, const QString &value) | |||
1364 | QString theKey = groupKey( group(), key ); | 1418 | QString theKey = groupKey( group(), key ); |
1365 | 1419 | ||
1366 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 1420 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1367 | if ( d->sysd ) | 1421 | if ( d->sysd ) |
1368 | return d->sysWriteEntry( theKey, value ); | 1422 | return d->sysWriteEntry( theKey, value ); |
@@ -1416,5 +1470,5 @@ bool QSettings::writeEntry(const QString &key, const QString &value) | |||
1416 | bool QSettings::removeEntry(const QString &key) | 1470 | bool QSettings::removeEntry(const QString &key) |
1417 | { | 1471 | { |
1418 | if ( !verifyKey( key ) ) { | 1472 | if ( !qt_verify_key( key ) ) { |
1419 | #if defined(QT_CHECK_STATE) | 1473 | #if defined(QT_CHECK_STATE) |
1420 | qWarning( "QSettings::removeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1474 | qWarning( "QSettings::removeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1425,5 +1479,5 @@ bool QSettings::removeEntry(const QString &key) | |||
1425 | QString theKey = groupKey( group(), key ); | 1479 | QString theKey = groupKey( group(), key ); |
1426 | 1480 | ||
1427 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 1481 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1428 | if ( d->sysd ) | 1482 | if ( d->sysd ) |
1429 | return d->sysRemoveEntry( theKey ); | 1483 | return d->sysRemoveEntry( theKey ); |
@@ -1495,5 +1549,5 @@ bool QSettings::removeEntry(const QString &key) | |||
1495 | QStringList QSettings::entryList(const QString &key) const | 1549 | QStringList QSettings::entryList(const QString &key) const |
1496 | { | 1550 | { |
1497 | if ( !verifyKey( key ) ) { | 1551 | if ( !qt_verify_key( key ) ) { |
1498 | #if defined(QT_CHECK_STATE) | 1552 | #if defined(QT_CHECK_STATE) |
1499 | qWarning( "QSettings::entryList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() ); | 1553 | qWarning( "QSettings::entryList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1504,5 +1558,5 @@ QStringList QSettings::entryList(const QString &key) const | |||
1504 | QString theKey = groupKey( group(), key ); | 1558 | QString theKey = groupKey( group(), key ); |
1505 | 1559 | ||
1506 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 1560 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1507 | if ( d->sysd ) | 1561 | if ( d->sysd ) |
1508 | return d->sysEntryList( theKey ); | 1562 | return d->sysEntryList( theKey ); |
@@ -1545,5 +1599,5 @@ QStringList QSettings::entryList(const QString &key) const | |||
1545 | while (it != grp.end()) { | 1599 | while (it != grp.end()) { |
1546 | itkey = it.key(); | 1600 | itkey = it.key(); |
1547 | it++; | 1601 | ++it; |
1548 | 1602 | ||
1549 | if ( realkey.length() > 0 ) { | 1603 | if ( realkey.length() > 0 ) { |
@@ -1592,5 +1646,5 @@ QStringList QSettings::entryList(const QString &key) const | |||
1592 | QStringList QSettings::subkeyList(const QString &key) const | 1646 | QStringList QSettings::subkeyList(const QString &key) const |
1593 | { | 1647 | { |
1594 | if ( !verifyKey( key ) ) { | 1648 | if ( !qt_verify_key( key ) ) { |
1595 | #if defined(QT_CHECK_STATE) | 1649 | #if defined(QT_CHECK_STATE) |
1596 | qWarning( "QSettings::subkeyList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() ); | 1650 | qWarning( "QSettings::subkeyList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1601,5 +1655,5 @@ QStringList QSettings::subkeyList(const QString &key) const | |||
1601 | QString theKey = groupKey( group(), key ); | 1655 | QString theKey = groupKey( group(), key ); |
1602 | 1656 | ||
1603 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 1657 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1604 | if ( d->sysd ) | 1658 | if ( d->sysd ) |
1605 | return d->sysSubkeyList( theKey ); | 1659 | return d->sysSubkeyList( theKey ); |
@@ -1607,4 +1661,5 @@ QStringList QSettings::subkeyList(const QString &key) const | |||
1607 | 1661 | ||
1608 | QString realkey; | 1662 | QString realkey; |
1663 | int subkeycount = 2; | ||
1609 | if (theKey[0] == '/') { | 1664 | if (theKey[0] == '/') { |
1610 | // parse our key | 1665 | // parse our key |
@@ -1619,4 +1674,6 @@ QStringList QSettings::subkeyList(const QString &key) const | |||
1619 | } | 1674 | } |
1620 | 1675 | ||
1676 | subkeycount = list.count(); | ||
1677 | |||
1621 | if (list.count() == 1) { | 1678 | if (list.count() == 1) { |
1622 | d->heading = list[0]; | 1679 | d->heading = list[0]; |
@@ -1633,14 +1690,26 @@ QStringList QSettings::subkeyList(const QString &key) const | |||
1633 | realkey = list.join("/"); | 1690 | realkey = list.join("/"); |
1634 | } | 1691 | } |
1692 | |||
1635 | } else | 1693 | } else |
1636 | realkey = theKey; | 1694 | realkey = theKey; |
1637 | 1695 | ||
1696 | QStringList ret; | ||
1697 | if ( subkeycount == 1 ) { | ||
1698 | QMap<QString,QSettingsHeading>::Iterator it = d->headings.begin(); | ||
1699 | while ( it != d->headings.end() ) { | ||
1700 | if ( it.key() != "General" && ! ret.contains( it.key() ) ) | ||
1701 | ret << it.key(); | ||
1702 | ++it; | ||
1703 | } | ||
1704 | |||
1705 | return ret; | ||
1706 | } | ||
1707 | |||
1638 | QSettingsGroup grp = d->readGroup(); | 1708 | QSettingsGroup grp = d->readGroup(); |
1639 | QSettingsGroup::Iterator it = grp.begin(); | 1709 | QSettingsGroup::Iterator it = grp.begin(); |
1640 | QStringList ret; | ||
1641 | QString itkey; | 1710 | QString itkey; |
1642 | while (it != grp.end()) { | 1711 | while (it != grp.end()) { |
1643 | itkey = it.key(); | 1712 | itkey = it.key(); |
1644 | it++; | 1713 | ++it; |
1645 | 1714 | ||
1646 | if ( realkey.length() > 0 ) { | 1715 | if ( realkey.length() > 0 ) { |
@@ -1671,5 +1740,5 @@ QStringList QSettings::subkeyList(const QString &key) const | |||
1671 | QDateTime QSettings::lastModficationTime(const QString &key) | 1740 | QDateTime QSettings::lastModficationTime(const QString &key) |
1672 | { | 1741 | { |
1673 | if ( !verifyKey( key ) ) { | 1742 | if ( !qt_verify_key( key ) ) { |
1674 | #if defined(QT_CHECK_STATE) | 1743 | #if defined(QT_CHECK_STATE) |
1675 | qWarning( "QSettings::lastModficationTime: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); | 1744 | qWarning( "QSettings::lastModficationTime: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); |
@@ -1680,5 +1749,5 @@ QDateTime QSettings::lastModficationTime(const QString &key) | |||
1680 | QString theKey = groupKey( group(), key ); | 1749 | QString theKey = groupKey( group(), key ); |
1681 | 1750 | ||
1682 | #if defined(Q_WS_WIN) || defined(Q_OS_MAC) | 1751 | #if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) |
1683 | if ( d->sysd ) | 1752 | if ( d->sysd ) |
1684 | return QDateTime(); | 1753 | return QDateTime(); |
@@ -1716,7 +1785,15 @@ QDateTime QSettings::lastModficationTime(const QString &key) | |||
1716 | is created if it doesn't exist. Any previous value is overwritten | 1785 | is created if it doesn't exist. Any previous value is overwritten |
1717 | by \a value. The list is stored as a sequence of strings separated | 1786 | by \a value. The list is stored as a sequence of strings separated |
1718 | by \a separator, so none of the strings in the list should contain | 1787 | by \a separator (using QStringList::join()), so none of the |
1719 | the separator. If the list is empty or null the key's value will | 1788 | strings in the list should contain the separator. If the list is |
1720 | be an empty string. | 1789 | empty or null the key's value will be an empty string. |
1790 | |||
1791 | \warning The list should not contain empty or null strings, as | ||
1792 | readListEntry() will use QStringList::split() to recreate the | ||
1793 | list. As the documentation states, QStringList::split() will omit | ||
1794 | empty strings from the list. Because of this, it is impossible to | ||
1795 | retrieve identical list data that is stored with this function. | ||
1796 | We recommend using the writeEntry() and readListEntry() overloads | ||
1797 | that do not take a \a separator argument. | ||
1721 | 1798 | ||
1722 | If an error occurs the settings are left unchanged and FALSE is | 1799 | If an error occurs the settings are left unchanged and FALSE is |
@@ -1769,4 +1846,11 @@ bool QSettings::writeEntry(const QString &key, const QStringList &value) | |||
1769 | key was read, otherwise \a *ok is set to FALSE. | 1846 | key was read, otherwise \a *ok is set to FALSE. |
1770 | 1847 | ||
1848 | \warning As the documentation states, QStringList::split() will | ||
1849 | omit empty strings from the list. Because of this, it is | ||
1850 | impossible to retrieve identical list data with this function. We | ||
1851 | recommend using the readListEntry() and writeEntry() overloads | ||
1852 | that do not take a \a separator argument. | ||
1853 | |||
1854 | |||
1771 | Note that if you want to iterate over the list, you should iterate | 1855 | Note that if you want to iterate over the list, you should iterate |
1772 | over a copy, e.g. | 1856 | over a copy, e.g. |
@@ -1848,4 +1932,8 @@ QStringList QSettings::readListEntry(const QString &key, bool *ok ) | |||
1848 | } | 1932 | } |
1849 | 1933 | ||
1934 | #ifdef Q_OS_MAC | ||
1935 | void qt_setSettingsBasePath(const QString &); //qsettings_mac.cpp | ||
1936 | #endif | ||
1937 | |||
1850 | /*! | 1938 | /*! |
1851 | Insert platform-dependent paths from platform-independent information. | 1939 | Insert platform-dependent paths from platform-independent information. |
@@ -1861,4 +1949,7 @@ QStringList QSettings::readListEntry(const QString &key, bool *ok ) | |||
1861 | QSettings::Global for system-wide settings (generally | 1949 | QSettings::Global for system-wide settings (generally |
1862 | these will be read-only to many users). | 1950 | these will be read-only to many users). |
1951 | |||
1952 | Not all information is relevant on all systems (e.g. scoping is | ||
1953 | currently used only if QSettings accesses the Windows registry). | ||
1863 | */ | 1954 | */ |
1864 | 1955 | ||
@@ -1881,4 +1972,6 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc | |||
1881 | // Note that on most installations, not all users can write to the System | 1972 | // Note that on most installations, not all users can write to the System |
1882 | // scope. | 1973 | // scope. |
1974 | d->globalScope = scope == Global; | ||
1975 | |||
1883 | QString actualSearchPath; | 1976 | QString actualSearchPath; |
1884 | int lastDot = domain.findRev( '.' ); | 1977 | int lastDot = domain.findRev( '.' ); |
@@ -1887,9 +1980,9 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc | |||
1887 | actualSearchPath = "/" + domain.mid( 0, lastDot ) + "/" + product; | 1980 | actualSearchPath = "/" + domain.mid( 0, lastDot ) + "/" + product; |
1888 | insertSearchPath( Windows, actualSearchPath ); | 1981 | insertSearchPath( Windows, actualSearchPath ); |
1889 | #elif defined(Q_WS_MAC) | 1982 | #elif !defined(QWS) && defined(Q_OS_MAC) |
1890 | QString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + "."; | 1983 | QString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + "."; |
1891 | if ( topLevelDomain.isEmpty() ) | 1984 | if ( !topLevelDomain.isEmpty() ) |
1892 | topLevelDomain = "com."; | 1985 | qt_setSettingsBasePath( topLevelDomain ); |
1893 | actualSearchPath = "/" + topLevelDomain + domain.left( lastDot ) + product; | 1986 | actualSearchPath = "/" + domain.left( lastDot ) + product; |
1894 | insertSearchPath( Mac, actualSearchPath ); | 1987 | insertSearchPath( Mac, actualSearchPath ); |
1895 | #else | 1988 | #else |
@@ -1897,10 +1990,15 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc | |||
1897 | insertSearchPath( Unix, actualSearchPath ); | 1990 | insertSearchPath( Unix, actualSearchPath ); |
1898 | #endif | 1991 | #endif |
1899 | |||
1900 | d->globalScope = scope == Global; | ||
1901 | } | 1992 | } |
1902 | 1993 | ||
1903 | /*! | 1994 | /*! |
1904 | Appends \a group to the current key prefix. | 1995 | Appends \a group to the current key prefix. |
1996 | |||
1997 | \code | ||
1998 | QSettings settings; | ||
1999 | settings.beginGroup( "/MainWindow" ); | ||
2000 | // read values | ||
2001 | settings.endGroup(); | ||
2002 | \endcode | ||
1905 | */ | 2003 | */ |
1906 | void QSettings::beginGroup( const QString &group ) | 2004 | void QSettings::beginGroup( const QString &group ) |
@@ -1913,4 +2011,11 @@ void QSettings::beginGroup( const QString &group ) | |||
1913 | Undo previous calls to beginGroup(). Note that a single beginGroup("a/b/c") is undone | 2011 | Undo previous calls to beginGroup(). Note that a single beginGroup("a/b/c") is undone |
1914 | by a single call to endGroup(). | 2012 | by a single call to endGroup(). |
2013 | |||
2014 | \code | ||
2015 | QSettings settings; | ||
2016 | settings.beginGroup( "/MainWindow/Geometry" ); | ||
2017 | // read values | ||
2018 | settings.endGroup(); | ||
2019 | \endcode | ||
1915 | */ | 2020 | */ |
1916 | void QSettings::endGroup() | 2021 | void QSettings::endGroup() |
@@ -1946,5 +2051,5 @@ QString QSettings::group() const | |||
1946 | ++it; | 2051 | ++it; |
1947 | if ( group[0] != '/' ) | 2052 | if ( group[0] != '/' ) |
1948 | group = "/" + group; | 2053 | group.prepend( "/" ); |
1949 | d->groupPrefix += group; | 2054 | d->groupPrefix += group; |
1950 | } | 2055 | } |