mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-28 16:20:01 +02:00
more working static playlists
This commit is contained in:
@@ -99,7 +99,6 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
|||||||
dynamic/widgets/DynamicWidget.cpp
|
dynamic/widgets/DynamicWidget.cpp
|
||||||
dynamic/widgets/DynamicControlWidget.cpp
|
dynamic/widgets/DynamicControlWidget.cpp
|
||||||
dynamic/widgets/DynamicControlList.cpp
|
dynamic/widgets/DynamicControlList.cpp
|
||||||
dynamic/DynamicPlaylistModel.cpp
|
|
||||||
|
|
||||||
transferview.cpp
|
transferview.cpp
|
||||||
tomahawkwindow.cpp
|
tomahawkwindow.cpp
|
||||||
@@ -181,7 +180,6 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
|||||||
dynamic/widgets/DynamicWidget.h
|
dynamic/widgets/DynamicWidget.h
|
||||||
dynamic/widgets/DynamicControlWidget.h
|
dynamic/widgets/DynamicControlWidget.h
|
||||||
dynamic/widgets/DynamicControlList.h
|
dynamic/widgets/DynamicControlList.h
|
||||||
dynamic/DynamicPlaylistModel.h
|
|
||||||
|
|
||||||
transferview.h
|
transferview.h
|
||||||
tomahawkwindow.h
|
tomahawkwindow.h
|
||||||
|
@@ -1,35 +0,0 @@
|
|||||||
/****************************************************************************************
|
|
||||||
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or modify it under *
|
|
||||||
* the terms of the GNU General Public License as published by the Free Software *
|
|
||||||
* Foundation; either version 2 of the License, or (at your option) any later *
|
|
||||||
* version. *
|
|
||||||
* *
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
|
|
||||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
|
|
||||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License along with *
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
||||||
****************************************************************************************/
|
|
||||||
|
|
||||||
#include "DynamicPlaylistModel.h"
|
|
||||||
#include "audio/audioengine.h"
|
|
||||||
#include "dynamic/DynamicPlaylist.h"
|
|
||||||
|
|
||||||
DynamicPlaylistModel::DynamicPlaylistModel(QObject* parent)
|
|
||||||
: PlaylistModel(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DynamicPlaylistModel::~DynamicPlaylistModel()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynamicPlaylistModel::loadPlaylist(const Tomahawk::dynplaylist_ptr& playlist)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
/****************************************************************************************
|
|
||||||
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or modify it under *
|
|
||||||
* the terms of the GNU General Public License as published by the Free Software *
|
|
||||||
* Foundation; either version 2 of the License, or (at your option) any later *
|
|
||||||
* version. *
|
|
||||||
* *
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
|
|
||||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
|
|
||||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License along with *
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
||||||
****************************************************************************************/
|
|
||||||
#ifndef DYNAMIC_PLAYLIST_MODEL_H
|
|
||||||
#define DYNAMIC_PLAYLIST_MODEL_H
|
|
||||||
|
|
||||||
#include "typedefs.h"
|
|
||||||
#include "playlist/playlistmodel.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple model that extends PlaylistModel with support for adding/removing tracks from top and bottom.
|
|
||||||
*/
|
|
||||||
class DynamicPlaylistModel : public PlaylistModel
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit DynamicPlaylistModel( QObject* parent = 0 );
|
|
||||||
~DynamicPlaylistModel();
|
|
||||||
|
|
||||||
void loadPlaylist( const Tomahawk::dynplaylist_ptr& playlist );
|
|
||||||
|
|
||||||
private:
|
|
||||||
Tomahawk::dynplaylist_ptr m_playlist;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@@ -32,7 +32,6 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget* parent )
|
DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget* parent )
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_playlist( playlist )
|
|
||||||
, m_layout( new QVBoxLayout )
|
, m_layout( new QVBoxLayout )
|
||||||
, m_headerText( 0 )
|
, m_headerText( 0 )
|
||||||
, m_headerLayout( 0 )
|
, m_headerLayout( 0 )
|
||||||
@@ -51,7 +50,6 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
|
|||||||
m_modeCombo = new QComboBox( this );
|
m_modeCombo = new QComboBox( this );
|
||||||
m_modeCombo->addItem( "On Demand", 0 );
|
m_modeCombo->addItem( "On Demand", 0 );
|
||||||
m_modeCombo->addItem( "Static", 1 );
|
m_modeCombo->addItem( "Static", 1 );
|
||||||
m_modeCombo->setCurrentIndex( static_cast<int>( playlist->mode() ) );
|
|
||||||
m_headerLayout->addWidget( m_modeCombo );
|
m_headerLayout->addWidget( m_modeCombo );
|
||||||
m_generatorCombo = new QComboBox( this );
|
m_generatorCombo = new QComboBox( this );
|
||||||
foreach( const QString& type, GeneratorFactory::types() )
|
foreach( const QString& type, GeneratorFactory::types() )
|
||||||
@@ -62,10 +60,6 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
|
|||||||
|
|
||||||
m_generateButton = new QPushButton( "Generate", this );
|
m_generateButton = new QPushButton( "Generate", this );
|
||||||
m_generateButton->hide();
|
m_generateButton->hide();
|
||||||
if( playlist->mode() == Static ) {
|
|
||||||
m_generateButton->show();
|
|
||||||
m_headerLayout->addWidget( m_generateButton );
|
|
||||||
}
|
|
||||||
connect( m_generateButton, SIGNAL( clicked( bool ) ), this, SLOT( generate() ) );
|
connect( m_generateButton, SIGNAL( clicked( bool ) ), this, SLOT( generate() ) );
|
||||||
|
|
||||||
m_layout->addLayout( m_headerLayout );
|
m_layout->addLayout( m_headerLayout );
|
||||||
@@ -86,26 +80,42 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
|
|||||||
|
|
||||||
m_splitter->show( 0, false );
|
m_splitter->show( 0, false );
|
||||||
|
|
||||||
if( !m_playlist.isNull() ) {
|
loadDynamicPlaylist( playlist );
|
||||||
m_controls->setControls( m_playlist->generator(), m_playlist->generator()->controls() );
|
|
||||||
|
|
||||||
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 );
|
setLayout( m_layout );
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicWidget::~DynamicWidget()
|
DynamicWidget::~DynamicWidget()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DynamicWidget::loadDynamicPlaylist(const Tomahawk::dynplaylist_ptr& playlist)
|
||||||
DynamicWidget::setPlaylist(const Tomahawk::dynplaylist_ptr& playlist)
|
|
||||||
{
|
{
|
||||||
|
if( !m_playlist.isNull() ) {
|
||||||
|
disconnect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_playlist = playlist;
|
||||||
|
m_model->loadPlaylist( m_playlist );
|
||||||
|
if( !m_playlist.isNull() )
|
||||||
|
m_controls->setControls( m_playlist->generator(), m_playlist->generator()->controls() );
|
||||||
|
m_modeCombo->setCurrentIndex( static_cast<int>( playlist->mode() ) );
|
||||||
|
|
||||||
|
if( playlist->mode() == Static ) {
|
||||||
|
m_generateButton->show();
|
||||||
|
m_headerLayout->addWidget( m_generateButton );
|
||||||
|
} else {
|
||||||
|
m_generateButton->hide();
|
||||||
|
m_headerLayout->removeWidget(m_generateButton);
|
||||||
|
}
|
||||||
|
connect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicWidget::setPlaylist( const Tomahawk::DynamicPlaylistRevision& rev )
|
||||||
|
{
|
||||||
|
loadDynamicPlaylist( m_playlist );
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistInterface*
|
PlaylistInterface*
|
||||||
@@ -125,6 +135,5 @@ void
|
|||||||
DynamicWidget::tracksGenerated( const QList< query_ptr >& queries )
|
DynamicWidget::tracksGenerated( const QList< query_ptr >& queries )
|
||||||
{
|
{
|
||||||
m_playlist->addEntries( queries, m_playlist->currentrevision() );
|
m_playlist->addEntries( queries, m_playlist->currentrevision() );
|
||||||
// connect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision) ), m_playlist.data(), SLOT( resolve() ) );
|
|
||||||
m_playlist->resolve();
|
m_playlist->resolve();
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <typedefs.h>
|
#include <typedefs.h>
|
||||||
|
#include <dynamic/DynamicPlaylist.h>
|
||||||
|
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
@@ -45,10 +46,13 @@ public:
|
|||||||
explicit DynamicWidget( const dynplaylist_ptr& playlist, QWidget* parent = 0);
|
explicit DynamicWidget( const dynplaylist_ptr& playlist, QWidget* parent = 0);
|
||||||
virtual ~DynamicWidget();
|
virtual ~DynamicWidget();
|
||||||
|
|
||||||
void setPlaylist( const dynplaylist_ptr& playlist );
|
void loadDynamicPlaylist( const dynplaylist_ptr& playlist );
|
||||||
|
|
||||||
PlaylistInterface* playlistInterface() const;
|
PlaylistInterface* playlistInterface() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setPlaylist( const DynamicPlaylistRevision& rev );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void generate();
|
void generate();
|
||||||
void tracksGenerated( const QList< Tomahawk::query_ptr>& queries );
|
void tracksGenerated( const QList< Tomahawk::query_ptr>& queries );
|
||||||
|
@@ -65,8 +65,6 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib )
|
|||||||
{
|
{
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
QString m_currentRevision;
|
|
||||||
|
|
||||||
// get the current revision for this playlist
|
// get the current revision for this playlist
|
||||||
// this also serves to check the playlist exists.
|
// this also serves to check the playlist exists.
|
||||||
TomahawkSqlQuery chkq = lib->newquery();
|
TomahawkSqlQuery chkq = lib->newquery();
|
||||||
@@ -75,7 +73,7 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib )
|
|||||||
if( chkq.exec() && chkq.next() )
|
if( chkq.exec() && chkq.next() )
|
||||||
{
|
{
|
||||||
m_currentRevision = chkq.value( 0 ).toString();
|
m_currentRevision = chkq.value( 0 ).toString();
|
||||||
//qDebug() << Q_FUNC_INFO << "pl guid" << m_playlistguid << " curr rev" << currentrevision;
|
qDebug() << Q_FUNC_INFO << "pl guid" << m_playlistguid << " curr rev" << m_currentRevision;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -298,16 +298,20 @@ DynamicPlaylist::setRevision( const QString& rev,
|
|||||||
m_generator->setControls( controls );
|
m_generator->setControls( controls );
|
||||||
m_generator->setMode( Static );
|
m_generator->setMode( Static );
|
||||||
|
|
||||||
DynamicPlaylistRevision pr = setNewRevision( rev, neworderedguids, oldorderedguids, is_newest_rev, addedmap );
|
PlaylistRevision pr = setNewRevision( rev, neworderedguids, oldorderedguids, is_newest_rev, addedmap );
|
||||||
pr.controls = controls;
|
pr.applied = applied;
|
||||||
pr.type = type;
|
|
||||||
pr.mode = Static;
|
DynamicPlaylistRevision dpr = pr;
|
||||||
|
dpr.controls = controls;
|
||||||
|
dpr.type = type;
|
||||||
|
dpr.mode = Static;
|
||||||
|
|
||||||
if( applied )
|
if( applied )
|
||||||
setCurrentrevision( rev );
|
setCurrentrevision( rev );
|
||||||
pr.applied = applied;
|
|
||||||
|
|
||||||
emit revisionLoaded( pr );
|
// meh :-( emit both, one for PlaylistModel, the other for DynamicWidget
|
||||||
|
emit revisionLoaded( pr );
|
||||||
|
emit revisionLoaded( dpr );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ondemand version
|
// ondemand version
|
||||||
|
@@ -95,7 +95,6 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
void
|
void
|
||||||
Tomahawk::EchonestControl::updateData()
|
Tomahawk::EchonestControl::updateData()
|
||||||
{
|
{
|
||||||
qDebug() << "Sender:" << sender() << qobject_cast<QLineEdit*>(sender()) << m_input << qobject_cast<QLineEdit*>(m_input.data());
|
|
||||||
if( selectedType() == "Artist" ) {
|
if( selectedType() == "Artist" ) {
|
||||||
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
||||||
if( combo ) {
|
if( combo ) {
|
||||||
|
@@ -121,6 +121,7 @@ PlaylistManager::show(const Tomahawk::dynplaylist_ptr& playlist)
|
|||||||
if( !m_dynamicWidgets.contains( playlist ) ) {
|
if( !m_dynamicWidgets.contains( playlist ) ) {
|
||||||
m_dynamicWidgets[ playlist ] = new Tomahawk::DynamicWidget( playlist, m_stack );
|
m_dynamicWidgets[ playlist ] = new Tomahawk::DynamicWidget( playlist, m_stack );
|
||||||
m_stack->addWidget( m_dynamicWidgets[ playlist ] );
|
m_stack->addWidget( m_dynamicWidgets[ playlist ] );
|
||||||
|
playlist->resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_stack->setCurrentWidget( m_dynamicWidgets.value( playlist ) );
|
m_stack->setCurrentWidget( m_dynamicWidgets.value( playlist ) );
|
||||||
|
Reference in New Issue
Block a user