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:
@@ -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
|
||||||
{
|
{
|
||||||
|
@@ -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
|
||||||
|
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user