mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-21 16:31:58 +02:00
* Restore a view's state if the model's guid changed.
This commit is contained in:
parent
55821c61de
commit
f5ff0c4558
src/libtomahawk/playlist
@ -72,17 +72,22 @@ ViewHeader::checkState()
|
||||
if ( !count() || m_init )
|
||||
return false;
|
||||
|
||||
disconnect( this, SIGNAL( sectionMoved( int, int, int ) ), this, SLOT( onSectionsChanged() ) );
|
||||
disconnect( this, SIGNAL( sectionResized( int, int, int ) ), this, SLOT( onSectionsChanged() ) );
|
||||
|
||||
QByteArray state;
|
||||
tDebug( LOGVERBOSE ) << "Restoring columns state for view:" << m_guid;
|
||||
|
||||
if ( !m_guid.isEmpty() )
|
||||
state = TomahawkSettings::instance()->playlistColumnSizes( m_guid );
|
||||
|
||||
if ( !state.isEmpty() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << "Restoring columns state for view:" << m_guid;
|
||||
restoreState( state );
|
||||
}
|
||||
else
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << "Giving columns initial weighting:" << m_columnWeights;
|
||||
for ( int i = 0; i < count() - 1; i++ )
|
||||
{
|
||||
if ( isSectionHidden( i ) )
|
||||
@ -95,10 +100,10 @@ ViewHeader::checkState()
|
||||
}
|
||||
}
|
||||
|
||||
m_init = true;
|
||||
connect( this, SIGNAL( sectionMoved( int, int, int ) ), SLOT( onSectionsChanged() ) );
|
||||
connect( this, SIGNAL( sectionResized( int, int, int ) ), SLOT( onSectionsChanged() ) );
|
||||
|
||||
m_init = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -139,10 +144,22 @@ ViewHeader::onToggleResizeColumns()
|
||||
void
|
||||
ViewHeader::toggleVisibility( int index )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << index;
|
||||
|
||||
if ( isSectionHidden( index ) )
|
||||
showSection( index );
|
||||
else
|
||||
hideSection( index );
|
||||
}
|
||||
|
||||
|
||||
void ViewHeader::setGuid( const QString& guid )
|
||||
{
|
||||
m_guid = guid;
|
||||
|
||||
// If we are _not_ initialized yet, this means we're still waiting for the view to resize initially.
|
||||
// We need to wait with restoring our state (column sizes) until that has happened.
|
||||
if ( m_init )
|
||||
{
|
||||
m_init = false;
|
||||
checkState();
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
void setDefaultColumnWeights( QList<double> weights ) { m_columnWeights = weights; }
|
||||
|
||||
QString guid() const { return m_guid; }
|
||||
void setGuid( const QString& guid ) { m_guid = guid; }
|
||||
void setGuid( const QString& guid );
|
||||
|
||||
public slots:
|
||||
void toggleVisibility( int index );
|
||||
|
Loading…
x
Reference in New Issue
Block a user