diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ed08c7e1..62932e4b9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -99,7 +99,6 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui} dynamic/widgets/DynamicWidget.cpp dynamic/widgets/DynamicControlWidget.cpp dynamic/widgets/DynamicControlList.cpp - dynamic/DynamicPlaylistModel.cpp transferview.cpp tomahawkwindow.cpp @@ -181,7 +180,6 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui} dynamic/widgets/DynamicWidget.h dynamic/widgets/DynamicControlWidget.h dynamic/widgets/DynamicControlList.h - dynamic/DynamicPlaylistModel.h transferview.h tomahawkwindow.h diff --git a/src/dynamic/DynamicPlaylistModel.cpp b/src/dynamic/DynamicPlaylistModel.cpp deleted file mode 100644 index de185b758..000000000 --- a/src/dynamic/DynamicPlaylistModel.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * 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 . * - ****************************************************************************************/ - -#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) -{ - -} diff --git a/src/dynamic/DynamicPlaylistModel.h b/src/dynamic/DynamicPlaylistModel.h deleted file mode 100644 index cca3cfa35..000000000 --- a/src/dynamic/DynamicPlaylistModel.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * 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 . * - ****************************************************************************************/ -#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 diff --git a/src/dynamic/widgets/DynamicWidget.cpp b/src/dynamic/widgets/DynamicWidget.cpp index 5a1809a91..fc6ed4acc 100644 --- a/src/dynamic/widgets/DynamicWidget.cpp +++ b/src/dynamic/widgets/DynamicWidget.cpp @@ -32,7 +32,6 @@ using namespace Tomahawk; DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget* parent ) : QWidget(parent) - , m_playlist( playlist ) , m_layout( new QVBoxLayout ) , m_headerText( 0 ) , m_headerLayout( 0 ) @@ -51,7 +50,6 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget m_modeCombo = new QComboBox( this ); m_modeCombo->addItem( "On Demand", 0 ); m_modeCombo->addItem( "Static", 1 ); - m_modeCombo->setCurrentIndex( static_cast( playlist->mode() ) ); m_headerLayout->addWidget( m_modeCombo ); m_generatorCombo = new QComboBox( this ); 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->hide(); - if( playlist->mode() == Static ) { - m_generateButton->show(); - m_headerLayout->addWidget( m_generateButton ); - } connect( m_generateButton, SIGNAL( clicked( bool ) ), this, SLOT( generate() ) ); m_layout->addLayout( m_headerLayout ); @@ -86,26 +80,42 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget m_splitter->show( 0, false ); - if( !m_playlist.isNull() ) { - m_controls->setControls( m_playlist->generator(), m_playlist->generator()->controls() ); + loadDynamicPlaylist( playlist ); - m_model->loadPlaylist( m_playlist ); - } - - connect( m_playlist->generator().data(), SIGNAL( generated( QList ) ), this, SLOT( tracksGenerated( QList ) ) ); - setLayout( m_layout ); } DynamicWidget::~DynamicWidget() { - } -void -DynamicWidget::setPlaylist(const Tomahawk::dynplaylist_ptr& playlist) +void DynamicWidget::loadDynamicPlaylist(const Tomahawk::dynplaylist_ptr& playlist) { + if( !m_playlist.isNull() ) { + disconnect( m_playlist->generator().data(), SIGNAL( generated( QList ) ), this, SLOT( tracksGenerated( QList ) ) ); + } + 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( 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 ) ), this, SLOT( tracksGenerated( QList ) ) ); +} + + +void +DynamicWidget::setPlaylist( const Tomahawk::DynamicPlaylistRevision& rev ) +{ + loadDynamicPlaylist( m_playlist ); } PlaylistInterface* @@ -125,6 +135,5 @@ 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(); } diff --git a/src/dynamic/widgets/DynamicWidget.h b/src/dynamic/widgets/DynamicWidget.h index 490ea354e..ea7c927ac 100644 --- a/src/dynamic/widgets/DynamicWidget.h +++ b/src/dynamic/widgets/DynamicWidget.h @@ -19,6 +19,7 @@ #include #include +#include class QVBoxLayout; class QHBoxLayout; @@ -45,10 +46,13 @@ public: explicit DynamicWidget( const dynplaylist_ptr& playlist, QWidget* parent = 0); virtual ~DynamicWidget(); - void setPlaylist( const dynplaylist_ptr& playlist ); + void loadDynamicPlaylist( const dynplaylist_ptr& playlist ); PlaylistInterface* playlistInterface() const; +public slots: + void setPlaylist( const DynamicPlaylistRevision& rev ); + private slots: void generate(); void tracksGenerated( const QList< Tomahawk::query_ptr>& queries ); diff --git a/src/libtomahawk/database/databasecommand_setplaylistrevision.cpp b/src/libtomahawk/database/databasecommand_setplaylistrevision.cpp index 2f60afcb5..5cabed1f0 100644 --- a/src/libtomahawk/database/databasecommand_setplaylistrevision.cpp +++ b/src/libtomahawk/database/databasecommand_setplaylistrevision.cpp @@ -65,8 +65,6 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib ) { using namespace Tomahawk; - QString m_currentRevision; - // get the current revision for this playlist // this also serves to check the playlist exists. TomahawkSqlQuery chkq = lib->newquery(); @@ -75,7 +73,7 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib ) if( chkq.exec() && chkq.next() ) { 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 { diff --git a/src/libtomahawk/dynamic/DynamicPlaylist.cpp b/src/libtomahawk/dynamic/DynamicPlaylist.cpp index fa02e1fc2..b744e5daa 100644 --- a/src/libtomahawk/dynamic/DynamicPlaylist.cpp +++ b/src/libtomahawk/dynamic/DynamicPlaylist.cpp @@ -298,16 +298,20 @@ DynamicPlaylist::setRevision( const QString& rev, m_generator->setControls( controls ); m_generator->setMode( Static ); - DynamicPlaylistRevision pr = setNewRevision( rev, neworderedguids, oldorderedguids, is_newest_rev, addedmap ); - pr.controls = controls; - pr.type = type; - pr.mode = Static; + PlaylistRevision pr = setNewRevision( rev, neworderedguids, oldorderedguids, is_newest_rev, addedmap ); + pr.applied = applied; + + DynamicPlaylistRevision dpr = pr; + dpr.controls = controls; + dpr.type = type; + dpr.mode = Static; if( applied ) 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 diff --git a/src/libtomahawk/dynamic/echonest/EchonestControl.cpp b/src/libtomahawk/dynamic/echonest/EchonestControl.cpp index 5c7d34778..dc1ace2f1 100644 --- a/src/libtomahawk/dynamic/echonest/EchonestControl.cpp +++ b/src/libtomahawk/dynamic/echonest/EchonestControl.cpp @@ -95,7 +95,6 @@ Tomahawk::EchonestControl::updateWidgets() void Tomahawk::EchonestControl::updateData() { - qDebug() << "Sender:" << sender() << qobject_cast(sender()) << m_input << qobject_cast(m_input.data()); if( selectedType() == "Artist" ) { QComboBox* combo = qobject_cast( m_match.data() ); if( combo ) { diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 2c0d2ae8e..6e03ba63e 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -121,6 +121,7 @@ PlaylistManager::show(const Tomahawk::dynplaylist_ptr& playlist) if( !m_dynamicWidgets.contains( playlist ) ) { m_dynamicWidgets[ playlist ] = new Tomahawk::DynamicWidget( playlist, m_stack ); m_stack->addWidget( m_dynamicWidgets[ playlist ] ); + playlist->resolve(); } m_stack->setCurrentWidget( m_dynamicWidgets.value( playlist ) );