Skip to content
Snippets Groups Projects

qt/MLVideoModel: don't reset model on media update event

Closed Prince Gupta requested to merge jagannatharjun/vlc:mlvideo-update into master
1 unresolved thread
1 file
+ 37
1
Compare changes
  • Side-by-side
  • Inline
@@ -18,6 +18,11 @@
#include "mlvideomodel.hpp"
namespace
{
const char *VIDEOITEM_UPDATE_QUEUE = "VIDEOITEM_UPDATE_QUEUE";
}
template<typename T>
QVariantList getVariantList(const QList<T> & desc)
{
@@ -147,10 +152,41 @@ void MLVideoModel::onVlcMlEvent(const MLEvent &event)
switch (event.i_type)
{
case VLC_ML_EVENT_MEDIA_ADDED:
case VLC_ML_EVENT_MEDIA_UPDATED:
case VLC_ML_EVENT_MEDIA_DELETED:
m_need_reset = true;
break;
case VLC_ML_EVENT_MEDIA_UPDATED:
{
struct Ctx
{
std::unique_ptr<MLVideo> video {};
};
m_mediaLib->runOnMLThread<Ctx>(this,
[id = event.modification.i_entity_id](vlc_medialibrary_t* ml, Ctx& ctx)
{
ctx.video = std::make_unique<MLVideo>(vlc_ml_get_media(ml, id));
},
[this, id = event.modification.i_entity_id](quint64, Ctx& ctx)
{
if (!ctx.video)
return;
int index {};
auto item = static_cast<MLVideo *>(findInCache(MLItemId {id, VLC_ML_PARENT_UNKNOWN}, &index));
if (!item)
return;
item->swap(*ctx.video);
emit dataChanged(this->index(index), this->index(index), {});
},
VIDEOITEM_UPDATE_QUEUE);
break;
}
default:
break;
}
Loading