progressbase.cpp
/* This file is part of the KDE libraries
Copyright (C) 2000 Matej Koss <koss@miesto.sk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "jobclasses.h"
#include "progressbase.h"
namespace KIO {
ProgressBase::ProgressBase( QWidget *parent )
: QWidget( parent )
{
m_pJob = 0;
// delete dialog after the job is finished / canceled
m_bOnlyClean = false;
// stop job on close
m_bStopOnClose = true;
}
void ProgressBase::setJob( KIO::Job *job )
{
// first connect all slots
connect( job, SIGNAL( percent( KIO::Job*, unsigned long ) ),
SLOT( slotPercent( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( result( KIO::Job* ) ),
SLOT( slotFinished( KIO::Job* ) ) );
connect( job, SIGNAL( canceled( KIO::Job* ) ),
SLOT( slotFinished( KIO::Job* ) ) );
// then assign job
m_pJob = job;
}
void ProgressBase::setJob( KIO::CopyJob *job )
{
// first connect all slots
connect( job, SIGNAL( totalSize( KIO::Job*, KIO::filesize_t ) ),
SLOT( slotTotalSize( KIO::Job*, KIO::filesize_t ) ) );
connect( job, SIGNAL( totalFiles( KIO::Job*, unsigned long ) ),
SLOT( slotTotalFiles( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( totalDirs( KIO::Job*, unsigned long ) ),
SLOT( slotTotalDirs( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( processedSize( KIO::Job*, KIO::filesize_t ) ),
SLOT( slotProcessedSize( KIO::Job*, KIO::filesize_t ) ) );
connect( job, SIGNAL( processedFiles( KIO::Job*, unsigned long ) ),
SLOT( slotProcessedFiles( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( processedDirs( KIO::Job*, unsigned long ) ),
SLOT( slotProcessedDirs( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( speed( KIO::Job*, unsigned long ) ),
SLOT( slotSpeed( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( percent( KIO::Job*, unsigned long ) ),
SLOT( slotPercent( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( copying( KIO::Job*, const KURL& , const KURL& ) ),
SLOT( slotCopying( KIO::Job*, const KURL&, const KURL& ) ) );
connect( job, SIGNAL( moving( KIO::Job*, const KURL& , const KURL& ) ),
SLOT( slotMoving( KIO::Job*, const KURL&, const KURL& ) ) );
connect( job, SIGNAL( creatingDir( KIO::Job*, const KURL& ) ),
SLOT( slotCreatingDir( KIO::Job*, const KURL& ) ) );
connect( job, SIGNAL( result( KIO::Job* ) ),
SLOT( slotFinished( KIO::Job* ) ) );
connect( job, SIGNAL( canceled( KIO::Job* ) ),
SLOT( slotFinished( KIO::Job* ) ) );
// then assign job
m_pJob = job;
}
void ProgressBase::setJob( KIO::DeleteJob *job )
{
// first connect all slots
connect( job, SIGNAL( totalSize( KIO::Job*, KIO::filesize_t ) ),
SLOT( slotTotalSize( KIO::Job*, KIO::filesize_t ) ) );
connect( job, SIGNAL( totalFiles( KIO::Job*, unsigned long ) ),
SLOT( slotTotalFiles( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( totalDirs( KIO::Job*, unsigned long ) ),
SLOT( slotTotalDirs( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( processedSize( KIO::Job*, KIO::filesize_t ) ),
SLOT( slotProcessedSize( KIO::Job*, KIO::filesize_t ) ) );
connect( job, SIGNAL( processedFiles( KIO::Job*, unsigned long ) ),
SLOT( slotProcessedFiles( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( processedDirs( KIO::Job*, unsigned long ) ),
SLOT( slotProcessedDirs( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( speed( KIO::Job*, unsigned long ) ),
SLOT( slotSpeed( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( percent( KIO::Job*, unsigned long ) ),
SLOT( slotPercent( KIO::Job*, unsigned long ) ) );
connect( job, SIGNAL( deleting( KIO::Job*, const KURL& ) ),
SLOT( slotDeleting( KIO::Job*, const KURL& ) ) );
connect( job, SIGNAL( result( KIO::Job* ) ),
SLOT( slotFinished( KIO::Job* ) ) );
connect( job, SIGNAL( canceled( KIO::Job* ) ),
SLOT( slotFinished( KIO::Job* ) ) );
// then assign job
m_pJob = job;
}
void ProgressBase::closeEvent( QCloseEvent* ) {
// kill job when desired
if ( m_bStopOnClose ) {
slotStop();
} else {
// clean or delete dialog
if ( m_bOnlyClean ) {
slotClean();
} else {
delete this;
}
}
}
void ProgressBase::finished() {
// clean or delete dialog
if ( m_bOnlyClean ) {
slotClean();
} else {
deleteLater();
}
}
void ProgressBase::slotFinished( KIO::Job* ) {
finished();
}
void ProgressBase::slotStop() {
if ( m_pJob ) {
m_pJob->kill(); // this will call slotFinished
m_pJob = 0L;
} else {
slotFinished( 0 ); // here we call it ourselves
}
emit stopped();
}
void ProgressBase::slotClean() {
hide();
}
void ProgressBase::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }
} /* namespace */
#include "progressbase.moc"
KIO::ProgressBase::slotTotalDirs
virtual void slotTotalDirs(KIO::Job *job, unsigned long dirs)
Called to set the total number of directories.
Definition: progressbase.h:163
KIO::ProgressBase::stopped
void stopped()
Called when the operation stopped.
KIO::Job::kill
virtual void kill(bool quietly=true)
Abort this job.
Definition: job.cpp:239
KIO::ProgressBase::slotStop
void slotStop()
This method should be called for correct cancellation of IO operation Connect this to the progress wi...
Definition: progressbase.cpp:158
KIO::ProgressBase::slotTotalFiles
virtual void slotTotalFiles(KIO::Job *job, unsigned long files)
Called to set the total number of files.
Definition: progressbase.h:156
KIO::DeleteJob
A more complex Job to delete files and directories.
Definition: jobclasses.h:1763
KIO::ProgressBase::slotClean
virtual void slotClean()
This method is called when the widget should be cleaned (after job is finished).
Definition: progressbase.cpp:170
KIO::ProgressBase::setJob
void setJob(KIO::Job *job)
Assign a KIO::Job to this progress dialog.
Definition: progressbase.cpp:37
KIO::ProgressBase::slotCreatingDir
virtual void slotCreatingDir(KIO::Job *job, const KURL &dir)
Called when the job is creating a directory.
Definition: progressbase.h:232
KIO::ProgressBase::ProgressBase
ProgressBase(QWidget *parent)
Creates a new progress dialog.
Definition: progressbase.cpp:24
KIO::ProgressBase::slotProcessedFiles
virtual void slotProcessedFiles(KIO::Job *job, unsigned long files)
Called to set the number of processed files.
Definition: progressbase.h:178
KIO::filesize_t
Q_ULLONG filesize_t
64-bit file size
Definition: global.h:39
KIO::ProgressBase::slotSpeed
virtual void slotSpeed(KIO::Job *job, unsigned long speed)
Called to set the speed.
Definition: progressbase.h:193
KIO::ProgressBase::slotProcessedSize
virtual void slotProcessedSize(KIO::Job *job, KIO::filesize_t bytes)
Called to set the processed size.
Definition: progressbase.h:171
KIO::ProgressBase::slotCopying
virtual void slotCopying(KIO::Job *job, const KURL &src, const KURL &dest)
Called when the job is copying.
Definition: progressbase.h:210
KIO::Job
The base class for all jobs.
Definition: jobclasses.h:68
KIO::ProgressBase::finished
void finished()
Call when the operation finished.
Definition: progressbase.cpp:144
KIO::ProgressBase::slotPercent
virtual void slotPercent(KIO::Job *job, unsigned long percent)
Called to set the percentage.
Definition: progressbase.h:201
KIO::ProgressBase::slotMoving
virtual void slotMoving(KIO::Job *job, const KURL &src, const KURL &dest)
Called when the job is moving.
Definition: progressbase.h:218
KIO::ProgressBase::slotDeleting
virtual void slotDeleting(KIO::Job *job, const KURL &url)
Called when the job is deleting.
Definition: progressbase.h:225
KIO::ProgressBase::slotProcessedDirs
virtual void slotProcessedDirs(KIO::Job *job, unsigned long dirs)
Called to set the number of processed directories.
Definition: progressbase.h:185
KIO::CopyJob
CopyJob is used to move, copy or symlink files and directories.
Definition: jobclasses.h:1508
KIO::ProgressBase::slotTotalSize
virtual void slotTotalSize(KIO::Job *job, KIO::filesize_t size)
Called to set the total size.
Definition: progressbase.h:149

KDE Home | KDE Accessibility Home | Description of Access Keys