mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
* Restore a view's state if the model's guid changed.
This commit is contained in:
@@ -72,17 +72,22 @@ ViewHeader::checkState()
|
|||||||
if ( !count() || m_init )
|
if ( !count() || m_init )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
disconnect( this, SIGNAL( sectionMoved( int, int, int ) ), this, SLOT( onSectionsChanged() ) );
|
||||||
|
disconnect( this, SIGNAL( sectionResized( int, int, int ) ), this, SLOT( onSectionsChanged() ) );
|
||||||
|
|
||||||
QByteArray state;
|
QByteArray state;
|
||||||
|
tDebug( LOGVERBOSE ) << "Restoring columns state for view:" << m_guid;
|
||||||
|
|
||||||
if ( !m_guid.isEmpty() )
|
if ( !m_guid.isEmpty() )
|
||||||
state = TomahawkSettings::instance()->playlistColumnSizes( m_guid );
|
state = TomahawkSettings::instance()->playlistColumnSizes( m_guid );
|
||||||
|
|
||||||
if ( !state.isEmpty() )
|
if ( !state.isEmpty() )
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << "Restoring columns state for view:" << m_guid;
|
|
||||||
restoreState( state );
|
restoreState( state );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << "Giving columns initial weighting:" << m_columnWeights;
|
||||||
for ( int i = 0; i < count() - 1; i++ )
|
for ( int i = 0; i < count() - 1; i++ )
|
||||||
{
|
{
|
||||||
if ( isSectionHidden( 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( sectionMoved( int, int, int ) ), SLOT( onSectionsChanged() ) );
|
||||||
connect( this, SIGNAL( sectionResized( int, int, int ) ), SLOT( onSectionsChanged() ) );
|
connect( this, SIGNAL( sectionResized( int, int, int ) ), SLOT( onSectionsChanged() ) );
|
||||||
|
|
||||||
|
m_init = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,10 +144,22 @@ ViewHeader::onToggleResizeColumns()
|
|||||||
void
|
void
|
||||||
ViewHeader::toggleVisibility( int index )
|
ViewHeader::toggleVisibility( int index )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << index;
|
|
||||||
|
|
||||||
if ( isSectionHidden( index ) )
|
if ( isSectionHidden( index ) )
|
||||||
showSection( index );
|
showSection( index );
|
||||||
else
|
else
|
||||||
hideSection( index );
|
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; }
|
void setDefaultColumnWeights( QList<double> weights ) { m_columnWeights = weights; }
|
||||||
|
|
||||||
QString guid() const { return m_guid; }
|
QString guid() const { return m_guid; }
|
||||||
void setGuid( const QString& guid ) { m_guid = guid; }
|
void setGuid( const QString& guid );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggleVisibility( int index );
|
void toggleVisibility( int index );
|
||||||
|
Reference in New Issue
Block a user