mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Don't depend on sender() as it can be null in queued events
This commit is contained in:
@@ -35,6 +35,7 @@ using namespace Tomahawk;
|
|||||||
AlbumModel::AlbumModel( QObject* parent )
|
AlbumModel::AlbumModel( QObject* parent )
|
||||||
: QAbstractItemModel( parent )
|
: QAbstractItemModel( parent )
|
||||||
, m_rootItem( new AlbumItem( 0, this ) )
|
, m_rootItem( new AlbumItem( 0, this ) )
|
||||||
|
, m_overwriteOnAdd( false )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
@@ -243,7 +244,7 @@ AlbumModel::addCollection( const collection_ptr& collection, bool overwrite )
|
|||||||
<< collection->source()->userName();
|
<< collection->source()->userName();
|
||||||
|
|
||||||
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection );
|
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection );
|
||||||
cmd->setProperty( "overwrite", overwrite );
|
m_overwriteOnAdd = overwrite;
|
||||||
|
|
||||||
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
|
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
|
||||||
SLOT( addAlbums( QList<Tomahawk::album_ptr> ) ) );
|
SLOT( addAlbums( QList<Tomahawk::album_ptr> ) ) );
|
||||||
@@ -266,7 +267,7 @@ AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned in
|
|||||||
cmd->setLimit( amount );
|
cmd->setLimit( amount );
|
||||||
cmd->setSortOrder( order );
|
cmd->setSortOrder( order );
|
||||||
cmd->setSortDescending( true );
|
cmd->setSortDescending( true );
|
||||||
cmd->setProperty( "overwrite", overwrite );
|
m_overwriteOnAdd = overwrite;
|
||||||
|
|
||||||
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
|
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
|
||||||
SLOT( addAlbums( QList<Tomahawk::album_ptr> ) ) );
|
SLOT( addAlbums( QList<Tomahawk::album_ptr> ) ) );
|
||||||
@@ -286,7 +287,7 @@ AlbumModel::addAlbums( const QList<Tomahawk::album_ptr>& albums )
|
|||||||
if ( !albums.count() )
|
if ( !albums.count() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( sender() && sender()->property( "overwrite" ).toBool() )
|
if ( m_overwriteOnAdd )
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
int c = rowCount( QModelIndex() );
|
int c = rowCount( QModelIndex() );
|
||||||
|
@@ -109,6 +109,7 @@ private:
|
|||||||
|
|
||||||
QString m_title;
|
QString m_title;
|
||||||
QString m_description;
|
QString m_description;
|
||||||
|
bool m_overwriteOnAdd;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ALBUMMODEL_H
|
#endif // ALBUMMODEL_H
|
||||||
|
Reference in New Issue
Block a user