// qsettings.sip generated by MetaSIP
//
// This file is part of the QtCore Python extension module.
//
// Copyright (c) 2016 Riverbank Computing Limited <info@riverbankcomputing.com>
// 
// This file is part of PyQt5.
// 
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file.  Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
// 
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license.  For more information contact
// info@riverbankcomputing.com.
// 
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.


class QSettings : QObject
{
%TypeHeaderCode
#include <qsettings.h>
%End

public:
    enum Status
    {
        NoError,
        AccessError,
        FormatError,
    };

    enum Format
    {
        NativeFormat,
        IniFormat,
        InvalidFormat,
    };

    enum Scope
    {
        UserScope,
        SystemScope,
    };

    QSettings(const QString &organization, const QString &application = QString(), QObject *parent /TransferThis/ = 0);
    QSettings(QSettings::Scope scope, const QString &organization, const QString &application = QString(), QObject *parent /TransferThis/ = 0);
    QSettings(QSettings::Format format, QSettings::Scope scope, const QString &organization, const QString &application = QString(), QObject *parent /TransferThis/ = 0);
    QSettings(const QString &fileName, QSettings::Format format, QObject *parent /TransferThis/ = 0);
    explicit QSettings(QObject *parent /TransferThis/ = 0);
    virtual ~QSettings();
    void clear();
    void sync();
    QSettings::Status status() const;
    void beginGroup(const QString &prefix);
    void endGroup();
    QString group() const;
    int beginReadArray(const QString &prefix);
    void beginWriteArray(const QString &prefix, int size = -1);
    void endArray();
    void setArrayIndex(int i);
    QStringList allKeys() const;
    QStringList childKeys() const;
    QStringList childGroups() const;
    bool isWritable() const;
    void setValue(const QString &key, const QVariant &value);
    SIP_PYOBJECT value(const QString &key, const QVariant &defaultValue = QVariant(), SIP_PYOBJECT type /TypeHint="type", TypeHintValue="None"/ = 0) const /ReleaseGIL/;
%MethodCode
        QVariant value;
        
        // QSettings has an internal mutex so release the GIL to avoid the possibility
        // of deadlocks.
        Py_BEGIN_ALLOW_THREADS
        value = sipCpp->value(*a0, *a1);
        Py_END_ALLOW_THREADS
        
        sipRes = pyqt5_from_qvariant_by_type(value, a2);
        
        sipIsErr = !sipRes;
%End

    void remove(const QString &key);
    bool contains(const QString &key) const;
    void setFallbacksEnabled(bool b);
    bool fallbacksEnabled() const;
    QString fileName() const;
    static void setPath(QSettings::Format format, QSettings::Scope scope, const QString &path);
    QSettings::Format format() const;
    QSettings::Scope scope() const;
    QString organizationName() const;
    QString applicationName() const;
    static void setDefaultFormat(QSettings::Format format);
    static QSettings::Format defaultFormat();
    void setIniCodec(QTextCodec *codec /KeepReference/);
    void setIniCodec(const char *codecName);
    QTextCodec *iniCodec() const;

protected:
    virtual bool event(QEvent *event);

private:
    QSettings(const QSettings &);
};
