libkdepim

progressdialog.h

00001 /* -*- c++ -*-
00002  * progressdialog.h
00003  *
00004  *  Copyright (c) 2004 Till Adam <adam@kde.org>
00005  *  based on imapprogressdialog.cpp ,which is
00006  *  Copyright (c) 2002-2003 Klar�vdalens Datakonsult AB
00007  *
00008  *  This program is free software; you can redistribute it and/or modify
00009  *  it under the terms of the GNU General Public License as published by
00010  *  the Free Software Foundation; version 2 of the License
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  *  In addition, as a special exception, the copyright holders give
00022  *  permission to link the code of this program with any edition of
00023  *  the Qt library by Trolltech AS, Norway (or with modified versions
00024  *  of Qt that use the same license as Qt), and distribute linked
00025  *  combinations including the two.  You must obey the GNU General
00026  *  Public License in all respects for all of the code used other than
00027  *  Qt.  If you modify this file, you may extend this exception to
00028  *  your version of the file, but you are not obligated to do so.  If
00029  *  you do not wish to do so, delete this exception statement from
00030  *  your version.
00031  */
00032 
00033 #ifndef __KPIM_PROGRESSDIALOG_H__
00034 #define __KPIM_PROGRESSDIALOG_H__
00035 
00036 #include <qdialog.h>
00037 #include <qlistview.h>
00038 #include <qlabel.h>
00039 #include <qvbox.h>
00040 #include "overlaywidget.h"
00041 #include <kdepimmacros.h>
00042 
00043 class QProgressBar;
00044 class QScrollView;
00045 class QFrame;
00046 
00047 namespace KPIM {
00048 class ProgressItem;
00049 class TransactionItemListView;
00050 class TransactionItem;
00051 class SSLLabel;
00052 
00053 class TransactionItemView : public QScrollView {
00054   Q_OBJECT
00055 public:
00056   TransactionItemView( QWidget * parent = 0,
00057                        const char * name = 0,
00058                        WFlags f = 0 );
00059 
00060   virtual ~TransactionItemView()
00061   {}
00062   TransactionItem* addTransactionItem( ProgressItem *item, bool first );
00063 
00064 
00065   QSize sizeHint() const;
00066   QSize minimumSizeHint() const;
00067 public slots:
00068   void slotLayoutFirstItem();
00069 
00070 protected:
00071   virtual void resizeContents ( int w, int h );
00072 
00073 private:
00074   QVBox *                  mBigBox;
00075 };
00076 
00077 class TransactionItem : public QVBox {
00078 
00079   Q_OBJECT
00080 
00081 public:
00082   TransactionItem( QWidget * parent,
00083                    ProgressItem* item, bool first );
00084 
00085   ~TransactionItem();
00086 
00087   void hideHLine();
00088 
00089   void setProgress( int progress );
00090   void setLabel( const QString& );
00091   void setStatus( const QString& );
00092   void setCrypto( bool );
00093   void setTotalSteps( int totalSteps );
00094 
00095   ProgressItem* item() const { return mItem; }
00096 
00097   void addSubTransaction( ProgressItem *item);
00098 
00099   // The progressitem is deleted immediately, we take 5s to go out,
00100   // so better not use mItem during this time.
00101   void setItemComplete() { mItem = 0; }
00102 
00103 public slots:
00104   void slotItemCanceled();
00105 
00106 protected:
00107   QProgressBar* mProgress;
00108   QPushButton*  mCancelButton;
00109   QLabel*       mItemLabel;
00110   QLabel*       mItemStatus;
00111   QFrame*       mFrame;
00112   SSLLabel*     mSSLLabel;
00113   ProgressItem* mItem;
00114 };
00115 
00116 class KDE_EXPORT ProgressDialog : public OverlayWidget
00117 {
00118     Q_OBJECT
00119 
00120 public:
00121   ProgressDialog( QWidget* alignWidget, QWidget* parent, const char* name = 0 );
00122   ~ProgressDialog();
00123   void setVisible( bool b );
00124 
00125 public slots:
00126   void slotToggleVisibility();
00127 
00128 protected slots:
00129 void slotTransactionAdded( KPIM::ProgressItem *item );
00130   void slotTransactionCompleted( KPIM::ProgressItem *item );
00131   void slotTransactionCanceled( KPIM::ProgressItem *item );
00132   void slotTransactionProgress( KPIM::ProgressItem *item, unsigned int progress );
00133   void slotTransactionStatus( KPIM::ProgressItem *item, const QString& );
00134   void slotTransactionLabel( KPIM::ProgressItem *item, const QString& );
00135   void slotTransactionUsesCrypto( KPIM::ProgressItem *item, bool );
00136   void slotTransactionUsesBusyIndicator( KPIM::ProgressItem*, bool );
00137 
00138   void slotClose();
00139   void slotShow();
00140   void slotHide();
00141 
00142 signals:
00143   void visibilityChanged( bool );
00144 
00145 protected:
00146   virtual void closeEvent( QCloseEvent* );
00147 
00148   TransactionItemView* mScrollView;
00149   TransactionItem* mPreviousItem;
00150   QMap< const ProgressItem*, TransactionItem* > mTransactionsToListviewItems;
00151   bool mWasLastShown;
00152 };
00153 
00154 
00155 } // namespace KPIM
00156 
00157 #endif // __KPIM_PROGRESSDIALOG_H__