// This is the SIP interface definition for all Qtopia types based on the QList
// template.
//
// Copyright (c) 2003
// 	Riverbank Computing Limited <info@riverbankcomputing.co.uk>
// 
// This file is part of PyQt.
// 
// This copy of PyQt is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2, or (at your option) any later
// version.
// 
// PyQt is supplied in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
// details.
// 
// You should have received a copy of the GNU General Public License along with
// PyQt; see the file LICENSE.  If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 
%If (WS_QWS)
%If (- Qt_3_0_0)

%MappedType QList<AppLnk>
{
%HeaderCode
#include <qlist.h>
%End

%ConvertFromTypeCode
	// Handle no list.

	if (!sipCpp)
		return PyList_New(0);

	// Convert to a Python list of AppLnk instances.

	AppLnk *al;
	int i;
	PyObject *l;

	// Create the list.

	if ((l = PyList_New(sipCpp -> count())) == NULL)
		return NULL;

	// Get it.

	i = 0;

	for (al = sipCpp -> first(); al != NULL; al = sipCpp -> next())
	{
		PyObject *alobj;

		if ((alobj = sipMapCppToSelfSubClass(al,sipClass_AppLnk)) == NULL || PyList_SetItem(l,i,alobj) < 0)
		{
			Py_XDECREF(alobj);
			Py_DECREF(l);

			return NULL;
		}

		++i;
	}

	return l;
%End

%ConvertToTypeCode
	if (sipIsErr == NULL)
		return PyList_Check(sipPy);

	if (sipPy == Py_None)
	{
		*sipCppPtr = NULL;

		return 0;
	}

	QList<AppLnk> *ql = new QList<AppLnk>;

	for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
	{
		ql -> append(reinterpret_cast<AppLnk *>(sipForceConvertTo_AppLnk(PyList_GET_ITEM(sipPy,i),sipIsErr)));

		if (*sipIsErr)
		{
			delete ql;

			return 0;
		}
	}

	*sipCppPtr = ql;

	return 1;
%End
};


%MappedType QList<DocLnk>
{
%HeaderCode
#include <qlist.h>
%End

%ConvertFromTypeCode
	// Handle no list.

	if (!sipCpp)
		return PyList_New(0);

	// Convert to a Python list of DocLnk instances.

	DocLnk *dl;
	int i;
	PyObject *l;

	// Create the list.

	if ((l = PyList_New(sipCpp -> count())) == NULL)
		return NULL;

	// Get it.

	i = 0;

	for (dl = sipCpp -> first(); dl != NULL; dl = sipCpp -> next())
	{
		PyObject *dlobj;

		if ((dlobj = sipMapCppToSelfSubClass(dl,sipClass_DocLnk)) == NULL || PyList_SetItem(l,i,dlobj) < 0)
		{
			Py_XDECREF(dlobj);
			Py_DECREF(l);

			return NULL;
		}

		++i;
	}

	return l;
%End

%ConvertToTypeCode
	if (sipIsErr == NULL)
		return PyList_Check(sipPy);

	if (sipPy == Py_None)
	{
		*sipCppPtr = NULL;

		return 0;
	}

	QList<DocLnk> *ql = new QList<DocLnk>;

	for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
	{
		ql -> append(reinterpret_cast<DocLnk *>(sipForceConvertTo_DocLnk(PyList_GET_ITEM(sipPy,i),sipIsErr)));

		if (*sipIsErr)
		{
			delete ql;

			return 0;
		}
	}

	*sipCppPtr = ql;

	return 1;
%End
};

%End
%End
