1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 00:54:20 +02:00

Merge branch 'master' into dynamic

Conflicts:
	src/CMakeLists.txt
	src/libtomahawk/collection.cpp
	src/libtomahawk/collection.h
	src/libtomahawk/network/filetransferconnection.h
	src/libtomahawk/playlist.h
	src/libtomahawk/query.h
	src/libtomahawk/result.h
	src/playlist/playlistmanager.cpp
	src/playlist/plitem.h
	src/tomahawkwindow.cpp
This commit is contained in:
Leo Franchi
2011-01-03 22:31:37 -06:00
217 changed files with 1227 additions and 2553 deletions

View File

@@ -25,5 +25,6 @@ ENDIF( UNIX AND NOT APPLE )
ADD_SUBDIRECTORY( libportfwd )
ADD_SUBDIRECTORY( qxt )
ADD_SUBDIRECTORY( src/libtomahawk )
ADD_SUBDIRECTORY( src )

25
README
View File

@@ -49,6 +49,31 @@ Now compile Tomahawk
$ make
$ ./tomahawk
Quickstart on OS X
------------------
# Install homebrew
$ ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"
$ brew install qt qjson gloox libmad libvorbis flac taglib boost liblastfm
# Install libEchnoest as per the above instructions
# If liblastfm gives problems, do the below:
$ brew edit liblastfm
# change url to https://github.com/davidsansome/liblastfm/tarball/0.3.1
$ brew install liblastfm
# copy the md5 hash it gives
$ brew edit liblastfm
# replace the md5 hash with the new one you copied
$ brew install liblastfm
# Build Tomahawk
$ git clone git://github.com/tomahawk-player/tomahawk.git
$ cd tomahawk
$ mkdir build && cd build
$ cmake ..
$ make
$ open tomahawk.app
Dependencies
------------

View File

@@ -1 +1 @@
47
53

View File

@@ -253,6 +253,11 @@ Section "Tomahawk Player" SEC_TOMAHAWK_PLAYER
;Main executable.
File "${ROOT_PATH}\build\tomahawk.exe"
;Plugins
File "${ROOT_PATH}\build\src\libtomahawk\libtomahawklib.dll"
File "${ROOT_PATH}\build\libsip_jabber.dll"
File "${ROOT_PATH}\build\libsip_zeroconf.dll"
;License & release notes.
File "${ROOT_PATH}\LICENSE.txt"
File /oname=NOTES.txt RELEASE_NOTES.txt

BIN
data/images/list-remove.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

View File

@@ -16,21 +16,15 @@
#include "QxtHttpServerConnector"
#include "QxtHttpSessionManager"
#include "tomahawk/functimeout.h"
#include "tomahawk/typedefs.h"
#include "tomahawk/tomahawkplugin.h"
#include "tomahawk/playlist.h"
#include "tomahawk/pipeline.h"
#include "typedefs.h"
#include "playlist.h"
#include "utils/tomahawkutils.h"
#include "sourcelist.h"
#include "servent.h"
class AudioEngine;
class Database;
class SipHandler;
class TomahawkZeroconf;
class TomahawkSettings;
class XMPPBot;
@@ -67,17 +61,12 @@ public:
static TomahawkApp* instance();
Tomahawk::Pipeline* pipeline() { return &m_pipeline; }
AudioEngine* audioEngine() { return m_audioEngine; }
Database* database() { return m_db; }
SourceList& sourcelist() { return m_sources; }
Servent& servent() { return m_servent; }
SipHandler* sipHandler() { return m_sipHandler; }
QNetworkAccessManager* nam() { return m_nam; }
QNetworkProxy* proxy() { return m_proxy; }
Tomahawk::InfoSystem::InfoSystem* infoSystem() { return m_infoSystem; }
XMPPBot* xmppBot() { return m_xmppBot; }
const QString& nodeID() const;
#ifndef TOMAHAWK_HEADLESS
AudioControls* audioControls();
@@ -85,21 +74,9 @@ public:
TomahawkWindow* mainWindow() const { return m_mainwindow; }
#endif
void registerIODeviceFactory( const QString &proto, boost::function<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> fac );
QSharedPointer<QIODevice> localFileIODeviceFactory( const Tomahawk::result_ptr& result );
QSharedPointer<QIODevice> httpIODeviceFactory( const Tomahawk::result_ptr& result );
TomahawkSettings* settings() { return m_settings; }
signals:
void settingsChanged();
public slots:
QSharedPointer<QIODevice> getIODeviceForUrl( const Tomahawk::result_ptr& result );
private slots:
void lanHostFound( const QString&, int, const QString&, const QString& );
private:
void initLocalCollection();
void loadPlugins();
@@ -113,12 +90,7 @@ private:
QList<Tomahawk::collection_ptr> m_collections;
QList<TomahawkPlugin*> m_plugins;
Tomahawk::Pipeline m_pipeline;
AudioEngine* m_audioEngine;
Database* m_db;
Servent m_servent;
SourceList m_sources;
TomahawkZeroconf* m_zeroconf;
SipHandler* m_sipHandler;
XMPPBot* m_xmppBot;
@@ -130,10 +102,7 @@ private:
TomahawkWindow* m_mainwindow;
#endif
QMap< QString,boost::function<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> > m_iofactories;
bool m_headless;
TomahawkSettings* m_settings;
QNetworkAccessManager* m_nam;
QNetworkProxy* m_proxy;

View File

@@ -1,9 +1,10 @@
#ifndef TOMAHAWK_PLUGIN_H
#define TOMAHAWK_PLUGIN_H
#include <QString>
#include <QtPlugin>
#include "tomahawk/pluginapi.h"
#include "pluginapi.h"
class TomahawkPlugin
{

View File

@@ -38,7 +38,7 @@ ADD_LIBRARY(portfwd STATIC
)
IF(WIN32)
TARGET_LINK_LIBRARIES( portfwd "ws2_32.dll" )
TARGET_LINK_LIBRARIES( portfwd "ws2_32.dll" "iphlpapi.a" )
ENDIF()
#ADD_EXECUTABLE(portfwd-demo
@@ -46,6 +46,6 @@ ENDIF()
# )
#TARGET_LINK_LIBRARIES(portfwd-demo portfwd)
#INSTALL(TARGETS portfwd ARCHIVE DESTINATION lib)
INSTALL(TARGETS portfwd ARCHIVE DESTINATION lib)
#INSTALL(TARGETS portfwd-demo RUNTIME DESTINATION bin)
#INSTALL(DIRECTORY include/portfwd DESTINATION include PATTERN "*~" EXCLUDE)

View File

@@ -558,7 +558,14 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
return info;
}
const char *mname = CFStringGetCStringPtr( cfname, CFStringGetSystemEncoding() );
CFIndex numbytes_cfname = CFStringGetMaximumSizeOfFileSystemRepresentation( cfname );
if( numbytes_cfname == 0 )
numbytes_cfname=256;
char mname[numbytes_cfname];
if(! CFStringGetCString( cfname, mname,numbytes_cfname,CFStringGetSystemEncoding() ) )
strcpy(mname,"");
info.name.append( (const char *)mname, strlen(mname) );
info.name.append( ": " );
CFRelease( cfname );
@@ -572,7 +579,13 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
return info;
}
const char *name = CFStringGetCStringPtr( cfname, CFStringGetSystemEncoding() );
numbytes_cfname = CFStringGetMaximumSizeOfFileSystemRepresentation( cfname );
if( numbytes_cfname == 0 )
numbytes_cfname=256;
char name[numbytes_cfname];
if(! CFStringGetCString( cfname, name,numbytes_cfname,CFStringGetSystemEncoding() ) )
strcpy(mname,"");
info.name.append( (const char *)name, strlen(name) );
CFRelease( cfname );

View File

@@ -1,6 +1,7 @@
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
alsaplayback
tomahawklib
)
IF( "${gui}" STREQUAL "no" )

View File

@@ -10,4 +10,5 @@ SET( OS_SPECIFIC_LINK_LIBRARIES
${COREAUDIO_LIBRARY}
${COREFOUNDATION_LIBRARY}
rtaudio
tomahawklib
)

View File

@@ -27,16 +27,6 @@ SET( TOMAHAWK_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../include/" )
#ENDFOREACH( moddir )
SET( tomahawkSources ${tomahawkSources}
artist.cpp
album.cpp
pipeline.cpp
playlist.cpp
pluginapi.cpp
query.cpp
result.cpp
source.cpp
sourcelist.cpp
audio/madtranscode.cpp
audio/vorbistranscode.cpp
audio/flactranscode.cpp
@@ -45,70 +35,18 @@ SET( tomahawkSources ${tomahawkSources}
utils/tomahawkutils.cpp
sip/SipHandler.cpp
sip/SipPlugin.cpp
infosystem/infosystem.cpp
infosystem/infoplugins/echonestplugin.cpp
infosystem/infoplugins/musixmatchplugin.cpp
collection.cpp
musicscanner.cpp
scriptresolver.cpp
network/bufferiodevice.cpp
network/msgprocessor.cpp
network/connection.cpp
network/controlconnection.cpp
network/filetransferconnection.cpp
network/dbsyncconnection.cpp
network/remotecollection.cpp
network/servent.cpp
database/fuzzyindex.cpp
database/database.cpp
database/databaseworker.cpp
database/databaseimpl.cpp
database/databaseresolver.cpp
database/databasecommand.cpp
database/databasecommandloggable.cpp
database/databasecommand_resolve.cpp
database/databasecommand_allalbums.cpp
database/databasecommand_alltracks.cpp
database/databasecommand_addfiles.cpp
database/databasecommand_dirmtimes.cpp
database/databasecommand_loadfile.cpp
database/databasecommand_addsource.cpp
database/databasecommand_sourceoffline.cpp
database/databasecommand_collectionstats.cpp
database/databasecommand_loadplaylistentries.cpp
database/databasecommand_modifyplaylist.cpp
database/databasecommand_setplaylistrevision.cpp
database/databasecommand_loadallplaylists.cpp
database/databasecommand_createplaylist.cpp
database/databasecommand_deleteplaylist.cpp
database/databasecommand_renameplaylist.cpp
database/databasecommand_loadops.cpp
database/databasecommand_updatesearchindex.cpp
database/databasecommand_loadallplaylists.cpp
database/databasecommand_setdynamicplaylistrevision.cpp
database/databasecommand_createdynamicplaylist.cpp
database/databasecommand_loaddynamicplaylist.cpp
database/databasecommand_loadalldynamicplaylists.cpp
database/databasecommand_deletedynamicplaylist.cpp
database/databasecollection.cpp
dynamic/DynamicPlaylist.cpp
dynamic/DynamicControl.cpp
dynamic/GeneratorFactory.cpp
dynamic/GeneratorInterface.cpp
dynamic/echonest/EchonestGenerator.cpp
dynamic/echonest/EchonestControl.cpp
scrobbler.cpp
xmppbot/xmppbot.cpp
web/api_v1.cpp
tomahawksettings.cpp
tomahawkapp.cpp
main.cpp
)
@@ -150,11 +88,6 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
sourcetree/sourcetreeitemwidget.cpp
sourcetree/sourcetreeview.cpp
dynamic/widgets/DynamicWidget.cpp
dynamic/widgets/DynamicControlWidget.cpp
dynamic/widgets/DynamicControlList.cpp
dynamic/DynamicPlaylistModel.cpp
topbar/topbar.cpp
topbar/clearbutton.cpp
topbar/searchlineedit.cpp
@@ -163,6 +96,10 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
infowidgets/sourceinfowidget.cpp
dynamic/widgets/DynamicWidget.cpp
dynamic/widgets/DynamicControlWidget.cpp
dynamic/widgets/DynamicControlList.cpp
dynamic/DynamicPlaylistModel.cpp
transferview.cpp
tomahawkwindow.cpp
@@ -174,89 +111,21 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
SET( tomahawkHeaders ${tomahawkHeaders}
"${TOMAHAWK_INC_DIR}/tomahawk/tomahawkapp.h"
"${TOMAHAWK_INC_DIR}/tomahawk/collection.h"
"${TOMAHAWK_INC_DIR}/tomahawk/pipeline.h"
"${TOMAHAWK_INC_DIR}/tomahawk/pluginapi.h"
"${TOMAHAWK_INC_DIR}/tomahawk/query.h"
"${TOMAHAWK_INC_DIR}/tomahawk/resolver.h"
"${TOMAHAWK_INC_DIR}/tomahawk/result.h"
"${TOMAHAWK_INC_DIR}/tomahawk/source.h"
"${TOMAHAWK_INC_DIR}/tomahawk/sourcelist.h"
"${TOMAHAWK_INC_DIR}/tomahawk/artist.h"
"${TOMAHAWK_INC_DIR}/tomahawk/album.h"
"${TOMAHAWK_INC_DIR}/tomahawk/track.h"
"${TOMAHAWK_INC_DIR}/tomahawk/playlist.h"
"${TOMAHAWK_INC_DIR}/tomahawk/infosystem.h"
"${TOMAHAWK_INC_DIR}/tomahawk/functimeout.h"
# "${TOMAHAWK_INC_DIR}/tomahawk/tomahawkplugin.h"
audio/transcodeinterface.h
audio/madtranscode.h
audio/vorbistranscode.h
audio/flactranscode.h
audio/audioengine.h
database/fuzzyindex.h
database/database.h
database/databaseworker.h
database/databaseimpl.h
database/databaseresolver.h
database/databasecommand.h
database/databasecommandloggable.h
database/databasecommand_resolve.h
database/databasecommand_allalbums.h
database/databasecommand_alltracks.h
database/databasecommand_addfiles.h
database/databasecommand_dirmtimes.h
database/databasecommand_loadfile.h
database/databasecommand_addsource.h
database/databasecommand_sourceoffline.h
database/databasecommand_collectionstats.h
database/databasecommand_loadplaylistentries.h
database/databasecommand_modifyplaylist.h
database/databasecommand_setplaylistrevision.h
database/databasecommand_loadallplaylists.h
database/databasecommand_createplaylist.h
database/databasecommand_deleteplaylist.h
database/databasecommand_setdynamicplaylistrevision.h
database/databasecommand_createdynamicplaylist.h
database/databasecommand_loaddynamicplaylist.h
database/databasecommand_deletedynamicplaylist.h
database/databasecommand_loadalldynamicplaylists.h
database/databasecommand_renameplaylist.h
database/databasecommand_loadops.h
database/databasecommand_updatesearchindex.h
database/databasecollection.h
sip/SipHandler.h
sip/SipPlugin.h
infosystem/infoplugins/echonestplugin.h
infosystem/infoplugins/musixmatchplugin.h
network/bufferiodevice.h
network/msgprocessor.h
network/remotecollection.h
network/servent.h
network/connection.h
network/controlconnection.h
network/filetransferconnection.h
network/dbsyncconnection.h
dynamic/DynamicPlaylist.h
dynamic/DynamicControl.h
dynamic/GeneratorFactory.h
dynamic/GeneratorInterface.h
dynamic/echonest/EchonestGenerator.h
dynamic/echonest/EchonestControl.h
musicscanner.h
scriptresolver.h
tomahawksettings.h
tomahawkzeroconf.h
scrobbler.h
xmppbot/xmppbot.h
@@ -345,10 +214,10 @@ INCLUDE_DIRECTORIES(
topbar
utils
dynamic
libtomahawk
../rtaudio
../alsa-playback
../libportfwd/include
../qxt/qxtweb-standalone/qxtweb
/usr/include/taglib
@@ -369,6 +238,7 @@ IF( UNIX )
ENDIF( UNIX )
ADD_SUBDIRECTORY( sip/jabber )
ADD_SUBDIRECTORY( sip/zeroconf )
kde4_add_app_icon( tomahawkSources "${CMAKE_CURRENT_SOURCE_DIR}/../data/icons/tomahawk-icon-*.png" )
qt4_add_resources( RC_SRCS "../resources.qrc" )
@@ -398,9 +268,9 @@ MESSAGE( STATUS "OS_SPECIFIC_LINK_LIBRARIES: ${OS_SPECIFIC_LINK_LIBRARIES}" )
TARGET_LINK_LIBRARIES( tomahawk
${QT_LIBRARIES}
${MAC_EXTRA_LIBS}
portfwd
${OS_SPECIFIC_LINK_LIBRARIES}
${LIBECHONEST_LIBRARY}
qjson
tag
)

View File

@@ -1,6 +1,7 @@
ADD_DEFINITIONS( /DNOMINMAX )
ADD_DEFINITIONS( /DWIN32_LEAN_AND_MEAN )
ADD_DEFINITIONS( -static-libgcc )
#ADD_DEFINITIONS( /DNO_LIBLASTFM )
#ADD_DEFINITIONS( -DNO_OGG )
@@ -17,18 +18,23 @@ INCLUDE_DIRECTORIES(
../../taglib-1.6.3/taglib/toolkit
)
SET( GLOOX_LIBS
${GLOOX_LIBS}
gloox
)
SET( OS_SPECIFIC_LINK_LIBRARIES
${LIBLASTFM_LIBRARY}
gloox
${GLOOX_LIBS}
)
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
"secur32.dll"
"crypt32.dll"
"ws2_32.dll"
"dnsapi.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/../qxt/qxtweb-standalone/libqxtweb-standalone.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/../build/src/libtomahawk/libtomahawklib.dll"
)
SET( tomahawkSourcesGui ${tomahawkSourcesGui} audio/rtaudiooutput.cpp )
@@ -45,4 +51,3 @@ SET( OS_SPECIFIC_LINK_LIBRARIES
"FLAC++"
"${CMAKE_CURRENT_SOURCE_DIR}/../rtaudio/librtaudio.dll"
)

View File

@@ -3,8 +3,8 @@
#include <QUrl>
#include <QMutexLocker>
#include <tomahawk/tomahawkapp.h>
#include "tomahawk/playlistinterface.h"
#include "playlistinterface.h"
#include "network/servent.h"
#include "madtranscode.h"
#ifndef NO_OGG
@@ -158,7 +158,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
emit finished( m_lastTrack );
m_currentTrack = result;
io = TomahawkApp::instance()->getIODeviceForUrl( m_currentTrack );
io = Servent::instance()->getIODeviceForUrl( m_currentTrack );
if ( !io || io.isNull() )
{

View File

@@ -5,8 +5,8 @@
#include <QMutex>
#include <QBuffer>
#include "tomahawk/result.h"
#include "tomahawk/typedefs.h"
#include "result.h"
#include "typedefs.h"
#include "rtaudiooutput.h"
#include "alsaplayback.h"

View File

@@ -4,7 +4,7 @@
#include <QNetworkReply>
#include "tomahawk/tomahawkapp.h"
#include "tomahawk/album.h"
#include "album.h"
#include "utils/tomahawkutils.h"
#include "audioengine.h"

View File

@@ -3,8 +3,8 @@
#include <QWidget>
#include "tomahawk/result.h"
#include "tomahawk/playlistinterface.h"
#include "result.h"
#include "playlistinterface.h"
namespace Ui
{

View File

@@ -1,57 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 "databasecommand_deletedynamicplaylist.h"
#include <QSqlQuery>
#include "tomahawk/tomahawkapp.h"
using namespace Tomahawk;
DatabaseCommand_DeleteDynamicPlaylist::DatabaseCommand_DeleteDynamicPlaylist( const source_ptr& source, const QString& playlistguid )
: DatabaseCommand_DeletePlaylist( source, playlistguid )
{
}
void
DatabaseCommand_DeleteDynamicPlaylist::exec( DatabaseImpl* lib )
{
qDebug() << Q_FUNC_INFO;
DatabaseCommand_DeletePlaylist::exec( lib );
TomahawkSqlQuery cre = lib->newquery();
cre.prepare( "DELETE FROM dynamic_playlist WHERE guid = :id" );
cre.bindValue( ":id", m_playlistguid );
cre.exec();
}
void
DatabaseCommand_DeleteDynamicPlaylist::postCommitHook()
{
qDebug() << Q_FUNC_INFO << "..reporting..";
dynplaylist_ptr playlist = source()->collection()->dynamicPlaylist( m_playlistguid );
Q_ASSERT( !playlist.isNull() );
playlist->reportDeleted( playlist );
if( source()->isLocal() )
APP->servent().triggerDBSync();
}

View File

@@ -1,45 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 DATABASECOMMAND_DELETEDYNAMICPLAYLIST_H
#define DATABASECOMMAND_DELETEDYNAMICPLAYLIST_H
#include "databaseimpl.h"
#include "databasecommand_deleteplaylist.h"
#include "tomahawk/source.h"
#include "tomahawk/typedefs.h"
class DatabaseCommand_DeleteDynamicPlaylist : public DatabaseCommand_DeletePlaylist
{
Q_OBJECT
public:
explicit DatabaseCommand_DeleteDynamicPlaylist( QObject* parent = 0 )
: DatabaseCommand_DeletePlaylist( parent )
{}
explicit DatabaseCommand_DeleteDynamicPlaylist( const Tomahawk::source_ptr& source, const QString& playlistguid );
QString commandname() const { return "deletedynamicplaylist"; }
virtual void exec( DatabaseImpl* lib );
virtual void postCommitHook();
virtual bool doesMutates() const { return true; }
private:
QString m_playlistguid;
};
#endif // DATABASECOMMAND_DELETEDYNAMICPLAYLIST_H

View File

@@ -1,56 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 "databasecommand_loadalldynamicplaylists.h"
#include <QSqlQuery>
#include "dynamic/DynamicPlaylist.h"
#include "databaseimpl.h"
using namespace Tomahawk;
void DatabaseCommand_LoadAllDynamicPlaylists::exec( DatabaseImpl* dbi )
{
TomahawkSqlQuery query = dbi->newquery();
query.exec( QString( "SELECT playlist.guid as guid, title, info, creator, lastmodified, shared, currentrevision, dynamic_playlist.pltype, dynamic_playlist.plmode "
"FROM playlist, dynamic_playlist WHERE source %1 AND dynplaylist AND playlist.guid = dynamic_playlist.guid" )
.arg( source()->isLocal() ? "IS NULL" :
QString( "=%1" ).arg( source()->id() )
) );
QList<dynplaylist_ptr> plists;
while ( query.next() )
{
dynplaylist_ptr p( new DynamicPlaylist( source(), //src
query.value(6).toString(), //current rev
query.value(1).toString(), //title
query.value(2).toString(), //info
query.value(3).toString(), //creator
query.value(7).toString(), // dynamic type
static_cast<GeneratorMode>(query.value(8).toInt()), // dynamic mode
query.value(5).toBool(), //shared
query.value(4).toInt(), //lastmod
query.value(0).toString() //GUID
) );
plists.append( p );
}
emit done( plists );
}

View File

@@ -1,42 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 DATABASECOMMAND_LOADALLDYNAMICPLAYLISTS_H
#define DATABASECOMMAND_LOADALLDYNAMICPLAYLISTS_H
#include <QObject>
#include <QVariantMap>
#include "databasecommand.h"
#include "tomahawk/typedefs.h"
class DatabaseCommand_LoadAllDynamicPlaylists : public DatabaseCommand
{
Q_OBJECT
public:
explicit DatabaseCommand_LoadAllDynamicPlaylists( const Tomahawk::source_ptr& s, QObject* parent = 0 )
: DatabaseCommand( s, parent )
{}
virtual void exec( DatabaseImpl* );
virtual bool doesMutates() const { return false; }
virtual QString commandname() const { return "loadalldynamicplaylists"; }
signals:
void done( const QList<Tomahawk::dynplaylist_ptr>& playlists );
};
#endif // DATABASECOMMAND_ADDFILES_H

View File

@@ -1,74 +0,0 @@
#include "databasecommand_loaddynamicplaylist.h"
#include <QSqlQuery>
#include <QString>
#include "databaseimpl.h"
#include "tomahawksqlquery.h"
#include "dynamic/DynamicControl.h"
#include "dynamic/GeneratorInterface.h"
using namespace Tomahawk;
void
DatabaseCommand_LoadDynamicPlaylist::exec( DatabaseImpl* dbi )
{
qDebug() << "Loading dynamic playlist revision" << guid();
// load the entries first
generateEntries( dbi );
// now load the controls etc
TomahawkSqlQuery controlsQuery = dbi->newquery();
controlsQuery.prepare("SELECT playlist_revision.playlist, controls, plmode, pltype "
"FROM dynamic_playlist_revision, playlist_revision "
"WHERE dynamic_playlist_revision.guid = ? AND playlist_revision.guid = dynamic_playlist_revision.guid");
controlsQuery.addBindValue( revisionGuid() );
controlsQuery.exec();
QList< dyncontrol_ptr > controls;
QString playlist_guid;
if( controlsQuery.next() )
{
playlist_guid = controlsQuery.value( 0 ).toString();
QStringList controlIds = controlsQuery.value( 1 ).toStringList();
foreach( const QString& controlId, controlIds )
{
TomahawkSqlQuery controlQuery = dbi->newquery();
controlQuery.prepare( "SELECT selectedType, match, input "
"FROM dynamic_playlist_controls "
"WHERE id = :id" );
controlQuery.bindValue( ":id", controlId );
controlQuery.exec();
if( controlQuery.next() )
{
dyncontrol_ptr c = dyncontrol_ptr( new DynamicControl );
c->setId( controlId );
c->setSelectedType( controlQuery.value( 0 ).toString() );
c->setMatch( controlQuery.value( 1 ).toString() );
c->setInput( controlQuery.value( 2 ).toString() );
controls << c;
}
}
}
TomahawkSqlQuery info = dbi->newquery();
info.prepare( QString( "SELECT dynamic_playlist.pltype, dynamic_playlist.plmode FROM playlist, dynamic_playlist WHERE playlist.guid = \"%1\" AND playlist.guid = dynamic_playlist.guid" ).arg( playlist_guid ) );
if( !info.exec() ) {
qWarning() << "Failed to load dynplaylist info..";
return;
} else if( !info.first() ) {
qWarning() << "Noo results for queryL:" << info.lastQuery();
return;
}
QString type = info.value( 0 ).toString();
GeneratorMode mode = static_cast<GeneratorMode>( info.value( 1 ).toInt() );
if( mode == OnDemand ) {
Q_ASSERT( m_entrymap.isEmpty() ); // ondemand should have no entry
emit done( revisionGuid(), m_islatest, type, controls, true );
} else {
emit done( revisionGuid(), m_guids, m_oldentries, type, controls, m_islatest, m_entrymap, true );
}
}

View File

@@ -1,47 +0,0 @@
#ifndef DATABASECOMMAND_LOADDYNAMICPLAYLIST_H
#define DATABASECOMMAND_LOADDYNAMICPLAYLIST_H
#include <QObject>
#include <QVariantMap>
#include "tomahawk/typedefs.h"
#include "databasecommand.h"
#include "databasecommand_loadplaylistentries.h"
#include "tomahawk/playlist.h"
#include "dynamic/DynamicControl.h"
class DatabaseCommand_LoadDynamicPlaylist : public DatabaseCommand_LoadPlaylistEntries
{
Q_OBJECT
public:
explicit DatabaseCommand_LoadDynamicPlaylist( QString revision_guid, QObject* parent = 0 )
: DatabaseCommand_LoadPlaylistEntries( revision_guid, parent )
{ qDebug() << "loaded with:" << revision_guid << guid(); }
virtual void exec( DatabaseImpl* );
virtual bool doesMutates() const { return false; }
virtual QString commandname() const { return "loaddynamicplaylist"; }
signals:
// used if loading an ondemand playlist
void done( QString,
bool,
QString,
QList< Tomahawk::dyncontrol_ptr>,
bool );
// used when loading a static playlist
void done( QString,
QList< QString >,
QList< QString >,
QString,
QList< Tomahawk::dyncontrol_ptr>,
bool,
QMap< QString, Tomahawk::plentry_ptr >,
bool );
private:
};
#endif // DATABASECOMMAND_LOADDYNAMICPLAYLIST_H

View File

@@ -1,150 +0,0 @@
#include "databasecommand_setdynamicplaylistrevision.h"
#include <QSqlQuery>
#include "tomahawksqlquery.h"
#include "dynamic/DynamicPlaylist.h"
#include "dynamic/DynamicControl.h"
#include "tomahawk/tomahawkapp.h"
DatabaseCommand_SetDynamicPlaylistRevision::DatabaseCommand_SetDynamicPlaylistRevision(const Tomahawk::source_ptr& s,
const QString& playlistguid,
const QString& newrev,
const QString& oldrev,
const QStringList& orderedguids,
const QList< plentry_ptr >& addedentries,
const QString& type,
GeneratorMode mode,
const QList< dyncontrol_ptr >& controls )
: DatabaseCommand_SetPlaylistRevision( s, playlistguid, newrev, oldrev, orderedguids, addedentries )
, m_type( type )
, m_mode( mode )
, m_controls( controls )
{
}
DatabaseCommand_SetDynamicPlaylistRevision::DatabaseCommand_SetDynamicPlaylistRevision(const Tomahawk::source_ptr& s,
const QString& playlistguid,
const QString& newrev,
const QString& oldrev,
const QString& type,
GeneratorMode mode,
const QList< dyncontrol_ptr >& controls )
: DatabaseCommand_SetPlaylistRevision( s, playlistguid, newrev, oldrev, QStringList(), QList< plentry_ptr >() )
, m_type( type )
, m_mode( mode )
, m_controls( controls )
{
}
QVariantList DatabaseCommand_SetDynamicPlaylistRevision::controlsV()
{
if( m_controls.isEmpty() )
return m_controlsV;
if( !m_controls.isEmpty() && m_controlsV.isEmpty() )
{
foreach( const dyncontrol_ptr& control, m_controls )
{
m_controlsV << QJson::QObjectHelper::qobject2qvariant( control.data() );
}
}
return m_controlsV;
}
void
DatabaseCommand_SetDynamicPlaylistRevision::postCommitHook()
{
qDebug() << Q_FUNC_INFO;
QStringList orderedentriesguids;
foreach( const QVariant& v, orderedguids() )
orderedentriesguids << v.toString();
// private, but we are a friend. will recall itself in its own thread:
dynplaylist_ptr playlist = source()->collection()->dynamicPlaylist( playlistguid() );
if ( playlist.isNull() )
{
qDebug() << playlistguid();
Q_ASSERT( !playlist.isNull() );
return;
}
if( m_controls.isEmpty() && !m_controlsV.isEmpty() ) // we were creatd from JSON, not programmatically. construct the controls fromthe playlist now
{
foreach( const QVariant& contrl, m_controlsV ) {
dyncontrol_ptr control = playlist->generator()->createControl( m_type );
QJson::QObjectHelper::qvariant2qobject( contrl.toMap(), control.data( ));
m_controls << control;
}
}
if( m_mode == OnDemand )
playlist->setRevision( newrev(),
true, // this *is* the newest revision so far
m_type,
m_controls,
m_applied );
else
playlist->setRevision( newrev(),
orderedentriesguids,
m_previous_rev_orderedguids,
m_type,
m_controls,
true, // this *is* the newest revision so far
m_addedmap,
m_applied );
if( source()->isLocal() )
APP->servent().triggerDBSync();
}
void
DatabaseCommand_SetDynamicPlaylistRevision::exec( DatabaseImpl* lib )
{
DatabaseCommand_SetPlaylistRevision::exec( lib );
QVariantList newcontrols;
foreach( const dyncontrol_ptr& control, m_controls ) {
newcontrols << control->id();
}
QJson::Serializer ser;
const QByteArray newcontrols_data = ser.serialize( newcontrols );
TomahawkSqlQuery query = lib->newquery();
QString sql = "INSERT INTO dynamic_playlist_revision (guid, controls, plmode, pltype) "
"VALUES(?, ?, ?, ?)";
query.prepare( sql );
query.addBindValue( m_newrev );
query.addBindValue( newcontrols_data );
query.addBindValue( QString::number( (int) m_mode ) );
query.addBindValue( m_type );
query.exec();
// delete all the old controls, replace with new onws
TomahawkSqlQuery delQuery = lib->newquery();
delQuery.prepare( "DELETE * FROM dynamic_playlist_controls" );
delQuery.exec();
TomahawkSqlQuery controlsQuery = lib->newquery();
controlsQuery.prepare( "INSERT INTO dynamic_playlist_controls( id, playlist, selectedType, match, input ) "
"VALUES( ?, ?, ?, ?, ?" );
foreach( const dyncontrol_ptr& control, m_controls )
{
controlsQuery.addBindValue( control->id() );
controlsQuery.addBindValue( m_playlistguid );
controlsQuery.addBindValue( control->selectedType() );
controlsQuery.addBindValue( control->match() );
controlsQuery.addBindValue( control->input() );
controlsQuery.exec();
}
}

View File

@@ -1,70 +0,0 @@
#ifndef DATABASECOMMAND_SETDYNAMICPLAYLISTREVISION_H
#define DATABASECOMMAND_SETDYNAMICPLAYLISTREVISION_H
#include "databasecommand_setplaylistrevision.h"
#include "databaseimpl.h"
#include "tomahawk/collection.h"
#include "tomahawk/playlist.h"
#include "dynamic/GeneratorInterface.h"
using namespace Tomahawk;
class DatabaseCommand_SetDynamicPlaylistRevision : public DatabaseCommand_SetPlaylistRevision
{
Q_OBJECT
Q_PROPERTY( QString type READ type WRITE setType )
Q_PROPERTY( int mode READ mode WRITE setMode )
Q_PROPERTY( QVariantList controls READ controlsV WRITE setControlsV )
public:
explicit DatabaseCommand_SetDynamicPlaylistRevision( QObject* parent = 0 )
: DatabaseCommand_SetPlaylistRevision( parent )
{}
explicit DatabaseCommand_SetDynamicPlaylistRevision( const source_ptr& s,
const QString& playlistguid,
const QString& newrev,
const QString& oldrev,
const QStringList& orderedguids,
const QList<Tomahawk::plentry_ptr>& addedentries,
const QString& type,
GeneratorMode mode,
const QList< dyncontrol_ptr >& controls );
explicit DatabaseCommand_SetDynamicPlaylistRevision( const source_ptr& s,
const QString& playlistguid,
const QString& newrev,
const QString& oldrev,
const QString& type,
GeneratorMode mode,
const QList< dyncontrol_ptr >& controls );
QString commandname() const { return "setdynamicplaylistrevision"; }
virtual void exec( DatabaseImpl* lib );
virtual void postCommitHook();
virtual bool doesMutates() const { return true; }
void setControlsV( const QVariantList& vlist )
{
m_controlsV = vlist;
}
QVariantList controlsV();
QString type() const { return m_type; }
// GeneratorMode mode() const { return m_mode; }
int mode() const { return (int)m_mode; }
void setType( const QString& type ) { m_type = type; }
// void setMode( GeneratorMode mode ) { m_mode = mode; }
void setMode( int mode ) { m_mode = (GeneratorMode)mode; }
private:
QString m_type;
GeneratorMode m_mode;
QList< dyncontrol_ptr > m_controls;
QList< QVariant > m_controlsV;
};
#endif // DATABASECOMMAND_SETDYNAMICPLAYLISTREVISION_H

View File

@@ -1,36 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 "DynamicControl.h"
Tomahawk::DynamicControl::DynamicControl( const QStringList& typeSelectors )
: m_typeSelectors( typeSelectors )
{
}
Tomahawk::DynamicControl::~DynamicControl()
{
}
Tomahawk::DynamicControl::DynamicControl(const QString& selectedType, const QStringList& typeSelectors, QObject* parent)
: QObject(parent)
, m_selectedType( selectedType )
, m_typeSelectors( typeSelectors )
{
}

View File

@@ -1,108 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 DYNAMIC_PLAYLIST_CONTROL
#define DYNAMIC_PLAYLIST_CONTROL
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QStringList>
#include <QtGui/QWidget>
#include <tomahawk/typedefs.h>
namespace Tomahawk
{
/**
* A Dynamic Control is a single constraint that limits a dynamic playlist. Each generator creates controls specific to that generator.
* Each control has 3 pieces:
* - Type (string selector for what this control is matching)
* - Match selector (how to match the type to the input)
* - Input field (the user input field).
*
* Each control also has a list of TypeSelectors that comes from the generator, and only one is selected at once.
*
*/
class DynamicControl : public QObject
{
Q_OBJECT
Q_PROPERTY( QString id READ id WRITE setId )
Q_PROPERTY( QString selectedType READ selectedType WRITE setSelectedType )
Q_PROPERTY( QString match READ match WRITE setMatch )
Q_PROPERTY( QString input READ input WRITE setInput )
public:
DynamicControl( const QStringList& typeSelectors = QStringList() );
virtual ~DynamicControl();
/// The current type of this control
QString selectedType() const { return m_selectedType; }
/**
* The match selector widget based on this control's type
*
* The control manages the lifetime of the widget.
*/
virtual QWidget* matchSelector() { Q_ASSERT( false ); return 0; }
/**
* The input field widget that is associated with this type
*
* The control manages the lifetime of the widget.
*/
virtual QWidget* inputField() { Q_ASSERT( false ); return 0; }
/// the serializable value of the match
QString match() const { return m_match; }
/// the serializable value of the input
QString input() const { return m_input; }
// used by JSON serialization
void setMatch( const QString& match ) { m_match = match; }
void setInput( const QString& input ) { m_input = input; }
/// All the potential type selectors for this control
QStringList typeSelectors() const { return m_typeSelectors; }
QString id() {
if( m_id.isEmpty() )
m_id = uuid();
return m_id;
};
void setId( const QString& id ) { m_id = id; }
public slots:
/**
* Sets the type to the newly specified one. Note that this will update the matchSelector
* and inputField widgets, so you should fetch the new widgets for use immediately.
*/
virtual void setSelectedType( const QString& selectedType ) { m_selectedType = selectedType; }
protected:
// Private constructor, you can't make one. Get it from your Generator.
explicit DynamicControl( const QString& selectedType, const QStringList& typeSelectors, QObject* parent = 0 );
QString m_match;
QString m_input;
private:
QString m_selectedType;
QStringList m_typeSelectors;
QString m_id;
};
};
#endif

View File

@@ -1,349 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 "DynamicPlaylist.h"
#include "tomahawk/tomahawkapp.h"
#include "GeneratorFactory.h"
#include "database.h"
#include "databasecommand.h"
#include "databasecommand_createdynamicplaylist.h"
#include "databasecommand_setdynamicplaylistrevision.h"
#include "databasecommand_loaddynamicplaylist.h"
using namespace Tomahawk;
DynamicPlaylist::DynamicPlaylist(const Tomahawk::source_ptr& author)
: Playlist(author)
{
qDebug() << Q_FUNC_INFO << "JSON";
}
DynamicPlaylist::~DynamicPlaylist()
{
}
// Called by loadAllPlaylists command
DynamicPlaylist::DynamicPlaylist ( const Tomahawk::source_ptr& src,
const QString& currentrevision,
const QString& title,
const QString& info,
const QString& creator,
const QString& type,
GeneratorMode mode,
bool shared,
int lastmod,
const QString& guid )
: Playlist( src, currentrevision, title, info, creator, shared, lastmod, guid )
{
qDebug() << "Creating Dynamic Playlist 1";
// TODO instantiate generator
m_generator = geninterface_ptr( GeneratorFactory::create( type ) );
m_generator->setMode( mode );
}
// called when a new playlist is created (no currentrevision, new guid)
DynamicPlaylist::DynamicPlaylist ( const Tomahawk::source_ptr& author,
const QString& guid,
const QString& title,
const QString& info,
const QString& creator,
const QString& type,
bool shared )
: Playlist ( author, guid, title, info, creator, shared )
{
qDebug() << "Creating Dynamic Playlist 2";
m_generator = geninterface_ptr( GeneratorFactory::create( type ) );
}
geninterface_ptr
DynamicPlaylist::generator() const
{
return m_generator;
}
GeneratorMode
DynamicPlaylist::mode() const
{
return m_generator->mode();
}
void
DynamicPlaylist::setGenerator(const Tomahawk::geninterface_ptr& gen_ptr)
{
m_generator = gen_ptr;
}
QString
DynamicPlaylist::type() const
{
return m_generator->type();
}
void
DynamicPlaylist::setMode(GeneratorMode mode)
{
m_generator->setMode( mode );
}
dynplaylist_ptr
DynamicPlaylist::create( const Tomahawk::source_ptr& author,
const QString& guid,
const QString& title,
const QString& info,
const QString& creator,
bool shared )
{
// default generator
QString type = "";
dynplaylist_ptr dynplaylist = dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, shared ) );
DatabaseCommand_CreateDynamicPlaylist* cmd = new DatabaseCommand_CreateDynamicPlaylist( author, dynplaylist );
connect( cmd, SIGNAL(finished()), dynplaylist.data(), SIGNAL(created()) );
APP->database()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
dynplaylist->reportCreated( dynplaylist );
return dynplaylist;
}
// create a new revision that will be a static playlist, as it has entries
void
DynamicPlaylist::createNewRevision( const QString& newrev,
const QString& oldrev,
const QString& type,
const QList< dyncontrol_ptr>& controls,
const QList< plentry_ptr >& entries )
{
// get the newly added tracks
QList< plentry_ptr > added = newEntries( entries );
QStringList orderedguids;
for( int i = 0; i < entries.size(); ++i )
orderedguids << entries.at(i)->guid();
// no conflict resolution or partial updating for controls. all or nothing baby
// source making the change (local user in this case)
source_ptr author = APP->sourcelist().getLocal();
// command writes new rev to DB and calls setRevision, which emits our signal
DatabaseCommand_SetDynamicPlaylistRevision* cmd =
new DatabaseCommand_SetDynamicPlaylistRevision( author,
guid(),
newrev,
oldrev,
orderedguids,
added,
type,
Static,
controls );
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
// create a new revision that will be an ondemand playlist, as it has no entries
void
DynamicPlaylist::createNewRevision( const QString& newrev,
const QString& oldrev,
const QString& type,
const QList< dyncontrol_ptr>& controls )
{
// can skip the entry stuff. just overwrite with new info
source_ptr author = APP->sourcelist().getLocal();
// command writes new rev to DB and calls setRevision, which emits our signal
DatabaseCommand_SetDynamicPlaylistRevision* cmd =
new DatabaseCommand_SetDynamicPlaylistRevision( author,
guid(),
newrev,
oldrev,
type,
OnDemand,
controls );
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
void
DynamicPlaylist::loadRevision( const QString& rev )
{
qDebug() << Q_FUNC_INFO << "Loading with:" << ( rev.isEmpty() ? currentrevision() : rev );
DatabaseCommand_LoadDynamicPlaylist* cmd = new DatabaseCommand_LoadDynamicPlaylist( rev.isEmpty() ? currentrevision() : rev );
if( m_generator->mode() == OnDemand ) {
connect( cmd, SIGNAL( done( QString,
bool,
QString,
QList< Tomahawk::dyncontrol_ptr>,
bool ) ),
SLOT( setRevision( QString,
bool,
QString,
QList< Tomahawk::dyncontrol_ptr>,
bool) ) );
} else if( m_generator->mode() == Static ) {
connect( cmd, SIGNAL( done( QString,
QList< QString >,
QList< QString >,
QString,
QList< Tomahawk::dyncontrol_ptr>,
bool,
QMap< QString, Tomahawk::plentry_ptr >,
bool ) ),
SLOT( setRevision( QString,
QList< QString >,
QList< QString >,
QString,
QList< Tomahawk::dyncontrol_ptr>,
bool,
QMap< QString, Tomahawk::plentry_ptr >,
bool ) ) );
}
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
bool
DynamicPlaylist::remove( const Tomahawk::dynplaylist_ptr& playlist )
{
// TODO
// DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeletePlaylist( playlist->author(), playlist->guid() );
// APP->database()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
return false;
}
void
DynamicPlaylist::reportCreated( const Tomahawk::dynplaylist_ptr& self )
{
qDebug() << Q_FUNC_INFO;
Q_ASSERT( self.data() == this );
// will emit Collection::playlistCreated(...)
author()->collection()->addDynamicPlaylist( self );
}
void
DynamicPlaylist::reportDeleted( const Tomahawk::dynplaylist_ptr& self )
{
qDebug() << Q_FUNC_INFO;
Q_ASSERT( self.data() == this );
// will emit Collection::playlistCreated(...)
author()->collection()->deleteDynamicPlaylist( self );
}
void DynamicPlaylist::addEntries(const QList< query_ptr >& queries, const QString& oldrev)
{
Q_ASSERT( m_generator->mode() == Static );
QList<plentry_ptr> el = addEntriesInternal( queries );
QString newrev = uuid();
createNewRevision( newrev, oldrev, m_generator->type(), m_generator->controls(), el );
}
void DynamicPlaylist::addEntry(const Tomahawk::query_ptr& query, const QString& oldrev)
{
QList<query_ptr> queries;
queries << query;
addEntries( queries, oldrev );
}
// static version
void
DynamicPlaylist::setRevision( const QString& rev,
const QList< QString >& neworderedguids,
const QList< QString >& oldorderedguids,
const QString& type,
const QList< Tomahawk::dyncontrol_ptr>& controls,
bool is_newest_rev,
const QMap< QString, Tomahawk::plentry_ptr >& addedmap,
bool applied )
{
// we're probably being called by a database worker thread
if( QThread::currentThread() != thread() )
{
QMetaObject::invokeMethod( this,
"setRevision",
Qt::BlockingQueuedConnection,
Q_ARG( QString, rev ),
Q_ARG( QList<QString> , neworderedguids ),
Q_ARG( QList<QString> , oldorderedguids ),
Q_ARG( QString , type ),
QGenericArgument( "QList< Tomahawk::dyncontrol_ptr > " , (const void*)&controls ),
Q_ARG( bool, is_newest_rev ),
QGenericArgument( "QMap< QString,Tomahawk::plentry_ptr > " , (const void*)&addedmap ),
Q_ARG( bool, applied ) );
return;
}
if( m_generator->type() != type ) { // new generator needed
m_generator = GeneratorFactory::create( type );
}
m_generator->setControls( controls );
m_generator->setMode( Static );
DynamicPlaylistRevision pr = setNewRevision( rev, neworderedguids, oldorderedguids, is_newest_rev, addedmap );
pr.controls = controls;
pr.type = type;
pr.mode = Static;
if( applied )
setCurrentrevision( rev );
pr.applied = applied;
emit revisionLoaded( pr );
}
// ondemand version
void
DynamicPlaylist::setRevision( const QString& rev,
bool is_newest_rev,
const QString& type,
const QList< Tomahawk::dyncontrol_ptr>& controls,
bool applied )
{
if( QThread::currentThread() != thread() )
{
QMetaObject::invokeMethod( this,
"setRevision",
Qt::BlockingQueuedConnection,
Q_ARG( QString, rev ),
Q_ARG( bool, is_newest_rev ),
Q_ARG( QString, type ),
QGenericArgument( "QList< Tomahawk::dyncontrol_ptr >" , (const void*)&controls ),
Q_ARG( bool, applied ) );
return;
}
if( m_generator->type() != type ) { // new generator needed
m_generator = geninterface_ptr( GeneratorFactory::create( type ) );
}
m_generator->setControls( controls );
m_generator->setMode( OnDemand );
DynamicPlaylistRevision pr;
pr.oldrevisionguid = currentrevision();
pr.revisionguid = rev;
pr.controls = controls;
pr.type = type;
pr.mode = OnDemand;
emit revisionLoaded( pr );
}

View File

@@ -1,161 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 DYNAMIC_PLAYLIST_H
#define DYNAMIC_PLAYLIST_H
#include <QObject>
#include <QList>
#include <QSharedPointer>
#include "tomahawk/playlist.h"
#include "tomahawk/typedefs.h"
#include "dynamic/DynamicControl.h"
class DatabaseCommand_LoadAllDynamicPlaylists;
class DatabaseCommand_SetDynamicPlaylistRevision;
class DatabaseCommand_CreateDynamicPlaylist;
namespace Tomahawk {
/**
* Subclass of playlist that adds the information needed to store a dynamic playlist.
* It uses normal PlaylistEntries but also has a mode, a generator, and a list of controls
*/
struct DynamicPlaylistRevision : PlaylistRevision
{
QList< dyncontrol_ptr > controls;
Tomahawk::GeneratorMode mode;
QString type;
DynamicPlaylistRevision( const PlaylistRevision& other )
{
revisionguid = other.revisionguid;
oldrevisionguid = other.oldrevisionguid;
newlist = other.newlist;
added = other.added;
removed = other.removed;
applied = other.applied;
}
DynamicPlaylistRevision() {}
};
class DynamicPlaylist : public Playlist
{
Q_OBJECT
Q_PROPERTY( GeneratorMode mode WRITE setMode READ mode )
Q_PROPERTY( QString type WRITE setType READ type )
friend class ::DatabaseCommand_LoadAllDynamicPlaylists;
friend class ::DatabaseCommand_SetDynamicPlaylistRevision;
friend class ::DatabaseCommand_CreateDynamicPlaylist;
public:
virtual ~DynamicPlaylist();
/// Generate an empty dynamic playlist with default generator
static Tomahawk::dynplaylist_ptr create( const source_ptr& author,
const QString& guid,
const QString& title,
const QString& info,
const QString& creator,
bool shared
);
static bool remove( const dynplaylist_ptr& playlist );
virtual void loadRevision( const QString& rev = "" );
GeneratorMode mode() const;
QString type() const;
geninterface_ptr generator() const;
virtual void addEntries( const QList< query_ptr >& queries, const QString& oldrev );
virtual void addEntry( const Tomahawk::query_ptr& query, const QString& oldrev );
// <IGNORE hack="true">
// these need to exist and be public for the json serialization stuff
// you SHOULD NOT call them. They are used for an alternate CTOR method from json.
// maybe friend QObjectHelper and make them private?
explicit DynamicPlaylist( const source_ptr& author );
void setMode( GeneratorMode mode );
void setType( const QString& type ) { /** TODO */; }
void setGenerator( const geninterface_ptr& gen_ptr );
// </IGNORE>
signals:
/// emitted when the playlist revision changes (whenever the playlist changes)
void revisionLoaded( Tomahawk::DynamicPlaylistRevision );
public slots:
// want to update the playlist from the model?
// generate a newrev using uuid() and call this:
// if this is a static playlist, pass it a new list of entries. implicitly sets mode to static
void createNewRevision( const QString& newrev, const QString& oldrev, const QString& type, const QList< dyncontrol_ptr>& controls, const QList< plentry_ptr >& entries );
// if it is ondemand, no entries are needed implicitly sets mode to ondemand
void createNewRevision( const QString& newrev, const QString& oldrev, const QString& type, const QList< dyncontrol_ptr>& controls );
void reportCreated( const Tomahawk::dynplaylist_ptr& self );
void reportDeleted( const Tomahawk::dynplaylist_ptr& self );
// called from setdynamicplaylistrevision db cmd
// static version
void setRevision( const QString& rev,
const QList<QString>& neworderedguids,
const QList<QString>& oldorderedguids,
const QString& type,
const QList< Tomahawk::dyncontrol_ptr>& controls,
bool is_newest_rev,
const QMap< QString, Tomahawk::plentry_ptr >& addedmap,
bool applied );
// ondemand version
void setRevision( const QString& rev,
bool is_newest_rev,
const QString& type,
const QList< Tomahawk::dyncontrol_ptr>& controls,
bool applied );
private:
// called from loadAllPlaylists DB cmd:
explicit DynamicPlaylist( const source_ptr& src,
const QString& currentrevision,
const QString& title,
const QString& info,
const QString& creator,
const QString& type,
GeneratorMode mode,
bool shared,
int lastmod,
const QString& guid = "" ); // populate db
// called when creating new playlist
explicit DynamicPlaylist( const source_ptr& author,
const QString& guid,
const QString& title,
const QString& info,
const QString& creator,
const QString& type,
bool shared );
private:
geninterface_ptr m_generator;
};
}; // namespace
#endif

View File

@@ -16,7 +16,7 @@
#ifndef DYNAMIC_PLAYLIST_MODEL_H
#define DYNAMIC_PLAYLIST_MODEL_H
#include "tomahawk/typedefs.h"
#include "typedefs.h"
#include "playlist/playlistmodel.h"
/**

View File

@@ -1,27 +0,0 @@
#include "dynamic/GeneratorFactory.h"
#include "dynamic/GeneratorInterface.h"
using namespace Tomahawk;
QHash< QString, GeneratorFactoryInterface* > GeneratorFactory::s_factories = QHash< QString, GeneratorFactoryInterface* >();
geninterface_ptr GeneratorFactory::create ( const QString& type )
{
if( type.isEmpty() && !s_factories.isEmpty() ) // default, return first
return geninterface_ptr( s_factories.begin().value()->create() );
if( !s_factories.contains( type ) )
return geninterface_ptr();
return geninterface_ptr( s_factories.value( type )->create() );
}
void GeneratorFactory::registerFactory ( const QString& type, GeneratorFactoryInterface* interface )
{
s_factories.insert( type, interface );
}
QStringList GeneratorFactory::types()
{
return s_factories.keys();
}

View File

@@ -1,40 +0,0 @@
#ifndef GENERATOR_FACTORY_H
#define GENERATOR_FACTORY_H
#include <QHash>
#include <QString>
#include "dynamic/GeneratorInterface.h"
namespace Tomahawk {
/**
* Generators should subclass this and have it create the custom Generator
*/
class GeneratorFactoryInterface
{
public:
GeneratorFactoryInterface() {}
virtual GeneratorInterface* create() = 0;
};
/**
* Simple factory that generates Generators from string type descriptors
*/
class GeneratorFactory
{
public:
static geninterface_ptr create( const QString& type );
static void registerFactory( const QString& type, GeneratorFactoryInterface* interface );
static QStringList types();
private:
static QHash<QString, GeneratorFactoryInterface*> s_factories;
};
};
#endif

View File

@@ -1,67 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 "dynamic/GeneratorInterface.h"
// lame
Tomahawk::GeneratorInterface::GeneratorInterface()
{
}
Tomahawk::GeneratorInterface::GeneratorInterface( QObject* parent ): QObject( parent )
{
}
Tomahawk::GeneratorInterface::~GeneratorInterface()
{
}
QList< Tomahawk::dyncontrol_ptr >
Tomahawk::GeneratorInterface::controls()
{
if( m_controls.isEmpty() ) { // return a default control (so the user can add more)
return QList< Tomahawk::dyncontrol_ptr >() << createControl();
}
return m_controls;
}
void
Tomahawk::GeneratorInterface::addControl( const Tomahawk::dyncontrol_ptr& control )
{
m_controls << control;
}
void
Tomahawk::GeneratorInterface::clearControls()
{
m_controls.clear();
}
void
Tomahawk::GeneratorInterface::setControls( const QList< Tomahawk::dyncontrol_ptr >& controls )
{
m_controls = controls;
}
Tomahawk::dyncontrol_ptr Tomahawk::GeneratorInterface::createControl(const QString& type)
{
return dyncontrol_ptr();
}

View File

@@ -1,95 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 GENERATOR_INTERFACE_H
#define GENERATOR_INTERFACE_H
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QStringList>
#include "tomahawk/typedefs.h"
#include "tomahawk/query.h"
#include "dynamic/DynamicControl.h"
namespace Tomahawk {
/**
* The abstract interface for Dynamic Playlist Generators. Generators have the following features:
* - They create new DynamicControls that are appropriate for the generator
* - They expose a list of controls that this generator currently is operating on
* - They have a mode of OnDemand or Static
*
* And they generate tracks
*/
class GeneratorInterface : public QObject
{
Q_OBJECT
Q_PROPERTY( QString type READ type )
Q_PROPERTY( GeneratorMode mode READ mode WRITE setMode )
Q_ENUMS( GeneratorMode )
public:
// can't inline constructors/destructors for forward declared shared pointer types
GeneratorInterface();
explicit GeneratorInterface( QObject* parent = 0 );
virtual ~GeneratorInterface();
// Can't make it pure otherwise we can't shove it in QVariants :-/
// empty QString means use default
/// The generator will keep track of all the controls it creates. No need to tell it about controls
/// you ask it to create
virtual dyncontrol_ptr createControl( const QString& type = QString() );
/**
* Generate tracks from the controls in this playlist. If the current mode is
* OnDemand, then \p number is not taken into account. If this generator is in static
* mode, then it will return the desired number of tracks
*
* Connect to the generated() signal for the results.
*
*/
virtual void generate( int number = -1 ) {}
/// The type of this generator
QString type() const { return m_type; }
GeneratorMode mode() const { return m_mode; }
void setMode( GeneratorMode mode ) { m_mode = mode; }
// control functions
QList< dyncontrol_ptr > controls();
void addControl( const dyncontrol_ptr& control );
void clearControls();
void setControls( const QList< dyncontrol_ptr>& controls );
QStringList typeSelectors() const { return m_typeSelectors; }
signals:
void generated( const QList< Tomahawk::query_ptr>& queries );
protected:
QString m_type;
GeneratorMode m_mode;
QList< dyncontrol_ptr > m_controls;
QStringList m_typeSelectors;
};
typedef QSharedPointer<GeneratorInterface> geninterface_ptr;
};
#endif

View File

@@ -1,109 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 "echonest/EchonestControl.h"
#include <echonest/Playlist.h>
#include <QComboBox>
#include <QLineEdit>
Tomahawk::EchonestControl::EchonestControl( const QString& type, const QStringList& typeSelectors, QObject* parent )
: DynamicControl ( type.isEmpty() ? "Artist" : type, typeSelectors, parent )
{
updateWidgets();
}
QWidget*
Tomahawk::EchonestControl::inputField()
{
return m_input.data();
}
QWidget*
Tomahawk::EchonestControl::matchSelector()
{
return m_match.data();
}
void
Tomahawk::EchonestControl::setSelectedType ( const QString& type )
{
if( !m_input.isNull() )
delete m_input.data();
if( !m_match.isNull() )
delete m_match.data();
Tomahawk::DynamicControl::setSelectedType ( type );
updateWidgets();
}
Echonest::DynamicPlaylist::PlaylistParamData
Tomahawk::EchonestControl::toENParam() const
{
return m_data;
}
void
Tomahawk::EchonestControl::updateWidgets()
{
if( !m_input.isNull() )
delete m_input.data();
if( !m_match.isNull() )
delete m_match.data();
// make sure the widgets are the proper kind for the selected type, and hook up to their slots
if( selectedType() == "Artist" ) {
m_currentType = Echonest::DynamicPlaylist::Artist;
QComboBox* match = new QComboBox();
QLineEdit* input = new QLineEdit();
match->addItem( "Limit To", Echonest::DynamicPlaylist::ArtistType );
match->addItem( "Similar To", Echonest::DynamicPlaylist::ArtistRadioType );
input->setPlaceholderText( "Artist name" );
input->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Fixed );
connect( match, SIGNAL( currentIndexChanged(int) ), this, SLOT( updateData() ) );
connect( input, SIGNAL( textChanged(QString) ), this, SLOT( updateData() ) );
match->hide();
input->hide();
m_match = QWeakPointer< QWidget >( match );
m_input = QWeakPointer< QWidget >( input );
} else {
m_match = QWeakPointer<QWidget>( new QWidget );
m_input = QWeakPointer<QWidget>( new QWidget );
}
}
void
Tomahawk::EchonestControl::updateData()
{
qDebug() << "Sender:" << sender() << qobject_cast<QLineEdit*>(sender()) << m_input << qobject_cast<QLineEdit*>(m_input.data());
if( selectedType() == "Artist" ) {
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
if( combo ) {
}
QLineEdit* edit = qobject_cast<QLineEdit*>( m_input.data() );
if( edit && !edit->text().isEmpty() ) {
m_data.first = m_currentType;
m_data.second = edit->text();
}
}
}

View File

@@ -1,63 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 ECHONEST_CONTROL_H
#define ECHONEST_CONTROL_H
#include <echonest/Playlist.h>
#include "dynamic/DynamicControl.h"
namespace Tomahawk
{
class EchonestControl : public DynamicControl
{
Q_OBJECT
public:
virtual QWidget* inputField();
virtual QWidget* matchSelector();
/// Converts this to an echonest suitable parameter
Echonest::DynamicPlaylist::PlaylistParamData toENParam() const;
public slots:
virtual void setSelectedType ( const QString& type );
private slots:
void updateData();
protected:
explicit EchonestControl( const QString& type, const QStringList& typeSelectors, QObject* parent = 0 );
private:
void updateWidgets();
Echonest::DynamicPlaylist::PlaylistParam m_currentType;
QWeakPointer< QWidget > m_input;
QWeakPointer< QWidget > m_match;
Echonest::DynamicPlaylist::PlaylistParamData m_data;
friend class EchonestGenerator;
};
typedef QSharedPointer<EchonestControl> encontrol_ptr;
};
#endif

View File

@@ -1,112 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 "echonest/EchonestGenerator.h"
#include "echonest/EchonestControl.h"
#include "tomahawk/query.h"
using namespace Tomahawk;
EchonestFactory::EchonestFactory()
{}
GeneratorInterface*
EchonestFactory::create()
{
return new EchonestGenerator();
}
EchonestGenerator::EchonestGenerator ( QObject* parent )
: GeneratorInterface ( parent )
{
m_typeSelectors << "Artist" << "Variety" << "Description" << "Tempo" << "Duration" << "Loudness"
<< "Danceability" << "Energy" << "Artist Familiarity" << "Artist Hotttnesss" << "Song Familiarity"
<< "Longitude" << "Latitude" << "Mode" << "Key" << "Sorting";
m_type = "echonest";
m_mode = OnDemand;
}
EchonestGenerator::~EchonestGenerator()
{
}
dyncontrol_ptr
EchonestGenerator::createControl( const QString& type )
{
m_controls << dyncontrol_ptr( new EchonestControl( type, m_typeSelectors ) );
return m_controls.last();
}
void
EchonestGenerator::generate ( int number )
{
// convert to an echonest query, and fire it off
if( number < 0 ) { // dynamic
} else { // static
Echonest::DynamicPlaylist::PlaylistParams params;
foreach( const dyncontrol_ptr& control, m_controls ) {
params.append( control.dynamicCast<EchonestControl>()->toENParam() );
}
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Type, determineRadioType() ) );
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Results, number ) );
QNetworkReply* reply = Echonest::DynamicPlaylist::staticPlaylist( params );
qDebug() << "Generating a static playlist from echonest!" << reply->url().toString();
connect( reply, SIGNAL( finished() ), this, SLOT( staticFinished() ) );
}
}
void
EchonestGenerator::staticFinished()
{
Q_ASSERT( sender() );
Q_ASSERT( qobject_cast< QNetworkReply* >( sender() ) );
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
Echonest::SongList songs;
try {
songs = Echonest::DynamicPlaylist::parseStaticPlaylist( reply );
} catch( const Echonest::ParseError& e ) {
qWarning() << "libechonest threw an error trying to parse the static playlist!" << e.errorType() << e.what();
return;
}
QList< query_ptr > queries;
foreach( const Echonest::Song& song, songs ) {
qDebug() << "EchonestGenerator got song:" << song;
QVariantMap track;
track[ "artist" ] = song.artistName();
// track[ "album" ] = song.release(); // TODO should we include it? can be quite specific
track[ "track" ] = song.title();
queries << query_ptr( new Query( track ) );
}
emit generated( queries );
}
// tries to heuristically determine what sort of radio this is based on the controls
Echonest::DynamicPlaylist::ArtistTypeEnum EchonestGenerator::determineRadioType() const
{
// TODO
return Echonest::DynamicPlaylist::ArtistRadioType;
}

View File

@@ -1,58 +0,0 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 ECHONEST_GENERATOR_H
#define ECHONEST_GENERATOR_H
#include <echonest/Playlist.h>
#include "dynamic/GeneratorInterface.h"
#include "dynamic/GeneratorFactory.h"
#include "dynamic/DynamicControl.h"
namespace Tomahawk
{
class EchonestFactory : public GeneratorFactoryInterface
{
public:
EchonestFactory();
virtual GeneratorInterface* create();
};
class EchonestGenerator : public GeneratorInterface
{
Q_OBJECT
public:
explicit EchonestGenerator( QObject* parent = 0 );
virtual ~EchonestGenerator();
virtual dyncontrol_ptr createControl( const QString& type = QString() );
virtual void generate ( int number = -1 );
private slots:
void staticFinished();
private:
Echonest::DynamicPlaylist::ArtistTypeEnum determineRadioType() const;
};
};
#endif

View File

@@ -22,7 +22,7 @@
#include <QPainter>
#include "DynamicControlWidget.h"
#include "GeneratorInterface.h"
#include "dynamic/GeneratorInterface.h"
using namespace Tomahawk;

View File

@@ -18,7 +18,7 @@
#define DYNAMIC_CONTROL_LIST_H
#include "animatedsplitter.h"
#include "tomahawk/typedefs.h"
#include "typedefs.h"
#include "dynamic/DynamicPlaylist.h"
class QVBoxLayout;

View File

@@ -19,7 +19,7 @@
#include <QWidget>
#include "tomahawk/typedefs.h"
#include "typedefs.h"
class QStackedLayout;
class QEvent;

View File

@@ -18,15 +18,15 @@
#include <QVBoxLayout>
#include <QLabel>
#include <QComboBox>
#include <QPushButton>
#include "DynamicControlList.h"
#include "playlistview.h"
#include "playlistmodel.h"
#include "trackproxymodel.h"
#include "dynamic/GeneratorInterface.h"
#include <QComboBox>
#include "dynamic/GeneratorFactory.h"
#include <QPushButton>
using namespace Tomahawk;

View File

@@ -18,7 +18,7 @@
#define DYNAMIC_WIDGET_H
#include <QWidget>
#include <tomahawk/typedefs.h>
#include <typedefs.h>
class QVBoxLayout;
class QHBoxLayout;

View File

@@ -1,7 +1,10 @@
#ifndef ECHONESTPLUGIN_H
#define ECHONESTPLUGIN_H
#include "tomahawk/infosystem.h"
#include <QObject>
class QNetworkReply;
namespace Echonest {
class Artist;

View File

@@ -3,9 +3,9 @@
#include <QWidget>
#include "tomahawk/album.h"
#include "tomahawk/result.h"
#include "tomahawk/playlistinterface.h"
#include "album.h"
#include "result.h"
#include "playlistinterface.h"
class AlbumModel;
class CollectionFlatModel;

View File

@@ -0,0 +1,177 @@
project( tomahawklib )
SET( QT_USE_QTSQL TRUE )
SET( QT_USE_QTNETWORK TRUE )
SET( QT_USE_QTXML TRUE )
include( ${QT_USE_FILE} )
add_definitions( ${QT_DEFINITIONS} )
add_definitions( -DQT_SHARED )
add_definitions( -DDLLEXPORT_PRO )
set( libSources
tomahawksettings.cpp
sourcelist.cpp
pipeline.cpp
artist.cpp
album.cpp
collection.cpp
playlist.cpp
pluginapi.cpp
query.cpp
result.cpp
source.cpp
sip/SipPlugin.cpp
network/bufferiodevice.cpp
network/msgprocessor.cpp
network/filetransferconnection.cpp
network/dbsyncconnection.cpp
network/remotecollection.cpp
database/fuzzyindex.cpp
database/databaseworker.cpp
database/databaseimpl.cpp
database/databaseresolver.cpp
database/databasecommand.cpp
database/databasecommandloggable.cpp
database/databasecommand_resolve.cpp
database/databasecommand_allalbums.cpp
database/databasecommand_alltracks.cpp
database/databasecommand_addfiles.cpp
database/databasecommand_dirmtimes.cpp
database/databasecommand_loadfile.cpp
database/databasecommand_addsource.cpp
database/databasecommand_sourceoffline.cpp
database/databasecommand_collectionstats.cpp
database/databasecommand_loadplaylistentries.cpp
database/databasecommand_modifyplaylist.cpp
database/databasecommand_setplaylistrevision.cpp
database/databasecommand_loadallplaylists.cpp
database/databasecommand_createplaylist.cpp
database/databasecommand_deleteplaylist.cpp
database/databasecommand_renameplaylist.cpp
database/databasecommand_loadops.cpp
database/databasecommand_updatesearchindex.cpp
database/databasecollection.cpp
database/databasecommand_setdynamicplaylistrevision.cpp
database/databasecommand_createdynamicplaylist.cpp
database/databasecommand_loaddynamicplaylist.cpp
database/databasecommand_loadalldynamicplaylists.cpp
database/databasecommand_deletedynamicplaylist.cpp
dynamic/DynamicPlaylist.cpp
dynamic/DynamicControl.cpp
dynamic/GeneratorFactory.cpp
dynamic/GeneratorInterface.cpp
dynamic/echonest/EchonestGenerator.cpp
dynamic/echonest/EchonestControl.cpp
database/database.cpp
network/servent.cpp
network/connection.cpp
network/controlconnection.cpp
)
set( libHeaders
tomahawksettings.h
sourcelist.h
pipeline.h
functimeout.h
collection.h
pluginapi.h
query.h
resolver.h
result.h
source.h
artist.h
album.h
track.h
playlist.h
sip/SipPlugin.h
database/database.h
database/fuzzyindex.h
database/databaseworker.h
database/databaseimpl.h
database/databaseresolver.h
database/databasecommand.h
database/databasecommandloggable.h
database/databasecommand_resolve.h
database/databasecommand_allalbums.h
database/databasecommand_alltracks.h
database/databasecommand_addfiles.h
database/databasecommand_dirmtimes.h
database/databasecommand_loadfile.h
database/databasecommand_addsource.h
database/databasecommand_sourceoffline.h
database/databasecommand_collectionstats.h
database/databasecommand_loadplaylistentries.h
database/databasecommand_modifyplaylist.h
database/databasecommand_setplaylistrevision.h
database/databasecommand_loadallplaylists.h
database/databasecommand_createplaylist.h
database/databasecommand_deleteplaylist.h
database/databasecommand_renameplaylist.h
database/databasecommand_loadops.h
database/databasecommand_updatesearchindex.h
database/databasecollection.h
database/databasecommand_setdynamicplaylistrevision.h
database/databasecommand_createdynamicplaylist.h
database/databasecommand_loaddynamicplaylist.h
database/databasecommand_deletedynamicplaylist.h
database/databasecommand_loadalldynamicplaylists.h
dynamic/DynamicPlaylist.h
dynamic/DynamicControl.h
dynamic/GeneratorFactory.h
dynamic/GeneratorInterface.h
dynamic/echonest/EchonestGenerator.h
dynamic/echonest/EchonestControl.h
network/bufferiodevice.h
network/msgprocessor.h
network/remotecollection.h
network/filetransferconnection.h
network/dbsyncconnection.h
network/servent.h
network/connection.h
network/controlconnection.h
)
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
${QT_INCLUDE_DIR}
${LIBECHONEST_INCLUDE_DIR}
${LIBECHONEST_INCLUDE_DIR}/..
../../libportfwd/include
../../include
../network
../../qxt/qxtweb-standalone/qxtweb
)
qt4_wrap_cpp( libMoc ${libHeaders} )
add_library( tomahawklib SHARED ${libSources} ${libMoc} )
IF( WIN32 )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
"iphlpapi.a"
"ws2_32.dll"
"dnsapi.dll"
)
ENDIF( WIN32 )
target_link_libraries( tomahawklib
${QT_LIBRARIES}
${OS_SPECIFIC_LINK_LIBRARIES}
${LIBECHONEST_LIBRARY}
portfwd
qjson
)
install( TARGETS tomahawklib DESTINATION lib )

View File

@@ -1,9 +1,8 @@
#include "tomahawk/album.h"
#include "album.h"
#include <QDebug>
#include "tomahawk/collection.h"
#include "tomahawk/tomahawkapp.h"
#include "collection.h"
#include "database/database.h"
#include "database/databasecommand_alltracks.h"
@@ -77,7 +76,7 @@ Album::tracks()
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
return m_queries;

View File

@@ -4,16 +4,17 @@
#include <QObject>
#include <QSharedPointer>
#include "tomahawk/typedefs.h"
#include "tomahawk/artist.h"
#include "tomahawk/collection.h"
#include "typedefs.h"
#include "artist.h"
#include "collection.h"
#include "playlistinterface.h"
#include "tomahawk/playlistinterface.h"
#include "dllmacro.h"
namespace Tomahawk
{
class Album : public QObject, public PlaylistInterface
class DLLEXPORT Album : public QObject, public PlaylistInterface
{
Q_OBJECT

View File

@@ -1,14 +1,16 @@
#include "tomahawk/artist.h"
#include "artist.h"
#include <QDebug>
#include "tomahawk/collection.h"
#include "tomahawk/tomahawkapp.h"
#include "collection.h"
#include "database/database.h"
#include "database/databasecommand_alltracks.h"
using namespace Tomahawk;
Artist::Artist() {}
Artist::~Artist() {}
artist_ptr
Artist::get( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection )
@@ -33,3 +35,10 @@ Artist::Artist( unsigned int id, const QString& name, const Tomahawk::collection
, m_collection( collection )
{
}
Tomahawk::collection_ptr
Artist::collection() const
{
return m_collection;
}

View File

@@ -4,25 +4,26 @@
#include <QObject>
#include <QSharedPointer>
#include "tomahawk/typedefs.h"
#include "tomahawk/collection.h"
#include "typedefs.h"
#include "dllmacro.h"
namespace Tomahawk
{
class Artist : public QObject
class DLLEXPORT Artist : public QObject
{
Q_OBJECT
public:
static artist_ptr get( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection );
Artist();
Artist( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection );
virtual ~Artist();
unsigned int id() const { return m_id; }
QString name() const { return m_name; }
Tomahawk::collection_ptr collection() const { return m_collection; }
Tomahawk::collection_ptr collection() const;
// QList<Tomahawk::query_ptr> tracks();
// virtual int trackCount() const { return 0; }

View File

@@ -1,10 +1,10 @@
#include "tomahawk/collection.h"
#include "collection.h"
#include <QMetaObject>
#include <QGenericArgument>
#include "tomahawk/playlist.h"
#include "dynamic/DynamicPlaylist.h"
#include "playlist.h"
using namespace Tomahawk;

View File

@@ -13,17 +13,18 @@
#include <QSharedPointer>
#include <QDebug>
#include "tomahawk/functimeout.h"
#include "tomahawk/query.h"
#include "tomahawk/source.h"
#include "tomahawk/typedefs.h"
#include "functimeout.h"
#include "playlist.h"
#include "source.h"
#include "typedefs.h"
#include "dynamic/DynamicPlaylist.h"
#include "dllmacro.h"
namespace Tomahawk
{
class Collection : public QObject
class DLLEXPORT Collection : public QObject
{
Q_OBJECT

View File

@@ -1,5 +1,14 @@
#include "database.h"
Database* Database::s_instance = 0;
Database*
Database::instance()
{
return s_instance;
}
Database::Database( const QString& dbname, QObject* parent )
: QObject( parent )
@@ -7,6 +16,8 @@ Database::Database( const QString& dbname, QObject* parent )
, m_workerRO( new DatabaseWorker( m_impl, this, false ) )
, m_workerRW( new DatabaseWorker( m_impl, this, true ) )
{
s_instance = this;
m_workerRO->start();
m_workerRW->start();
}

View File

@@ -4,9 +4,11 @@
#include <QSharedPointer>
#include <QVariant>
#include "databaseimpl.h"
#include "databasecommand.h"
#include "databaseworker.h"
#include "database/databaseimpl.h"
#include "database/databasecommand.h"
#include "database/databaseworker.h"
#include "dllmacro.h"
/*
This class is really a firewall/pimpl - the public functions of LibraryImpl
@@ -19,10 +21,12 @@
Update: 1 thread for mutates, one for readonly queries.
*/
class Database : public QObject
class DLLEXPORT Database : public QObject
{
Q_OBJECT
public:
static Database* instance();
explicit Database( const QString& dbname, QObject* parent = 0 );
~Database();
@@ -43,6 +47,8 @@ private:
DatabaseImpl* m_impl;
DatabaseWorker *m_workerRO, *m_workerRW;
bool m_indexReady;
static Database* s_instance;
};
#endif // DATABASE_H

View File

@@ -1,7 +1,6 @@
#include "databasecollection.h"
#include "tomahawk/tomahawkapp.h"
#include "database.h"
#include "database/database.h"
#include "databasecommand_alltracks.h"
#include "databasecommand_addfiles.h"
#include "databasecommand_loadallplaylists.h"
@@ -25,7 +24,7 @@ DatabaseCollection::loadPlaylists()
connect( cmd, SIGNAL( done( const QList<Tomahawk::playlist_ptr>& ) ),
SLOT( setPlaylists( const QList<Tomahawk::playlist_ptr>& ) ) );
TomahawkApp::instance()->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
void
@@ -37,7 +36,7 @@ DatabaseCollection::loadDynamicPlaylists()
connect( cmd, SIGNAL( done( const QList<Tomahawk::dynplaylist_ptr>& ) ),
SLOT( setDynamicPlaylists( const QList<Tomahawk::dynplaylist_ptr>& ) ) );
TomahawkApp::instance()->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
@@ -53,7 +52,7 @@ DatabaseCollection::loadTracks()
/* connect( cmd, SIGNAL( done( Tomahawk::collection_ptr ) ),
SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ) );*/
TomahawkApp::instance()->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
@@ -63,7 +62,7 @@ DatabaseCollection::addTracks( const QList<QVariant> &newitems )
qDebug() << Q_FUNC_INFO << newitems.length();
DatabaseCommand_AddFiles* cmd = new DatabaseCommand_AddFiles( newitems, source() );
TomahawkApp::instance()->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}

View File

@@ -1,10 +1,12 @@
#ifndef DATABASECOLLECTION_H
#define DATABASECOLLECTION_H
#include "tomahawk/collection.h"
#include "tomahawk/typedefs.h"
#include "collection.h"
#include "typedefs.h"
class DatabaseCollection : public Tomahawk::Collection
#include "dllmacro.h"
class DLLEXPORT DatabaseCollection : public Tomahawk::Collection
{
Q_OBJECT

View File

@@ -6,13 +6,15 @@
#include <QTime>
#include <QSqlQuery>
#include "tomahawk/source.h"
#include "tomahawk/typedefs.h"
#include "source.h"
#include "typedefs.h"
#include "database/op.h"
#include "dllmacro.h"
class DatabaseImpl;
class DatabaseCommand : public QObject
class DLLEXPORT DatabaseCommand : public QObject
{
Q_OBJECT
Q_PROPERTY( QString guid READ guid WRITE setGuid )

View File

@@ -2,12 +2,11 @@
#include <QSqlQuery>
#include "tomahawk/collection.h"
#include "tomahawk/tomahawkapp.h"
#include "database.h"
#include "collection.h"
#include "database/database.h"
#include "databasecommand_collectionstats.h"
#include "databaseimpl.h"
#include "controlconnection.h"
#include "network/controlconnection.h"
using namespace Tomahawk;
@@ -49,10 +48,10 @@ DatabaseCommand_AddFiles::postCommitHook()
DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( source() );
connect( cmd, SIGNAL( done( const QVariantMap& ) ),
source().data(), SLOT( setStats( const QVariantMap& ) ), Qt::QueuedConnection );
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
if( source()->isLocal() )
APP->servent().triggerDBSync();
Servent::instance()->triggerDBSync();
}

View File

@@ -5,9 +5,11 @@
#include <QVariantMap>
#include "database/databasecommandloggable.h"
#include "tomahawk/typedefs.h"
#include "typedefs.h"
class DatabaseCommand_AddFiles : public DatabaseCommandLoggable
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_AddFiles : public DatabaseCommandLoggable
{
Q_OBJECT
Q_PROPERTY( QVariantList files READ files WRITE setFiles )

View File

@@ -6,7 +6,9 @@
#include "databasecommand.h"
class DatabaseCommand_addSource : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_addSource : public DatabaseCommand
{
Q_OBJECT

View File

@@ -5,11 +5,13 @@
#include <QVariantMap>
#include "databasecommand.h"
#include "tomahawk/album.h"
#include "tomahawk/collection.h"
#include "tomahawk/typedefs.h"
#include "album.h"
#include "collection.h"
#include "typedefs.h"
class DatabaseCommand_AllAlbums : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_AllAlbums : public DatabaseCommand
{
Q_OBJECT
public:

View File

@@ -5,11 +5,13 @@
#include <QVariantMap>
#include "databasecommand.h"
#include "tomahawk/album.h"
#include "tomahawk/collection.h"
#include "tomahawk/typedefs.h"
#include "album.h"
#include "collection.h"
#include "typedefs.h"
class DatabaseCommand_AllTracks : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_AllTracks : public DatabaseCommand
{
Q_OBJECT
public:

View File

@@ -4,10 +4,12 @@
#include <QVariantMap>
#include "databasecommand.h"
#include "tomahawk/source.h"
#include "tomahawk/typedefs.h"
#include "source.h"
#include "typedefs.h"
class DatabaseCommand_CollectionStats : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_CollectionStats : public DatabaseCommand
{
Q_OBJECT

View File

@@ -3,11 +3,12 @@
#include <QSqlQuery>
#include <QSqlDriver>
#include "tomahawk/tomahawkapp.h"
#include "dynamic/DynamicPlaylist.h"
#include "dynamic/DynamicControl.h"
#include "dynamic/GeneratorInterface.h"
#include "network/servent.h"
using namespace Tomahawk;
@@ -73,5 +74,5 @@ DatabaseCommand_CreateDynamicPlaylist::postCommitHook()
m_playlist->reportCreated( m_playlist );
if( source()->isLocal() )
APP->servent().triggerDBSync();
Servent::instance()->triggerDBSync();
}

View File

@@ -4,7 +4,7 @@
#include "databaseimpl.h"
#include "databasecommand_createplaylist.h"
#include "dynamic/DynamicPlaylist.h"
#include "tomahawk/typedefs.h"
#include "typedefs.h"
class DatabaseCommand_CreateDynamicPlaylist : public DatabaseCommand_CreatePlaylist
{

View File

@@ -2,7 +2,7 @@
#include <QSqlQuery>
#include "tomahawk/tomahawkapp.h"
#include "network/servent.h"
using namespace Tomahawk;
@@ -60,5 +60,5 @@ DatabaseCommand_CreatePlaylist::postCommitHook()
m_playlist->reportCreated( m_playlist );
if( source()->isLocal() )
APP->servent().triggerDBSync();
Servent::instance()->triggerDBSync();
}

View File

@@ -3,10 +3,12 @@
#include "databaseimpl.h"
#include "databasecommandloggable.h"
#include "tomahawk/playlist.h"
#include "tomahawk/typedefs.h"
#include "playlist.h"
#include "typedefs.h"
class DatabaseCommand_CreatePlaylist : public DatabaseCommandLoggable
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_CreatePlaylist : public DatabaseCommandLoggable
{
Q_OBJECT
Q_PROPERTY( QVariant playlist READ playlistV WRITE setPlaylistV )

View File

@@ -2,7 +2,7 @@
#include <QSqlQuery>
#include "tomahawk/tomahawkapp.h"
#include "network/servent.h"
using namespace Tomahawk;
@@ -41,5 +41,5 @@ DatabaseCommand_DeletePlaylist::postCommitHook()
playlist->reportDeleted( playlist );
if( source()->isLocal() )
APP->servent().triggerDBSync();
Servent::instance()->triggerDBSync();
}

View File

@@ -3,10 +3,12 @@
#include "databaseimpl.h"
#include "databasecommandloggable.h"
#include "tomahawk/source.h"
#include "tomahawk/typedefs.h"
#include "source.h"
#include "typedefs.h"
class DatabaseCommand_DeletePlaylist : public DatabaseCommandLoggable
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_DeletePlaylist : public DatabaseCommandLoggable
{
Q_OBJECT
Q_PROPERTY( QString playlistguid READ playlistguid WRITE setPlaylistguid )

View File

@@ -7,9 +7,11 @@
#include "databasecommand.h"
#include "dllmacro.h"
// Not loggable, mtimes only used to speed up our local scanner.
class DatabaseCommand_DirMtimes : public DatabaseCommand
class DLLEXPORT DatabaseCommand_DirMtimes : public DatabaseCommand
{
Q_OBJECT

View File

@@ -1,13 +1,17 @@
#ifndef DATABASECOMMAND_IMPORTPLAYLIST_H
#define DATABASECOMMAND_IMPORTPLAYLIST_H
#include <QObject>
#include <QVariantMap>
#include "databasecommand.h"
#include "tomahawk/source.h"
#include "dllmacro.h"
class Playlist;
class DatabaseCommand_ImportPlaylist : public DatabaseCommand
class DLLEXPORT DatabaseCommand_ImportPlaylist : public DatabaseCommand
{
Q_OBJECT
public:

View File

@@ -2,7 +2,7 @@
#include <QSqlQuery>
#include "tomahawk/playlist.h"
#include "playlist.h"
#include "databaseimpl.h"
using namespace Tomahawk;

View File

@@ -5,9 +5,11 @@
#include <QVariantMap>
#include "databasecommand.h"
#include "tomahawk/typedefs.h"
#include "typedefs.h"
class DatabaseCommand_LoadAllPlaylists : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_LoadAllPlaylists : public DatabaseCommand
{
Q_OBJECT

View File

@@ -1,7 +1,7 @@
#include "databasecommand_loadfile.h"
#include "databaseimpl.h"
#include "tomahawk/collection.h"
#include "collection.h"
DatabaseCommand_LoadFile::DatabaseCommand_LoadFile( const QString& id, QObject* parent )

View File

@@ -7,7 +7,9 @@
#include "databasecommand.h"
class DatabaseCommand_LoadFile : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_LoadFile : public DatabaseCommand
{
Q_OBJECT

View File

@@ -1,12 +1,14 @@
#ifndef DATABASECOMMAND_LOADOPS_H
#define DATABASECOMMAND_LOADOPS_H
#include "tomahawk/typedefs.h"
#include "typedefs.h"
#include "databasecommand.h"
#include "databaseimpl.h"
#include "op.h"
class DatabaseCommand_loadOps : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_loadOps : public DatabaseCommand
{
Q_OBJECT
public:

View File

@@ -5,9 +5,11 @@
#include <QVariantMap>
#include "databasecommand.h"
#include "tomahawk/playlist.h"
#include "playlist.h"
class DatabaseCommand_LoadPlaylistEntries : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_LoadPlaylistEntries : public DatabaseCommand
{
Q_OBJECT

View File

@@ -5,10 +5,12 @@
#include <QVariantMap>
#include "databasecommand.h"
#include "tomahawk/source.h"
#include "tomahawk/playlist.h"
#include "source.h"
#include "playlist.h"
class DatabaseCommand_ModifyPlaylist : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_ModifyPlaylist : public DatabaseCommand
{
Q_OBJECT
Q_PROPERTY( int mode READ mode WRITE setMode )

View File

@@ -2,7 +2,7 @@
#include <QSqlQuery>
#include "tomahawk/tomahawkapp.h"
#include "network/servent.h"
using namespace Tomahawk;
@@ -44,5 +44,5 @@ DatabaseCommand_RenamePlaylist::postCommitHook()
playlist->setTitle( m_playlistTitle );
if( source()->isLocal() )
APP->servent().triggerDBSync();
Servent::instance()->triggerDBSync();
}

View File

@@ -3,10 +3,12 @@
#include "databaseimpl.h"
#include "databasecommandloggable.h"
#include "tomahawk/source.h"
#include "tomahawk/typedefs.h"
#include "source.h"
#include "typedefs.h"
class DatabaseCommand_RenamePlaylist : public DatabaseCommandLoggable
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_RenamePlaylist : public DatabaseCommandLoggable
{
Q_OBJECT
Q_PROPERTY( QString playlistguid READ playlistguid WRITE setPlaylistguid )

View File

@@ -1,7 +1,7 @@
#include "databasecommand_resolve.h"
#include "tomahawk/tomahawkapp.h"
#include "tomahawk/album.h"
#include "album.h"
#include "sourcelist.h"
#define MINSCORE 0.5
@@ -114,13 +114,13 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib )
const QString url_str = files_query.value( 0 ).toString();
if( m_searchlocal )
{
coll = APP->sourcelist().getLocal()->collection();
coll = SourceList::instance()->getLocal()->collection();
m["url"] = url_str;
m["source"] = "Local Database"; // TODO
}
else
{
source_ptr s = APP->sourcelist().get( files_query.value( 13 ).toUInt() );
source_ptr s = SourceList::instance()->get( files_query.value( 13 ).toUInt() );
if( s.isNull() )
{
//qDebug() << "Skipping result for offline sourceid:" << files_query.value(13).toUInt();

View File

@@ -3,11 +3,13 @@
#include "databasecommand.h"
#include "databaseimpl.h"
#include "tomahawk/result.h"
#include "result.h"
#include <QVariant>
class DatabaseCommand_Resolve : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_Resolve : public DatabaseCommand
{
Q_OBJECT
public:

View File

@@ -3,7 +3,7 @@
#include <QSqlQuery>
#include "tomahawksqlquery.h"
#include "tomahawk/tomahawkapp.h"
#include "network/servent.h"
DatabaseCommand_SetPlaylistRevision::DatabaseCommand_SetPlaylistRevision(
@@ -56,7 +56,7 @@ DatabaseCommand_SetPlaylistRevision::postCommitHook()
m_applied );
if( source()->isLocal() )
APP->servent().triggerDBSync();
Servent::instance()->triggerDBSync();
}

View File

@@ -3,12 +3,14 @@
#include "databasecommandloggable.h"
#include "databaseimpl.h"
#include "tomahawk/collection.h"
#include "tomahawk/playlist.h"
#include "collection.h"
#include "playlist.h"
#include "dllmacro.h"
using namespace Tomahawk;
class DatabaseCommand_SetPlaylistRevision : public DatabaseCommandLoggable
class DLLEXPORT DatabaseCommand_SetPlaylistRevision : public DatabaseCommandLoggable
{
Q_OBJECT
Q_PROPERTY( QString playlistguid READ playlistguid WRITE setPlaylistguid )

View File

@@ -4,7 +4,9 @@
#include "databasecommand.h"
#include "databaseimpl.h"
class DatabaseCommand_SourceOffline : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_SourceOffline : public DatabaseCommand
{
Q_OBJECT

View File

@@ -4,7 +4,9 @@
#include "databasecommand.h"
#include "databaseimpl.h"
class DatabaseCommand_UpdateSearchIndex : public DatabaseCommand
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_UpdateSearchIndex : public DatabaseCommand
{
Q_OBJECT
public:

Some files were not shown because too many files have changed in this diff Show More