Changeset 25


Ignore:
Timestamp:
Jun 11, 2009, 12:40:50 PM (11 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib: More OS/2 bits for QSettings.

Location:
trunk/src/corelib/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/corelib/io/qsettings.cpp

    r2 r25  
    350350// see also qsettings_win.cpp and qsettings_mac.cpp
    351351
    352 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
     352#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) && !defined(Q_OS_OS2)
    353353QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, QSettings::Scope scope,
    354354                                           const QString &organization, const QString &application)
     
    358358#endif
    359359
    360 #if !defined(Q_OS_WIN)
     360#if !defined(Q_OS_WIN) && !defined(Q_OS_OS2)
    361361QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::Format format)
    362362{
     
    11301130           Windows registry and the Mac CFPreferences.)
    11311131       */
    1132 #ifdef Q_OS_WIN
     1132#if defined(Q_OS_WIN)
    11331133        pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope),
    11341134                         windowsConfigPath(CSIDL_APPDATA) + QDir::separator());
    11351135        pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope),
    11361136                         windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator());
     1137#elif defined(Q_OS_OS2)
     1138        /* Though this code is very similar to the following #else statment,
     1139         * we have to do it separately for OS/2 and leave the original code
     1140         * intact since QDir::separator() returns ":" on Mac OS X while "/" is
     1141         * actually used in the #else below. */
     1142        QString userPath;
     1143        QString env = QLatin1String(getenv("XDG_CONFIG_HOME"));
     1144        if (env.isEmpty()) {
     1145            userPath = homePath;
     1146            userPath += QDir::separator();
     1147            userPath += QLatin1String(".config");
     1148        } else if (QDir::isAbsolutePath(env)) {
     1149            userPath = env;
     1150        } else {
     1151            userPath = homePath;
     1152            userPath += QDir::separator();
     1153            userPath += env;
     1154        }
     1155        userPath += QDir::separator();
     1156
     1157        pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), userPath);
     1158        pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), systemPath);
    11371159#else
    11381160        QString userPath;
     
    18981920    IniMap::const_iterator i;
    18991921
    1900 #ifdef Q_OS_WIN
     1922#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
    19011923    const char * const eol = "\r\n";
    19021924#else
     
    20322054    Users normally expect an application to remember its settings
    20332055    (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 and OS/2,
    20352057    and in XML preferences files on Mac OS X. On Unix systems, in the
    20362058    absence of a standard, many applications (including the KDE
     
    21352157    \section1 Key Syntax
    21362158
    2137     Setting keys can contain any Unicode characters. The Windows
     2159    Setting keys can contain any Unicode characters. The Windows and OS/2
    21382160    registry and INI files use case-insensitive keys, whereas the
    21392161    Carbon Preferences API on Mac OS X uses case-sensitive keys. To
     
    23212343    \endlist
    23222344
    2323     On Windows, NativeFormat settings are stored in the following
     2345    On Windows and OS/2, NativeFormat settings are stored in the following
    23242346    registry paths:
    23252347
     
    23592381    Settings\\All Users\\Application Data}.
    23602382
     2383    On OS/2, the following files are used:
     2384
     2385    \list 1
     2386    \o \c{%HOME%\.config\MySoft\Star Runner.ini}
     2387    \o \c{%HOME%\.config\MySoft.ini}
     2388    \o \c{<boot_drv>:\OS2\xdg\MySoft\Star Runner.ini}
     2389    \o \c{<boot_drv>:\OS2\xdg\MySoft.ini}
     2390    \endlist
     2391
    23612392    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.
    23652395
    23662396    \section2 Accessing INI and .plist Files Directly
     
    23822412    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 3
    23832413
    2384     \section2 Accessing the Windows Registry Directly
    2385 
    2386     On Windows, QSettings lets you access settings that have been
     2414    \section2 Accessing the Windows and OS/2 Registry Directly
     2415
     2416    On Windows and OS/2, QSettings lets you access settings that have been
    23872417    written with QSettings (or settings in a supported format, e.g., string
    23882418    data) in the system registry. This is done by constructing a QSettings
     
    24052435    so.
    24062436
    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 "." in
     2437    \section2 Accessing Common Registry Settings on Windows and OS/2
     2438
     2439    On Windows and OS/2, it is possible for a key to have both a value and
     2440    subkeys. Its default value is accessed by using "Default" or "." in
    24112441    place of a subkey:
    24122442
    24132443    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 6
    24142444
    2415     On other platforms than Windows, "Default" and "." would be
     2445    On other platforms than Windows and OS/2, "Default" and "." would be
    24162446    treated as regular subkeys.
    24172447
     
    24242454
    24252455    \list
    2426     \o  The Windows system registry has the following limitations: A
     2456    \o  The Windows and OS/2 system registry has the following limitations: A
    24272457        subkey may not exceed 255 characters, an entry's value may
    24282458        not exceed 16,383 characters, and all the values of a key may
     
    24822512    \value NativeFormat  Store the settings using the most
    24832513                         appropriate storage format for the platform.
    2484                          On Windows, this means the system registry;
     2514                         On Windows and OS/2, this means the system registry;
    24852515                         on Mac OS X, this means the CFPreferences
    24862516                         API; on Unix, this means textual
     
    26472677    fileName depends on the platform. On Unix, \a fileName is the
    26482678    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 system
     2679    \c .plist file. On Windows and OS/2, \a fileName is a path in the system
    26502680    registry.
    26512681
     
    28062836    object are stored.
    28072837
    2808     On Windows, if the format is QSettings::NativeFormat, the return value
    2809     is a system registry path, not a file path.
     2838    On Windows and OS/2, if the format is QSettings::NativeFormat, the return
     2839    value is a system registry path, not a file path.
    28102840
    28112841    \sa isWritable(), format()
     
    32063236
    32073237/*!
    3208  
     3238
    32093239  Sets the value of setting \a key to \a value. If the \a key already
    32103240  exists, the previous value is overwritten.
    32113241
    3212   Note that the Windows registry and INI files use case-insensitive
     3242  Note that the Windows and OS/2 registry and INI files use case-insensitive
    32133243  keys, whereas the Carbon Preferences API on Mac OS X uses
    32143244  case-sensitive keys. To avoid portability problems, see the \l{Key
     
    32453275    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 25
    32463276
    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.
    32513280
    32523281    \sa setValue(), value(), contains()
     
    32803309    relative to that group.
    32813310
    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.
    32863314
    32873315    \sa value(), setValue()
     
    33423370    returned.
    33433371
    3344     Note that the Windows registry and INI files use case-insensitive
     3372    Note that the Windows and OS/2 registry and INI files use case-insensitive
    33453373    keys, whereas the Carbon Preferences API on Mac OS X uses
    33463374    case-sensitive keys. To avoid portability problems, see the \l{Key
     
    34053433{
    34063434    setPath(IniFormat, SystemScope, dir);
    3407 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
     3435#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) && !defined(Q_OS_OS2)
    34083436    setPath(NativeFormat, SystemScope, dir);
    34093437#endif
     
    34193447{
    34203448    setPath(IniFormat, UserScope, dir);
    3421 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
     3449#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) && !defined(Q_OS_OS2)
    34223450    setPath(NativeFormat, UserScope, dir);
    34233451#endif
     
    34423470    \row    \o{1,2} Mac OS X    \o{1,2} IniFormat               \o UserScope   \o \c $HOME/.config
    34433471    \row                                                        \o SystemScope \o \c /etc/xdg
     3472    \row    \o{1,2} OS/2        \o{1,2} IniFormat               \o UserScope   \o \c $HOME\.config
     3473    \row                                                        \o SystemScope \o \c <boot_drv>:\OS2\xdg
    34443474    \endtable
    34453475
    3446     The default UserScope paths on Unix and Mac OS X (\c
    3447     $HOME/.config or $HOME/Settings) can be overridden by the user by setting the
     3476    The default UserScope paths on Unix, Mac OS X and OS/2 (\c $HOME/.config or
     3477    $HOME/Settings) can be overridden by the user by setting the
    34483478    \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
    34513482    --sysconfdir flag (see QLibraryInfo for details).
    34523483
    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.
    34553485
    34563486    \warning This function doesn't affect existing QSettings objects.
     
    37233753
    37243754    \value Unix Unix systems (X11 and Embedded Linux)
    3725     \value Windows Microsoft Windows systems
     3755    \value Windows Microsoft Windows and IBM OS/2 systems
    37263756    \value Mac Mac OS X systems
    37273757
  • trunk/src/corelib/io/qsettings_os2.cpp

    r23 r25  
    555555
    556556/*******************************************************************************
    557 ** class QWinSettingsPrivate
     557** class QOS2SettingsPrivate
    558558*/
    559559
    560 class QWinSettingsPrivate : public QSettingsPrivate
     560class QOS2SettingsPrivate : public QSettingsPrivate
    561561{
    562562public:
    563     QWinSettingsPrivate(QSettings::Scope scope, const QString &organization,
     563    QOS2SettingsPrivate(QSettings::Scope scope, const QString &organization,
    564564                        const QString &application);
    565     QWinSettingsPrivate(QString rKey);
    566     ~QWinSettingsPrivate();
     565    QOS2SettingsPrivate(QString rKey);
     566    ~QOS2SettingsPrivate();
    567567
    568568    void remove(const QString &uKey);
     
    583583};
    584584
    585 QWinSettingsPrivate::QWinSettingsPrivate(QSettings::Scope scope, const QString &organization,
     585QOS2SettingsPrivate::QOS2SettingsPrivate(QSettings::Scope scope, const QString &organization,
    586586                                         const QString &application)
    587587    : QSettingsPrivate(QSettings::NativeFormat, scope, organization, application)
     
    611611}
    612612
    613 QWinSettingsPrivate::QWinSettingsPrivate(QString rPath)
     613QOS2SettingsPrivate::QOS2SettingsPrivate(QString rPath)
    614614    : QSettingsPrivate(QSettings::NativeFormat)
    615615{
     
    639639}
    640640
    641 bool QWinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVariant *value) const
     641bool QOS2SettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVariant *value) const
    642642{
    643643    QString rSubkeyName = keyName(rSubKey);
     
    752752}
    753753
    754 HKEY QWinSettingsPrivate::writeHandle() const
     754HKEY QOS2SettingsPrivate::writeHandle() const
    755755{
    756756    if (regList.isEmpty())
     
    762762}
    763763
    764 QWinSettingsPrivate::~QWinSettingsPrivate()
     764QOS2SettingsPrivate::~QOS2SettingsPrivate()
    765765{
    766766    if (deleteWriteHandleOnExit && writeHandle() != 0) {
     
    786786}
    787787
    788 void QWinSettingsPrivate::remove(const QString &uKey)
     788void QOS2SettingsPrivate::remove(const QString &uKey)
    789789{
    790790    if (writeHandle() == 0) {
     
    858858}
    859859
    860 void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value)
     860void QOS2SettingsPrivate::set(const QString &uKey, const QVariant &value)
    861861{
    862862    if (writeHandle() == 0) {
     
    974974}
    975975
    976 bool QWinSettingsPrivate::get(const QString &uKey, QVariant *value) const
     976bool QOS2SettingsPrivate::get(const QString &uKey, QVariant *value) const
    977977{
    978978    QString rKey = escapedKey(uKey);
     
    990990}
    991991
    992 QStringList QWinSettingsPrivate::children(const QString &uKey, ChildSpec spec) const
     992QStringList QOS2SettingsPrivate::children(const QString &uKey, ChildSpec spec) const
    993993{
    994994    NameSet result;
     
    10211021}
    10221022
    1023 void QWinSettingsPrivate::clear()
     1023void QOS2SettingsPrivate::clear()
    10241024{
    10251025    remove(QString());
     
    10271027}
    10281028
    1029 void QWinSettingsPrivate::sync()
     1029void QOS2SettingsPrivate::sync()
    10301030{
    10311031    RegFlushKey(writeHandle());
    10321032}
    10331033
    1034 void QWinSettingsPrivate::flush()
    1035 {
    1036     // Windows does this for us.
    1037 }
    1038 
    1039 QString QWinSettingsPrivate::fileName() const
     1034void QOS2SettingsPrivate::flush()
     1035{
     1036    // OS/2 does this for us.
     1037}
     1038
     1039QString QOS2SettingsPrivate::fileName() const
    10401040{
    10411041    if (regList.isEmpty())
     
    10521052}
    10531053
    1054 bool QWinSettingsPrivate::isWritable() const
     1054bool QOS2SettingsPrivate::isWritable() const
    10551055{
    10561056    return writeHandle() != 0;
     
    10611061{
    10621062    if (format == QSettings::NativeFormat) {
    1063         return new QWinSettingsPrivate(scope, organization, application);
     1063        return new QOS2SettingsPrivate(scope, organization, application);
    10641064    } else {
    10651065        return new QConfFileSettingsPrivate(format, scope, organization, application);
     
    10701070{
    10711071    if (format == QSettings::NativeFormat) {
    1072         return new QWinSettingsPrivate(fileName);
     1072        return new QOS2SettingsPrivate(fileName);
    10731073    } else {
    10741074        return new QConfFileSettingsPrivate(fileName, format);
Note: See TracChangeset for help on using the changeset viewer.