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 00371 void finished(KJob *job); 00372 00381 void suspended(KJob *job); 00382 00391 void resumed(KJob *job); 00392 00407 void result(KJob *job); 00408 00409 Q_SIGNALS: 00423 void description(KJob *job, const QString &title, 00424 const QPair<QString, QString> &field1 = qMakePair(QString(), QString()), 00425 const QPair<QString, QString> &field2 = qMakePair(QString(), QString())); 00426 00435 void infoMessage( KJob *job, const QString &plain, const QString &rich = QString() ); 00436 00444 void warning( KJob *job, const QString &plain, const QString &rich = QString() ); 00445 00446 00447 Q_SIGNALS: 00448 #if !defined(Q_MOC_RUN) && !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(IN_IDE_PARSER) 00449 private: // don't tell moc, doxygen or kdevelop, but those signals are in fact private 00450 #endif 00451 00463 void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount); 00464 00477 void processedAmount(KJob *job, KJob::Unit unit, qulonglong amount); 00478 00489 void totalSize(KJob *job, qulonglong size); 00490 00501 void processedSize(KJob *job, qulonglong size); 00502 00516 void percent( KJob *job, unsigned long percent ); 00517 00527 void speed(KJob *job, unsigned long speed); 00528 00529 protected: 00549 void setError( int errorCode ); 00550 00564 void setErrorText( const QString &errorText ); 00565 00566 00575 void setProcessedAmount(Unit unit, qulonglong amount); 00576 00585 void setTotalAmount(Unit unit, qulonglong amount); 00586 00593 void setPercent( unsigned long percentage ); 00594 00595 00606 void emitResult(); 00607 00617 void emitPercent( qulonglong processedAmount, qulonglong totalAmount ); 00618 00625 void emitSpeed(unsigned long speed); 00626 00627 protected: 00628 KJobPrivate *const d_ptr; 00629 KJob(KJobPrivate &dd, QObject *parent); 00630 00631 private: 00632 Q_PRIVATE_SLOT(d_func(), void _k_speedTimeout()) 00633 Q_DECLARE_PRIVATE(KJob) 00634 }; 00635 00636 Q_DECLARE_OPERATORS_FOR_FLAGS( KJob::Capabilities ) 00637 00638 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Wed May 2 2012 17:05:02 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Wed May 2 2012 17:05:02 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.