KDECore
kjobuidelegate.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "kjobuidelegate.h"
00023 #include "kjob.h"
00024
00025 class KJobUiDelegate::Private
00026 {
00027 public:
00028 Private(KJobUiDelegate *delegate)
00029 : q(delegate), job( 0 ),
00030 autoErrorHandling( false ),
00031 autoWarningHandling( true ) { }
00032
00033 KJobUiDelegate * const q;
00034
00035 KJob *job;
00036 bool autoErrorHandling : 1;
00037 bool autoWarningHandling : 1;
00038
00039 void connectJob(KJob *job);
00040 void _k_result(KJob *job);
00041 };
00042
00043 KJobUiDelegate::KJobUiDelegate()
00044 : QObject(), d(new Private(this))
00045 {
00046
00047 }
00048
00049 KJobUiDelegate::~KJobUiDelegate()
00050 {
00051 delete d;
00052 }
00053
00054 bool KJobUiDelegate::setJob( KJob *job )
00055 {
00056 if ( d->job!=0 )
00057 {
00058 return false;
00059 }
00060
00061 d->job = job;
00062 setParent( job );
00063
00064 return true;
00065 }
00066
00067 KJob *KJobUiDelegate::job()
00068 {
00069 return d->job;
00070 }
00071
00072 void KJobUiDelegate::showErrorMessage()
00073 {
00074 }
00075
00076 void KJobUiDelegate::setAutoErrorHandlingEnabled( bool enable)
00077 {
00078 d->autoErrorHandling = enable;
00079 }
00080
00081 bool KJobUiDelegate::isAutoErrorHandlingEnabled() const
00082 {
00083 return d->autoErrorHandling;
00084 }
00085
00086 void KJobUiDelegate::setAutoWarningHandlingEnabled( bool enable )
00087 {
00088 d->autoWarningHandling = enable;
00089 }
00090
00091 bool KJobUiDelegate::isAutoWarningHandlingEnabled() const
00092 {
00093 return d->autoWarningHandling;
00094 }
00095
00096 void KJobUiDelegate::slotWarning(KJob *job, const QString &plain,
00097 const QString &rich)
00098 {
00099 Q_UNUSED(job)
00100 Q_UNUSED(plain)
00101 Q_UNUSED(rich)
00102 }
00103
00104 void KJobUiDelegate::connectJob(KJob *job)
00105 {
00106 connect(job, SIGNAL(result(KJob*)),
00107 this, SLOT(_k_result(KJob*)));
00108
00109 connect(job, SIGNAL(warning(KJob*,QString,QString)),
00110 this, SLOT(slotWarning(KJob*,QString,QString)));
00111 }
00112
00113 void KJobUiDelegate::Private::_k_result(KJob *job2)
00114 {
00115 Q_UNUSED(job2)
00116 if ( job->error() && autoErrorHandling )
00117 q->showErrorMessage();
00118 }
00119
00120 #include "kjobuidelegate.moc"