diff --git a/src/core-impl/collections/CMakeLists.txt b/src/core-impl/collections/CMakeLists.txt index ba9e96218b..6b480b352f 100644 --- a/src/core-impl/collections/CMakeLists.txt +++ b/src/core-impl/collections/CMakeLists.txt @@ -1,19 +1,18 @@ include_directories( ${Amarok_SOURCE_DIR}/src ) set(AMAROK_COLLECTION_SUPPORT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/support) add_subdirectory( daap ) if( NOT WIN32) add_subdirectory( audiocd ) endif() add_subdirectory( ipodcollection ) add_subdirectory( mtpcollection ) add_subdirectory( umscollection ) add_subdirectory( db ) add_subdirectory( playdarcollection ) add_subdirectory( upnpcollection ) -#add_subdirectory( nepomukcollection ) diff --git a/src/core-impl/collections/nepomukcollection/CMakeLists.txt b/src/core-impl/collections/nepomukcollection/CMakeLists.txt deleted file mode 100644 index 2c01f64bf4..0000000000 --- a/src/core-impl/collections/nepomukcollection/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -find_package(NepomukCore QUIET) -set_package_properties(NEPOMUK-CORE PROPERTIES DESCRIPTION "NepomukCore Libraries required by Nepomuk Collection" URL "http://kde.org/download/#v4.9" TYPE OPTIONAL) -find_package(Soprano QUIET) -set_package_properties(SOPRANO PROPERTIES DESCRIPTION "Soprano libraries required by Nepomuk Collection" URL "http://soprano.sourceforge.net/" TYPE OPTIONAL) - -if(NepomukCore_FOUND AND Soprano_FOUND) - include(NepomukAddOntologyClasses) - - include_directories( ../.. - ${SOPRANO_INCLUDE_DIR} - ${NEPOMUK_CORE_INCLUDE_DIR} - ) - - ########### next target ############### - - set(amarok_collection-nepomukcollection_PART_SRCS - - NepomukCache.cpp - NepomukCollection.cpp - NepomukCollectionFactory.cpp - NepomukInquirer.cpp - NepomukParser.cpp - NepomukQueryMaker.cpp - - meta/NepomukAlbum.cpp - meta/NepomukArtist.cpp - meta/NepomukComposer.cpp - meta/NepomukGenre.cpp - meta/NepomukTrack.cpp - meta/NepomukLabel.cpp - meta/NepomukYear.cpp - ) - - add_library(amarok_collection-nepomukcollection MODULE ${amarok_collection-nepomukcollection_PART_SRCS}) - - target_link_libraries(amarok_collection-nepomukcollection - amarokcore - amaroklib - KF5::ThreadWeaver - ${NEPOMUK_CORE_LIBRARY} - ${SOPRANO_LIBRARIES} - ) - - install(TARGETS amarok_collection-nepomukcollection DESTINATION ${KDE_INSTALL_PLUGINDIR}) - - ########### install files ############### - - install(FILES amarok_collection-nepomukcollection.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) - -endif() diff --git a/src/core-impl/collections/nepomukcollection/NepomukCache.cpp b/src/core-impl/collections/nepomukcollection/NepomukCache.cpp deleted file mode 100644 index b9e839bca3..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukCache.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Edward Toroshchin - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NepomukCache.h" - -#include "NepomukCollection.h" -#include "meta/NepomukAlbum.h" -#include "meta/NepomukArtist.h" -#include "meta/NepomukComposer.h" -#include "meta/NepomukGenre.h" -#include "meta/NepomukLabel.h" -#include "meta/NepomukTrack.h" -#include "meta/NepomukYear.h" - -#include -#include -#include - -namespace Collections { - -class NepomukCachePrivate -{ -public: - QHash< QUrl, Meta::TrackPtr > trackMap; - QHash< QUrl, Meta::ArtistPtr > artistMap; - QHash< QUrl, Meta::AlbumPtr > albumMap; - QHash< QUrl, Meta::ComposerPtr > composerMap; - QHash< QString, Meta::GenrePtr > genreMap; - QHash< int, Meta::YearPtr > yearMap; - QHash< QUrl, Meta::LabelPtr > labelMap; - - QMutex lock; - - template< class NepomukObject, class Key, class Ptr > - Ptr getOrCreate( QHash< Key, Ptr > &hash, const Key &key ) - { - QMutexLocker locker(&lock); - Ptr &ptr( hash[key] ); - if( !ptr ) - { - // Create a new empty object. The empty object must be filled - // by NepomukParser before being used - ptr = new NepomukObject( key ); - } - - return ptr; - } -}; - -NepomukCache::NepomukCache( NepomukCollection *parent ) - : QObject( parent ) - , d( new NepomukCachePrivate ) -{ -} - -NepomukCache::~NepomukCache() -{ - delete d; - d = 0; -} - -Meta::TrackPtr -NepomukCache::getTrack( const QUrl &resourceUri ) -{ - return d->getOrCreate< Meta::NepomukTrack >( d->trackMap, resourceUri ); -} - -Meta::ArtistPtr -NepomukCache::getArtist( const QUrl &resourceUri ) -{ - return d->getOrCreate< Meta::NepomukArtist >( d->artistMap, resourceUri ); -} - -Meta::AlbumPtr -NepomukCache::getAlbum( const QUrl &resourceUri ) -{ - return d->getOrCreate< Meta::NepomukAlbum >( d->albumMap, resourceUri ); -} - -Meta::ComposerPtr -NepomukCache::getComposer( const QUrl &resourceUri ) -{ - return d->getOrCreate< Meta::NepomukComposer >( d->composerMap, resourceUri ); -} - -Meta::GenrePtr -NepomukCache::getGenre( const QString &genre ) -{ - return d->getOrCreate< Meta::NepomukGenre >( d->genreMap, genre ); -} - -Meta::YearPtr -NepomukCache::getYear( const int year ) -{ - return d->getOrCreate< Meta::NepomukYear >( d->yearMap, year ); -} - -Meta::LabelPtr -NepomukCache::getLabel( const QUrl &label ) -{ - return d->getOrCreate< Meta::NepomukLabel >( d->labelMap, label ); -} - -} diff --git a/src/core-impl/collections/nepomukcollection/NepomukCache.h b/src/core-impl/collections/nepomukcollection/NepomukCache.h deleted file mode 100644 index ef9a8f3ac5..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukCache.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Edward Toroshchin - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_NEPOMUKCACHE_H -#define AMAROK_COLLECTION_NEPOMUKCACHE_H - -#include "core/meta/forward_declarations.h" - -#include - -class QString; -class QUrl; - -namespace Collections { - -class NepomukCollection; - -class NepomukCachePrivate; - -/** - * The storage/cache thingy for objects retrieved from Nepomuk. - * - * The Nepomuk tracks, artists, albums, composers and labels are identified by - * their resource URIs. This class provides a one-to-one mapping from Nepomuk - * URIs to respective Amarok Meta::Nepomuk* objects. - * - * The genres and years are identified by their literal values. This class - * provides a one-to-one mapping from the literal values to Amarok - * Meta::NepomukGenre and Meta::NepomukYear objects. - * - * You can convert a Nepomuk URI (or literal value for genres and years) to a - * Meta object using the appropriate get*() method. If the object isn't known to - * NepomukCache, it will create a new empty object and return a pointer to it. - * All subsequent requests with the same URI (or literal value) will return - * pointers to the same object. - * - * NepomukCache is non-copyable and should only be constructed by - * NepomukCollection. - * - * All functions are thread-safe. - */ -class NepomukCache: public QObject -{ - Q_OBJECT - Q_DISABLE_COPY(NepomukCache) - - NepomukCachePrivate *d; - - explicit NepomukCache( NepomukCollection *parent ); - ~NepomukCache(); - - friend class NepomukCollection; - -public: - Meta::TrackPtr getTrack( const QUrl &resourceUri ); - Meta::ArtistPtr getArtist( const QUrl &resourceUri ); - Meta::AlbumPtr getAlbum( const QUrl &resourceUri ); - Meta::ComposerPtr getComposer( const QUrl &resourceUri ); - Meta::GenrePtr getGenre( const QString &genre ); - Meta::YearPtr getYear( const int year ); - Meta::LabelPtr getLabel( const QUrl &resourceUri ); -}; - -} - -#endif // AMAROK_COLLECTION_NEPOMUKCACHE_H diff --git a/src/core-impl/collections/nepomukcollection/NepomukCollection.cpp b/src/core-impl/collections/nepomukcollection/NepomukCollection.cpp deleted file mode 100644 index 7446d6348d..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukCollection.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "NepomukCollection" - -#include "NepomukCollection.h" - -#include "NepomukCache.h" -#include "NepomukQueryMaker.h" - -#include "core/meta/Meta.h" -#include "core/meta/support/MetaKeys.h" -#include "core/support/Debug.h" - -#include -#include -#include - -#include - -namespace Collections -{ - -NepomukCollection::NepomukCollection() - : m_cache( new NepomukCache( this ) ) -{ -} - -NepomukCollection::~NepomukCollection() -{ -} - -QueryMaker* -NepomukCollection::queryMaker() -{ - return new NepomukQueryMaker( this ); -} - -QString -NepomukCollection::uidUrlProtocol() const -{ - return QLatin1String( "amarok-nepomuk" ); -} - -QString -NepomukCollection::collectionId() const -{ - return QString( "%1://" ).arg( uidUrlProtocol() ); -} - -QString -NepomukCollection::prettyName() const -{ - return i18n( "Nepomuk Collection" ); -} - -QIcon -NepomukCollection::icon() const -{ - return QIcon::fromTheme( "nepomuk" ); -} - -bool -NepomukCollection::isWritable() const -{ - // right now NepomukCollectionLocation isn't implemented, which deals with moving - // and copying tracks into collection. So false until that is implemented. - - return false; -} - -bool -NepomukCollection::possiblyContainsTrack( const QUrl & ) const -{ - return true; -} - -Meta::TrackPtr -NepomukCollection::trackForUrl( const QUrl &url ) -{ - DEBUG_BLOCK - debug() << url; - return Meta::TrackPtr(); // TODO -} - -} diff --git a/src/core-impl/collections/nepomukcollection/NepomukCollection.h b/src/core-impl/collections/nepomukcollection/NepomukCollection.h deleted file mode 100644 index 84fec00516..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukCollection.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NEPOMUKCOLLECTION_H -#define NEPOMUKCOLLECTION_H - -#include "core/collections/Collection.h" - -#include - -namespace Collections -{ - - -class NepomukCache; - -/** - * This collection class interfaces with KDE Nepomuk semantic data storage. - * - * It connects to the underlying Soprano database interface and provides a - * QueryMaker interface to the objects of type nfo:Audio stored there. - */ -class NepomukCollection : public Collection -{ - Q_OBJECT - -public: - NepomukCollection(); - virtual ~NepomukCollection(); - - virtual QueryMaker *queryMaker(); - virtual QString uidUrlProtocol() const; - virtual QString collectionId() const; - virtual QString prettyName() const; - virtual QIcon icon() const; - virtual bool isWritable() const; - - // TrackProvider methods - virtual bool possiblyContainsTrack( const QUrl &url ) const; - virtual Meta::TrackPtr trackForUrl( const QUrl &url ); - - NepomukCache *cache() const { return m_cache; } - -private: - NepomukCache *m_cache; -}; - -} //namespace Collections -#endif // NEPOMUKCOLLECTION_H diff --git a/src/core-impl/collections/nepomukcollection/NepomukCollectionFactory.cpp b/src/core-impl/collections/nepomukcollection/NepomukCollectionFactory.cpp deleted file mode 100644 index 66c3f39fc5..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukCollectionFactory.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "NepomukCollection Factory" - -#include "NepomukCollection.h" -#include "NepomukCollectionFactory.h" - -#include "core/logger/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" - -#include - -void -NepomukCollectionFactory::init() -{ - DEBUG_BLOCK - m_initialized = true; - - // check if Nepomuk service is running - if( Nepomuk2::ResourceManager::instance()->initialized() ) - { - // if it is, create a new NepomukCollection - emit newCollection( new Collections::NepomukCollection() ); - return; - } - else - { - warning() << "Couldn't initialize Nepomuk Collection. " - "Check if 'Nepomuk Semantic Desktop' is enabled in System Settings -> Desktop Search. " - "Nepomuk Plugin won't be loaded unless Nepomuk is enabled."; - - Amarok::Logger::longMessage( - i18n( "Couldn't initialize Nepomuk Collection. " - "Check if 'Nepomuk Semantic Desktop' is enabled in System Settings -> Desktop Search. " - "Nepomuk Plugin won't be loaded unless Nepomuk is enabled." ), - Amarok::Logger::Warning ); - } -} - -NepomukCollectionFactory::NepomukCollectionFactory( QObject *parent, - const QVariantList &args ) - : CollectionFactory( parent, args ) -{ - m_info = KPluginInfo( "amarok_collection-nepomukcollection.desktop" ); -} - -NepomukCollectionFactory::~NepomukCollectionFactory() -{ -} - -AMAROK_EXPORT_COLLECTION( NepomukCollectionFactory, nepomukcollection ) diff --git a/src/core-impl/collections/nepomukcollection/NepomukCollectionFactory.h b/src/core-impl/collections/nepomukcollection/NepomukCollectionFactory.h deleted file mode 100644 index 16d9f08f23..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukCollectionFactory.h +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NEPOMUKCOLLECTIONFACTORY_H -#define NEPOMUKCOLLECTIONFACTORY_H - -#include "core/collections/Collection.h" - -class NepomukCollectionFactory : public Collections::CollectionFactory -{ - Q_OBJECT -public: - NepomukCollectionFactory( QObject *parent, const QVariantList &args ); - virtual ~NepomukCollectionFactory(); - virtual void init(); -}; - -#endif // NEPOMUKCOLLECTIONFACTORY_H diff --git a/src/core-impl/collections/nepomukcollection/NepomukInquirer.cpp b/src/core-impl/collections/nepomukcollection/NepomukInquirer.cpp deleted file mode 100644 index 6eee985b12..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukInquirer.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Edward Toroshchin - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NepomukInquirer.h" - -#include "NepomukParser.h" - -#include "core/support/Debug.h" - -#include -#include - -namespace Collections { - - -NepomukInquirer::NepomukInquirer( QString query, std::auto_ptr parser ) - : m_query( query ) -{ - Q_ASSERT( parser.get() ); - - m_parser = parser.release(); - m_parser->setParent( this ); -} - -NepomukInquirer::~NepomukInquirer() -{ -} - -void -NepomukInquirer::run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread *thread) -{ - Q_UNUSED(self); - Q_UNUSED(thread); - DEBUG_BLOCK - - Soprano::Model *model = Nepomuk2::ResourceManager::instance()->mainModel(); - Soprano::QueryResultIterator it = model->executeQuery( m_query, Soprano::Query::QueryLanguageSparql ); - - if( !it.isValid() ) - { - error() << "nepomuk query failed!"; - error() << "Soprano message:" << it.lastError().message(); - return; - } - - m_parser->parse( it ); -} - -void -NepomukInquirer::defaultBegin(const ThreadWeaver::JobPointer& self, ThreadWeaver::Thread *thread) -{ - Q_EMIT started(self); - ThreadWeaver::Job::defaultBegin(self, thread); -} - -void -NepomukInquirer::defaultEnd(const ThreadWeaver::JobPointer& self, ThreadWeaver::Thread *thread) -{ - ThreadWeaver::Job::defaultEnd(self, thread); - if (!self->success()) { - Q_EMIT failed(self); - } - Q_EMIT done(self); -} - -} diff --git a/src/core-impl/collections/nepomukcollection/NepomukInquirer.h b/src/core-impl/collections/nepomukcollection/NepomukInquirer.h deleted file mode 100644 index 90ece0e76b..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukInquirer.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Edward Toroshchin - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_NEPOMUKINQUIRER_H -#define AMAROK_COLLECTION_NEPOMUKINQUIRER_H - -#include - -#include - -#include - -namespace Collections { - -class NepomukParser; - -class NepomukInquirerPrivate; - -/** - * A ThreadWeaver Job that runs the given SPARQL query on a Nepomuk's - * database and passes the results to a given parser. - */ -class NepomukInquirer: public QObject, public ThreadWeaver::Job -{ - Q_OBJECT - -public: - NepomukInquirer( QString query, std::auto_ptr parser ); - ~NepomukInquirer(); - -Q_SIGNALS: - /** This signal is emitted when this job is being processed by a thread. */ - void started(ThreadWeaver::JobPointer); - /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ - void done(ThreadWeaver::JobPointer); - /** This job has failed. - * This signal is emitted when success() returns false after the job is executed. */ - void failed(ThreadWeaver::JobPointer); - -protected: - void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; - void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; - void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread = 0) override; - -private: - QString m_query; - NepomukParser *m_parser; -}; - -} - -#endif // AMAROK_COLLECTION_NEPOMUKINQUIRER_H diff --git a/src/core-impl/collections/nepomukcollection/NepomukParser.cpp b/src/core-impl/collections/nepomukcollection/NepomukParser.cpp deleted file mode 100644 index 239a4e49e6..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukParser.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Edward Toroshchin - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NepomukParser.h" - -#include "NepomukCache.h" -#include "NepomukCollection.h" -#include "NepomukSelectors.h" - -#include "core/support/Debug.h" - -#include "meta/NepomukAlbum.h" -#include "meta/NepomukArtist.h" -#include "meta/NepomukComposer.h" -#include "meta/NepomukGenre.h" -#include "meta/NepomukLabel.h" -#include "meta/NepomukTrack.h" -#include "meta/NepomukYear.h" - -namespace Collections { - -NepomukParser::NepomukParser( NepomukCollection *coll ) - : m_collection( coll ) -{ - Q_ASSERT( coll ); -} - -bool -NepomukParser::parseOne( Soprano::QueryResultIterator &queryResult, - Meta::TrackList &objectList ) -{ - QUrl resource = queryResult.binding( NS_track ).uri(); - if( resource.isEmpty() ) return false; - - /* Prevent duplicate results. This may look quite crude, and that's because - * it is. Actually, this should be handled by SPARQL query's DISTINCT - * clause, but it doesn't work always. Here's why. - * - * We select all the information (title, album, artist, date - * created/modified, you name it) about the tracks in one go. This allows us - * to create new Meta* objects without any additional SPARQL queries. - * - * But this also prevents DISTINCT from doing what we want, because the - * "database" "model" of Nepomuk allows tracks to have more than one: - * - * - artist (which is okay), - * - title (meh?), - * - modification/creation date (lol wut), - * - pretty much any other piece of information. - * - * DISTINCT would naturally select all the existing combinations, creating - * many duplicates in the query results. - * - * Long story short: TODO improve Nepomuk performance. - */ - if( m_seen_uri.contains( resource ) ) return false; - m_seen_uri.insert( resource ); - - Meta::TrackPtr track( m_collection->cache()->getTrack( resource ) ); - objectList << track; - - AmarokSharedPointer ntrack( AmarokSharedPointer::staticCast( track ) ); - if( !ntrack->isFilled() ) - { - Meta::ArtistList artist; - Meta::AlbumList album; - Meta::ComposerList composer; - Meta::GenreList genre; - Meta::YearList year; - - if( parseOne( queryResult, artist ) ) - ntrack->setArtist( artist.first() ); - if( parseOne( queryResult, album ) ) - ntrack->setAlbum( album.first() ); - if( parseOne( queryResult, composer ) ) - ntrack->setComposer( composer.first() ); - if( parseOne( queryResult, genre ) ) - ntrack->setGenre( genre.first() ); - if( parseOne( queryResult, year ) ) - ntrack->setYear( year.first() ); - - ntrack->fill( queryResult.binding( NS_trackTitle ).literal().toString(), - queryResult.binding( NS_trackUrl ).uri(), - m_collection ); - - if( !queryResult.binding( NS_trackType ).isEmpty() ) - ntrack->setType( queryResult.binding( NS_trackType ).literal().toString() ); - if( !queryResult.binding( NS_trackLength ).isEmpty() ) - ntrack->setLength( queryResult.binding( NS_trackLength ).literal().toInt() ); - if( !queryResult.binding( NS_trackBitrate ).isEmpty() ) - ntrack->setBitrate( queryResult.binding( NS_trackBitrate ).literal().toInt() ); - if( !queryResult.binding( NS_trackNumber ).isEmpty() ) - ntrack->setTrackNumber( queryResult.binding( NS_trackNumber ).literal().toInt() ); - if( !queryResult.binding( NS_trackBPM ).isEmpty() ) - ntrack->setbpm( queryResult.binding( NS_trackBPM ).literal().toDouble() ); - if( !queryResult.binding( NS_trackComment ).isEmpty() ) - ntrack->setComment( queryResult.binding( NS_trackComment ).literal().toString() ); - if( !queryResult.binding( NS_trackSampleRate ).isEmpty() ) - ntrack->setSampleRate( queryResult.binding( NS_trackSampleRate ).literal().toInt() ); - if( !queryResult.binding( NS_trackFileSize ).isEmpty() ) - ntrack->setFilesize( queryResult.binding( NS_trackFileSize ).literal().toInt() ); - if( !queryResult.binding( NS_trackGain ).isEmpty() ) - ntrack->setTrackGain( queryResult.binding( NS_trackGain ).literal().toDouble() ); - if( !queryResult.binding( NS_trackPeakGain ).isEmpty() ) - ntrack->setTrackPeakGain( queryResult.binding( NS_trackPeakGain ).literal().toDouble() ); - if( !queryResult.binding( NS_albumGain ).isEmpty() ) - ntrack->setAlbumGain( queryResult.binding( NS_albumGain ).literal().toDouble() ); - if( !queryResult.binding( NS_albumPeakGain ).isEmpty() ) - ntrack->setAlbumPeakGain( queryResult.binding( NS_albumPeakGain ).literal().toDouble() ); - if( !queryResult.binding( NS_trackModifyDate ).isEmpty() ) - ntrack->setModifyDate( queryResult.binding( NS_trackModifyDate ).literal().toDateTime() ); - if( !queryResult.binding( NS_trackCreateDate ).isEmpty() ) - ntrack->setCreateDate( queryResult.binding( NS_trackCreateDate ).literal().toDateTime() ); - } - - return true; -} - -bool -NepomukParser::parseOne( Soprano::QueryResultIterator &queryResult, - Meta::ArtistList &objectList ) -{ - QUrl resource = queryResult.binding( NS_artist ).uri(); - if( resource.isEmpty() ) return false; - - Meta::ArtistPtr artist( m_collection->cache()->getArtist( resource ) ); - objectList << artist; - - AmarokSharedPointer nartist( AmarokSharedPointer::staticCast( artist ) ); - if( !nartist->isFilled() ) - nartist->fill( queryResult.binding( NS_artistName ).literal().toString() ); - - return true; -} - -bool -NepomukParser::parseOne( Soprano::QueryResultIterator &queryResult, - Meta::AlbumList &objectList ) -{ - QUrl resource = queryResult.binding( NS_album ).uri(); - if( resource.isEmpty() ) return false; - - Meta::AlbumPtr album( m_collection->cache()->getAlbum( resource ) ); - objectList << album; - - AmarokSharedPointer nalbum( AmarokSharedPointer::staticCast( album ) ); - if( !nalbum->isFilled() ) - nalbum->fill( queryResult.binding( NS_albumTitle ).literal().toString() ); - - return true; -} - -bool -NepomukParser::parseOne( Soprano::QueryResultIterator &queryResult, - Meta::GenreList &objectList ) -{ - QString genre = queryResult.binding( NS_genre ).literal().toString(); - - if( genre.isEmpty() ) return false; - - objectList << m_collection->cache()->getGenre( genre ); - return true; -} - -bool -NepomukParser::parseOne( Soprano::QueryResultIterator &queryResult, - Meta::ComposerList &objectList ) -{ - QUrl resource = queryResult.binding( NS_composer ).uri(); - if( resource.isEmpty() ) return false; - - Meta::ComposerPtr composer( m_collection->cache()->getComposer( resource ) ); - objectList << composer; - - AmarokSharedPointer ncomposer( AmarokSharedPointer::staticCast( composer ) ); - if( !ncomposer->isFilled() ) - ncomposer->fill( queryResult.binding( NS_composerName ).literal().toString() ); - - return true; -} - -bool -NepomukParser::parseOne( Soprano::QueryResultIterator &queryResult, - Meta::YearList &objectList ) -{ - int year = queryResult.binding( NS_year ).literal().toString().toInt(); - - if( !year ) return false; - - objectList << m_collection->cache()->getYear( year ); - return true; -} - -bool -NepomukParser::parseOne( Soprano::QueryResultIterator &queryResult, - QStringList &objectList ) -{ - for( int i = 0; i < queryResult.bindingCount(); ++i ) - objectList << queryResult.binding(i).literal().toString(); - return true; -} - -bool -NepomukParser::parseOne( Soprano::QueryResultIterator &queryResult, - Meta::LabelList &objectList ) -{ - QUrl labelResource = queryResult.binding( NS_tag ).uri(); - - if( labelResource.isEmpty() ) - return false; - - objectList << m_collection->cache()->getLabel( labelResource ); - return true; -} - -} diff --git a/src/core-impl/collections/nepomukcollection/NepomukParser.h b/src/core-impl/collections/nepomukcollection/NepomukParser.h deleted file mode 100644 index 41ecfb8e6c..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukParser.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Edward Toroshchin - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_NEPOMUKPARSER_H -#define AMAROK_COLLECTION_NEPOMUKPARSER_H - -#include "core/meta/Meta.h" - -#include - -#include -#include -#include - -namespace Collections { - -class NepomukCollection; - -/** - * This is an interface for classes that parse the results of the - * NepomukQueryMaker's Soprano queries. - * - * The parse() method is called by NepomukInquirer with the query result - * iterator. - * - * The implementations of this interface should return the results by emitting - * the appropriate newResultReady() signals. - * - * The instances of this class will be constructed in a non-main thread by the - * NepomukInquirer, so don't do anything nasty in constructors and methods (no - * GUI, no non-thread-safe methods of non-local objects, etc.) - */ -class NepomukParser: public QObject -{ - Q_OBJECT - -public: - /** - * Construct a NepomukParser. - * - * @param coll must be a valid NepomukCollection - */ - explicit NepomukParser( NepomukCollection *coll ); - - /** - * Parse all the query results in the given QueryResultIterator and Q_EMIT - * newResultReady with the constructed objects. - */ - virtual void parse( Soprano::QueryResultIterator& ) = 0; - -Q_SIGNALS: - z - -protected: - bool parseOne( Soprano::QueryResultIterator &queryResult, - Meta::TrackList &objectList ); - bool parseOne( Soprano::QueryResultIterator &queryResult, - Meta::ArtistList &objectList ); - bool parseOne( Soprano::QueryResultIterator &queryResult, - Meta::AlbumList &objectList ); - bool parseOne( Soprano::QueryResultIterator &queryResult, - Meta::GenreList &objectList ); - bool parseOne( Soprano::QueryResultIterator &queryResult, - Meta::ComposerList &objectList ); - bool parseOne( Soprano::QueryResultIterator &queryResult, - Meta::YearList &objectList ); - bool parseOne( Soprano::QueryResultIterator &queryResult, - QStringList &objectList ); - bool parseOne( Soprano::QueryResultIterator &queryResult, - Meta::LabelList &objectList ); - -private: - NepomukCollection *m_collection; - QSet m_seen_uri; -}; - -template< class MetaObjectList > -class NepomukObjectParser: public NepomukParser -{ -public: - NepomukObjectParser( NepomukCollection *coll ) - : NepomukParser( coll ) - {} - - virtual void parse( Soprano::QueryResultIterator &queryResult ) - { - MetaObjectList result; - - while( queryResult.next() ) - parseOne( queryResult, result ); - - Q_EMIT newResultReady( result ); - } -}; - -typedef NepomukObjectParser< Meta::TrackList > NepomukTrackParser; -typedef NepomukObjectParser< Meta::ArtistList > NepomukArtistParser; -typedef NepomukObjectParser< Meta::AlbumList > NepomukAlbumParser; -typedef NepomukObjectParser< Meta::GenreList > NepomukGenreParser; -typedef NepomukObjectParser< Meta::ComposerList > NepomukComposerParser; -typedef NepomukObjectParser< Meta::YearList > NepomukYearParser; -typedef NepomukObjectParser< QStringList > NepomukCustomParser; -typedef NepomukObjectParser< Meta::LabelList > NepomukLabelParser; - -} - -#endif // AMAROK_COLLECTION_NEPOMUKPARSER_H diff --git a/src/core-impl/collections/nepomukcollection/NepomukQueryMaker.cpp b/src/core-impl/collections/nepomukcollection/NepomukQueryMaker.cpp deleted file mode 100644 index 54a2f2f9b8..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukQueryMaker.cpp +++ /dev/null @@ -1,736 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Edward Toroshchin - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NepomukQueryMaker.h" - -#include "NepomukInquirer.h" -#include "NepomukParser.h" -#include "NepomukSelectors.h" - -#include "meta/NepomukAlbum.h" -#include "meta/NepomukArtist.h" -#include "meta/NepomukComposer.h" -#include "meta/NepomukTrack.h" - -#include "core/support/Debug.h" - -#include -#include - -#include - -namespace Collections { - -/** - * This class holds private data for a NepomukQueryMaker instance and provides - * some helper routines. - */ -class NepomukQueryMakerPrivate -{ -public: - QString info; ///< a text description of the query (for debug purposes) - QueryMaker::QueryType type; - QStringList customSelectors; ///< SPARQL selectors for custom queries @see constructQuery - QString filters; ///< SPARQL filters - bool filterNeedsConjunction; ///< true, if a logical operator (AND or OR) must be added to filters - QString extra; ///< extra SPARQL clauses (ORDER BY, LIMIT, etc.) - QStack logic; ///< stack of logic operators (AND or OR) @see popLogic and pushLogic - bool distinct; ///< if a "DISTINCT" operator must be present in the SPARQL query - - /** - * @return a text representation of SPARQL selectors for the current query - * type - */ - QString constructSelector(); - - /** - * @return the final SPARQL query - */ - QString constructQuery(); - - /** - * Convert a single Meta::val* value to a SPARQL selector. - * - * Won't (and shouldn't) work for a mask of Meta::val* values. - */ - QString valueToSelector(qint64 value); - - /** - * Convert a ReturnFunction type to a SPARQL function. - */ - QString returnFunctionSelector(QueryMaker::ReturnFunction function, qint64 value); - - /** - * Add a SPARQL filter term to the current filter expression along with - * correct logic operator if needed. - */ - void addFilter(QString); - - /** - * Add a filter term that does not match anything - */ - void matchNothing(); - - /** - * Escape a string literal to be included in a SPARQL query - */ - QString escape(QString); - - /** - * Convert a matchBegin/matchEnd flag combination to a SPARQL logical string - * function, like this: - * - * - !matchBegin && !matchEnd: CONTAINS( haystack, needle ) - * - !matchBegin && matchEnd: STRENDS( haystack, needle ) - * - matchBegin && !matchEnd: STRSTARTS( haystack, needle ) - * - matchBegin && matchEnd: haystack = needle - * - * The result is returned as a string with "%1" and "%2" placeholders for - * the haystack and the needle respectively. - */ - QString stringOperation(bool matchBegin, bool matchEnd); - - /** - * Convert a NumberComparison operator to a SPARQL operator - */ - QString numberOperator(QueryMaker::NumberComparison); - - /** - * Begin a new filtering subexpression with the given logical operator. - * - * All filtration terms added by subsequent calls to addFilter() will be - * enclosed in braces and separated by the given operator. - * - * Example: - * - * pushLogic("OR") - * addFilter("a") - * pushLogic("AND") - * addFilter("b") - * addFilter("c") - * popLogic() - * popLogic() - * - * will yield the following filter expression: - * - * (a OR (b AND c)) - */ - void pushLogic(QString oper); - - /** - * End a filtering subexpression. - * - * @see pushLogic - */ - void popLogic(); - - NepomukInquirer *inquirer; -}; - -QString -NepomukQueryMakerPrivate::constructSelector() -{ - // These are different SPARQL selectors for different sets of data - // Q macro is a question mark ("track" is a name, "?track" is a selector) - static const QString trackSelector(Q NS_track " " Q NS_trackTitle " " Q NS_trackUrl " " - Q NS_trackType " (concat(str(" Q NS_trackLengthSeconds "), \"000\") AS " Q NS_trackLength ") " // don't ask - "(" Q NS_trackBitrateBPS " / 1000 AS " Q NS_trackBitrate ") " - Q NS_trackNumber " " Q NS_trackBPM " " Q NS_trackComment " " - Q NS_trackSampleRate " " Q NS_trackFileSize " " - Q NS_trackGain " " Q NS_trackPeakGain " " - Q NS_trackModifyDate " " Q NS_trackCreateDate " "); - static const QString artistSelector(Q NS_artist " " Q NS_artistName " "); - static const QString albumSelector(Q NS_album " " Q NS_albumTitle " " Q NS_albumGain " " Q NS_albumPeakGain " "); - static const QString genreSelector(Q NS_genre " "); - static const QString composerSelector(Q NS_composer " " Q NS_composerName " "); - static const QString yearSelector(Q NS_date " (IF( bound(" Q NS_date "), year(" Q NS_date "), 0 ) AS " Q NS_year ") "); - - static const QString allSelector( trackSelector - + artistSelector - + albumSelector - + genreSelector - + composerSelector - + yearSelector ); - - switch(type) - { - case QueryMaker::None: - return QString(); - case QueryMaker::Track: - return allSelector; - case QueryMaker::Artist: - return artistSelector; - case QueryMaker::Album: - return albumSelector; - case QueryMaker::AlbumArtist: - return artistSelector; - case QueryMaker::Genre: - return genreSelector; - case QueryMaker::Composer: - return composerSelector; - case QueryMaker::Year: - return yearSelector; - case QueryMaker::Custom: - return customSelectors.join(" "); - case QueryMaker::Label: - return QString(); - } - warning() << "unknown QueryMaker type " << type; - return QString(); -} - -QString -NepomukQueryMakerPrivate::constructQuery() -{ - // This is the big SPARQL relationship constraint clause that defines all - // the relationships between objects we want to know about. Basically this - // defines the semantics of the SPARQL selectors we're using everywhere - // Q macro is a question mark ("track" is a name, "?track" is a selector) - static const QString queryTemplate( - "SELECT %1 {" - " " Q NS_track " a nfo:Audio ;" - " nie:title " Q NS_trackTitle " ;" - " nie:url " Q NS_trackUrl " ." - " OPTIONAL { " Q NS_track " nmm:performer " Q NS_artist " ." - " " Q NS_artist " nco:fullname " Q NS_artistName " . }" - " OPTIONAL { " Q NS_track " nmm:musicAlbum " Q NS_album " ." - " " Q NS_album " nie:title " Q NS_albumTitle " ." - " OPTIONAL { " Q NS_album " nmm:albumGain " Q NS_albumGain " . }" - " OPTIONAL { " Q NS_album " nmm:albumPeakGain " Q NS_albumPeakGain " . } }" - " OPTIONAL { " Q NS_track " nmm:genre " Q NS_genre " . }" - " OPTIONAL { " Q NS_track " nmm:composer " Q NS_composer " ." - " " Q NS_composer " nco:fullname " Q NS_composerName " . }" - " OPTIONAL { " Q NS_track " nmm:releaseDate " Q NS_year " . }" - " OPTIONAL { " Q NS_track " nfo:codec " Q NS_trackType " . }" - " OPTIONAL { " Q NS_track " nfo:duration " Q NS_trackLengthSeconds " . }" - " OPTIONAL { " Q NS_track " nfo:averageBitrate " Q NS_trackBitrateBPS " . }" - " OPTIONAL { " Q NS_track " nmm:trackNumber " Q NS_trackNumber " . }" - " OPTIONAL { " Q NS_track " nmm:beatsPerMinute " Q NS_trackBPM " . }" - " OPTIONAL { " Q NS_track " nie:comment " Q NS_trackComment " . }" - " OPTIONAL { " Q NS_track " nfo:sampleRate " Q NS_trackSampleRate " . }" - " OPTIONAL { " Q NS_track " nfo:fileSize " Q NS_trackFileSize " . }" - " OPTIONAL { " Q NS_track " nie:contentSize " Q NS_trackFileSize " . }" - " OPTIONAL { " Q NS_track " nmm:trackGain " Q NS_trackGain " . }" - " OPTIONAL { " Q NS_track " nmm:trackPeakGain " Q NS_trackPeakGain " . }" - " OPTIONAL { " Q NS_track " nie:modified " Q NS_trackModifyDate " . }" - " OPTIONAL { " Q NS_track " nie:created " Q NS_trackCreateDate " . }" - " %2 " // a placeholder for filter expression - " }" ); - - // This is a special query for labels - static const QString labelQueryTemplate( - "SELECT DISTINCT " Q NS_tag " " Q NS_tagLabel " {" - " " Q NS_track " a nfo:Audio ." - " " Q NS_track " nao:hasTag " Q NS_tag " ." - " " Q NS_tag " nao:prefLabel " Q NS_tagLabel " ." - " }" ); - - if( type == QueryMaker::None ) - { - error() << "requested to perform a none-query"; - return QString(); - } - else if( type == QueryMaker::Label ) - { - return labelQueryTemplate; - } - - QString filter; - if( !filters.isEmpty() ) filter = QString( "FILTER( %1 )" ).arg( filters ); - - QString selector( constructSelector() ); - - if( distinct ) - selector = QString("DISTINCT ") + selector; - - return queryTemplate.arg(selector).arg(filter) + extra; -} - -/** - * Helper class to construct the map in valueToSelector - */ -template< class K, class V > -class ConstMap: public QHash< K, V > -{ -public: - inline ConstMap &add( const K &key, const V &val ) - { - this->insert( key, val ); - return *this; - } -}; - -QString -NepomukQueryMakerPrivate::valueToSelector(qint64 bitValue) -{ - typedef ConstMap< qint64, QString > ValueMap; - static const ValueMap map = ValueMap() - .add( Meta::valUrl, Q NS_trackUrl ) - .add( Meta::valTitle, Q NS_trackTitle ) - .add( Meta::valArtist, Q NS_artistName ) - .add( Meta::valAlbum, Q NS_albumTitle ) - .add( Meta::valGenre, Q NS_genre ) - .add( Meta::valComposer, Q NS_composerName ) - .add( Meta::valYear, "IF( bound(" Q NS_date "), year(" Q NS_date "), 0 )" ) - .add( Meta::valComment, Q NS_trackComment ) - .add( Meta::valTrackNr, Q NS_trackNumber ) - .add( Meta::valDiscNr, Q NS_trackDiscNumber ) - .add( Meta::valBpm, Q NS_trackBPM ) - .add( Meta::valLength, "(concat(str(" Q NS_trackLengthSeconds "), \"000\"))" ) // I said, don't ask - .add( Meta::valBitrate, "(" Q NS_trackBitrateBPS " / 1000)" ) - .add( Meta::valSamplerate, Q NS_trackSampleRate ) - .add( Meta::valFilesize, Q NS_trackFileSize ) - .add( Meta::valFormat, Q NS_trackType ) - .add( Meta::valCreateDate, Q NS_trackCreateDate ) - .add( Meta::valScore, Q NS_trackScore ) - .add( Meta::valRating, Q NS_trackRating ) - .add( Meta::valFirstPlayed, Q NS_trackFirstPlayed ) - .add( Meta::valLastPlayed, Q NS_trackLastPlayed ) - .add( Meta::valPlaycount, Q NS_trackPlaycount ) - .add( Meta::valUniqueId, "STR(" Q NS_track ")" ) - .add( Meta::valTrackGain, Q NS_trackGain ) - .add( Meta::valTrackGainPeak, Q NS_trackPeakGain ) - .add( Meta::valAlbumGain, Q NS_albumGain ) - .add( Meta::valAlbumGainPeak, Q NS_albumPeakGain ) - .add( Meta::valAlbumArtist, Q NS_albumArtist ) - .add( Meta::valLabel, Q NS_label ) - .add( Meta::valModified, Q NS_trackModifyDate ); - - return map.value( bitValue, Q NS__unknownValue ); // this will be just an unset SPARQL selector (e.g. NULL values) -} - -QString -NepomukQueryMakerPrivate::returnFunctionSelector(QueryMaker::ReturnFunction function, qint64 value) -{ - QString valSelector(valueToSelector(value)); - - if( valSelector != Q NS__unknownValue ) - { - switch(function) - { - case QueryMaker::Count: - return QString("COUNT(DISTINCT %1)").arg(valSelector); - case QueryMaker::Sum: - return QString("SUM(%1)").arg(valSelector); - case QueryMaker::Max: - return QString("MAX(%1)").arg(valSelector); - case QueryMaker::Min: - return QString("MIN(%1)").arg(valSelector); - } - } - return Q NS__unknownFunction; -} - -void -NepomukQueryMakerPrivate::addFilter( QString expression ) -{ - if( filterNeedsConjunction ) - filters += logic.top(); - filters += expression; - filterNeedsConjunction = true; -} - -void -NepomukQueryMakerPrivate::matchNothing() -{ - filters = '0'; - filterNeedsConjunction = true; -} - -QString -NepomukQueryMakerPrivate::escape( QString string ) -{ - return QString("\"\"\"%1\"\"\"").arg(string); // TODO: use some actual function from Nepomuk API -} - -QString -NepomukQueryMakerPrivate::stringOperation(bool matchBegin, bool matchEnd) -{ - // We'll convert matchBegin and matchEnd to an index in the following array: - // - static const QString map[] = { "CONTAINS( str(%1), %2 )", // 0 0 - "STRENDS( str(%1), %2 )", // 0 1 - "STRSTARTS( str(%1), %2 )", // 1 0 - "str(%1) = %2" }; // 1 1 - return map[ !!matchBegin * 2 + !!matchEnd ]; -} - -QString -NepomukQueryMakerPrivate::numberOperator(QueryMaker::NumberComparison oper) -{ - switch( oper ) - { - case QueryMaker::GreaterThan: - return ">"; - case QueryMaker::LessThan: - return "<"; - case QueryMaker::Equals: - return "="; - } - warning() << "unknown number comparison" << oper; - return "="; // couldn't be worse -} - -void -NepomukQueryMakerPrivate::pushLogic( QString oper ) -{ - if( filterNeedsConjunction ) - filters += logic.top(); - filters += '('; - logic.push( QString(" %1 ").arg( oper ) ); - filterNeedsConjunction = false; -} - -void -NepomukQueryMakerPrivate::popLogic() -{ - filters += ')'; - logic.pop(); -} - -NepomukQueryMaker::NepomukQueryMaker( NepomukCollection *collection ) - : d(new NepomukQueryMakerPrivate) - , myCollection( collection ) -{ - Q_ASSERT( collection ); - - d->type = QueryType(0); - d->filterNeedsConjunction = false; - d->inquirer = 0; - d->logic.push(" && "); - d->distinct = true; -} - -NepomukQueryMaker::~NepomukQueryMaker() -{ - delete d; - d = 0; -} - -void -NepomukQueryMaker::abortQuery() -{ - // TODO -} - -void -NepomukQueryMaker::run() -{ - DEBUG_BLOCK - debug() << "running the following query" << d->info; - - QString query(d->constructQuery()); - debug() << "translated into" << query; - - std::auto_ptr parser; - - switch(d->type) - { - case None: - debug() << "QueryMaker requested to run a None-query"; - break; - case Track: - parser.reset( new NepomukTrackParser( myCollection ) ); - connect(parser.get(), SIGNAL(newResultReady(Meta::TrackList)), - SIGNAL(newResultReady(Meta::TrackList))); - break; - case Artist: - parser.reset( new NepomukArtistParser( myCollection ) ); - connect(parser.get(), SIGNAL(newResultReady(Meta::ArtistList)), - SIGNAL(newResultReady(Meta::ArtistList))); - break; - case Album: - parser.reset( new NepomukAlbumParser( myCollection ) ); - connect(parser.get(), SIGNAL(newResultReady(Meta::AlbumList)), - SIGNAL(newResultReady(Meta::AlbumList))); - break; - case AlbumArtist: - parser.reset( new NepomukArtistParser( myCollection ) ); - connect(parser.get(), SIGNAL(newResultReady(Meta::ArtistList)), - SIGNAL(newResultReady(Meta::ArtistList))); - break; - case Genre: - parser.reset( new NepomukGenreParser( myCollection ) ); - connect(parser.get(), SIGNAL(newResultReady(Meta::GenreList)), - SIGNAL(newResultReady(Meta::GenreList))); - break; - case Composer: - parser.reset( new NepomukComposerParser( myCollection ) ); - connect(parser.get(), SIGNAL(newResultReady(Meta::ComposerList)), - SIGNAL(newResultReady(Meta::ComposerList))); - break; - case Year: - parser.reset( new NepomukYearParser( myCollection ) ); - connect(parser.get(), SIGNAL(newResultReady(Meta::YearList)), - SIGNAL(newResultReady(Meta::YearList))); - break; - case Custom: - parser.reset( new NepomukCustomParser( myCollection ) ); - connect(parser.get(), SIGNAL(newResultReady(QStringList)), - SIGNAL(newResultReady(QStringList))); - break; - case Label: - parser.reset( new NepomukLabelParser( myCollection ) ); - connect(parser.get(), SIGNAL(newResultReady(Meta::LabelList)), - SIGNAL(newResultReady(Meta::LabelList))); - break; - } - - if( !parser.get() ) - { - emit queryDone(); - return; - } - - d->inquirer = new NepomukInquirer(query, parser); - connect(d->inquirer, &ThreadWeaver::Job::done, SLOT(inquirerDone())); - ThreadWeaver::Queue::instance()->enqueue( QSharedPointer(d->inquirer) ); -} - -QueryMaker* -NepomukQueryMaker::setQueryType( QueryType type ) -{ - d->type = type; - d->info += QString("[type %1] ").arg(type); - return this; -} - -QueryMaker* -NepomukQueryMaker::addMatch( const Meta::TrackPtr &track ) -{ - d->info += QString("[match track %1] ").arg(track->prettyName()); - if( track ) - d->addFilter( QString(Q NS_track " = <%1>").arg(track->uidUrl()) ); - else - d->matchNothing(); - return this; -} - -QueryMaker* -NepomukQueryMaker::addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour ) -{ - d->info += QString("[match %1 artist %2] ").arg(behaviour).arg(artist->prettyName()); - if( behaviour == TrackArtists || behaviour == AlbumOrTrackArtists ) - { - if( artist ) - { - const Meta::NepomukArtist *nartist = dynamic_cast( artist.data() ); - if( nartist ) - d->addFilter( QString("bound(" Q NS_artist ") && " Q NS_artist " = <%1>").arg( nartist->resourceUri().toString() ) ); - else - d->addFilter( QString("bound(" Q NS_artistName ") && str(" Q NS_artistName ") = %1").arg( d->escape( artist->name() ) ) ); - return this; - } - else - d->addFilter( "!bound(" Q NS_artist ")" ); - } - else - { - if( artist ) - d->matchNothing(); // TODO add album artist matching behavior - } - return this; -} - -QueryMaker* -NepomukQueryMaker::addMatch( const Meta::AlbumPtr &album ) -{ - d->info += QString("[match album %1] ").arg(album? album->prettyName() : "0"); - if( album ) - { - const Meta::NepomukAlbum *nalbum = dynamic_cast( album.data() ); - if( nalbum ) - d->addFilter( QString("bound(" Q NS_album ") && " Q NS_album " = <%1>").arg( nalbum->resourceUri().toString() ) ); - else - // TODO: fix album matching once album artists are supported by Nepomuk - d->addFilter( QString("bound(" Q NS_albumTitle ") && str(" Q NS_albumTitle ") = %1").arg( d->escape( album->name() ) ) ); - return this; - } - else - d->addFilter( "!bound(" Q NS_album ")" ); - return this; -} - -QueryMaker* -NepomukQueryMaker::addMatch( const Meta::ComposerPtr &composer ) -{ - d->info += QString("[match composer %1] ").arg(composer->prettyName()); - if( composer ) - { - const Meta::NepomukComposer *ncomposer = dynamic_cast( composer.data() ); - if( ncomposer ) - d->addFilter( QString("bound(" Q NS_composer ") && " Q NS_composer " = <%1>").arg( ncomposer->resourceUri().toString() ) ); - else - d->addFilter( QString("bound(" Q NS_composerName ") && str(" Q NS_composerName ") = %1").arg( d->escape( composer->name() ) ) ); - return this; - } - else - d->addFilter( "!bound(" Q NS_composer ")" ); - return this; -} - -QueryMaker* -NepomukQueryMaker::addMatch( const Meta::GenrePtr &genre ) -{ - d->info += QString("[match genre %1] ").arg(genre->prettyName()); - if( genre ) - d->addFilter( QString( "bound(" Q NS_genre ") && str(" Q NS_genre ") = %1" ).arg( d->escape( genre->name() ) ) ); - else - d->addFilter( "!bound(" Q NS_genre ")" ); - return this; -} - -QueryMaker* -NepomukQueryMaker::addMatch( const Meta::YearPtr &year ) -{ - d->info += QString("[match year %1] ").arg(year->prettyName()); - if( year->year() ) - d->addFilter( QString( "bound(" Q NS_date ") && year(" Q NS_date ") = %1" ).arg( year->year() ) ); - else - d->addFilter( "!bound(" Q NS_date ")" ); - return this; -} - -QueryMaker* -NepomukQueryMaker::addMatch( const Meta::LabelPtr &label ) -{ - d->info += QString("[match label %1] ").arg(label->prettyName()); - if( label ) - d->addFilter( QString( "EXISTS { " Q NS_track " nao:hasTag " Q NS_tag " . " Q NS_tag " nao:prefLabel %1 . }" ).arg( label->name() ) ); - else - d->addFilter( "NOT EXISTS { " Q NS_track " nao:hasTag " Q NS_tag " . }" ); - return this; -} - -QueryMaker* -NepomukQueryMaker::addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ - d->info += QString("[filter %1 %2 begin(%3) end(%4)] ").arg(value).arg(filter).arg(matchBegin).arg(matchEnd); - d->addFilter( d->stringOperation( matchBegin, matchEnd ).arg( d->valueToSelector( value ), - d->escape( filter ) ) ); - return this; -} - -QueryMaker* -NepomukQueryMaker::excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ - d->info += QString("[exclude %1 %2 begin(%3) end(%4)] ").arg(value).arg(filter).arg(matchBegin).arg(matchEnd); - d->addFilter( QString("!(%1)").arg( d->stringOperation( matchBegin, matchEnd ).arg( d->valueToSelector( value ), - d->escape( filter ) ) ) ); - return this; -} - -QueryMaker* -NepomukQueryMaker::addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) -{ - d->info += QString("[filter %1 %2 (%3)] ").arg(value).arg(filter).arg(compare); - d->addFilter( QString("%1 %2 %3").arg( d->valueToSelector( value ) ) - .arg( d->numberOperator( compare ) ) - .arg( filter ) ); - return this; -} - -QueryMaker* -NepomukQueryMaker::excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) -{ - d->info += QString("[exclude %1 %2 (%3)] ").arg(value).arg(filter).arg(compare); - d->addFilter( QString("!( %1 %2 %3 )").arg( d->valueToSelector( value ) ) - .arg( d->numberOperator( compare ) ) - .arg( filter ) ); - return this; -} - -QueryMaker* -NepomukQueryMaker::addReturnValue( qint64 value ) -{ - d->info += QString("[return %1] ").arg(value); - d->customSelectors << d->valueToSelector(value); - return this; -} - -QueryMaker* -NepomukQueryMaker::addReturnFunction( ReturnFunction function, qint64 value ) -{ - d->info += QString("[return %1(%2)] ").arg(function).arg(value); - d->customSelectors << d->returnFunctionSelector(function, value); - d->distinct = false; - return this; -} - -QueryMaker* -NepomukQueryMaker::orderBy( qint64 value, bool descending ) -{ - d->info += QString("[order %1(%2)] ").arg(value).arg(descending); - d->extra += QString(" ORDER BY %1").arg( d->valueToSelector( value ) ); - return this; -} - -QueryMaker* -NepomukQueryMaker::limitMaxResultSize( int size ) -{ - d->info += QString("[limit %1] ").arg(size); - d->extra += QString(" LIMIT %1").arg( size ); - return this; -} - -QueryMaker* -NepomukQueryMaker::setAlbumQueryMode( AlbumQueryMode mode ) -{ - // TODO - d->info += QString("[album mode %1] ").arg(mode); - return this; -} - -QueryMaker* -NepomukQueryMaker::setLabelQueryMode( LabelQueryMode mode ) -{ - // TODO - d->info += QString("[label mode %1] ").arg(mode); - return this; -} - -QueryMaker* -NepomukQueryMaker::beginAnd() -{ - d->info += QString("(AND "); - d->pushLogic("&&"); - return this; -} - -QueryMaker* -NepomukQueryMaker::beginOr() -{ - d->info += QString("(OR "); - d->pushLogic("||"); - return this; -} - -QueryMaker* -NepomukQueryMaker::endAndOr() -{ - d->info += QString(") "); - d->popLogic(); - return this; -} - -void -NepomukQueryMaker::inquirerDone() -{ - d->inquirer->deleteLater(); - emit queryDone(); -} - -} //namespace Collections diff --git a/src/core-impl/collections/nepomukcollection/NepomukQueryMaker.h b/src/core-impl/collections/nepomukcollection/NepomukQueryMaker.h deleted file mode 100644 index 00146eeb3a..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukQueryMaker.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Edward Toroshchin - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_NEPOMUKQUERYMAKER_H -#define AMAROK_COLLECTION_NEPOMUKQUERYMAKER_H - -#include "core/collections/QueryMaker.h" - -namespace Collections { - -class NepomukCollection; - -class NepomukQueryMakerPrivate; - -/** - * This class implements a QueryMaker for a given NepomukCollection. - */ -class NepomukQueryMaker : public QueryMaker -{ - Q_OBJECT - - NepomukQueryMakerPrivate *d; - NepomukCollection *myCollection; - -public: - explicit NepomukQueryMaker( NepomukCollection *collection ); - virtual ~NepomukQueryMaker(); - - virtual void abortQuery(); - virtual void run(); - - virtual QueryMaker *setQueryType( QueryType type ); - - virtual QueryMaker *addMatch( const Meta::TrackPtr &track ); - virtual QueryMaker *addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ); - virtual QueryMaker *addMatch( const Meta::AlbumPtr &album ); - virtual QueryMaker *addMatch( const Meta::ComposerPtr &composer ); - virtual QueryMaker *addMatch( const Meta::GenrePtr &genre ); - virtual QueryMaker *addMatch( const Meta::YearPtr &year ); - virtual QueryMaker *addMatch( const Meta::LabelPtr &label ); - - virtual QueryMaker *addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); - virtual QueryMaker *excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); - - virtual QueryMaker *addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ); - virtual QueryMaker *excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ); - - virtual QueryMaker *addReturnValue( qint64 value ); - virtual QueryMaker *addReturnFunction( ReturnFunction function, qint64 value ); - virtual QueryMaker *orderBy( qint64 value, bool descending = false ); - - virtual QueryMaker *limitMaxResultSize( int size ); - - virtual QueryMaker *setAlbumQueryMode( AlbumQueryMode mode ); - virtual QueryMaker *setLabelQueryMode( LabelQueryMode mode ); - - virtual QueryMaker *beginAnd(); - virtual QueryMaker *beginOr(); - virtual QueryMaker *endAndOr(); - -private Q_SLOTS: - void inquirerDone(); -}; - -} //namespace Collections - -#endif diff --git a/src/core-impl/collections/nepomukcollection/NepomukSelectors.h b/src/core-impl/collections/nepomukcollection/NepomukSelectors.h deleted file mode 100644 index ee1454c3e9..0000000000 --- a/src/core-impl/collections/nepomukcollection/NepomukSelectors.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Edward Toroshchin - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_NEPOMUKSELECTORS_H -#define AMAROK_COLLECTION_NEPOMUKSELECTORS_H - -#ifdef Q -#error "someone has already defined a macro named Q, this is bad" -#endif - -#define Q "?" - -#define NS_album "album" -#define NS_albumArtist "albumArtist" -#define NS_albumGain "albumGain" -#define NS_albumPeakGain "albumPeakGain" -#define NS_albumTitle "albumTitle" -#define NS_artist "artist" -#define NS_artistName "artistName" -#define NS_composer "composer" -#define NS_composerName "composerName" -#define NS_date "date" -#define NS_genre "genre" -#define NS_label "label" -#define NS_tag "tag" -#define NS_tagLabel "tagLabel" -#define NS_track "track" -#define NS_trackBitrate "trackBitrate" -#define NS_trackBitrateBPS "trackBitrateBPS" -#define NS_trackBPM "trackBPM" -#define NS_trackComment "trackComment" -#define NS_trackCreateDate "trackCreateDate" -#define NS_trackDiscNumber "trackDiscNumber" -#define NS_trackFileSize "trackFileSize" -#define NS_trackFirstPlayed "trackFirstPlayed" -#define NS_trackGain "trackGain" -#define NS_trackLastPlayed "trackLastPlayed" -#define NS_trackLength "trackLength" -#define NS_trackLengthSeconds "trackLengthSeconds" -#define NS_trackModifyDate "trackModifyDate" -#define NS_trackNumber "trackNumber" -#define NS_trackPeakGain "trackPeakGain" -#define NS_trackPlaycount "trackPlaycount" -#define NS_trackRating "trackRating" -#define NS_trackSampleRate "trackSampleRate" -#define NS_trackScore "trackScore" -#define NS_trackTitle "trackTitle" -#define NS_trackType "trackType" -#define NS_trackUrl "trackUrl" -#define NS_year "year" - -#define NS__unknownFunction "_unknownFunction" -#define NS__unknownValue "_unknownValue" - -#endif // AMAROK_COLLECTION_NEPOMUKSELECTORS_H diff --git a/src/core-impl/collections/nepomukcollection/amarok_collection-nepomukcollection.desktop b/src/core-impl/collections/nepomukcollection/amarok_collection-nepomukcollection.desktop deleted file mode 100644 index e856663891..0000000000 --- a/src/core-impl/collections/nepomukcollection/amarok_collection-nepomukcollection.desktop +++ /dev/null @@ -1,75 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=nepomuk -Name=Nepomuk Collection -Name[be]=Калекцыя Nepomuk -Name[bg]=Колекция Nepomuk -Name[bs]=Nepomuk zbirka -Name[ca]=Col·lecció Nepomuk -Name[ca@valencia]=Col·lecció Nepomuk -Name[cs]=Sbírka Nepomuku -Name[csb]=Kòlekcëjô Nepomuka -Name[da]=Nepomuk-samling -Name[de]=Nepomuk-Sammlung -Name[el]=Συλλογή Nepomuk -Name[en_GB]=Nepomuk Collection -Name[es]=Colección Nepomuk -Name[et]=Nepomuki kogu -Name[eu]=Nepomuk bilduma -Name[fi]=Nepomuk-kokoelma -Name[fr]=Collection « Nepomuk » -Name[ga]=Bailiúchán Nepomuk -Name[gl]=Colección de Nepomuk -Name[he]=אוסף Nepomuk -Name[hne]=नेपोमक संग्रह -Name[hu]=Nepomuk-gyűjtemény -Name[id]=Koleksi Nepomuk -Name[is]=Nepomuk safn -Name[it]=Collezione Nepomuk -Name[ja]=Nepomuk コレクション -Name[km]=សម្រាំង Nepomuk -Name[ko]=Nepomuk 모음집 -Name[ku]=Berhevoka Nepomuk ji bo Amarok -Name[lt]=Nepomuk fonoteka -Name[lv]=Nepomuk kolekcija -Name[nb]=Nepomuk samling -Name[nds]=Nepomuk-Sammeln -Name[nl]=Nepomuk-verzameling -Name[nn]=Nepomuk-samling -Name[pa]=ਨਿਪੁਮੂਕ ਭੰਡਾਰ -Name[pl]=Zbiór Nepomuk -Name[pt]=Colecção do Nepomuk -Name[pt_BR]=Coleção Nepomuk -Name[ro]=Colecție Nepomuk -Name[ru]=Коллекция Nepomuk -Name[sk]=Kolekcia Nepomuk -Name[sl]=Zbirka Nepomuk -Name[sr]=Непомук збирка -Name[sr@ijekavian]=Непомук збирка -Name[sr@ijekavianlatin]=Nepomuk zbirka -Name[sr@latin]=Nepomuk zbirka -Name[sv]=Nepomuk-samling -Name[th]=คลังสื่อของ Nepomuk -Name[tr]=Nepomuk Koleksiyonu -Name[uk]=Збірка Nepomuk -Name[wa]=Ramexhnêye Nepomuk -Name[x-test]=xxNepomuk Collectionxx -Name[zh_TW]=Nepomuk 收藏 - - -ServiceTypes=Amarok/Plugin - -X-KDE-PluginInfo-Author=Phalgun Guduthur -X-KDE-PluginInfo-Email=me@phalgun.in -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Collection -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=false -X-KDE-PluginInfo-Name=amarok_collection-nepomukcollection -X-KDE-Library=amarok_collection-nepomukcollection -X-KDE-Amarok-authors=Phalgun Guduthur -X-KDE-Amarok-email=me@phalgun.in -X-KDE-Amarok-framework-version=73 -X-KDE-Amarok-name=nepomuk-collection -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukAlbum.cpp b/src/core-impl/collections/nepomukcollection/meta/NepomukAlbum.cpp deleted file mode 100644 index b2291129e8..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukAlbum.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NepomukAlbum.h" - -#include "core/meta/Meta.h" - -using namespace Meta; - -NepomukAlbum::NepomukAlbum( const QUrl &resourceUri ) - : m_resource( resourceUri ) -{ -} - -TrackList -NepomukAlbum::tracks() -{ - return TrackList(); // TODO -} - -QString -NepomukAlbum::name() const -{ - return m_name; -} diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukAlbum.h b/src/core-impl/collections/nepomukcollection/meta/NepomukAlbum.h deleted file mode 100644 index a0c73edeaa..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukAlbum.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NEPOMUKALBUM_H -#define NEPOMUKALBUM_H - -#include "core/meta/Meta.h" - -#include - -namespace Meta -{ -/** - * Represents a unit album resource in Amarok - */ -class NepomukAlbum : public Album -{ -public: - explicit NepomukAlbum( const QUrl &resourceUri ); - - /* Nepomuk does not support album artists and compilations */ - /* TODO: fix this once it actually does */ - virtual bool isCompilation() const { return false; } - virtual bool hasAlbumArtist() const { return false; } - virtual ArtistPtr albumArtist() const { return ArtistPtr(); } - - virtual TrackList tracks(); - virtual QString name() const; - - bool isFilled() const { return !m_name.isEmpty(); } - - void fill( const QString &name ) { m_name = name; } - - QUrl resourceUri() const { return m_resource; } - -private: - QUrl m_resource; - QString m_name; -}; - -} -#endif /*NEPOMUKALBUM_H*/ diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukArtist.cpp b/src/core-impl/collections/nepomukcollection/meta/NepomukArtist.cpp deleted file mode 100644 index 205f9dbe73..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukArtist.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NepomukArtist.h" - -#include "core/meta/Meta.h" - -using namespace Meta; - -NepomukArtist::NepomukArtist( const QUrl &resourceUri ) - : m_resource( resourceUri ) -{ -} - -TrackList -NepomukArtist::tracks() -{ - return TrackList(); // TODO -} diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukArtist.h b/src/core-impl/collections/nepomukcollection/meta/NepomukArtist.h deleted file mode 100644 index bf0fa2b7db..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukArtist.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NEPOMUKARTIST_H -#define NEPOMUKARTIST_H - -#include "core/meta/Meta.h" - -#include - -namespace Meta -{ -/** - * Represents a unit artist resource in Amarok - */ -class NepomukArtist : public Artist -{ -public: - explicit NepomukArtist( const QUrl &resourceUri ); - - virtual TrackList tracks(); - virtual QString name() const { return m_name; } - - bool isFilled() const { return !m_name.isEmpty(); } - - void fill( const QString &name ) { m_name = name; } - - QUrl resourceUri() const { return m_resource; } - -private: - QUrl m_resource; - QString m_name; -}; - -} -#endif // NEPOMUKARTIST_H diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukComposer.cpp b/src/core-impl/collections/nepomukcollection/meta/NepomukComposer.cpp deleted file mode 100644 index 0c986a01ae..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukComposer.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NepomukComposer.h" - -#include "core/meta/Meta.h" - -using namespace Meta; - -NepomukComposer::NepomukComposer( const QUrl &resourceUri ) - : m_resource( resourceUri ) -{ -} - -TrackList -NepomukComposer::tracks() -{ - return TrackList(); // TODO -} - -QString -NepomukComposer::name() const -{ - return m_name; -} diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukComposer.h b/src/core-impl/collections/nepomukcollection/meta/NepomukComposer.h deleted file mode 100644 index cd104d08b8..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukComposer.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NEPOMUKCOMPOSER_H -#define NEPOMUKCOMPOSER_H - -#include "core/meta/Meta.h" - -#include - -namespace Meta -{ -/** - * Represents a unit composer resource in Amarok - */ -class NepomukComposer : public Composer -{ -public: - explicit NepomukComposer( const QUrl &resourceUri ); - - virtual TrackList tracks(); - virtual QString name() const; - - bool isFilled() const { return !m_name.isEmpty(); } - - void fill( const QString &name ) { m_name = name; } - - QUrl resourceUri() const { return m_resource; } - -private: - QUrl m_resource; - QString m_name; -}; - -} -#endif // NEPOMUKCOMPOSER_H diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukGenre.cpp b/src/core-impl/collections/nepomukcollection/meta/NepomukGenre.cpp deleted file mode 100644 index 6b0d799633..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukGenre.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NepomukGenre.h" - -#include "core/meta/Meta.h" - -using namespace Meta; - -NepomukGenre::NepomukGenre( const QString &name ) - : m_name( name ) -{ -} - -TrackList -NepomukGenre::tracks() -{ - return TrackList(); // TODO -} - -QString -NepomukGenre::name() const -{ - return m_name; -} diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukGenre.h b/src/core-impl/collections/nepomukcollection/meta/NepomukGenre.h deleted file mode 100644 index 232de9fcbb..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukGenre.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NEPOMUKGENRE_H -#define NEPOMUKGENRE_H - -#include "core/meta/Meta.h" - -namespace Meta -{ -/** - * Represents a unit genre resource in Amarok - */ -class NepomukGenre : public Genre -{ -public: - explicit NepomukGenre( const QString &name ); - virtual TrackList tracks(); - virtual QString name() const; - -private: - QString m_name; -}; - -} -#endif // NEPOMUKGENRE_H diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukLabel.cpp b/src/core-impl/collections/nepomukcollection/meta/NepomukLabel.cpp deleted file mode 100644 index dbdf1f8d11..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukLabel.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NepomukLabel.h" - -#include "../NepomukCache.h" -#include "../NepomukCollection.h" - -#include "core/meta/Meta.h" - -#include - -using namespace Meta; - -NepomukLabel::NepomukLabel( const QString &name ) - : m_nepomukTag( new Nepomuk2::Tag ) -{ - m_nepomukTag->setLabel( name ); -} - -NepomukLabel::NepomukLabel( const QUrl &resourceUri ) - : m_nepomukTag( new Nepomuk2::Tag( resourceUri ) ) -{ -} - -NepomukLabel::~NepomukLabel() -{ -} - -QString -NepomukLabel::name() const -{ - return m_nepomukTag->label(); -} - -LabelPtr -NepomukLabel::fromNepomukTag( Collections::NepomukCollection *collection, - const Nepomuk2::Tag &tag ) -{ - if( !collection ) return LabelPtr(); - if( tag.uri().isEmpty() ) return LabelPtr(); - return collection->cache()->getLabel( tag.uri() ); -} diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukLabel.h b/src/core-impl/collections/nepomukcollection/meta/NepomukLabel.h deleted file mode 100644 index 4521c7f536..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukLabel.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NEPOMUKLABEL_H -#define NEPOMUKLABEL_H - -#include "core/meta/Meta.h" - -#include - -namespace Nepomuk2 { class Tag; } - -namespace Collections { class NepomukCollection; } - -namespace Meta -{ -/** - * Represents a unit label/tag resource in Amarok - */ -class NepomukLabel : public Label -{ -public: - explicit NepomukLabel( const QString &name ); - explicit NepomukLabel( const QUrl &resourceUri ); - ~NepomukLabel(); - - virtual QString name() const; - - Nepomuk2::Tag &tag() const { return *m_nepomukTag; } - - static LabelPtr fromNepomukTag( Collections::NepomukCollection *collection, - const Nepomuk2::Tag &tag ); - -private: - QScopedPointer m_nepomukTag; -}; - -} -#endif // NEPOMUKLABEL_H diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukTrack.cpp b/src/core-impl/collections/nepomukcollection/meta/NepomukTrack.cpp deleted file mode 100644 index 51b2d2c4ce..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukTrack.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NepomukTrack.h" - -#include "NepomukCollection.h" -#include "NepomukLabel.h" - -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include -#include -#include -#include -#include -#include - -using namespace Meta; - -NepomukTrack::NepomukTrack( const QUrl &resUri, Collections::NepomukCollection *coll ) - : m_filled( false ) - , m_length( 0 ) - , m_bitrate( 0 ) - , m_trackNumber( 0 ) - , m_discNumber( 0 ) - , m_bpm( 0.0 ) - , m_sampleRate( 0 ) - , m_filesize( 0 ) - , m_trackGain( 0.0 ) - , m_trackPeakGain( 0.0 ) - , m_albumGain( 0.0 ) - , m_albumPeakGain( 0.0 ) - , m_coll( coll ) - , m_resourceUri( resUri ) -{ -} - -NepomukTrack::~NepomukTrack() -{ -} - -QString -NepomukTrack::name() const -{ - return m_name; -} - -QUrl -NepomukTrack::playableUrl() const -{ - return m_playableUrl; -} - -QString -NepomukTrack::prettyUrl() const -{ - return m_playableUrl.path(); -} - -QString -NepomukTrack::uidUrl() const -{ - return m_resourceUri.toString(); -} - -QString -NepomukTrack::notPlayableReason() const -{ - if( !m_playableUrl.isValid() ) - return i18n( "Invalid URL" ); - return QString(); -} - -AlbumPtr -NepomukTrack::album() const -{ - return m_album; -} - -ArtistPtr -NepomukTrack::artist() const -{ - return m_artist; -} - -ComposerPtr -NepomukTrack::composer() const -{ - return m_composer; -} - -GenrePtr -NepomukTrack::genre() const -{ - return m_genre; -} - -YearPtr -NepomukTrack::year() const -{ - return m_year; -} - -qreal -NepomukTrack::bpm() const -{ - return m_bpm; -} - -QString -NepomukTrack::comment() const -{ - return m_comment; -} - -qint64 -NepomukTrack::length() const -{ - - return m_length; -} - -int -NepomukTrack::filesize() const -{ - return m_filesize; -} - -int -NepomukTrack::sampleRate() const -{ - return m_sampleRate; -} - -int -NepomukTrack::bitrate() const -{ - return m_bitrate; -} - -QDateTime -NepomukTrack::createDate() const -{ - return m_createDate; -} - -QDateTime -NepomukTrack::modifyDate() const -{ - return m_modifyDate; -} - -int -NepomukTrack::trackNumber() const -{ - return m_trackNumber; -} - -int -NepomukTrack::discNumber() const -{ - return m_discNumber; -} - -qreal -NepomukTrack::replayGain( ReplayGainTag mode ) const -{ - qreal gain = 0; - switch( mode ) - { - case ReplayGain_Track_Gain : - gain = m_trackGain; - break; - case ReplayGain_Track_Peak : - gain = m_trackPeakGain; - break; - case ReplayGain_Album_Gain : - gain = m_albumGain; - if( gain == 0 ) - gain = m_trackGain; - break; - case ReplayGain_Album_Peak : - gain = m_albumPeakGain; - if( gain == 0 ) - gain = m_trackPeakGain; - break; - } - - return gain; -} - -QString -NepomukTrack::type() const -{ - return m_type; -} - -bool -NepomukTrack::inCollection() const -{ - return m_coll; -} - -Collections::Collection* -NepomukTrack::collection() const -{ - return m_coll; -} - -void -NepomukTrack::addLabel( const Meta::LabelPtr &label ) -{ - if( !label ) - return; - - const NepomukLabel *nlabel = dynamic_cast(label.data()); - if( nlabel ) - { - resource()->addTag( nlabel->tag() ); - notifyObservers(); - } - else - { - addLabel( label->name() ); - } -} - -void -NepomukTrack::addLabel( const QString &label ) -{ - Nepomuk2::Tag tag; - tag.setLabel( label ); - resource()->addTag( tag ); - - notifyObservers(); -} - -Meta::LabelList -NepomukTrack::labels() const -{ - LabelList result; - - foreach( const Nepomuk2::Tag &tag, resource()->tags() ) - result << NepomukLabel::fromNepomukTag( m_coll, tag ); - - return result; -} - -void -NepomukTrack::removeLabel( const LabelPtr &label ) -{ - const NepomukLabel *nlabel = dynamic_cast(label.data()); - - if( !nlabel ) return; - - resource()->removeProperty( Soprano::Vocabulary::NAO::hasTag(), nlabel->tag() ); - - notifyObservers(); -} - -StatisticsPtr -NepomukTrack::statistics() -{ - return StatisticsPtr( this ); -} - -int -NepomukTrack::rating() const -{ - return resource()->rating(); -} - -void -NepomukTrack::setRating( int newRating ) -{ - resource()->setRating( newRating ); - notifyObservers(); -} - -QDateTime -NepomukTrack::lastPlayed() const -{ - return resource()->property( Nepomuk2::Vocabulary::NUAO::lastUsage() ).toDateTime(); -} - -void -NepomukTrack::setLastPlayed( const QDateTime &date ) -{ - resource()->setProperty( Nepomuk2::Vocabulary::NUAO::lastUsage(), date ); - notifyObservers(); -} - -QDateTime -NepomukTrack::firstPlayed() const -{ - return resource()->property( Nepomuk2::Vocabulary::NUAO::firstUsage() ).toDateTime(); -} - -void -NepomukTrack::setFirstPlayed( const QDateTime &date ) -{ - resource()->setProperty( Nepomuk2::Vocabulary::NUAO::firstUsage(), date ); - notifyObservers(); -} - -int -NepomukTrack::playCount() const -{ - return resource()->usageCount(); -} - -void -NepomukTrack::setPlayCount( int newPlayCount ) -{ - resource()->setProperty( Nepomuk2::Vocabulary::NUAO::usageCount(), newPlayCount ); - notifyObservers(); -} - -Nepomuk2::Resource* -NepomukTrack::resource() const -{ - if( !m_resource ) - m_resource.reset(new Nepomuk2::Resource( m_resourceUri )); - return m_resource.data(); -} diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukTrack.h b/src/core-impl/collections/nepomukcollection/meta/NepomukTrack.h deleted file mode 100644 index ce0179a483..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukTrack.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * Copyright (c) 2013 Edward Toroshchin * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NEPOMUKTRACK_H -#define NEPOMUKTRACK_H - -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" - -#include - -namespace Collections { class NepomukCollection; } - -namespace Nepomuk2 { class Resource; } - -namespace Meta -{ - -class NepomukTrack; - -/** - * Represents a unit music track resource in Amarok - */ -class NepomukTrack : public Track, public Statistics -{ -public: - // construct a NepomukTrack out of a Nepomuk resource - explicit NepomukTrack( const QUrl &resUri, Collections::NepomukCollection *coll = 0 ); - ~NepomukTrack(); - - virtual QString name() const; - virtual QUrl playableUrl() const; - virtual QString prettyUrl() const; - virtual QString uidUrl() const; - virtual QString notPlayableReason() const; - - virtual AlbumPtr album() const; - virtual ArtistPtr artist() const; - virtual ComposerPtr composer() const; - virtual GenrePtr genre() const; - virtual YearPtr year() const; - - virtual LabelList labels() const; - virtual qreal bpm() const; - virtual QString comment() const; - virtual qint64 length() const; - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; - virtual QDateTime createDate() const; - virtual QDateTime modifyDate() const; - virtual int trackNumber() const; - virtual int discNumber() const; - virtual qreal replayGain( ReplayGainTag mode ) const; - - virtual QString type() const; - - virtual bool inCollection() const; - virtual Collections::Collection *collection() const; - - virtual void addLabel( const LabelPtr &label ); - virtual void addLabel( const QString &label ); - virtual void removeLabel( const LabelPtr &label ); - - virtual StatisticsPtr statistics(); - - // Meta::Statistics methods - // TODO: introduce scores into Nepomuk and implement score(), setScore() - - virtual int rating() const; - virtual void setRating( int newRating ); - - virtual QDateTime lastPlayed() const; - virtual void setLastPlayed( const QDateTime &date ); - virtual QDateTime firstPlayed() const; - virtual void setFirstPlayed( const QDateTime &date ); - - virtual int playCount() const; - virtual void setPlayCount( int newPlayCount ); - - // NepomukTrack meta methods - void setAlbum( AlbumPtr album ) { m_album = album; } - void setArtist( ArtistPtr artist ) { m_artist = artist; } - void setComposer( ComposerPtr composer ) { m_composer = composer; } - void setGenre( GenrePtr genre ) { m_genre = genre; } - void setYear( YearPtr year ) { m_year = year; } - - // NepomukTrack secondary metadata methods - void setName( const QString &name ) { m_name = name; } - void setType( const QString &type ) { m_type = type; } - void setLength( const qint64 length ) { m_length = length; } - void setBitrate( int rate ) { m_bitrate = rate; } - void setTrackNumber( int trackNumber ) { m_trackNumber = trackNumber; } - void setDiscNumber( int discNumber ) { m_discNumber = discNumber; } - void setModifyDate( const QDateTime &modifyDate ) { m_modifyDate = modifyDate; } - void setCreateDate( const QDateTime &createDate ) { m_createDate = createDate; } - void setbpm( const qreal bpm ) { m_bpm = bpm; } - void setComment( const QString &comment ) { m_comment = comment; } - void setSampleRate( int sampleRate ) { m_sampleRate = sampleRate; } - void setFilesize( int filesize ) { m_filesize = filesize; } - void setTrackGain( qreal trackGain ) { m_trackGain = trackGain; } - void setTrackPeakGain( qreal trackPeakGain ) { m_trackPeakGain = trackPeakGain; } - void setAlbumGain( qreal albumGain ) { m_albumGain = albumGain; } - void setAlbumPeakGain( qreal albumPeakGain ) { m_albumPeakGain = albumPeakGain; } - void setPlayableUrl( const QUrl &url ) { m_playableUrl = url; } - - bool isFilled(){ return m_filled; } - - void fill( const QString &name, const QUrl &url, Collections::NepomukCollection *coll ) - { - m_name = name; - m_playableUrl = url; - m_coll = coll; - m_filled = true; - } - - Nepomuk2::Resource *resource() const; - -private: - bool m_filled; - - ArtistPtr m_artist; - GenrePtr m_genre; - ComposerPtr m_composer; - AlbumPtr m_album; - YearPtr m_year; - LabelList m_labellist; - - QUrl m_playableUrl; - QString m_name; - QString m_type; - qint64 m_length; - int m_bitrate; - int m_trackNumber; - int m_discNumber; - QDateTime m_modifyDate; - QDateTime m_createDate; - qreal m_bpm; - QString m_comment; - int m_sampleRate; - int m_filesize; - double m_trackGain; - double m_trackPeakGain; - double m_albumGain; - double m_albumPeakGain; - - Collections::NepomukCollection *m_coll; - mutable QScopedPointer m_resource; - QUrl m_resourceUri; -}; - -} -#endif /*NEPOMUKTRACK_H*/ diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukYear.cpp b/src/core-impl/collections/nepomukcollection/meta/NepomukYear.cpp deleted file mode 100644 index 543807021c..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukYear.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NepomukYear.h" - -#include "core/meta/Meta.h" - -using namespace Meta; - -NepomukYear::NepomukYear( int yearValue ) - : m_year( yearValue ) -{ -} - -TrackList -NepomukYear::tracks() -{ - return TrackList(); // TODO -} - -QString -NepomukYear::name() const -{ - return QString::number( m_year ); -} - -int -NepomukYear::year() const -{ - return m_year; -} diff --git a/src/core-impl/collections/nepomukcollection/meta/NepomukYear.h b/src/core-impl/collections/nepomukcollection/meta/NepomukYear.h deleted file mode 100644 index 1b2aba0b17..0000000000 --- a/src/core-impl/collections/nepomukcollection/meta/NepomukYear.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Phalgun Guduthur * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NEPOMUKYEAR_H -#define NEPOMUKYEAR_H - -#include "core/meta/Meta.h" - -using namespace Collections; - -namespace Meta -{ -class NepomukYear : public Year -{ -public: - explicit NepomukYear( int yearValue ); - - virtual TrackList tracks(); - virtual QString name() const; - virtual int year() const; - -private: - int m_year; -}; - -} - -#endif // NEPOMUKYEAR_H