//
//     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 KJob : QObject
{
%TypeHeaderCode
#include <kjob.h>
%End


public:

    enum Unit
    {
        Bytes,
        Files,
        Directories
    };


    enum Capability
    {
        NoCapabilities,
        Killable,
        Suspendable
    };

    typedef QFlags<KJob::Capability> Capabilities;

    explicit                KJob (QObject* parent /TransferThis/ = 0);
    void                    setUiDelegate (KJobUiDelegate* delegate);
    KJobUiDelegate*         uiDelegate () const;
    KJob::Capabilities      capabilities () const;
    bool                    isSuspended () const;
    virtual void            start () = 0;

    enum KillVerbosity
    {
        Quietly,
        EmitResult
    };

    bool                    kill (KJob::KillVerbosity verbosity = KJob::Quietly);
    bool                    suspend ();
    bool                    resume ();

protected:
    virtual bool            doKill ();
    virtual bool            doSuspend ();
    virtual bool            doResume ();
    void                    setCapabilities (KJob::Capabilities capabilities);

public:
    bool                    exec () /PyName=exec_/;

    enum 
    {
        NoError,
        KilledJobError,
        UserDefinedError
    };

    int                     error () const;
    QString                 errorText () const;
    virtual QString         errorString () const;
    qulonglong              processedAmount (KJob::Unit unit) const;
    qulonglong              totalAmount (KJob::Unit unit) const;
    unsigned long           percent () const;

    void                    setAutoDelete (bool autodelete);
    bool                    isAutoDelete () const;


signals:
    void                    description (KJob* job, const QString& title, const QPair<QString,QString>& field1 = qMakePair(QString(),QString()), const QPair<QString,QString>& field2 = qMakePair(QString(),QString()));
    void                    infoMessage (KJob* job, const QString& plain, const QString& rich = QString());
    void                    warning (KJob* job, const QString& plain, const QString& rich = QString());

protected:
    void                    setError (int errorCode);
    void                    setErrorText (const QString& errorText);
    void                    setProcessedAmount (KJob::Unit unit, qulonglong amount);
    void                    setTotalAmount (KJob::Unit unit, qulonglong amount);
    void                    setPercent (unsigned long percentage);
    void                    emitResult ();
    void                    emitPercent (qulonglong processedAmount, qulonglong totalAmount);
    void                    emitSpeed (unsigned long speed);
//ig                        KJob (KJobPrivate& dd, QObject* parent /TransferThis/);
};   // KJob


