summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-05-27 21:27:18 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-05-29 21:21:34 -0700
commit535f2d051f965e9ee4a9c1eed13a8d0e997463e8 (patch)
treea727ac71334c24387a0d7d035061d6158d1b9293 /app
parent583a1da88bfc703bad7568d182a99cf4ead8b65b (diff)
playlistwithmediadata: allow removal of elements
Currently removing elements from the playlist doesn't actually remove them. This patchset removes them from the underlaying model. Change-Id: Idf52f05b25bb236e91633e3e1e6e84b5b7f77665 Bug-AGL: SPEC-630 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'app')
-rw-r--r--app/playlistwithmetadata.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/playlistwithmetadata.cpp b/app/playlistwithmetadata.cpp
index 28bd0b2..9e2e614 100644
--- a/app/playlistwithmetadata.cpp
+++ b/app/playlistwithmetadata.cpp
@@ -78,6 +78,25 @@ void PlaylistWithMetadata::Private::connect()
q->endInsertRows();
}));
+ connections.append(q->connect(source, &QAbstractListModel::rowsAboutToBeRemoved, [&](const QModelIndex &parent, int first, int last) {
+ Q_UNUSED(parent)
+ q->beginRemoveRows(QModelIndex(), first, last);
+ }));
+ connections.append(q->connect(source, &QAbstractListModel::rowsRemoved, [&](const QModelIndex &parent, int first, int last) {
+ Q_UNUSED(parent)
+ for (int i = last; i >= first; --i) {
+ QUrl url = urls.at(i);
+ urls.removeAt(i);
+
+ players.remove(url);
+ title.remove(url);
+ artist.remove(url);
+ coverArt.remove(url);
+ duration.remove(url);
+ }
+ q->endRemoveRows();
+ }));
+
int count = source->rowCount();
if (count > 0) {
q->beginInsertRows(QModelIndex(), 0, count);