mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-05 16:42:26 +02:00
Rejig the parameters and add QASSERTs. Chris, I decided to take your advice about the asserts -- it will help in the future to make sure people don't mistakenly use the wrong function in new code either.
This commit is contained in:
parent
4a6bc942fa
commit
e2a3c48e6e
@ -41,15 +41,18 @@ AlbumProxyModel::AlbumProxyModel( QObject* parent )
|
||||
setSourceModel( 0 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumProxyModel::setSourceModel( QAbstractItemModel* sourceModel )
|
||||
{
|
||||
AlbumModel* amodel = static_cast< AlbumModel* >( sourceModel );
|
||||
if( !amodel )
|
||||
return;
|
||||
else
|
||||
m_model = amodel;
|
||||
Q_UNUSED( sourceModel );
|
||||
qDebug() << "Explicitly use setSourceAlbumModel instead";
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
|
||||
void
|
||||
AlbumProxyModel::setSourceAlbumModel( AlbumModel* sourceModel )
|
||||
{
|
||||
m_model = sourceModel;
|
||||
|
||||
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
SIGNAL( sourceTrackCountChanged( unsigned int ) ) );
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
explicit AlbumProxyModel( QObject* parent = 0 );
|
||||
|
||||
virtual AlbumModel* sourceModel() const { return m_model; }
|
||||
virtual void setSourceAlbumModel( AlbumModel* sourceModel );
|
||||
virtual void setSourceModel( QAbstractItemModel* sourceModel );
|
||||
|
||||
virtual QList<Tomahawk::query_ptr> tracks() { Q_ASSERT( FALSE ); QList<Tomahawk::query_ptr> queries; return queries; }
|
||||
|
@ -74,16 +74,20 @@ AlbumView::setProxyModel( AlbumProxyModel* model )
|
||||
void
|
||||
AlbumView::setModel( QAbstractItemModel* model )
|
||||
{
|
||||
AlbumModel *amodel = static_cast< AlbumModel* >( model );
|
||||
Q_UNUSED( model );
|
||||
qDebug() << "Explicitly use setAlbumModel instead";
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
|
||||
if ( !amodel )
|
||||
return;
|
||||
else
|
||||
m_model = amodel;
|
||||
|
||||
void
|
||||
AlbumView::setAlbumModel( AlbumModel* model )
|
||||
{
|
||||
m_model = model;
|
||||
|
||||
if ( m_proxyModel )
|
||||
{
|
||||
m_proxyModel->setSourceModel( model );
|
||||
m_proxyModel->setSourceModel( m_model );
|
||||
m_proxyModel->sort( 0 );
|
||||
}
|
||||
|
||||
@ -147,6 +151,7 @@ AlbumView::onFilterChanged( const QString& )
|
||||
void
|
||||
AlbumView::startDrag( Qt::DropActions supportedActions )
|
||||
{
|
||||
Q_UNUSED( supportedActions );
|
||||
}
|
||||
|
||||
|
||||
@ -154,5 +159,6 @@ AlbumView::startDrag( Qt::DropActions supportedActions )
|
||||
QPixmap
|
||||
AlbumView::createDragPixmap( int itemCount ) const
|
||||
{
|
||||
Q_UNUSED( itemCount );
|
||||
return QPixmap();
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
AlbumProxyModel* proxyModel() const { return m_proxyModel; }
|
||||
// PlaylistItemDelegate* delegate() { return m_delegate; }
|
||||
|
||||
void setAlbumModel( AlbumModel* model );
|
||||
void setModel( QAbstractItemModel* model );
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
|
@ -53,14 +53,18 @@ CollectionView::~CollectionView()
|
||||
void
|
||||
CollectionView::setModel( QAbstractItemModel* model )
|
||||
{
|
||||
TrackModel *tmodel = static_cast< TrackModel* >( model );
|
||||
if ( !tmodel )
|
||||
return;
|
||||
qDebug() << "Explicitly use setTrackModel instead";
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
|
||||
TrackView::setModel( tmodel );
|
||||
|
||||
void
|
||||
CollectionView::setTrackModel( TrackModel* model )
|
||||
{
|
||||
TrackView::setModel( model );
|
||||
setGuid( "collectionview" );
|
||||
|
||||
connect( tmodel, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
explicit CollectionView( QWidget* parent = 0 );
|
||||
~CollectionView();
|
||||
|
||||
virtual void setTrackModel( TrackModel* model );
|
||||
virtual void setModel( QAbstractItemModel* model );
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
|
@ -71,13 +71,13 @@ DynamicView::~DynamicView()
|
||||
}
|
||||
|
||||
void
|
||||
DynamicView::setModel( DynamicModel* model)
|
||||
DynamicView::setDynamicModel( DynamicModel* model)
|
||||
{
|
||||
m_model = model;
|
||||
PlaylistView::setModel( model );
|
||||
PlaylistView::setModel( m_model );
|
||||
|
||||
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
connect( model, SIGNAL( checkForOverflow() ), this, SLOT( checkForOverflow() ) );
|
||||
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
connect( m_model, SIGNAL( checkForOverflow() ), this, SLOT( checkForOverflow() ) );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
explicit DynamicView( QWidget* parent = 0 );
|
||||
virtual ~DynamicView();
|
||||
|
||||
virtual void setModel( DynamicModel* model );
|
||||
virtual void setDynamicModel( DynamicModel* model );
|
||||
|
||||
void setOnDemand( bool onDemand );
|
||||
void setReadOnly( bool readOnly );
|
||||
|
@ -47,14 +47,18 @@ PlaylistView::~PlaylistView()
|
||||
void
|
||||
PlaylistView::setModel( QAbstractItemModel* model )
|
||||
{
|
||||
PlaylistModel* pmodel = static_cast< PlaylistModel* >( model );
|
||||
Q_UNUSED( model );
|
||||
qDebug() << "Explicitly use setPlaylistModel instead";
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
|
||||
if ( !pmodel )
|
||||
return;
|
||||
else
|
||||
m_model = pmodel;
|
||||
|
||||
TrackView::setModel( model );
|
||||
void
|
||||
PlaylistView::setPlaylistModel( PlaylistModel* model )
|
||||
{
|
||||
m_model = model;
|
||||
|
||||
TrackView::setModel( m_model );
|
||||
setColumnHidden( 5, true ); // Hide age column per default
|
||||
|
||||
if ( !m_model->playlist().isNull() )
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
~PlaylistView();
|
||||
|
||||
PlaylistModel* playlistModel() const { return m_model; }
|
||||
virtual void setPlaylistModel( PlaylistModel* model );
|
||||
virtual void setModel( QAbstractItemModel* model );
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
|
@ -45,19 +45,23 @@ TrackProxyModel::TrackProxyModel( QObject* parent )
|
||||
|
||||
|
||||
void
|
||||
TrackProxyModel::setSourceModel( QAbstractItemModel* sourceModel )
|
||||
TrackProxyModel::setSourceModel( QAbstractItemModel* model )
|
||||
{
|
||||
TrackModel* tmodel = static_cast< TrackModel* >( sourceModel );
|
||||
Q_UNUSED( model );
|
||||
qDebug() << "Explicitly use setSourceTrackModel instead";
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
|
||||
if ( !tmodel )
|
||||
return;
|
||||
else
|
||||
m_model = tmodel;
|
||||
|
||||
void
|
||||
TrackProxyModel::setSourceTrackModel( TrackModel* sourceModel )
|
||||
{
|
||||
m_model = sourceModel;
|
||||
|
||||
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
SIGNAL( sourceTrackCountChanged( unsigned int ) ) );
|
||||
|
||||
QSortFilterProxyModel::setSourceModel( sourceModel );
|
||||
QSortFilterProxyModel::setSourceModel( m_model );
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,7 +34,8 @@ public:
|
||||
explicit TrackProxyModel ( QObject* parent = 0 );
|
||||
|
||||
virtual TrackModel* sourceModel() const { return m_model; }
|
||||
virtual void setSourceModel( QAbstractItemModel* sourceModel );
|
||||
virtual void setSourceTrackModel( TrackModel* sourceModel );
|
||||
virtual void setSourceModel( QAbstractItemModel* model );
|
||||
|
||||
virtual QPersistentModelIndex currentItem() const { return mapFromSource( m_model->currentItem() ); }
|
||||
virtual void setCurrentItem( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "queueview.h"
|
||||
#include "trackmodel.h"
|
||||
#include "trackproxymodel.h"
|
||||
#include <track.h>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@ -109,16 +110,20 @@ TrackView::setProxyModel( TrackProxyModel* model )
|
||||
void
|
||||
TrackView::setModel( QAbstractItemModel* model )
|
||||
{
|
||||
TrackModel* tmodel = static_cast< TrackModel* >( model );
|
||||
Q_UNUSED( model );
|
||||
qDebug() << "Explicitly use setTrackModel instead";
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
|
||||
if ( !tmodel )
|
||||
return;
|
||||
else
|
||||
m_model = tmodel;
|
||||
|
||||
void
|
||||
TrackView::setTrackModel( TrackModel* model )
|
||||
{
|
||||
m_model = model;
|
||||
|
||||
if ( m_proxyModel )
|
||||
{
|
||||
m_proxyModel->setSourceModel( model );
|
||||
m_proxyModel->setSourceModel( m_model );
|
||||
}
|
||||
|
||||
connect( m_model, SIGNAL( itemSizeChanged( QModelIndex ) ), SLOT( onItemResized( QModelIndex ) ) );
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
virtual QString guid() const { return m_guid; }
|
||||
virtual void setGuid( const QString& guid );
|
||||
|
||||
virtual void setTrackModel( TrackModel* model );
|
||||
virtual void setModel( QAbstractItemModel* model );
|
||||
void setProxyModel( TrackProxyModel* model );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user