• Skip to content
  • Skip to link menu
KDE 4.3 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:
00173     bool kill( KillVerbosity verbosity = Quietly );
00174 
00181     bool suspend();
00182 
00188     bool resume();
00189 
00190 protected:
00197     virtual bool doKill();
00198 
00204     virtual bool doSuspend();
00205 
00211     virtual bool doResume();
00212 
00219     void setCapabilities( Capabilities capabilities );
00220 
00221 public:
00227     bool exec();
00228 
00229     enum
00230     {
00231         NoError = 0,
00232         KilledJobError = 1,
00233         UserDefinedError = 100
00234     };
00235 
00236 
00243     int error() const;
00244 
00253     QString errorText() const;
00254 
00271     virtual QString errorString() const;
00272 
00273 
00280     qulonglong processedAmount(Unit unit) const;
00281 
00288     qulonglong totalAmount(Unit unit) const;
00289 
00295     unsigned long percent() const;
00296 
00306     void setAutoDelete( bool autodelete );
00307 
00315     bool isAutoDelete() const;
00316 
00317 Q_SIGNALS:
00318 #ifndef Q_MOC_RUN
00319 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00320 private: // don't tell moc or doxygen, but those signals are in fact private
00321 #endif
00322 #endif
00323 
00336     void finished(KJob *job);
00337 
00346     void suspended(KJob *job);
00347 
00356     void resumed(KJob *job);
00357 
00372     void result(KJob *job);
00373 
00374 Q_SIGNALS:
00388     void description(KJob *job, const QString &title,
00389                      const QPair<QString, QString> &field1 = qMakePair(QString(), QString()),
00390                      const QPair<QString, QString> &field2 = qMakePair(QString(), QString()));
00391 
00400     void infoMessage( KJob *job, const QString &plain, const QString &rich = QString() );
00401 
00409     void warning( KJob *job, const QString &plain, const QString &rich = QString() );
00410 
00411 
00412 Q_SIGNALS:
00413 #ifndef Q_MOC_RUN
00414 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00415 private: // don't tell moc, but those signals are in fact private
00416 #endif
00417 #endif
00418 
00430     void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount);
00431 
00444     void processedAmount(KJob *job, KJob::Unit unit, qulonglong amount);
00445 
00456     void totalSize(KJob *job, qulonglong size);
00457 
00468     void processedSize(KJob *job, qulonglong size);
00469 
00483     void percent( KJob *job, unsigned long percent );
00484 
00494     void speed(KJob *job, unsigned long speed);
00495 
00496 protected:
00504     void setError( int errorCode );
00505 
00513     void setErrorText( const QString &errorText );
00514 
00515 
00524     void setProcessedAmount(Unit unit, qulonglong amount);
00525 
00534     void setTotalAmount(Unit unit, qulonglong amount);
00535 
00542     void setPercent( unsigned long percentage );
00543 
00544 
00555     void emitResult();
00556 
00566     void emitPercent( qulonglong processedAmount, qulonglong totalAmount );
00567 
00574     void emitSpeed(unsigned long speed);
00575 
00576 protected:
00577     KJobPrivate *const d_ptr;
00578     KJob(KJobPrivate &dd, QObject *parent);
00579 
00580 private:
00581     Q_PRIVATE_SLOT(d_func(), void _k_speedTimeout())
00582     Q_DECLARE_PRIVATE(KJob)
00583 };
00584 
00585 Q_DECLARE_OPERATORS_FOR_FLAGS( KJob::Capabilities )
00586 
00587 #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
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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