kio Library API Documentation

uiserver.h

00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2000 Matej Koss <koss@miesto.sk>
00003                       David Faure <faure@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
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,     //lv_count
00076     TB_PROGRESS = 4,  // lv_progress
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   //hack, alexxx
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   // ids that uniquely identify this progress item
00168   QCString m_sAppId;
00169   int m_iJobId;
00170 
00171   // whether shown or not (it is hidden if a rename dialog pops up for the same job)
00172   bool m_visible;
00173   bool m_defaultProgressVisible;
00174 
00175   // parent listview
00176   ListProgress *listProgress;
00177 
00178   // associated default progress dialog
00179   KIO::DefaultProgress *defaultProgress;
00180 
00181   // we store these values for calculation of totals ( for statusbar )
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 /* KIO::RenameDlg_Mode */ mode,
00302                              KIO::filesize_t sizeSrc,
00303                              KIO::filesize_t sizeDest,
00304                              unsigned long /* time_t */ ctimeSrc,
00305                              unsigned long /* time_t */ ctimeDest,
00306                              unsigned long /* time_t */ mtimeSrc,
00307                              unsigned long /* time_t */ mtimeDest
00308                              );
00314   QByteArray open_RenameDlg( int id,
00315                              const QString & caption,
00316                              const QString& src, const QString & dest,
00317                              int /* KIO::RenameDlg_Mode */ mode,
00318                              unsigned long sizeSrc,
00319                              unsigned long sizeDest,
00320                              unsigned long /* time_t */ ctimeSrc,
00321                              unsigned long /* time_t */ ctimeDest,
00322                              unsigned long /* time_t */ mtimeSrc,
00323                              unsigned long /* time_t */ mtimeDest
00324                              );
00325 
00331   int open_SkipDlg( int id,
00332                     int /*bool*/ 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    * Show an SSL Certificate Selection Dialog
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   // true if there's a new job that hasn't been shown yet.
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 // -*- mode: c++; c-basic-offset: 2 -*-
00416 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Feb 4 12:35:10 2004 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2003