mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-04 09:11:33 +02:00
qt: partially update model when possible on media deletion/update
This commit is contained in:
parent
65ed60190a
commit
9860b13b1b
@ -63,23 +63,36 @@ void MLAlbumModel::onVlcMlEvent(const MLEvent &event)
|
|||||||
switch( event.i_type )
|
switch( event.i_type )
|
||||||
{
|
{
|
||||||
case VLC_ML_EVENT_ALBUM_ADDED:
|
case VLC_ML_EVENT_ALBUM_ADDED:
|
||||||
|
{
|
||||||
|
emit resetRequested();
|
||||||
|
return;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_ALBUM_DELETED:
|
case VLC_ML_EVENT_ALBUM_DELETED:
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.deletion.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
|
deleteItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_ALBUM_UPDATED:
|
case VLC_ML_EVENT_ALBUM_UPDATED:
|
||||||
m_need_reset = true;
|
{
|
||||||
break;
|
MLItemId itemId(event.modification.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
|
updateItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_ARTIST_DELETED:
|
case VLC_ML_EVENT_ARTIST_DELETED:
|
||||||
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_ARTIST &&
|
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_ARTIST &&
|
||||||
event.deletion.i_entity_id == m_parent.id )
|
event.deletion.i_entity_id == m_parent.id )
|
||||||
m_need_reset = true;
|
emit resetRequested();
|
||||||
break;
|
return;
|
||||||
case VLC_ML_EVENT_GENRE_DELETED:
|
case VLC_ML_EVENT_GENRE_DELETED:
|
||||||
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_GENRE &&
|
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_GENRE &&
|
||||||
event.deletion.i_entity_id == m_parent.id )
|
event.deletion.i_entity_id == m_parent.id )
|
||||||
m_need_reset = true;
|
emit resetRequested();;
|
||||||
break;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
MLBaseModel::onVlcMlEvent( event );
|
MLBaseModel::onVlcMlEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,30 +115,37 @@ void MLAlbumTrackModel::onVlcMlEvent(const MLEvent &event)
|
|||||||
{
|
{
|
||||||
case VLC_ML_EVENT_MEDIA_ADDED:
|
case VLC_ML_EVENT_MEDIA_ADDED:
|
||||||
if ( event.creation.media.i_subtype == VLC_ML_MEDIA_SUBTYPE_ALBUMTRACK )
|
if ( event.creation.media.i_subtype == VLC_ML_MEDIA_SUBTYPE_ALBUMTRACK )
|
||||||
m_need_reset = true;
|
emit resetRequested();
|
||||||
break;
|
return;
|
||||||
case VLC_ML_EVENT_MEDIA_UPDATED:
|
case VLC_ML_EVENT_MEDIA_UPDATED:
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.modification.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
|
updateItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_MEDIA_DELETED:
|
case VLC_ML_EVENT_MEDIA_DELETED:
|
||||||
// FIXME: Not optimal, this will trigger a clean/refresh for video
|
{
|
||||||
// media as well, but this needs fixing in the medialibrary
|
MLItemId itemId(event.deletion.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
m_need_reset = true;
|
deleteItemInCache(itemId);
|
||||||
break;
|
return;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_ALBUM_UPDATED:
|
case VLC_ML_EVENT_ALBUM_UPDATED:
|
||||||
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_ALBUM &&
|
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_ALBUM &&
|
||||||
m_parent.id == event.modification.i_entity_id )
|
m_parent.id == event.modification.i_entity_id )
|
||||||
m_need_reset = true;
|
emit resetRequested();
|
||||||
break;
|
return;
|
||||||
case VLC_ML_EVENT_ALBUM_DELETED:
|
case VLC_ML_EVENT_ALBUM_DELETED:
|
||||||
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_ALBUM &&
|
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_ALBUM &&
|
||||||
m_parent.id == event.deletion.i_entity_id )
|
m_parent.id == event.deletion.i_entity_id )
|
||||||
m_need_reset = true;
|
emit resetRequested();
|
||||||
break;
|
return;
|
||||||
case VLC_ML_EVENT_GENRE_DELETED:
|
case VLC_ML_EVENT_GENRE_DELETED:
|
||||||
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_GENRE &&
|
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_GENRE &&
|
||||||
m_parent.id == event.deletion.i_entity_id )
|
m_parent.id == event.deletion.i_entity_id )
|
||||||
m_need_reset = true;
|
emit resetRequested();
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MLBaseModel::onVlcMlEvent( event );
|
MLBaseModel::onVlcMlEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,16 +89,27 @@ void MLArtistModel::onVlcMlEvent(const MLEvent &event)
|
|||||||
switch (event.i_type)
|
switch (event.i_type)
|
||||||
{
|
{
|
||||||
case VLC_ML_EVENT_ARTIST_ADDED:
|
case VLC_ML_EVENT_ARTIST_ADDED:
|
||||||
|
emit resetRequested();
|
||||||
|
return;
|
||||||
case VLC_ML_EVENT_ARTIST_UPDATED:
|
case VLC_ML_EVENT_ARTIST_UPDATED:
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.deletion.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
|
updateItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_ARTIST_DELETED:
|
case VLC_ML_EVENT_ARTIST_DELETED:
|
||||||
m_need_reset = true;
|
{
|
||||||
break;
|
MLItemId itemId(event.deletion.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
|
deleteItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_GENRE_DELETED:
|
case VLC_ML_EVENT_GENRE_DELETED:
|
||||||
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_GENRE &&
|
if ( m_parent.id != 0 && m_parent.type == VLC_ML_PARENT_GENRE &&
|
||||||
m_parent.id == event.deletion.i_entity_id )
|
m_parent.id == event.deletion.i_entity_id )
|
||||||
m_need_reset = true;
|
emit resetRequested();
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MLBaseModel::onVlcMlEvent(event);
|
MLBaseModel::onVlcMlEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,11 +87,22 @@ void MLGenreModel::onVlcMlEvent(const MLEvent &event)
|
|||||||
switch (event.i_type)
|
switch (event.i_type)
|
||||||
{
|
{
|
||||||
case VLC_ML_EVENT_GENRE_ADDED:
|
case VLC_ML_EVENT_GENRE_ADDED:
|
||||||
|
emit resetRequested();
|
||||||
|
return;
|
||||||
case VLC_ML_EVENT_GENRE_UPDATED:
|
case VLC_ML_EVENT_GENRE_UPDATED:
|
||||||
case VLC_ML_EVENT_GENRE_DELETED:
|
{
|
||||||
m_need_reset = true;
|
MLItemId itemId(event.modification.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
break;
|
updateItemInCache(itemId);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
case VLC_ML_EVENT_GENRE_DELETED:
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.deletion.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
|
deleteItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MLBaseModel::onVlcMlEvent(event);
|
MLBaseModel::onVlcMlEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,20 +351,33 @@ QString MLPlaylistListModel::getCover(MLPlaylist * playlist) const
|
|||||||
|
|
||||||
void MLPlaylistListModel::onVlcMlEvent(const MLEvent & event) /* override */
|
void MLPlaylistListModel::onVlcMlEvent(const MLEvent & event) /* override */
|
||||||
{
|
{
|
||||||
|
if (m_transactionPending
|
||||||
|
&& (event.i_type == VLC_ML_EVENT_PLAYLIST_UPDATED
|
||||||
|
|| event.i_type == VLC_ML_EVENT_PLAYLIST_DELETED
|
||||||
|
|| event.i_type == VLC_ML_EVENT_PLAYLIST_ADDED))
|
||||||
|
{
|
||||||
|
m_resetAfterTransaction = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (event.i_type)
|
switch (event.i_type)
|
||||||
{
|
{
|
||||||
case VLC_ML_EVENT_PLAYLIST_UPDATED:
|
|
||||||
case VLC_ML_EVENT_PLAYLIST_ADDED:
|
|
||||||
case VLC_ML_EVENT_PLAYLIST_DELETED:
|
case VLC_ML_EVENT_PLAYLIST_DELETED:
|
||||||
{
|
{
|
||||||
if(m_transactionPending)
|
MLItemId itemId(event.deletion.i_entity_id, VLC_ML_PARENT_PLAYLIST);
|
||||||
m_resetAfterTransaction = true;
|
deleteItemInCache(itemId);
|
||||||
else
|
return;
|
||||||
{
|
|
||||||
m_need_reset = true;
|
|
||||||
// NOTE: Maybe we should call this from MLBaseModel ?
|
|
||||||
emit resetRequested();
|
|
||||||
}
|
}
|
||||||
|
case VLC_ML_EVENT_PLAYLIST_UPDATED:
|
||||||
|
{
|
||||||
|
|
||||||
|
MLItemId itemId(event.modification.i_entity_id, VLC_ML_PARENT_PLAYLIST);
|
||||||
|
updateItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case VLC_ML_EVENT_PLAYLIST_ADDED:
|
||||||
|
{
|
||||||
|
emit resetRequested();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -420,17 +420,23 @@ void MLPlaylistModel::onVlcMlEvent(const MLEvent & event) /* override */
|
|||||||
{
|
{
|
||||||
switch (event.i_type)
|
switch (event.i_type)
|
||||||
{
|
{
|
||||||
|
case VLC_ML_EVENT_MEDIA_UPDATED:
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.modification.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
|
updateItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_PLAYLIST_UPDATED:
|
case VLC_ML_EVENT_PLAYLIST_UPDATED:
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.modification.i_entity_id, VLC_ML_PARENT_PLAYLIST);
|
||||||
|
if (m_parent == itemId)
|
||||||
{
|
{
|
||||||
if (m_transactionPending)
|
if (m_transactionPending)
|
||||||
m_resetAfterTransaction = true;
|
m_resetAfterTransaction = true;
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_need_reset = true;
|
|
||||||
// NOTE: Maybe we should call this from MLBaseModel ?
|
|
||||||
emit resetRequested();
|
emit resetRequested();
|
||||||
}
|
}
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -80,13 +80,10 @@ void MLRecentsModel::onVlcMlEvent( const MLEvent &event )
|
|||||||
switch ( event.i_type )
|
switch ( event.i_type )
|
||||||
{
|
{
|
||||||
case VLC_ML_EVENT_HISTORY_CHANGED:
|
case VLC_ML_EVENT_HISTORY_CHANGED:
|
||||||
|
{
|
||||||
emit resetRequested();
|
emit resetRequested();
|
||||||
break;
|
return;
|
||||||
case VLC_ML_EVENT_MEDIA_ADDED:
|
}
|
||||||
case VLC_ML_EVENT_MEDIA_UPDATED:
|
|
||||||
case VLC_ML_EVENT_MEDIA_DELETED:
|
|
||||||
m_need_reset = true;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ void MLRecentsVideoModel::onVlcMlEvent(const MLEvent & event) /* override */
|
|||||||
{
|
{
|
||||||
case VLC_ML_EVENT_HISTORY_CHANGED:
|
case VLC_ML_EVENT_HISTORY_CHANGED:
|
||||||
emit resetRequested();
|
emit resetRequested();
|
||||||
break;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,8 @@ void MLUrlModel::onVlcMlEvent(const MLEvent &event)
|
|||||||
{
|
{
|
||||||
case VLC_ML_EVENT_MEDIA_UPDATED:
|
case VLC_ML_EVENT_MEDIA_UPDATED:
|
||||||
case VLC_ML_EVENT_HISTORY_CHANGED:
|
case VLC_ML_EVENT_HISTORY_CHANGED:
|
||||||
m_need_reset = true;
|
emit resetRequested();
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
MLBaseModel::onVlcMlEvent( event );
|
MLBaseModel::onVlcMlEvent( event );
|
||||||
}
|
}
|
||||||
|
@ -135,14 +135,21 @@ void MLVideoFoldersModel::onVlcMlEvent(const MLEvent & event) /* override */
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case VLC_ML_EVENT_FOLDER_ADDED:
|
case VLC_ML_EVENT_FOLDER_ADDED:
|
||||||
|
{
|
||||||
|
emit resetRequested();
|
||||||
|
return;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_FOLDER_UPDATED:
|
case VLC_ML_EVENT_FOLDER_UPDATED:
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.modification.i_entity_id, VLC_ML_PARENT_FOLDER);
|
||||||
|
updateItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_FOLDER_DELETED:
|
case VLC_ML_EVENT_FOLDER_DELETED:
|
||||||
{
|
{
|
||||||
m_need_reset = true;
|
MLItemId itemId(event.deletion.i_entity_id, VLC_ML_PARENT_FOLDER);
|
||||||
|
deleteItemInCache(itemId);
|
||||||
emit resetRequested();
|
return;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -165,14 +165,49 @@ void MLVideoGroupsModel::onVlcMlEvent(const MLEvent & event) /* override */
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case VLC_ML_EVENT_GROUP_ADDED:
|
case VLC_ML_EVENT_GROUP_ADDED:
|
||||||
|
{
|
||||||
|
emit resetRequested();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case VLC_ML_EVENT_MEDIA_ADDED:
|
||||||
|
{
|
||||||
|
if (event.creation.media.i_type == VLC_ML_MEDIA_TYPE_VIDEO)
|
||||||
|
{
|
||||||
|
emit resetRequested();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_GROUP_UPDATED:
|
case VLC_ML_EVENT_GROUP_UPDATED:
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.modification.i_entity_id, VLC_ML_PARENT_GROUP);
|
||||||
|
updateItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case VLC_ML_EVENT_MEDIA_UPDATED:
|
||||||
|
{
|
||||||
|
if (event.creation.media.i_type == VLC_ML_MEDIA_TYPE_VIDEO)
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.modification.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
|
updateItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case VLC_ML_EVENT_GROUP_DELETED:
|
case VLC_ML_EVENT_GROUP_DELETED:
|
||||||
{
|
{
|
||||||
m_need_reset = true;
|
MLItemId itemId(event.deletion.i_entity_id, VLC_ML_PARENT_GROUP);
|
||||||
|
deleteItemInCache(itemId);
|
||||||
// NOTE: Maybe we should call this from MLBaseModel ?
|
return;
|
||||||
emit resetRequested();
|
}
|
||||||
break;
|
case VLC_ML_EVENT_MEDIA_DELETED:
|
||||||
|
{
|
||||||
|
if (event.creation.media.i_type == VLC_ML_MEDIA_TYPE_VIDEO)
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.deletion.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
|
deleteItemInCache(itemId);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -144,13 +144,28 @@ QByteArray MLVideoModel::criteriaToName(vlc_ml_sorting_criteria_t criteria) cons
|
|||||||
|
|
||||||
void MLVideoModel::onVlcMlEvent(const MLEvent &event)
|
void MLVideoModel::onVlcMlEvent(const MLEvent &event)
|
||||||
{
|
{
|
||||||
|
if (event.creation.media.i_type != VLC_ML_MEDIA_TYPE_VIDEO)
|
||||||
|
return MLBaseModel::onVlcMlEvent( event );
|
||||||
|
|
||||||
switch (event.i_type)
|
switch (event.i_type)
|
||||||
{
|
{
|
||||||
case VLC_ML_EVENT_MEDIA_ADDED:
|
case VLC_ML_EVENT_MEDIA_ADDED:
|
||||||
case VLC_ML_EVENT_MEDIA_UPDATED:
|
{
|
||||||
case VLC_ML_EVENT_MEDIA_DELETED:
|
emit resetRequested();
|
||||||
m_need_reset = true;
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case VLC_ML_EVENT_MEDIA_UPDATED:
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.modification.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
|
updateItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case VLC_ML_EVENT_MEDIA_DELETED:
|
||||||
|
{
|
||||||
|
MLItemId itemId(event.deletion.i_entity_id, VLC_ML_PARENT_UNKNOWN);
|
||||||
|
deleteItemInCache(itemId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user