mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-21 13:21:52 +02:00
resolve playlists when set from a peer
update dynamic playlist to peers 3s after editing a control is finished
This commit is contained in:
@@ -26,6 +26,10 @@ Tomahawk::EchonestControl::EchonestControl( const QString& selectedType, const Q
|
||||
: DynamicControl ( selectedType.isEmpty() ? "Artist" : selectedType, typeSelectors, parent )
|
||||
{
|
||||
setType( "echonest" );
|
||||
m_editingTimer.setInterval( 3000 ); // 3 second timeout to edits
|
||||
m_editingTimer.setSingleShot( true );
|
||||
|
||||
connect( &m_editingTimer, SIGNAL( timeout() ), this, SIGNAL( changed() ) );
|
||||
updateWidgets();
|
||||
}
|
||||
|
||||
@@ -117,7 +121,8 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
connect( match, SIGNAL( currentIndexChanged(int) ), this, SLOT( updateData() ) );
|
||||
connect( match, SIGNAL( currentIndexChanged(int) ), this, SIGNAL( changed() ) );
|
||||
connect( input, SIGNAL( textChanged(QString) ), this, SLOT( updateData() ) );
|
||||
connect( input, SIGNAL( editingFinished() ), this, SIGNAL( changed() ) );
|
||||
connect( input, SIGNAL( editingFinished() ), this, SLOT( editingFinished() ) );
|
||||
connect( input, SIGNAL( textEdited( QString ) ), &m_editingTimer, SLOT( stop() ) );
|
||||
|
||||
match->hide();
|
||||
input->hide();
|
||||
@@ -147,7 +152,8 @@ Tomahawk::EchonestControl::updateData()
|
||||
}
|
||||
|
||||
// fills in the current widget with the data from json or dbcmd (m_data.second and m_matchData)
|
||||
void Tomahawk::EchonestControl::updateWidgetsFromData()
|
||||
void
|
||||
Tomahawk::EchonestControl::updateWidgetsFromData()
|
||||
{
|
||||
if( selectedType() == "Artist" ) {
|
||||
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
||||
@@ -159,3 +165,9 @@ void Tomahawk::EchonestControl::updateWidgetsFromData()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Tomahawk::EchonestControl::editingFinished()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
m_editingTimer.start();
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <echonest/Playlist.h>
|
||||
|
||||
#include "dynamic/DynamicControl.h"
|
||||
#include <QTimer>
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
@@ -49,6 +50,7 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void updateData();
|
||||
void editingFinished();
|
||||
|
||||
private:
|
||||
void updateWidgets();
|
||||
@@ -61,6 +63,8 @@ private:
|
||||
QString m_matchData;
|
||||
QString m_matchString;
|
||||
|
||||
QTimer m_editingTimer;
|
||||
|
||||
Echonest::DynamicPlaylist::PlaylistParamData m_data;
|
||||
|
||||
friend class EchonestGenerator;
|
||||
|
@@ -30,7 +30,6 @@ DynamicControlList::DynamicControlList()
|
||||
: AnimatedWidget()
|
||||
, m_layout( new QVBoxLayout )
|
||||
, m_summaryWidget( 0 )
|
||||
, m_lastControlDirty( false )
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -40,7 +39,6 @@ DynamicControlList::DynamicControlList( AnimatedSplitter* parent )
|
||||
, m_layout( new QVBoxLayout )
|
||||
, m_summaryWidget( 0 )
|
||||
, m_isLocal( true )
|
||||
, m_lastControlDirty( false )
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -51,7 +49,6 @@ DynamicControlList::DynamicControlList( const geninterface_ptr& generator, const
|
||||
, m_layout( new QVBoxLayout )
|
||||
, m_summaryWidget( 0 )
|
||||
, m_isLocal( isLocal )
|
||||
, m_lastControlDirty( false )
|
||||
{
|
||||
init();
|
||||
setControls( generator, controls, m_isLocal );
|
||||
@@ -97,12 +94,14 @@ DynamicControlList::setControls( const geninterface_ptr& generator, const QList<
|
||||
m_controls << new DynamicControlWidget( generator->createControl(), false, false, false, isLocal, this );
|
||||
connect( m_controls.last(), SIGNAL( addNewControl() ), this, SLOT( addNewControl() ) );
|
||||
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
||||
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
|
||||
} else
|
||||
{
|
||||
foreach( const dyncontrol_ptr& control, controls ) {
|
||||
m_controls << new DynamicControlWidget( control, false, false, false, isLocal, this );
|
||||
connect( m_controls.last(), SIGNAL( addNewControl() ), this, SLOT( addNewControl() ) );
|
||||
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
||||
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
|
||||
}
|
||||
}
|
||||
onShown( this );
|
||||
@@ -155,7 +154,6 @@ void DynamicControlList::addNewControl()
|
||||
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
||||
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
|
||||
|
||||
m_lastControlDirty = false;
|
||||
emit controlsChanged();
|
||||
}
|
||||
|
||||
@@ -181,19 +179,10 @@ void DynamicControlList::controlChanged()
|
||||
Q_ASSERT( sender() && qobject_cast<DynamicControlWidget*>(sender()) );
|
||||
DynamicControlWidget* widget = qobject_cast<DynamicControlWidget*>(sender());
|
||||
|
||||
if( !widget->control()->input().isEmpty() )
|
||||
m_lastControlDirty = true;
|
||||
|
||||
emit controlChanged( qobject_cast<DynamicControlWidget*>(sender())->control() );
|
||||
emit controlChanged( widget->control() );
|
||||
}
|
||||
|
||||
|
||||
void DynamicControlList::paintEvent(QPaintEvent* )
|
||||
{
|
||||
}
|
||||
|
||||
bool DynamicControlList::lastControlDirty() const
|
||||
{
|
||||
return m_lastControlDirty;
|
||||
}
|
||||
|
||||
|
@@ -47,7 +47,6 @@ public:
|
||||
|
||||
virtual void paintEvent(QPaintEvent* );
|
||||
|
||||
bool lastControlDirty() const;
|
||||
signals:
|
||||
void controlsChanged();
|
||||
void controlChanged( const Tomahawk::dyncontrol_ptr& control );
|
||||
@@ -68,7 +67,6 @@ private:
|
||||
QList< DynamicControlWidget* > m_controls;
|
||||
QWidget* m_summaryWidget;
|
||||
bool m_isLocal;
|
||||
bool m_lastControlDirty;
|
||||
};
|
||||
|
||||
};
|
||||
|
@@ -150,7 +150,7 @@ DynamicWidget::onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev )
|
||||
{
|
||||
qDebug() << "DynamicWidget::onRevisionLoaded";
|
||||
loadDynamicPlaylist( m_playlist );
|
||||
if( m_resolveOnNextLoad )
|
||||
if( m_resolveOnNextLoad || !m_playlist->author()->isLocal() )
|
||||
{
|
||||
m_playlist->resolve();
|
||||
m_resolveOnNextLoad = false;
|
||||
@@ -279,16 +279,15 @@ void
|
||||
DynamicWidget::controlsChanged()
|
||||
{
|
||||
// save the current playlist
|
||||
// if( !m_controls->lastControlDirty() ) {
|
||||
if( m_controls->controls().size() == 1 && m_controls->lastControlDirty() && m_playlist->generator()->controls().at( 0 )->input() == QString() ) {
|
||||
if( m_controls->controls().size() == 1 && m_playlist->generator()->controls().at( 0 )->input() == QString() ) { // if there is only 1 empty control, remove it as it's the default created one
|
||||
m_playlist->generator()->removeControl( m_playlist->generator()->controls().last() );
|
||||
}
|
||||
m_playlist->createNewRevision();
|
||||
}
|
||||
|
||||
void
|
||||
DynamicWidget::controlChanged(const Tomahawk::dyncontrol_ptr& control)
|
||||
DynamicWidget::controlChanged( const Tomahawk::dyncontrol_ptr& control )
|
||||
{
|
||||
|
||||
m_playlist->createNewRevision();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user