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     bool keepOpen() const;
00119   void setVisible( bool visible );
00120   void setDefaultProgressVisible( bool visible );
00121   bool isVisible() const { return m_visible; }
00122 
00123   void setTotalSize( KIO::filesize_t bytes );
00124   void setTotalFiles( unsigned long files );
00125   void setTotalDirs( unsigned long dirs );
00126 
00127   void setProcessedSize( KIO::filesize_t size );
00128   void setProcessedFiles( unsigned long files );
00129   void setProcessedDirs( unsigned long dirs );
00130 
00131   void setPercent( unsigned long percent );
00132   void setSpeed( unsigned long bytes_per_second );
00133   void setInfoMessage( const QString & msg );
00134 
00135   void setCopying( const KURL& from, const KURL& to );
00136   void setMoving( const KURL& from, const KURL& to );
00137   void setDeleting( const KURL& url );
00138   void setTransferring( const KURL& url );
00139   void setCreatingDir( const KURL& dir );
00140   void setStating( const KURL& url );
00141   void setMounting( const QString & dev, const QString & point );
00142   void setUnmounting( const QString & point );
00143 
00144   void setCanResume( KIO::filesize_t offset );
00145 
00146   KIO::filesize_t totalSize() { return m_iTotalSize; }
00147   unsigned long totalFiles() { return m_iTotalFiles; }
00148   KIO::filesize_t processedSize() { return m_iProcessedSize; }
00149   unsigned long processedFiles() { return m_iProcessedFiles; }
00150   unsigned long speed() { return m_iSpeed; }
00151   QTime remainingTime() { return m_remainingTime; }
00152 
00153   const QString& fullLengthAddress() const {return m_fullLengthAddress;}
00154   void setText(ListProgress::ListProgressFields field, const QString& text);
00155 public slots:
00156   void slotShowDefaultProgress();
00157   void slotToggleDefaultProgress();
00158 
00159 protected slots:
00160   void slotCanceled();
00161 
00162 signals:
00163   void jobCanceled( ProgressItem* );
00164 
00165 protected:
00166   void updateVisibility();
00167 
00168   // ids that uniquely identify this progress item
00169   QCString m_sAppId;
00170   int m_iJobId;
00171 
00172   // whether shown or not (it is hidden if a rename dialog pops up for the same job)
00173   bool m_visible;
00174   bool m_defaultProgressVisible;
00175 
00176   // parent listview
00177   ListProgress *listProgress;
00178 
00179   // associated default progress dialog
00180   KIO::DefaultProgress *defaultProgress;
00181 
00182   // we store these values for calculation of totals ( for statusbar )
00183   KIO::filesize_t m_iTotalSize;
00184   unsigned long m_iTotalFiles;
00185   KIO::filesize_t m_iProcessedSize;
00186   unsigned long m_iProcessedFiles;
00187   unsigned long m_iSpeed;
00188   QTime m_remainingTime;
00189   QTimer m_showTimer;
00190   QString m_fullLengthAddress;
00191 };
00192 
00193 class QResizeEvent;
00194 class QHideEvent;
00195 class QShowEvent;
00196 class ProgressConfigDialog;
00197 class QPopupMenu;
00198 class UIServerSystemTray;
00199 
00215 class UIServer : public KMainWindow, public DCOPObject {
00216 
00217   K_DCOP
00218   Q_OBJECT
00219 
00220   UIServer();
00221   virtual ~UIServer();
00222 
00223 public:
00224    static UIServer* createInstance();
00225 
00226 k_dcop:
00227 
00237   int newJob( QCString appId, bool showProgress );
00238 
00239   ASYNC jobFinished( int id );
00240 
00241   ASYNC totalSize( int id, unsigned long size );
00242   ASYNC totalSize64( int id, KIO::filesize_t size );
00243   ASYNC totalFiles( int id, unsigned long files );
00244   ASYNC totalDirs( int id, unsigned long dirs );
00245 
00246   ASYNC processedSize( int id, unsigned long bytes );
00247   ASYNC processedSize64( int id, KIO::filesize_t bytes );
00248   ASYNC processedFiles( int id, unsigned long files );
00249   ASYNC processedDirs( int id, unsigned long dirs );
00250 
00251   ASYNC percent( int id, unsigned long ipercent );
00252   ASYNC speed( int id, unsigned long bytes_per_second );
00253   ASYNC infoMessage( int id, const QString & msg );
00254 
00255   ASYNC copying( int id, KURL from, KURL to );
00256   ASYNC moving( int id, KURL from, KURL to );
00257   ASYNC deleting( int id, KURL url );
00258   ASYNC transferring( int id, KURL url );
00259   ASYNC creatingDir( int id, KURL dir );
00260   ASYNC stating( int id, KURL url );
00261 
00262   ASYNC mounting( int id, QString dev, QString point );
00263   ASYNC unmounting( int id, QString point );
00264 
00265   ASYNC canResume( int id, unsigned long offset );
00266   ASYNC canResume64( int id, KIO::filesize_t offset );
00267 
00273   QByteArray openPassDlg( const KIO::AuthInfo &info );
00274 
00291   int messageBox( int id, int type, const QString &text, const QString &caption,
00292                   const QString &buttonYes, const QString &buttonNo );
00293 
00299   QByteArray open_RenameDlg64( int id,
00300                              const QString & caption,
00301                              const QString& src, const QString & dest,
00302                              int /* KIO::RenameDlg_Mode */ mode,
00303                              KIO::filesize_t sizeSrc,
00304                              KIO::filesize_t sizeDest,
00305                              unsigned long /* time_t */ ctimeSrc,
00306                              unsigned long /* time_t */ ctimeDest,
00307                              unsigned long /* time_t */ mtimeSrc,
00308                              unsigned long /* time_t */ mtimeDest
00309                              );
00315   QByteArray open_RenameDlg( int id,
00316                              const QString & caption,
00317                              const QString& src, const QString & dest,
00318                              int /* KIO::RenameDlg_Mode */ mode,
00319                              unsigned long sizeSrc,
00320                              unsigned long sizeDest,
00321                              unsigned long /* time_t */ ctimeSrc,
00322                              unsigned long /* time_t */ ctimeDest,
00323                              unsigned long /* time_t */ mtimeSrc,
00324                              unsigned long /* time_t */ mtimeDest
00325                              );
00326 
00332   int open_SkipDlg( int id,
00333                     int /*bool*/ multi,
00334                     const QString & error_text );
00335 
00339   void setListMode( bool list );
00340 
00345   void setJobVisible( int id, bool visible );
00346 
00350   void showSSLInfoDialog(const QString &url, const KIO::MetaData &data);
00351 
00352   /*
00353    * Show an SSL Certificate Selection Dialog
00354    */
00355   KSSLCertDlgRet showSSLCertDialog(const QString& host, const QStringList& certList);
00356 
00357 public slots:
00358   void slotConfigure();
00359   void slotRemoveSystemTrayIcon();
00360 protected slots:
00361 
00362   void slotUpdate();
00363   void slotQuit();
00364 
00365   void slotCancelCurrent();
00366 
00367   void slotToggleDefaultProgress( QListViewItem * );
00368   void slotSelection();
00369 
00370   void slotJobCanceled( ProgressItem * );
00371   void slotApplyConfig();
00372   void slotShowContextMenu(KListView*, QListViewItem *item, const QPoint& pos);
00373 
00374 protected:
00375 
00376   ProgressItem* findItem( int id );
00377 
00378   virtual void resizeEvent(QResizeEvent* e);
00379   virtual bool queryClose();
00380 
00381   void setItemVisible( ProgressItem * item, bool visible );
00382 
00383   QTimer* updateTimer;
00384   ListProgress* listProgress;
00385 
00386   KToolBar::BarPosition toolbarPos;
00387   QString properties;
00388 
00389   void applySettings();
00390   void readSettings();
00391   void writeSettings();
00392 private:
00393 
00394   void killJob( QCString observerAppId, int progressId );
00395 
00396   int m_initWidth;
00397   int m_initHeight;
00398   int m_idCancelItem;
00399   bool m_bShowList;
00400   bool m_showStatusBar;
00401   bool m_showToolBar;
00402   bool m_keepListOpen;
00403   bool m_showSystemTray;
00404   bool m_shuttingDown;
00405 
00406   // true if there's a new job that hasn't been shown yet.
00407   bool m_bUpdateNewJob;
00408   ProgressConfigDialog *m_configDialog;
00409   QPopupMenu* m_contextMenu;
00410   UIServerSystemTray *m_systemTray;
00411 
00412   static int s_jobId;
00413   friend class no_bogus_warning_from_gcc;
00414 };
00415 
00416 // -*- mode: c++; c-basic-offset: 2 -*-
00417 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 3 19:23:45 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003