mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 16:29:43 +01:00
auto-expand the local collections on startup
This commit is contained in:
parent
c8ba2ee171
commit
0e6c79b921
@ -114,6 +114,9 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
|
||||
SLOT( onAutoPlaylistsAdded( QList<Tomahawk::dynplaylist_ptr> ) ), Qt::QueuedConnection );
|
||||
connect( source->collection().data(), SIGNAL( stationsAdded( QList<Tomahawk::dynplaylist_ptr> ) ),
|
||||
SLOT( onStationsAdded( QList<Tomahawk::dynplaylist_ptr> ) ), Qt::QueuedConnection );
|
||||
|
||||
if ( m_source->isLocal() )
|
||||
QTimer::singleShot(0, this, SLOT(requestExpanding()));
|
||||
}
|
||||
|
||||
|
||||
@ -343,6 +346,13 @@ CollectionItem::onStationDeleted( const dynplaylist_ptr& station )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CollectionItem::requestExpanding()
|
||||
{
|
||||
emit expandRequest(this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CollectionItem::tempPageActivated( Tomahawk::ViewPage* v )
|
||||
{
|
||||
|
@ -51,6 +51,8 @@ private slots:
|
||||
void onStationsAdded( const QList<Tomahawk::dynplaylist_ptr>& stations );
|
||||
void onStationDeleted( const Tomahawk::dynplaylist_ptr& stations );
|
||||
|
||||
void requestExpanding();
|
||||
|
||||
void tempPageActivated( Tomahawk::ViewPage* );
|
||||
Tomahawk::ViewPage* tempItemClicked();
|
||||
Tomahawk::ViewPage* getTempPage() const;
|
||||
|
@ -33,6 +33,7 @@ SourceTreeItem::SourceTreeItem( SourcesModel* model, SourceTreeItem* parent, Sou
|
||||
connect( this, SIGNAL( childRowsRemoved() ), m_model, SLOT( onItemRowsRemovedDone() ) );
|
||||
connect( this, SIGNAL( updated() ), m_model, SLOT( itemUpdated() ) );
|
||||
connect( this, SIGNAL( selectRequest( SourceTreeItem* ) ), m_model, SLOT( itemSelectRequest( SourceTreeItem* ) ) );
|
||||
connect( this, SIGNAL( expandRequest( SourceTreeItem* ) ), m_model, SLOT( itemExpandRequest( SourceTreeItem* ) ) );
|
||||
if( !m_parent )
|
||||
return;
|
||||
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
signals:
|
||||
void updated();
|
||||
void selectRequest( SourceTreeItem* );
|
||||
void expandRequest( SourceTreeItem* );
|
||||
|
||||
void beginChildRowsAdded( int fromRow, int toRow );
|
||||
void childRowsAdded();
|
||||
|
@ -493,3 +493,10 @@ SourcesModel::itemSelectRequest( SourceTreeItem* item )
|
||||
{
|
||||
emit selectRequest( indexFromItem( item ) );
|
||||
}
|
||||
|
||||
void
|
||||
SourcesModel::itemExpandRequest( SourceTreeItem *item )
|
||||
{
|
||||
qDebug() << "expanding source" << indexFromItem( item ) << item;
|
||||
emit expandRequest( indexFromItem( item ) );
|
||||
}
|
||||
|
@ -102,8 +102,11 @@ public slots:
|
||||
void viewPageActivated( Tomahawk::ViewPage* );
|
||||
|
||||
void itemSelectRequest( SourceTreeItem* item );
|
||||
void itemExpandRequest( SourceTreeItem* item );
|
||||
|
||||
signals:
|
||||
void selectRequest( const QModelIndex& idx );
|
||||
void expandRequest( const QModelIndex& idx );
|
||||
|
||||
private slots:
|
||||
void onSourcesAdded( const QList<Tomahawk::source_ptr>& sources );
|
||||
|
@ -37,8 +37,8 @@ SourcesProxyModel::SourcesProxyModel( SourcesModel* model, QObject* parent )
|
||||
setSourceModel( model );
|
||||
|
||||
|
||||
if ( model && model->metaObject()->indexOfSignal( "trackCountChanged(QModelIndex)" ) > -1 )
|
||||
connect( model, SIGNAL( askForExpand( QModelIndex ) ), this, SLOT( askedToExpand( QModelIndex ) ) );
|
||||
if ( model && model->metaObject()->indexOfSignal( "expandRequest(QModelIndex)" ) > -1 )
|
||||
connect( model, SIGNAL( expandRequest( QModelIndex ) ), this, SLOT( expandRequested( QModelIndex ) ) );
|
||||
if ( model && model->metaObject()->indexOfSignal( "selectRequest(QModelIndex)" ) > -1 )
|
||||
connect( model, SIGNAL( selectRequest( QModelIndex ) ), this, SLOT( selectRequested( QModelIndex ) ) );
|
||||
}
|
||||
@ -73,6 +73,14 @@ SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourcePar
|
||||
void
|
||||
SourcesProxyModel::selectRequested( const QModelIndex& idx )
|
||||
{
|
||||
qDebug() << "selectRequested for idx" << idx << idx.data(Qt::DisplayRole).toString() << mapFromSource( idx );
|
||||
emit selectRequest( mapFromSource( idx ) );
|
||||
}
|
||||
|
||||
void
|
||||
SourcesProxyModel::expandRequested( const QModelIndex& idx )
|
||||
{
|
||||
qDebug() << "emitting expand for idx" << idx << idx.data(Qt::DisplayRole).toString() << mapFromSource( idx );
|
||||
emit expandRequest( mapFromSource( idx ) );
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,11 @@ public slots:
|
||||
void showOfflineSources( bool offlineSourcesShown );
|
||||
|
||||
void selectRequested( const QModelIndex& );
|
||||
void expandRequested( const QModelIndex& );
|
||||
|
||||
signals:
|
||||
void selectRequest( const QModelIndex& idx );
|
||||
void expandRequest( const QModelIndex& idx );
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||
|
@ -108,6 +108,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
||||
m_model = new SourcesModel( this );
|
||||
m_proxyModel = new SourcesProxyModel( m_model, this );
|
||||
connect( m_proxyModel, SIGNAL( selectRequest( QModelIndex ) ), this, SLOT( selectRequest( QModelIndex ) ), Qt::QueuedConnection );
|
||||
connect( m_proxyModel, SIGNAL( expandRequest( QModelIndex ) ), this, SLOT( expandRequest( QModelIndex ) ), Qt::QueuedConnection );
|
||||
|
||||
setModel( m_proxyModel );
|
||||
|
||||
@ -246,6 +247,13 @@ SourceTreeView::selectRequest( const QModelIndex& idx )
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SourceTreeView::expandRequest( const QModelIndex &idx )
|
||||
{
|
||||
qDebug() << "Expanding idx" << idx;
|
||||
expand( idx );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::loadPlaylist()
|
||||
|
@ -49,6 +49,7 @@ private slots:
|
||||
void onItemExpanded( const QModelIndex& idx );
|
||||
void onItemActivated( const QModelIndex& index );
|
||||
void selectRequest( const QModelIndex& idx );
|
||||
void expandRequest( const QModelIndex& idx );
|
||||
|
||||
void loadPlaylist();
|
||||
void deletePlaylist( const QModelIndex& = QModelIndex() );
|
||||
@ -73,6 +74,7 @@ protected:
|
||||
|
||||
private:
|
||||
void setupMenus();
|
||||
int totalSize(const QModelIndex &parentIndex);
|
||||
|
||||
template< typename T >
|
||||
T* itemFromIndex( const QModelIndex& index ) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user