add_subdirectory( playdarcollection )
endif( QJSON_FOUND )
add_subdirectory( upnpcollection )
-add_subdirectory( nepomukcollection )
+++ /dev/null
-macro_optional_find_package(NepomukCore QUIET)
-macro_log_feature(NepomukCore_FOUND "nepomuk-core" "NepomukCore Libraries required by Nepomuk Collection" "http://kde.org/download/#v4.9" FALSE "4.9.0")
-macro_optional_find_package(Soprano QUIET)
-macro_log_feature(Soprano_FOUND "Soprano" "Soprano libraries required by Nepomuk Collection" "http://soprano.sourceforge.net/" FALSE)
-
-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
- )
-
- kde4_add_plugin(amarok_collection-nepomukcollection ${amarok_collection-nepomukcollection_PART_SRCS})
-
- target_link_libraries(amarok_collection-nepomukcollection
- amarokcore
- amaroklib
- ${KDE4_THREADWEAVER_LIBRARIES}
- ${NEPOMUK_CORE_LIBRARY}
- ${KDE4_KDEUI_LIBS}
- ${KDE4_KDECORE_LIBS}
- ${SOPRANO_LIBRARIES}
- )
-
- install(TARGETS amarok_collection-nepomukcollection DESTINATION ${PLUGIN_INSTALL_DIR})
-
- ########### install files ###############
-
- install(FILES amarok_collection-nepomukcollection.desktop DESTINATION ${SERVICES_INSTALL_DIR})
-
-endif()
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name>
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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 <QHash>
-#include <QMutex>
-#include <QMutexLocker>
-
-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 );
-}
-
-}
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name>
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#ifndef AMAROK_COLLECTION_NEPOMUKCACHE_H
-#define AMAROK_COLLECTION_NEPOMUKCACHE_H
-
-#include "core/meta/forward_declarations.h"
-
-#include <QObject>
-
-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;
-
- 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
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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 <Nepomuk2/Resource>
-#include <Nepomuk2/ResourceManager>
-#include <Nepomuk2/Vocabulary/NFO>
-
-#include <KIcon>
-#include <ThreadWeaver/Weaver>
-
-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" );
-}
-
-KIcon
-NepomukCollection::icon() const
-{
- return KIcon( "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 KUrl & ) const
-{
- return true;
-}
-
-Meta::TrackPtr
-NepomukCollection::trackForUrl( const KUrl &url )
-{
- DEBUG_BLOCK
- debug() << url;
- return Meta::TrackPtr(); // TODO
-}
-
-}
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#ifndef NEPOMUKCOLLECTION_H
-#define NEPOMUKCOLLECTION_H
-
-#include "core/collections/Collection.h"
-
-#include <KIcon>
-
-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 KIcon icon() const;
- virtual bool isWritable() const;
-
- // TrackProvider methods
- virtual bool possiblyContainsTrack( const KUrl &url ) const;
- virtual Meta::TrackPtr trackForUrl( const KUrl &url );
-
- NepomukCache *cache() const { return m_cache; }
-
-private:
- NepomukCache *m_cache;
-};
-
-} //namespace Collections
-#endif // NEPOMUKCOLLECTION_H
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#define DEBUG_PREFIX "NepomukCollection Factory"
-
-#include "NepomukCollection.h"
-#include "NepomukCollectionFactory.h"
-
-#include "core/interfaces/Logger.h"
-#include "core/support/Components.h"
-#include "core/support/Debug.h"
-
-#include <Nepomuk2/ResourceManager>
-
-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::Components::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", "services" );
-}
-
-NepomukCollectionFactory::~NepomukCollectionFactory()
-{
-}
-
-AMAROK_EXPORT_COLLECTION( NepomukCollectionFactory, nepomukcollection )
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name>
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#include "NepomukInquirer.h"
-
-#include "NepomukParser.h"
-
-#include "core/support/Debug.h"
-
-#include <Nepomuk2/ResourceManager>
-#include <Soprano/Model>
-
-namespace Collections {
-
-
-NepomukInquirer::NepomukInquirer( QString query, std::auto_ptr<NepomukParser> parser )
- : m_query( query )
-{
- Q_ASSERT( parser.get() );
-
- m_parser = parser.release();
- m_parser->setParent( this );
-}
-
-NepomukInquirer::~NepomukInquirer()
-{
-}
-
-void
-NepomukInquirer::run()
-{
- 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 );
-}
-
-}
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name>
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#ifndef AMAROK_COLLECTION_NEPOMUKINQUIRER_H
-#define AMAROK_COLLECTION_NEPOMUKINQUIRER_H
-
-#include <memory>
-
-#include <ThreadWeaver/Job>
-
-#include <QString>
-
-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 ThreadWeaver::Job
-{
- Q_OBJECT
-
-public:
- NepomukInquirer( QString query, std::auto_ptr<NepomukParser> parser );
- ~NepomukInquirer();
-
-protected:
- void run();
-
-private:
- QString m_query;
- NepomukParser *m_parser;
-};
-
-}
-
-#endif // AMAROK_COLLECTION_NEPOMUKINQUIRER_H
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name>
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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;
-
- KSharedPtr<Meta::NepomukTrack> ntrack( KSharedPtr<Meta::NepomukTrack>::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;
-
- KSharedPtr<Meta::NepomukArtist> nartist( KSharedPtr<Meta::NepomukArtist>::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;
-
- KSharedPtr<Meta::NepomukAlbum> nalbum( KSharedPtr<Meta::NepomukAlbum>::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;
-
- KSharedPtr<Meta::NepomukComposer> ncomposer( KSharedPtr<Meta::NepomukComposer>::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;
-}
-
-}
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name>
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#ifndef AMAROK_COLLECTION_NEPOMUKPARSER_H
-#define AMAROK_COLLECTION_NEPOMUKPARSER_H
-
-#include "core/meta/Meta.h"
-
-#include <Soprano/QueryResultIterator>
-
-#include <QObject>
-#include <QSet>
-#include <QStringList>
-
-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
- */
- NepomukParser( NepomukCollection *coll );
-
- /**
- * Parse all the query results in the given QueryResultIterator and emit
- * newResultReady with the constructed objects.
- */
- virtual void parse( Soprano::QueryResultIterator& ) = 0;
-
-signals:
- void newResultReady( Meta::TrackList );
- void newResultReady( Meta::ArtistList );
- void newResultReady( Meta::AlbumList );
- void newResultReady( Meta::GenreList );
- void newResultReady( Meta::ComposerList );
- void newResultReady( Meta::YearList );
- void newResultReady( QStringList );
- void newResultReady( Meta::LabelList );
-
-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<QUrl> 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 );
-
- 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
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name>
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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 <ThreadWeaver/Weaver>
-
-#include <QStack>
-
-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<QString> 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:
- // <result> <matchBegin> <matchEnd>
- 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<NepomukParser> 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, SIGNAL(done(ThreadWeaver::Job*)), SLOT(inquirerDone()));
- ThreadWeaver::Weaver::instance()->enqueue(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<const Meta::NepomukArtist*>( 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<const Meta::NepomukAlbum*>( 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<const Meta::NepomukComposer*>( 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
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name>
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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 slots:
- void inquirerDone();
-};
-
-} //namespace Collections
-
-#endif
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name>
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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
+++ /dev/null
-[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_CN]=Nepomuk 收藏
-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=72
-X-KDE-Amarok-name=nepomuk-collection
-X-KDE-Amarok-plugintype=collection
-X-KDE-Amarok-rank=100
-X-KDE-Amarok-version=1
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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;
-}
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#ifndef NEPOMUKALBUM_H
-#define NEPOMUKALBUM_H
-
-#include "core/meta/Meta.h"
-
-#include <QUrl>
-
-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*/
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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
-}
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#ifndef NEPOMUKARTIST_H
-#define NEPOMUKARTIST_H
-
-#include "core/meta/Meta.h"
-
-#include <QUrl>
-
-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
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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;
-}
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#ifndef NEPOMUKCOMPOSER_H
-#define NEPOMUKCOMPOSER_H
-
-#include "core/meta/Meta.h"
-
-#include <QUrl>
-
-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
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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;
-}
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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:
- NepomukGenre( const QString &name );
- virtual TrackList tracks();
- virtual QString name() const;
-
-private:
- QString m_name;
-};
-
-}
-#endif // NEPOMUKGENRE_H
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#include "NepomukLabel.h"
-
-#include "../NepomukCache.h"
-#include "../NepomukCollection.h"
-
-#include "core/meta/Meta.h"
-
-#include <Nepomuk2/Tag>
-
-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() );
-}
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#ifndef NEPOMUKLABEL_H
-#define NEPOMUKLABEL_H
-
-#include "core/meta/Meta.h"
-
-#include <QScopedPointer>
-
-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<Nepomuk2::Tag> m_nepomukTag;
-};
-
-}
-#endif // NEPOMUKLABEL_H
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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 <KLocalizedString>
-#include <Nepomuk2/Resource>
-#include <Nepomuk2/Tag>
-#include <Nepomuk2/Variant>
-#include <Nepomuk2/Vocabulary/NUAO>
-#include <Soprano/Vocabulary/NAO>
-
-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;
-}
-
-KUrl
-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<const NepomukLabel*>(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<const NepomukLabel*>(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();
-}
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * Copyright (c) 2013 Edward Toroshchin <amarok@hades.name> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#ifndef NEPOMUKTRACK_H
-#define NEPOMUKTRACK_H
-
-#include "core/meta/Meta.h"
-#include "core/meta/Statistics.h"
-
-#include <QScopedPointer>
-
-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
- NepomukTrack( const QUrl &resUri, Collections::NepomukCollection *coll = 0 );
- ~NepomukTrack();
-
- virtual QString name() const;
- virtual KUrl 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 KUrl &url ) { m_playableUrl = url; }
-
- bool isFilled(){ return m_filled; }
-
- void fill( const QString &name, const KUrl &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;
-
- KUrl 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<Nepomuk2::Resource> m_resource;
- QUrl m_resourceUri;
-};
-
-}
-#endif /*NEPOMUKTRACK_H*/
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#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;
-}
+++ /dev/null
-/****************************************************************************************
- * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
- ****************************************************************************************/
-
-#ifndef NEPOMUKYEAR_H
-#define NEPOMUKYEAR_H
-
-#include "core/meta/Meta.h"
-
-using namespace Collections;
-
-namespace Meta
-{
-class NepomukYear : public Year
-{
-public:
- NepomukYear( int yearValue );
-
- virtual TrackList tracks();
- virtual QString name() const;
- virtual int year() const;
-
-private:
- int m_year;
-};
-
-}
-
-#endif // NEPOMUKYEAR_H