# kio Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# progressbase.cpp

    00001 /* This file is part of the KDE libraries
    00002    Copyright (C) 2000 Matej Koss <koss@miesto.sk>
    00003
    00004    This library is free software; you can redistribute it and/or
    00005    modify it under the terms of the GNU Library General Public
    00006    License version 2 as published by the Free Software Foundation.
    00007
    00008    This library is distributed in the hope that it will be useful,
    00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00011    Library General Public License for more details.
    00012
    00013    You should have received a copy of the GNU Library General Public License
    00014    along with this library; see the file COPYING.LIB.  If not, write to
    00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00016    Boston, MA 02111-1307, USA.
    00017 */
    00018
    00019 #include "jobclasses.h"
    00020 #include "progressbase.h"
    00021
    00022 namespace KIO {
    00023
    00024 ProgressBase::ProgressBase( QWidget *parent )
    00025   : QWidget( parent )
    00026 {
    00027   m_pJob = 0;
    00028
    00029   // delete dialog after the job is finished / canceled
    00030   m_bOnlyClean = false;
    00031
    00032   // stop job on close
    00033   m_bStopOnClose = true;
    00034 }
    00035
    00036
    00037 void ProgressBase::setJob( KIO::Job *job )
    00038 {
    00039   // first connect all slots
    00040   connect( job, SIGNAL( percent( KIO::Job*, unsigned long ) ),
    00041        SLOT( slotPercent( KIO::Job*, unsigned long ) ) );
    00042
    00043   connect( job, SIGNAL( result( KIO::Job* ) ),
    00044        SLOT( slotFinished( KIO::Job* ) ) );
    00045
    00046   connect( job, SIGNAL( canceled( KIO::Job* ) ),
    00047        SLOT( slotFinished( KIO::Job* ) ) );
    00048
    00049   // then assign job
    00050   m_pJob = job;
    00051 }
    00052
    00053
    00054 void ProgressBase::setJob( KIO::CopyJob *job )
    00055 {
    00056   // first connect all slots
    00057   connect( job, SIGNAL( totalSize( KIO::Job*, KIO::filesize_t ) ),
    00058        SLOT( slotTotalSize( KIO::Job*, KIO::filesize_t ) ) );
    00059   connect( job, SIGNAL( totalFiles( KIO::Job*, unsigned long ) ),
    00060        SLOT( slotTotalFiles( KIO::Job*, unsigned long ) ) );
    00061   connect( job, SIGNAL( totalDirs( KIO::Job*, unsigned long ) ),
    00062        SLOT( slotTotalDirs( KIO::Job*, unsigned long ) ) );
    00063
    00064   connect( job, SIGNAL( processedSize( KIO::Job*, KIO::filesize_t ) ),
    00065        SLOT( slotProcessedSize( KIO::Job*, KIO::filesize_t ) ) );
    00066   connect( job, SIGNAL( processedFiles( KIO::Job*, unsigned long ) ),
    00067        SLOT( slotProcessedFiles( KIO::Job*, unsigned long ) ) );
    00068   connect( job, SIGNAL( processedDirs( KIO::Job*, unsigned long ) ),
    00069        SLOT( slotProcessedDirs( KIO::Job*, unsigned long ) ) );
    00070
    00071   connect( job, SIGNAL( speed( KIO::Job*, unsigned long ) ),
    00072        SLOT( slotSpeed( KIO::Job*, unsigned long ) ) );
    00073   connect( job, SIGNAL( percent( KIO::Job*, unsigned long ) ),
    00074        SLOT( slotPercent( KIO::Job*, unsigned long ) ) );
    00075
    00076   connect( job, SIGNAL( copying( KIO::Job*, const KURL& , const KURL& ) ),
    00077        SLOT( slotCopying( KIO::Job*, const KURL&, const KURL& ) ) );
    00078   connect( job, SIGNAL( moving( KIO::Job*, const KURL& , const KURL& ) ),
    00079        SLOT( slotMoving( KIO::Job*, const KURL&, const KURL& ) ) );
    00080   connect( job, SIGNAL( creatingDir( KIO::Job*, const KURL& ) ),
    00081        SLOT( slotCreatingDir( KIO::Job*, const KURL& ) ) );
    00082
    00083   connect( job, SIGNAL( result( KIO::Job* ) ),
    00084        SLOT( slotFinished( KIO::Job* ) ) );
    00085
    00086   connect( job, SIGNAL( canceled( KIO::Job* ) ),
    00087        SLOT( slotFinished( KIO::Job* ) ) );
    00088
    00089   // then assign job
    00090   m_pJob = job;
    00091 }
    00092
    00093
    00094 void ProgressBase::setJob( KIO::DeleteJob *job )
    00095 {
    00096   // first connect all slots
    00097   connect( job, SIGNAL( totalSize( KIO::Job*, KIO::filesize_t ) ),
    00098        SLOT( slotTotalSize( KIO::Job*, KIO::filesize_t ) ) );
    00099   connect( job, SIGNAL( totalFiles( KIO::Job*, unsigned long ) ),
    00100        SLOT( slotTotalFiles( KIO::Job*, unsigned long ) ) );
    00101   connect( job, SIGNAL( totalDirs( KIO::Job*, unsigned long ) ),
    00102        SLOT( slotTotalDirs( KIO::Job*, unsigned long ) ) );
    00103
    00104   connect( job, SIGNAL( processedSize( KIO::Job*, KIO::filesize_t ) ),
    00105        SLOT( slotProcessedSize( KIO::Job*, KIO::filesize_t ) ) );
    00106   connect( job, SIGNAL( processedFiles( KIO::Job*, unsigned long ) ),
    00107        SLOT( slotProcessedFiles( KIO::Job*, unsigned long ) ) );
    00108   connect( job, SIGNAL( processedDirs( KIO::Job*, unsigned long ) ),
    00109        SLOT( slotProcessedDirs( KIO::Job*, unsigned long ) ) );
    00110
    00111   connect( job, SIGNAL( speed( KIO::Job*, unsigned long ) ),
    00112        SLOT( slotSpeed( KIO::Job*, unsigned long ) ) );
    00113   connect( job, SIGNAL( percent( KIO::Job*, unsigned long ) ),
    00114        SLOT( slotPercent( KIO::Job*, unsigned long ) ) );
    00115
    00116   connect( job, SIGNAL( deleting( KIO::Job*, const KURL& ) ),
    00117        SLOT( slotDeleting( KIO::Job*, const KURL& ) ) );
    00118
    00119   connect( job, SIGNAL( result( KIO::Job* ) ),
    00120        SLOT( slotFinished( KIO::Job* ) ) );
    00121
    00122   connect( job, SIGNAL( canceled( KIO::Job* ) ),
    00123        SLOT( slotFinished( KIO::Job* ) ) );
    00124
    00125   // then assign job
    00126   m_pJob = job;
    00127 }
    00128
    00129
    00130 void ProgressBase::closeEvent( QCloseEvent* ) {
    00131   // kill job when desired
    00132   if ( m_bStopOnClose ) {
    00133     slotStop();
    00134   } else {
    00135     // clean or delete dialog
    00136     if ( m_bOnlyClean ) {
    00137       slotClean();
    00138     } else {
    00139       delete this;
    00140     }
    00141   }
    00142 }
    00143
    00144 void ProgressBase::finished() {
    00145   // clean or delete dialog
    00146   if ( m_bOnlyClean ) {
    00147     slotClean();
    00148   } else {
    00149     deleteLater();
    00150   }
    00151 }
    00152
    00153 void ProgressBase::slotFinished( KIO::Job* ) {
    00154   finished();
    00155 }
    00156
    00157
    00158 void ProgressBase::slotStop() {
    00159   if ( m_pJob ) {
    00160     m_pJob->kill(); // this will call slotFinished
    00161     m_pJob = 0L;
    00162   } else {
    00163     slotFinished( 0 ); // here we call it ourselves
    00164   }
    00165
    00166   emit stopped();
    00167 }
    00168
    00169
    00170 void ProgressBase::slotClean() {
    00171   hide();
    00172 }
    00173
    00174 void ProgressBase::virtual_hook( int, void* )
    00175 { /*BASE::virtual_hook( id, data );*/ }
    00176
    00177 } /* namespace */
    00178
    00179 #include "progressbase.moc"
    00180

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:24:06 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003