home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bthreadjob.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  2.1 KB  |  90 lines

  1. /*
  2.  *
  3.  * $Id: k3bthreadjob.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef _K3B_THREAD_JOB_H_
  18. #define _K3B_THREAD_JOB_H_
  19.  
  20. #include "k3bjob.h"
  21. #include "k3b_export.h"
  22. class QCustomEvent;
  23. class K3bThread;
  24.  
  25.  
  26. /**
  27.  * A Wrapper to use a K3bThread just like a K3bJob.
  28.  * Usage:
  29.  * <pre>
  30.  *   K3bThread* thread = new MySuperThread(...);
  31.  *   K3bThreadJob* job = new K3bThreadJob( thread, ... );
  32.  *   K3bBurnProgressDialog d;
  33.  *   d.setJob(job);
  34.  *   job->start();
  35.  *   d.exec();
  36.  *   delete job;
  37.  * </pre>
  38.  * Be aware that K3bThreadJob'd destructor does NOT delete the thread.
  39.  */
  40. class LIBK3B_EXPORT K3bThreadJob : public K3bJob
  41. {
  42.   Q_OBJECT
  43.  
  44.  public:
  45.   K3bThreadJob( K3bJobHandler*, QObject* parent = 0, const char* name = 0 );
  46.   K3bThreadJob( K3bThread*, K3bJobHandler*, QObject* parent = 0, const char* name = 0 );
  47.   virtual ~K3bThreadJob();
  48.  
  49.   void setThread( K3bThread* t );
  50.   K3bThread* thread() const { return m_thread; }
  51.  
  52.   /**
  53.    * \reimplemented from K3bJob
  54.    *
  55.    * \return true if the job has been started and has not yet
  56.    * emitted the finished signal
  57.    */
  58.   virtual bool active() const { return m_running; }
  59.  
  60.   virtual QString jobDescription() const;
  61.   virtual QString jobDetails() const;
  62.  
  63.  public slots:
  64.   virtual void start();
  65.   virtual void cancel();
  66.  
  67.  protected:
  68.   /**
  69.    * converts K3bThread events to K3bJob signals
  70.    */
  71.   virtual void customEvent( QCustomEvent* );
  72.  
  73.   /**
  74.    * Reimplement this method to do some housekeeping once
  75.    * the thread has finished.
  76.    *
  77.    * The default implementation does nothing.
  78.    *
  79.    * \param success True if the thread finished successfully
  80.    */
  81.   virtual void cleanupJob( bool success );
  82.  
  83.  private:
  84.   K3bThread* m_thread;
  85.   bool m_running;
  86. };
  87.  
  88. #endif
  89.  
  90.