1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 03:10:12 +02:00

* Fixed TWK-703: Auto expand sidebar's groups per default.

This commit is contained in:
Christian Muehlhaeuser
2012-03-02 04:42:25 +01:00
parent be7b5babe9
commit cdf7c11b29
3 changed files with 20 additions and 3 deletions

View File

@@ -30,9 +30,8 @@ using namespace Tomahawk;
GroupItem::GroupItem( SourcesModel* model, SourceTreeItem* parent, const QString& text, int peerSortValue ) GroupItem::GroupItem( SourcesModel* model, SourceTreeItem* parent, const QString& text, int peerSortValue )
: SourceTreeItem( model, parent, SourcesModel::Group, peerSortValue ) : SourceTreeItem( model, parent, SourcesModel::Group, peerSortValue )
, m_text( text ) , m_text( text )
, m_defaultExpanded( true )
{ {
// expand by default
QTimer::singleShot( 0, this, SLOT( requestExpanding() ) );
} }
@@ -55,6 +54,18 @@ GroupItem::requestExpanding()
} }
void
GroupItem::checkExpandedState()
{
if ( m_defaultExpanded )
{
// only default expand once
m_defaultExpanded = false;
requestExpanding();
}
}
QString QString
GroupItem::text() const GroupItem::text() const
{ {

View File

@@ -38,6 +38,9 @@ public:
virtual QIcon icon() const { return QIcon(); } virtual QIcon icon() const { return QIcon(); }
virtual bool isBeingPlayed() const { return false; } virtual bool isBeingPlayed() const { return false; }
void checkExpandedState();
void setDefaultExpanded( bool b ) { m_defaultExpanded = b; }
public slots: public slots:
virtual void activate(); virtual void activate();
@@ -49,6 +52,7 @@ private slots:
private: private:
QString m_text; QString m_text;
bool m_defaultExpanded;
}; };
#endif #endif

View File

@@ -300,7 +300,7 @@ SourcesModel::appendGroups()
void void
SourcesModel::appendItem( const Tomahawk::source_ptr& source ) SourcesModel::appendItem( const Tomahawk::source_ptr& source )
{ {
SourceTreeItem* parent; GroupItem* parent;
if ( !source.isNull() && source->isLocal() ) if ( !source.isNull() && source->isLocal() )
{ {
parent = m_myMusicGroup; parent = m_myMusicGroup;
@@ -314,6 +314,8 @@ SourcesModel::appendItem( const Tomahawk::source_ptr& source )
beginInsertRows( idx, rowCount( idx ), rowCount( idx ) ); beginInsertRows( idx, rowCount( idx ), rowCount( idx ) );
new SourceItem( this, parent, source ); new SourceItem( this, parent, source );
endInsertRows(); endInsertRows();
parent->checkExpandedState();
} }