X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=app%2Fplaylistwithmetadata.cpp;h=9e2e614b93d95706b96c9d8b6c3ba684245a6940;hb=18a06c173161b77e650c1e3a36ed2381e428ef9f;hp=be6d9a1feb6b5f9e97cb865e9743a0a81fea0cc6;hpb=9daba1c3bc1cb1ae68486a7aa34f734e54748403;p=apps%2Fmediaplayer.git diff --git a/app/playlistwithmetadata.cpp b/app/playlistwithmetadata.cpp index be6d9a1..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); @@ -160,6 +179,8 @@ QVariant PlaylistWithMetadata::data(const QModelIndex &index, int role) const switch (role) { case TitleRole: ret = d->title.value(url); + if (ret.toString().isEmpty()) + ret = QVariant(url.fileName()); break; case ArtistRole: ret = d->artist.value(url);