Playlist: Rename some variables
This commit is contained in:
@@ -1304,11 +1304,11 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const {
|
|||||||
rows << idx.row();
|
rows << idx.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
QBuffer buf;
|
QBuffer buffer;
|
||||||
if (!buf.open(QIODevice::WriteOnly)) {
|
if (!buffer.open(QIODevice::WriteOnly)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
QDataStream stream(&buf);
|
QDataStream stream(&buffer);
|
||||||
|
|
||||||
const Playlist *self = this;
|
const Playlist *self = this;
|
||||||
const qint64 pid = QCoreApplication::applicationPid();
|
const qint64 pid = QCoreApplication::applicationPid();
|
||||||
@@ -1316,11 +1316,11 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const {
|
|||||||
stream.writeRawData(reinterpret_cast<char*>(&self), sizeof(self)); // NOLINT(bugprone-sizeof-expression)
|
stream.writeRawData(reinterpret_cast<char*>(&self), sizeof(self)); // NOLINT(bugprone-sizeof-expression)
|
||||||
stream << rows;
|
stream << rows;
|
||||||
stream.writeRawData(reinterpret_cast<const char*>(&pid), sizeof(pid));
|
stream.writeRawData(reinterpret_cast<const char*>(&pid), sizeof(pid));
|
||||||
buf.close();
|
buffer.close();
|
||||||
|
|
||||||
QMimeData *mimedata = new QMimeData;
|
QMimeData *mimedata = new QMimeData;
|
||||||
mimedata->setUrls(urls);
|
mimedata->setUrls(urls);
|
||||||
mimedata->setData(QLatin1String(kRowsMimetype), buf.data());
|
mimedata->setData(QLatin1String(kRowsMimetype), buffer.data());
|
||||||
|
|
||||||
return mimedata;
|
return mimedata;
|
||||||
|
|
||||||
@@ -1607,21 +1607,21 @@ void Playlist::ItemsLoaded() {
|
|||||||
InsertItems(items, 0);
|
InsertItems(items, 0);
|
||||||
is_loading_ = false;
|
is_loading_ = false;
|
||||||
|
|
||||||
PlaylistBackend::Playlist p = playlist_backend_->GetPlaylist(id_);
|
const PlaylistBackend::Playlist playlist = playlist_backend_->GetPlaylist(id_);
|
||||||
|
|
||||||
// The newly loaded list of items might be shorter than it was before so look out for a bad last_played index
|
// The newly loaded list of items might be shorter than it was before so look out for a bad last_played index
|
||||||
last_played_item_index_ = p.last_played == -1 || p.last_played >= rowCount() ? QModelIndex() : index(p.last_played);
|
last_played_item_index_ = playlist.last_played == -1 || playlist.last_played >= rowCount() ? QModelIndex() : index(playlist.last_played);
|
||||||
|
|
||||||
if (p.dynamic_type == PlaylistGenerator::Type::Query) {
|
if (playlist.dynamic_type == PlaylistGenerator::Type::Query) {
|
||||||
PlaylistGeneratorPtr gen = PlaylistGenerator::Create(p.dynamic_type);
|
PlaylistGeneratorPtr gen = PlaylistGenerator::Create(playlist.dynamic_type);
|
||||||
if (gen) {
|
if (gen) {
|
||||||
|
|
||||||
SharedPtr<CollectionBackend> backend = nullptr;
|
SharedPtr<CollectionBackend> backend = nullptr;
|
||||||
if (p.dynamic_backend == collection_backend_->songs_table()) backend = collection_backend_;
|
if (playlist.dynamic_backend == collection_backend_->songs_table()) backend = collection_backend_;
|
||||||
|
|
||||||
if (backend) {
|
if (backend) {
|
||||||
gen->set_collection_backend(collection_backend_);
|
gen->set_collection_backend(collection_backend_);
|
||||||
gen->Load(p.dynamic_data);
|
gen->Load(playlist.dynamic_data);
|
||||||
TurnOnDynamicPlaylist(gen);
|
TurnOnDynamicPlaylist(gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1725,11 +1725,11 @@ PlaylistItemPtrList Playlist::RemoveItemsWithoutUndo(const int row, const int co
|
|||||||
|
|
||||||
// Remove items
|
// Remove items
|
||||||
beginRemoveRows(QModelIndex(), row, row + count - 1);
|
beginRemoveRows(QModelIndex(), row, row + count - 1);
|
||||||
PlaylistItemPtrList ret;
|
PlaylistItemPtrList items;
|
||||||
ret.reserve(count);
|
items.reserve(count);
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
PlaylistItemPtr item(items_.takeAt(row));
|
PlaylistItemPtr item(items_.takeAt(row));
|
||||||
ret << item;
|
items << item;
|
||||||
|
|
||||||
if (item->source() == Song::Source::Collection) {
|
if (item->source() == Song::Source::Collection) {
|
||||||
int id = item->Metadata().id();
|
int id = item->Metadata().id();
|
||||||
@@ -1769,7 +1769,7 @@ PlaylistItemPtrList Playlist::RemoveItemsWithoutUndo(const int row, const int co
|
|||||||
|
|
||||||
ScheduleSave();
|
ScheduleSave();
|
||||||
|
|
||||||
return ret;
|
return items;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2053,12 +2053,12 @@ PlaylistFilter *Playlist::filter() const { return filter_; }
|
|||||||
|
|
||||||
SongList Playlist::GetAllSongs() const {
|
SongList Playlist::GetAllSongs() const {
|
||||||
|
|
||||||
SongList ret;
|
SongList songs;
|
||||||
ret.reserve(items_.count());
|
songs.reserve(items_.count());
|
||||||
for (PlaylistItemPtr item : items_) { // clazy:exclude=range-loop-reference
|
for (PlaylistItemPtr item : items_) { // clazy:exclude=range-loop-reference
|
||||||
ret << item->Metadata();
|
songs << item->Metadata();
|
||||||
}
|
}
|
||||||
return ret;
|
return songs;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2066,12 +2066,13 @@ PlaylistItemPtrList Playlist::GetAllItems() const { return items_; }
|
|||||||
|
|
||||||
quint64 Playlist::GetTotalLength() const {
|
quint64 Playlist::GetTotalLength() const {
|
||||||
|
|
||||||
quint64 ret = 0;
|
quint64 total_length = 0;
|
||||||
for (PlaylistItemPtr item : items_) { // clazy:exclude=range-loop-reference
|
for (PlaylistItemPtr item : items_) { // clazy:exclude=range-loop-reference
|
||||||
qint64 length = item->Metadata().length_nanosec();
|
qint64 length = item->Metadata().length_nanosec();
|
||||||
if (length > 0) ret += length;
|
if (length > 0) total_length += length;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
|
return total_length;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user