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