Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
VLMC
Commits
8a464972
Commit
8a464972
authored
Jul 08, 2016
by
Hugo Beauzée-Luyssen
Browse files
MediaLibrary: Propagate media deletion to the model
parent
afa06228
Changes
3
Show whitespace changes
Inline
Side-by-side
src/Library/MediaLibrary.cpp
View file @
8a464972
...
...
@@ -118,8 +118,16 @@ void MediaLibrary::onMediaUpdated( std::vector<medialibrary::MediaPtr> mediaList
}
}
void
MediaLibrary
::
onMediaDeleted
(
std
::
vector
<
int64_t
>
)
void
MediaLibrary
::
onMediaDeleted
(
std
::
vector
<
int64_t
>
mediaList
)
{
for
(
auto
id
:
mediaList
)
{
// We can't know the media type, however ID are unique regardless of the type
// so we are sure that we will remove the correct media.
if
(
m_videoModel
->
removeMedia
(
id
)
==
true
)
continue
;
m_audioModel
->
removeMedia
(
id
);
}
}
void
MediaLibrary
::
onArtistsAdded
(
std
::
vector
<
medialibrary
::
ArtistPtr
>
)
...
...
src/Library/MediaLibraryModel.cpp
View file @
8a464972
...
...
@@ -71,22 +71,21 @@ void MediaLibraryModel::updateMedia( medialibrary::MediaPtr media )
emit
dataChanged
(
m
,
m
);
}
void
MediaLibraryModel
::
removeMedia
(
medialibrary
::
MediaPtr
media
)
bool
MediaLibraryModel
::
removeMedia
(
int64_t
media
Id
)
{
if
(
media
->
type
()
!=
m_mediaType
)
return
;
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mediaMutex
);
auto
it
=
std
::
find_if
(
begin
(
m_media
),
end
(
m_media
),
[
media
](
medialibrary
::
MediaPtr
m
)
{
return
m
->
id
()
==
media
->
id
()
;
auto
it
=
std
::
find_if
(
begin
(
m_media
),
end
(
m_media
),
[
media
Id
](
medialibrary
::
MediaPtr
m
)
{
return
m
->
id
()
==
media
Id
;
});
if
(
it
==
end
(
m_media
)
)
return
;
return
false
;
auto
idx
=
it
-
begin
(
m_media
);
beginRemoveRows
(
QModelIndex
(),
idx
,
idx
);
m_media
.
erase
(
it
);
m_rowCount
.
fetch_sub
(
1
,
std
::
memory_order_relaxed
);
removeRow
(
idx
);
endRemoveRows
();
return
true
;
}
int
MediaLibraryModel
::
rowCount
(
const
QModelIndex
&
)
const
...
...
src/Library/MediaLibraryModel.h
View file @
8a464972
...
...
@@ -48,7 +48,7 @@ public:
void
addMedia
(
medialibrary
::
MediaPtr
media
);
void
updateMedia
(
medialibrary
::
MediaPtr
media
);
void
removeMedia
(
medialibrary
::
MediaPtr
media
);
bool
removeMedia
(
int64_t
media
);
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
()
)
const
override
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
override
;
QHash
<
int
,
QByteArray
>
roleNames
()
const
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment