mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-14 04:51:53 +02:00
be smarter about when we reload the UI
This commit is contained in:
parent
7eb6822725
commit
bb5d1ca709
@ -92,12 +92,24 @@ DynamicControlList::init()
|
||||
void
|
||||
DynamicControlList::setControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, bool isLocal )
|
||||
{
|
||||
if( m_controls.size() == controls.size() ) { // check if we're setting the same controls we already have, and exit if we are
|
||||
bool different = false;
|
||||
for( int i = 0; i < m_controls.size(); i++ ) {
|
||||
if( m_controls.value( i )->control().data() != controls.value( i ).data() ) {
|
||||
different = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !different ) { // no work to do
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( !m_controls.isEmpty() ) {
|
||||
qDeleteAll( m_controls );
|
||||
m_controls.clear();
|
||||
}
|
||||
|
||||
|
||||
m_layout->removeItem( m_collapseLayout );
|
||||
|
||||
m_isLocal = isLocal;
|
||||
@ -124,11 +136,14 @@ DynamicControlList::setControls( const geninterface_ptr& generator, const QList<
|
||||
|
||||
void DynamicControlList::addNewControl()
|
||||
{
|
||||
m_layout->removeItem( m_collapseLayout );
|
||||
|
||||
dyncontrol_ptr control = m_generator->createControl();
|
||||
m_controls.append( new DynamicControlWrapper( control, m_layout, m_controls.size(), m_isLocal, this ) );
|
||||
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
||||
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
|
||||
|
||||
m_layout->addItem( m_collapseLayout, m_layout->rowCount(), 0, 1, 4, Qt::AlignCenter );
|
||||
emit controlsChanged();
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <QStackedWidget>
|
||||
|
||||
class QEvent;
|
||||
class QGridLayout;
|
||||
class QPushButton;
|
||||
class QHBoxLayout;
|
||||
@ -48,7 +49,7 @@ public:
|
||||
|
||||
void setControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, bool isLocal );
|
||||
QList< DynamicControlWrapper* > controls() const { return m_controls; }
|
||||
|
||||
|
||||
signals:
|
||||
void controlsChanged();
|
||||
void controlChanged( const Tomahawk::dyncontrol_ptr& control );
|
||||
|
@ -59,7 +59,7 @@ DynamicControlWrapper::DynamicControlWrapper( const Tomahawk::dyncontrol_ptr& co
|
||||
connect( m_minusButton, SIGNAL( clicked( bool ) ), this, SIGNAL( removeControl() ) );
|
||||
|
||||
|
||||
m_plusL = new QStackedLayout;
|
||||
m_plusL = new QStackedLayout();
|
||||
m_plusL->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_plusL->setMargin( 0 );
|
||||
m_plusL->addWidget( m_minusButton );
|
||||
@ -81,7 +81,7 @@ DynamicControlWrapper::DynamicControlWrapper( const Tomahawk::dyncontrol_ptr& co
|
||||
if( m_isLocal )
|
||||
{
|
||||
m_layout->addLayout( m_plusL, m_row, 3, Qt::AlignCenter );
|
||||
m_plusL->setCurrentIndex( 1 );
|
||||
m_plusL->setCurrentIndex( 0 );
|
||||
}
|
||||
|
||||
}
|
||||
@ -98,6 +98,8 @@ DynamicControlWrapper::~DynamicControlWrapper()
|
||||
delete m_typeSelector;
|
||||
delete m_matchSelector;
|
||||
delete m_entryWidget;
|
||||
delete m_minusButton;
|
||||
delete m_plusL;
|
||||
}
|
||||
|
||||
dyncontrol_ptr
|
||||
|
@ -105,8 +105,18 @@ DynamicWidget::~DynamicWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void DynamicWidget::loadDynamicPlaylist(const Tomahawk::dynplaylist_ptr& playlist)
|
||||
void
|
||||
DynamicWidget::loadDynamicPlaylist( const Tomahawk::dynplaylist_ptr& playlist )
|
||||
{
|
||||
// if we're being told to load the same dynamic playlist over again, only do it if the controls have a different number
|
||||
if( !m_playlist.isNull() && ( m_playlist.data() == playlist.data() ) // same playlist pointer
|
||||
&& m_playlist->generator()->controls().size() == playlist->generator()->controls().size() ) {
|
||||
// we can skip our work. just let the dynamiccontrollist show the difference
|
||||
m_controls->setControls( m_playlist->generator(), m_playlist->generator()->controls(), m_playlist->author()->isLocal() );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( !m_playlist.isNull() ) {
|
||||
disconnect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
|
||||
disconnect( m_playlist.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision) ), this, SLOT(onRevisionLoaded( Tomahawk::DynamicPlaylistRevision) ) );
|
||||
|
@ -38,6 +38,9 @@ ReadOrWriteWidget::ReadOrWriteWidget( QWidget* writableWidget, bool writable, QW
|
||||
setWritable( m_writable );
|
||||
|
||||
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
|
||||
setContentsMargins( 0, 0, 0, 0 );
|
||||
m_layout->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_layout->setSpacing( 0 );
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user