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

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • jobs
kjob.h
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
3  David Faure <faure@kde.org>
4  Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 
20 */
21 
22 #ifndef KJOB_H
23 #define KJOB_H
24 
25 #include <kdecore_export.h>
26 #include <QtCore/QObject>
27 #include <QtCore/QPair>
28 
29 class KJobUiDelegate;
30 
31 class KJobPrivate;
84 class KDECORE_EXPORT KJob : public QObject
85 {
86  Q_OBJECT
87  Q_ENUMS( KillVerbosity Capability Unit )
88  Q_FLAGS( Capabilities )
89 
90 public:
91  enum Unit { Bytes, Files, Directories };
92 
93  enum Capability { NoCapabilities = 0x0000,
94  Killable = 0x0001,
95  Suspendable = 0x0002 };
96 
97  Q_DECLARE_FLAGS( Capabilities, Capability )
98 
99 
104  explicit KJob( QObject *parent = 0 );
105 
109  virtual ~KJob();
110 
120  void setUiDelegate( KJobUiDelegate *delegate );
121 
127  KJobUiDelegate *uiDelegate() const;
128 
135  Capabilities capabilities() const;
136 
143  bool isSuspended() const;
144 
166  virtual void start() = 0;
167 
168  enum KillVerbosity { Quietly, EmitResult };
169 
170 public Q_SLOTS:
184  bool kill( KillVerbosity verbosity = Quietly );
185 
192  bool suspend();
193 
199  bool resume();
200 
201 protected:
209  virtual bool doKill();
210 
216  virtual bool doSuspend();
217 
223  virtual bool doResume();
224 
231  void setCapabilities( Capabilities capabilities );
232 
233 public:
252  bool exec();
253 
254  enum
255  {
256  /*** Indicates there is no error */
257  NoError = 0,
258  /*** Indicates the job was killed */
259  KilledJobError = 1,
260  /*** Subclasses should define error codes starting at this value */
261  UserDefinedError = 100
262  };
263 
264 
272  int error() const;
273 
285  QString errorText() const;
286 
303  virtual QString errorString() const;
304 
305 
312  qulonglong processedAmount(Unit unit) const;
313 
320  qulonglong totalAmount(Unit unit) const;
321 
327  unsigned long percent() const;
328 
338  void setAutoDelete( bool autodelete );
339 
347  bool isAutoDelete() const;
348 
349 Q_SIGNALS:
350 #if !defined(Q_MOC_RUN) && !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(IN_IDE_PARSER)
351 private: // don't tell moc, doxygen or kdevelop, but those signals are in fact private
352 #endif
353 
370  void finished(KJob *job);
371 
380  void suspended(KJob *job);
381 
390  void resumed(KJob *job);
391 
406  void result(KJob *job);
407 
408 Q_SIGNALS:
422  void description(KJob *job, const QString &title,
423  const QPair<QString, QString> &field1 = qMakePair(QString(), QString()),
424  const QPair<QString, QString> &field2 = qMakePair(QString(), QString()));
425 
434  void infoMessage( KJob *job, const QString &plain, const QString &rich = QString() );
435 
443  void warning( KJob *job, const QString &plain, const QString &rich = QString() );
444 
445 
446 Q_SIGNALS:
447 #if !defined(Q_MOC_RUN) && !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(IN_IDE_PARSER)
448 private: // don't tell moc, doxygen or kdevelop, but those signals are in fact private
449 #endif
450 
462  void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount);
463 
476  void processedAmount(KJob *job, KJob::Unit unit, qulonglong amount);
477 
488  void totalSize(KJob *job, qulonglong size);
489 
500  void processedSize(KJob *job, qulonglong size);
501 
515  void percent( KJob *job, unsigned long percent );
516 
526  void speed(KJob *job, unsigned long speed);
527 
528 protected:
548  void setError( int errorCode );
549 
563  void setErrorText( const QString &errorText );
564 
565 
574  void setProcessedAmount(Unit unit, qulonglong amount);
575 
584  void setTotalAmount(Unit unit, qulonglong amount);
585 
592  void setPercent( unsigned long percentage );
593 
594 
605  void emitResult();
606 
616  void emitPercent( qulonglong processedAmount, qulonglong totalAmount );
617 
624  void emitSpeed(unsigned long speed);
625 
626 protected:
627  KJobPrivate *const d_ptr;
628  KJob(KJobPrivate &dd, QObject *parent);
629 
630 private:
631  Q_PRIVATE_SLOT(d_func(), void _k_speedTimeout())
632  Q_DECLARE_PRIVATE(KJob)
633 };
634 
635 Q_DECLARE_OPERATORS_FOR_FLAGS( KJob::Capabilities )
636 
637 #endif
KJob::KillVerbosity
KillVerbosity
Definition: kjob.h:168
kdecore_export.h
KJob::Quietly
Definition: kjob.h:168
KJob::Capability
Capability
Definition: kjob.h:93
setError
static void setError(QAbstractSocket *socket, QAbstractSocket::SocketError error, const QString &errorString)
Definition: ksocketfactory.cpp:44
QObject
QString
KJobUiDelegate
The base class for all KJob UI delegate.
Definition: kjobuidelegate.h:39
QPair
KJob::Unit
Unit
Definition: kjob.h:91
KShell::NoError
Success.
Definition: kshell.h:89
KJobPrivate
Definition: kjob_p.h:35
KJob::d_ptr
KJobPrivate *const d_ptr
Definition: kjob.h:627
KJob
The base class for all jobs.
Definition: kjob.h:84
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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

Search



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