[vlmc-devel] MediaLibrary: Signal that a media was modified
Hugo Beauzée-Luyssen
git at videolan.org
Fri Jul 8 22:56:49 CEST 2016
vlmc | branch: medialibrary | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Jul 8 16:47:12 2016 +0200| [17528211b19234d224a035534303909a1387cad9] | committer: Hugo Beauzée-Luyssen
MediaLibrary: Signal that a media was modified
> https://code.videolan.org/videolan/vlmc/commit/17528211b19234d224a035534303909a1387cad9
---
src/Library/MediaLibrary.cpp | 16 +++++++++++++++-
src/Library/MediaLibraryModel.cpp | 6 ++++++
src/Library/MediaLibraryModel.h | 3 +++
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/Library/MediaLibrary.cpp b/src/Library/MediaLibrary.cpp
index ce8a686..7065f26 100644
--- a/src/Library/MediaLibrary.cpp
+++ b/src/Library/MediaLibrary.cpp
@@ -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> )
diff --git a/src/Library/MediaLibraryModel.cpp b/src/Library/MediaLibraryModel.cpp
index f0f8617..f60d85c 100644
--- a/src/Library/MediaLibraryModel.cpp
+++ b/src/Library/MediaLibraryModel.cpp
@@ -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 )
diff --git a/src/Library/MediaLibraryModel.h b/src/Library/MediaLibraryModel.h
index 12eff3f..00ad4b8 100644
--- a/src/Library/MediaLibraryModel.h
+++ b/src/Library/MediaLibraryModel.h
@@ -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;
More information about the Vlmc-devel
mailing list