Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Restore a view's state if the model's guid changed.

  • Loading branch information...
commit f5ff0c45585c5bb27776de038e7e7fe1c00fe0d1 1 parent 55821c6
Christian Muehlhaeuser muesli authored
25 src/libtomahawk/playlist/ViewHeader.cpp
View
@@ -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();
+ }
+}
2  src/libtomahawk/playlist/ViewHeader.h
View
@@ -37,7 +37,7 @@ Q_OBJECT
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 );
Please sign in to comment.
Something went wrong with that request. Please try again.