• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk-core
  • services
  • filewatch
removablemediadatamigrator.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Vishesh Handa <me@vhanda.in>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  */
19 
20 #include "removablemediadatamigrator.h"
21 #include "resourcemanager.h"
22 #include "nie.h"
23 #include <KDebug>
24 
25 #include <Soprano/Model>
26 #include <Soprano/QueryResultIterator>
27 
28 using namespace Nepomuk2::Vocabulary;
29 
30 namespace Nepomuk2 {
31 
32 RemovableMediaDataMigrator::RemovableMediaDataMigrator(const RemovableMediaCache::Entry* entry)
33 {
34  m_mountPoint = entry->mountPath();
35  m_uuid = entry->url();
36 }
37 
38 void RemovableMediaDataMigrator::run()
39 {
40  QString query = QString::fromLatin1("select ?r ?url where { ?r a nfo:FileDataObject ;"
41  " nie:url ?url ."
42  " FILTER( REGEX(STR(?url), '^%1') ). }")
43  .arg( m_uuid );
44 
45  Soprano::Model* model = ResourceManager::instance()->mainModel();
46  Soprano::QueryResultIterator it = model->executeQuery( query, Soprano::Query::QueryLanguageSparqlNoInference );
47  while( it.next() ) {
48  const QUrl resUri = it[0].uri();
49  const QUrl nieUrl = it[1].uri();
50 
51  const QString path = nieUrl.toString().mid( m_uuid.length() );
52  const QUrl newUrl = QUrl::fromLocalFile( m_mountPoint + path );
53 
54  model->removeAllStatements( resUri, NIE::url(), nieUrl );
55  kDebug() << nieUrl << newUrl;
56  model->addStatement( resUri, NIE::url(), newUrl );
57  }
58 }
59 
60 }
removablemediadatamigrator.h
Nepomuk2::RemovableMediaCache::Entry::mountPath
QString mountPath() const
Definition: removablemediacache.cpp:322
Nepomuk2::RemovableMediaCache::Entry
Definition: removablemediacache.h:53
Nepomuk2::ResourceManager::instance
static ResourceManager * instance()
Definition: resourcemanager.cpp:270
resourcemanager.h
Nepomuk2::RemovableMediaDataMigrator::run
virtual void run()
Definition: removablemediadatamigrator.cpp:38
Nepomuk2::RemovableMediaDataMigrator::RemovableMediaDataMigrator
RemovableMediaDataMigrator(const RemovableMediaCache::Entry *entry)
Definition: removablemediadatamigrator.cpp:32
Nepomuk2::RemovableMediaCache::Entry::url
QString url() const
Definition: removablemediacache.h:67
Nepomuk2::ResourceManager::mainModel
Soprano::Model * mainModel()
Retrieve the main data storage model.
Definition: resourcemanager.cpp:363
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal