add more spacing
[personal-kdebase.git] / runtime / nepomuk / services / storage / modelcopyjob.cpp
blobeae6bade89afae843c9b0e096c49789b343f2982
1 /*
3 * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
5 * This file is part of the Nepomuk KDE project.
6 * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 * See the file "COPYING" for the exact licensing terms.
15 #include "modelcopyjob.h"
17 #include <Soprano/Model>
18 #include <Soprano/Error/Error>
20 #include <KLocale>
21 #include <KDebug>
24 Nepomuk::ModelCopyJob::ModelCopyJob( Soprano::Model* source, Soprano::Model* dest, QObject* parent )
25 : KJob( parent ),
26 m_source( source ),
27 m_dest( dest )
29 kDebug();
30 connect( &m_timer, SIGNAL( timeout() ),
31 this, SLOT( slotCopy() ) );
35 Nepomuk::ModelCopyJob::~ModelCopyJob()
40 void Nepomuk::ModelCopyJob::start()
42 kDebug();
43 emit description( this, i18n( "Converting Nepomuk database" ) );
45 m_size = m_source->statementCount();
46 m_done = 0;
47 m_allCopied = true;
49 if ( m_size > 0 ) {
50 setTotalAmount( KJob::Files, m_size );
53 m_iterator = m_source->listStatements();
55 m_timer.start( 0 );
59 void Nepomuk::ModelCopyJob::slotCopy()
61 if ( m_iterator.next() ) {
62 ++m_done;
64 if ( m_dest->addStatement( *m_iterator ) != Soprano::Error::ErrorNone ) {
65 kDebug() << m_dest->lastError();
66 emit warning( this, m_dest->lastError().message() );
67 m_allCopied = false;
70 setProcessedAmount( KJob::Files, m_done );
72 else {
73 kDebug() << "done";
74 m_timer.stop();
76 if ( !m_allCopied ) {
77 setError( 1 );
78 setErrorText( i18n( "Some data was lost in the conversion." ) );
81 emitResult();
85 #include "modelcopyjob.moc"