mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 15:29:42 +01:00
Merge branch 'master' into accounts
Conflicts: src/accounts/twitter/CMakeLists.txt src/accounts/zeroconf/CMakeLists.txt src/sip/jabber/CMakeLists.txt src/sip/jabber/googlewrapper/CMakeLists.txt
This commit is contained in:
commit
811b6842c5
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "thirdparty/jreen"]
|
||||
path = thirdparty/jreen
|
||||
url = git://github.com/euroelessar/jreen.git
|
@ -55,6 +55,9 @@ SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
|
||||
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
|
||||
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
|
||||
|
||||
# make predefined install dirs available everywhere
|
||||
INCLUDE(GNUInstallDirs)
|
||||
|
||||
# installer creation
|
||||
INCLUDE( TomahawkCPack.cmake )
|
||||
|
||||
@ -111,6 +114,13 @@ macro_log_feature(LIBATTICA_FOUND "libattica" "Provides support for automatic fe
|
||||
macro_optional_find_package(QuaZip)
|
||||
macro_log_feature(QuaZip_FOUND "QuaZip" "Provides support for extracting downloaded resolvers automatically." "http://quazip.sourceforge.net/" FALSE "" "")
|
||||
|
||||
macro_optional_find_package(Jreen)
|
||||
macro_log_feature(LIBJREEN_FOUND "Jreen" "Qt XMPP Library" "https://github.com/euroelessar/jreen" FALSE "" "Jreen is needed for the Jabber SIP plugin.\n")
|
||||
|
||||
macro_optional_find_package(QTweetLib)
|
||||
macro_log_feature(QTWEETLIB_FOUND "QTweetLib" "Qt Twitter Library" "https://github.com/minimoog/QTweetLib" FALSE "" "QTweetLib is needed for the Twitter SIP plugin.\n")
|
||||
|
||||
|
||||
IF( NOT QuaZip_FOUND )
|
||||
add_subdirectory( ${CMAKE_SOURCE_DIR}/src/libtomahawk/thirdparty/quazip )
|
||||
SET( QuaZip_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/libtomahawk/thirdparty/quazip )
|
||||
@ -130,29 +140,17 @@ ENDIF()
|
||||
set(LIBLASTFM_FOUND true)
|
||||
|
||||
#### submodules start
|
||||
# automatically init submodules here, don't delete this code we may add submodules again
|
||||
|
||||
# this installs headers and such and should really be handled in a separate package by packagers
|
||||
IF( INTERNAL_JREEN )
|
||||
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules)
|
||||
EXECUTE_PROCESS(COMMAND git submodule init WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
EXECUTE_PROCESS(COMMAND git submodule update WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules)
|
||||
ENDIF()
|
||||
|
||||
IF( INTERNAL_JREEN )
|
||||
ADD_SUBDIRECTORY( ${THIRDPARTY_DIR}/jreen )
|
||||
SET( LIBJREEN_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/include )
|
||||
SET( LIBJREEN_LIBRARY jreen )
|
||||
SET( LIBJREEN_LIBRARIES ${LIBJREEN_LIBRARY} )
|
||||
SET( LIBJREEN_FOUND true )
|
||||
MESSAGE(STATUS "INTERNAL libjreen: ${LIBJREEN_INCLUDE_DIR}, ${LIBJREEN_LIBRARY}")
|
||||
ELSE( INTERNAL_JREEN )
|
||||
macro_optional_find_package(Jreen)
|
||||
ENDIF( INTERNAL_JREEN )
|
||||
macro_log_feature(LIBJREEN_FOUND "Jreen" "Qt XMPP Library" "https://github.com/euroelessar/jreen" FALSE "" "Jreen is needed for the Jabber SIP plugin. \n\n Use -DINTERNAL_JREEN=ON to build the git submodule inside Tomahawk \n Be aware this installs a full jreen with headers and everything!\n")
|
||||
# IF( FALSE )
|
||||
# IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules)
|
||||
# EXECUTE_PROCESS(COMMAND git submodule init WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
# EXECUTE_PROCESS(COMMAND git submodule update WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
# ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules)
|
||||
# ENDIF()
|
||||
|
||||
macro_optional_find_package(QTweetLib)
|
||||
macro_log_feature(QTWEETLIB_FOUND "QTweetLib" "Qt Twitter Library" "https://github.com/minimoog/QTweetLib" FALSE "" "QTweetLib is needed for the Twitter SIP plugin.\n")
|
||||
#### submodules end
|
||||
|
||||
### libportfwd
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,9 +2,9 @@ FILE( GLOB _icons "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" )
|
||||
FOREACH( _file ${_icons} )
|
||||
STRING( REPLACE "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-" "" _res ${_file} )
|
||||
STRING( REPLACE ".png" "" _res ${_res} )
|
||||
INSTALL( FILES ${_file} RENAME tomahawk.png DESTINATION share/icons/hicolor/${_res}/apps )
|
||||
INSTALL( FILES ${_file} RENAME tomahawk.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/${_res}/apps )
|
||||
ENDFOREACH( _file )
|
||||
|
||||
INSTALL( FILES ${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon.svg RENAME tomahawk.svg DESTINATION share/icons/hicolor/scalable/apps )
|
||||
INSTALL( FILES ${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon.svg RENAME tomahawk.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps )
|
||||
|
||||
INSTALL( FILES ${CMAKE_SOURCE_DIR}/admin/unix/tomahawk.desktop DESTINATION share/applications )
|
||||
INSTALL( FILES ${CMAKE_SOURCE_DIR}/admin/unix/tomahawk.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications )
|
@ -13,6 +13,8 @@ SET( QT_USE_QTNETWORK TRUE )
|
||||
SET( QT_USE_QTXML TRUE )
|
||||
SET( QT_USE_QTWEBKIT TRUE )
|
||||
|
||||
add_definitions( -DQT_SHAREDPOINTER_TRACK_POINTERS )
|
||||
|
||||
INCLUDE( ${QT_USE_FILE} )
|
||||
INCLUDE( AddAppIconMacro )
|
||||
|
||||
@ -176,10 +178,10 @@ INCLUDE_DIRECTORIES(
|
||||
SET( OS_SPECIFIC_LINK_LIBRARIES "" )
|
||||
|
||||
IF( WIN32 )
|
||||
INCLUDE( "CMakeLists.win32.txt" )
|
||||
INCLUDE( "CMakeLists.win32.cmake" )
|
||||
ENDIF( WIN32 )
|
||||
IF( UNIX )
|
||||
INCLUDE( "CMakeLists.unix.txt" )
|
||||
INCLUDE( "CMakeLists.unix.cmake" )
|
||||
ENDIF( UNIX )
|
||||
|
||||
IF( APPLE )
|
||||
@ -205,6 +207,7 @@ IF(QCA2_FOUND)
|
||||
INCLUDE_DIRECTORIES( ${QCA2_INCLUDE_DIR} )
|
||||
ENDIF(QCA2_FOUND)
|
||||
|
||||
INCLUDE(GNUInstallDirs)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
@ -270,12 +273,12 @@ IF( APPLE )
|
||||
ENDIF(HAVE_SPARKLE)
|
||||
ENDIF( APPLE )
|
||||
|
||||
INSTALL( TARGETS tomahawk BUNDLE DESTINATION . RUNTIME DESTINATION bin )
|
||||
INSTALL( TARGETS tomahawk BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
|
||||
|
||||
IF( UNIX AND NOT APPLE AND KDE4_INSTALLED AND LEGACY_KDE_INTEGRATION ) #install protocol file
|
||||
FILE( READ ${CMAKE_SOURCE_DIR}/admin/unix/tomahawk.protocol protocol )
|
||||
STRING( REPLACE "/path/to/binary" # match this
|
||||
"${CMAKE_INSTALL_PREFIX}/bin/tomahawk" # this is linux (kde) so pretty safe I think
|
||||
"${CMAKE_INSTALL_FULL_BINDIR}/tomahawk" # this is linux (kde) so pretty safe I think
|
||||
edited_protocol # save in this variable
|
||||
"${protocol}" # from the contents of this var
|
||||
)
|
||||
@ -283,7 +286,7 @@ IF( UNIX AND NOT APPLE AND KDE4_INSTALLED AND LEGACY_KDE_INTEGRATION ) #install
|
||||
IF( ${SERVICES_INSTALL_DIR} )
|
||||
SET( PROTOCOL_INSTALL_DIR ${SERVICES_INSTALL_DIR} )
|
||||
ELSE()
|
||||
SET( PROTOCOL_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/kde4/services" )
|
||||
SET( PROTOCOL_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/kde4/services" )
|
||||
ENDIF()
|
||||
INSTALL( FILES ${CMAKE_BINARY_DIR}/tomahawk.protocol DESTINATION ${PROTOCOL_INSTALL_DIR} )
|
||||
ENDIF()
|
||||
|
@ -7,9 +7,9 @@ ADD_DEFINITIONS( -fPIC )
|
||||
SET( QXTWEB_LIBRARIES qxtweb-standalone )
|
||||
|
||||
IF( APPLE )
|
||||
INCLUDE( "CMakeLists.osx.txt" )
|
||||
INCLUDE( "CMakeLists.osx.cmake" )
|
||||
ENDIF( APPLE )
|
||||
|
||||
IF( UNIX AND NOT APPLE )
|
||||
INCLUDE( "CMakeLists.linux.txt" )
|
||||
INCLUDE( "CMakeLists.linux.cmake" )
|
||||
ENDIF( UNIX AND NOT APPLE )
|
@ -53,4 +53,4 @@ IF( APPLE )
|
||||
# SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
|
||||
ENDIF( APPLE )
|
||||
|
||||
install( TARGETS tomahawk_account_twitter DESTINATION lib${LIB_SUFFIX} )
|
||||
install( TARGETS tomahawk_account_twitter DESTINATION ${CMAKE_INSTALL_LIBDIR} )
|
||||
|
@ -58,7 +58,7 @@ IF( APPLE )
|
||||
# SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
|
||||
ENDIF( APPLE )
|
||||
|
||||
install( TARGETS tomahawk_account_xmpp DESTINATION lib${LIB_SUFFIX} )
|
||||
install( TARGETS tomahawk_account_xmpp DESTINATION ${CMAKE_INSTALL_LIBDIR} )
|
||||
|
||||
add_subdirectory(googlewrapper)
|
||||
|
||||
|
@ -34,4 +34,4 @@ target_link_libraries( tomahawk_account_google
|
||||
tomahawklib
|
||||
)
|
||||
|
||||
install( TARGETS tomahawk_account_google DESTINATION lib${LIB_SUFFIX} )
|
||||
install( TARGETS tomahawk_account_google DESTINATION ${CMAKE_INSTALL_LIBDIR} )
|
||||
|
@ -44,4 +44,4 @@ IF( APPLE )
|
||||
# SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
|
||||
ENDIF( APPLE )
|
||||
|
||||
install( TARGETS tomahawk_account_zeroconf DESTINATION lib${LIB_SUFFIX} )
|
||||
install( TARGETS tomahawk_account_zeroconf DESTINATION ${CMAKE_INSTALL_LIBDIR} )
|
@ -98,9 +98,12 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
ui->volumeSlider->setRange( 0, 100 );
|
||||
ui->volumeSlider->setValue( AudioEngine::instance()->volume() );
|
||||
|
||||
m_phononTickCheckTimer.setSingleShot( true );
|
||||
|
||||
m_sliderTimeLine.setCurveShape( QTimeLine::LinearCurve );
|
||||
ui->seekSlider->setTimeLine( &m_sliderTimeLine );
|
||||
|
||||
connect( &m_phononTickCheckTimer, SIGNAL( timeout() ), SLOT( phononTickCheckTimeout() ) );
|
||||
connect( &m_sliderTimeLine, SIGNAL( frameChanged( int ) ), ui->seekSlider, SLOT( setValue( int ) ) );
|
||||
|
||||
connect( ui->seekSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( seek( int ) ) );
|
||||
@ -176,6 +179,13 @@ AudioControls::changeEvent( QEvent* e )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::phononTickCheckTimeout()
|
||||
{
|
||||
onPlaybackTimer( m_lastSliderCheck );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onVolumeChanged( int volume )
|
||||
{
|
||||
@ -204,6 +214,8 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
||||
ui->seekSlider->setRange( 0, duration );
|
||||
ui->seekSlider->setValue( 0 );
|
||||
|
||||
m_phononTickCheckTimer.stop();
|
||||
|
||||
m_sliderTimeLine.stop();
|
||||
m_sliderTimeLine.setDuration( duration );
|
||||
m_sliderTimeLine.setFrameRange( 0, duration );
|
||||
@ -344,6 +356,7 @@ AudioControls::onPlaybackSeeked( qint64 msec )
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO << " setting current timer to " << msec;
|
||||
m_sliderTimeLine.setPaused( true );
|
||||
m_sliderTimeLine.setCurrentTime( msec );
|
||||
m_lastSliderCheck = msec;
|
||||
m_seekMsecs = msec;
|
||||
}
|
||||
|
||||
@ -373,16 +386,22 @@ AudioControls::onPlaybackStopped()
|
||||
void
|
||||
AudioControls::onPlaybackTimer( qint64 msElapsed )
|
||||
{
|
||||
// tDebug( LOGEXTRA ) << Q_FUNC_INFO << "msElapsed =" << msElapsed << "and timer current time =" << m_sliderTimeLine.currentTime() << "and m_seekMsecs =" << m_seekMsecs;
|
||||
if ( msElapsed > 0 && msElapsed - 500 < m_lastSliderCheck )
|
||||
//tDebug( LOGEXTRA ) << Q_FUNC_INFO << "msElapsed =" << msElapsed << "and timer current time =" << m_sliderTimeLine.currentTime() << "and m_seekMsecs =" << m_seekMsecs;
|
||||
if ( msElapsed > 0 && msElapsed != m_lastSliderCheck && m_seekMsecs == -1 && msElapsed - 500 < m_lastSliderCheck )
|
||||
return;
|
||||
m_lastSliderCheck = msElapsed;
|
||||
|
||||
if ( m_currentTrack.isNull() )
|
||||
{
|
||||
m_sliderTimeLine.stop();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ui->seekSlider->blockSignals( true );
|
||||
|
||||
if ( sender() != &m_phononTickCheckTimer )
|
||||
m_phononTickCheckTimer.start( 1000 );
|
||||
|
||||
const int seconds = msElapsed / 1000;
|
||||
ui->timeLabel->setText( TomahawkUtils::timeToString( seconds ) );
|
||||
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->duration() - seconds ) );
|
||||
@ -391,7 +410,10 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
|
||||
{
|
||||
if ( m_sliderTimeLine.currentTime() != msElapsed )
|
||||
{
|
||||
m_sliderTimeLine.setPaused( true );
|
||||
m_noTimeChange = false;
|
||||
m_sliderTimeLine.setCurrentTime( msElapsed );
|
||||
m_seekMsecs = -1;
|
||||
m_sliderTimeLine.resume();
|
||||
}
|
||||
}
|
||||
@ -405,10 +427,10 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
|
||||
|
||||
m_sliderTimeLine.setCurrentTime( msElapsed );
|
||||
m_seekMsecs = -1;
|
||||
if ( AudioEngine::instance()->state() != AudioEngine::Paused )
|
||||
if ( AudioEngine::instance()->state() != AudioEngine::Paused && sender() != &m_phononTickCheckTimer )
|
||||
m_sliderTimeLine.resume();
|
||||
}
|
||||
else if ( m_sliderTimeLine.duration() > msElapsed && m_sliderTimeLine.state() == QTimeLine::NotRunning )
|
||||
else if ( m_sliderTimeLine.duration() > msElapsed && m_sliderTimeLine.state() == QTimeLine::NotRunning && AudioEngine::instance()->state() == AudioEngine::Playing )
|
||||
{
|
||||
ui->seekSlider->setEnabled( AudioEngine::instance()->canSeek() );
|
||||
m_sliderTimeLine.start();
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define AUDIOCONTROLS_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QTimeLine>
|
||||
|
||||
#include "result.h"
|
||||
@ -51,7 +52,7 @@ signals:
|
||||
public slots:
|
||||
void onRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
|
||||
void onShuffleModeChanged( bool enabled );
|
||||
|
||||
|
||||
protected:
|
||||
void changeEvent( QEvent* e );
|
||||
void dragEnterEvent ( QDragEnterEvent* );
|
||||
@ -59,6 +60,8 @@ protected:
|
||||
void dropEvent ( QDropEvent* );
|
||||
|
||||
private slots:
|
||||
void phononTickCheckTimeout();
|
||||
|
||||
void onPlaybackStarted( const Tomahawk::result_ptr& result );
|
||||
void onPlaybackLoading( const Tomahawk::result_ptr& result );
|
||||
void onPlaybackPaused();
|
||||
@ -93,6 +96,7 @@ private:
|
||||
Tomahawk::PlaylistInterface::RepeatMode m_repeatMode;
|
||||
bool m_shuffled;
|
||||
|
||||
QTimer m_phononTickCheckTimer;
|
||||
QTimeLine m_sliderTimeLine;
|
||||
qint64 m_seekMsecs;
|
||||
qint64 m_lastSliderCheck;
|
||||
|
@ -82,14 +82,14 @@ BreakPad::BreakPad( const QString& path, bool active )
|
||||
|
||||
QString reporter;
|
||||
QString localReporter = QString( "%1/%2" ).arg( qApp->applicationDirPath() ).arg( CRASH_REPORTER_BINARY );
|
||||
QString globalReporter = QString( "%1/%2" ).arg( CMAKE_INSTALL_PREFIX "/" CMAKE_INSTALL_LIBEXECDIR ).arg( CRASH_REPORTER_BINARY );
|
||||
QString globalReporter = QString( "%1/%2" ).arg( CMAKE_INSTALL_FULL_LIBEXECDIR ).arg( CRASH_REPORTER_BINARY );
|
||||
|
||||
if ( QFileInfo( localReporter ).exists() )
|
||||
reporter = localReporter;
|
||||
else if ( QFileInfo( globalReporter ).exists() )
|
||||
reporter = globalReporter;
|
||||
else
|
||||
tLog() << "Could not find \"" CRASH_REPORTER_BINARY "\" in \"" CMAKE_INSTALL_PREFIX "/" CMAKE_INSTALL_LIBEXECDIR "\" or application path";
|
||||
tLog() << "Could not find \"" CRASH_REPORTER_BINARY "\" in \"" CMAKE_INSTALL_FULL_LIBEXECDIR "\" or application path";
|
||||
|
||||
char* creporter;
|
||||
std::string sreporter = reporter.toStdString();
|
||||
|
@ -22,4 +22,4 @@ ADD_EXECUTABLE( tomahawk_crash_reporter WIN32 ${crashreporter_SOURCES} ${crashre
|
||||
TARGET_LINK_LIBRARIES( tomahawk_crash_reporter ${QT_LIBRARIES} tomahawklib )
|
||||
|
||||
INCLUDE(GNUInstallDirs)
|
||||
install(TARGETS tomahawk_crash_reporter RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
|
||||
install(TARGETS tomahawk_crash_reporter RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_LIBEXECDIR})
|
||||
|
@ -9,7 +9,7 @@
|
||||
#cmakedefine DEBUG_BUILD
|
||||
|
||||
#define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
|
||||
#define CMAKE_INSTALL_LIBEXECDIR "${CMAKE_INSTALL_LIBEXECDIR}"
|
||||
#define CMAKE_INSTALL_FULL_LIBEXECDIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}"
|
||||
#define CMAKE_SYSTEM "${CMAKE_SYSTEM}"
|
||||
|
||||
#cmakedefine LION
|
||||
|
@ -11,6 +11,8 @@ include( ${QT_USE_FILE} )
|
||||
add_definitions( ${QT_DEFINITIONS} )
|
||||
add_definitions( -DQT_SHARED )
|
||||
add_definitions( -DDLLEXPORT_PRO )
|
||||
add_definitions( -DQT_SHAREDPOINTER_TRACK_POINTERS )
|
||||
|
||||
|
||||
set( libGuiSources
|
||||
actioncollection.cpp
|
||||
@ -41,26 +43,32 @@ set( libGuiSources
|
||||
|
||||
playlist/treemodel.cpp
|
||||
playlist/treeproxymodel.cpp
|
||||
playlist/treeproxymodelplaylistinterface.cpp
|
||||
playlist/treeheader.cpp
|
||||
playlist/treeitemdelegate.cpp
|
||||
playlist/collectionproxymodel.cpp
|
||||
playlist/collectionproxymodelplaylistinterface.cpp
|
||||
playlist/collectionflatmodel.cpp
|
||||
playlist/collectionview.cpp
|
||||
playlist/playlistmodel.cpp
|
||||
playlist/playlistproxymodel.cpp
|
||||
playlist/playlistproxymodelplaylistinterface.cpp
|
||||
playlist/playlistview.cpp
|
||||
playlist/playlistitemdelegate.cpp
|
||||
playlist/queueproxymodel.cpp
|
||||
playlist/queueproxymodelplaylistinterface.cpp
|
||||
playlist/queueview.cpp
|
||||
playlist/trackmodel.cpp
|
||||
playlist/trackmodelitem.cpp
|
||||
playlist/trackproxymodel.cpp
|
||||
playlist/trackproxymodelplaylistinterface.cpp
|
||||
playlist/trackview.cpp
|
||||
playlist/trackheader.cpp
|
||||
playlist/treemodelitem.cpp
|
||||
playlist/albumitem.cpp
|
||||
playlist/albummodel.cpp
|
||||
playlist/albumproxymodel.cpp
|
||||
playlist/albumproxymodelplaylistinterface.cpp
|
||||
playlist/albumitemdelegate.cpp
|
||||
playlist/albumview.cpp
|
||||
playlist/artistview.cpp
|
||||
@ -166,26 +174,32 @@ set( libGuiHeaders
|
||||
|
||||
playlist/treemodel.h
|
||||
playlist/treeproxymodel.h
|
||||
playlist/treeproxymodelplaylistinterface.h
|
||||
playlist/treeheader.h
|
||||
playlist/treeitemdelegate.h
|
||||
playlist/collectionproxymodel.h
|
||||
playlist/collectionproxymodelplaylistinterface.h
|
||||
playlist/collectionflatmodel.h
|
||||
playlist/collectionview.h
|
||||
playlist/playlistmodel.h
|
||||
playlist/playlistproxymodel.h
|
||||
playlist/playlistproxymodelplaylistinterface.h
|
||||
playlist/playlistview.h
|
||||
playlist/playlistitemdelegate.h
|
||||
playlist/queueproxymodel.h
|
||||
playlist/queueproxymodelplaylistinterface.h
|
||||
playlist/queueview.h
|
||||
playlist/trackmodel.h
|
||||
playlist/trackmodelitem.h
|
||||
playlist/trackproxymodel.h
|
||||
playlist/trackproxymodelplaylistinterface.h
|
||||
playlist/trackview.h
|
||||
playlist/trackheader.h
|
||||
playlist/treemodelitem.h
|
||||
playlist/albumitem.h
|
||||
playlist/albummodel.h
|
||||
playlist/albumproxymodel.h
|
||||
playlist/albumproxymodelplaylistinterface.h
|
||||
playlist/albumitemdelegate.h
|
||||
playlist/albumview.h
|
||||
playlist/artistview.h
|
||||
@ -275,9 +289,12 @@ set( libSources
|
||||
|
||||
aclsystem.cpp
|
||||
artist.cpp
|
||||
artistplaylistinterface.cpp
|
||||
album.cpp
|
||||
albumplaylistinterface.cpp
|
||||
collection.cpp
|
||||
playlist.cpp
|
||||
playlistplaylistinterface.cpp
|
||||
resolver.cpp
|
||||
ExternalResolver.cpp
|
||||
query.cpp
|
||||
@ -401,6 +418,8 @@ set( libHeaders
|
||||
pipeline.h
|
||||
functimeout.h
|
||||
|
||||
playlistinterface.h
|
||||
|
||||
aclsystem.h
|
||||
collection.h
|
||||
query.h
|
||||
@ -411,8 +430,11 @@ set( libHeaders
|
||||
sourceplaylistinterface.h
|
||||
|
||||
artist.h
|
||||
artistplaylistinterface.h
|
||||
album.h
|
||||
albumplaylistinterface.h
|
||||
playlist.h
|
||||
playlistplaylistinterface.h
|
||||
|
||||
accounts/Account.h
|
||||
accounts/AccountManager.h
|
||||
@ -600,6 +622,7 @@ IF( WIN32 )
|
||||
"dsound.dll"
|
||||
"winmm.dll"
|
||||
"advapi32.dll"
|
||||
"shlwapi.dll"
|
||||
)
|
||||
ENDIF( WIN32 )
|
||||
|
||||
@ -677,7 +700,7 @@ TARGET_LINK_LIBRARIES( tomahawklib
|
||||
)
|
||||
|
||||
INSTALL( TARGETS tomahawklib
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
|
@ -34,7 +34,7 @@ LatchManager::LatchManager( QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_state( NotLatched )
|
||||
{
|
||||
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistChanged( Tomahawk::PlaylistInterface* ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::playlistinterface_ptr ) ), this, SLOT( playlistChanged( Tomahawk::playlistinterface_ptr ) ) );
|
||||
}
|
||||
|
||||
LatchManager::~LatchManager()
|
||||
@ -58,11 +58,11 @@ LatchManager::latchRequest( const source_ptr& source )
|
||||
|
||||
m_state = Latching;
|
||||
m_waitingForLatch = source;
|
||||
AudioEngine::instance()->playItem( source->getPlaylistInterface().data(), source->getPlaylistInterface()->nextItem() );
|
||||
AudioEngine::instance()->playItem( source->getPlaylistInterface(), source->getPlaylistInterface()->nextItem() );
|
||||
}
|
||||
|
||||
void
|
||||
LatchManager::playlistChanged( PlaylistInterface* )
|
||||
LatchManager::playlistChanged( Tomahawk::playlistinterface_ptr )
|
||||
{
|
||||
// If we were latched on and changed, send the listening along stop
|
||||
if ( m_latchedOnTo.isNull() )
|
||||
@ -108,7 +108,7 @@ LatchManager::playlistChanged( PlaylistInterface* )
|
||||
m_latchedInterface.clear();
|
||||
|
||||
// call ourselves to hit the "create latch" condition
|
||||
playlistChanged( 0 );
|
||||
playlistChanged( Tomahawk::playlistinterface_ptr() );
|
||||
return;
|
||||
}
|
||||
m_latchedOnTo.clear();
|
||||
@ -133,7 +133,7 @@ LatchManager::unlatchRequest( const source_ptr& source )
|
||||
{
|
||||
Q_UNUSED( source );
|
||||
AudioEngine::instance()->stop();
|
||||
AudioEngine::instance()->setPlaylist( 0 );
|
||||
AudioEngine::instance()->setPlaylist( Tomahawk::playlistinterface_ptr() );
|
||||
|
||||
ActionCollection::instance()->getAction( "latchOn" )->setText( tr( "&Listen Along" ) );
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ public slots:
|
||||
void catchUpRequest();
|
||||
|
||||
private slots:
|
||||
|
||||
void playlistChanged( Tomahawk::PlaylistInterface* );
|
||||
void playlistChanged( Tomahawk::playlistinterface_ptr );
|
||||
|
||||
private:
|
||||
enum State {
|
||||
NotLatched = 0,
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "album.h"
|
||||
|
||||
#include "artist.h"
|
||||
#include "albumplaylistinterface.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databaseimpl.h"
|
||||
#include "database/databasecommand_alltracks.h"
|
||||
@ -63,12 +64,10 @@ Album::get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& ar
|
||||
|
||||
|
||||
Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist )
|
||||
: PlaylistInterface( this )
|
||||
: QObject()
|
||||
, m_id( id )
|
||||
, m_name( name )
|
||||
, m_artist( artist )
|
||||
, m_currentItem( 0 )
|
||||
, m_currentTrack( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
@ -78,65 +77,28 @@ Album::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_queries << tracks;
|
||||
Tomahawk::AlbumPlaylistInterface* api = dynamic_cast< Tomahawk::AlbumPlaylistInterface* >( getPlaylistInterface().data() );
|
||||
if ( api )
|
||||
api->addQueries( tracks );
|
||||
|
||||
emit tracksAdded( tracks );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
Album::siblingItem( int itemsAway )
|
||||
{
|
||||
int p = m_currentTrack;
|
||||
p += itemsAway;
|
||||
|
||||
if ( p < 0 )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
if ( p >= m_queries.count() )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
m_currentTrack = p;
|
||||
m_currentItem = m_queries.at( p )->results().first();
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
result_ptr
|
||||
Album::currentItem() const
|
||||
{
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
bool
|
||||
Album::hasNextItem()
|
||||
{
|
||||
int p = m_currentTrack;
|
||||
p++;
|
||||
if ( p < 0 || p >= m_queries.count() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
artist_ptr
|
||||
Album::artist() const
|
||||
{
|
||||
return m_artist;
|
||||
}
|
||||
|
||||
QList<Tomahawk::query_ptr>
|
||||
Album::tracks()
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
Album::getPlaylistInterface()
|
||||
{
|
||||
if ( m_queries.isEmpty() )
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks();
|
||||
cmd->setAlbum( this );
|
||||
cmd->setSortOrder( DatabaseCommand_AllTracks::AlbumPosition );
|
||||
|
||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
|
||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::AlbumPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
return m_queries;
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
}
|
@ -19,8 +19,8 @@
|
||||
#ifndef TOMAHAWKALBUM_H
|
||||
#define TOMAHAWKALBUM_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QSharedPointer>
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "playlistinterface.h"
|
||||
@ -29,7 +29,7 @@
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT Album : public QObject, public PlaylistInterface
|
||||
class DLLEXPORT Album : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -37,56 +37,33 @@ public:
|
||||
static album_ptr get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCreate = false );
|
||||
static album_ptr get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist );
|
||||
|
||||
Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist );
|
||||
~Album();
|
||||
explicit Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist );
|
||||
virtual ~Album();
|
||||
|
||||
unsigned int id() const { return m_id; }
|
||||
QString name() const { return m_name; }
|
||||
artist_ptr artist() const;
|
||||
|
||||
QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
virtual int trackCount() const { return m_queries.count(); }
|
||||
virtual int unfilteredTrackCount() const { return m_queries.count(); }
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||
|
||||
virtual bool hasNextItem();
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||
virtual void setShuffled( bool ) {}
|
||||
|
||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||
Tomahawk::playlistinterface_ptr getPlaylistInterface();
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
private slots:
|
||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||
|
||||
private:
|
||||
Album();
|
||||
Q_DISABLE_COPY( Album )
|
||||
explicit Album();
|
||||
|
||||
unsigned int m_id;
|
||||
QString m_name;
|
||||
|
||||
artist_ptr m_artist;
|
||||
QList<Tomahawk::query_ptr> m_queries;
|
||||
result_ptr m_currentItem;
|
||||
unsigned int m_currentTrack;
|
||||
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
};
|
||||
|
||||
}; // ns
|
||||
} // ns
|
||||
|
||||
#endif
|
||||
|
108
src/libtomahawk/albumplaylistinterface.cpp
Normal file
108
src/libtomahawk/albumplaylistinterface.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "albumplaylistinterface.h"
|
||||
|
||||
#include "artist.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databaseimpl.h"
|
||||
#include "database/databasecommand_alltracks.h"
|
||||
#include "query.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
AlbumPlaylistInterface::AlbumPlaylistInterface() {}
|
||||
|
||||
AlbumPlaylistInterface::AlbumPlaylistInterface( Tomahawk::Album *album )
|
||||
: Tomahawk::PlaylistInterface()
|
||||
, m_currentItem( 0 )
|
||||
, m_currentTrack( 0 )
|
||||
, m_album( QWeakPointer< Tomahawk::Album >( album ) )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AlbumPlaylistInterface::~AlbumPlaylistInterface()
|
||||
{
|
||||
m_album.clear();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
AlbumPlaylistInterface::siblingItem( int itemsAway )
|
||||
{
|
||||
int p = m_currentTrack;
|
||||
p += itemsAway;
|
||||
|
||||
if ( p < 0 )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
if ( p >= m_queries.count() )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
m_currentTrack = p;
|
||||
m_currentItem = m_queries.at( p )->results().first();
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
|
||||
result_ptr
|
||||
AlbumPlaylistInterface::currentItem() const
|
||||
{
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AlbumPlaylistInterface::hasNextItem()
|
||||
{
|
||||
int p = m_currentTrack;
|
||||
p++;
|
||||
if ( p < 0 || p >= m_queries.count() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QList< Tomahawk::query_ptr >
|
||||
AlbumPlaylistInterface::tracks()
|
||||
{
|
||||
if ( m_queries.isEmpty() && m_album )
|
||||
{
|
||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks();
|
||||
cmd->setAlbum( m_album.data() );
|
||||
cmd->setSortOrder( DatabaseCommand_AllTracks::AlbumPosition );
|
||||
|
||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
|
||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
return m_queries;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumPlaylistInterface::addQueries( const QList< query_ptr >& tracks )
|
||||
{
|
||||
m_queries << tracks;
|
||||
}
|
83
src/libtomahawk/albumplaylistinterface.h
Normal file
83
src/libtomahawk/albumplaylistinterface.h
Normal file
@ -0,0 +1,83 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TOMAHAWKALBUMPLAYLISTINTERFACE_H
|
||||
#define TOMAHAWKALBUMPLAYLISTINTERFACE_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QSharedPointer>
|
||||
|
||||
#include "album.h"
|
||||
#include "typedefs.h"
|
||||
#include "playlistinterface.h"
|
||||
#include "dllmacro.h"
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT AlbumPlaylistInterface : public Tomahawk::PlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AlbumPlaylistInterface( Tomahawk::Album *album );
|
||||
virtual ~AlbumPlaylistInterface();
|
||||
|
||||
QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
virtual int trackCount() const { return m_queries.count(); }
|
||||
virtual int unfilteredTrackCount() const { return m_queries.count(); }
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||
|
||||
virtual bool hasNextItem();
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||
virtual void setShuffled( bool ) {}
|
||||
|
||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||
|
||||
virtual void addQueries( const QList<Tomahawk::query_ptr>& tracks );
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY( AlbumPlaylistInterface )
|
||||
AlbumPlaylistInterface();
|
||||
|
||||
QList< Tomahawk::query_ptr > m_queries;
|
||||
result_ptr m_currentItem;
|
||||
unsigned int m_currentTrack;
|
||||
|
||||
QWeakPointer< Tomahawk::Album > m_album;
|
||||
};
|
||||
|
||||
}; // ns
|
||||
|
||||
#endif
|
@ -18,10 +18,10 @@
|
||||
|
||||
#include "artist.h"
|
||||
|
||||
#include "artistplaylistinterface.h"
|
||||
#include "collection.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databaseimpl.h"
|
||||
#include "database/databasecommand_alltracks.h"
|
||||
#include "query.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
@ -71,11 +71,9 @@ Artist::get( unsigned int id, const QString& name )
|
||||
|
||||
|
||||
Artist::Artist( unsigned int id, const QString& name )
|
||||
: PlaylistInterface( this )
|
||||
: QObject()
|
||||
, m_id( id )
|
||||
, m_name( name )
|
||||
, m_currentItem( 0 )
|
||||
, m_currentTrack( 0 )
|
||||
{
|
||||
m_sortname = DatabaseImpl::sortname( name, true );
|
||||
}
|
||||
@ -86,61 +84,19 @@ Artist::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_queries << tracks;
|
||||
Tomahawk::ArtistPlaylistInterface* api = dynamic_cast< Tomahawk::ArtistPlaylistInterface* >( getPlaylistInterface().data() );
|
||||
if ( api )
|
||||
api->addQueries( tracks );
|
||||
emit tracksAdded( tracks );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
Artist::siblingItem( int itemsAway )
|
||||
Tomahawk::playlistinterface_ptr
|
||||
Artist::getPlaylistInterface()
|
||||
{
|
||||
int p = m_currentTrack;
|
||||
p += itemsAway;
|
||||
|
||||
if ( p < 0 )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
if ( p >= m_queries.count() )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
m_currentTrack = p;
|
||||
m_currentItem = m_queries.at( p )->results().first();
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Artist::hasNextItem()
|
||||
{
|
||||
int p = m_currentTrack;
|
||||
p++;
|
||||
if ( p < 0 || p >= m_queries.count() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
result_ptr
|
||||
Artist::currentItem() const
|
||||
{
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
|
||||
QList<Tomahawk::query_ptr>
|
||||
Artist::tracks()
|
||||
{
|
||||
if ( m_queries.isEmpty() )
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks();
|
||||
cmd->setArtist( this );
|
||||
cmd->setSortOrder( DatabaseCommand_AllTracks::Album );
|
||||
|
||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
|
||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::ArtistPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
return m_queries;
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
@ -19,75 +19,49 @@
|
||||
#ifndef TOMAHAWKARTIST_H
|
||||
#define TOMAHAWKARTIST_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QSharedPointer>
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "playlistinterface.h"
|
||||
#include "dllmacro.h"
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT Artist : public QObject, public PlaylistInterface
|
||||
class DLLEXPORT Artist : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static artist_ptr get( const QString& name, bool autoCreate = false );
|
||||
static artist_ptr get( unsigned int id, const QString& name );
|
||||
Artist( unsigned int id, const QString& name );
|
||||
explicit Artist( unsigned int id, const QString& name );
|
||||
|
||||
Artist();
|
||||
explicit Artist();
|
||||
virtual ~Artist();
|
||||
|
||||
unsigned int id() const { return m_id; }
|
||||
QString name() const { return m_name; }
|
||||
QString sortname() const { return m_sortname; }
|
||||
|
||||
virtual QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
virtual int trackCount() const { return 0; }
|
||||
virtual int unfilteredTrackCount() const { return m_queries.count(); }
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||
|
||||
virtual bool hasNextItem();
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||
virtual void setShuffled( bool ) {}
|
||||
|
||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||
Tomahawk::playlistinterface_ptr getPlaylistInterface();
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
private slots:
|
||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(Artist)
|
||||
Q_DISABLE_COPY( Artist )
|
||||
|
||||
unsigned int m_id;
|
||||
QString m_name;
|
||||
QString m_sortname;
|
||||
|
||||
QList<Tomahawk::query_ptr> m_queries;
|
||||
result_ptr m_currentItem;
|
||||
unsigned int m_currentTrack;
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
};
|
||||
|
||||
}; // ns
|
||||
} // ns
|
||||
|
||||
#endif
|
||||
|
106
src/libtomahawk/artistplaylistinterface.cpp
Normal file
106
src/libtomahawk/artistplaylistinterface.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "artistplaylistinterface.h"
|
||||
|
||||
#include "artist.h"
|
||||
#include "collection.h"
|
||||
#include "query.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommand_alltracks.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
ArtistPlaylistInterface::ArtistPlaylistInterface( Tomahawk::Artist *artist )
|
||||
: Tomahawk::PlaylistInterface()
|
||||
, m_currentItem( 0 )
|
||||
, m_currentTrack( 0 )
|
||||
, m_artist( QWeakPointer< Tomahawk::Artist >( artist ) )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ArtistPlaylistInterface::~ArtistPlaylistInterface()
|
||||
{
|
||||
m_artist.clear();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
ArtistPlaylistInterface::siblingItem( int itemsAway )
|
||||
{
|
||||
int p = m_currentTrack;
|
||||
p += itemsAway;
|
||||
|
||||
if ( p < 0 )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
if ( p >= m_queries.count() )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
m_currentTrack = p;
|
||||
m_currentItem = m_queries.at( p )->results().first();
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ArtistPlaylistInterface::hasNextItem()
|
||||
{
|
||||
int p = m_currentTrack;
|
||||
p++;
|
||||
if ( p < 0 || p >= m_queries.count() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
result_ptr
|
||||
ArtistPlaylistInterface::currentItem() const
|
||||
{
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
|
||||
QList<Tomahawk::query_ptr>
|
||||
ArtistPlaylistInterface::tracks()
|
||||
{
|
||||
if ( m_queries.isEmpty() && m_artist )
|
||||
{
|
||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks();
|
||||
cmd->setArtist( m_artist.data() );
|
||||
cmd->setSortOrder( DatabaseCommand_AllTracks::Album );
|
||||
|
||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
|
||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
}
|
||||
|
||||
return m_queries;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ArtistPlaylistInterface::addQueries( const QList< query_ptr >& tracks )
|
||||
{
|
||||
m_queries << tracks;
|
||||
}
|
82
src/libtomahawk/artistplaylistinterface.h
Normal file
82
src/libtomahawk/artistplaylistinterface.h
Normal file
@ -0,0 +1,82 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TOMAHAWKARTISTPLAYLISTINTERFACE_H
|
||||
#define TOMAHAWKARTISTPLAYLISTINTERFACE_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QSharedPointer>
|
||||
|
||||
#include "artist.h"
|
||||
#include "typedefs.h"
|
||||
#include "playlistinterface.h"
|
||||
#include "dllmacro.h"
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT ArtistPlaylistInterface : public Tomahawk::PlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ArtistPlaylistInterface( Tomahawk::Artist *artist );
|
||||
virtual ~ArtistPlaylistInterface();
|
||||
|
||||
virtual QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
virtual int trackCount() const { return 0; }
|
||||
virtual int unfilteredTrackCount() const { return m_queries.count(); }
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||
|
||||
virtual bool hasNextItem();
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||
virtual void setShuffled( bool ) {}
|
||||
|
||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||
|
||||
virtual void addQueries( const QList<Tomahawk::query_ptr>& tracks );
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY( ArtistPlaylistInterface )
|
||||
|
||||
QList< Tomahawk::query_ptr > m_queries;
|
||||
result_ptr m_currentItem;
|
||||
unsigned int m_currentTrack;
|
||||
|
||||
QWeakPointer< Tomahawk::Artist > m_artist;
|
||||
};
|
||||
|
||||
}; // ns
|
||||
|
||||
#endif
|
@ -554,7 +554,7 @@ AudioEngine::loadNextTrack()
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::result_ptr& result )
|
||||
AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result )
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO << ( result.isNull() ? QString() : result->url() );
|
||||
|
||||
@ -562,7 +562,7 @@ AudioEngine::playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::re
|
||||
m_playlist.data()->reset();
|
||||
|
||||
setPlaylist( playlist );
|
||||
m_currentTrackPlaylist = playlist->getSharedPointer();
|
||||
m_currentTrackPlaylist = playlist;
|
||||
|
||||
if ( !result.isNull() )
|
||||
loadTrack( result );
|
||||
@ -678,26 +678,26 @@ AudioEngine::timerTriggered( qint64 time )
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::setPlaylist( PlaylistInterface* playlist )
|
||||
AudioEngine::setPlaylist( Tomahawk::playlistinterface_ptr playlist )
|
||||
{
|
||||
if ( !m_playlist.isNull() )
|
||||
{
|
||||
if ( m_playlist.data()->object() && m_playlist.data()->retryMode() == PlaylistInterface::Retry )
|
||||
disconnect( m_playlist.data()->object(), SIGNAL( nextTrackReady() ) );
|
||||
if ( m_playlist.data() && m_playlist.data()->retryMode() == PlaylistInterface::Retry )
|
||||
disconnect( m_playlist.data(), SIGNAL( nextTrackReady() ) );
|
||||
m_playlist.data()->reset();
|
||||
}
|
||||
|
||||
if ( !playlist )
|
||||
if ( playlist.isNull() )
|
||||
{
|
||||
m_playlist.clear();
|
||||
emit playlistChanged( playlist );
|
||||
return;
|
||||
}
|
||||
|
||||
m_playlist = playlist->getSharedPointer();
|
||||
m_playlist = playlist;
|
||||
|
||||
if ( m_playlist.data()->object() && m_playlist.data()->retryMode() == PlaylistInterface::Retry )
|
||||
connect( m_playlist.data()->object(), SIGNAL( nextTrackReady() ), SLOT( playlistNextTrackReady() ) );
|
||||
if ( !m_playlist.isNull() && m_playlist.data() && m_playlist.data()->retryMode() == PlaylistInterface::Retry )
|
||||
connect( m_playlist.data(), SIGNAL( nextTrackReady() ), SLOT( playlistNextTrackReady() ) );
|
||||
|
||||
emit playlistChanged( playlist );
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
#ifndef AUDIOENGINE_H
|
||||
#define AUDIOENGINE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
#include <phonon/MediaObject>
|
||||
#include <phonon/AudioOutput>
|
||||
@ -30,15 +30,12 @@
|
||||
|
||||
#include "result.h"
|
||||
#include "typedefs.h"
|
||||
#include "playlistinterface.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#define AUDIO_VOLUME_STEP 5
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
class PlaylistInterface;
|
||||
}
|
||||
|
||||
class DLLEXPORT AudioEngine : public QObject
|
||||
{
|
||||
@ -62,10 +59,10 @@ public:
|
||||
bool isStopped() const { return m_state == Stopped; }
|
||||
|
||||
/* Returns the PlaylistInterface of the currently playing track. Note: This might be different to the current playlist! */
|
||||
Tomahawk::PlaylistInterface* currentTrackPlaylist() const { return m_currentTrackPlaylist.data(); }
|
||||
Tomahawk::playlistinterface_ptr currentTrackPlaylist() const { return m_currentTrackPlaylist; }
|
||||
|
||||
/* Returns the PlaylistInterface of the current playlist. Note: The currently playing track might still be from a different playlist! */
|
||||
Tomahawk::PlaylistInterface* playlist() const { return m_playlist.data(); }
|
||||
Tomahawk::playlistinterface_ptr playlist() const { return m_playlist; }
|
||||
|
||||
Tomahawk::result_ptr currentTrack() const { return m_currentTrack; }
|
||||
|
||||
@ -93,9 +90,9 @@ public slots:
|
||||
void onVolumeChanged( qreal volume ) { emit volumeChanged( volume * 100 ); }
|
||||
void mute();
|
||||
|
||||
void playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::result_ptr& result );
|
||||
void setPlaylist( Tomahawk::PlaylistInterface* playlist );
|
||||
void setQueue( Tomahawk::PlaylistInterface* queue ) { m_queue = queue; }
|
||||
void playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result );
|
||||
void setPlaylist( Tomahawk::playlistinterface_ptr playlist );
|
||||
void setQueue( Tomahawk::playlistinterface_ptr queue ) { m_queue = queue; }
|
||||
|
||||
void playlistNextTrackReady();
|
||||
|
||||
@ -119,7 +116,7 @@ signals:
|
||||
void timerSeconds( unsigned int secondsElapsed );
|
||||
void timerPercentage( unsigned int percentage );
|
||||
|
||||
void playlistChanged( Tomahawk::PlaylistInterface* playlist );
|
||||
void playlistChanged( Tomahawk::playlistinterface_ptr playlist );
|
||||
|
||||
void error( AudioEngine::AudioErrorCode errorCode );
|
||||
|
||||
@ -147,9 +144,9 @@ private:
|
||||
|
||||
Tomahawk::result_ptr m_currentTrack;
|
||||
Tomahawk::result_ptr m_lastTrack;
|
||||
QWeakPointer< Tomahawk::PlaylistInterface > m_playlist;
|
||||
QWeakPointer< Tomahawk::PlaylistInterface > m_currentTrackPlaylist;
|
||||
Tomahawk::PlaylistInterface* m_queue;
|
||||
Tomahawk::playlistinterface_ptr m_playlist;
|
||||
Tomahawk::playlistinterface_ptr m_currentTrackPlaylist;
|
||||
Tomahawk::playlistinterface_ptr m_queue;
|
||||
|
||||
Phonon::MediaObject* m_mediaObject;
|
||||
Phonon::AudioOutput* m_audioOutput;
|
||||
|
@ -149,24 +149,24 @@ Collection::deleteStation( const dynplaylist_ptr& s )
|
||||
}
|
||||
|
||||
|
||||
playlist_ptr
|
||||
Tomahawk::playlist_ptr
|
||||
Collection::playlist( const QString& guid )
|
||||
{
|
||||
return m_playlists.value( guid, playlist_ptr() );
|
||||
return m_playlists.value( guid, Tomahawk::playlist_ptr() );
|
||||
}
|
||||
|
||||
|
||||
dynplaylist_ptr
|
||||
Tomahawk::dynplaylist_ptr
|
||||
Collection::autoPlaylist( const QString& guid )
|
||||
{
|
||||
return m_autoplaylists.value( guid, dynplaylist_ptr() );
|
||||
return m_autoplaylists.value( guid, Tomahawk::dynplaylist_ptr() );
|
||||
}
|
||||
|
||||
|
||||
dynplaylist_ptr
|
||||
Tomahawk::dynplaylist_ptr
|
||||
Collection::station( const QString& guid )
|
||||
{
|
||||
return m_stations.value( guid, dynplaylist_ptr() );
|
||||
return m_stations.value( guid, Tomahawk::dynplaylist_ptr() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
virtual ~ContextPage() {}
|
||||
|
||||
virtual QGraphicsWidget* widget() = 0;
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const = 0;
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const = 0;
|
||||
|
||||
virtual QString title() const = 0;
|
||||
virtual QString description() const = 0;
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
virtual QGraphicsWidget* widget() { return m_proxy; }
|
||||
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); }
|
||||
|
||||
virtual QString title() const { return tr( "Related Artists" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
virtual QGraphicsWidget* widget() { return m_proxy; }
|
||||
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); }
|
||||
|
||||
virtual QString title() const { return tr( "Top Hits" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
WikipediaContext() : WebContext() {}
|
||||
~WikipediaContext() {}
|
||||
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); }
|
||||
|
||||
virtual QString title() const { return tr( "Wikipedia" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
@ -61,7 +61,7 @@ public:
|
||||
LastfmContext() : WebContext() {}
|
||||
~LastfmContext() {}
|
||||
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); }
|
||||
|
||||
virtual QString title() const { return tr( "Last.fm" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -764,7 +764,7 @@ QList< query_ptr >
|
||||
DropJob::getArtist( const QString &artist )
|
||||
{
|
||||
artist_ptr artistPtr = Artist::get( artist );
|
||||
if ( artistPtr->tracks().isEmpty() )
|
||||
if ( artistPtr->getPlaylistInterface()->tracks().isEmpty() )
|
||||
{
|
||||
connect( artistPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||
@ -772,7 +772,7 @@ DropJob::getArtist( const QString &artist )
|
||||
return QList< query_ptr >();
|
||||
}
|
||||
else
|
||||
return artistPtr->tracks();
|
||||
return artistPtr->getPlaylistInterface()->tracks();
|
||||
}
|
||||
|
||||
|
||||
@ -785,7 +785,7 @@ DropJob::getAlbum(const QString &artist, const QString &album)
|
||||
if ( albumPtr.isNull() )
|
||||
return QList< query_ptr >();
|
||||
|
||||
if ( albumPtr->tracks().isEmpty() )
|
||||
if ( albumPtr->getPlaylistInterface()->tracks().isEmpty() )
|
||||
{
|
||||
m_dropJob = new DropJobNotifier( QPixmap( RESPATH "images/album-icon.png" ), Album );
|
||||
connect( albumPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
||||
@ -796,7 +796,7 @@ DropJob::getAlbum(const QString &artist, const QString &album)
|
||||
return QList< query_ptr >();
|
||||
}
|
||||
else
|
||||
return albumPtr->tracks();
|
||||
return albumPtr->getPlaylistInterface()->tracks();
|
||||
}
|
||||
|
||||
|
||||
|
@ -596,19 +596,19 @@ GlobalActionManager::handleAutoPlaylistCommand( const QUrl& url )
|
||||
}
|
||||
|
||||
|
||||
dynplaylist_ptr
|
||||
Tomahawk::dynplaylist_ptr
|
||||
GlobalActionManager::loadDynamicPlaylist( const QUrl& url, bool station )
|
||||
{
|
||||
QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command
|
||||
if( parts.isEmpty() ) {
|
||||
tLog() << "No specific station command:" << url.toString();
|
||||
return dynplaylist_ptr();
|
||||
return Tomahawk::dynplaylist_ptr();
|
||||
}
|
||||
|
||||
if( parts[ 0 ] == "create" ) {
|
||||
if( !url.hasQueryItem( "title" ) || !url.hasQueryItem( "type" ) ) {
|
||||
tLog() << "Station create command needs title and type..." << url.toString();
|
||||
return dynplaylist_ptr();
|
||||
return Tomahawk::dynplaylist_ptr();
|
||||
}
|
||||
QString title = url.queryItemValue( "title" );
|
||||
QString type = url.queryItemValue( "type" );
|
||||
@ -737,7 +737,7 @@ GlobalActionManager::loadDynamicPlaylist( const QUrl& url, bool station )
|
||||
return pl;
|
||||
}
|
||||
|
||||
return dynplaylist_ptr();
|
||||
return Tomahawk::dynplaylist_ptr();
|
||||
}
|
||||
|
||||
|
||||
@ -1012,7 +1012,7 @@ GlobalActionManager::waitingForResolved( bool /* success */ )
|
||||
// AudioEngine::instance()->playItem( AudioEngine::instance()->playlist(), m_waitingToPlay->results().first() );
|
||||
if ( sender() && sender()->property( "playNow" ).toBool() )
|
||||
{
|
||||
if ( AudioEngine::instance()->playlist() )
|
||||
if ( !AudioEngine::instance()->playlist().isNull() )
|
||||
AudioEngine::instance()->playItem( AudioEngine::instance()->playlist(), m_waitingToPlay->results().first() );
|
||||
else
|
||||
{
|
||||
|
@ -62,13 +62,13 @@ MprisPlugin::MprisPlugin()
|
||||
SLOT( onVolumeChanged( int ) ) );
|
||||
|
||||
// When the playlist changes, signals for several properties are sent
|
||||
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ),
|
||||
SLOT( onPlaylistChanged( Tomahawk::PlaylistInterface* ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::playlistinterface_ptr ) ),
|
||||
SLOT( onPlaylistChanged( Tomahawk::playlistinterface_ptr ) ) );
|
||||
|
||||
// When a track is added or removed, CanGoNext updated signal is sent
|
||||
PlaylistInterface *playlist = AudioEngine::instance()->playlist();
|
||||
if( playlist )
|
||||
connect( playlist->object(), SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
Tomahawk::playlistinterface_ptr playlist = AudioEngine::instance()->playlist();
|
||||
if( !playlist.isNull() )
|
||||
connect( playlist.data(), SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
|
||||
// Connect to AudioEngine's seeked signal
|
||||
@ -182,15 +182,15 @@ bool
|
||||
MprisPlugin::canPlay() const
|
||||
{
|
||||
// If there is a currently playing track, or if there is a playlist with at least 1 track, you can hit play
|
||||
PlaylistInterface *p = AudioEngine::instance()->playlist();
|
||||
return AudioEngine::instance()->currentTrack() || ( p && p->trackCount() );
|
||||
Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist();
|
||||
return AudioEngine::instance()->currentTrack() || ( !p.isNull() && p->trackCount() );
|
||||
}
|
||||
|
||||
bool
|
||||
MprisPlugin::canSeek() const
|
||||
{
|
||||
PlaylistInterface *p = AudioEngine::instance()->playlist();
|
||||
if (!p)
|
||||
Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist();
|
||||
if ( p.isNull() )
|
||||
return false;
|
||||
return p->seekRestrictions() != PlaylistInterface::NoSeek;
|
||||
|
||||
@ -199,8 +199,8 @@ MprisPlugin::canSeek() const
|
||||
QString
|
||||
MprisPlugin::loopStatus() const
|
||||
{
|
||||
PlaylistInterface *p = AudioEngine::instance()->playlist();
|
||||
if (!p)
|
||||
Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist();
|
||||
if ( p.isNull() )
|
||||
return "None";
|
||||
PlaylistInterface::RepeatMode mode = p->repeatMode();
|
||||
switch( mode )
|
||||
@ -225,8 +225,8 @@ MprisPlugin::loopStatus() const
|
||||
void
|
||||
MprisPlugin::setLoopStatus( const QString &value )
|
||||
{
|
||||
PlaylistInterface *p = AudioEngine::instance()->playlist();
|
||||
if (!p)
|
||||
Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist();
|
||||
if ( p.isNull() )
|
||||
return;
|
||||
if( value == "Track")
|
||||
p->setRepeatMode( PlaylistInterface::RepeatOne );
|
||||
@ -314,8 +314,8 @@ MprisPlugin::setRate( double value )
|
||||
bool
|
||||
MprisPlugin::shuffle() const
|
||||
{
|
||||
PlaylistInterface *p = AudioEngine::instance()->playlist();
|
||||
if (!p)
|
||||
Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist();
|
||||
if ( p.isNull() )
|
||||
return false;
|
||||
return p->shuffled();
|
||||
}
|
||||
@ -323,8 +323,8 @@ MprisPlugin::shuffle() const
|
||||
void
|
||||
MprisPlugin::setShuffle( bool value )
|
||||
{
|
||||
PlaylistInterface *p = AudioEngine::instance()->playlist();
|
||||
if (!p)
|
||||
Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist();
|
||||
if ( p.isNull() )
|
||||
return;
|
||||
return p->setShuffled( value );
|
||||
}
|
||||
@ -539,16 +539,16 @@ MprisPlugin::onVolumeChanged( int volume )
|
||||
}
|
||||
|
||||
void
|
||||
MprisPlugin::onPlaylistChanged( Tomahawk::PlaylistInterface* playlist )
|
||||
MprisPlugin::onPlaylistChanged( Tomahawk::playlistinterface_ptr playlist )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
disconnect( this, SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
qDebug() << "disconnected";
|
||||
if( playlist )
|
||||
if( !playlist.isNull() )
|
||||
qDebug() << "playlist not null";
|
||||
|
||||
if( playlist )
|
||||
connect( playlist->object(), SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
if( !playlist.isNull() )
|
||||
connect( playlist.data(), SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
|
||||
qDebug() << "connected new playlist";
|
||||
|
@ -146,7 +146,7 @@ protected slots:
|
||||
private slots:
|
||||
void stateChanged( AudioState newState, AudioState oldState );
|
||||
void onVolumeChanged( int volume );
|
||||
void onPlaylistChanged( Tomahawk::PlaylistInterface* playlist);
|
||||
void onPlaylistChanged( Tomahawk::playlistinterface_ptr );
|
||||
void onTrackCountChanged( unsigned int tracks );
|
||||
void onSeeked( qint64 ms );
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
#include "playlist.h"
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <QDomElement>
|
||||
#include <QtXml/QDomDocument>
|
||||
#include <QtXml/QDomElement>
|
||||
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommand_loadplaylistentries.h"
|
||||
@ -32,6 +32,7 @@
|
||||
#include "pipeline.h"
|
||||
#include "source.h"
|
||||
#include "sourcelist.h"
|
||||
#include "playlistplaylistinterface.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
#include "PlaylistUpdaterInterface.h"
|
||||
@ -562,17 +563,6 @@ Playlist::newEntries( const QList< plentry_ptr >& entries )
|
||||
}
|
||||
|
||||
|
||||
QList<Tomahawk::query_ptr>
|
||||
Playlist::tracks()
|
||||
{
|
||||
QList<Tomahawk::query_ptr> queries;
|
||||
foreach( const plentry_ptr& p, m_entries )
|
||||
queries << p->query();
|
||||
|
||||
return queries;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Playlist::setBusy( bool b )
|
||||
{
|
||||
@ -602,3 +592,15 @@ Playlist::checkRevisionQueue()
|
||||
createNewRevision( item.newRev, item.oldRev, item.entries );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
Playlist::getPlaylistInterface()
|
||||
{
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::PlaylistPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class DLLEXPORT Playlist : public QObject, public PlaylistInterface
|
||||
class DLLEXPORT Playlist : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QString guid READ guid WRITE setGuid )
|
||||
@ -132,7 +132,7 @@ friend class ::DatabaseCommand_CreatePlaylist;
|
||||
friend class DynamicPlaylist;
|
||||
|
||||
public:
|
||||
~Playlist();
|
||||
virtual ~Playlist();
|
||||
|
||||
static Tomahawk::playlist_ptr load( const QString& guid );
|
||||
|
||||
@ -180,28 +180,13 @@ public:
|
||||
void setCreatedOn( uint createdOn ) { m_createdOn = createdOn; }
|
||||
// </IGNORE>
|
||||
|
||||
virtual QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
virtual int unfilteredTrackCount() const { return m_entries.count(); }
|
||||
virtual int trackCount() const { return m_entries.count(); }
|
||||
|
||||
virtual bool hasNextItem() { return false; }
|
||||
virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; }
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int /*itemsAway*/ ) { return result_ptr(); }
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||
virtual void setShuffled( bool ) {}
|
||||
|
||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||
|
||||
QList<plentry_ptr> entriesFromQueries( const QList<Tomahawk::query_ptr>& queries, bool clearFirst = false );
|
||||
void setUpdater( PlaylistUpdaterInterface* interface ) { m_updater = interface; }
|
||||
PlaylistUpdaterInterface* updater() const { return m_updater; }
|
||||
|
||||
Tomahawk::playlistinterface_ptr getPlaylistInterface();
|
||||
|
||||
signals:
|
||||
/// emitted when the playlist revision changes (whenever the playlist changes)
|
||||
void revisionLoaded( Tomahawk::PlaylistRevision );
|
||||
@ -221,13 +206,6 @@ signals:
|
||||
/// was deleted, eh?
|
||||
void deleted( const Tomahawk::playlist_ptr& pl );
|
||||
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void nextTrackReady();
|
||||
public slots:
|
||||
// want to update the playlist from the model?
|
||||
// generate a newrev using uuid() and call this:
|
||||
@ -291,8 +269,6 @@ private:
|
||||
unsigned int m_createdOn;
|
||||
bool m_shared;
|
||||
|
||||
result_ptr m_currentItem;
|
||||
|
||||
QList< plentry_ptr > m_initEntries;
|
||||
QList< plentry_ptr > m_entries;
|
||||
|
||||
@ -303,9 +279,11 @@ private:
|
||||
bool m_locallyChanged;
|
||||
bool m_deleted;
|
||||
bool m_busy;
|
||||
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE( QSharedPointer< Tomahawk::Playlist > )
|
||||
|
||||
|
@ -20,10 +20,11 @@
|
||||
|
||||
#include "playlist.h"
|
||||
#include "utils/xspfloader.h"
|
||||
#include "tomahawksettings.h"
|
||||
#include "pipeline.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <tomahawksettings.h>
|
||||
#include <pipeline.h>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@ -66,46 +67,15 @@ XspfUpdater::playlistLoaded()
|
||||
XSPFLoader* loader = qobject_cast<XSPFLoader*>( sender() );
|
||||
Q_ASSERT( loader );
|
||||
|
||||
QList< query_ptr> oldqueries;
|
||||
foreach ( const plentry_ptr& ple, playlist()->entries() )
|
||||
oldqueries << ple->query();
|
||||
QList< query_ptr > tracks;
|
||||
foreach ( const plentry_ptr ple, playlist()->entries() )
|
||||
tracks << ple->query();
|
||||
|
||||
QList< query_ptr > newqueries = loader->entries();
|
||||
int sameCount = 0;
|
||||
QList< query_ptr > tosave = newqueries;
|
||||
foreach ( const query_ptr& newquery, newqueries )
|
||||
{
|
||||
foreach ( const query_ptr& oldq, oldqueries )
|
||||
{
|
||||
if ( newquery->track() == oldq->track() &&
|
||||
newquery->artist() == oldq->artist() &&
|
||||
newquery->album() == oldq->album() )
|
||||
{
|
||||
sameCount++;
|
||||
if ( tosave.contains( newquery ) )
|
||||
tosave.replace( tosave.indexOf( newquery ), oldq );
|
||||
QList< query_ptr > mergedTracks = TomahawkUtils::mergePlaylistChanges( tracks, loader->entries() );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No work to be done if all are the same
|
||||
if ( oldqueries.size() == newqueries.size() && sameCount == oldqueries.size() )
|
||||
return;
|
||||
|
||||
QList<plentry_ptr> el = playlist()->entriesFromQueries( tosave, true );
|
||||
QList<Tomahawk::plentry_ptr> el = playlist()->entriesFromQueries( mergedTracks, true );
|
||||
playlist()->createNewRevision( uuid(), playlist()->currentrevision(), el );
|
||||
|
||||
// // if there are any different from the current playlist, clear and use the new one, update
|
||||
// bool changed = ( queries.size() == playlist()->entries().count() );
|
||||
// if ( !changed )
|
||||
// {
|
||||
// foreach( const query_ptr& newSong, queries )
|
||||
// {
|
||||
// if ( !playlist()->entries.contains() )
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -129,7 +129,8 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
|
||||
QString text;
|
||||
QFont font = opt.font;
|
||||
QFont boldFont = opt.font;
|
||||
font.setPixelSize( 11 );
|
||||
QFont boldFont = font;
|
||||
boldFont.setBold( true );
|
||||
|
||||
QRect textRect = option.rect.adjusted( 0, option.rect.height() - 32, 0, -2 );
|
||||
@ -140,6 +141,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
else if ( !item->artist().isNull() )
|
||||
name = item->artist()->name();
|
||||
|
||||
painter->setFont( boldFont );
|
||||
bool oneLiner = false;
|
||||
if ( item->album().isNull() || item->album()->artist().isNull() )
|
||||
oneLiner = true;
|
||||
@ -149,14 +151,12 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
|
||||
if ( oneLiner )
|
||||
{
|
||||
painter->setFont( boldFont );
|
||||
to.setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
|
||||
text = painter->fontMetrics().elidedText( name, Qt::ElideRight, textRect.width() - 3 );
|
||||
painter->drawText( textRect, text, to );
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->setFont( boldFont );
|
||||
to.setAlignment( Qt::AlignHCenter | Qt::AlignTop );
|
||||
text = painter->fontMetrics().elidedText( item->album()->name(), Qt::ElideRight, textRect.width() - 3 );
|
||||
painter->drawText( textRect, text, to );
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QListView>
|
||||
|
||||
#include "albumproxymodelplaylistinterface.h"
|
||||
#include "artist.h"
|
||||
#include "albumitem.h"
|
||||
#include "query.h"
|
||||
@ -28,10 +29,7 @@
|
||||
|
||||
AlbumProxyModel::AlbumProxyModel( QObject* parent )
|
||||
: QSortFilterProxyModel( parent )
|
||||
, PlaylistInterface( this )
|
||||
, m_model( 0 )
|
||||
, m_repeatMode( PlaylistInterface::NoRepeat )
|
||||
, m_shuffled( false )
|
||||
{
|
||||
setFilterCaseSensitivity( Qt::CaseInsensitive );
|
||||
setSortCaseSensitivity( Qt::CaseInsensitive );
|
||||
@ -61,29 +59,6 @@ AlbumProxyModel::setSourceAlbumModel( AlbumModel* sourceModel )
|
||||
QSortFilterProxyModel::setSourceModel( sourceModel );
|
||||
}
|
||||
|
||||
QList< Tomahawk::query_ptr >
|
||||
AlbumProxyModel::tracks()
|
||||
{
|
||||
Q_ASSERT( FALSE );
|
||||
QList<Tomahawk::query_ptr> queries;
|
||||
return queries;
|
||||
}
|
||||
|
||||
Tomahawk::result_ptr
|
||||
AlbumProxyModel::currentItem() const
|
||||
{
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
void
|
||||
AlbumProxyModel::setFilter( const QString& pattern )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
setFilterRegExp( pattern );
|
||||
|
||||
emit filterChanged( pattern );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AlbumProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||
@ -165,10 +140,13 @@ AlbumProxyModel::removeIndexes( const QList<QModelIndex>& indexes )
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
AlbumProxyModel::siblingItem( int itemsAway )
|
||||
Tomahawk::playlistinterface_ptr
|
||||
AlbumProxyModel::getPlaylistInterface()
|
||||
{
|
||||
Q_UNUSED( itemsAway );
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
return Tomahawk::result_ptr( 0 );
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::AlbumProxyModelPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
@ -26,59 +26,38 @@
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class DLLEXPORT AlbumProxyModel : public QSortFilterProxyModel, public Tomahawk::PlaylistInterface
|
||||
class DLLEXPORT AlbumProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumProxyModel( QObject* parent = 0 );
|
||||
virtual ~AlbumProxyModel() {}
|
||||
|
||||
virtual AlbumModel* sourceModel() const { return m_model; }
|
||||
virtual void setSourceAlbumModel( AlbumModel* sourceModel );
|
||||
virtual void setSourceModel( QAbstractItemModel* sourceModel );
|
||||
|
||||
virtual QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
virtual int unfilteredTrackCount() const { return sourceModel()->rowCount( QModelIndex() ); }
|
||||
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
||||
virtual int albumCount() const { return rowCount( QModelIndex() ); }
|
||||
|
||||
virtual void removeIndex( const QModelIndex& index );
|
||||
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
||||
|
||||
virtual bool hasNextItem() { return true; }
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction );
|
||||
virtual void emitFilterChanged( const QString &pattern ) { emit filterChanged( pattern ); }
|
||||
|
||||
virtual void setFilter( const QString& pattern );
|
||||
|
||||
virtual Tomahawk::PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
||||
virtual bool shuffled() const { return m_shuffled; }
|
||||
virtual Tomahawk::PlaylistInterface::ViewMode viewMode() const { return Tomahawk::PlaylistInterface::Album; }
|
||||
virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void filterChanged( const QString& filter );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
|
||||
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||
bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
|
||||
|
||||
private:
|
||||
AlbumModel* m_model;
|
||||
RepeatMode m_repeatMode;
|
||||
bool m_shuffled;
|
||||
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
};
|
||||
|
||||
#endif // ALBUMPROXYMODEL_H
|
||||
|
100
src/libtomahawk/playlist/albumproxymodelplaylistinterface.cpp
Normal file
100
src/libtomahawk/playlist/albumproxymodelplaylistinterface.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "albumproxymodelplaylistinterface.h"
|
||||
|
||||
#include "albumproxymodel.h"
|
||||
#include "artist.h"
|
||||
#include "albumitem.h"
|
||||
#include "query.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
AlbumProxyModelPlaylistInterface::AlbumProxyModelPlaylistInterface( AlbumProxyModel *proxyModel )
|
||||
: Tomahawk::PlaylistInterface()
|
||||
, m_proxyModel( proxyModel )
|
||||
, m_repeatMode( PlaylistInterface::NoRepeat )
|
||||
, m_shuffled( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AlbumProxyModelPlaylistInterface::~AlbumProxyModelPlaylistInterface()
|
||||
{
|
||||
m_proxyModel.clear();
|
||||
}
|
||||
|
||||
|
||||
QList< Tomahawk::query_ptr >
|
||||
AlbumProxyModelPlaylistInterface::tracks()
|
||||
{
|
||||
Q_ASSERT( FALSE );
|
||||
QList<Tomahawk::query_ptr> queries;
|
||||
return queries;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
AlbumProxyModelPlaylistInterface::unfilteredTrackCount() const
|
||||
{
|
||||
return ( m_proxyModel.isNull() ? 0 : m_proxyModel.data()->sourceModel()->rowCount( QModelIndex() ) );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
AlbumProxyModelPlaylistInterface::trackCount() const
|
||||
{
|
||||
return ( m_proxyModel.isNull() ? 0 : m_proxyModel.data()->rowCount( QModelIndex() ) );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
AlbumProxyModelPlaylistInterface::currentItem() const
|
||||
{
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
AlbumProxyModelPlaylistInterface::filter() const
|
||||
{
|
||||
return ( m_proxyModel.isNull() ? QString() : m_proxyModel.data()->filterRegExp().pattern() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumProxyModelPlaylistInterface::setFilter( const QString& pattern )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( m_proxyModel.isNull() )
|
||||
return;
|
||||
|
||||
m_proxyModel.data()->setFilterRegExp( pattern );
|
||||
m_proxyModel.data()->emitFilterChanged( pattern );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
AlbumProxyModelPlaylistInterface::siblingItem( int itemsAway )
|
||||
{
|
||||
Q_UNUSED( itemsAway );
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
return Tomahawk::result_ptr( 0 );
|
||||
}
|
77
src/libtomahawk/playlist/albumproxymodelplaylistinterface.h
Normal file
77
src/libtomahawk/playlist/albumproxymodelplaylistinterface.h
Normal file
@ -0,0 +1,77 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ALBUMPROXYMODELPLAYLISTINTERFACE_H
|
||||
#define ALBUMPROXYMODELPLAYLISTINTERFACE_H
|
||||
|
||||
#include "playlistinterface.h"
|
||||
#include "playlist/albummodel.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class AlbumProxyModel;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT AlbumProxyModelPlaylistInterface : public Tomahawk::PlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumProxyModelPlaylistInterface( AlbumProxyModel *proxyModel );
|
||||
virtual ~AlbumProxyModelPlaylistInterface();
|
||||
|
||||
virtual QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
virtual int unfilteredTrackCount() const;
|
||||
virtual int trackCount() const;
|
||||
|
||||
virtual bool hasNextItem() { return true; }
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction );
|
||||
|
||||
virtual QString filter() const;
|
||||
virtual void setFilter( const QString& pattern );
|
||||
|
||||
virtual Tomahawk::PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
||||
virtual bool shuffled() const { return m_shuffled; }
|
||||
virtual Tomahawk::PlaylistInterface::ViewMode viewMode() const { return Tomahawk::PlaylistInterface::Album; }
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
|
||||
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
|
||||
|
||||
private:
|
||||
QWeakPointer< AlbumProxyModel > m_proxyModel;
|
||||
RepeatMode m_repeatMode;
|
||||
bool m_shuffled;
|
||||
};
|
||||
|
||||
} //ns
|
||||
|
||||
#endif // ALBUMPROXYMODELPLAYLISTINTERFACE_H
|
@ -219,7 +219,7 @@ AlbumView::resizeEvent( QResizeEvent* event )
|
||||
if ( autoFitItems() )
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
int scrollbar = !verticalScrollBar()->isVisible() ? verticalScrollBar()->rect().width() : 0;
|
||||
int scrollbar = verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0;
|
||||
#else
|
||||
int scrollbar = verticalScrollBar()->rect().width();
|
||||
#endif
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
void setModel( QAbstractItemModel* model );
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return proxyModel(); }
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); }
|
||||
|
||||
virtual QString title() const { return m_model->title(); }
|
||||
virtual QString description() const { return m_model->description(); }
|
||||
|
@ -188,7 +188,7 @@ ArtistView::onItemActivated( const QModelIndex& index )
|
||||
else if ( !item->result().isNull() && item->result()->isOnline() )
|
||||
{
|
||||
m_model->setCurrentItem( item->index );
|
||||
AudioEngine::instance()->playItem( m_proxyModel, item->result() );
|
||||
AudioEngine::instance()->playItem( m_proxyModel->getPlaylistInterface(), item->result() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -248,9 +248,9 @@ ArtistView::onFilterChanged( const QString& )
|
||||
if ( selectedIndexes().count() )
|
||||
scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter );
|
||||
|
||||
if ( !proxyModel()->filter().isEmpty() && !proxyModel()->trackCount() && model()->trackCount() )
|
||||
if ( !proxyModel()->getPlaylistInterface()->filter().isEmpty() && !proxyModel()->getPlaylistInterface()->trackCount() && model()->trackCount() )
|
||||
{
|
||||
m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->filter() ) );
|
||||
m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->getPlaylistInterface()->filter() ) );
|
||||
m_overlay->show();
|
||||
}
|
||||
else
|
||||
@ -332,7 +332,7 @@ ArtistView::onScrollTimeout()
|
||||
while ( right.isValid() && right.parent().isValid() )
|
||||
right = right.parent();
|
||||
|
||||
int max = m_proxyModel->trackCount();
|
||||
int max = m_proxyModel->getPlaylistInterface()->trackCount();
|
||||
if ( right.isValid() )
|
||||
max = right.row() + 1;
|
||||
|
||||
|
@ -19,13 +19,15 @@
|
||||
#ifndef ARTISTVIEW_H
|
||||
#define ARTISTVIEW_H
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QTreeView>
|
||||
#include <QTimer>
|
||||
#include <QtGui/QSortFilterProxyModel>
|
||||
#include <QtGui/QTreeView>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
#include "treeproxymodel.h"
|
||||
#include "viewpage.h"
|
||||
|
||||
#include "playlistinterface.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
namespace Tomahawk
|
||||
@ -60,7 +62,7 @@ public:
|
||||
void setTreeModel( TreeModel* model );
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return proxyModel(); }
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); }
|
||||
|
||||
virtual QString title() const { return m_model->title(); }
|
||||
virtual QString description() const { return m_model->description(); }
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "collectionproxymodel.h"
|
||||
|
||||
#include "collectionproxymodelplaylistinterface.h"
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
#include "album.h"
|
||||
@ -29,3 +31,14 @@ CollectionProxyModel::CollectionProxyModel( QObject* parent )
|
||||
: TrackProxyModel( parent )
|
||||
{
|
||||
}
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
CollectionProxyModel::getPlaylistInterface()
|
||||
{
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::CollectionProxyModelPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define COLLECTIONPROXYMODEL_H
|
||||
|
||||
#include "trackproxymodel.h"
|
||||
#include "trackproxymodelplaylistinterface.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
@ -29,8 +30,10 @@ Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CollectionProxyModel( QObject* parent = 0 );
|
||||
virtual ~CollectionProxyModel() {}
|
||||
|
||||
virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
|
||||
|
||||
virtual PlaylistInterface::ViewMode viewMode() const { return PlaylistInterface::Flat; }
|
||||
};
|
||||
|
||||
#endif // COLLECTIONPROXYMODEL_H
|
||||
|
@ -0,0 +1,36 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "collectionproxymodelplaylistinterface.h"
|
||||
|
||||
#include "collectionproxymodel.h"
|
||||
#include "album.h"
|
||||
#include "query.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
CollectionProxyModelPlaylistInterface::CollectionProxyModelPlaylistInterface( CollectionProxyModel *proxyModel )
|
||||
: TrackProxyModelPlaylistInterface( proxyModel )
|
||||
{
|
||||
}
|
||||
|
||||
CollectionProxyModelPlaylistInterface::~CollectionProxyModelPlaylistInterface()
|
||||
{
|
||||
m_proxyModel.clear();
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef COLLECTIONPROXYMODELPLAYLISTINTERFACE_H
|
||||
#define COLLECTIONPROXYMODELPLAYLISTINTERFACE_H
|
||||
|
||||
#include "trackproxymodel.h"
|
||||
#include "trackproxymodelplaylistinterface.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class CollectionProxyModel;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT CollectionProxyModelPlaylistInterface : public TrackProxyModelPlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CollectionProxyModelPlaylistInterface( CollectionProxyModel* proxyModel );
|
||||
virtual ~CollectionProxyModelPlaylistInterface();
|
||||
|
||||
virtual PlaylistInterface::ViewMode viewMode() const { return PlaylistInterface::Flat; }
|
||||
};
|
||||
|
||||
} //ns
|
||||
|
||||
#endif // COLLECTIONPROXYMODELPLAYLISTINTERFACE_H
|
@ -39,7 +39,7 @@ public:
|
||||
virtual void setModel( QAbstractItemModel* model );
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return proxyModel(); }
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); }
|
||||
|
||||
virtual QString title() const { return model()->title(); }
|
||||
virtual QString description() const { return model()->description(); }
|
||||
|
@ -41,12 +41,12 @@ CustomPlaylistView::CustomPlaylistView( CustomPlaylistView::PlaylistType type, c
|
||||
generateTracks();
|
||||
|
||||
if ( m_type == SourceLovedTracks )
|
||||
connect( m_source.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) );
|
||||
connect( m_source.data(), SIGNAL( socialAttributesChanged( QString ) ), this, SLOT( socialAttributesChanged( QString ) ) );
|
||||
else if ( m_type == AllLovedTracks )
|
||||
{
|
||||
connect( SourceList::instance()->getLocal().data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) );
|
||||
connect( SourceList::instance()->getLocal().data(), SIGNAL( socialAttributesChanged( QString ) ), this, SLOT( socialAttributesChanged( QString ) ) );
|
||||
foreach ( const source_ptr& s, SourceList::instance()->sources( true ) )
|
||||
connect( s.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) );
|
||||
connect( s.data(), SIGNAL( socialAttributesChanged( QString ) ), this, SLOT( socialAttributesChanged( QString ) ) );
|
||||
|
||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), this, SLOT( sourceAdded( Tomahawk::source_ptr ) ) );
|
||||
}
|
||||
@ -104,7 +104,10 @@ CustomPlaylistView::generateTracks()
|
||||
void
|
||||
CustomPlaylistView::tracksGenerated( QList< query_ptr > tracks )
|
||||
{
|
||||
m_model->append( tracks );
|
||||
QList< query_ptr > newTracks = TomahawkUtils::mergePlaylistChanges( m_model->queries(), tracks );
|
||||
|
||||
m_model->clear();
|
||||
m_model->append( newTracks );
|
||||
}
|
||||
|
||||
|
||||
@ -153,15 +156,17 @@ CustomPlaylistView::pixmap() const
|
||||
|
||||
|
||||
void
|
||||
CustomPlaylistView::reload()
|
||||
CustomPlaylistView::socialAttributesChanged( const QString& action )
|
||||
{
|
||||
m_model->clear();
|
||||
generateTracks();
|
||||
if ( action == "Love" )
|
||||
{
|
||||
generateTracks();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CustomPlaylistView::sourceAdded( const source_ptr& s )
|
||||
{
|
||||
connect( s.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) );
|
||||
connect( s.data(), SIGNAL( socialAttributesChanged( QString ) ), this, SLOT( socialAttributesChanged( QString ) ) );
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
private slots:
|
||||
void tracksGenerated( QList<Tomahawk::query_ptr> tracks );
|
||||
|
||||
void reload();
|
||||
void socialAttributesChanged( const QString& );
|
||||
void sourceAdded( const Tomahawk::source_ptr& );
|
||||
|
||||
private:
|
||||
|
@ -152,7 +152,7 @@ DynamicPlaylist::create( const Tomahawk::source_ptr& author,
|
||||
bool autoLoad
|
||||
)
|
||||
{
|
||||
dynplaylist_ptr dynplaylist = dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, mode, shared, autoLoad ) );
|
||||
dynplaylist_ptr dynplaylist = Tomahawk::dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, mode, shared, autoLoad ) );
|
||||
|
||||
DatabaseCommand_CreateDynamicPlaylist* cmd = new DatabaseCommand_CreateDynamicPlaylist( author, dynplaylist, autoLoad );
|
||||
connect( cmd, SIGNAL(finished()), dynplaylist.data(), SIGNAL(created()) );
|
||||
|
@ -55,7 +55,7 @@ struct DynQueueItem : RevisionQueueItem
|
||||
RevisionQueueItem( nRev, oRev, e, latest ), type( typ ), controls( ctrls ), mode( m ) {}
|
||||
};
|
||||
|
||||
class DLLEXPORT DynamicPlaylist : public Playlist
|
||||
class DLLEXPORT DynamicPlaylist : public Tomahawk::Playlist
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -98,7 +98,7 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
|
||||
connect( m_controls, SIGNAL( controlsChanged( bool ) ), this, SLOT( controlsChanged( bool ) ), Qt::QueuedConnection );
|
||||
|
||||
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), this, SLOT( trackStarted() ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistChanged( Tomahawk::PlaylistInterface* ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::playlistinterface_ptr ) ), this, SLOT( playlistChanged( Tomahawk::playlistinterface_ptr ) ) );
|
||||
}
|
||||
|
||||
|
||||
@ -200,10 +200,10 @@ DynamicWidget::onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev )
|
||||
}
|
||||
|
||||
|
||||
PlaylistInterface*
|
||||
Tomahawk::playlistinterface_ptr
|
||||
DynamicWidget::playlistInterface() const
|
||||
{
|
||||
return m_view->proxyModel();
|
||||
return m_view->proxyModel()->getPlaylistInterface();
|
||||
}
|
||||
|
||||
|
||||
@ -241,9 +241,9 @@ DynamicWidget::layoutFloatingWidgets()
|
||||
|
||||
|
||||
void
|
||||
DynamicWidget::playlistChanged( PlaylistInterface* pl )
|
||||
DynamicWidget::playlistChanged( Tomahawk::playlistinterface_ptr pl )
|
||||
{
|
||||
if( pl == static_cast< PlaylistInterface* >( m_view->proxyModel() ) ) { // same playlist
|
||||
if( pl == m_view->proxyModel()->getPlaylistInterface() ) { // same playlist
|
||||
m_activePlaylist = true;
|
||||
} else {
|
||||
m_activePlaylist = false;
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
void loadDynamicPlaylist( const dynplaylist_ptr& playlist );
|
||||
dynplaylist_ptr playlist();
|
||||
|
||||
virtual PlaylistInterface* playlistInterface() const;
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual void resizeEvent( QResizeEvent* );
|
||||
@ -88,7 +88,7 @@ public slots:
|
||||
void trackStarted();
|
||||
void stationFailed( const QString& );
|
||||
|
||||
void playlistChanged( Tomahawk::PlaylistInterface* );
|
||||
void playlistChanged( Tomahawk::playlistinterface_ptr );
|
||||
void tracksAdded();
|
||||
|
||||
signals:
|
||||
|
@ -79,7 +79,10 @@ PlaylistItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModel
|
||||
{
|
||||
int style = index.data( TrackModel::StyleRole ).toInt();
|
||||
if ( style == TrackModel::Short || style == TrackModel::ShortWithAvatars )
|
||||
size.setHeight( 44 );
|
||||
{
|
||||
int rowHeight = option.fontMetrics.height() + 8;
|
||||
size.setHeight( rowHeight * 2 );
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
@ -235,8 +238,7 @@ PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem&
|
||||
QString text = painter->fontMetrics().elidedText( upperText, Qt::ElideRight, r.width() );
|
||||
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_topOption );
|
||||
|
||||
|
||||
painter->setFont( opt.font);
|
||||
painter->setFont( opt.font );
|
||||
text = painter->fontMetrics().elidedText( lowerText, Qt::ElideRight, r.width() );
|
||||
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_bottomOption );
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ PlaylistModel::append( const Tomahawk::album_ptr& album )
|
||||
m_isTemporary = true;
|
||||
}
|
||||
|
||||
append( album->tracks() );
|
||||
append( album->getPlaylistInterface()->tracks() );
|
||||
}
|
||||
|
||||
|
||||
@ -172,7 +172,7 @@ PlaylistModel::append( const Tomahawk::artist_ptr& artist )
|
||||
m_isTemporary = true;
|
||||
}
|
||||
|
||||
append( artist->tracks() );
|
||||
append( artist->getPlaylistInterface()->tracks() );
|
||||
}
|
||||
|
||||
|
||||
@ -229,7 +229,7 @@ PlaylistModel::insert( const QList< Tomahawk::plentry_ptr >& entries, int row )
|
||||
TrackModelItem* plitem;
|
||||
foreach( const plentry_ptr& entry, entries )
|
||||
{
|
||||
plitem = new TrackModelItem( entry, m_rootItem, row + i );
|
||||
plitem = new TrackModelItem( entry, rootItem(), row + i );
|
||||
plitem->index = createIndex( row + i, 0, plitem );
|
||||
i++;
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "playlistproxymodel.h"
|
||||
|
||||
#include "playlistproxymodelplaylistinterface.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
|
||||
@ -25,3 +26,14 @@ PlaylistProxyModel::PlaylistProxyModel( QObject* parent )
|
||||
: TrackProxyModel( parent )
|
||||
{
|
||||
}
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
PlaylistProxyModel::getPlaylistInterface()
|
||||
{
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::PlaylistProxyModelPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -29,6 +29,9 @@ Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlaylistProxyModel( QObject* parent = 0 );
|
||||
virtual ~PlaylistProxyModel() {}
|
||||
|
||||
virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
|
||||
};
|
||||
|
||||
#endif // PLAYLISTPROXYMODEL_H
|
||||
|
@ -0,0 +1,34 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "playlistproxymodelplaylistinterface.h"
|
||||
|
||||
#include "playlistproxymodel.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
PlaylistProxyModelPlaylistInterface::PlaylistProxyModelPlaylistInterface( PlaylistProxyModel *proxyModel )
|
||||
: TrackProxyModelPlaylistInterface( proxyModel )
|
||||
{
|
||||
}
|
||||
|
||||
PlaylistProxyModelPlaylistInterface::~PlaylistProxyModelPlaylistInterface()
|
||||
{
|
||||
m_proxyModel.clear();
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PLAYLISTPROXYMODELPLAYLISTINTERFACE_H
|
||||
#define PLAYLISTPROXYMODELPLAYLISTINTERFACE_H
|
||||
|
||||
#include "trackproxymodelplaylistinterface.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class PlaylistProxyModel;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT PlaylistProxyModelPlaylistInterface : public TrackProxyModelPlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlaylistProxyModelPlaylistInterface( PlaylistProxyModel *proxyModel );
|
||||
virtual ~PlaylistProxyModelPlaylistInterface();
|
||||
};
|
||||
|
||||
} //ns
|
||||
|
||||
#endif // PLAYLISTPROXYMODELPLAYLISTINTERFACE_H
|
@ -31,14 +31,14 @@ Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlaylistView( QWidget* parent = 0 );
|
||||
~PlaylistView();
|
||||
virtual ~PlaylistView();
|
||||
|
||||
PlaylistModel* playlistModel() const { return m_model; }
|
||||
virtual void setPlaylistModel( PlaylistModel* model );
|
||||
virtual void setModel( QAbstractItemModel* model );
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return proxyModel(); }
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); }
|
||||
|
||||
virtual bool showFilter() const { return true; }
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "queueproxymodel.h"
|
||||
|
||||
#include "queueproxymodelplaylistinterface.h"
|
||||
#include "playlist/trackview.h"
|
||||
#include "viewmanager.h"
|
||||
#include "utils/logger.h"
|
||||
@ -31,7 +32,7 @@ QueueProxyModel::QueueProxyModel( TrackView* parent )
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
connect( parent, SIGNAL( itemActivated( QModelIndex ) ), this, SLOT( onIndexActivated( QModelIndex ) ) );
|
||||
connect( this, SIGNAL( sourceTrackCountChanged( unsigned int ) ), this, SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
connect( getPlaylistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ), this, SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
}
|
||||
|
||||
|
||||
@ -48,21 +49,21 @@ QueueProxyModel::onIndexActivated( const QModelIndex& index )
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
QueueProxyModel::siblingItem( int itemsAway )
|
||||
{
|
||||
setCurrentIndex( QModelIndex() );
|
||||
Tomahawk::result_ptr res = PlaylistProxyModel::siblingItem( itemsAway );
|
||||
|
||||
remove( currentIndex() );
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
QueueProxyModel::onTrackCountChanged( unsigned int count )
|
||||
{
|
||||
if ( count == 0 )
|
||||
ViewManager::instance()->hideQueue();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
QueueProxyModel::getPlaylistInterface()
|
||||
{
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::QueueProxyModelPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
@ -32,11 +32,9 @@ Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QueueProxyModel( TrackView* parent = 0 );
|
||||
~QueueProxyModel();
|
||||
virtual ~QueueProxyModel();
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||
|
||||
using PlaylistProxyModel::siblingItem;
|
||||
virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
|
||||
|
||||
private slots:
|
||||
void onIndexActivated( const QModelIndex& index );
|
||||
|
@ -0,0 +1,50 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "queueproxymodelplaylistinterface.h"
|
||||
|
||||
#include "queueproxymodel.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
QueueProxyModelPlaylistInterface::QueueProxyModelPlaylistInterface( QueueProxyModel *proxyModel )
|
||||
: PlaylistProxyModelPlaylistInterface( proxyModel )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QueueProxyModelPlaylistInterface::~QueueProxyModelPlaylistInterface()
|
||||
{
|
||||
m_proxyModel.clear();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
QueueProxyModelPlaylistInterface::siblingItem( int itemsAway )
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
m_proxyModel.data()->setCurrentIndex( QModelIndex() );
|
||||
Tomahawk::result_ptr res = PlaylistProxyModelPlaylistInterface::siblingItem( itemsAway );
|
||||
|
||||
m_proxyModel.data()->remove( m_proxyModel.data()->currentIndex() );
|
||||
|
||||
return res;
|
||||
}
|
44
src/libtomahawk/playlist/queueproxymodelplaylistinterface.h
Normal file
44
src/libtomahawk/playlist/queueproxymodelplaylistinterface.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef QUEUEPROXYMODELPLAYLISTINTERFACE_H
|
||||
#define QUEUEPROXYMODELPLAYLISTINTERFACE_H
|
||||
|
||||
#include "playlistproxymodelplaylistinterface.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class QueueProxyModel;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT QueueProxyModelPlaylistInterface : public PlaylistProxyModelPlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QueueProxyModelPlaylistInterface( QueueProxyModel *proxyModel );
|
||||
virtual ~QueueProxyModelPlaylistInterface();
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||
};
|
||||
|
||||
} //ns
|
||||
|
||||
#endif // QUEUEPROXYMODELPLAYLISTINTERFACE_H
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2011 Leo Franchi <lfranchi@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -336,6 +337,21 @@ TrackModel::clear()
|
||||
}
|
||||
|
||||
|
||||
QList< query_ptr >
|
||||
TrackModel::queries() const
|
||||
{
|
||||
Q_ASSERT( m_rootItem );
|
||||
|
||||
QList< query_ptr > tracks;
|
||||
foreach ( TrackModelItem* item, m_rootItem->children )
|
||||
{
|
||||
tracks << item->query();
|
||||
}
|
||||
|
||||
return tracks;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackModel::append( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2011 Leo Franchi <lfranchi@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -93,7 +94,8 @@ public:
|
||||
virtual void ensureResolved();
|
||||
|
||||
TrackModelItem* itemFromIndex( const QModelIndex& index ) const;
|
||||
TrackModelItem* m_rootItem;
|
||||
/// Returns a flat list of all tracks in this model
|
||||
QList< Tomahawk::query_ptr > queries() const;
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
|
||||
@ -125,11 +127,15 @@ public slots:
|
||||
virtual void setRepeatMode( Tomahawk::PlaylistInterface::RepeatMode /*mode*/ ) {}
|
||||
virtual void setShuffled( bool /*shuffled*/ ) {}
|
||||
|
||||
protected:
|
||||
TrackModelItem* rootItem() const { return m_rootItem; }
|
||||
|
||||
private slots:
|
||||
void onPlaybackStarted( const Tomahawk::result_ptr& result );
|
||||
void onPlaybackStopped();
|
||||
|
||||
private:
|
||||
TrackModelItem* m_rootItem;
|
||||
QPersistentModelIndex m_currentIndex;
|
||||
Tomahawk::QID m_currentUuid;
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
#include "trackproxymodelplaylistinterface.h"
|
||||
#include "artist.h"
|
||||
#include "album.h"
|
||||
#include "query.h"
|
||||
@ -28,10 +29,7 @@
|
||||
|
||||
TrackProxyModel::TrackProxyModel( QObject* parent )
|
||||
: QSortFilterProxyModel( parent )
|
||||
, PlaylistInterface( this )
|
||||
, m_model( 0 )
|
||||
, m_repeatMode( PlaylistInterface::NoRepeat )
|
||||
, m_shuffled( false )
|
||||
, m_showOfflineResults( true )
|
||||
{
|
||||
setFilterCaseSensitivity( Qt::CaseInsensitive );
|
||||
@ -57,126 +55,12 @@ TrackProxyModel::setSourceTrackModel( TrackModel* sourceModel )
|
||||
m_model = sourceModel;
|
||||
|
||||
if ( m_model && m_model->metaObject()->indexOfSignal( "trackCountChanged(uint)" ) > -1 )
|
||||
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SIGNAL( sourceTrackCountChanged( unsigned int ) ) );
|
||||
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), getPlaylistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ) );
|
||||
|
||||
QSortFilterProxyModel::setSourceModel( m_model );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackProxyModel::setFilter( const QString& pattern )
|
||||
{
|
||||
PlaylistInterface::setFilter( pattern );
|
||||
setFilterRegExp( pattern );
|
||||
|
||||
emit filterChanged( pattern );
|
||||
emit trackCountChanged( trackCount() );
|
||||
}
|
||||
|
||||
|
||||
QList< Tomahawk::query_ptr >
|
||||
TrackProxyModel::tracks()
|
||||
{
|
||||
QList<Tomahawk::query_ptr> queries;
|
||||
|
||||
for ( int i = 0; i < rowCount( QModelIndex() ); i++ )
|
||||
{
|
||||
TrackModelItem* item = itemFromIndex( mapToSource( index( i, 0 ) ) );
|
||||
if ( item )
|
||||
queries << item->query();
|
||||
}
|
||||
|
||||
return queries;
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TrackProxyModel::siblingItem( int itemsAway )
|
||||
{
|
||||
return siblingItem( itemsAway, false );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TrackProxyModel::hasNextItem()
|
||||
{
|
||||
return !( siblingItem( 1, true ).isNull() );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TrackProxyModel::siblingItem( int itemsAway, bool readOnly )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
QModelIndex idx = index( 0, 0 );
|
||||
if ( rowCount() )
|
||||
{
|
||||
if ( m_shuffled )
|
||||
{
|
||||
// random mode is enabled
|
||||
// TODO come up with a clever random logic, that keeps track of previously played items
|
||||
idx = index( qrand() % rowCount(), 0 );
|
||||
}
|
||||
else if ( currentIndex().isValid() )
|
||||
{
|
||||
idx = currentIndex();
|
||||
|
||||
// random mode is disabled
|
||||
if ( m_repeatMode != PlaylistInterface::RepeatOne )
|
||||
{
|
||||
// keep progressing through the playlist normally
|
||||
idx = index( idx.row() + itemsAway, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll )
|
||||
{
|
||||
// repeat all tracks
|
||||
if ( itemsAway > 0 )
|
||||
{
|
||||
// reset to first item
|
||||
idx = index( 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// reset to last item
|
||||
idx = index( rowCount() - 1, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
// Try to find the next available PlaylistItem (with results)
|
||||
while ( idx.isValid() )
|
||||
{
|
||||
TrackModelItem* item = itemFromIndex( mapToSource( idx ) );
|
||||
if ( item && item->query()->playable() )
|
||||
{
|
||||
qDebug() << "Next PlaylistItem found:" << item->query()->toString() << item->query()->results().at( 0 )->url();
|
||||
if ( !readOnly )
|
||||
setCurrentIndex( idx );
|
||||
return item->query()->results().at( 0 );
|
||||
}
|
||||
|
||||
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0 );
|
||||
}
|
||||
|
||||
if ( !readOnly )
|
||||
setCurrentIndex( QModelIndex() );
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TrackProxyModel::currentItem() const
|
||||
{
|
||||
TrackModelItem* item = itemFromIndex( mapToSource( currentIndex() ) );
|
||||
if ( item && !item->query().isNull() && item->query()->playable() )
|
||||
return item->query()->results().at( 0 );
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||
{
|
||||
@ -388,3 +272,15 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
|
||||
|
||||
return QString::localeAwareCompare( lefts, rights ) < 0;
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
TrackProxyModel::getPlaylistInterface()
|
||||
{
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::TrackProxyModelPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
@ -19,19 +19,20 @@
|
||||
#ifndef TRACKPROXYMODEL_H
|
||||
#define TRACKPROXYMODEL_H
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QtGui/QSortFilterProxyModel>
|
||||
|
||||
#include "playlistinterface.h"
|
||||
#include "playlist/trackmodel.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class DLLEXPORT TrackProxyModel : public QSortFilterProxyModel, public Tomahawk::PlaylistInterface
|
||||
class DLLEXPORT TrackProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TrackProxyModel ( QObject* parent = 0 );
|
||||
virtual ~TrackProxyModel() {}
|
||||
|
||||
virtual TrackModel* sourceModel() const { return m_model; }
|
||||
virtual void setSourceTrackModel( TrackModel* sourceModel );
|
||||
@ -40,55 +41,29 @@ public:
|
||||
virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); }
|
||||
virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
|
||||
|
||||
virtual QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
virtual int unfilteredTrackCount() const { return sourceModel()->trackCount(); }
|
||||
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
||||
|
||||
virtual void remove( const QModelIndex& index );
|
||||
virtual void remove( const QModelIndexList& indexes );
|
||||
virtual void remove( const QList< QPersistentModelIndex >& indexes );
|
||||
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly );
|
||||
virtual bool hasNextItem();
|
||||
virtual bool showOfflineResults() const { return m_showOfflineResults; }
|
||||
virtual void setShowOfflineResults( bool b ) { m_showOfflineResults = b; }
|
||||
|
||||
virtual QString filter() const { return filterRegExp().pattern(); }
|
||||
virtual void setFilter( const QString& pattern );
|
||||
virtual void emitFilterChanged( const QString &pattern ) { emit filterChanged( pattern ); }
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
||||
virtual bool shuffled() const { return m_shuffled; }
|
||||
virtual TrackModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
||||
|
||||
bool showOfflineResults() const { return m_showOfflineResults; }
|
||||
void setShowOfflineResults( bool b ) { m_showOfflineResults = b; }
|
||||
|
||||
TrackModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
||||
virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void filterChanged( const QString& filter );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
|
||||
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||
bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
|
||||
virtual bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||
virtual bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
|
||||
|
||||
private:
|
||||
TrackModel* m_model;
|
||||
RepeatMode m_repeatMode;
|
||||
bool m_shuffled;
|
||||
bool m_showOfflineResults;
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
};
|
||||
|
||||
#endif // TRACKPROXYMODEL_H
|
||||
|
193
src/libtomahawk/playlist/trackproxymodelplaylistinterface.cpp
Normal file
193
src/libtomahawk/playlist/trackproxymodelplaylistinterface.cpp
Normal file
@ -0,0 +1,193 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "trackproxymodelplaylistinterface.h"
|
||||
|
||||
#include "trackproxymodel.h"
|
||||
#include "artist.h"
|
||||
#include "album.h"
|
||||
#include "query.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
TrackProxyModelPlaylistInterface::TrackProxyModelPlaylistInterface( TrackProxyModel* proxyModel )
|
||||
: PlaylistInterface()
|
||||
, m_proxyModel( proxyModel )
|
||||
, m_repeatMode( PlaylistInterface::NoRepeat )
|
||||
, m_shuffled( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TrackProxyModelPlaylistInterface::~TrackProxyModelPlaylistInterface()
|
||||
{
|
||||
m_proxyModel.clear();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TrackProxyModelPlaylistInterface::unfilteredTrackCount() const
|
||||
{
|
||||
return ( m_proxyModel.isNull() ? 0 : m_proxyModel.data()->sourceModel()->trackCount() );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TrackProxyModelPlaylistInterface::trackCount() const
|
||||
{
|
||||
return ( m_proxyModel.isNull() ? 0 : m_proxyModel.data()->rowCount( QModelIndex() ) );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
TrackProxyModelPlaylistInterface::filter() const
|
||||
{
|
||||
return ( m_proxyModel.isNull() ? QString() : m_proxyModel.data()->filterRegExp().pattern() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackProxyModelPlaylistInterface::setFilter( const QString& pattern )
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return;
|
||||
|
||||
m_proxyModel.data()->setFilterRegExp( pattern );
|
||||
m_proxyModel.data()->emitFilterChanged( pattern );
|
||||
|
||||
emit trackCountChanged( trackCount() );
|
||||
}
|
||||
|
||||
|
||||
QList< Tomahawk::query_ptr >
|
||||
TrackProxyModelPlaylistInterface::tracks()
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return QList< Tomahawk::query_ptr >();
|
||||
|
||||
TrackProxyModel* proxyModel = m_proxyModel.data();
|
||||
QList<Tomahawk::query_ptr> queries;
|
||||
|
||||
for ( int i = 0; i < proxyModel->rowCount( QModelIndex() ); i++ )
|
||||
{
|
||||
TrackModelItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->index( i, 0 ) ) );
|
||||
if ( item )
|
||||
queries << item->query();
|
||||
}
|
||||
|
||||
return queries;
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TrackProxyModelPlaylistInterface::siblingItem( int itemsAway )
|
||||
{
|
||||
return siblingItem( itemsAway, false );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TrackProxyModelPlaylistInterface::hasNextItem()
|
||||
{
|
||||
return !( siblingItem( 1, true ).isNull() );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TrackProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( m_proxyModel.isNull() )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
TrackProxyModel* proxyModel = m_proxyModel.data();
|
||||
|
||||
QModelIndex idx = proxyModel->index( 0, 0 );
|
||||
if ( proxyModel->rowCount() )
|
||||
{
|
||||
if ( m_shuffled )
|
||||
{
|
||||
// random mode is enabled
|
||||
// TODO come up with a clever random logic, that keeps track of previously played items
|
||||
idx = proxyModel->index( qrand() % proxyModel->rowCount(), 0 );
|
||||
}
|
||||
else if ( proxyModel->currentIndex().isValid() )
|
||||
{
|
||||
idx = proxyModel->currentIndex();
|
||||
|
||||
// random mode is disabled
|
||||
if ( m_repeatMode != PlaylistInterface::RepeatOne )
|
||||
{
|
||||
// keep progressing through the playlist normally
|
||||
idx = proxyModel->index( idx.row() + itemsAway, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll )
|
||||
{
|
||||
// repeat all tracks
|
||||
if ( itemsAway > 0 )
|
||||
{
|
||||
// reset to first item
|
||||
idx = proxyModel->index( 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// reset to last item
|
||||
idx = proxyModel->index( proxyModel->rowCount() - 1, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
// Try to find the next available PlaylistItem (with results)
|
||||
while ( idx.isValid() )
|
||||
{
|
||||
TrackModelItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( idx ) );
|
||||
if ( item && item->query()->playable() )
|
||||
{
|
||||
qDebug() << "Next PlaylistItem found:" << item->query()->toString() << item->query()->results().at( 0 )->url();
|
||||
if ( !readOnly )
|
||||
proxyModel->setCurrentIndex( idx );
|
||||
return item->query()->results().at( 0 );
|
||||
}
|
||||
|
||||
idx = proxyModel->index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0 );
|
||||
}
|
||||
|
||||
if ( !readOnly )
|
||||
proxyModel->setCurrentIndex( QModelIndex() );
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TrackProxyModelPlaylistInterface::currentItem() const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
TrackProxyModel* proxyModel = m_proxyModel.data();
|
||||
|
||||
TrackModelItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->currentIndex() ) );
|
||||
if ( item && !item->query().isNull() && item->query()->playable() )
|
||||
return item->query()->results().at( 0 );
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
69
src/libtomahawk/playlist/trackproxymodelplaylistinterface.h
Normal file
69
src/libtomahawk/playlist/trackproxymodelplaylistinterface.h
Normal file
@ -0,0 +1,69 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TRACKPROXYMODELPLAYLISTINTERFACE_H
|
||||
#define TRACKPROXYMODELPLAYLISTINTERFACE_H
|
||||
|
||||
#include <QtGui/QSortFilterProxyModel>
|
||||
|
||||
#include "playlistinterface.h"
|
||||
#include "playlist/trackmodel.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class TrackProxyModel;
|
||||
|
||||
namespace Tomahawk {
|
||||
|
||||
class DLLEXPORT TrackProxyModelPlaylistInterface : public Tomahawk::PlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TrackProxyModelPlaylistInterface( TrackProxyModel* proxyModel );
|
||||
virtual ~TrackProxyModelPlaylistInterface();
|
||||
|
||||
virtual QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
virtual int unfilteredTrackCount() const;
|
||||
virtual int trackCount() const;
|
||||
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly );
|
||||
virtual bool hasNextItem();
|
||||
|
||||
virtual QString filter() const;
|
||||
virtual void setFilter( const QString& pattern );
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
||||
virtual bool shuffled() const { return m_shuffled; }
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
|
||||
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
|
||||
|
||||
protected:
|
||||
QWeakPointer< TrackProxyModel > m_proxyModel;
|
||||
RepeatMode m_repeatMode;
|
||||
bool m_shuffled;
|
||||
};
|
||||
|
||||
} //ns
|
||||
|
||||
#endif // TRACKPROXYMODELPLAYLISTINTERFACE_H
|
@ -182,7 +182,7 @@ TrackView::onItemActivated( const QModelIndex& index )
|
||||
{
|
||||
tDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
|
||||
m_proxyModel->setCurrentIndex( index );
|
||||
AudioEngine::instance()->playItem( m_proxyModel, item->query()->results().first() );
|
||||
AudioEngine::instance()->playItem( m_proxyModel->getPlaylistInterface(), item->query()->results().first() );
|
||||
}
|
||||
|
||||
emit itemActivated( index );
|
||||
@ -369,9 +369,9 @@ TrackView::onFilterChanged( const QString& )
|
||||
if ( selectedIndexes().count() )
|
||||
scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter );
|
||||
|
||||
if ( !proxyModel()->filter().isEmpty() && !proxyModel()->trackCount() && model()->trackCount() )
|
||||
if ( !proxyModel()->getPlaylistInterface()->filter().isEmpty() && !proxyModel()->getPlaylistInterface()->trackCount() && model()->trackCount() )
|
||||
{
|
||||
m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->filter() ) );
|
||||
m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->getPlaylistInterface()->filter() ) );
|
||||
m_overlay->show();
|
||||
}
|
||||
else
|
||||
|
@ -19,8 +19,8 @@
|
||||
#ifndef TRACKVIEW_H
|
||||
#define TRACKVIEW_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QtGui/QTreeView>
|
||||
#include <QtGui/QSortFilterProxyModel>
|
||||
|
||||
#include "contextmenu.h"
|
||||
#include "playlistitemdelegate.h"
|
||||
|
@ -18,8 +18,9 @@
|
||||
|
||||
#include "treeproxymodel.h"
|
||||
|
||||
#include <QListView>
|
||||
#include <QtGui/QListView>
|
||||
|
||||
#include "treeproxymodelplaylistinterface.h"
|
||||
#include "source.h"
|
||||
#include "query.h"
|
||||
#include "database/database.h"
|
||||
@ -30,11 +31,8 @@
|
||||
|
||||
TreeProxyModel::TreeProxyModel( QObject* parent )
|
||||
: QSortFilterProxyModel( parent )
|
||||
, PlaylistInterface( this )
|
||||
, m_artistsFilterCmd( 0 )
|
||||
, m_model( 0 )
|
||||
, m_repeatMode( PlaylistInterface::NoRepeat )
|
||||
, m_shuffled( false )
|
||||
{
|
||||
setFilterCaseSensitivity( Qt::CaseInsensitive );
|
||||
setSortCaseSensitivity( Qt::CaseInsensitive );
|
||||
@ -111,9 +109,8 @@ TreeProxyModel::onModelReset()
|
||||
m_albumsFilter.clear();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeProxyModel::setFilter( const QString& pattern )
|
||||
TreeProxyModel::newFilterFromPlaylistInterface( const QString &pattern )
|
||||
{
|
||||
emit filteringStarted();
|
||||
|
||||
@ -145,7 +142,6 @@ TreeProxyModel::setFilter( const QString& pattern )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeProxyModel::onFilterArtists( const QList<Tomahawk::artist_ptr>& artists )
|
||||
{
|
||||
@ -191,15 +187,16 @@ TreeProxyModel::filterFinished()
|
||||
{
|
||||
m_artistsFilterCmd = 0;
|
||||
|
||||
if ( PlaylistInterface::filter() != m_filter )
|
||||
if ( qobject_cast< Tomahawk::TreeProxyModelPlaylistInterface* >( m_playlistInterface.data() )->vanillaFilter() != m_filter )
|
||||
{
|
||||
emit filterChanged( m_filter );
|
||||
}
|
||||
|
||||
PlaylistInterface::setFilter( m_filter );
|
||||
qobject_cast< Tomahawk::TreeProxyModelPlaylistInterface* >( m_playlistInterface )->setVanillaFilter( m_filter );
|
||||
setFilterRegExp( m_filter );
|
||||
|
||||
emit trackCountChanged( trackCount() );
|
||||
qobject_cast< Tomahawk::TreeProxyModelPlaylistInterface* >( m_playlistInterface )->sendTrackCount();
|
||||
|
||||
emit filteringFinished();
|
||||
}
|
||||
|
||||
@ -338,82 +335,6 @@ TreeProxyModel::removeIndexes( const QList<QModelIndex>& indexes )
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TreeProxyModel::hasNextItem()
|
||||
{
|
||||
return !( siblingItem( 1, true ).isNull() );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TreeProxyModel::siblingItem( int itemsAway )
|
||||
{
|
||||
return siblingItem( itemsAway, false );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TreeProxyModel::siblingItem( int itemsAway, bool readOnly )
|
||||
{
|
||||
QModelIndex idx = currentIndex();
|
||||
if ( !idx.isValid() )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
if ( m_shuffled )
|
||||
{
|
||||
idx = index( qrand() % rowCount( idx.parent() ), 0, idx.parent() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_repeatMode != PlaylistInterface::RepeatOne )
|
||||
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
|
||||
}
|
||||
|
||||
if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll )
|
||||
{
|
||||
if ( itemsAway > 0 )
|
||||
{
|
||||
// reset to first item
|
||||
idx = index( 0, 0, currentIndex().parent() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// reset to last item
|
||||
idx = index( rowCount( currentIndex().parent() ) - 1, 0, currentIndex().parent() );
|
||||
}
|
||||
}
|
||||
|
||||
// Try to find the next available PlaylistItem (with results)
|
||||
while ( idx.isValid() )
|
||||
{
|
||||
TreeModelItem* item = itemFromIndex( mapToSource( idx ) );
|
||||
if ( item && !item->result().isNull() && item->result()->isOnline() )
|
||||
{
|
||||
qDebug() << "Next PlaylistItem found:" << item->result()->url();
|
||||
if ( !readOnly )
|
||||
setCurrentIndex( idx );
|
||||
return item->result();
|
||||
}
|
||||
|
||||
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
|
||||
}
|
||||
|
||||
if ( !readOnly )
|
||||
setCurrentIndex( QModelIndex() );
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TreeProxyModel::currentItem() const
|
||||
{
|
||||
TreeModelItem* item = itemFromIndex( mapToSource( currentIndex() ) );
|
||||
if ( item && !item->result().isNull() && item->result()->isOnline() )
|
||||
return item->result();
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
TreeProxyModel::textForItem( TreeModelItem* item ) const
|
||||
{
|
||||
@ -439,3 +360,15 @@ TreeProxyModel::textForItem( TreeModelItem* item ) const
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
TreeProxyModel::getPlaylistInterface()
|
||||
{
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::TreeProxyModelPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
@ -28,12 +28,18 @@
|
||||
|
||||
class DatabaseCommand_AllArtists;
|
||||
|
||||
class DLLEXPORT TreeProxyModel : public QSortFilterProxyModel, public Tomahawk::PlaylistInterface
|
||||
namespace Tomahawk
|
||||
{
|
||||
class TreeProxyModelPlaylistInterface;
|
||||
}
|
||||
|
||||
class DLLEXPORT TreeProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TreeProxyModel( QObject* parent = 0 );
|
||||
virtual ~TreeProxyModel() {}
|
||||
|
||||
virtual TreeModel* sourceModel() const { return m_model; }
|
||||
virtual void setSourceTreeModel( TreeModel* sourceModel );
|
||||
@ -42,46 +48,22 @@ public:
|
||||
virtual QPersistentModelIndex currentIndex() const;
|
||||
virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
|
||||
|
||||
virtual QList<Tomahawk::query_ptr> tracks() { Q_ASSERT( FALSE ); QList<Tomahawk::query_ptr> queries; return queries; }
|
||||
|
||||
virtual int unfilteredTrackCount() const { return sourceModel()->rowCount( QModelIndex() ); }
|
||||
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
||||
virtual int albumCount() const { return rowCount( QModelIndex() ); }
|
||||
virtual void newFilterFromPlaylistInterface( const QString &pattern );
|
||||
|
||||
virtual void removeIndex( const QModelIndex& index );
|
||||
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
||||
|
||||
virtual bool hasNextItem();
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction );
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction, bool readOnly );
|
||||
virtual int albumCount() const { return rowCount( QModelIndex() ); }
|
||||
|
||||
virtual QString filter() const { return filterRegExp().pattern(); }
|
||||
virtual void setFilter( const QString& pattern );
|
||||
virtual TreeModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
||||
virtual bool shuffled() const { return m_shuffled; }
|
||||
virtual PlaylistInterface::ViewMode viewMode() const { return PlaylistInterface::Tree; }
|
||||
|
||||
TreeModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
||||
virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void filterChanged( const QString& filter );
|
||||
void filteringStarted();
|
||||
void filteringFinished();
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
|
||||
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||
bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
|
||||
@ -104,11 +86,11 @@ private:
|
||||
QList<int> m_albumsFilter;
|
||||
DatabaseCommand_AllArtists* m_artistsFilterCmd;
|
||||
|
||||
QString m_filter;
|
||||
QString m_filter;
|
||||
|
||||
TreeModel* m_model;
|
||||
RepeatMode m_repeatMode;
|
||||
bool m_shuffled;
|
||||
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
};
|
||||
|
||||
#endif // TREEPROXYMODEL_H
|
||||
|
167
src/libtomahawk/playlist/treeproxymodelplaylistinterface.cpp
Normal file
167
src/libtomahawk/playlist/treeproxymodelplaylistinterface.cpp
Normal file
@ -0,0 +1,167 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "treeproxymodelplaylistinterface.h"
|
||||
|
||||
#include "treeproxymodel.h"
|
||||
|
||||
#include "source.h"
|
||||
#include "query.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databaseimpl.h"
|
||||
#include "database/databasecommand_allalbums.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
TreeProxyModelPlaylistInterface::TreeProxyModelPlaylistInterface( TreeProxyModel *proxyModel )
|
||||
: PlaylistInterface()
|
||||
, m_proxyModel( proxyModel )
|
||||
, m_repeatMode( PlaylistInterface::NoRepeat )
|
||||
, m_shuffled( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TreeProxyModelPlaylistInterface::~TreeProxyModelPlaylistInterface()
|
||||
{
|
||||
m_proxyModel.clear();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
TreeProxyModelPlaylistInterface::filter() const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return 0;
|
||||
TreeProxyModel* proxyModel = m_proxyModel.data();
|
||||
return proxyModel->filterRegExp().pattern();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeProxyModelPlaylistInterface::setFilter( const QString& pattern )
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return;
|
||||
m_proxyModel.data()->newFilterFromPlaylistInterface( pattern );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TreeProxyModelPlaylistInterface::unfilteredTrackCount() const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return 0;
|
||||
TreeProxyModel* proxyModel = m_proxyModel.data();
|
||||
return proxyModel->sourceModel()->rowCount( QModelIndex() );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TreeProxyModelPlaylistInterface::trackCount() const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return 0;
|
||||
TreeProxyModel* proxyModel = m_proxyModel.data();
|
||||
return proxyModel->rowCount( QModelIndex() );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TreeProxyModelPlaylistInterface::hasNextItem()
|
||||
{
|
||||
return !( siblingItem( 1, true ).isNull() );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TreeProxyModelPlaylistInterface::siblingItem( int itemsAway )
|
||||
{
|
||||
return siblingItem( itemsAway, false );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TreeProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return Tomahawk::result_ptr();
|
||||
TreeProxyModel* proxyModel = m_proxyModel.data();
|
||||
|
||||
QModelIndex idx = proxyModel->currentIndex();
|
||||
if ( !idx.isValid() )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
if ( m_shuffled )
|
||||
{
|
||||
idx = proxyModel->index( qrand() % proxyModel->rowCount( idx.parent() ), 0, idx.parent() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_repeatMode != PlaylistInterface::RepeatOne )
|
||||
idx = proxyModel->index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
|
||||
}
|
||||
|
||||
if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll )
|
||||
{
|
||||
if ( itemsAway > 0 )
|
||||
{
|
||||
// reset to first item
|
||||
idx = proxyModel->index( 0, 0, proxyModel->currentIndex().parent() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// reset to last item
|
||||
idx = proxyModel->index( proxyModel->rowCount( proxyModel->currentIndex().parent() ) - 1, 0, proxyModel->currentIndex().parent() );
|
||||
}
|
||||
}
|
||||
|
||||
// Try to find the next available PlaylistItem (with results)
|
||||
while ( idx.isValid() )
|
||||
{
|
||||
TreeModelItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( idx ) );
|
||||
if ( item && !item->result().isNull() && item->result()->isOnline() )
|
||||
{
|
||||
qDebug() << "Next PlaylistItem found:" << item->result()->url();
|
||||
if ( !readOnly )
|
||||
proxyModel->setCurrentIndex( idx );
|
||||
return item->result();
|
||||
}
|
||||
|
||||
idx = proxyModel->index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
|
||||
}
|
||||
|
||||
if ( !readOnly )
|
||||
proxyModel->setCurrentIndex( QModelIndex() );
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TreeProxyModelPlaylistInterface::currentItem() const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return Tomahawk::result_ptr();
|
||||
TreeProxyModel* proxyModel = m_proxyModel.data();
|
||||
|
||||
TreeModelItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->currentIndex() ) );
|
||||
if ( item && !item->result().isNull() && item->result()->isOnline() )
|
||||
return item->result();
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
89
src/libtomahawk/playlist/treeproxymodelplaylistinterface.h
Normal file
89
src/libtomahawk/playlist/treeproxymodelplaylistinterface.h
Normal file
@ -0,0 +1,89 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TREEPROXYMODELPLAYLISTINTERFACE_H
|
||||
#define TREEPROXYMODELPLAYLISTINTERFACE_H
|
||||
|
||||
#include "playlistinterface.h"
|
||||
#include "treemodel.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class DatabaseCommand_AllArtists;
|
||||
class TreeProxyModel;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT TreeProxyModelPlaylistInterface : public Tomahawk::PlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TreeProxyModelPlaylistInterface( TreeProxyModel *proxyModel );
|
||||
virtual ~TreeProxyModelPlaylistInterface();
|
||||
|
||||
virtual QList< Tomahawk::query_ptr > tracks() { Q_ASSERT( FALSE ); QList< Tomahawk::query_ptr > queries; return queries; }
|
||||
|
||||
virtual int unfilteredTrackCount() const;
|
||||
virtual int trackCount() const;
|
||||
|
||||
virtual bool hasNextItem();
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction );
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction, bool readOnly );
|
||||
|
||||
virtual QString filter() const;
|
||||
virtual void setFilter( const QString& pattern );
|
||||
|
||||
virtual QString vanillaFilter() const { return PlaylistInterface::filter(); }
|
||||
virtual void setVanillaFilter( const QString &filter ) { PlaylistInterface::setFilter( filter ); }
|
||||
|
||||
virtual void sendTrackCount() { emit trackCountChanged( trackCount() ); }
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
||||
virtual bool shuffled() const { return m_shuffled; }
|
||||
virtual PlaylistInterface::ViewMode viewMode() const { return PlaylistInterface::Tree; }
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void filterChanged( const QString& filter );
|
||||
void filteringStarted();
|
||||
void filteringFinished();
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
|
||||
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
|
||||
|
||||
private:
|
||||
QWeakPointer< TreeProxyModel > m_proxyModel;
|
||||
|
||||
RepeatMode m_repeatMode;
|
||||
bool m_shuffled;
|
||||
};
|
||||
|
||||
} //ns
|
||||
|
||||
#endif // TREEPROXYMODELPLAYLISTINTERFACE_H
|
@ -17,13 +17,13 @@
|
||||
*/
|
||||
|
||||
#include "playlistinterface.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
#include "result.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
PlaylistInterface::PlaylistInterface ( QObject *parent )
|
||||
: m_object( parent )
|
||||
PlaylistInterface::PlaylistInterface ()
|
||||
: QObject()
|
||||
{
|
||||
qRegisterMetaType<Tomahawk::PlaylistInterface::RepeatMode>( "Tomahawk::PlaylistInterface::RepeatMode" );
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef PLAYLISTINTERFACE_H
|
||||
#define PLAYLISTINTERFACE_H
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QtCore/QModelIndex>
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "dllmacro.h"
|
||||
@ -28,8 +28,9 @@
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT PlaylistInterface
|
||||
class DLLEXPORT PlaylistInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
||||
@ -39,7 +40,7 @@ public:
|
||||
enum SkipRestrictions { NoSkipRestrictions, NoSkipForwards, NoSkipBackwards, NoSkip };
|
||||
enum RetryMode { NoRetry, Retry };
|
||||
|
||||
explicit PlaylistInterface( QObject* parent = 0 );
|
||||
explicit PlaylistInterface();
|
||||
virtual ~PlaylistInterface();
|
||||
|
||||
virtual QList< Tomahawk::query_ptr > tracks() = 0;
|
||||
@ -67,44 +68,25 @@ public:
|
||||
|
||||
virtual void reset() {}
|
||||
|
||||
//TODO: Get rid of the next two functions once all playlsitinterfaces are factored out
|
||||
// Some playlist interfaces can wrap other interfaces. When checking for top-level
|
||||
// equality (say, to compare the currently playing interface) this might be needed
|
||||
virtual bool hasChildInterface( PlaylistInterface* ) { return false; }
|
||||
|
||||
QObject* object() const { return m_object; }
|
||||
|
||||
static void dontDelete( Tomahawk::PlaylistInterface* obj )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << obj;
|
||||
}
|
||||
|
||||
virtual Tomahawk::playlistinterface_ptr getSharedPointer()
|
||||
{
|
||||
if ( m_sharedPtr.isNull() )
|
||||
{
|
||||
m_sharedPtr = Tomahawk::playlistinterface_ptr( this, dontDelete );
|
||||
}
|
||||
|
||||
return m_sharedPtr;
|
||||
}
|
||||
virtual bool hasChildInterface( Tomahawk::playlistinterface_ptr ) { return false; }
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode ) = 0;
|
||||
virtual void setShuffled( bool enabled ) = 0;
|
||||
|
||||
signals:
|
||||
virtual void repeatModeChanged( PlaylistInterface::RepeatMode mode ) = 0;
|
||||
virtual void shuffleModeChanged( bool enabled ) = 0;
|
||||
virtual void trackCountChanged( unsigned int tracks ) = 0;
|
||||
virtual void sourceTrackCountChanged( unsigned int tracks ) = 0;
|
||||
virtual void nextTrackReady() = 0;
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
void nextTrackReady();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY( PlaylistInterface )
|
||||
|
||||
QObject* m_object;
|
||||
Tomahawk::playlistinterface_ptr m_sharedPtr;
|
||||
|
||||
QString m_filter;
|
||||
};
|
||||
|
||||
|
64
src/libtomahawk/playlistplaylistinterface.cpp
Normal file
64
src/libtomahawk/playlistplaylistinterface.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "playlistplaylistinterface.h"
|
||||
|
||||
#include "playlist.h"
|
||||
#include "sourcelist.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
PlaylistPlaylistInterface::PlaylistPlaylistInterface( Tomahawk::Playlist* playlist )
|
||||
: Tomahawk::PlaylistInterface()
|
||||
, m_playlist( playlist )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PlaylistPlaylistInterface::~PlaylistPlaylistInterface()
|
||||
{
|
||||
m_playlist.clear();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PlaylistPlaylistInterface::unfilteredTrackCount() const
|
||||
{
|
||||
return ( m_playlist.isNull() ? 0 : m_playlist.data()->entries().count() );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PlaylistPlaylistInterface::trackCount() const
|
||||
{
|
||||
return ( m_playlist.isNull() ? 0 : m_playlist.data()->entries().count() );
|
||||
}
|
||||
|
||||
|
||||
QList< Tomahawk::query_ptr >
|
||||
PlaylistPlaylistInterface::tracks()
|
||||
{
|
||||
QList<Tomahawk::query_ptr> queries;
|
||||
foreach( const plentry_ptr& p, ( m_playlist.isNull() ? QList< Tomahawk::plentry_ptr >() : m_playlist.data()->entries() ) )
|
||||
queries << p->query();
|
||||
|
||||
return queries;
|
||||
}
|
83
src/libtomahawk/playlistplaylistinterface.h
Normal file
83
src/libtomahawk/playlistplaylistinterface.h
Normal file
@ -0,0 +1,83 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PLAYLISTPLAYLISTINTERFACE_H
|
||||
#define PLAYLISTPLAYLISTINTERFACE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "result.h"
|
||||
#include "playlistinterface.h"
|
||||
#include "query.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT PlaylistPlaylistInterface : public Tomahawk::PlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlaylistPlaylistInterface( Tomahawk::Playlist* playlist );
|
||||
virtual ~PlaylistPlaylistInterface();
|
||||
|
||||
virtual QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
virtual int unfilteredTrackCount() const;
|
||||
virtual int trackCount() const;
|
||||
|
||||
virtual bool hasNextItem() { return false; }
|
||||
virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; }
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int /*itemsAway*/ ) { return result_ptr(); }
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||
virtual void setShuffled( bool ) {}
|
||||
|
||||
private:
|
||||
PlaylistPlaylistInterface();
|
||||
Q_DISABLE_COPY( PlaylistPlaylistInterface )
|
||||
|
||||
QWeakPointer< Tomahawk::Playlist > m_playlist;
|
||||
|
||||
result_ptr m_currentItem;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // PLAYLISTPLAYLISTINTERFACE_H
|
@ -30,6 +30,9 @@
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <shlwapi.h>
|
||||
#endif
|
||||
|
||||
ScriptResolver::ScriptResolver( const QString& exe )
|
||||
: Tomahawk::ExternalResolverGui( exe )
|
||||
@ -45,24 +48,13 @@ ScriptResolver::ScriptResolver( const QString& exe )
|
||||
connect( &m_proc, SIGNAL( readyReadStandardOutput() ), SLOT( readStdout() ) );
|
||||
connect( &m_proc, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( cmdExited( int, QProcess::ExitStatus ) ) );
|
||||
|
||||
QString runPath = filePath();
|
||||
#ifdef WIN32
|
||||
// have to enclose in quotes if path contains spaces on windows...
|
||||
runPath = QString( "\"%1\"" ).arg( filePath() );
|
||||
#endif
|
||||
|
||||
if ( !QFile::exists( filePath() ) )
|
||||
m_error = Tomahawk::ExternalResolver::FileNotFound;
|
||||
else
|
||||
m_proc.start( runPath );
|
||||
startProcess();
|
||||
|
||||
if ( !TomahawkUtils::nam() )
|
||||
return;
|
||||
|
||||
// set the name to the binary, if we launch properly we'll get the name the resolver reports
|
||||
m_name = QFileInfo( filePath() ).baseName();
|
||||
|
||||
sendConfig();
|
||||
}
|
||||
|
||||
|
||||
@ -141,15 +133,7 @@ ScriptResolver::sendConfig()
|
||||
void
|
||||
ScriptResolver::reload()
|
||||
{
|
||||
if ( !QFile::exists( filePath() ) )
|
||||
m_error = Tomahawk::ExternalResolver::FileNotFound;
|
||||
else
|
||||
{
|
||||
m_error = Tomahawk::ExternalResolver::NoError;
|
||||
m_proc.start( filePath() );
|
||||
|
||||
sendConfig();
|
||||
}
|
||||
startProcess();
|
||||
}
|
||||
|
||||
|
||||
@ -309,7 +293,7 @@ ScriptResolver::cmdExited( int code, QProcess::ExitStatus status )
|
||||
{
|
||||
m_num_restarts++;
|
||||
tLog() << "*** Restart num" << m_num_restarts;
|
||||
m_proc.start( filePath() );
|
||||
startProcess();
|
||||
sendConfig();
|
||||
}
|
||||
else
|
||||
@ -381,6 +365,58 @@ ScriptResolver::setupConfWidget( const QVariantMap& m )
|
||||
}
|
||||
|
||||
|
||||
void ScriptResolver::startProcess()
|
||||
{
|
||||
if ( !QFile::exists( filePath() ) )
|
||||
m_error = Tomahawk::ExternalResolver::FileNotFound;
|
||||
else
|
||||
{
|
||||
m_error = Tomahawk::ExternalResolver::NoError;
|
||||
}
|
||||
|
||||
QFileInfo fi( filePath() );
|
||||
|
||||
QString interpreter;
|
||||
QString runPath = filePath();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if ( fi.suffix().toLower() != "exe" )
|
||||
{
|
||||
DWORD dwSize = MAX_PATH;
|
||||
|
||||
wchar_t path[MAX_PATH] = { 0 };
|
||||
wchar_t *ext = (wchar_t *) ("." + fi.suffix()).utf16();
|
||||
|
||||
HRESULT hr = AssocQueryStringW(
|
||||
(ASSOCF) 0,
|
||||
ASSOCSTR_EXECUTABLE,
|
||||
ext,
|
||||
L"open",
|
||||
path,
|
||||
&dwSize
|
||||
);
|
||||
|
||||
if ( ! FAILED( hr ) )
|
||||
{
|
||||
interpreter = QString( "\"%1\"" ).arg(QString::fromUtf16((const ushort *) path));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// have to enclose in quotes if path contains spaces on windows...
|
||||
runPath = QString( "\"%1\"" ).arg( filePath() );
|
||||
}
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
if( interpreter.isEmpty() )
|
||||
m_proc.start( runPath );
|
||||
else
|
||||
m_proc.start( interpreter, QStringList() << filePath() );
|
||||
|
||||
sendConfig();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScriptResolver::saveConfig()
|
||||
{
|
||||
|
@ -75,6 +75,8 @@ private:
|
||||
void doSetup( const QVariantMap& m );
|
||||
void setupConfWidget( const QVariantMap& m );
|
||||
|
||||
void startProcess();
|
||||
|
||||
QProcess m_proc;
|
||||
QString m_name;
|
||||
unsigned int m_weight, m_preference, m_timeout, m_num_restarts;
|
||||
|
@ -19,8 +19,9 @@
|
||||
#ifndef RESULT_H
|
||||
#define RESULT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
@ -125,7 +126,7 @@ private slots:
|
||||
private:
|
||||
// private constructor
|
||||
explicit Result( const QString& url );
|
||||
Result();
|
||||
explicit Result();
|
||||
|
||||
void updateAttributes();
|
||||
void parseSocialActions();
|
||||
@ -156,6 +157,6 @@ private:
|
||||
QList< SocialAction > m_allSocialActions;
|
||||
};
|
||||
|
||||
}; //ns
|
||||
} //ns
|
||||
|
||||
#endif // RESULT_H
|
||||
|
@ -188,7 +188,7 @@ Source::setOffline()
|
||||
|
||||
m_cc = 0;
|
||||
DatabaseCommand_SourceOffline* cmd = new DatabaseCommand_SourceOffline( id() );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
@ -307,7 +307,7 @@ Source::getPlaylistInterface()
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
Tomahawk::source_ptr source = SourceList::instance()->get( id() );
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::SourcePlaylistInterface( source ) );
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::SourcePlaylistInterface( source.data() ) );
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
@ -411,7 +411,9 @@ Source::executeCommands()
|
||||
void
|
||||
Source::reportSocialAttributesChanged( DatabaseCommand_SocialAction* action )
|
||||
{
|
||||
emit socialAttributesChanged();
|
||||
Q_ASSERT( action );
|
||||
|
||||
emit socialAttributesChanged( action->action() );
|
||||
|
||||
if ( action->action() == "latchOn" )
|
||||
{
|
||||
|
@ -19,9 +19,9 @@
|
||||
#ifndef SOURCE_H
|
||||
#define SOURCE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QVariantMap>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/QVariantMap>
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "network/dbsyncconnection.h"
|
||||
@ -106,7 +106,7 @@ signals:
|
||||
void stateChanged();
|
||||
void commandsFinished();
|
||||
|
||||
void socialAttributesChanged();
|
||||
void socialAttributesChanged( const QString& action );
|
||||
|
||||
void latchedOn( const Tomahawk::source_ptr& to );
|
||||
void latchedOff( const Tomahawk::source_ptr& from );
|
||||
@ -162,6 +162,6 @@ private:
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
};
|
||||
|
||||
};
|
||||
} //ns
|
||||
|
||||
#endif // SOURCE_H
|
||||
|
@ -26,18 +26,21 @@
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::source_ptr& source )
|
||||
: PlaylistInterface( this )
|
||||
SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::Source *source )
|
||||
: PlaylistInterface()
|
||||
, m_source( source )
|
||||
, m_currentItem( 0 )
|
||||
, m_gotNextItem( false )
|
||||
{
|
||||
connect( source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) );
|
||||
if ( !m_source.isNull() )
|
||||
connect( m_source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) );
|
||||
}
|
||||
|
||||
|
||||
SourcePlaylistInterface::~SourcePlaylistInterface()
|
||||
{}
|
||||
{
|
||||
m_source.clear();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
@ -52,7 +55,7 @@ Tomahawk::result_ptr
|
||||
SourcePlaylistInterface::nextItem()
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
if ( m_source.isNull() || m_source->currentTrack().isNull() || m_source->currentTrack()->results().isEmpty() )
|
||||
if ( m_source.isNull() || m_source.data()->currentTrack().isNull() || m_source.data()->currentTrack()->results().isEmpty() )
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO << " Results were empty for current track or source no longer valid";
|
||||
m_currentItem = Tomahawk::result_ptr();
|
||||
@ -65,7 +68,7 @@ SourcePlaylistInterface::nextItem()
|
||||
}
|
||||
|
||||
m_gotNextItem = false;
|
||||
m_currentItem = m_source->currentTrack()->results().first();
|
||||
m_currentItem = m_source.data()->currentTrack()->results().first();
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
@ -81,7 +84,7 @@ bool
|
||||
SourcePlaylistInterface::hasNextItem()
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
if ( m_source.isNull() || m_source->currentTrack().isNull() || m_source->currentTrack()->results().isEmpty() )
|
||||
if ( m_source.isNull() || m_source.data()->currentTrack().isNull() || m_source.data()->currentTrack()->results().isEmpty() )
|
||||
return false;
|
||||
|
||||
return m_gotNextItem;
|
||||
@ -96,7 +99,7 @@ SourcePlaylistInterface::tracks()
|
||||
}
|
||||
|
||||
|
||||
source_ptr
|
||||
QWeakPointer< Tomahawk::Source >
|
||||
SourcePlaylistInterface::source() const
|
||||
{
|
||||
return m_source;
|
||||
|
@ -30,13 +30,13 @@
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT SourcePlaylistInterface : public QObject, public PlaylistInterface
|
||||
class DLLEXPORT SourcePlaylistInterface : public Tomahawk::PlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SourcePlaylistInterface( Tomahawk::source_ptr& source );
|
||||
~SourcePlaylistInterface();
|
||||
SourcePlaylistInterface( Tomahawk::Source *source );
|
||||
virtual ~SourcePlaylistInterface();
|
||||
|
||||
QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
@ -57,7 +57,7 @@ public:
|
||||
virtual bool shuffled() const { return false; }
|
||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||
|
||||
virtual Tomahawk::source_ptr source() const;
|
||||
virtual QWeakPointer< Tomahawk::Source > source() const;
|
||||
|
||||
virtual void reset();
|
||||
|
||||
@ -77,7 +77,7 @@ private slots:
|
||||
void resolvingFinished( bool hasResults );
|
||||
|
||||
private:
|
||||
Tomahawk::source_ptr m_source;
|
||||
QWeakPointer< Tomahawk::Source > m_source;
|
||||
Tomahawk::result_ptr m_currentItem;
|
||||
bool m_gotNextItem;
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "kdsingleapplicationguard.h"
|
||||
|
||||
#ifndef KDSINGLEAPPLICATIONGUARD_NUMBER_OF_PROCESSES
|
||||
#define KDSINGLEAPPLICATIONGUARD_NUMBER_OF_PROCESSES 128
|
||||
#define KDSINGLEAPPLICATIONGUARD_NUMBER_OF_PROCESSES 10
|
||||
#endif
|
||||
|
||||
#ifndef KDSINGLEAPPLICATIONGUARD_MAX_COMMAND_LINE
|
||||
|
@ -2,7 +2,7 @@
|
||||
*
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
* Copyright 2010-2011, Hugo Lindström <hugolm84@gmail.com>
|
||||
* Copyright 2010-2011, Stefan Derkits <stefan@derkits.at>
|
||||
* Copyright 2010-2012, Stefan Derkits <stefan@derkits.at>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -91,42 +91,56 @@ GroovesharkParser::lookupGroovesharkPlaylist( const QString& linkRaw )
|
||||
{
|
||||
tLog() << "Parsing Grooveshark Playlist URI:" << linkRaw;
|
||||
|
||||
QStringList urlParts = linkRaw.split( "/" );
|
||||
QString urlFragment = QUrl( linkRaw ).fragment( );
|
||||
if ( urlFragment.isEmpty() ) {
|
||||
tDebug() << "no fragment, setting fragment to path";
|
||||
urlFragment = QUrl(linkRaw).path();
|
||||
}
|
||||
|
||||
tDebug() << urlFragment;
|
||||
|
||||
int paramStartingPostition = urlFragment.indexOf( "?" );
|
||||
|
||||
if ( paramStartingPostition != -1 )
|
||||
urlFragment.truncate( paramStartingPostition );
|
||||
|
||||
bool ok;
|
||||
QString playlistStr = urlParts.last();
|
||||
playlistStr.truncate(playlistStr.indexOf("?"));
|
||||
int playlistID = playlistStr.toInt( &ok, 10 );
|
||||
|
||||
QStringList urlParts = urlFragment.split( "/", QString::SkipEmptyParts );
|
||||
|
||||
tDebug() << urlParts;
|
||||
|
||||
int playlistID = urlParts.at( 2 ).toInt( &ok, 10 );
|
||||
if (!ok)
|
||||
{
|
||||
tDebug() << "incorrect grooveshark url";
|
||||
return;
|
||||
}
|
||||
|
||||
m_title = urlParts.at( urlParts.size()-2 );
|
||||
|
||||
|
||||
m_title = urlParts.at( 1 );
|
||||
|
||||
tDebug() << "should get playlist " << playlistID;
|
||||
|
||||
DropJob::DropType type;
|
||||
|
||||
if ( linkRaw.contains( "playlist" ) )
|
||||
type = DropJob::Playlist;
|
||||
type = DropJob::Playlist;
|
||||
|
||||
QString base_url( "http://api.grooveshark.com/ws3.php?sig=" );
|
||||
|
||||
QByteArray data = QString( "{\"method\":\"getPlaylistSongs\",\"parameters\":{\"playlistID\":\"%1\"},\"header\":{\"wsKey\":\"tomahawkplayer\"}}" ).arg( playlistID ).toLocal8Bit();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QCA::MessageAuthenticationCode hmac( "hmac(md5)", m_apiKey );
|
||||
|
||||
QCA::SecureArray secdata( data );
|
||||
hmac.update(secdata);
|
||||
QCA::SecureArray resultArray = hmac.final();
|
||||
|
||||
|
||||
QString hash = QCA::arrayToHex( resultArray.toByteArray() );
|
||||
QUrl url = QUrl( base_url + hash );
|
||||
|
||||
|
||||
tDebug() << "Looking up URL..." << url.toString();
|
||||
|
||||
QNetworkReply* reply = TomahawkUtils::nam()->post( QNetworkRequest( url ), data );
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user