NepomukDaemons
modelcopyjob.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "modelcopyjob.h"
00016
00017 #include <Soprano/Model>
00018 #include <Soprano/Error/Error>
00019
00020 #include <KLocale>
00021 #include <KDebug>
00022
00023
00024 Nepomuk::ModelCopyJob::ModelCopyJob( Soprano::Model* source, Soprano::Model* dest, QObject* parent )
00025 : KJob( parent ),
00026 m_source( source ),
00027 m_dest( dest )
00028 {
00029 kDebug();
00030 connect( &m_timer, SIGNAL( timeout() ),
00031 this, SLOT( slotCopy() ) );
00032 }
00033
00034
00035 Nepomuk::ModelCopyJob::~ModelCopyJob()
00036 {
00037 }
00038
00039
00040 void Nepomuk::ModelCopyJob::start()
00041 {
00042 kDebug();
00043 emit description( this, i18n( "Converting Nepomuk database" ) );
00044
00045 m_size = m_source->statementCount();
00046 m_done = 0;
00047 m_allCopied = true;
00048
00049 if ( m_size > 0 ) {
00050 setTotalAmount( KJob::Files, m_size );
00051 }
00052
00053 m_iterator = m_source->listStatements();
00054
00055 m_timer.start( 0 );
00056 }
00057
00058
00059 void Nepomuk::ModelCopyJob::slotCopy()
00060 {
00061 if ( m_iterator.next() ) {
00062 ++m_done;
00063
00064 if ( m_dest->addStatement( *m_iterator ) != Soprano::Error::ErrorNone ) {
00065 kDebug() << m_dest->lastError();
00066 emit warning( this, m_dest->lastError().message() );
00067 m_allCopied = false;
00068 }
00069
00070 setProcessedAmount( KJob::Files, m_done );
00071 }
00072 else {
00073 kDebug() << "done";
00074 m_timer.stop();
00075
00076 if ( !m_allCopied ) {
00077 setError( 1 );
00078 setErrorText( i18n( "Some data was lost in the conversion." ) );
00079 }
00080
00081 emitResult();
00082 }
00083 }
00084
00085 #include "modelcopyjob.moc"