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

NepomukDaemons

modelcopyjob.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
00004  *
00005  * This file is part of the Nepomuk KDE project.
00006  * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  * See the file "COPYING" for the exact licensing terms.
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"

NepomukDaemons

Skip menu "NepomukDaemons"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KCMShell
  • KNotify
  • KStyles
  • Nepomuk Daemons
Generated for API Reference by doxygen 1.5.7
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