00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __kio_uiserver_h__
00020 #define __kio_uiserver_h__
00021
00022 #include <qintdict.h>
00023 #include <qdatetime.h>
00024 #include <qtimer.h>
00025
00026 #include <dcopobject.h>
00027 #include <kio/global.h>
00028 #include <kio/authinfo.h>
00029 #include <kurl.h>
00030 #include <kmainwindow.h>
00031 #include <kdatastream.h>
00032 #include <klistview.h>
00033 #include <ksslcertdlg.h>
00034
00035 class ListProgress;
00036 class KSqueezedTextLabel;
00037 class ProgressItem;
00038 class UIServer;
00039
00040 namespace KIO {
00041 class Job;
00042 class DefaultProgress;
00043 }
00044
00045
00046 struct ListProgressColumnConfig
00047 {
00048 QString title;
00049 int index;
00050 int width;
00051 bool enabled;
00052 };
00053
00058 class ListProgress : public KListView {
00059
00060 Q_OBJECT
00061
00062 public:
00063
00064 ListProgress (QWidget *parent = 0, const char *name = 0 );
00065
00066 virtual ~ListProgress();
00067
00071 enum ListProgressFields {
00072 TB_OPERATION = 0,
00073 TB_LOCAL_FILENAME = 1,
00074 TB_RESUME = 2,
00075 TB_COUNT = 3,
00076 TB_PROGRESS = 4,
00077 TB_TOTAL = 5,
00078 TB_SPEED = 6,
00079 TB_REMAINING_TIME = 7,
00080 TB_ADDRESS = 8,
00081 TB_MAX = 9
00082 };
00083
00084 friend class ProgressItem;
00085 friend class UIServer;
00086 protected slots:
00087 void columnWidthChanged(int column);
00088 protected:
00089
00090 void writeSettings();
00091 void readSettings();
00092 void applySettings();
00093 void createColumns();
00094
00095 bool m_showHeader;
00096 bool m_fixedColumnWidths;
00097 ListProgressColumnConfig m_lpcc[TB_MAX];
00098
00099 KSqueezedTextLabel *m_squeezer;
00100 };
00101
00106 class ProgressItem : public QObject, public QListViewItem {
00107
00108 Q_OBJECT
00109
00110 public:
00111 ProgressItem( ListProgress* view, QListViewItem *after, QCString app_id, int job_id,
00112 bool showDefault = true );
00113 ~ProgressItem();
00114
00115 QCString appId() { return m_sAppId; }
00116 int jobId() { return m_iJobId; }
00117
00118 void setVisible( bool visible );
00119 void setDefaultProgressVisible( bool visible );
00120 bool isVisible() const { return m_visible; }
00121
00122 void setTotalSize( KIO::filesize_t bytes );
00123 void setTotalFiles( unsigned long files );
00124 void setTotalDirs( unsigned long dirs );
00125
00126 void setProcessedSize( KIO::filesize_t size );
00127 void setProcessedFiles( unsigned long files );
00128 void setProcessedDirs( unsigned long dirs );
00129
00130 void setPercent( unsigned long percent );
00131 void setSpeed( unsigned long bytes_per_second );
00132 void setInfoMessage( const QString & msg );
00133
00134 void setCopying( const KURL& from, const KURL& to );
00135 void setMoving( const KURL& from, const KURL& to );
00136 void setDeleting( const KURL& url );
00137 void setTransferring( const KURL& url );
00138 void setCreatingDir( const KURL& dir );
00139 void setStating( const KURL& url );
00140 void setMounting( const QString & dev, const QString & point );
00141 void setUnmounting( const QString & point );
00142
00143 void setCanResume( KIO::filesize_t offset );
00144
00145 KIO::filesize_t totalSize() { return m_iTotalSize; }
00146 unsigned long totalFiles() { return m_iTotalFiles; }
00147 KIO::filesize_t processedSize() { return m_iProcessedSize; }
00148 unsigned long processedFiles() { return m_iProcessedFiles; }
00149 unsigned long speed() { return m_iSpeed; }
00150 QTime remainingTime() { return m_remainingTime; }
00151
00152 const QString& fullLengthAddress() const {return m_fullLengthAddress;}
00153 void setText(ListProgress::ListProgressFields field, const QString& text);
00154 public slots:
00155 void slotShowDefaultProgress();
00156 void slotToggleDefaultProgress();
00157
00158 protected slots:
00159 void slotCanceled();
00160
00161 signals:
00162 void jobCanceled( ProgressItem* );
00163
00164 protected:
00165 void updateVisibility();
00166
00167
00168 QCString m_sAppId;
00169 int m_iJobId;
00170
00171
00172 bool m_visible;
00173 bool m_defaultProgressVisible;
00174
00175
00176 ListProgress *listProgress;
00177
00178
00179 KIO::DefaultProgress *defaultProgress;
00180
00181
00182 KIO::filesize_t m_iTotalSize;
00183 unsigned long m_iTotalFiles;
00184 KIO::filesize_t m_iProcessedSize;
00185 unsigned long m_iProcessedFiles;
00186 unsigned long m_iSpeed;
00187 QTime m_remainingTime;
00188 QTimer m_showTimer;
00189 QString m_fullLengthAddress;
00190 };
00191
00192 class QResizeEvent;
00193 class QHideEvent;
00194 class QShowEvent;
00195 class ProgressConfigDialog;
00196 class QPopupMenu;
00197 class UIServerSystemTray;
00198
00214 class UIServer : public KMainWindow, public DCOPObject {
00215
00216 K_DCOP
00217 Q_OBJECT
00218
00219 UIServer();
00220 virtual ~UIServer();
00221
00222 public:
00223 static UIServer* createInstance();
00224
00225 k_dcop:
00226
00236 int newJob( QCString appId, bool showProgress );
00237
00238 ASYNC jobFinished( int id );
00239
00240 ASYNC totalSize( int id, unsigned long size );
00241 ASYNC totalSize64( int id, KIO::filesize_t size );
00242 ASYNC totalFiles( int id, unsigned long files );
00243 ASYNC totalDirs( int id, unsigned long dirs );
00244
00245 ASYNC processedSize( int id, unsigned long bytes );
00246 ASYNC processedSize64( int id, KIO::filesize_t bytes );
00247 ASYNC processedFiles( int id, unsigned long files );
00248 ASYNC processedDirs( int id, unsigned long dirs );
00249
00250 ASYNC percent( int id, unsigned long ipercent );
00251 ASYNC speed( int id, unsigned long bytes_per_second );
00252 ASYNC infoMessage( int id, const QString & msg );
00253
00254 ASYNC copying( int id, KURL from, KURL to );
00255 ASYNC moving( int id, KURL from, KURL to );
00256 ASYNC deleting( int id, KURL url );
00257 ASYNC transferring( int id, KURL url );
00258 ASYNC creatingDir( int id, KURL dir );
00259 ASYNC stating( int id, KURL url );
00260
00261 ASYNC mounting( int id, QString dev, QString point );
00262 ASYNC unmounting( int id, QString point );
00263
00264 ASYNC canResume( int id, unsigned long offset );
00265 ASYNC canResume64( int id, KIO::filesize_t offset );
00266
00272 QByteArray openPassDlg( const KIO::AuthInfo &info );
00273
00290 int messageBox( int id, int type, const QString &text, const QString &caption,
00291 const QString &buttonYes, const QString &buttonNo );
00292
00298 QByteArray open_RenameDlg64( int id,
00299 const QString & caption,
00300 const QString& src, const QString & dest,
00301 int mode,
00302 KIO::filesize_t sizeSrc,
00303 KIO::filesize_t sizeDest,
00304 unsigned long ctimeSrc,
00305 unsigned long ctimeDest,
00306 unsigned long mtimeSrc,
00307 unsigned long mtimeDest
00308 );
00314 QByteArray open_RenameDlg( int id,
00315 const QString & caption,
00316 const QString& src, const QString & dest,
00317 int mode,
00318 unsigned long sizeSrc,
00319 unsigned long sizeDest,
00320 unsigned long ctimeSrc,
00321 unsigned long ctimeDest,
00322 unsigned long mtimeSrc,
00323 unsigned long mtimeDest
00324 );
00325
00331 int open_SkipDlg( int id,
00332 int multi,
00333 const QString & error_text );
00334
00338 void setListMode( bool list );
00339
00344 void setJobVisible( int id, bool visible );
00345
00349 void showSSLInfoDialog(const QString &url, const KIO::MetaData &data);
00350
00351
00352
00353
00354 KSSLCertDlgRet showSSLCertDialog(const QString& host, const QStringList& certList);
00355
00356 public slots:
00357 void slotConfigure();
00358 void slotRemoveSystemTrayIcon();
00359 protected slots:
00360
00361 void slotUpdate();
00362 void slotQuit();
00363
00364 void slotCancelCurrent();
00365
00366 void slotToggleDefaultProgress( QListViewItem * );
00367 void slotSelection();
00368
00369 void slotJobCanceled( ProgressItem * );
00370 void slotApplyConfig();
00371 void slotShowContextMenu(KListView*, QListViewItem *item, const QPoint& pos);
00372
00373 protected:
00374
00375 ProgressItem* findItem( int id );
00376
00377 virtual void resizeEvent(QResizeEvent* e);
00378 virtual bool queryClose();
00379
00380 void setItemVisible( ProgressItem * item, bool visible );
00381
00382 QTimer* updateTimer;
00383 ListProgress* listProgress;
00384
00385 KToolBar::BarPosition toolbarPos;
00386 QString properties;
00387
00388 void applySettings();
00389 void readSettings();
00390 void writeSettings();
00391 private:
00392
00393 void killJob( QCString observerAppId, int progressId );
00394
00395 int m_initWidth;
00396 int m_initHeight;
00397 int m_idCancelItem;
00398 bool m_bShowList;
00399 bool m_showStatusBar;
00400 bool m_showToolBar;
00401 bool m_keepListOpen;
00402 bool m_showSystemTray;
00403 bool m_shuttingDown;
00404
00405
00406 bool m_bUpdateNewJob;
00407 ProgressConfigDialog *m_configDialog;
00408 QPopupMenu* m_contextMenu;
00409 UIServerSystemTray *m_systemTray;
00410
00411 static int s_jobId;
00412 friend class no_bogus_warning_from_gcc;
00413 };
00414
00415
00416 #endif