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

KDECore

  • 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
29class KJobUiDelegate;
30
31class KJobPrivate;
84class KDECORE_EXPORT KJob : public QObject
85{
86 Q_OBJECT
87 Q_ENUMS( KillVerbosity Capability Unit )
88 Q_FLAGS( Capabilities )
89
90public:
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
170public Q_SLOTS:
184 bool kill( KillVerbosity verbosity = Quietly );
185
192 bool suspend();
193
199 bool resume();
200
201protected:
209 virtual bool doKill();
210
216 virtual bool doSuspend();
217
223 virtual bool doResume();
224
231 void setCapabilities( Capabilities capabilities );
232
233public:
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
349Q_SIGNALS:
350#if !defined(Q_MOC_RUN) && !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(IN_IDE_PARSER)
351private: // don't tell moc, doxygen or kdevelop, but those signals are in fact private
352#endif
370 void finished(KJob *job);
371
380 void suspended(KJob *job);
381
390 void resumed(KJob *job);
391
406 void result(KJob *job);
407
408Q_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
446Q_SIGNALS:
447#if !defined(Q_MOC_RUN) && !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(IN_IDE_PARSER)
448private: // don't tell moc, doxygen or kdevelop, but those signals are in fact private
449#endif
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
528protected:
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
626protected:
627 KJobPrivate *const d_ptr;
628 KJob(KJobPrivate &dd, QObject *parent);
629
630private:
631 Q_PRIVATE_SLOT(d_func(), void _k_speedTimeout())
632 Q_DECLARE_PRIVATE(KJob)
633};
634
635Q_DECLARE_OPERATORS_FOR_FLAGS( KJob::Capabilities )
636
637#endif
KJobPrivate
Definition: kjob_p.h:36
KJobUiDelegate
The base class for all KJob UI delegate.
Definition: kjobuidelegate.h:40
KJob
The base class for all jobs.
Definition: kjob.h:85
KJob::resumed
void resumed(KJob *job)
Emitted when the job is resumed.
KJob::Unit
Unit
Definition: kjob.h:91
KJob::Bytes
@ Bytes
Definition: kjob.h:91
KJob::start
virtual void start()=0
Starts the job asynchronously.
KJob::d_ptr
KJobPrivate *const d_ptr
Definition: kjob.h:627
KJob::KillVerbosity
KillVerbosity
Definition: kjob.h:168
KJob::processedSize
void processedSize(KJob *job, qulonglong size)
Regularly emitted to show the progress of this job (current data size in bytes for transfers,...
KJob::description
void description(KJob *job, const QString &title, const QPair< QString, QString > &field1=qMakePair(QString(), QString()), const QPair< QString, QString > &field2=qMakePair(QString(), QString()))
Emitted to display general description of this job.
KJob::result
void result(KJob *job)
Emitted when the job is finished (except when killed with KJob::Quietly).
KJob::finished
void finished(KJob *job)
Emitted when the job is finished, in any case.
KJob::percent
void percent(KJob *job, unsigned long percent)
Progress signal showing the overall progress of the job This is valid for any kind of job,...
KJob::warning
void warning(KJob *job, const QString &plain, const QString &rich=QString())
Emitted to display a warning about this job.
KJob::processedAmount
void processedAmount(KJob *job, KJob::Unit unit, qulonglong amount)
Regularly emitted to show the progress of this job by giving the current amount.
KJob::totalSize
void totalSize(KJob *job, qulonglong size)
Emitted when we know the size of this job (data size in bytes for transfers, number of entries for li...
KJob::suspended
void suspended(KJob *job)
Emitted when the job is suspended.
KJob::totalAmount
void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount)
Emitted when we know the amount the job will have to process.
KJob::Capability
Capability
Definition: kjob.h:93
KJob::speed
void speed(KJob *job, unsigned long speed)
Emitted to display information about the speed of this job.
KJob::infoMessage
void infoMessage(KJob *job, const QString &plain, const QString &rich=QString())
Emitted to display state information about this job.
QObject
QPair
QString
kdecore_export.h
setError
static void setError(QAbstractSocket *socket, QAbstractSocket::SocketError error, const QString &errorString)
Definition: ksocketfactory.cpp:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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.14.38 API Reference

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