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