mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* CollectionFlatModel is obsolete now.
This commit is contained in:
@@ -52,7 +52,6 @@ set( libGuiSources
|
|||||||
playlist/TreeItemDelegate.cpp
|
playlist/TreeItemDelegate.cpp
|
||||||
playlist/CollectionProxyModel.cpp
|
playlist/CollectionProxyModel.cpp
|
||||||
playlist/CollectionProxyModelPlaylistInterface.cpp
|
playlist/CollectionProxyModelPlaylistInterface.cpp
|
||||||
playlist/CollectionFlatModel.cpp
|
|
||||||
playlist/CollectionView.cpp
|
playlist/CollectionView.cpp
|
||||||
playlist/PlaylistModel.cpp
|
playlist/PlaylistModel.cpp
|
||||||
playlist/PlaylistProxyModel.cpp
|
playlist/PlaylistProxyModel.cpp
|
||||||
|
@@ -28,7 +28,6 @@
|
|||||||
#include "topbar/TopBar.h"
|
#include "topbar/TopBar.h"
|
||||||
|
|
||||||
#include "TreeModel.h"
|
#include "TreeModel.h"
|
||||||
#include "CollectionFlatModel.h"
|
|
||||||
#include "CollectionView.h"
|
#include "CollectionView.h"
|
||||||
#include "PlaylistModel.h"
|
#include "PlaylistModel.h"
|
||||||
#include "PlaylistView.h"
|
#include "PlaylistView.h"
|
||||||
@@ -280,7 +279,7 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
|
|||||||
ViewPage* shown = 0;
|
ViewPage* shown = 0;
|
||||||
if ( m_currentMode == PlaylistModes::Flat )
|
if ( m_currentMode == PlaylistModes::Flat )
|
||||||
{
|
{
|
||||||
CollectionView* view;
|
/* CollectionView* view;
|
||||||
if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() )
|
if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() )
|
||||||
{
|
{
|
||||||
view = new CollectionView();
|
view = new CollectionView();
|
||||||
@@ -297,7 +296,7 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
|
|||||||
}
|
}
|
||||||
|
|
||||||
shown = view;
|
shown = view;
|
||||||
setPage( view );
|
setPage( view );*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_currentMode == PlaylistModes::Tree )
|
if ( m_currentMode == PlaylistModes::Tree )
|
||||||
|
@@ -39,7 +39,6 @@ class AlbumInfoWidget;
|
|||||||
class ArtistInfoWidget;
|
class ArtistInfoWidget;
|
||||||
class ArtistView;
|
class ArtistView;
|
||||||
class CollectionModel;
|
class CollectionModel;
|
||||||
class CollectionFlatModel;
|
|
||||||
class CollectionView;
|
class CollectionView;
|
||||||
class ContextWidget;
|
class ContextWidget;
|
||||||
class PlaylistModel;
|
class PlaylistModel;
|
||||||
|
@@ -1,141 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
|
||||||
*
|
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Tomahawk is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "CollectionFlatModel.h"
|
|
||||||
|
|
||||||
#include "database/Database.h"
|
|
||||||
#include "SourceList.h"
|
|
||||||
#include "PlayableItem.h"
|
|
||||||
#include "utils/Logger.h"
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
|
||||||
|
|
||||||
|
|
||||||
CollectionFlatModel::CollectionFlatModel( QObject* parent )
|
|
||||||
: PlayableModel( parent )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CollectionFlatModel::~CollectionFlatModel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CollectionFlatModel::addCollections( const QList< collection_ptr >& collections )
|
|
||||||
{
|
|
||||||
foreach( const collection_ptr& col, collections )
|
|
||||||
{
|
|
||||||
addCollection( col );
|
|
||||||
}
|
|
||||||
|
|
||||||
// we are waiting for some to load
|
|
||||||
if( !m_loadingCollections.isEmpty() )
|
|
||||||
emit loadingStarted();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CollectionFlatModel::addCollection( const collection_ptr& collection, bool sendNotifications )
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO << collection->name()
|
|
||||||
<< collection->source()->id()
|
|
||||||
<< collection->source()->userName();
|
|
||||||
|
|
||||||
if ( sendNotifications )
|
|
||||||
emit loadingStarted();
|
|
||||||
|
|
||||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( collection );
|
|
||||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
|
|
||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ), Qt::QueuedConnection );
|
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
|
||||||
|
|
||||||
m_loadingCollections << collection.data();
|
|
||||||
|
|
||||||
if ( collection->source()->isLocal() )
|
|
||||||
setTitle( tr( "My Collection" ) );
|
|
||||||
else
|
|
||||||
setTitle( tr( "Collection of %1" ).arg( collection->source()->friendlyName() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CollectionFlatModel::addFilteredCollection( const collection_ptr& collection, unsigned int amount, DatabaseCommand_AllTracks::SortOrder order )
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO << collection->name()
|
|
||||||
<< collection->source()->id()
|
|
||||||
<< collection->source()->userName()
|
|
||||||
<< amount << order;
|
|
||||||
|
|
||||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( collection );
|
|
||||||
cmd->setLimit( amount );
|
|
||||||
cmd->setSortOrder( order );
|
|
||||||
cmd->setSortDescending( true );
|
|
||||||
|
|
||||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
|
|
||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ), Qt::QueuedConnection );
|
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CollectionFlatModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO << tracks.count() << rowCount( QModelIndex() );
|
|
||||||
|
|
||||||
if ( !m_loadingCollections.isEmpty() && sender() && qobject_cast< Collection* >( sender() ) )
|
|
||||||
{
|
|
||||||
// we are keeping track and are called as a slot
|
|
||||||
m_loadingCollections.removeAll( qobject_cast< Collection* >( sender() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
append( tracks );
|
|
||||||
|
|
||||||
if ( m_loadingCollections.isEmpty() )
|
|
||||||
emit loadingFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CollectionFlatModel::onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks )
|
|
||||||
{
|
|
||||||
QList<Tomahawk::query_ptr> t = tracks;
|
|
||||||
for ( int i = rowCount( QModelIndex() ); i >= 0 && t.count(); i-- )
|
|
||||||
{
|
|
||||||
QModelIndex idx = index( i, 0, QModelIndex() );
|
|
||||||
PlayableItem* item = itemFromIndex( idx );
|
|
||||||
if ( !item )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int j = 0;
|
|
||||||
foreach ( const query_ptr& query, t )
|
|
||||||
{
|
|
||||||
if ( item->query().data() == query.data() )
|
|
||||||
{
|
|
||||||
remove( idx );
|
|
||||||
t.removeAt( j );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,72 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
|
||||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
|
||||||
*
|
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Tomahawk is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COLLECTIONFLATMODEL_H
|
|
||||||
#define COLLECTIONFLATMODEL_H
|
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
|
||||||
#include <QList>
|
|
||||||
#include <QHash>
|
|
||||||
|
|
||||||
#include "Typedefs.h"
|
|
||||||
#include "PlayableModel.h"
|
|
||||||
#include "Query.h"
|
|
||||||
#include "Source.h"
|
|
||||||
#include "PlaylistInterface.h"
|
|
||||||
|
|
||||||
#include "database/DatabaseCommand_AllTracks.h"
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
|
||||||
|
|
||||||
class QMetaData;
|
|
||||||
|
|
||||||
class DLLEXPORT CollectionFlatModel : public PlayableModel
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit CollectionFlatModel( QObject* parent = 0 );
|
|
||||||
~CollectionFlatModel();
|
|
||||||
|
|
||||||
virtual int trackCount() const { return rowCount( QModelIndex() ) + m_tracksToAdd.count(); }
|
|
||||||
|
|
||||||
void addCollections( const QList< Tomahawk::collection_ptr >& collections );
|
|
||||||
void addCollection( const Tomahawk::collection_ptr& collection, bool sendNotifications = true );
|
|
||||||
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllTracks::SortOrder order );
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode );
|
|
||||||
void shuffleModeChanged( bool enabled );
|
|
||||||
|
|
||||||
void loadingStarted();
|
|
||||||
void loadingFinished();
|
|
||||||
void trackCountChanged( unsigned int tracks );
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
|
||||||
void onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks );
|
|
||||||
|
|
||||||
private:
|
|
||||||
QMap< Tomahawk::collection_ptr, QPair< int, int > > m_collectionRows;
|
|
||||||
QList<Tomahawk::query_ptr> m_tracksToAdd;
|
|
||||||
// just to keep track of what we are waiting to be loaded
|
|
||||||
QList<Tomahawk::Collection*> m_loadingCollections;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // COLLECTIONFLATMODEL_H
|
|
@@ -23,7 +23,6 @@
|
|||||||
#include "ViewManager.h"
|
#include "ViewManager.h"
|
||||||
|
|
||||||
#include "playlist/AlbumModel.h"
|
#include "playlist/AlbumModel.h"
|
||||||
#include "playlist/CollectionFlatModel.h"
|
|
||||||
#include "playlist/RecentlyAddedModel.h"
|
#include "playlist/RecentlyAddedModel.h"
|
||||||
#include "playlist/RecentlyPlayedModel.h"
|
#include "playlist/RecentlyPlayedModel.h"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user