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älvdalens 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 TQt library by Trolltech AS, Norway (or with modified versions 00024 * of TQt that use the same license as TQt), 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 * TQt. 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 <tqdialog.h> 00037 #include <tqlistview.h> 00038 #include <tqlabel.h> 00039 #include <tqvbox.h> 00040 #include "overlaywidget.h" 00041 #include <tdepimmacros.h> 00042 00043 class TQProgressBar; 00044 class TQScrollView; 00045 class TQFrame; 00046 00047 namespace KPIM { 00048 class ProgressItem; 00049 class TransactionItemListView; 00050 class TransactionItem; 00051 class SSLLabel; 00052 00053 class TransactionItemView : public TQScrollView { 00054 Q_OBJECT 00055 00056 public: 00057 TransactionItemView( TQWidget * parent = 0, 00058 const char * name = 0, 00059 WFlags f = 0 ); 00060 00061 virtual ~TransactionItemView() 00062 {} 00063 TransactionItem* addTransactionItem( ProgressItem *item, bool first ); 00064 00065 00066 TQSize sizeHint() const; 00067 TQSize minimumSizeHint() const; 00068 public slots: 00069 void slotLayoutFirstItem(); 00070 00071 protected: 00072 virtual void resizeContents ( int w, int h ); 00073 00074 private: 00075 TQVBox * mBigBox; 00076 }; 00077 00078 class TransactionItem : public TQVBox { 00079 00080 Q_OBJECT 00081 00082 00083 public: 00084 TransactionItem( TQWidget * parent, 00085 ProgressItem* item, bool first ); 00086 00087 ~TransactionItem(); 00088 00089 void hideHLine(); 00090 00091 void setProgress( int progress ); 00092 void setLabel( const TQString& ); 00093 void setStatus( const TQString& ); 00094 void setCrypto( bool ); 00095 void setTotalSteps( int totalSteps ); 00096 00097 ProgressItem* item() const { return mItem; } 00098 00099 void addSubTransaction( ProgressItem *item); 00100 00101 // The progressitem is deleted immediately, we take 5s to go out, 00102 // so better not use mItem during this time. 00103 void setItemComplete() { mItem = 0; } 00104 00105 public slots: 00106 void slotItemCanceled(); 00107 00108 protected: 00109 TQProgressBar* mProgress; 00110 TQPushButton* mCancelButton; 00111 TQLabel* mItemLabel; 00112 TQLabel* mItemStatus; 00113 TQFrame* mFrame; 00114 SSLLabel* mSSLLabel; 00115 ProgressItem* mItem; 00116 }; 00117 00118 class KDE_EXPORT ProgressDialog : public OverlayWidget 00119 { 00120 Q_OBJECT 00121 00122 00123 public: 00124 ProgressDialog( TQWidget* alignWidget, TQWidget* parent, const char* name = 0 ); 00125 ~ProgressDialog(); 00126 void setVisible( bool b ); 00127 00128 public slots: 00129 void slotToggleVisibility(); 00130 00131 protected slots: 00132 void slotTransactionAdded( KPIM::ProgressItem *item ); 00133 void slotTransactionCompleted( KPIM::ProgressItem *item ); 00134 void slotTransactionCanceled( KPIM::ProgressItem *item ); 00135 void slotTransactionProgress( KPIM::ProgressItem *item, unsigned int progress ); 00136 void slotTransactionStatus( KPIM::ProgressItem *item, const TQString& ); 00137 void slotTransactionLabel( KPIM::ProgressItem *item, const TQString& ); 00138 void slotTransactionUsesCrypto( KPIM::ProgressItem *item, bool ); 00139 void slotTransactionUsesBusyIndicator( KPIM::ProgressItem*, bool ); 00140 00141 void slotClose(); 00142 void slotShow(); 00143 void slotHide(); 00144 00145 signals: 00146 void visibilityChanged( bool ); 00147 00148 protected: 00149 virtual void closeEvent( TQCloseEvent* ); 00150 00151 TransactionItemView* mScrollView; 00152 TransactionItem* mPreviousItem; 00153 TQMap< const ProgressItem*, TransactionItem* > mTransactionsToListviewItems; 00154 bool mWasLastShown; 00155 }; 00156 00157 00158 } // namespace KPIM 00159 00160 #endif // __KPIM_PROGRESSDIALOG_H__