/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt for Python.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

//workaround to access protected functions
#define protected public

// default includes
#include <shiboken.h>
#ifndef QT_NO_VERSION_TAGGING
#  define QT_NO_VERSION_TAGGING
#endif
#include <QDebug>
#include <pysidesignal.h>
#include <pysideproperty.h>
#include <pyside.h>
#include <pysideqenum.h>
#include <feature_select.h>
QT_WARNING_DISABLE_DEPRECATED

#include <typeinfo>
#include <iterator>

// module include
#include "pyside6_qtdesigner_python.h"

// main header
#include "qdesignerdnditeminterface_wrapper.h"

// inner classes

// Extra includes
#include <QtWidgets/qwidget.h>
#include <qpoint.h>


#include <cctype>
#include <cstring>



template <class T>
static const char *typeNameOf(const T &t)
{
    const char *typeName =  typeid(t).name();
    auto size = std::strlen(typeName);
#if defined(Q_CC_MSVC) // MSVC: "class QPaintDevice * __ptr64"
    if (auto lastStar = strchr(typeName, '*')) {
        // MSVC: "class QPaintDevice * __ptr64"
        while (*--lastStar == ' ') {
        }
        size = lastStar - typeName + 1;
    }
#else // g++, Clang: "QPaintDevice *" -> "P12QPaintDevice"
    if (size > 2 && typeName[0] == 'P' && std::isdigit(typeName[1])) {
        ++typeName;
        --size;
    }
#endif
    char *result = new char[size + 1];
    result[size] = '\0';
    memcpy(result, typeName, size);
    return result;
}


// Target ---------------------------------------------------------

extern "C" {
static int
Sbk_QDesignerDnDItemInterface_Init(PyObject *self, PyObject *args, PyObject *kwds)
{
    SbkObject *sbkSelf = reinterpret_cast<SbkObject *>(self);
    PyTypeObject *type = self->ob_type;
    PyTypeObject *myType = SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_IDX];
    SBK_UNUSED(sbkSelf)
    SBK_UNUSED(type)
    SBK_UNUSED(myType)
    PyErr_SetString(PyExc_NotImplementedError,
        "Abstract class  'QDesignerDnDItemInterface' cannot be instantiated since the wrapper has been disabled.");
    return -1;
}

static PyObject *Sbk_QDesignerDnDItemInterfaceFunc_decoration(PyObject *self)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    auto cppSelf = reinterpret_cast< ::QDesignerDnDItemInterface *>(Shiboken::Conversions::cppPointer(SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_IDX], reinterpret_cast<SbkObject *>(self)));
    SBK_UNUSED(cppSelf)
    PyObject *pyResult{};
    Shiboken::AutoDecRef errInfo{};
    static const char *fullName = "PySide6.QtDesigner.QDesignerDnDItemInterface.decoration";
    SBK_UNUSED(fullName)

    // Call function/method
    {

        if (!PyErr_Occurred()) {
            // decoration()const
            if (Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(self))) {
                PyErr_SetString(PyExc_NotImplementedError, "pure virtual method 'QDesignerDnDItemInterface.decoration()' not implemented.");
                return {};
            }
            QWidget * cppResult = const_cast<const ::QDesignerDnDItemInterface *>(cppSelf)->decoration();
            pyResult = Shiboken::Conversions::pointerToPython(SbkPySide6_QtWidgetsTypes[SBK_QWIDGET_IDX], cppResult);
            Shiboken::Object::setParent(self, pyResult);
        }
    }

    if (PyErr_Occurred() || !pyResult) {
        Py_XDECREF(pyResult);
        return {};
    }
    return pyResult;
}

static PyObject *Sbk_QDesignerDnDItemInterfaceFunc_hotSpot(PyObject *self)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    auto cppSelf = reinterpret_cast< ::QDesignerDnDItemInterface *>(Shiboken::Conversions::cppPointer(SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_IDX], reinterpret_cast<SbkObject *>(self)));
    SBK_UNUSED(cppSelf)
    PyObject *pyResult{};
    Shiboken::AutoDecRef errInfo{};
    static const char *fullName = "PySide6.QtDesigner.QDesignerDnDItemInterface.hotSpot";
    SBK_UNUSED(fullName)

    // Call function/method
    {

        if (!PyErr_Occurred()) {
            // hotSpot()const
            if (Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(self))) {
                PyErr_SetString(PyExc_NotImplementedError, "pure virtual method 'QDesignerDnDItemInterface.hotSpot()' not implemented.");
                return {};
            }
            QPoint cppResult = const_cast<const ::QDesignerDnDItemInterface *>(cppSelf)->hotSpot();
            pyResult = Shiboken::Conversions::copyToPython(SbkPySide6_QtCoreTypes[SBK_QPOINT_IDX], &cppResult);
        }
    }

    if (PyErr_Occurred() || !pyResult) {
        Py_XDECREF(pyResult);
        return {};
    }
    return pyResult;
}

static PyObject *Sbk_QDesignerDnDItemInterfaceFunc_source(PyObject *self)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    auto cppSelf = reinterpret_cast< ::QDesignerDnDItemInterface *>(Shiboken::Conversions::cppPointer(SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_IDX], reinterpret_cast<SbkObject *>(self)));
    SBK_UNUSED(cppSelf)
    PyObject *pyResult{};
    Shiboken::AutoDecRef errInfo{};
    static const char *fullName = "PySide6.QtDesigner.QDesignerDnDItemInterface.source";
    SBK_UNUSED(fullName)

    // Call function/method
    {

        if (!PyErr_Occurred()) {
            // source()const
            if (Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(self))) {
                PyErr_SetString(PyExc_NotImplementedError, "pure virtual method 'QDesignerDnDItemInterface.source()' not implemented.");
                return {};
            }
            QWidget * cppResult = const_cast<const ::QDesignerDnDItemInterface *>(cppSelf)->source();
            pyResult = Shiboken::Conversions::pointerToPython(SbkPySide6_QtWidgetsTypes[SBK_QWIDGET_IDX], cppResult);
            Shiboken::Object::setParent(self, pyResult);
        }
    }

    if (PyErr_Occurred() || !pyResult) {
        Py_XDECREF(pyResult);
        return {};
    }
    return pyResult;
}

static PyObject *Sbk_QDesignerDnDItemInterfaceFunc_type(PyObject *self)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    auto cppSelf = reinterpret_cast< ::QDesignerDnDItemInterface *>(Shiboken::Conversions::cppPointer(SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_IDX], reinterpret_cast<SbkObject *>(self)));
    SBK_UNUSED(cppSelf)
    PyObject *pyResult{};
    Shiboken::AutoDecRef errInfo{};
    static const char *fullName = "PySide6.QtDesigner.QDesignerDnDItemInterface.type";
    SBK_UNUSED(fullName)

    // Call function/method
    {

        if (!PyErr_Occurred()) {
            // type()const
            if (Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(self))) {
                PyErr_SetString(PyExc_NotImplementedError, "pure virtual method 'QDesignerDnDItemInterface.type()' not implemented.");
                return {};
            }
            QDesignerDnDItemInterface::DropType cppResult = const_cast<const ::QDesignerDnDItemInterface *>(cppSelf)->type();
            pyResult = Shiboken::Conversions::copyToPython(PepType_SETP(reinterpret_cast<SbkEnumType *>(SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_DROPTYPE_IDX]))->converter, &cppResult);
        }
    }

    if (PyErr_Occurred() || !pyResult) {
        Py_XDECREF(pyResult);
        return {};
    }
    return pyResult;
}

static PyObject *Sbk_QDesignerDnDItemInterfaceFunc_widget(PyObject *self)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    auto cppSelf = reinterpret_cast< ::QDesignerDnDItemInterface *>(Shiboken::Conversions::cppPointer(SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_IDX], reinterpret_cast<SbkObject *>(self)));
    SBK_UNUSED(cppSelf)
    PyObject *pyResult{};
    Shiboken::AutoDecRef errInfo{};
    static const char *fullName = "PySide6.QtDesigner.QDesignerDnDItemInterface.widget";
    SBK_UNUSED(fullName)

    // Call function/method
    {

        if (!PyErr_Occurred()) {
            // widget()const
            if (Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(self))) {
                PyErr_SetString(PyExc_NotImplementedError, "pure virtual method 'QDesignerDnDItemInterface.widget()' not implemented.");
                return {};
            }
            QWidget * cppResult = const_cast<const ::QDesignerDnDItemInterface *>(cppSelf)->widget();
            pyResult = Shiboken::Conversions::pointerToPython(SbkPySide6_QtWidgetsTypes[SBK_QWIDGET_IDX], cppResult);
            Shiboken::Object::setParent(self, pyResult);
        }
    }

    if (PyErr_Occurred() || !pyResult) {
        Py_XDECREF(pyResult);
        return {};
    }
    return pyResult;
}


static const char *Sbk_QDesignerDnDItemInterface_PropertyStrings[] = {
    nullptr // Sentinel
};

static PyMethodDef Sbk_QDesignerDnDItemInterface_methods[] = {
    {"decoration", reinterpret_cast<PyCFunction>(Sbk_QDesignerDnDItemInterfaceFunc_decoration), METH_NOARGS},
    {"hotSpot", reinterpret_cast<PyCFunction>(Sbk_QDesignerDnDItemInterfaceFunc_hotSpot), METH_NOARGS},
    {"source", reinterpret_cast<PyCFunction>(Sbk_QDesignerDnDItemInterfaceFunc_source), METH_NOARGS},
    {"type", reinterpret_cast<PyCFunction>(Sbk_QDesignerDnDItemInterfaceFunc_type), METH_NOARGS},
    {"widget", reinterpret_cast<PyCFunction>(Sbk_QDesignerDnDItemInterfaceFunc_widget), METH_NOARGS},

    {nullptr, nullptr} // Sentinel
};

static int Sbk_QDesignerDnDItemInterface_setattro(PyObject *self, PyObject *name, PyObject *value)
{
    PySide::Feature::Select(self);
    return PyObject_GenericSetAttr(self, name, value);
}

} // extern "C"

static int Sbk_QDesignerDnDItemInterface_traverse(PyObject *self, visitproc visit, void *arg)
{
    return SbkObject_TypeF()->tp_traverse(self, visit, arg);
}
static int Sbk_QDesignerDnDItemInterface_clear(PyObject *self)
{
    return reinterpret_cast<PyTypeObject *>(SbkObject_TypeF())->tp_clear(self);
}
// Class Definition -----------------------------------------------
extern "C" {
static PyTypeObject *_Sbk_QDesignerDnDItemInterface_Type = nullptr;
static PyTypeObject *Sbk_QDesignerDnDItemInterface_TypeF(void)
{
    return _Sbk_QDesignerDnDItemInterface_Type;
}

static PyType_Slot Sbk_QDesignerDnDItemInterface_slots[] = {
    {Py_tp_base,        nullptr}, // inserted by introduceWrapperType
    {Py_tp_dealloc,     reinterpret_cast<void *>(&SbkDeallocWrapper)},
    {Py_tp_repr,        nullptr},
    {Py_tp_hash,        nullptr},
    {Py_tp_call,        nullptr},
    {Py_tp_str,         nullptr},
    {Py_tp_getattro,    nullptr},
    {Py_tp_setattro,    reinterpret_cast<void *>(Sbk_QDesignerDnDItemInterface_setattro)},
    {Py_tp_traverse,    reinterpret_cast<void *>(Sbk_QDesignerDnDItemInterface_traverse)},
    {Py_tp_clear,       reinterpret_cast<void *>(Sbk_QDesignerDnDItemInterface_clear)},
    {Py_tp_richcompare, nullptr},
    {Py_tp_iter,        nullptr},
    {Py_tp_iternext,    nullptr},
    {Py_tp_methods,     reinterpret_cast<void *>(Sbk_QDesignerDnDItemInterface_methods)},
    {Py_tp_getset,      nullptr},
    {Py_tp_init,        reinterpret_cast<void *>(Sbk_QDesignerDnDItemInterface_Init)},
    {Py_tp_new,         reinterpret_cast<void *>(SbkObjectTpNew)},
    {0, nullptr}
};
static PyType_Spec Sbk_QDesignerDnDItemInterface_spec = {
    "2:PySide6.QtDesigner.QDesignerDnDItemInterface",
    sizeof(SbkObject),
    0,
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
    Sbk_QDesignerDnDItemInterface_slots
};

} //extern "C"


// Type conversion functions.

// Python to C++ enum conversion.
static void QDesignerDnDItemInterface_DropType_PythonToCpp_QDesignerDnDItemInterface_DropType(PyObject *pyIn, void *cppOut)
{
    *reinterpret_cast<::QDesignerDnDItemInterface::DropType *>(cppOut) =
        static_cast<::QDesignerDnDItemInterface::DropType>(Shiboken::Enum::getValue(pyIn));

}
static PythonToCppFunc is_QDesignerDnDItemInterface_DropType_PythonToCpp_QDesignerDnDItemInterface_DropType_Convertible(PyObject *pyIn)
{
    if (PyObject_TypeCheck(pyIn, SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_DROPTYPE_IDX]))
        return QDesignerDnDItemInterface_DropType_PythonToCpp_QDesignerDnDItemInterface_DropType;
    return {};
}
static PyObject *QDesignerDnDItemInterface_DropType_CppToPython_QDesignerDnDItemInterface_DropType(const void *cppIn)
{
    const int castCppIn = int(*reinterpret_cast<const ::QDesignerDnDItemInterface::DropType *>(cppIn));
    return Shiboken::Enum::newItem(SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_DROPTYPE_IDX], castCppIn);

}

// Python to C++ pointer conversion - returns the C++ object of the Python wrapper (keeps object identity).
static void QDesignerDnDItemInterface_PythonToCpp_QDesignerDnDItemInterface_PTR(PyObject *pyIn, void *cppOut)
{
    Shiboken::Conversions::pythonToCppPointer(Sbk_QDesignerDnDItemInterface_TypeF(), pyIn, cppOut);
}
static PythonToCppFunc is_QDesignerDnDItemInterface_PythonToCpp_QDesignerDnDItemInterface_PTR_Convertible(PyObject *pyIn)
{
    if (pyIn == Py_None)
        return Shiboken::Conversions::nonePythonToCppNullPtr;
    if (PyObject_TypeCheck(pyIn, reinterpret_cast<PyTypeObject *>(Sbk_QDesignerDnDItemInterface_TypeF())))
        return QDesignerDnDItemInterface_PythonToCpp_QDesignerDnDItemInterface_PTR;
    return {};
}

// C++ to Python pointer conversion - tries to find the Python wrapper for the C++ object (keeps object identity).
static PyObject *QDesignerDnDItemInterface_PTR_CppToPython_QDesignerDnDItemInterface(const void *cppIn)
{
    auto pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper(cppIn));
    if (pyOut) {
        Py_INCREF(pyOut);
        return pyOut;
    }
    bool changedTypeName = false;
    auto tCppIn = reinterpret_cast<const ::QDesignerDnDItemInterface *>(cppIn);
    const char *typeName = typeid(*tCppIn).name();
    auto sbkType = Shiboken::ObjectType::typeForTypeName(typeName);
    if (sbkType && Shiboken::ObjectType::hasSpecialCastFunction(sbkType)) {
        typeName = typeNameOf(tCppIn);
        changedTypeName = true;
    }
    PyObject *result = Shiboken::Object::newObject(Sbk_QDesignerDnDItemInterface_TypeF(), const_cast<void *>(cppIn), false, /* exactType */ changedTypeName, typeName);
    if (changedTypeName)
        delete [] typeName;
    return result;
}

// The signatures string for the functions.
// Multiple signatures have their index "n:" in front.
static const char *QDesignerDnDItemInterface_SignatureStrings[] = {
    "PySide6.QtDesigner.QDesignerDnDItemInterface(self)",
    "PySide6.QtDesigner.QDesignerDnDItemInterface.decoration(self)->PySide6.QtWidgets.QWidget",
    "PySide6.QtDesigner.QDesignerDnDItemInterface.hotSpot(self)->PySide6.QtCore.QPoint",
    "PySide6.QtDesigner.QDesignerDnDItemInterface.source(self)->PySide6.QtWidgets.QWidget",
    "PySide6.QtDesigner.QDesignerDnDItemInterface.type(self)->PySide6.QtDesigner.QDesignerDnDItemInterface.DropType",
    "PySide6.QtDesigner.QDesignerDnDItemInterface.widget(self)->PySide6.QtWidgets.QWidget",
    nullptr}; // Sentinel

void init_QDesignerDnDItemInterface(PyObject *module)
{
    _Sbk_QDesignerDnDItemInterface_Type = Shiboken::ObjectType::introduceWrapperType(
        module,
        "QDesignerDnDItemInterface",
        "QDesignerDnDItemInterface*",
        &Sbk_QDesignerDnDItemInterface_spec,
        &Shiboken::callCppDestructor< ::QDesignerDnDItemInterface >,
        0,
        0,
        0);
    auto *pyType = Sbk_QDesignerDnDItemInterface_TypeF(); // references _Sbk_QDesignerDnDItemInterface_Type
    InitSignatureStrings(pyType, QDesignerDnDItemInterface_SignatureStrings);
    SbkObjectType_SetPropertyStrings(reinterpret_cast<PyTypeObject *>(_Sbk_QDesignerDnDItemInterface_Type), Sbk_QDesignerDnDItemInterface_PropertyStrings);
    SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_IDX]
        = Sbk_QDesignerDnDItemInterface_TypeF();

    // Register Converter
    SbkConverter *converter = Shiboken::Conversions::createConverter(Sbk_QDesignerDnDItemInterface_TypeF(),
        QDesignerDnDItemInterface_PythonToCpp_QDesignerDnDItemInterface_PTR,
        is_QDesignerDnDItemInterface_PythonToCpp_QDesignerDnDItemInterface_PTR_Convertible,
        QDesignerDnDItemInterface_PTR_CppToPython_QDesignerDnDItemInterface);

    Shiboken::Conversions::registerConverterName(converter, "QDesignerDnDItemInterface");
    Shiboken::Conversions::registerConverterName(converter, "QDesignerDnDItemInterface*");
    Shiboken::Conversions::registerConverterName(converter, "QDesignerDnDItemInterface&");
    Shiboken::Conversions::registerConverterName(converter, typeid(::QDesignerDnDItemInterface).name());


    // Initialization of enums.

    // Initialization of enum 'DropType'.
    SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_DROPTYPE_IDX] = Shiboken::Enum::createScopedEnum(Sbk_QDesignerDnDItemInterface_TypeF(),
        "DropType",
        "2:PySide6.QtDesigner.QDesignerDnDItemInterface.DropType",
        "QDesignerDnDItemInterface::DropType");
    if (!SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_DROPTYPE_IDX])
        return;

    if (!Shiboken::Enum::createScopedEnumItem(SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_DROPTYPE_IDX],
        Sbk_QDesignerDnDItemInterface_TypeF(), "MoveDrop", (long) QDesignerDnDItemInterface::DropType::MoveDrop))
        return;
    if (!Shiboken::Enum::createScopedEnumItem(SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_DROPTYPE_IDX],
        Sbk_QDesignerDnDItemInterface_TypeF(), "CopyDrop", (long) QDesignerDnDItemInterface::DropType::CopyDrop))
        return;
    // Register converter for enum 'QDesignerDnDItemInterface::DropType'.
    {
        SbkConverter *converter = Shiboken::Conversions::createConverter(SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_DROPTYPE_IDX],
            QDesignerDnDItemInterface_DropType_CppToPython_QDesignerDnDItemInterface_DropType);
        Shiboken::Conversions::addPythonToCppValueConversion(converter,
            QDesignerDnDItemInterface_DropType_PythonToCpp_QDesignerDnDItemInterface_DropType,
            is_QDesignerDnDItemInterface_DropType_PythonToCpp_QDesignerDnDItemInterface_DropType_Convertible);
        Shiboken::Enum::setTypeConverter(SbkPySide6_QtDesignerTypes[SBK_QDESIGNERDNDITEMINTERFACE_DROPTYPE_IDX], converter, false);
        Shiboken::Conversions::registerConverterName(converter, "QDesignerDnDItemInterface::DropType");
        Shiboken::Conversions::registerConverterName(converter, "DropType");
    }
    // End of 'DropType' enum.

    qRegisterMetaType< ::QDesignerDnDItemInterface::DropType >("QDesignerDnDItemInterface::DropType");
}
