//
//     Copyright 2006 Jim Bublitz <jbublitz@nwinternet.com>
//     Earlier copyrights 1998 - 2005 Jim Bublitz and/or Phil Thompson
//     may also apply


//                 Generated by preSip
//            module tdefile  version KDE 3.5.3


// This software 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 of
// the License, or (at your option) any later version.
//
// This software is distributed 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 this library; see the file COPYING.
// If not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


class KFileTreeBranch : KDirLister
{
%TypeHeaderCode
#include <tdefiletreebranch.h>
%End


public:
                         KFileTreeBranch (KFileTreeView*, const KURL&, const TQString&, const TQPixmap&, bool = 0, KFileTreeViewItem* = 0);
    KURL                 rootUrl () const;
    virtual void         setRoot (KFileTreeViewItem*);
    KFileTreeViewItem*   root ();
    TQString              name () const;
    virtual void         setName (const TQString);
    const TQPixmap&       pixmap ();
    const TQPixmap&       openPixmap ();
    bool                 showExtensions () const;
    void                 setOpen (bool = 1);
    void                 setChildRecurse (bool = 1);
    bool                 childRecurse ();

public slots:
    virtual bool         populate (const KURL&, KFileTreeViewItem*);
    virtual void         setShowExtensions (bool = 1);
    void                 setOpenPixmap (const TQPixmap&);

protected:
    virtual KFileTreeViewItem* createTreeViewItem (KFileTreeViewItem* /Transfer/, KFileItem*);

public:

%If ( KDE_3_1_0 -  )
    virtual KFileTreeViewItem* findTVIByURL (const KURL&);
%End


signals:
    void                 populateFinished (KFileTreeViewItem*);
    void                 newTreeViewItems (KFileTreeBranch*, KFileTreeViewItemList&);
    void                 directoryChildCount (KFileTreeViewItem*, int);

protected:
//igx     virtual void         virtual_hook (int, void*);

protected:

%If (  - KDE_3_1_0 )
    virtual KFileTreeViewItem* findTVIByURL (const KURL&);
%End


};  // class KFileTreeBranch

typedef TQPtrList<KFileTreeBranch> KFileTreeBranchList;
//ig typedef TQPtrListIterator<KFileTreeBranch> KFileTreeBranchIterator;


%MappedType TQPtrList<KFileTreeViewItem>
//converts a Python list of KFileTreeViewItem
{
%TypeHeaderCode
#include <tdefiletreeviewitem.h>
typedef TQPtrList<KFileTreeViewItem> KFileTreeViewItemList;
%End

%ConvertFromTypeCode
    // Convert to a Python list of KFileTreeViewItem

    if (!sipCpp)
        return PyList_New(0);

    PyObject *ftvilist;

    // Create the list

    if ((ftvilist = PyList_New(0)) == NULL)
        return NULL;

    // Get it.

    TQPtrList<KFileTreeViewItem> *cList = (TQPtrList<KFileTreeViewItem> *)sipCpp;
    PyObject *item;
    KFileTreeViewItem *ftvi;

    for( ftvi = cList->first(); ftvi; ftvi = cList->next ())
    {
        item = sipConvertFromInstance (ftvi, sipClass_KFileTreeViewItem, sipTransferObj);
        if ((item == NULL) || (PyList_Append (ftvilist, item) < 0))
        {
            Py_XDECREF (item);
            Py_DECREF (ftvilist);
            return NULL;
        }
    }

        return ftvilist;
%End

%ConvertToTypeCode
    // Convert a Python list to a KFileTreeViewItemList on the heap.

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

    TQPtrList<KFileTreeViewItem> *cList = new TQPtrList<KFileTreeViewItem>;

    PyObject *elem;
    int iserr = 0;
    KFileTreeViewItem *ftvi;

    for (int i = 0; i < PyList_Size (sipPy); i++)
    {
        elem = PyList_GET_ITEM (sipPy, i);
        ftvi = (KFileTreeViewItem *)sipForceConvertToType(elem, sipType_KFileTreeViewItem, sipTransferObj, SIP_NO_CONVERTORS, NULL, &iserr);
        
        if (iserr)
        {
            *sipIsErr = 1;
            delete cList;
            return 0;
        }

        cList->append (ftvi);
    }

    *sipCppPtr = cList;

    return 1;
%End
};


%MappedType TQPtrList<KFileTreeBranch>
//converts a Python list of KFileTreeBranch
{
%TypeHeaderCode
#include <tdefiletreebranch.h>
//typedef TQPtrList<KFileTreeBranch> KFileTreeBList;
%End

%ConvertFromTypeCode
    // Convert to a Python list of KFileTreeBranch

    if (!sipCpp)
        return PyList_New(0);

    PyObject *ftblist;

    // Create the list

    if ((ftblist = PyList_New(0)) == NULL)
        return NULL;

    // Get it.

    TQPtrList<KFileTreeBranch> *cList = (TQPtrList<KFileTreeBranch> *)sipCpp;
    PyObject *item;
    KFileTreeBranch *ftb;

    for( ftb = cList->first(); ftb; ftb = cList->next ())
    {
        item = sipConvertFromInstance (ftb, sipClass_KFileTreeBranch, sipTransferObj);
        if ((item == NULL) || (PyList_Append (ftblist, item) < 0))
        {
            Py_XDECREF (item);
            Py_DECREF (ftblist);
            return NULL;
        }
    }

    return ftblist;
%End

%ConvertToTypeCode
    // Convert a Python list to a KFileTreeBranchList on the heap.

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

    TQPtrList<KFileTreeBranch> *cList = new TQPtrList<KFileTreeBranch>;

    PyObject *elem;
    int iserr = 0;
    KFileTreeBranch *ftb;

    for (int i = 0; i < PyList_Size (sipPy); i++)
    {
        elem = PyList_GET_ITEM (sipPy, i);
        ftb = (KFileTreeBranch *)sipForceConvertToType(elem, sipType_KFileTreeBranch, sipTransferObj, SIP_NO_CONVERTORS, NULL, &iserr);

        if (iserr)
        {
            *sipIsErr = 1;
            delete cList;
            return 0;
        }

        cList->append (ftb);
    }

    *sipCppPtr = cList;

    return 1;
%End
};