• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeutils
  • Sitemap
  • Contact Us
 

ark

jobs.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2007 Henrique Pinto <henrique.pinto@kdemail.net>
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00015  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00016  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00017  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00018  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
00019  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00020  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
00021  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00022  * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
00023  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00024  */
00025 #include "jobs.h"
00026 #include "internaljobs.h"
00027 
00028 #include <kdebug.h>
00029 #include <KLocale>
00030 
00031 namespace Kerfuffle
00032 {
00033     ListJob::ListJob( ReadOnlyArchiveInterface *interface, QObject *parent )
00034         : KJob( parent ), m_archive( interface )
00035     {
00036     }
00037 
00038     void ListJob::start()
00039     {
00040         emit description( this, i18n( "Listing entries" ) );
00041         InternalListingJob *job = new InternalListingJob( m_archive, this );
00042         // TODO: connects
00043         connect( job, SIGNAL( entry( const ArchiveEntry& ) ),
00044                  this, SIGNAL( newEntry( const ArchiveEntry & ) ) );
00045         connect( job, SIGNAL( done( ThreadWeaver::Job* ) ),
00046                  this, SLOT( done( ThreadWeaver::Job* ) ) );
00047         connect( job, SIGNAL( progress( double ) ),
00048                  this, SLOT( progress( double ) ) );
00049         ThreadWeaver::Weaver::instance()->enqueue( job );
00050     }
00051 
00052     void ListJob::done( ThreadWeaver::Job *job )
00053     {
00054         emitResult();
00055     }
00056 
00057     ExtractJob::ExtractJob( const QList<QVariant>& files, const QString& destinationDir,
00058                             bool preservePaths, ReadOnlyArchiveInterface *interface, QObject *parent )
00059         : KJob( parent ), m_files( files ), m_destinationDir( destinationDir ), m_preservePaths( preservePaths ),  m_archive( interface )
00060     {
00061     }
00062 
00063     void ExtractJob::start()
00064     {
00065         QString desc;
00066         if ( m_files.count() == 0 )
00067         {
00068             desc = i18n( "Extracting all files" );
00069         }
00070         else
00071         {
00072             desc = i18np( "Extracting one file", "Extracting %1 files", m_files.count() );
00073         }
00074         emit description( this, desc );
00075         InternalExtractJob *job = new InternalExtractJob( m_archive, m_files, m_destinationDir, m_preservePaths, this );
00076 
00077         connect( job, SIGNAL( done( ThreadWeaver::Job* ) ),
00078                  this, SLOT( done( ThreadWeaver::Job* ) ) );
00079         connect( job, SIGNAL( progress( double ) ),
00080                  this, SLOT( progress( double ) ) );
00081         connect( job, SIGNAL( error( const QString&, const QString& ) ),
00082                  this, SLOT( error( const QString&, const QString& ) ) );
00083 
00084         ThreadWeaver::Weaver::instance()->enqueue( job );
00085     }
00086 
00087     void ExtractJob::done( ThreadWeaver::Job *job )
00088     {
00089         emitResult();
00090     }
00091 
00092     void ExtractJob::progress( double p )
00093     {
00094         setPercent( static_cast<unsigned long>( 100.0*p ) );
00095     }
00096 
00097     void ExtractJob::error( const QString& errorMessage, const QString& details )
00098     {
00099         Q_UNUSED( details );
00100         setError( 1 );
00101         setErrorText( errorMessage );
00102     }
00103 
00104     void ListJob::progress( double p )
00105     {
00106         setPercent( static_cast<unsigned long>( 100.0*p ) );
00107     }
00108 
00109     AddJob::AddJob( const QStringList & files, ReadWriteArchiveInterface *interface, QObject *parent )
00110         : KJob( parent ), m_files( files ), m_archive( interface )
00111     {
00112     }
00113 
00114     void AddJob::start()
00115     {
00116         emit description( this, i18np( "Adding a file", "Adding %1 files", m_files.count() ) );
00117         
00118         InternalAddJob *job = new InternalAddJob( m_archive, m_files, this );
00119         
00120         connect( job, SIGNAL( done( ThreadWeaver::Job* ) ),
00121                  this, SLOT( done( ThreadWeaver::Job* ) ) );
00122         connect( job, SIGNAL( progress( double ) ),
00123                  this, SLOT( progress( double ) ) );
00124         connect( job, SIGNAL( entry( const ArchiveEntry& ) ),
00125                  this, SIGNAL( newEntry( const ArchiveEntry & ) ) );
00126         connect( job, SIGNAL( error( const QString&, const QString& ) ),
00127                  this, SLOT( error( const QString&, const QString& ) ) );
00128         
00129         ThreadWeaver::Weaver::instance()->enqueue( job );
00130     }
00131 
00132     void AddJob::done( ThreadWeaver::Job *job )
00133     {
00134         emitResult();
00135     }
00136 
00137     void AddJob::progress( double p )
00138     {
00139         setPercent( static_cast<unsigned long>( 100.0*p ) );
00140     }
00141 
00142     void AddJob::error( const QString& errorMessage, const QString& details )
00143     {
00144         kDebug( 1601 ) ;
00145         Q_UNUSED( details );
00146         setError( 1 );
00147         setErrorText( errorMessage );
00148     }
00149 
00150     DeleteJob::DeleteJob( const QList<QVariant>& files, ReadWriteArchiveInterface *interface, QObject *parent )
00151         : KJob( parent ), m_files( files ), m_archive( interface )
00152     {
00153     }
00154 
00155     void DeleteJob::start()
00156     {
00157         emit description( this, i18np( "Deleting a file from the archive", "Deleting %1 files", m_files.count() ) );
00158 
00159         InternalDeleteJob *job = new InternalDeleteJob( m_archive, m_files, this );
00160 
00161         connect( job, SIGNAL( done( ThreadWeaver::Job* ) ),
00162                  this, SLOT( done( ThreadWeaver::Job* ) ) );
00163         connect( job, SIGNAL( progress( double ) ),
00164                  this, SLOT( progress( double ) ) );
00165         connect( job, SIGNAL( entryRemoved( const QString& ) ),
00166                  this, SIGNAL( entryRemoved( const QString& ) ) );
00167 
00168         ThreadWeaver::Weaver::instance()->enqueue( job );
00169     }
00170 
00171     void DeleteJob::done( ThreadWeaver::Job *job )
00172     {
00173         emitResult();
00174     }
00175 
00176     void DeleteJob::progress( double p )
00177     {
00178         setPercent( static_cast<unsigned long>( 100.0*p ) );
00179     }
00180 
00181 } // namespace Kerfuffle

ark

Skip menu "ark"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdelirc
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • kjots
  • klaptopdaemon
  • kmilo
  • ksim
  • ktimer
  • kwallet
  • superkaramba
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal