Commit afa06228 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

MediaLibrary: Signal that a media was modified

parent bd5989d9
......@@ -100,8 +100,22 @@ void MediaLibrary::onMediaAdded( std::vector<medialibrary::MediaPtr> mediaList )
}
}
void MediaLibrary::onMediaUpdated( std::vector<medialibrary::MediaPtr> )
void MediaLibrary::onMediaUpdated( std::vector<medialibrary::MediaPtr> mediaList )
{
for ( auto m : mediaList )
{
switch ( m->type() )
{
case medialibrary::IMedia::Type::VideoType:
m_videoModel->updateMedia( m );
break;
case medialibrary::IMedia::Type::AudioType:
m_audioModel->updateMedia( m );
break;
default:
Q_UNREACHABLE();
}
}
}
void MediaLibrary::onMediaDeleted( std::vector<int64_t> )
......
......@@ -65,6 +65,12 @@ void MediaLibraryModel::addMedia( medialibrary::MediaPtr media )
endInsertRows();
}
void MediaLibraryModel::updateMedia( medialibrary::MediaPtr media )
{
auto m = createIndex( media->id(), 0 );
emit dataChanged( m, m );
}
void MediaLibraryModel::removeMedia( medialibrary::MediaPtr media )
{
if ( media->type() != m_mediaType )
......
......@@ -33,6 +33,8 @@
class MediaLibraryModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Roles
{
......@@ -45,6 +47,7 @@ public:
QObject *parent = 0 );
void addMedia( medialibrary::MediaPtr media );
void updateMedia( medialibrary::MediaPtr media );
void removeMedia( medialibrary::MediaPtr media );
int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment