mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-13 04:21:51 +02:00
first working playlists, wohoo :D
This commit is contained in:
parent
e9963bb4d2
commit
dedcd7a0f5
@ -104,6 +104,13 @@ Collection::playlist( const QString& guid )
|
||||
return pp;
|
||||
}
|
||||
|
||||
// TODO do we really want to do this?
|
||||
foreach( const dynplaylist_ptr& pp, m_dynplaylists )
|
||||
{
|
||||
if( pp->guid() == guid )
|
||||
return pp.staticCast<Playlist>();
|
||||
}
|
||||
|
||||
return playlist_ptr();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
This file was automatically generated from schema.sql on Sun Dec 12 14:07:45 EST 2010.
|
||||
This file was automatically generated from schema.sql on Sun Dec 12 21:41:41 EST 2010.
|
||||
*/
|
||||
|
||||
static const char * tomahawk_schema_sql =
|
||||
|
@ -33,7 +33,7 @@ Tomahawk::GeneratorInterface::~GeneratorInterface()
|
||||
}
|
||||
|
||||
QList< Tomahawk::dyncontrol_ptr >
|
||||
Tomahawk::GeneratorInterface::controls() const
|
||||
Tomahawk::GeneratorInterface::controls()
|
||||
{
|
||||
if( m_controls.isEmpty() ) { // return a default control (so the user can add more)
|
||||
return QList< Tomahawk::dyncontrol_ptr >() << createControl();
|
||||
@ -60,7 +60,7 @@ Tomahawk::GeneratorInterface::setControls( const QList< Tomahawk::dyncontrol_ptr
|
||||
m_controls = controls;
|
||||
}
|
||||
|
||||
Tomahawk::dyncontrol_ptr Tomahawk::GeneratorInterface::createControl(const QString& type) const
|
||||
Tomahawk::dyncontrol_ptr Tomahawk::GeneratorInterface::createControl(const QString& type)
|
||||
{
|
||||
return dyncontrol_ptr();
|
||||
}
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <QStringList>
|
||||
|
||||
#include "tomahawk/typedefs.h"
|
||||
#include "tomahawk/query.h"
|
||||
#include "dynamic/DynamicControl.h"
|
||||
|
||||
namespace Tomahawk {
|
||||
|
||||
@ -47,7 +49,9 @@ public:
|
||||
|
||||
// Can't make it pure otherwise we can't shove it in QVariants :-/
|
||||
// empty QString means use default
|
||||
virtual dyncontrol_ptr createControl( const QString& type = QString() ) const;
|
||||
/// The generator will keep track of all the controls it creates. No need to tell it about controls
|
||||
/// you ask it to create
|
||||
virtual dyncontrol_ptr createControl( const QString& type = QString() );
|
||||
|
||||
/**
|
||||
* Generate tracks from the controls in this playlist. If the current mode is
|
||||
@ -66,7 +70,7 @@ public:
|
||||
void setMode( GeneratorMode mode ) { m_mode = mode; }
|
||||
|
||||
// control functions
|
||||
QList< dyncontrol_ptr > controls() const;
|
||||
QList< dyncontrol_ptr > controls();
|
||||
void addControl( const dyncontrol_ptr& control );
|
||||
void clearControls();
|
||||
void setControls( const QList< dyncontrol_ptr>& controls );
|
||||
@ -74,7 +78,7 @@ public:
|
||||
QStringList typeSelectors() const { return m_typeSelectors; }
|
||||
|
||||
signals:
|
||||
void generated( const QList< query_ptr>& queries );
|
||||
void generated( const QList< Tomahawk::query_ptr>& queries );
|
||||
|
||||
protected:
|
||||
QString m_type;
|
||||
|
@ -52,7 +52,7 @@ Tomahawk::EchonestControl::setSelectedType ( const QString& type )
|
||||
updateWidgets();
|
||||
}
|
||||
|
||||
Echonest::DynamicPlaylist::PlaylistParamData
|
||||
Echonest::DynamicPlaylist::PlaylistParamData
|
||||
Tomahawk::EchonestControl::toENParam() const
|
||||
{
|
||||
return m_data;
|
||||
@ -68,6 +68,8 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
|
||||
// make sure the widgets are the proper kind for the selected type, and hook up to their slots
|
||||
if( selectedType() == "Artist" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::Artist;
|
||||
|
||||
QComboBox* match = new QComboBox();
|
||||
QLineEdit* input = new QLineEdit();
|
||||
|
||||
@ -93,12 +95,15 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
void
|
||||
Tomahawk::EchonestControl::updateData()
|
||||
{
|
||||
qDebug() << "Sender:" << sender() << qobject_cast<QLineEdit*>(sender()) << m_input << qobject_cast<QLineEdit*>(m_input.data());
|
||||
if( selectedType() == "Artist" ) {
|
||||
QWeakPointer<QComboBox> combo = qWeakPointerCast<QComboBox, QWidget>( m_match );
|
||||
if( !combo.isNull() )
|
||||
m_data.first = static_cast<Echonest::DynamicPlaylist::PlaylistParam>( combo.data()->itemData( combo.data()->currentIndex() ).toInt() );
|
||||
QWeakPointer<QLineEdit> edit = qWeakPointerCast<QLineEdit, QWidget>( m_input );
|
||||
if( !edit.isNull() )
|
||||
m_data.second = edit.data()->text();
|
||||
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
||||
if( combo ) {
|
||||
}
|
||||
QLineEdit* edit = qobject_cast<QLineEdit*>( m_input.data() );
|
||||
if( edit && !edit->text().isEmpty() ) {
|
||||
m_data.first = m_currentType;
|
||||
m_data.second = edit->text();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ protected:
|
||||
private:
|
||||
void updateWidgets();
|
||||
|
||||
Echonest::DynamicPlaylist::PlaylistParam m_currentType;
|
||||
|
||||
QWeakPointer< QWidget > m_input;
|
||||
QWeakPointer< QWidget > m_match;
|
||||
|
||||
|
@ -47,25 +47,29 @@ EchonestGenerator::~EchonestGenerator()
|
||||
}
|
||||
|
||||
dyncontrol_ptr
|
||||
EchonestGenerator::createControl( const QString& type ) const
|
||||
EchonestGenerator::createControl( const QString& type )
|
||||
{
|
||||
return dyncontrol_ptr( new EchonestControl( type, m_typeSelectors ) );
|
||||
m_controls << dyncontrol_ptr( new EchonestControl( type, m_typeSelectors ) );
|
||||
return m_controls.last();
|
||||
}
|
||||
|
||||
void
|
||||
EchonestGenerator::generate ( int number )
|
||||
{
|
||||
// convert to an echonest query, and fire it off
|
||||
if( number < 0 ) { // dynamic
|
||||
if( number < 0 ) { // dynamic
|
||||
|
||||
} else { // static
|
||||
Echonest::DynamicPlaylist::PlaylistParams params;
|
||||
foreach( const dyncontrol_ptr& control, m_controls )
|
||||
params.append( control.dynamicCast<EchonestControl>()->toENParam() );
|
||||
|
||||
QNetworkReply* reply = Echonest::DynamicPlaylist::staticPlaylist( params );
|
||||
connect( reply, SIGNAL( finished() ), this, SLOT( staticFinished() ) );
|
||||
}
|
||||
} else { // static
|
||||
Echonest::DynamicPlaylist::PlaylistParams params;
|
||||
foreach( const dyncontrol_ptr& control, m_controls ) {
|
||||
params.append( control.dynamicCast<EchonestControl>()->toENParam() );
|
||||
}
|
||||
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Type, determineRadioType() ) );
|
||||
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Results, number ) );
|
||||
QNetworkReply* reply = Echonest::DynamicPlaylist::staticPlaylist( params );
|
||||
qDebug() << "Generating a static playlist from echonest!" << reply->url().toString();
|
||||
connect( reply, SIGNAL( finished() ), this, SLOT( staticFinished() ) );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -97,3 +101,12 @@ EchonestGenerator::staticFinished()
|
||||
|
||||
emit generated( queries );
|
||||
}
|
||||
|
||||
|
||||
// tries to heuristically determine what sort of radio this is based on the controls
|
||||
Echonest::DynamicPlaylist::ArtistTypeEnum EchonestGenerator::determineRadioType() const
|
||||
{
|
||||
// TODO
|
||||
return Echonest::DynamicPlaylist::ArtistRadioType;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "dynamic/GeneratorInterface.h"
|
||||
#include "dynamic/GeneratorFactory.h"
|
||||
|
||||
#include "dynamic/DynamicControl.h"
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
@ -42,12 +42,15 @@ public:
|
||||
explicit EchonestGenerator( QObject* parent = 0 );
|
||||
virtual ~EchonestGenerator();
|
||||
|
||||
virtual dyncontrol_ptr createControl( const QString& type = QString() ) const;
|
||||
virtual dyncontrol_ptr createControl( const QString& type = QString() );
|
||||
|
||||
virtual void generate ( int number = -1 );
|
||||
|
||||
private slots:
|
||||
void staticFinished();
|
||||
|
||||
private:
|
||||
Echonest::DynamicPlaylist::ArtistTypeEnum determineRadioType() const;
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -148,12 +148,6 @@ void DynamicControlList::removeControl()
|
||||
m_controls.last()->setShowMinusButton( false );
|
||||
}
|
||||
|
||||
QList< dyncontrol_ptr >& DynamicControlList::controls() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DynamicControlList::paintEvent(QPaintEvent* )
|
||||
{
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ public:
|
||||
explicit DynamicControlList( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, AnimatedSplitter* parent );
|
||||
virtual ~DynamicControlList();
|
||||
|
||||
QList< dyncontrol_ptr >& controls() const;
|
||||
void setControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls );
|
||||
|
||||
virtual void paintEvent(QPaintEvent* );
|
||||
|
@ -104,6 +104,12 @@ DynamicControlWidget::~DynamicControlWidget()
|
||||
|
||||
}
|
||||
|
||||
dyncontrol_ptr DynamicControlWidget::control() const
|
||||
{
|
||||
return m_control;
|
||||
}
|
||||
|
||||
|
||||
QToolButton* DynamicControlWidget::initButton()
|
||||
{
|
||||
QToolButton* btn = new QToolButton( this );
|
||||
|
@ -49,6 +49,8 @@ public:
|
||||
virtual void enterEvent(QEvent* );
|
||||
virtual void leaveEvent(QEvent* );
|
||||
|
||||
dyncontrol_ptr control() const;
|
||||
|
||||
signals:
|
||||
void addNewControl();
|
||||
void collapse();
|
||||
|
@ -66,6 +66,7 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
|
||||
m_generateButton->show();
|
||||
m_headerLayout->addWidget( m_generateButton );
|
||||
}
|
||||
connect( m_generateButton, SIGNAL( clicked( bool ) ), this, SLOT( generate() ) );
|
||||
|
||||
m_layout->addLayout( m_headerLayout );
|
||||
|
||||
@ -91,6 +92,8 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
|
||||
m_model->loadPlaylist( m_playlist );
|
||||
}
|
||||
|
||||
connect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
|
||||
|
||||
setLayout( m_layout );
|
||||
}
|
||||
|
||||
@ -110,3 +113,18 @@ DynamicWidget::playlistInterface() const
|
||||
{
|
||||
return m_view->proxyModel();
|
||||
}
|
||||
|
||||
void
|
||||
DynamicWidget::generate()
|
||||
{
|
||||
// get the items from the generator, and put them in the playlist
|
||||
m_playlist->generator()->generate( 15 );
|
||||
}
|
||||
|
||||
void
|
||||
DynamicWidget::tracksGenerated( const QList< query_ptr >& queries )
|
||||
{
|
||||
m_playlist->addEntries( queries, m_playlist->currentrevision() );
|
||||
// connect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision) ), m_playlist.data(), SLOT( resolve() ) );
|
||||
m_playlist->resolve();
|
||||
}
|
||||
|
@ -49,6 +49,10 @@ public:
|
||||
|
||||
PlaylistInterface* playlistInterface() const;
|
||||
|
||||
private slots:
|
||||
void generate();
|
||||
void tracksGenerated( const QList< Tomahawk::query_ptr>& queries );
|
||||
|
||||
private:
|
||||
dynplaylist_ptr m_playlist;
|
||||
QVBoxLayout* m_layout;
|
||||
|
Loading…
x
Reference in New Issue
Block a user