mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
TWK-447: Clear albums model before appending to it
This commit is contained in:
parent
def10a2e2b
commit
50d00fc1bf
@ -236,13 +236,14 @@ AlbumModel::removeIndexes( const QList<QModelIndex>& indexes )
|
||||
|
||||
|
||||
void
|
||||
AlbumModel::addCollection( const collection_ptr& collection )
|
||||
AlbumModel::addCollection( const collection_ptr& collection, bool overwrite )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << collection->name()
|
||||
<< collection->source()->id()
|
||||
<< collection->source()->userName();
|
||||
|
||||
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection );
|
||||
cmd->setProperty( "overwrite", overwrite );
|
||||
|
||||
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
|
||||
SLOT( addAlbums( QList<Tomahawk::album_ptr> ) ) );
|
||||
@ -254,7 +255,7 @@ AlbumModel::addCollection( const collection_ptr& collection )
|
||||
|
||||
|
||||
void
|
||||
AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order )
|
||||
AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order, bool overwrite )
|
||||
{
|
||||
/* qDebug() << Q_FUNC_INFO << collection->name()
|
||||
<< collection->source()->id()
|
||||
@ -265,6 +266,7 @@ AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned in
|
||||
cmd->setLimit( amount );
|
||||
cmd->setSortOrder( order );
|
||||
cmd->setSortDescending( true );
|
||||
cmd->setProperty( "overwrite", overwrite );
|
||||
|
||||
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
|
||||
SLOT( addAlbums( QList<Tomahawk::album_ptr> ) ) );
|
||||
@ -284,6 +286,9 @@ AlbumModel::addAlbums( const QList<Tomahawk::album_ptr>& albums )
|
||||
if ( !albums.count() )
|
||||
return;
|
||||
|
||||
if ( sender() && sender()->property( "overwrite" ).toBool() )
|
||||
clear();
|
||||
|
||||
int c = rowCount( QModelIndex() );
|
||||
QPair< int, int > crows;
|
||||
crows.first = c;
|
||||
|
@ -63,8 +63,8 @@ public:
|
||||
virtual QStringList mimeTypes() const;
|
||||
virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
|
||||
|
||||
void addCollection( const Tomahawk::collection_ptr& collection );
|
||||
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order );
|
||||
void addCollection( const Tomahawk::collection_ptr& collection, bool overwrite = false );
|
||||
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order, bool overwrite = false );
|
||||
|
||||
void clear();
|
||||
|
||||
|
@ -86,7 +86,7 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
|
||||
|
||||
m_recentAlbumsModel = new AlbumModel( ui->additionsView );
|
||||
ui->additionsView->setAlbumModel( m_recentAlbumsModel );
|
||||
m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime );
|
||||
m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime, true );
|
||||
|
||||
m_timer = new QTimer( this );
|
||||
connect( m_timer, SIGNAL( timeout() ), SLOT( checkQueries() ) );
|
||||
@ -115,8 +115,7 @@ WelcomeWidget::updateRecentTracks()
|
||||
void
|
||||
WelcomeWidget::updateRecentAdditions()
|
||||
{
|
||||
m_recentAlbumsModel->clear();
|
||||
m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime );
|
||||
m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime, true );
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user