Changeset 25
- Timestamp:
- Jun 11, 2009, 2:40:50 PM (16 years ago)
- Location:
- trunk/src/corelib/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/io/qsettings.cpp
r2 r25 350 350 // see also qsettings_win.cpp and qsettings_mac.cpp 351 351 352 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) 352 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) 353 353 QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, QSettings::Scope scope, 354 354 const QString &organization, const QString &application) … … 358 358 #endif 359 359 360 #if !defined(Q_OS_WIN) 360 #if !defined(Q_OS_WIN) 361 361 QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::Format format) 362 362 { … … 1130 1130 Windows registry and the Mac CFPreferences.) 1131 1131 */ 1132 #if def Q_OS_WIN1132 #if 1133 1133 pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), 1134 1134 windowsConfigPath(CSIDL_APPDATA) + QDir::separator()); 1135 1135 pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), 1136 1136 windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator()); 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1137 1159 #else 1138 1160 QString userPath; … … 1898 1920 IniMap::const_iterator i; 1899 1921 1900 #if def Q_OS_WIN1922 #if 1901 1923 const char * const eol = "\r\n"; 1902 1924 #else … … 2032 2054 Users normally expect an application to remember its settings 2033 2055 (window sizes and positions, options, etc.) across sessions. This 2034 information is often stored in the system registry on Windows ,2056 information is often stored in the system registry on Windows, 2035 2057 and in XML preferences files on Mac OS X. On Unix systems, in the 2036 2058 absence of a standard, many applications (including the KDE … … 2135 2157 \section1 Key Syntax 2136 2158 2137 Setting keys can contain any Unicode characters. The Windows 2159 Setting keys can contain any Unicode characters. The Windows 2138 2160 registry and INI files use case-insensitive keys, whereas the 2139 2161 Carbon Preferences API on Mac OS X uses case-sensitive keys. To … … 2321 2343 \endlist 2322 2344 2323 On Windows , NativeFormat settings are stored in the following2345 On Windows, NativeFormat settings are stored in the following 2324 2346 registry paths: 2325 2347 … … 2359 2381 Settings\\All Users\\Application Data}. 2360 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2361 2392 The paths for the \c .ini and \c .conf files can be changed using 2362 setPath(). On Unix and Mac OS X, the user can override them by by 2363 setting the \c XDG_CONFIG_HOME environment variable; see 2364 setPath() for details. 2393 setPath(). On Unix, Mac OS X and OS/2, the user can override them by setting 2394 the \c XDG_CONFIG_HOME environment variable; see setPath() for details. 2365 2395 2366 2396 \section2 Accessing INI and .plist Files Directly … … 2382 2412 \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 3 2383 2413 2384 \section2 Accessing the Windows Registry Directly2385 2386 On Windows , QSettings lets you access settings that have been2414 \section2 Accessing the Windows Registry Directly 2415 2416 On Windows, QSettings lets you access settings that have been 2387 2417 written with QSettings (or settings in a supported format, e.g., string 2388 2418 data) in the system registry. This is done by constructing a QSettings … … 2405 2435 so. 2406 2436 2407 \section2 Accessing Common Registry Settings on Windows 2408 2409 On Windows , it is possible for a key to have both a value and subkeys.2410 Its default value is accessed by using "Default" or "." in2437 \section2 Accessing Common Registry Settings on Windows 2438 2439 On Windows 2440 Its default value is accessed by using "Default" or "." in 2411 2441 place of a subkey: 2412 2442 2413 2443 \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 6 2414 2444 2415 On other platforms than Windows , "Default" and "." would be2445 On other platforms than Windows, "Default" and "." would be 2416 2446 treated as regular subkeys. 2417 2447 … … 2424 2454 2425 2455 \list 2426 \o The Windows system registry has the following limitations: A2456 \o The Windows system registry has the following limitations: A 2427 2457 subkey may not exceed 255 characters, an entry's value may 2428 2458 not exceed 16,383 characters, and all the values of a key may … … 2482 2512 \value NativeFormat Store the settings using the most 2483 2513 appropriate storage format for the platform. 2484 On Windows , this means the system registry;2514 On Windows, this means the system registry; 2485 2515 on Mac OS X, this means the CFPreferences 2486 2516 API; on Unix, this means textual … … 2647 2677 fileName depends on the platform. On Unix, \a fileName is the 2648 2678 name of an INI file. On Mac OS X, \a fileName is the name of a 2649 \c .plist file. On Windows , \a fileName is a path in the system2679 \c .plist file. On Windows, \a fileName is a path in the system 2650 2680 registry. 2651 2681 … … 2806 2836 object are stored. 2807 2837 2808 On Windows , if the format is QSettings::NativeFormat, the return value2809 is a system registry path, not a file path.2838 On Windows 2839 is a system registry path, not a file path. 2810 2840 2811 2841 \sa isWritable(), format() … … 3206 3236 3207 3237 /*! 3208 3238 3209 3239 Sets the value of setting \a key to \a value. If the \a key already 3210 3240 exists, the previous value is overwritten. 3211 3241 3212 Note that the Windows registry and INI files use case-insensitive3242 Note that the Windows registry and INI files use case-insensitive 3213 3243 keys, whereas the Carbon Preferences API on Mac OS X uses 3214 3244 case-sensitive keys. To avoid portability problems, see the \l{Key … … 3245 3275 \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 25 3246 3276 3247 Note that the Windows registry and INI files use case-insensitive 3248 keys, whereas the Carbon Preferences API on Mac OS X uses 3249 case-sensitive keys. To avoid portability problems, see the \l{Key 3250 Syntax} rules. 3277 Note that the Windows and OS/2 registry and INI files use case-insensitive 3278 keys, whereas the Carbon Preferences API on Mac OS X uses case-sensitive 3279 keys. To avoid portability problems, see the \l{Key Syntax} rules. 3251 3280 3252 3281 \sa setValue(), value(), contains() … … 3280 3309 relative to that group. 3281 3310 3282 Note that the Windows registry and INI files use case-insensitive 3283 keys, whereas the Carbon Preferences API on Mac OS X uses 3284 case-sensitive keys. To avoid portability problems, see the \l{Key 3285 Syntax} rules. 3311 Note that the Windows and OS/2 registry and INI files use case-insensitive 3312 keys, whereas the Carbon Preferences API on Mac OS X uses case-sensitive 3313 keys. To avoid portability problems, see the \l{Key Syntax} rules. 3286 3314 3287 3315 \sa value(), setValue() … … 3342 3370 returned. 3343 3371 3344 Note that the Windows registry and INI files use case-insensitive3372 Note that the Windows registry and INI files use case-insensitive 3345 3373 keys, whereas the Carbon Preferences API on Mac OS X uses 3346 3374 case-sensitive keys. To avoid portability problems, see the \l{Key … … 3405 3433 { 3406 3434 setPath(IniFormat, SystemScope, dir); 3407 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) 3435 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) 3408 3436 setPath(NativeFormat, SystemScope, dir); 3409 3437 #endif … … 3419 3447 { 3420 3448 setPath(IniFormat, UserScope, dir); 3421 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) 3449 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) 3422 3450 setPath(NativeFormat, UserScope, dir); 3423 3451 #endif … … 3442 3470 \row \o{1,2} Mac OS X \o{1,2} IniFormat \o UserScope \o \c $HOME/.config 3443 3471 \row \o SystemScope \o \c /etc/xdg 3472 3473 3444 3474 \endtable 3445 3475 3446 The default UserScope paths on Unix and Mac OS X (\c3447 $HOME/ .config or $HOME/Settings) can be overridden by the user by setting the3476 The default UserScope paths on Unix 3477 $HOME/Settings) can be overridden by the user by setting the 3448 3478 \c XDG_CONFIG_HOME environment variable. The default SystemScope 3449 paths on Unix and Mac OS X (\c /etc/xdg) can be overridden when 3450 building the Qt library using the \c configure script's \c 3479 paths on Unix, Mac OS X (\c /etc/xdg) and OS/2 (\c <boot_drv>:\OS2\xdg) can 3480 be overridden when building the Qt library using the \c configure script's 3481 \c 3451 3482 --sysconfdir flag (see QLibraryInfo for details). 3452 3483 3453 Setting the NativeFormat paths on Windows and Mac OS X has no 3454 effect. 3484 Setting the NativeFormat paths on Windows, Mac OS X and OS/2 has no effect. 3455 3485 3456 3486 \warning This function doesn't affect existing QSettings objects. … … 3723 3753 3724 3754 \value Unix Unix systems (X11 and Embedded Linux) 3725 \value Windows Microsoft Windows systems3755 \value Windows Microsoft Windows systems 3726 3756 \value Mac Mac OS X systems 3727 3757 -
trunk/src/corelib/io/qsettings_os2.cpp
r23 r25 555 555 556 556 /******************************************************************************* 557 ** class Q WinSettingsPrivate557 ** class QSettingsPrivate 558 558 */ 559 559 560 class Q WinSettingsPrivate : public QSettingsPrivate560 class QSettingsPrivate : public QSettingsPrivate 561 561 { 562 562 public: 563 Q WinSettingsPrivate(QSettings::Scope scope, const QString &organization,563 QSettingsPrivate(QSettings::Scope scope, const QString &organization, 564 564 const QString &application); 565 Q WinSettingsPrivate(QString rKey);566 ~Q WinSettingsPrivate();565 QSettingsPrivate(QString rKey); 566 ~QSettingsPrivate(); 567 567 568 568 void remove(const QString &uKey); … … 583 583 }; 584 584 585 Q WinSettingsPrivate::QWinSettingsPrivate(QSettings::Scope scope, const QString &organization,585 QSettingsPrivate(QSettings::Scope scope, const QString &organization, 586 586 const QString &application) 587 587 : QSettingsPrivate(QSettings::NativeFormat, scope, organization, application) … … 611 611 } 612 612 613 Q WinSettingsPrivate::QWinSettingsPrivate(QString rPath)613 QSettingsPrivate(QString rPath) 614 614 : QSettingsPrivate(QSettings::NativeFormat) 615 615 { … … 639 639 } 640 640 641 bool Q WinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVariant *value) const641 bool QSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVariant *value) const 642 642 { 643 643 QString rSubkeyName = keyName(rSubKey); … … 752 752 } 753 753 754 HKEY Q WinSettingsPrivate::writeHandle() const754 HKEY QSettingsPrivate::writeHandle() const 755 755 { 756 756 if (regList.isEmpty()) … … 762 762 } 763 763 764 Q WinSettingsPrivate::~QWinSettingsPrivate()764 QSettingsPrivate() 765 765 { 766 766 if (deleteWriteHandleOnExit && writeHandle() != 0) { … … 786 786 } 787 787 788 void Q WinSettingsPrivate::remove(const QString &uKey)788 void QSettingsPrivate::remove(const QString &uKey) 789 789 { 790 790 if (writeHandle() == 0) { … … 858 858 } 859 859 860 void Q WinSettingsPrivate::set(const QString &uKey, const QVariant &value)860 void QSettingsPrivate::set(const QString &uKey, const QVariant &value) 861 861 { 862 862 if (writeHandle() == 0) { … … 974 974 } 975 975 976 bool Q WinSettingsPrivate::get(const QString &uKey, QVariant *value) const976 bool QSettingsPrivate::get(const QString &uKey, QVariant *value) const 977 977 { 978 978 QString rKey = escapedKey(uKey); … … 990 990 } 991 991 992 QStringList Q WinSettingsPrivate::children(const QString &uKey, ChildSpec spec) const992 QStringList QSettingsPrivate::children(const QString &uKey, ChildSpec spec) const 993 993 { 994 994 NameSet result; … … 1021 1021 } 1022 1022 1023 void Q WinSettingsPrivate::clear()1023 void QSettingsPrivate::clear() 1024 1024 { 1025 1025 remove(QString()); … … 1027 1027 } 1028 1028 1029 void Q WinSettingsPrivate::sync()1029 void QSettingsPrivate::sync() 1030 1030 { 1031 1031 RegFlushKey(writeHandle()); 1032 1032 } 1033 1033 1034 void Q WinSettingsPrivate::flush()1035 { 1036 // Windowsdoes this for us.1037 } 1038 1039 QString Q WinSettingsPrivate::fileName() const1034 void QSettingsPrivate::flush() 1035 { 1036 // does this for us. 1037 } 1038 1039 QString QSettingsPrivate::fileName() const 1040 1040 { 1041 1041 if (regList.isEmpty()) … … 1052 1052 } 1053 1053 1054 bool Q WinSettingsPrivate::isWritable() const1054 bool QSettingsPrivate::isWritable() const 1055 1055 { 1056 1056 return writeHandle() != 0; … … 1061 1061 { 1062 1062 if (format == QSettings::NativeFormat) { 1063 return new Q WinSettingsPrivate(scope, organization, application);1063 return new QSettingsPrivate(scope, organization, application); 1064 1064 } else { 1065 1065 return new QConfFileSettingsPrivate(format, scope, organization, application); … … 1070 1070 { 1071 1071 if (format == QSettings::NativeFormat) { 1072 return new Q WinSettingsPrivate(fileName);1072 return new QSettingsPrivate(fileName); 1073 1073 } else { 1074 1074 return new QConfFileSettingsPrivate(fileName, format);
Note:
See TracChangeset
for help on using the changeset viewer.