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 
00094   ProgressItem* item() const { return mItem; }
00095 
00096   void addSubTransaction( ProgressItem *item);
00097 
00098   // The progressitem is deleted immediately, we take 5s to go out,
00099   // so better not use mItem during this time.
00100   void setItemComplete() { mItem = 0; }
00101 
00102 public slots:
00103   void slotItemCanceled();
00104 
00105 protected:
00106   QProgressBar* mProgress;
00107   QPushButton*  mCancelButton;
00108   QLabel*       mItemLabel;
00109   QLabel*       mItemStatus;
00110   QFrame*       mFrame;
00111   SSLLabel*     mSSLLabel;
00112   ProgressItem* mItem;
00113 };
00114 
00115 class KDE_EXPORT ProgressDialog : public OverlayWidget
00116 {
00117     Q_OBJECT
00118 
00119 public:
00120   ProgressDialog( QWidget* alignWidget, QWidget* parent, const char* name = 0 );
00121   ~ProgressDialog();
00122   void setVisible( bool b );
00123 
00124 public slots:
00125   void slotToggleVisibility();
00126 
00127 protected slots:
00128 void slotTransactionAdded( KPIM::ProgressItem *item );
00129   void slotTransactionCompleted( KPIM::ProgressItem *item );
00130   void slotTransactionCanceled( KPIM::ProgressItem *item );
00131   void slotTransactionProgress( KPIM::ProgressItem *item, unsigned int progress );
00132   void slotTransactionStatus( KPIM::ProgressItem *item, const QString& );
00133   void slotTransactionLabel( KPIM::ProgressItem *item, const QString& );
00134   void slotTransactionUsesCrypto( KPIM::ProgressItem *item, bool );
00135 
00136   void slotClose();
00137   void slotShow();
00138   void slotHide();
00139 
00140 signals:
00141   void visibilityChanged( bool );
00142 
00143 protected:
00144   virtual void closeEvent( QCloseEvent* );
00145 
00146   TransactionItemView* mScrollView;
00147   TransactionItem* mPreviousItem;
00148   QMap< const ProgressItem*, TransactionItem* > mTransactionsToListviewItems;
00149   bool mWasLastShown;
00150 };
00151 
00152 
00153 } // namespace KPIM
00154 
00155 #endif // __KPIM_PROGRESSDIALOG_H__
KDE Home | KDE Accessibility Home | Description of Access Keys