• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.9.5 API Reference
  • KDE Home
  • 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;
00084 class KDECORE_EXPORT KJob : public QObject
00085 {
00086     Q_OBJECT
00087     Q_ENUMS( KillVerbosity Capability Unit )
00088     Q_FLAGS( Capabilities )
00089 
00090 public:
00091     enum Unit { Bytes, Files, Directories };
00092 
00093     enum Capability { NoCapabilities = 0x0000,
00094                       Killable       = 0x0001,
00095                       Suspendable    = 0x0002 };
00096 
00097     Q_DECLARE_FLAGS( Capabilities, Capability )
00098 
00099     
00104     explicit KJob( QObject *parent = 0 );
00105 
00109     virtual ~KJob();
00110 
00120     void setUiDelegate( KJobUiDelegate *delegate );
00121 
00127     KJobUiDelegate *uiDelegate() const;
00128 
00135     Capabilities capabilities() const;
00136 
00143     bool isSuspended() const;
00144 
00166     virtual void start() = 0;
00167 
00168     enum KillVerbosity { Quietly, EmitResult };
00169 
00170 public Q_SLOTS:
00184     bool kill( KillVerbosity verbosity = Quietly );
00185 
00192     bool suspend();
00193 
00199     bool resume();
00200 
00201 protected:
00209     virtual bool doKill();
00210 
00216     virtual bool doSuspend();
00217 
00223     virtual bool doResume();
00224 
00231     void setCapabilities( Capabilities capabilities );
00232 
00233 public:
00252     bool exec();
00253 
00254     enum
00255     {
00256         /*** Indicates there is no error */
00257         NoError = 0,
00258         /*** Indicates the job was killed */
00259         KilledJobError = 1,
00260         /*** Subclasses should define error codes starting at this value */
00261         UserDefinedError = 100
00262     };
00263 
00264 
00272     int error() const;
00273 
00285     QString errorText() const;
00286 
00303     virtual QString errorString() const;
00304 
00305 
00312     qulonglong processedAmount(Unit unit) const;
00313 
00320     qulonglong totalAmount(Unit unit) const;
00321 
00327     unsigned long percent() const;
00328 
00338     void setAutoDelete( bool autodelete );
00339 
00347     bool isAutoDelete() const;
00348 
00349 Q_SIGNALS:
00350 #if !defined(Q_MOC_RUN) && !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(IN_IDE_PARSER)
00351 private: // don't tell moc, doxygen or kdevelop, but those signals are in fact private
00352 #endif
00353 
00370     void finished(KJob *job);
00371 
00380     void suspended(KJob *job);
00381 
00390     void resumed(KJob *job);
00391 
00406     void result(KJob *job);
00407 
00408 Q_SIGNALS:
00422     void description(KJob *job, const QString &title,
00423                      const QPair<QString, QString> &field1 = qMakePair(QString(), QString()),
00424                      const QPair<QString, QString> &field2 = qMakePair(QString(), QString()));
00425 
00434     void infoMessage( KJob *job, const QString &plain, const QString &rich = QString() );
00435 
00443     void warning( KJob *job, const QString &plain, const QString &rich = QString() );
00444 
00445 
00446 Q_SIGNALS:
00447 #if !defined(Q_MOC_RUN) && !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(IN_IDE_PARSER)
00448 private: // don't tell moc, doxygen or kdevelop, but those signals are in fact private
00449 #endif
00450 
00462     void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount);
00463 
00476     void processedAmount(KJob *job, KJob::Unit unit, qulonglong amount);
00477 
00488     void totalSize(KJob *job, qulonglong size);
00489 
00500     void processedSize(KJob *job, qulonglong size);
00501 
00515     void percent( KJob *job, unsigned long percent );
00516 
00526     void speed(KJob *job, unsigned long speed);
00527 
00528 protected:
00548     void setError( int errorCode );
00549 
00563     void setErrorText( const QString &errorText );
00564 
00565 
00574     void setProcessedAmount(Unit unit, qulonglong amount);
00575 
00584     void setTotalAmount(Unit unit, qulonglong amount);
00585 
00592     void setPercent( unsigned long percentage );
00593 
00594 
00605     void emitResult();
00606 
00616     void emitPercent( qulonglong processedAmount, qulonglong totalAmount );
00617 
00624     void emitSpeed(unsigned long speed);
00625 
00626 protected:
00627     KJobPrivate *const d_ptr;
00628     KJob(KJobPrivate &dd, QObject *parent);
00629 
00630 private:
00631     Q_PRIVATE_SLOT(d_func(), void _k_speedTimeout())
00632     Q_DECLARE_PRIVATE(KJob)
00633 };
00634 
00635 Q_DECLARE_OPERATORS_FOR_FLAGS( KJob::Capabilities )
00636 
00637 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Mon Jan 21 2019 12:28:10 by doxygen 1.7.5.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs-4.9.5 API Reference

Skip menu "kdelibs-4.9.5 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal