//
//     Copyright 2008 Jim Bublitz <jbublitz@nwinternet.com>
//     Earlier copyrights 1998 - 2007 Jim Bublitz also apply

//                 Generated by twine

// This file is part of PyKDE4.

// PyKDE4 is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.

// PyKDE4 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 program.  If not, see <http://www.gnu.org/licenses/>.



class KDirLister : QObject
{
%TypeHeaderCode
#include <kdirlister.h>
%End



public:
    enum OpenUrlFlag
    {
        NoFlags,
        Keep,
        Reload
    };

    typedef QFlags<KDirLister::OpenUrlFlag> OpenUrlFlags;

                            KDirLister (QObject* parent /TransferThis/ = 0);
    virtual bool            openUrl (const KUrl& _url, KDirLister::OpenUrlFlags _flags = KDirLister::NoFlags);
    virtual void            stop ();
    virtual void            stop (const KUrl& _url);
    bool                    delayedMimeTypes () const;
    void                    setDelayedMimeTypes (bool delayedMimeTypes);
    bool                    autoUpdate () const;
    virtual void            setAutoUpdate (bool enable);
    bool                    autoErrorHandlingEnabled () const;
    void                    setAutoErrorHandlingEnabled (bool enable, QWidget* parent /Transfer/);
    bool                    showingDotFiles () const;
    virtual void            setShowingDotFiles (bool _showDotFiles);
    bool                    dirOnlyMode () const;
    virtual void            setDirOnlyMode (bool dirsOnly);
    KUrl                    url () const;
    KUrl::List              directories () const;
    virtual void            emitChanges ();
    virtual void            updateDirectory (const KUrl& _dir);
    bool                    isFinished () const;
    KFileItem               rootItem () const;
    virtual KFileItem       findByUrl (const KUrl& _url) const;
    virtual KFileItem       findByName (const QString& name) const;
    virtual void            setNameFilter (const QString& filter);
    QString                 nameFilter () const;
    virtual void            setMimeFilter (const QStringList& mimeList);
    void                    setMimeExcludeFilter (const QStringList& mimeList);
    virtual void            clearMimeFilter ();
    QStringList             mimeFilters () const;
    bool                    matchesFilter (const QString& name) const;
    bool                    matchesMimeFilter (const QString& mime) const;
    void                    setMainWindow (QWidget* window);
    QWidget*                mainWindow ();

    enum WhichItems
    {
        AllItems,
        FilteredItems
    };

    KFileItemList           items (KDirLister::WhichItems which = KDirLister::FilteredItems) const;
    KFileItemList           itemsForDir (const KUrl& dir, KDirLister::WhichItems which = KDirLister::FilteredItems) const;
    static KFileItem        cachedItemForUrl (const KUrl& url);

signals:
    void                    started (const KUrl& _url);
    void                    completed ();
    void                    completed (const KUrl& _url);
    void                    canceled ();
    void                    canceled (const KUrl& _url);
    void                    redirection (const KUrl& _url);
    void                    redirection (const KUrl& oldUrl, const KUrl& newUrl);
    void                    clear ();
    void                    clear (const KUrl& _url);
    void                    newItems (const KFileItemList& items);
    void                    itemsAdded (const KUrl& directoryUrl, const KFileItemList& items);
    void                    itemsFilteredByMime (const KFileItemList& items);
    void                    deleteItem (const KFileItem& _fileItem);
    void                    itemsDeleted (const KFileItemList& items);
    void                    infoMessage (const QString& msg);
    void                    percent (int percent);
    void                    totalSize (KIO::filesize_t size);
    void                    processedSize (KIO::filesize_t size);
    void                    speed (int bytes_per_second);


protected:
    enum Changes
    {
        NONE,
        NAME_FILTER,
        MIME_FILTER,
        DOT_FILES,
        DIR_ONLY_MODE
    };

    virtual bool            matchesFilter (const KFileItem&) const;
    virtual bool            matchesMimeFilter (const KFileItem&) const;
    virtual bool            doNameFilter (const QString& name, const QList<QRegExp>& filters) const;
    virtual bool            doMimeFilter (const QString& mime, const QStringList& filters) const;
    virtual void            handleError (KIO::Job*);
public:
    ~KDirLister ();
signals:
    void                    refreshItems (const QList<QPair<KFileItem,KFileItem>>& items);
};
// KDirLister


