• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

kjob.h

Go to the documentation of this file.
00001 /*  This file is part of the KDE project
00002     Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
00003                        David Faure <faure@kde.org>
00004     Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License version 2 as published by the Free Software Foundation.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 
00020 */
00021 
00022 #ifndef KJOB_H
00023 #define KJOB_H
00024 
00025 #include <kdecore_export.h>
00026 #include <QtCore/QObject>
00027 #include <QtCore/QPair>
00028 
00029 class KJobUiDelegate;
00030 
00031 class KJobPrivate;
00079 class KDECORE_EXPORT KJob : public QObject
00080 {
00081     Q_OBJECT
00082     Q_ENUMS( KillVerbosity Capability Unit )
00083     Q_FLAGS( Capabilities )
00084 
00085 public:
00086     enum Unit { Bytes, Files, Directories };
00087 
00088     enum Capability { NoCapabilities = 0x0000,
00089                       Killable       = 0x0001,
00090                       Suspendable    = 0x0002 };
00091 
00092     Q_DECLARE_FLAGS( Capabilities, Capability )
00093 
00094     
00099     explicit KJob( QObject *parent = 0 );
00100 
00104     virtual ~KJob();
00105 
00115     void setUiDelegate( KJobUiDelegate *delegate );
00116 
00122     KJobUiDelegate *uiDelegate() const;
00123 
00130     Capabilities capabilities() const;
00131 
00138     bool isSuspended() const;
00139 
00156     virtual void start() = 0;
00157 
00158     enum KillVerbosity { Quietly, EmitResult };
00159 
00160 public Q_SLOTS:
00172     bool kill( KillVerbosity verbosity = Quietly );
00173 
00180     bool suspend();
00181 
00187     bool resume();
00188 
00189 protected:
00196     virtual bool doKill();
00197 
00203     virtual bool doSuspend();
00204 
00210     virtual bool doResume();
00211 
00218     void setCapabilities( Capabilities capabilities );
00219 
00220 public:
00226     bool exec();
00227 
00228     enum
00229     {
00230         NoError = 0,
00231         KilledJobError = 1,
00232         UserDefinedError = 100
00233     };
00234 
00235 
00242     int error() const;
00243 
00252     QString errorText() const;
00253 
00270     virtual QString errorString() const;
00271 
00272 
00279     qulonglong processedAmount(Unit unit) const;
00280 
00287     qulonglong totalAmount(Unit unit) const;
00288 
00294     unsigned long percent() const;
00295 
00305     void setAutoDelete( bool autodelete );
00306 
00314     bool isAutoDelete() const;
00315 
00316 Q_SIGNALS:
00317 #ifndef Q_MOC_RUN
00318 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00319 private: // don't tell moc or doxygen, but those signals are in fact private
00320 #endif
00321 #endif
00322 
00332     void finished(KJob *job);
00333 
00342     void suspended(KJob *job);
00343 
00352     void resumed(KJob *job);
00353 
00363     void result(KJob *job);
00364 
00365 Q_SIGNALS:
00379     void description(KJob *job, const QString &title,
00380                      const QPair<QString, QString> &field1 = qMakePair(QString(), QString()),
00381                      const QPair<QString, QString> &field2 = qMakePair(QString(), QString()));
00382 
00391     void infoMessage( KJob *job, const QString &plain, const QString &rich = QString() );
00392 
00400     void warning( KJob *job, const QString &plain, const QString &rich = QString() );
00401 
00402 
00403 Q_SIGNALS:
00404 #ifndef Q_MOC_RUN
00405 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00406 private: // don't tell moc, but those signals are in fact private
00407 #endif
00408 #endif
00409 
00421     void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount);
00422 
00435     void processedAmount(KJob *job, KJob::Unit unit, qulonglong amount);
00436 
00447     void totalSize(KJob *job, qulonglong size);
00448 
00459     void processedSize(KJob *job, qulonglong size);
00460 
00474     void percent( KJob *job, unsigned long percent );
00475 
00485     void speed(KJob *job, unsigned long speed);
00486 
00487 protected:
00495     void setError( int errorCode );
00496 
00504     void setErrorText( const QString &errorText );
00505 
00506 
00515     void setProcessedAmount(Unit unit, qulonglong amount);
00516 
00525     void setTotalAmount(Unit unit, qulonglong amount);
00526 
00533     void setPercent( unsigned long percentage );
00534 
00535 
00546     void emitResult();
00547 
00557     void emitPercent( qulonglong processedAmount, qulonglong totalAmount );
00558 
00565     void emitSpeed(unsigned long speed);
00566 
00567 protected:
00568     KJobPrivate *const d_ptr;
00569     KJob(KJobPrivate &dd, QObject *parent);
00570 
00571 private:
00572     Q_PRIVATE_SLOT(d_func(), void _k_speedTimeout())
00573     Q_DECLARE_PRIVATE(KJob)
00574 };
00575 
00576 Q_DECLARE_OPERATORS_FOR_FLAGS( KJob::Capabilities )
00577 
00578 #endif

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal