mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 00:09:47 +01:00
Move ScriptCollection items to their own top-level category.
This commit is contained in:
parent
176a9c8ce0
commit
1bf5787d74
@ -253,6 +253,14 @@ SourceList::count() const
|
||||
return m_sources.size();
|
||||
}
|
||||
|
||||
|
||||
QList<collection_ptr>
|
||||
SourceList::scriptCollections() const
|
||||
{
|
||||
return m_scriptCollections;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceList::latchedOff( const source_ptr& to )
|
||||
{
|
||||
@ -305,26 +313,19 @@ SourceList::addScriptCollection( const collection_ptr& collection )
|
||||
{
|
||||
m_scriptCollections.append( collection );
|
||||
|
||||
matchSourceForScriptCollection( collection );
|
||||
emit scriptCollectionAdded( collection );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceList::removeScriptCollection( const collection_ptr& collection )
|
||||
{
|
||||
getLocal()->removeCollection( collection );
|
||||
emit scriptCollectionRemoved( collection );
|
||||
|
||||
m_scriptCollections.removeAll( collection );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceList::matchSourceForScriptCollection( const collection_ptr& collection )
|
||||
{
|
||||
//TODO: implement for multi-collection resolvers
|
||||
getLocal()->addCollection( collection );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceList::latchedOn( const source_ptr& to )
|
||||
{
|
||||
|
@ -52,6 +52,8 @@ public:
|
||||
QList<Tomahawk::source_ptr> sources( bool onlyOnline = false ) const;
|
||||
unsigned int count() const;
|
||||
|
||||
QList<Tomahawk::collection_ptr> scriptCollections() const;
|
||||
|
||||
Tomahawk::source_ptr get( const QString& username, const QString& friendlyName = QString(), bool autoCreate = false );
|
||||
Tomahawk::source_ptr get( int id ) const;
|
||||
|
||||
@ -69,6 +71,9 @@ signals:
|
||||
void sourceAdded( const Tomahawk::source_ptr& );
|
||||
void sourceRemoved( const Tomahawk::source_ptr& );
|
||||
|
||||
void scriptCollectionAdded( const Tomahawk::collection_ptr& );
|
||||
void scriptCollectionRemoved( const Tomahawk::collection_ptr& );
|
||||
|
||||
void sourceLatchedOn( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to );
|
||||
void sourceLatchedOff( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to );
|
||||
|
||||
@ -84,7 +89,6 @@ private slots:
|
||||
|
||||
private:
|
||||
void add( const Tomahawk::source_ptr& source );
|
||||
void matchSourceForScriptCollection( const Tomahawk::collection_ptr& collection );
|
||||
|
||||
QMap< QString, Tomahawk::source_ptr > m_sources;
|
||||
QMap< int, QString > m_sources_id2name;
|
||||
|
@ -58,9 +58,22 @@ SourcesModel::SourcesModel( QObject* parent )
|
||||
appendGroups();
|
||||
onSourcesAdded( SourceList::instance()->sources() );
|
||||
|
||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
||||
connect( SourceList::instance(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceRemoved( Tomahawk::source_ptr ) ) );
|
||||
connect( ViewManager::instance(), SIGNAL( viewPageActivated( Tomahawk::ViewPage* ) ), this, SLOT( viewPageActivated( Tomahawk::ViewPage* ) ) );
|
||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ),
|
||||
SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
||||
connect( SourceList::instance(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ),
|
||||
SLOT( onSourceRemoved( Tomahawk::source_ptr ) ) );
|
||||
connect( ViewManager::instance(), SIGNAL( viewPageActivated( Tomahawk::ViewPage* ) ),
|
||||
this, SLOT( viewPageActivated( Tomahawk::ViewPage* ) ) );
|
||||
|
||||
foreach ( const collection_ptr& c, SourceList::instance()->scriptCollections() )
|
||||
{
|
||||
onScriptCollectionAdded( c );
|
||||
}
|
||||
|
||||
connect( SourceList::instance(), SIGNAL( scriptCollectionAdded( Tomahawk::collection_ptr ) ),
|
||||
this, SLOT( onScriptCollectionAdded( Tomahawk::collection_ptr ) ) );
|
||||
connect( SourceList::instance(), SIGNAL( scriptCollectionRemoved( Tomahawk::collection_ptr ) ),
|
||||
this, SLOT( onScriptCollectionRemoved( Tomahawk::collection_ptr ) ) );
|
||||
}
|
||||
|
||||
|
||||
@ -275,7 +288,7 @@ SourcesModel::flags( const QModelIndex& index ) const
|
||||
void
|
||||
SourcesModel::appendGroups()
|
||||
{
|
||||
beginInsertRows( QModelIndex(), rowCount(), rowCount() + 3 );
|
||||
beginInsertRows( QModelIndex(), rowCount(), rowCount() + 4 );
|
||||
|
||||
GroupItem* browse = new GroupItem( this, m_rootItem, tr( "Browse" ), 0 );
|
||||
new HistoryItem( this, m_rootItem, tr( "Search History" ), 1 );
|
||||
@ -314,6 +327,8 @@ SourcesModel::appendGroups()
|
||||
|
||||
m_collectionsGroup = new GroupItem( this, m_rootItem, tr( "Friends" ), 4 );
|
||||
|
||||
m_cloudGroup = new GroupItem( this, m_rootItem, tr( "Cloud" ), 5 );
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
@ -492,6 +507,59 @@ SourcesModel::onSourceRemoved( const source_ptr& source )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourcesModel::onScriptCollectionAdded( const collection_ptr& collection )
|
||||
{
|
||||
if ( m_scriptCollections.contains( collection ) )
|
||||
return;
|
||||
|
||||
QModelIndex parent = indexFromItem( m_cloudGroup );
|
||||
beginInsertRows( parent, rowCount( parent ), rowCount( parent ) );
|
||||
GenericPageItem* item = new GenericPageItem( this,
|
||||
m_cloudGroup,
|
||||
collection->itemName(),
|
||||
collection->icon(),
|
||||
boost::bind( &SourcesModel::scriptCollectionClicked, this, collection ),
|
||||
boost::bind( &SourcesModel::getScriptCollectionPage, this, collection ) );
|
||||
endInsertRows();
|
||||
|
||||
m_scriptCollections.insert( collection, item );
|
||||
m_cloudGroup->checkExpandedState();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourcesModel::onScriptCollectionRemoved( const collection_ptr& collection )
|
||||
{
|
||||
SourceTreeItem* item = m_scriptCollections.value( collection );
|
||||
int row = indexFromItem( item ).row();
|
||||
|
||||
QModelIndex parent = indexFromItem( m_cloudGroup );
|
||||
beginRemoveRows( parent, row, row );
|
||||
m_cloudGroup->removeChild( item );
|
||||
endRemoveRows();
|
||||
|
||||
m_scriptCollectionPages.remove( collection );
|
||||
m_scriptCollections.remove( collection );
|
||||
item->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
ViewPage*
|
||||
SourcesModel::scriptCollectionClicked( const Tomahawk::collection_ptr& collection )
|
||||
{
|
||||
m_scriptCollectionPages[ collection ] = ViewManager::instance()->show( collection );
|
||||
return m_scriptCollectionPages[ collection ];
|
||||
}
|
||||
|
||||
|
||||
ViewPage*
|
||||
SourcesModel::getScriptCollectionPage( const Tomahawk::collection_ptr& collection ) const
|
||||
{
|
||||
return m_scriptCollectionPages[ collection ];
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourcesModel::itemUpdated()
|
||||
{
|
||||
|
@ -135,6 +135,12 @@ private slots:
|
||||
void onSourceAdded( const Tomahawk::source_ptr& source );
|
||||
void onSourceRemoved( const Tomahawk::source_ptr& source );
|
||||
|
||||
void onScriptCollectionAdded( const Tomahawk::collection_ptr& collection );
|
||||
void onScriptCollectionRemoved( const Tomahawk::collection_ptr& collection );
|
||||
|
||||
Tomahawk::ViewPage* scriptCollectionClicked( const Tomahawk::collection_ptr& collection );
|
||||
Tomahawk::ViewPage* getScriptCollectionPage( const Tomahawk::collection_ptr& collection ) const;
|
||||
|
||||
void onWidgetDestroyed( QWidget* w );
|
||||
|
||||
private:
|
||||
@ -145,9 +151,12 @@ private:
|
||||
SourceTreeItem* m_rootItem;
|
||||
GroupItem* m_collectionsGroup;
|
||||
GroupItem* m_myMusicGroup;
|
||||
GroupItem* m_cloudGroup;
|
||||
|
||||
QList< Tomahawk::source_ptr > m_sourcesWithViewPage;
|
||||
QHash< Tomahawk::source_ptr, SourceTreeItem* > m_sourcesWithViewPageItems;
|
||||
QHash< Tomahawk::collection_ptr, SourceTreeItem* > m_scriptCollections;
|
||||
QHash< Tomahawk::collection_ptr, Tomahawk::ViewPage* > m_scriptCollectionPages;
|
||||
|
||||
QHash< Tomahawk::ViewPage*, SourceTreeItem* > m_sourceTreeLinks;
|
||||
Tomahawk::ViewPage* m_viewPageDelayedCacheItem;
|
||||
|
Loading…
x
Reference in New Issue
Block a user