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 / kio / statusbarprogress.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  2.9 KB  |  113 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (C) 2000 Matej Koss <koss@miesto.sk>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License version 2 as published by the Free Software Foundation.
  7.  
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU Library General Public License
  14.    along with this library; see the file COPYING.LIB.  If not, write to
  15.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.    Boston, MA 02110-1301, USA.
  17. */
  18.  
  19. #ifndef __statusbarprogress_h__
  20. #define __statusbarprogress_h__
  21.  
  22. #include "progressbase.h"
  23.  
  24. class QWidgetStack;
  25. class QBoxLayout;
  26. class QPushButton;
  27. class QLabel;
  28. class KProgress;
  29.  
  30. namespace KIO {
  31.  
  32. class Job;
  33.  
  34. /**
  35. * This is a special IO progress widget.
  36. *
  37. * Similarly to DefaultProgress,
  38. * it's purpose is to show a progress of the IO operation.
  39. *
  40. * Instead of creating a separate window, this is only a widget that can be
  41. * easily embedded in a statusbar.
  42. *
  43. * Usage of StatusbarProgress is little different.
  44. * This dialog will be a part of some application.
  45. * \code
  46. * // create a dialog
  47. * StatusbarProgress *statusProgress;
  48. * statusProgress = new StatusbarProgress( statusBar() );
  49. * statusBar()->insertWidget( statusProgress, statusProgress->width() , 0 );
  50. * ...
  51. * // create job and connect it to the progress
  52. * CopyJob* job = KIO::copy(...);
  53. * statusProgress->setJob( job );
  54. * ...
  55. * \endcode
  56. *
  57. * @short IO progress widget for embedding in a statusbar.
  58. * @author Matej Koss <koss@miesto.sk>
  59. */
  60. class KIO_EXPORT StatusbarProgress : public ProgressBase {
  61.  
  62.   Q_OBJECT
  63.  
  64. public:
  65.  
  66.   /**
  67.    * Creates a new StatusbarProgress.
  68.    * @param parent the parent of this widget
  69.    * @param button true to add an abort button. The button will be
  70.    *               connected to ProgressBase::slotStop()
  71.    */
  72.   StatusbarProgress( QWidget* parent, bool button = true );
  73.   ~StatusbarProgress() {}
  74.  
  75.   /**
  76.    * Sets the job to monitor.
  77.    * @param job the job to monitor
  78.    */
  79.   void setJob( KIO::Job *job );
  80.  
  81. public slots:
  82.   virtual void slotClean();
  83.   virtual void slotTotalSize( KIO::Job* job, KIO::filesize_t size );
  84.   virtual void slotPercent( KIO::Job* job, unsigned long percent );
  85.   virtual void slotSpeed( KIO::Job* job, unsigned long speed );
  86.  
  87. protected:
  88.   KProgress* m_pProgressBar;
  89.   QLabel* m_pLabel;
  90.   QPushButton* m_pButton;
  91.  
  92.   KIO::filesize_t m_iTotalSize;
  93.  
  94.   enum Mode { None, Label, Progress };
  95.  
  96.   uint mode;
  97.   bool m_bShowButton;
  98.  
  99.   void setMode();
  100.  
  101.   virtual bool eventFilter( QObject *, QEvent * );
  102.   QBoxLayout *box;
  103.   QWidgetStack *stack;
  104. protected:
  105.   virtual void virtual_hook( int id, void* data );
  106. private:
  107.   class StatusbarProgressPrivate* d;
  108. };
  109.  
  110. } /* namespace */
  111.  
  112. #endif  //  __statusbarprogress_h__
  113.