medialibrary: Add comprehensive group support
[vlc.git] / modules / gui / qt / medialibrary / mlevent.hpp
blob10bf4a83a353bdda669606ec2f67cd6173bcd54a
1 /*****************************************************************************
2 * Copyright (C) 2019 VLC authors and VideoLAN
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * ( at your option ) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17 *****************************************************************************/
18 #pragma once
20 #include <vlc_media_library.h>
22 /**
23 * Owned (and simplified) version of vlc_ml_event_t, which can be copied and
24 * moved to another thread.
26 struct MLEvent
28 int i_type;
29 union
31 struct
33 int64_t i_entity_id;
34 union {
35 struct {
36 vlc_ml_media_subtype_t i_subtype;
37 } media;
39 } creation;
40 struct
42 int64_t i_entity_id;
43 } modification;
44 struct
46 int64_t i_entity_id;
47 } deletion;
48 struct
50 bool b_idle;
51 } background_idle_changed;
52 struct
54 int64_t i_media_id;
55 bool b_success;
56 } media_thumbnail_generated;
59 explicit MLEvent(const vlc_ml_event_t *event)
61 i_type = event->i_type;
62 switch (event->i_type)
64 case VLC_ML_EVENT_MEDIA_ADDED:
65 creation.i_entity_id = event->creation.p_media->i_id;
66 creation.media.i_subtype = event->creation.p_media->i_subtype;
67 break;
68 case VLC_ML_EVENT_ARTIST_ADDED:
69 creation.i_entity_id = event->creation.p_artist->i_id;
70 break;
71 case VLC_ML_EVENT_ALBUM_ADDED:
72 creation.i_entity_id = event->creation.p_album->i_id;
73 break;
74 case VLC_ML_EVENT_GROUP_ADDED:
75 creation.i_entity_id = event->creation.p_group->i_id;
76 break;
77 case VLC_ML_EVENT_PLAYLIST_ADDED:
78 creation.i_entity_id = event->creation.p_playlist->i_id;
79 break;
80 case VLC_ML_EVENT_GENRE_ADDED:
81 creation.i_entity_id = event->creation.p_genre->i_id;
82 break;
83 case VLC_ML_EVENT_BOOKMARKS_ADDED:
84 creation.i_entity_id = event->creation.p_bookmark->i_media_id;
85 break;
86 case VLC_ML_EVENT_MEDIA_UPDATED:
87 case VLC_ML_EVENT_ARTIST_UPDATED:
88 case VLC_ML_EVENT_ALBUM_UPDATED:
89 case VLC_ML_EVENT_GROUP_UPDATED:
90 case VLC_ML_EVENT_PLAYLIST_UPDATED:
91 case VLC_ML_EVENT_GENRE_UPDATED:
92 case VLC_ML_EVENT_BOOKMARKS_UPDATED:
93 modification.i_entity_id = event->modification.i_entity_id;
94 break;
95 case VLC_ML_EVENT_MEDIA_DELETED:
96 case VLC_ML_EVENT_ARTIST_DELETED:
97 case VLC_ML_EVENT_ALBUM_DELETED:
98 case VLC_ML_EVENT_GROUP_DELETED:
99 case VLC_ML_EVENT_PLAYLIST_DELETED:
100 case VLC_ML_EVENT_GENRE_DELETED:
101 case VLC_ML_EVENT_BOOKMARKS_DELETED:
102 deletion.i_entity_id = event->deletion.i_entity_id;
103 break;
104 case VLC_ML_EVENT_BACKGROUND_IDLE_CHANGED:
105 background_idle_changed.b_idle = event->background_idle_changed.b_idle;
106 break;
107 case VLC_ML_EVENT_MEDIA_THUMBNAIL_GENERATED:
108 media_thumbnail_generated.i_media_id = event->media_thumbnail_generated.p_media->i_id;
109 media_thumbnail_generated.b_success = event->media_thumbnail_generated.b_success;
110 break;