Use C++11 enum class
This commit is contained in:
@@ -171,7 +171,7 @@ Playlist::~Playlist() {
|
||||
template<typename T>
|
||||
void Playlist::InsertSongItems(const SongList &songs, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
PlaylistItemList items;
|
||||
PlaylistItemPtrList items;
|
||||
items.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
items << std::make_shared<T>(song);
|
||||
@@ -315,7 +315,7 @@ QVariant Playlist::data(const QModelIndex &idx, int role) const {
|
||||
case Column_Filename: return song.effective_stream_url();
|
||||
case Column_BaseFilename: return song.basefilename();
|
||||
case Column_Filesize: return song.filesize();
|
||||
case Column_Filetype: return song.filetype();
|
||||
case Column_Filetype: return QVariant::fromValue(song.filetype());
|
||||
case Column_DateModified: return song.mtime();
|
||||
case Column_DateCreated: return song.ctime();
|
||||
|
||||
@@ -323,7 +323,7 @@ QVariant Playlist::data(const QModelIndex &idx, int role) const {
|
||||
if (role == Qt::DisplayRole) return song.comment().simplified();
|
||||
return song.comment();
|
||||
|
||||
case Column_Source: return song.source();
|
||||
case Column_Source: return QVariant::fromValue(song.source());
|
||||
|
||||
case Column_Rating: return song.rating();
|
||||
|
||||
@@ -451,7 +451,7 @@ void Playlist::ItemReloadComplete(const QPersistentModelIndex &idx, const Song &
|
||||
old_metadata.albumartist() == item->Metadata().albumartist() &&
|
||||
old_metadata.artist() == item->Metadata().artist() &&
|
||||
old_metadata.album() == item->Metadata().album();
|
||||
InformOfCurrentSongChange(AutoScroll_Never, minor);
|
||||
InformOfCurrentSongChange(AutoScroll::Never, minor);
|
||||
}
|
||||
else {
|
||||
emit dataChanged(index(idx.row(), 0), index(idx.row(), ColumnCount - 1));
|
||||
@@ -478,7 +478,7 @@ int Playlist::last_played_row() const {
|
||||
}
|
||||
|
||||
void Playlist::ShuffleModeChanged(const PlaylistSequence::ShuffleMode mode) {
|
||||
is_shuffled_ = (mode != PlaylistSequence::Shuffle_Off);
|
||||
is_shuffled_ = (mode != PlaylistSequence::ShuffleMode::Off);
|
||||
ReshuffleIndices();
|
||||
}
|
||||
|
||||
@@ -492,10 +492,10 @@ int Playlist::NextVirtualIndex(int i, const bool ignore_repeat_track) const {
|
||||
|
||||
PlaylistSequence::RepeatMode repeat_mode = playlist_sequence_->repeat_mode();
|
||||
PlaylistSequence::ShuffleMode shuffle_mode = playlist_sequence_->shuffle_mode();
|
||||
bool album_only = repeat_mode == PlaylistSequence::Repeat_Album || shuffle_mode == PlaylistSequence::Shuffle_InsideAlbum;
|
||||
bool album_only = repeat_mode == PlaylistSequence::RepeatMode::Album || shuffle_mode == PlaylistSequence::ShuffleMode::InsideAlbum;
|
||||
|
||||
// This one's easy - if we have to repeat the current track then just return i
|
||||
if (repeat_mode == PlaylistSequence::Repeat_Track && !ignore_repeat_track) {
|
||||
if (repeat_mode == PlaylistSequence::RepeatMode::Track && !ignore_repeat_track) {
|
||||
if (!FilterContainsVirtualIndex(i)) {
|
||||
return static_cast<int>(virtual_items_.count()); // It's not in the filter any more
|
||||
}
|
||||
@@ -537,10 +537,10 @@ int Playlist::PreviousVirtualIndex(int i, const bool ignore_repeat_track) const
|
||||
|
||||
PlaylistSequence::RepeatMode repeat_mode = playlist_sequence_->repeat_mode();
|
||||
PlaylistSequence::ShuffleMode shuffle_mode = playlist_sequence_->shuffle_mode();
|
||||
bool album_only = repeat_mode == PlaylistSequence::Repeat_Album || shuffle_mode == PlaylistSequence::Shuffle_InsideAlbum;
|
||||
bool album_only = repeat_mode == PlaylistSequence::RepeatMode::Album || shuffle_mode == PlaylistSequence::ShuffleMode::InsideAlbum;
|
||||
|
||||
// This one's easy - if we have to repeat the current track then just return i
|
||||
if (repeat_mode == PlaylistSequence::Repeat_Track && !ignore_repeat_track) {
|
||||
if (repeat_mode == PlaylistSequence::RepeatMode::Track && !ignore_repeat_track) {
|
||||
if (!FilterContainsVirtualIndex(i)) return -1;
|
||||
return i;
|
||||
}
|
||||
@@ -583,10 +583,10 @@ int Playlist::next_row(const bool ignore_repeat_track) const {
|
||||
// We've gone off the end of the playlist.
|
||||
|
||||
switch (playlist_sequence_->repeat_mode()) {
|
||||
case PlaylistSequence::Repeat_Off:
|
||||
case PlaylistSequence::Repeat_Intro:
|
||||
case PlaylistSequence::RepeatMode::Off:
|
||||
case PlaylistSequence::RepeatMode::Intro:
|
||||
return -1;
|
||||
case PlaylistSequence::Repeat_Track:
|
||||
case PlaylistSequence::RepeatMode::Track:
|
||||
next_virtual_index = current_virtual_index_;
|
||||
break;
|
||||
|
||||
@@ -611,9 +611,9 @@ int Playlist::previous_row(const bool ignore_repeat_track) const {
|
||||
// We've gone off the beginning of the playlist.
|
||||
|
||||
switch (playlist_sequence_->repeat_mode()) {
|
||||
case PlaylistSequence::Repeat_Off:
|
||||
case PlaylistSequence::RepeatMode::Off:
|
||||
return -1;
|
||||
case PlaylistSequence::Repeat_Track:
|
||||
case PlaylistSequence::RepeatMode::Track:
|
||||
prev_virtual_index = current_virtual_index_;
|
||||
break;
|
||||
|
||||
@@ -823,7 +823,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
|
||||
}
|
||||
else if (pid == own_pid) {
|
||||
// Drag from a different playlist
|
||||
PlaylistItemList items;
|
||||
PlaylistItemPtrList items;
|
||||
items.reserve(source_rows.count());
|
||||
for (const int i : source_rows) items << source_playlist->item_at(i);
|
||||
|
||||
@@ -888,7 +888,7 @@ void Playlist::InsertSmartPlaylist(PlaylistGeneratorPtr generator, const int pos
|
||||
void Playlist::TurnOnDynamicPlaylist(PlaylistGeneratorPtr gen) {
|
||||
|
||||
dynamic_playlist_ = gen;
|
||||
ShuffleModeChanged(PlaylistSequence::Shuffle_Off);
|
||||
ShuffleModeChanged(PlaylistSequence::ShuffleMode::Off);
|
||||
emit DynamicModeChanged(true);
|
||||
|
||||
ScheduleSave();
|
||||
@@ -902,7 +902,7 @@ void Playlist::MoveItemWithoutUndo(const int source, const int dest) {
|
||||
void Playlist::MoveItemsWithoutUndo(const QList<int> &source_rows, int pos) {
|
||||
|
||||
emit layoutAboutToBeChanged();
|
||||
PlaylistItemList moved_items;
|
||||
PlaylistItemPtrList moved_items;
|
||||
moved_items.reserve(source_rows.count());
|
||||
|
||||
if (pos < 0) {
|
||||
@@ -955,7 +955,7 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int> &dest_rows) {
|
||||
|
||||
emit layoutAboutToBeChanged();
|
||||
|
||||
PlaylistItemList moved_items;
|
||||
PlaylistItemPtrList moved_items;
|
||||
moved_items.reserve(dest_rows.count());
|
||||
|
||||
int pos = start;
|
||||
@@ -1007,13 +1007,13 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int> &dest_rows) {
|
||||
|
||||
}
|
||||
|
||||
void Playlist::InsertItems(const PlaylistItemList &itemsIn, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
void Playlist::InsertItems(const PlaylistItemPtrList &itemsIn, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
if (itemsIn.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlaylistItemList items = itemsIn;
|
||||
PlaylistItemPtrList items = itemsIn;
|
||||
|
||||
// Exercise vetoes
|
||||
SongList songs;
|
||||
@@ -1064,11 +1064,11 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, const int pos, const
|
||||
undo_stack_->push(new PlaylistUndoCommands::InsertItems(this, items, pos, enqueue, enqueue_next));
|
||||
}
|
||||
|
||||
if (play_now) emit PlayRequested(index(start, 0), AutoScroll_Maybe);
|
||||
if (play_now) emit PlayRequested(index(start, 0), AutoScroll::Maybe);
|
||||
|
||||
}
|
||||
|
||||
void Playlist::InsertItemsWithoutUndo(const PlaylistItemList &items, const int pos, const bool enqueue, const bool enqueue_next) {
|
||||
void Playlist::InsertItemsWithoutUndo(const PlaylistItemPtrList &items, const int pos, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
if (items.isEmpty()) return;
|
||||
|
||||
@@ -1081,7 +1081,7 @@ void Playlist::InsertItemsWithoutUndo(const PlaylistItemList &items, const int p
|
||||
items_.insert(i, item);
|
||||
virtual_items_ << static_cast<int>(virtual_items_.count());
|
||||
|
||||
if (item->source() == Song::Source_Collection) {
|
||||
if (item->source() == Song::Source::Collection) {
|
||||
int id = item->Metadata().id();
|
||||
if (id != -1) {
|
||||
collection_items_by_id_.insert(id, item);
|
||||
@@ -1133,7 +1133,7 @@ void Playlist::InsertSongs(const SongList &songs, const int pos, const bool play
|
||||
|
||||
void Playlist::InsertSongsOrCollectionItems(const SongList &songs, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
PlaylistItemList items;
|
||||
PlaylistItemPtrList items;
|
||||
for (const Song &song : songs) {
|
||||
if (song.url().isLocalFile()) {
|
||||
if (song.is_collection_song()) {
|
||||
@@ -1158,7 +1158,7 @@ void Playlist::InsertSongsOrCollectionItems(const SongList &songs, const int pos
|
||||
|
||||
void Playlist::InsertInternetItems(InternetService *service, const SongList &songs, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
PlaylistItemList playlist_items;
|
||||
PlaylistItemPtrList playlist_items;
|
||||
playlist_items.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
playlist_items << std::make_shared<InternetPlaylistItem>(service, song);
|
||||
@@ -1170,7 +1170,7 @@ void Playlist::InsertInternetItems(InternetService *service, const SongList &son
|
||||
|
||||
void Playlist::InsertRadioItems(const SongList &songs, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
PlaylistItemList playlist_items;
|
||||
PlaylistItemPtrList playlist_items;
|
||||
playlist_items.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
playlist_items << std::make_shared<RadioPlaylistItem>(song);
|
||||
@@ -1196,7 +1196,7 @@ void Playlist::UpdateItems(SongList songs) {
|
||||
while (it.hasNext()) {
|
||||
const Song &song = it.next();
|
||||
const PlaylistItemPtr &item = items_[i];
|
||||
if (item->Metadata().url() == song.url() && (item->Metadata().filetype() == Song::FileType_Unknown || item->Metadata().filetype() == Song::FileType_Stream || item->Metadata().filetype() == Song::FileType_CDDA || !item->Metadata().init_from_file())) {
|
||||
if (item->Metadata().url() == song.url() && (item->Metadata().filetype() == Song::FileType::Unknown || item->Metadata().filetype() == Song::FileType::Stream || item->Metadata().filetype() == Song::FileType::CDDA || !item->Metadata().init_from_file())) {
|
||||
PlaylistItemPtr new_item;
|
||||
if (song.url().isLocalFile()) {
|
||||
if (song.is_collection_song()) {
|
||||
@@ -1414,8 +1414,8 @@ void Playlist::sort(int column, Qt::SortOrder order) {
|
||||
|
||||
if (ignore_sorting_) return;
|
||||
|
||||
PlaylistItemList new_items(items_);
|
||||
PlaylistItemList::iterator begin = new_items.begin();
|
||||
PlaylistItemPtrList new_items(items_);
|
||||
PlaylistItemPtrList::iterator begin = new_items.begin();
|
||||
|
||||
if (dynamic_playlist_ && current_item_index_.isValid())
|
||||
begin += current_item_index_.row() + 1;
|
||||
@@ -1441,11 +1441,11 @@ void Playlist::sort(int column, Qt::SortOrder order) {
|
||||
|
||||
}
|
||||
|
||||
void Playlist::ReOrderWithoutUndo(const PlaylistItemList &new_items) {
|
||||
void Playlist::ReOrderWithoutUndo(const PlaylistItemPtrList &new_items) {
|
||||
|
||||
emit layoutAboutToBeChanged();
|
||||
|
||||
PlaylistItemList old_items = items_;
|
||||
PlaylistItemPtrList old_items = items_;
|
||||
items_ = new_items;
|
||||
|
||||
QHash<const PlaylistItem*, int> new_rows;
|
||||
@@ -1521,20 +1521,20 @@ void Playlist::Restore() {
|
||||
|
||||
cancel_restore_ = false;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QFuture<PlaylistItemList> future = QtConcurrent::run(&PlaylistBackend::GetPlaylistItems, backend_, id_);
|
||||
QFuture<PlaylistItemPtrList> future = QtConcurrent::run(&PlaylistBackend::GetPlaylistItems, backend_, id_);
|
||||
#else
|
||||
QFuture<PlaylistItemList> future = QtConcurrent::run(backend_, &PlaylistBackend::GetPlaylistItems, id_);
|
||||
QFuture<PlaylistItemPtrList> future = QtConcurrent::run(backend_, &PlaylistBackend::GetPlaylistItems, id_);
|
||||
#endif
|
||||
QFutureWatcher<PlaylistItemList> *watcher = new QFutureWatcher<PlaylistItemList>();
|
||||
QObject::connect(watcher, &QFutureWatcher<PlaylistItemList>::finished, this, &Playlist::ItemsLoaded);
|
||||
QFutureWatcher<PlaylistItemPtrList> *watcher = new QFutureWatcher<PlaylistItemPtrList>();
|
||||
QObject::connect(watcher, &QFutureWatcher<PlaylistItemPtrList>::finished, this, &Playlist::ItemsLoaded);
|
||||
watcher->setFuture(future);
|
||||
|
||||
}
|
||||
|
||||
void Playlist::ItemsLoaded() {
|
||||
|
||||
QFutureWatcher<PlaylistItemList> *watcher = static_cast<QFutureWatcher<PlaylistItemList>*>(sender());
|
||||
PlaylistItemList items = watcher->result();
|
||||
QFutureWatcher<PlaylistItemPtrList> *watcher = static_cast<QFutureWatcher<PlaylistItemPtrList>*>(sender());
|
||||
PlaylistItemPtrList items = watcher->result();
|
||||
watcher->deleteLater();
|
||||
|
||||
if (cancel_restore_) return;
|
||||
@@ -1558,7 +1558,7 @@ void Playlist::ItemsLoaded() {
|
||||
// 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);
|
||||
|
||||
if (p.dynamic_type == PlaylistGenerator::Type_Query) {
|
||||
if (p.dynamic_type == PlaylistGenerator::Type::Query) {
|
||||
PlaylistGeneratorPtr gen = PlaylistGenerator::Create(p.dynamic_type);
|
||||
if (gen) {
|
||||
|
||||
@@ -1667,21 +1667,21 @@ bool Playlist::removeRows(QList<int> &rows) {
|
||||
|
||||
}
|
||||
|
||||
PlaylistItemList Playlist::RemoveItemsWithoutUndo(const int row, const int count) {
|
||||
PlaylistItemPtrList Playlist::RemoveItemsWithoutUndo(const int row, const int count) {
|
||||
|
||||
if (row < 0 || row >= items_.size() || row + count > items_.size()) {
|
||||
return PlaylistItemList();
|
||||
return PlaylistItemPtrList();
|
||||
}
|
||||
beginRemoveRows(QModelIndex(), row, row + count - 1);
|
||||
|
||||
// Remove items
|
||||
PlaylistItemList ret;
|
||||
PlaylistItemPtrList ret;
|
||||
ret.reserve(count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
PlaylistItemPtr item(items_.takeAt(row));
|
||||
ret << item;
|
||||
|
||||
if (item->source() == Song::Source_Collection) {
|
||||
if (item->source() == Song::Source::Collection) {
|
||||
int id = item->Metadata().id();
|
||||
if (id != -1 && collection_items_by_id_.contains(id, item)) {
|
||||
collection_items_by_id_.remove(id, item);
|
||||
@@ -1747,7 +1747,7 @@ void Playlist::SetStreamMetadata(const QUrl &url, const Song &song, const bool m
|
||||
bool update_scrobble_point = song.length_nanosec() != current_item_metadata().length_nanosec();
|
||||
current_item()->SetTemporaryMetadata(song);
|
||||
if (update_scrobble_point) UpdateScrobblePoint();
|
||||
InformOfCurrentSongChange(AutoScroll_Never, minor);
|
||||
InformOfCurrentSongChange(AutoScroll::Never, minor);
|
||||
|
||||
}
|
||||
|
||||
@@ -1765,7 +1765,7 @@ void Playlist::ClearStreamMetadata() {
|
||||
bool Playlist::stop_after_current() const {
|
||||
|
||||
PlaylistSequence::RepeatMode repeat_mode = playlist_sequence_->repeat_mode();
|
||||
if (repeat_mode == PlaylistSequence::Repeat_OneByOne) {
|
||||
if (repeat_mode == PlaylistSequence::RepeatMode::OneByOne) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1785,7 +1785,7 @@ PlaylistItemPtr Playlist::current_item() const {
|
||||
}
|
||||
|
||||
PlaylistItem::Options Playlist::current_item_options() const {
|
||||
if (!current_item()) return PlaylistItem::Default;
|
||||
if (!current_item()) return PlaylistItem::Option::Default;
|
||||
return current_item()->options();
|
||||
}
|
||||
|
||||
@@ -1903,7 +1903,7 @@ void Playlist::SongInsertVetoListenerDestroyed() {
|
||||
|
||||
void Playlist::Shuffle() {
|
||||
|
||||
PlaylistItemList new_items(items_);
|
||||
PlaylistItemPtrList new_items(items_);
|
||||
|
||||
int begin = 0;
|
||||
if (current_item_index_.isValid()) {
|
||||
@@ -1948,7 +1948,7 @@ void Playlist::ReshuffleIndices() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (playlist_sequence_->shuffle_mode() == PlaylistSequence::Shuffle_Off) {
|
||||
if (playlist_sequence_->shuffle_mode() == PlaylistSequence::ShuffleMode::Off) {
|
||||
// No shuffling - sort the virtual item list normally.
|
||||
std::sort(virtual_items_.begin(), virtual_items_.end());
|
||||
if (current_row() != -1) {
|
||||
@@ -1968,16 +1968,16 @@ void Playlist::ReshuffleIndices() {
|
||||
std::mt19937 g(rd());
|
||||
|
||||
switch (playlist_sequence_->shuffle_mode()) {
|
||||
case PlaylistSequence::Shuffle_Off:
|
||||
case PlaylistSequence::ShuffleMode::Off:
|
||||
// Handled above.
|
||||
break;
|
||||
|
||||
case PlaylistSequence::Shuffle_All:
|
||||
case PlaylistSequence::Shuffle_InsideAlbum:
|
||||
case PlaylistSequence::ShuffleMode::All:
|
||||
case PlaylistSequence::ShuffleMode::InsideAlbum:
|
||||
std::shuffle(begin, end, g);
|
||||
break;
|
||||
|
||||
case PlaylistSequence::Shuffle_Albums: {
|
||||
case PlaylistSequence::ShuffleMode::Albums: {
|
||||
QMap<int, QString> album_keys; // real index -> key
|
||||
QSet<QString> album_key_set; // unique keys
|
||||
|
||||
@@ -2040,7 +2040,7 @@ SongList Playlist::GetAllSongs() const {
|
||||
|
||||
}
|
||||
|
||||
PlaylistItemList Playlist::GetAllItems() const { return items_; }
|
||||
PlaylistItemPtrList Playlist::GetAllItems() const { return items_; }
|
||||
|
||||
quint64 Playlist::GetTotalLength() const {
|
||||
|
||||
@@ -2053,7 +2053,7 @@ quint64 Playlist::GetTotalLength() const {
|
||||
|
||||
}
|
||||
|
||||
PlaylistItemList Playlist::collection_items_by_id(const int id) const {
|
||||
PlaylistItemPtrList Playlist::collection_items_by_id(const int id) const {
|
||||
return collection_items_by_id_.values(id);
|
||||
}
|
||||
|
||||
@@ -2258,7 +2258,7 @@ bool Playlist::ApplyValidityOnCurrentSong(const QUrl &url, const bool valid) {
|
||||
Song current_song = current->Metadata();
|
||||
|
||||
// If validity has changed, reload the item
|
||||
if (current_song.source() == Song::Source_LocalFile || current_song.source() == Song::Source_Collection) {
|
||||
if (current_song.source() == Song::Source::LocalFile || current_song.source() == Song::Source::Collection) {
|
||||
if (current_song.url() == url && current_song.url().isLocalFile() && current_song.is_valid() != QFile::exists(current_song.url().toLocalFile())) {
|
||||
ReloadItems(QList<int>() << current_row());
|
||||
}
|
||||
@@ -2319,7 +2319,7 @@ void Playlist::UpdateScrobblePoint(const qint64 seek_point_nanosec) {
|
||||
void Playlist::AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result) {
|
||||
|
||||
// Update art_manual for local songs that are not in the collection.
|
||||
if (((result.type == AlbumCoverLoaderResult::Type_Manual && result.album_cover.cover_url.isLocalFile()) || result.type == AlbumCoverLoaderResult::Type_ManuallyUnset) && (song.source() == Song::Source_LocalFile || song.source() == Song::Source_CDDA || song.source() == Song::Source_Device)) {
|
||||
if (((result.type == AlbumCoverLoaderResult::Type_Manual && result.album_cover.cover_url.isLocalFile()) || result.type == AlbumCoverLoaderResult::Type_ManuallyUnset) && (song.source() == Song::Source::LocalFile || song.source() == Song::Source::CDDA || song.source() == Song::Source::Device)) {
|
||||
PlaylistItemPtr item = current_item();
|
||||
if (item && item->Metadata() == song && (!item->Metadata().art_manual_is_valid() || (result.type == AlbumCoverLoaderResult::Type_ManuallyUnset && !item->Metadata().has_manually_unset_cover()))) {
|
||||
qLog(Debug) << "Updating art manual for local song" << song.title() << song.album() << song.title() << "to" << result.album_cover.cover_url << "in playlist.";
|
||||
|
||||
@@ -142,10 +142,10 @@ class Playlist : public QAbstractListModel {
|
||||
Role_CanSetRating,
|
||||
};
|
||||
|
||||
enum AutoScroll {
|
||||
AutoScroll_Never,
|
||||
AutoScroll_Maybe,
|
||||
AutoScroll_Always
|
||||
enum class AutoScroll {
|
||||
Never,
|
||||
Maybe,
|
||||
Always
|
||||
};
|
||||
|
||||
static const char *kCddaMimeType;
|
||||
@@ -211,10 +211,10 @@ class Playlist : public QAbstractListModel {
|
||||
PlaylistItem::Options current_item_options() const;
|
||||
Song current_item_metadata() const;
|
||||
|
||||
PlaylistItemList collection_items_by_id(const int id) const;
|
||||
PlaylistItemPtrList collection_items_by_id(const int id) const;
|
||||
|
||||
SongList GetAllSongs() const;
|
||||
PlaylistItemList GetAllItems() const;
|
||||
PlaylistItemPtrList GetAllItems() const;
|
||||
quint64 GetTotalLength() const; // in seconds
|
||||
|
||||
void set_sequence(PlaylistSequence *v);
|
||||
@@ -229,7 +229,7 @@ class Playlist : public QAbstractListModel {
|
||||
void UpdateScrobblePoint(const qint64 seek_point_nanosec = 0);
|
||||
|
||||
// Changing the playlist
|
||||
void InsertItems(const PlaylistItemList &itemsIn, const int pos = -1, const bool play_now = false, const bool enqueue = false, const bool enqueue_next = false);
|
||||
void InsertItems(const PlaylistItemPtrList &itemsIn, const int pos = -1, const bool play_now = false, const bool enqueue = false, const bool enqueue_next = false);
|
||||
void InsertCollectionItems(const SongList &songs, const int pos = -1, const bool play_now = false, const bool enqueue = false, const bool enqueue_next = false);
|
||||
void InsertSongs(const SongList &songs, const int pos = -1, const bool play_now = false, const bool enqueue = false, const bool enqueue_next = false);
|
||||
void InsertSongsOrCollectionItems(const SongList &songs, const int pos = -1, const bool play_now = false, const bool enqueue = false, const bool enqueue_next = false);
|
||||
@@ -293,7 +293,7 @@ class Playlist : public QAbstractListModel {
|
||||
void ItemReload(const QPersistentModelIndex &idx, const Song &old_metadata, const bool metadata_edit);
|
||||
|
||||
public slots:
|
||||
void set_current_row(const int i, const Playlist::AutoScroll autoscroll = Playlist::AutoScroll_Maybe, const bool is_stopping = false, const bool force_inform = false);
|
||||
void set_current_row(const int i, const Playlist::AutoScroll autoscroll = Playlist::AutoScroll::Maybe, const bool is_stopping = false, const bool force_inform = false);
|
||||
void Paused();
|
||||
void Playing();
|
||||
void Stopped();
|
||||
@@ -350,12 +350,12 @@ class Playlist : public QAbstractListModel {
|
||||
void InsertSongItems(const SongList &songs, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next = false);
|
||||
|
||||
// Modify the playlist without changing the undo stack. These are used by our friends in PlaylistUndoCommands
|
||||
void InsertItemsWithoutUndo(const PlaylistItemList &items, int pos, bool enqueue = false, bool enqueue_next = false);
|
||||
PlaylistItemList RemoveItemsWithoutUndo(const int row, const int count);
|
||||
void InsertItemsWithoutUndo(const PlaylistItemPtrList &items, int pos, bool enqueue = false, bool enqueue_next = false);
|
||||
PlaylistItemPtrList RemoveItemsWithoutUndo(const int row, const int count);
|
||||
void MoveItemsWithoutUndo(const QList<int> &source_rows, int pos);
|
||||
void MoveItemWithoutUndo(const int source, const int dest);
|
||||
void MoveItemsWithoutUndo(int start, const QList<int> &dest_rows);
|
||||
void ReOrderWithoutUndo(const PlaylistItemList &new_items);
|
||||
void ReOrderWithoutUndo(const PlaylistItemPtrList &new_items);
|
||||
|
||||
void RemoveItemsNotInQueue();
|
||||
|
||||
@@ -392,7 +392,7 @@ class Playlist : public QAbstractListModel {
|
||||
QString ui_path_;
|
||||
bool favorite_;
|
||||
|
||||
PlaylistItemList items_;
|
||||
PlaylistItemPtrList items_;
|
||||
|
||||
// Contains the indices into items_ in the order that they will be played.
|
||||
QList<int> virtual_items_;
|
||||
|
||||
@@ -86,15 +86,15 @@ void PlaylistBackend::Exit() {
|
||||
}
|
||||
|
||||
PlaylistBackend::PlaylistList PlaylistBackend::GetAllPlaylists() {
|
||||
return GetPlaylists(GetPlaylists_All);
|
||||
return GetPlaylists(GetPlaylistsFlags::GetPlaylists_All);
|
||||
}
|
||||
|
||||
PlaylistBackend::PlaylistList PlaylistBackend::GetAllOpenPlaylists() {
|
||||
return GetPlaylists(GetPlaylists_OpenInUi);
|
||||
return GetPlaylists(GetPlaylistsFlags::GetPlaylists_OpenInUi);
|
||||
}
|
||||
|
||||
PlaylistBackend::PlaylistList PlaylistBackend::GetAllFavoritePlaylists() {
|
||||
return GetPlaylists(GetPlaylists_Favorite);
|
||||
return GetPlaylists(GetPlaylistsFlags::GetPlaylists_Favorite);
|
||||
}
|
||||
|
||||
PlaylistBackend::PlaylistList PlaylistBackend::GetPlaylists(const GetPlaylistsFlags flags) {
|
||||
@@ -105,10 +105,10 @@ PlaylistBackend::PlaylistList PlaylistBackend::GetPlaylists(const GetPlaylistsFl
|
||||
PlaylistList ret;
|
||||
|
||||
QStringList condition_list;
|
||||
if (flags & GetPlaylists_OpenInUi) {
|
||||
if (flags & GetPlaylistsFlags::GetPlaylists_OpenInUi) {
|
||||
condition_list << "ui_order != -1";
|
||||
}
|
||||
if (flags & GetPlaylists_Favorite) {
|
||||
if (flags & GetPlaylistsFlags::GetPlaylists_Favorite) {
|
||||
condition_list << "is_favorite != 0";
|
||||
}
|
||||
QString condition;
|
||||
@@ -172,9 +172,9 @@ PlaylistBackend::Playlist PlaylistBackend::GetPlaylist(const int id) {
|
||||
|
||||
}
|
||||
|
||||
PlaylistItemList PlaylistBackend::GetPlaylistItems(const int playlist) {
|
||||
PlaylistItemPtrList PlaylistBackend::GetPlaylistItems(const int playlist) {
|
||||
|
||||
PlaylistItemList playlistitems;
|
||||
PlaylistItemPtrList playlistitems;
|
||||
|
||||
{
|
||||
|
||||
@@ -189,7 +189,7 @@ PlaylistItemList PlaylistBackend::GetPlaylistItems(const int playlist) {
|
||||
q.BindValue(":playlist", playlist);
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return PlaylistItemList();
|
||||
return PlaylistItemPtrList();
|
||||
}
|
||||
|
||||
// it's probable that we'll have a few songs associated with the same CUE, so we're caching results of parsing CUEs
|
||||
@@ -270,7 +270,7 @@ Song PlaylistBackend::NewSongFromQuery(const SqlRow &row, std::shared_ptr<NewSon
|
||||
PlaylistItemPtr PlaylistBackend::RestoreCueData(PlaylistItemPtr item, std::shared_ptr<NewSongFromQueryState> state) {
|
||||
|
||||
// We need collection to run a CueParser; also, this method applies only to file-type PlaylistItems
|
||||
if (item->source() != Song::Source_LocalFile) return item;
|
||||
if (item->source() != Song::Source::LocalFile) return item;
|
||||
|
||||
CueParser cue_parser(app_->collection_backend());
|
||||
|
||||
@@ -316,13 +316,13 @@ PlaylistItemPtr PlaylistBackend::RestoreCueData(PlaylistItemPtr item, std::share
|
||||
|
||||
}
|
||||
|
||||
void PlaylistBackend::SavePlaylistAsync(int playlist, const PlaylistItemList &items, int last_played, PlaylistGeneratorPtr dynamic) {
|
||||
void PlaylistBackend::SavePlaylistAsync(int playlist, const PlaylistItemPtrList &items, int last_played, PlaylistGeneratorPtr dynamic) {
|
||||
|
||||
QMetaObject::invokeMethod(this, "SavePlaylist", Qt::QueuedConnection, Q_ARG(int, playlist), Q_ARG(PlaylistItemList, items), Q_ARG(int, last_played), Q_ARG(PlaylistGeneratorPtr, dynamic));
|
||||
QMetaObject::invokeMethod(this, "SavePlaylist", Qt::QueuedConnection, Q_ARG(int, playlist), Q_ARG(PlaylistItemPtrList, items), Q_ARG(int, last_played), Q_ARG(PlaylistGeneratorPtr, dynamic));
|
||||
|
||||
}
|
||||
|
||||
void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList &items, int last_played, PlaylistGeneratorPtr dynamic) {
|
||||
void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemPtrList &items, int last_played, PlaylistGeneratorPtr dynamic) {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
@@ -361,7 +361,7 @@ void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList &items,
|
||||
q.prepare("UPDATE playlists SET last_played=:last_played, dynamic_playlist_type=:dynamic_type, dynamic_playlist_data=:dynamic_data, dynamic_playlist_backend=:dynamic_backend WHERE ROWID=:playlist");
|
||||
q.BindValue(":last_played", last_played);
|
||||
if (dynamic) {
|
||||
q.BindValue(":dynamic_type", dynamic->type());
|
||||
q.BindValue(":dynamic_type", static_cast<int>(dynamic->type()));
|
||||
q.BindValue(":dynamic_data", dynamic->Save());
|
||||
q.BindValue(":dynamic_backend", dynamic->collection()->songs_table());
|
||||
}
|
||||
|
||||
@@ -75,14 +75,14 @@ class PlaylistBackend : public QObject {
|
||||
PlaylistList GetAllFavoritePlaylists();
|
||||
PlaylistBackend::Playlist GetPlaylist(const int id);
|
||||
|
||||
PlaylistItemList GetPlaylistItems(const int playlist);
|
||||
PlaylistItemPtrList GetPlaylistItems(const int playlist);
|
||||
SongList GetPlaylistSongs(const int playlist);
|
||||
|
||||
void SetPlaylistOrder(const QList<int> &ids);
|
||||
void SetPlaylistUiPath(const int id, const QString &path);
|
||||
|
||||
int CreatePlaylist(const QString &name, const QString &special_type);
|
||||
void SavePlaylistAsync(const int playlist, const PlaylistItemList &items, const int last_played, PlaylistGeneratorPtr dynamic);
|
||||
void SavePlaylistAsync(const int playlist, const PlaylistItemPtrList &items, const int last_played, PlaylistGeneratorPtr dynamic);
|
||||
void RenamePlaylist(const int id, const QString &new_name);
|
||||
void FavoritePlaylist(const int id, bool is_favorite);
|
||||
void RemovePlaylist(const int id);
|
||||
@@ -91,7 +91,7 @@ class PlaylistBackend : public QObject {
|
||||
|
||||
public slots:
|
||||
void Exit();
|
||||
void SavePlaylist(const int playlist, const PlaylistItemList &items, const int last_played, PlaylistGeneratorPtr dynamic);
|
||||
void SavePlaylist(const int playlist, const PlaylistItemPtrList &items, const int last_played, PlaylistGeneratorPtr dynamic);
|
||||
|
||||
signals:
|
||||
void ExitFinished();
|
||||
|
||||
@@ -339,7 +339,7 @@ void PlaylistContainer::NewPlaylist() { manager_->New(tr("Playlist")); }
|
||||
void PlaylistContainer::LoadPlaylist() {
|
||||
|
||||
QString filename = settings_.value("last_load_playlist").toString();
|
||||
filename = QFileDialog::getOpenFileName(this, tr("Load playlist"), filename, manager_->parser()->filters(PlaylistParser::Type_Load));
|
||||
filename = QFileDialog::getOpenFileName(this, tr("Load playlist"), filename, manager_->parser()->filters(PlaylistParser::Type::Load));
|
||||
|
||||
if (filename.isNull()) return;
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ class FilterTerm : public FilterTree {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
FilterType type() override { return Term; }
|
||||
FilterType type() override { return FilterType::Term; }
|
||||
private:
|
||||
QScopedPointer<SearchTermComparator> cmp_;
|
||||
QList<int> columns_;
|
||||
@@ -213,7 +213,7 @@ class FilterColumnTerm : public FilterTree {
|
||||
QModelIndex idx(model->index(row, col, parent));
|
||||
return cmp_->Matches(idx.data().toString().toLower());
|
||||
}
|
||||
FilterType type() override { return Column; }
|
||||
FilterType type() override { return FilterType::Column; }
|
||||
private:
|
||||
int col;
|
||||
QScopedPointer<SearchTermComparator> cmp_;
|
||||
@@ -226,7 +226,7 @@ class NotFilter : public FilterTree {
|
||||
bool accept(int row, const QModelIndex &parent, const QAbstractItemModel *const model) const override {
|
||||
return !child_->accept(row, parent, model);
|
||||
}
|
||||
FilterType type() override { return Not; }
|
||||
FilterType type() override { return FilterType::Not; }
|
||||
private:
|
||||
QScopedPointer<const FilterTree> child_;
|
||||
};
|
||||
@@ -238,7 +238,7 @@ class OrFilter : public FilterTree {
|
||||
bool accept(int row, const QModelIndex &parent, const QAbstractItemModel *const model) const override {
|
||||
return std::any_of(children_.begin(), children_.end(), [row, parent, model](FilterTree *child) { return child->accept(row, parent, model); });
|
||||
}
|
||||
FilterType type() override { return Or; }
|
||||
FilterType type() override { return FilterType::Or; }
|
||||
private:
|
||||
QList<FilterTree*> children_;
|
||||
};
|
||||
@@ -250,7 +250,7 @@ class AndFilter : public FilterTree {
|
||||
bool accept(int row, const QModelIndex &parent, const QAbstractItemModel *const model) const override {
|
||||
return !std::any_of(children_.begin(), children_.end(), [row, parent, model](FilterTree *child) { return !child->accept(row, parent, model); });
|
||||
}
|
||||
FilterType type() override { return And; }
|
||||
FilterType type() override { return FilterType::And; }
|
||||
private:
|
||||
QList<FilterTree*> children_;
|
||||
};
|
||||
@@ -385,7 +385,7 @@ FilterTree *FilterParser::parseSearchExpression() {
|
||||
else if (*iter_ == '-') {
|
||||
++iter_;
|
||||
FilterTree *tree = parseSearchExpression();
|
||||
if (tree->type() != FilterTree::Nop) return new NotFilter(tree);
|
||||
if (tree->type() != FilterTree::FilterType::Nop) return new NotFilter(tree);
|
||||
return tree;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -36,7 +36,7 @@ class FilterTree {
|
||||
FilterTree() = default;
|
||||
virtual ~FilterTree() {}
|
||||
virtual bool accept(int row, const QModelIndex &parent, const QAbstractItemModel *const model) const = 0;
|
||||
enum FilterType {
|
||||
enum class FilterType {
|
||||
Nop = 0,
|
||||
Or,
|
||||
And,
|
||||
@@ -53,7 +53,7 @@ class FilterTree {
|
||||
class NopFilter : public FilterTree {
|
||||
public:
|
||||
bool accept(int row, const QModelIndex &parent, const QAbstractItemModel *const model) const override { Q_UNUSED(row); Q_UNUSED(parent); Q_UNUSED(model); return true; }
|
||||
FilterType type() override { return Nop; }
|
||||
FilterType type() override { return FilterType::Nop; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -41,20 +41,20 @@
|
||||
PlaylistItemPtr PlaylistItem::NewFromSource(const Song::Source source) {
|
||||
|
||||
switch (source) {
|
||||
case Song::Source_Collection:
|
||||
case Song::Source::Collection:
|
||||
return std::make_shared<CollectionPlaylistItem>();
|
||||
case Song::Source_Subsonic:
|
||||
case Song::Source_Tidal:
|
||||
case Song::Source_Qobuz:
|
||||
case Song::Source::Subsonic:
|
||||
case Song::Source::Tidal:
|
||||
case Song::Source::Qobuz:
|
||||
return std::make_shared<InternetPlaylistItem>(source);
|
||||
case Song::Source_Stream:
|
||||
case Song::Source_RadioParadise:
|
||||
case Song::Source_SomaFM:
|
||||
case Song::Source::Stream:
|
||||
case Song::Source::RadioParadise:
|
||||
case Song::Source::SomaFM:
|
||||
return std::make_shared<RadioPlaylistItem>(source);
|
||||
case Song::Source_LocalFile:
|
||||
case Song::Source_CDDA:
|
||||
case Song::Source_Device:
|
||||
case Song::Source_Unknown:
|
||||
case Song::Source::LocalFile:
|
||||
case Song::Source::CDDA:
|
||||
case Song::Source::Device:
|
||||
case Song::Source::Unknown:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -65,20 +65,20 @@ PlaylistItemPtr PlaylistItem::NewFromSource(const Song::Source source) {
|
||||
PlaylistItemPtr PlaylistItem::NewFromSong(const Song &song) {
|
||||
|
||||
switch (song.source()) {
|
||||
case Song::Source_Collection:
|
||||
case Song::Source::Collection:
|
||||
return std::make_shared<CollectionPlaylistItem>(song);
|
||||
case Song::Source_Subsonic:
|
||||
case Song::Source_Tidal:
|
||||
case Song::Source_Qobuz:
|
||||
case Song::Source::Subsonic:
|
||||
case Song::Source::Tidal:
|
||||
case Song::Source::Qobuz:
|
||||
return std::make_shared<InternetPlaylistItem>(song);
|
||||
case Song::Source_Stream:
|
||||
case Song::Source_RadioParadise:
|
||||
case Song::Source_SomaFM:
|
||||
case Song::Source::Stream:
|
||||
case Song::Source::RadioParadise:
|
||||
case Song::Source::SomaFM:
|
||||
return std::make_shared<RadioPlaylistItem>(song);
|
||||
case Song::Source_LocalFile:
|
||||
case Song::Source_CDDA:
|
||||
case Song::Source_Device:
|
||||
case Song::Source_Unknown:
|
||||
case Song::Source::LocalFile:
|
||||
case Song::Source::CDDA:
|
||||
case Song::Source::Device:
|
||||
case Song::Source::Unknown:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ PlaylistItem::~PlaylistItem() = default;
|
||||
|
||||
void PlaylistItem::BindToQuery(SqlQuery *query) const {
|
||||
|
||||
query->BindValue(":type", source_);
|
||||
query->BindValue(":type", static_cast<int>(source_));
|
||||
query->BindValue(":collection_id", DatabaseValue(Column_CollectionId));
|
||||
|
||||
DatabaseSongMetadata().BindToQuery(query);
|
||||
|
||||
@@ -51,7 +51,7 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
||||
static std::shared_ptr<PlaylistItem> NewFromSource(const Song::Source source);
|
||||
static std::shared_ptr<PlaylistItem> NewFromSong(const Song &song);
|
||||
|
||||
enum Option {
|
||||
enum class Option {
|
||||
Default = 0x00,
|
||||
|
||||
// Disables the "pause" action.
|
||||
@@ -64,7 +64,7 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
||||
|
||||
virtual Song::Source source() const { return source_; }
|
||||
|
||||
virtual Options options() const { return Default; }
|
||||
virtual Options options() const { return Option::Default; }
|
||||
|
||||
virtual QList<QAction*> actions() { return QList<QAction*>(); }
|
||||
|
||||
@@ -132,10 +132,10 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
||||
Q_DISABLE_COPY(PlaylistItem)
|
||||
};
|
||||
using PlaylistItemPtr = std::shared_ptr<PlaylistItem>;
|
||||
using PlaylistItemList = QList<PlaylistItemPtr>;
|
||||
using PlaylistItemPtrList = QList<PlaylistItemPtr>;
|
||||
|
||||
Q_DECLARE_METATYPE(PlaylistItemPtr)
|
||||
Q_DECLARE_METATYPE(PlaylistItemList)
|
||||
Q_DECLARE_METATYPE(PlaylistItemPtrList)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::Options)
|
||||
|
||||
#endif // PLAYLISTITEM_H
|
||||
|
||||
@@ -32,10 +32,10 @@ class PlaylistItemMimeData : public MimeData {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlaylistItemMimeData(const PlaylistItemPtr &item, QObject* = nullptr) : MimeData(), items_(PlaylistItemList() << item) {}
|
||||
explicit PlaylistItemMimeData(const PlaylistItemList &items, QObject* = nullptr) : MimeData(), items_(items) {}
|
||||
explicit PlaylistItemMimeData(const PlaylistItemPtr &item, QObject* = nullptr) : MimeData(), items_(PlaylistItemPtrList() << item) {}
|
||||
explicit PlaylistItemMimeData(const PlaylistItemPtrList &items, QObject* = nullptr) : MimeData(), items_(items) {}
|
||||
|
||||
PlaylistItemList items_;
|
||||
PlaylistItemPtrList items_;
|
||||
};
|
||||
|
||||
#endif // PLAYLISTITEMMIMEDATA_H
|
||||
|
||||
@@ -252,18 +252,18 @@ void PlaylistManager::SaveWithUI(const int id, const QString &playlist_name) {
|
||||
|
||||
QFileInfo fileinfo;
|
||||
forever {
|
||||
filename = QFileDialog::getSaveFileName(nullptr, tr("Save playlist", "Title of the playlist save dialog."), filename, parser()->filters(PlaylistParser::Type_Save), &last_save_filter);
|
||||
filename = QFileDialog::getSaveFileName(nullptr, tr("Save playlist", "Title of the playlist save dialog."), filename, parser()->filters(PlaylistParser::Type::Save), &last_save_filter);
|
||||
if (filename.isEmpty()) return;
|
||||
fileinfo.setFile(filename);
|
||||
ParserBase *parser = parser_->ParserForExtension(PlaylistParser::Type_Save, fileinfo.suffix());
|
||||
ParserBase *parser = parser_->ParserForExtension(PlaylistParser::Type::Save, fileinfo.suffix());
|
||||
if (parser) break;
|
||||
QMessageBox::warning(nullptr, tr("Unknown playlist extension"), tr("Unknown file extension for playlist."));
|
||||
}
|
||||
|
||||
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
|
||||
PlaylistSettingsPage::PathType path_type = static_cast<PlaylistSettingsPage::PathType>(s.value("path_type", PlaylistSettingsPage::PathType_Automatic).toInt());
|
||||
PlaylistSettingsPage::PathType path_type = static_cast<PlaylistSettingsPage::PathType>(s.value("path_type", static_cast<int>(PlaylistSettingsPage::PathType::Automatic)).toInt());
|
||||
s.endGroup();
|
||||
if (path_type == PlaylistSettingsPage::PathType_Ask_User) {
|
||||
if (path_type == PlaylistSettingsPage::PathType::Ask_User) {
|
||||
PlaylistSaveOptionsDialog optionsdialog;
|
||||
optionsdialog.setModal(true);
|
||||
if (optionsdialog.exec() != QDialog::Accepted) return;
|
||||
@@ -470,7 +470,7 @@ void PlaylistManager::SongsDiscovered(const SongList &songs) {
|
||||
|
||||
for (const Song &song : songs) {
|
||||
for (const Data &data : std::as_const(playlists_)) {
|
||||
PlaylistItemList items = data.p->collection_items_by_id(song.id());
|
||||
PlaylistItemPtrList items = data.p->collection_items_by_id(song.id());
|
||||
for (PlaylistItemPtr item : items) {
|
||||
if (item->Metadata().directory_id() != song.directory_id()) continue;
|
||||
item->SetMetadata(song);
|
||||
@@ -624,7 +624,7 @@ void PlaylistManager::RateCurrentSong2(const int rating) {
|
||||
|
||||
void PlaylistManager::SaveAllPlaylists() {
|
||||
|
||||
SavePlaylistsDialog dialog(parser()->file_extensions(PlaylistParser::Type_Save), parser()->default_extension());
|
||||
SavePlaylistsDialog dialog(parser()->file_extensions(PlaylistParser::Type::Save), parser()->default_extension());
|
||||
if (dialog.exec() != QDialog::Accepted) {
|
||||
return;
|
||||
}
|
||||
@@ -637,9 +637,9 @@ void PlaylistManager::SaveAllPlaylists() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
|
||||
PlaylistSettingsPage::PathType path_type = static_cast<PlaylistSettingsPage::PathType>(s.value("path_type", PlaylistSettingsPage::PathType_Automatic).toInt());
|
||||
PlaylistSettingsPage::PathType path_type = static_cast<PlaylistSettingsPage::PathType>(s.value("path_type", static_cast<int>(PlaylistSettingsPage::PathType::Automatic)).toInt());
|
||||
s.endGroup();
|
||||
if (path_type == PlaylistSettingsPage::PathType_Ask_User) {
|
||||
if (path_type == PlaylistSettingsPage::PathType::Ask_User) {
|
||||
PlaylistSaveOptionsDialog optionsdialog;
|
||||
optionsdialog.setModal(true);
|
||||
if (optionsdialog.exec() != QDialog::Accepted) return;
|
||||
|
||||
@@ -37,9 +37,9 @@ PlaylistSaveOptionsDialog::PlaylistSaveOptionsDialog(QWidget *parent) : QDialog(
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->filePaths->addItem(tr("Automatic"), PlaylistSettingsPage::PathType_Automatic);
|
||||
ui->filePaths->addItem(tr("Relative"), PlaylistSettingsPage::PathType_Relative);
|
||||
ui->filePaths->addItem(tr("Absolute"), PlaylistSettingsPage::PathType_Absolute);
|
||||
ui->filePaths->addItem(tr("Automatic"), QVariant::fromValue(PlaylistSettingsPage::PathType::Automatic));
|
||||
ui->filePaths->addItem(tr("Relative"), QVariant::fromValue(PlaylistSettingsPage::PathType::Relative));
|
||||
ui->filePaths->addItem(tr("Absolute"), QVariant::fromValue(PlaylistSettingsPage::PathType::Absolute));
|
||||
|
||||
}
|
||||
|
||||
@@ -59,5 +59,5 @@ void PlaylistSaveOptionsDialog::accept() {
|
||||
}
|
||||
|
||||
PlaylistSettingsPage::PathType PlaylistSaveOptionsDialog::path_type() const {
|
||||
return static_cast<PlaylistSettingsPage::PathType>(ui->filePaths->itemData(ui->filePaths->currentIndex()).toInt());
|
||||
return ui->filePaths->itemData(ui->filePaths->currentIndex()).value<PlaylistSettingsPage::PathType>();
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ PlaylistSequence::PlaylistSequence(QWidget *parent, SettingsProvider *settings)
|
||||
repeat_menu_(new QMenu(this)),
|
||||
shuffle_menu_(new QMenu(this)),
|
||||
loading_(false),
|
||||
repeat_mode_(Repeat_Off),
|
||||
shuffle_mode_(Shuffle_Off),
|
||||
repeat_mode_(RepeatMode::Off),
|
||||
shuffle_mode_(ShuffleMode::Off),
|
||||
dynamic_(false) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
@@ -94,8 +94,8 @@ PlaylistSequence::~PlaylistSequence() {
|
||||
void PlaylistSequence::Load() {
|
||||
|
||||
loading_ = true; // Stops these setter functions calling Save()
|
||||
SetShuffleMode(ShuffleMode(settings_->value("shuffle_mode", Shuffle_Off).toInt()));
|
||||
SetRepeatMode(RepeatMode(settings_->value("repeat_mode", Repeat_Off).toInt()));
|
||||
SetShuffleMode(static_cast<ShuffleMode>(settings_->value("shuffle_mode", static_cast<int>(ShuffleMode::Off)).toInt()));
|
||||
SetRepeatMode(static_cast<RepeatMode>(settings_->value("repeat_mode", static_cast<int>(RepeatMode::Off)).toInt()));
|
||||
loading_ = false;
|
||||
|
||||
}
|
||||
@@ -104,8 +104,8 @@ void PlaylistSequence::Save() {
|
||||
|
||||
if (loading_) return;
|
||||
|
||||
settings_->setValue("shuffle_mode", shuffle_mode_);
|
||||
settings_->setValue("repeat_mode", repeat_mode_);
|
||||
settings_->setValue("shuffle_mode", static_cast<int>(shuffle_mode_));
|
||||
settings_->setValue("repeat_mode", static_cast<int>(repeat_mode_));
|
||||
|
||||
}
|
||||
|
||||
@@ -139,12 +139,12 @@ QPixmap PlaylistSequence::DesaturatedPixmap(const QPixmap &pixmap) {
|
||||
|
||||
void PlaylistSequence::RepeatActionTriggered(QAction *action) {
|
||||
|
||||
RepeatMode mode = Repeat_Off;
|
||||
if (action == ui_->action_repeat_track) mode = Repeat_Track;
|
||||
if (action == ui_->action_repeat_album) mode = Repeat_Album;
|
||||
if (action == ui_->action_repeat_playlist) mode = Repeat_Playlist;
|
||||
if (action == ui_->action_repeat_onebyone) mode = Repeat_OneByOne;
|
||||
if (action == ui_->action_repeat_intro) mode = Repeat_Intro;
|
||||
RepeatMode mode = RepeatMode::Off;
|
||||
if (action == ui_->action_repeat_track) mode = RepeatMode::Track;
|
||||
if (action == ui_->action_repeat_album) mode = RepeatMode::Album;
|
||||
if (action == ui_->action_repeat_playlist) mode = RepeatMode::Playlist;
|
||||
if (action == ui_->action_repeat_onebyone) mode = RepeatMode::OneByOne;
|
||||
if (action == ui_->action_repeat_intro) mode = RepeatMode::Intro;
|
||||
|
||||
SetRepeatMode(mode);
|
||||
|
||||
@@ -152,10 +152,10 @@ void PlaylistSequence::RepeatActionTriggered(QAction *action) {
|
||||
|
||||
void PlaylistSequence::ShuffleActionTriggered(QAction *action) {
|
||||
|
||||
ShuffleMode mode = Shuffle_Off;
|
||||
if (action == ui_->action_shuffle_all) mode = Shuffle_All;
|
||||
if (action == ui_->action_shuffle_inside_album) mode = Shuffle_InsideAlbum;
|
||||
if (action == ui_->action_shuffle_albums) mode = Shuffle_Albums;
|
||||
ShuffleMode mode = ShuffleMode::Off;
|
||||
if (action == ui_->action_shuffle_all) mode = ShuffleMode::All;
|
||||
if (action == ui_->action_shuffle_inside_album) mode = ShuffleMode::InsideAlbum;
|
||||
if (action == ui_->action_shuffle_albums) mode = ShuffleMode::Albums;
|
||||
|
||||
SetShuffleMode(mode);
|
||||
|
||||
@@ -163,15 +163,15 @@ void PlaylistSequence::ShuffleActionTriggered(QAction *action) {
|
||||
|
||||
void PlaylistSequence::SetRepeatMode(const RepeatMode mode) {
|
||||
|
||||
ui_->repeat->setChecked(mode != Repeat_Off);
|
||||
ui_->repeat->setChecked(mode != RepeatMode::Off);
|
||||
|
||||
switch (mode) {
|
||||
case Repeat_Off: ui_->action_repeat_off->setChecked(true); break;
|
||||
case Repeat_Track: ui_->action_repeat_track->setChecked(true); break;
|
||||
case Repeat_Album: ui_->action_repeat_album->setChecked(true); break;
|
||||
case Repeat_Playlist: ui_->action_repeat_playlist->setChecked(true); break;
|
||||
case Repeat_OneByOne: ui_->action_repeat_onebyone->setChecked(true); break;
|
||||
case Repeat_Intro: ui_->action_repeat_intro->setChecked(true); break;
|
||||
case RepeatMode::Off: ui_->action_repeat_off->setChecked(true); break;
|
||||
case RepeatMode::Track: ui_->action_repeat_track->setChecked(true); break;
|
||||
case RepeatMode::Album: ui_->action_repeat_album->setChecked(true); break;
|
||||
case RepeatMode::Playlist: ui_->action_repeat_playlist->setChecked(true); break;
|
||||
case RepeatMode::OneByOne: ui_->action_repeat_onebyone->setChecked(true); break;
|
||||
case RepeatMode::Intro: ui_->action_repeat_intro->setChecked(true); break;
|
||||
|
||||
}
|
||||
|
||||
@@ -186,13 +186,13 @@ void PlaylistSequence::SetRepeatMode(const RepeatMode mode) {
|
||||
|
||||
void PlaylistSequence::SetShuffleMode(const ShuffleMode mode) {
|
||||
|
||||
ui_->shuffle->setChecked(mode != Shuffle_Off);
|
||||
ui_->shuffle->setChecked(mode != ShuffleMode::Off);
|
||||
|
||||
switch (mode) {
|
||||
case Shuffle_Off: ui_->action_shuffle_off->setChecked(true); break;
|
||||
case Shuffle_All: ui_->action_shuffle_all->setChecked(true); break;
|
||||
case Shuffle_InsideAlbum: ui_->action_shuffle_inside_album->setChecked(true); break;
|
||||
case Shuffle_Albums: ui_->action_shuffle_albums->setChecked(true); break;
|
||||
case ShuffleMode::Off: ui_->action_shuffle_off->setChecked(true); break;
|
||||
case ShuffleMode::All: ui_->action_shuffle_all->setChecked(true); break;
|
||||
case ShuffleMode::InsideAlbum: ui_->action_shuffle_inside_album->setChecked(true); break;
|
||||
case ShuffleMode::Albums: ui_->action_shuffle_albums->setChecked(true); break;
|
||||
}
|
||||
|
||||
if (mode != shuffle_mode_) {
|
||||
@@ -205,23 +205,23 @@ void PlaylistSequence::SetShuffleMode(const ShuffleMode mode) {
|
||||
}
|
||||
|
||||
PlaylistSequence::ShuffleMode PlaylistSequence::shuffle_mode() const {
|
||||
return dynamic_ ? Shuffle_Off : shuffle_mode_;
|
||||
return dynamic_ ? ShuffleMode::Off : shuffle_mode_;
|
||||
}
|
||||
|
||||
PlaylistSequence::RepeatMode PlaylistSequence::repeat_mode() const {
|
||||
return dynamic_ ? Repeat_Off : repeat_mode_;
|
||||
return dynamic_ ? RepeatMode::Off : repeat_mode_;
|
||||
}
|
||||
|
||||
//called from global shortcut
|
||||
// Called from global shortcut
|
||||
void PlaylistSequence::CycleShuffleMode() {
|
||||
|
||||
ShuffleMode mode = Shuffle_Off;
|
||||
//we cycle through the shuffle modes
|
||||
ShuffleMode mode = ShuffleMode::Off;
|
||||
// We cycle through the shuffle modes
|
||||
switch (shuffle_mode()) {
|
||||
case Shuffle_Off: mode = Shuffle_All; break;
|
||||
case Shuffle_All: mode = Shuffle_InsideAlbum; break;
|
||||
case Shuffle_InsideAlbum: mode = Shuffle_Albums; break;
|
||||
case Shuffle_Albums: break;
|
||||
case ShuffleMode::Off: mode = ShuffleMode::All; break;
|
||||
case ShuffleMode::All: mode = ShuffleMode::InsideAlbum; break;
|
||||
case ShuffleMode::InsideAlbum: mode = ShuffleMode::Albums; break;
|
||||
case ShuffleMode::Albums: break;
|
||||
}
|
||||
|
||||
SetShuffleMode(mode);
|
||||
@@ -231,15 +231,15 @@ void PlaylistSequence::CycleShuffleMode() {
|
||||
//called from global shortcut
|
||||
void PlaylistSequence::CycleRepeatMode() {
|
||||
|
||||
RepeatMode mode = Repeat_Off;
|
||||
RepeatMode mode = RepeatMode::Off;
|
||||
//we cycle through the repeat modes
|
||||
switch (repeat_mode()) {
|
||||
case Repeat_Off: mode = Repeat_Track; break;
|
||||
case Repeat_Track: mode = Repeat_Album; break;
|
||||
case Repeat_Album: mode = Repeat_Playlist; break;
|
||||
case Repeat_Playlist: mode = Repeat_OneByOne; break;
|
||||
case Repeat_OneByOne: mode = Repeat_Intro; break;
|
||||
case Repeat_Intro:
|
||||
case RepeatMode::Off: mode = RepeatMode::Track; break;
|
||||
case RepeatMode::Track: mode = RepeatMode::Album; break;
|
||||
case RepeatMode::Album: mode = RepeatMode::Playlist; break;
|
||||
case RepeatMode::Playlist: mode = RepeatMode::OneByOne; break;
|
||||
case RepeatMode::OneByOne: mode = RepeatMode::Intro; break;
|
||||
case RepeatMode::Intro:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,19 +45,19 @@ class PlaylistSequence : public QWidget {
|
||||
explicit PlaylistSequence(QWidget *parent = nullptr, SettingsProvider *settings = nullptr);
|
||||
~PlaylistSequence() override;
|
||||
|
||||
enum RepeatMode {
|
||||
Repeat_Off = 0,
|
||||
Repeat_Track = 1,
|
||||
Repeat_Album = 2,
|
||||
Repeat_Playlist = 3,
|
||||
Repeat_OneByOne = 4,
|
||||
Repeat_Intro = 5,
|
||||
enum class RepeatMode {
|
||||
Off = 0,
|
||||
Track = 1,
|
||||
Album = 2,
|
||||
Playlist = 3,
|
||||
OneByOne = 4,
|
||||
Intro = 5
|
||||
};
|
||||
enum ShuffleMode {
|
||||
Shuffle_Off = 0,
|
||||
Shuffle_All = 1,
|
||||
Shuffle_InsideAlbum = 2,
|
||||
Shuffle_Albums = 3,
|
||||
enum class ShuffleMode {
|
||||
Off = 0,
|
||||
All = 1,
|
||||
InsideAlbum = 2,
|
||||
Albums = 3
|
||||
};
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace PlaylistUndoCommands {
|
||||
|
||||
Base::Base(Playlist *playlist) : QUndoCommand(nullptr), playlist_(playlist) {}
|
||||
|
||||
InsertItems::InsertItems(Playlist *playlist, const PlaylistItemList &items, int pos, bool enqueue, bool enqueue_next)
|
||||
InsertItems::InsertItems(Playlist *playlist, const PlaylistItemPtrList &items, int pos, bool enqueue, bool enqueue_next)
|
||||
: Base(playlist),
|
||||
items_(items),
|
||||
pos_(pos),
|
||||
@@ -117,14 +117,14 @@ void MoveItems::undo() {
|
||||
playlist_->MoveItemsWithoutUndo(pos_, source_rows_);
|
||||
}
|
||||
|
||||
ReOrderItems::ReOrderItems(Playlist *playlist, const PlaylistItemList &new_items)
|
||||
ReOrderItems::ReOrderItems(Playlist *playlist, const PlaylistItemPtrList &new_items)
|
||||
: Base(playlist), old_items_(playlist->items_), new_items_(new_items) {}
|
||||
|
||||
void ReOrderItems::undo() { playlist_->ReOrderWithoutUndo(old_items_); }
|
||||
|
||||
void ReOrderItems::redo() { playlist_->ReOrderWithoutUndo(new_items_); }
|
||||
|
||||
SortItems::SortItems(Playlist *playlist, int column, Qt::SortOrder order, const PlaylistItemList &new_items)
|
||||
SortItems::SortItems(Playlist *playlist, int column, Qt::SortOrder order, const PlaylistItemPtrList &new_items)
|
||||
: ReOrderItems(playlist, new_items) {
|
||||
|
||||
Q_UNUSED(column);
|
||||
@@ -135,7 +135,7 @@ SortItems::SortItems(Playlist *playlist, int column, Qt::SortOrder order, const
|
||||
}
|
||||
|
||||
|
||||
ShuffleItems::ShuffleItems(Playlist *playlist, const PlaylistItemList &new_items)
|
||||
ShuffleItems::ShuffleItems(Playlist *playlist, const PlaylistItemPtrList &new_items)
|
||||
: ReOrderItems(playlist, new_items) {
|
||||
|
||||
setText(tr("shuffle songs"));
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace PlaylistUndoCommands {
|
||||
|
||||
class InsertItems : public Base {
|
||||
public:
|
||||
explicit InsertItems(Playlist *playlist, const PlaylistItemList &items, int pos, bool enqueue = false, bool enqueue_next = false);
|
||||
explicit InsertItems(Playlist *playlist, const PlaylistItemPtrList &items, int pos, bool enqueue = false, bool enqueue_next = false);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
@@ -59,7 +59,7 @@ namespace PlaylistUndoCommands {
|
||||
bool UpdateItem(const PlaylistItemPtr &updated_item);
|
||||
|
||||
private:
|
||||
PlaylistItemList items_;
|
||||
PlaylistItemPtrList items_;
|
||||
int pos_;
|
||||
bool enqueue_;
|
||||
bool enqueue_next_;
|
||||
@@ -80,7 +80,7 @@ namespace PlaylistUndoCommands {
|
||||
Range(int pos, int count) : pos_(pos), count_(count) {}
|
||||
int pos_;
|
||||
int count_;
|
||||
PlaylistItemList items_;
|
||||
PlaylistItemPtrList items_;
|
||||
};
|
||||
|
||||
QList<Range> ranges_;
|
||||
@@ -100,25 +100,25 @@ namespace PlaylistUndoCommands {
|
||||
|
||||
class ReOrderItems : public Base {
|
||||
public:
|
||||
explicit ReOrderItems(Playlist *playlist, const PlaylistItemList &new_items);
|
||||
explicit ReOrderItems(Playlist *playlist, const PlaylistItemPtrList &new_items);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
private:
|
||||
PlaylistItemList old_items_;
|
||||
PlaylistItemList new_items_;
|
||||
PlaylistItemPtrList old_items_;
|
||||
PlaylistItemPtrList new_items_;
|
||||
};
|
||||
|
||||
class SortItems : public ReOrderItems {
|
||||
public:
|
||||
explicit SortItems(Playlist *playlist, int column, Qt::SortOrder order, const PlaylistItemList &new_items);
|
||||
explicit SortItems(Playlist *playlist, int column, Qt::SortOrder order, const PlaylistItemPtrList &new_items);
|
||||
|
||||
};
|
||||
|
||||
class ShuffleItems : public ReOrderItems {
|
||||
public:
|
||||
explicit ShuffleItems(Playlist *playlist, const PlaylistItemList &new_items);
|
||||
explicit ShuffleItems(Playlist *playlist, const PlaylistItemPtrList &new_items);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -138,8 +138,8 @@ PlaylistView::PlaylistView(QWidget *parent)
|
||||
style_(new PlaylistProxyStyle()),
|
||||
playlist_(nullptr),
|
||||
header_(new PlaylistHeader(Qt::Horizontal, this, this)),
|
||||
background_image_type_(AppearanceSettingsPage::BackgroundImageType_Default),
|
||||
background_image_position_(AppearanceSettingsPage::BackgroundImagePosition_BottomRight),
|
||||
background_image_type_(AppearanceSettingsPage::BackgroundImageType::Default),
|
||||
background_image_position_(AppearanceSettingsPage::BackgroundImagePosition::BottomRight),
|
||||
background_image_maxsize_(0),
|
||||
background_image_stretch_(false),
|
||||
background_image_do_not_cut_(true),
|
||||
@@ -668,7 +668,7 @@ void PlaylistView::showEvent(QShowEvent *e) {
|
||||
glow_timer_.start(1500 / kGlowIntensitySteps, this);
|
||||
}
|
||||
|
||||
MaybeAutoscroll(Playlist::AutoScroll_Maybe);
|
||||
MaybeAutoscroll(Playlist::AutoScroll::Maybe);
|
||||
|
||||
QTreeView::showEvent(e);
|
||||
|
||||
@@ -699,7 +699,7 @@ void PlaylistView::keyPressEvent(QKeyEvent *event) {
|
||||
CopyCurrentSongToClipboard();
|
||||
}
|
||||
else if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
|
||||
if (currentIndex().isValid()) emit PlayItem(currentIndex(), Playlist::AutoScroll_Never);
|
||||
if (currentIndex().isValid()) emit PlayItem(currentIndex(), Playlist::AutoScroll::Never);
|
||||
event->accept();
|
||||
}
|
||||
else if (event->modifiers() != Qt::ControlModifier && event->key() == Qt::Key_Space) {
|
||||
@@ -957,7 +957,7 @@ void PlaylistView::InhibitAutoscrollTimeout() {
|
||||
|
||||
void PlaylistView::MaybeAutoscroll(const Playlist::AutoScroll autoscroll) {
|
||||
|
||||
if (autoscroll == Playlist::AutoScroll_Always || (autoscroll == Playlist::AutoScroll_Maybe && !inhibit_autoscroll_)) {
|
||||
if (autoscroll == Playlist::AutoScroll::Always || (autoscroll == Playlist::AutoScroll::Maybe && !inhibit_autoscroll_)) {
|
||||
JumpToCurrentlyPlayingTrack();
|
||||
}
|
||||
|
||||
@@ -1013,7 +1013,7 @@ void PlaylistView::paintEvent(QPaintEvent *event) {
|
||||
// The cached pixmap gets invalidated in dragLeaveEvent, dropEvent and scrollContentsBy.
|
||||
|
||||
// Draw background
|
||||
if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Custom || background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Album) {
|
||||
if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType::Custom || background_image_type_ == AppearanceSettingsPage::BackgroundImageType::Album) {
|
||||
if (!background_image_.isNull() || !previous_background_image_.isNull()) {
|
||||
QPainter background_painter(viewport());
|
||||
|
||||
@@ -1064,23 +1064,23 @@ void PlaylistView::paintEvent(QPaintEvent *event) {
|
||||
background_painter.setOpacity(1.0 - previous_background_image_opacity_);
|
||||
}
|
||||
switch (background_image_position_) {
|
||||
case AppearanceSettingsPage::BackgroundImagePosition_UpperLeft:
|
||||
case AppearanceSettingsPage::BackgroundImagePosition::UpperLeft:
|
||||
current_background_image_x_ = 0;
|
||||
current_background_image_y_ = 0;
|
||||
break;
|
||||
case AppearanceSettingsPage::BackgroundImagePosition_UpperRight:
|
||||
case AppearanceSettingsPage::BackgroundImagePosition::UpperRight:
|
||||
current_background_image_x_ = (pb_width - cached_scaled_background_image_.width());
|
||||
current_background_image_y_ = 0;
|
||||
break;
|
||||
case AppearanceSettingsPage::BackgroundImagePosition_Middle:
|
||||
case AppearanceSettingsPage::BackgroundImagePosition::Middle:
|
||||
current_background_image_x_ = ((pb_width - cached_scaled_background_image_.width()) / 2);
|
||||
current_background_image_y_ = ((pb_height - cached_scaled_background_image_.height()) / 2);
|
||||
break;
|
||||
case AppearanceSettingsPage::BackgroundImagePosition_BottomLeft:
|
||||
case AppearanceSettingsPage::BackgroundImagePosition::BottomLeft:
|
||||
current_background_image_x_ = 0;
|
||||
current_background_image_y_ = (pb_height - cached_scaled_background_image_.height());
|
||||
break;
|
||||
case AppearanceSettingsPage::BackgroundImagePosition_BottomRight:
|
||||
case AppearanceSettingsPage::BackgroundImagePosition::BottomRight:
|
||||
default:
|
||||
current_background_image_x_ = (pb_width - cached_scaled_background_image_.width());
|
||||
current_background_image_y_ = (pb_height - cached_scaled_background_image_.height());
|
||||
@@ -1250,20 +1250,20 @@ void PlaylistView::ReloadSettings() {
|
||||
if (!glow_enabled_) StopGlowing();
|
||||
|
||||
// Background:
|
||||
AppearanceSettingsPage::BackgroundImageType background_image_type(AppearanceSettingsPage::BackgroundImageType_Default);
|
||||
AppearanceSettingsPage::BackgroundImageType background_image_type(AppearanceSettingsPage::BackgroundImageType::Default);
|
||||
if (background_image_type_var.isValid()) {
|
||||
background_image_type = static_cast<AppearanceSettingsPage::BackgroundImageType>(background_image_type_var.toInt());
|
||||
}
|
||||
else {
|
||||
background_image_type = AppearanceSettingsPage::BackgroundImageType_Default;
|
||||
background_image_type = AppearanceSettingsPage::BackgroundImageType::Default;
|
||||
}
|
||||
|
||||
AppearanceSettingsPage::BackgroundImagePosition background_image_position(AppearanceSettingsPage::BackgroundImagePosition_BottomRight);
|
||||
AppearanceSettingsPage::BackgroundImagePosition background_image_position(AppearanceSettingsPage::BackgroundImagePosition::BottomRight);
|
||||
if (background_image_position_var.isValid()) {
|
||||
background_image_position = static_cast<AppearanceSettingsPage::BackgroundImagePosition>(background_image_position_var.toInt());
|
||||
}
|
||||
else {
|
||||
background_image_position = AppearanceSettingsPage::BackgroundImagePosition_BottomRight;
|
||||
background_image_position = AppearanceSettingsPage::BackgroundImagePosition::BottomRight;
|
||||
}
|
||||
|
||||
// Check if background properties have changed.
|
||||
@@ -1295,10 +1295,10 @@ void PlaylistView::ReloadSettings() {
|
||||
blur_radius_ = blur_radius;
|
||||
opacity_level_ = opacity_level;
|
||||
|
||||
if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Custom) {
|
||||
if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType::Custom) {
|
||||
set_background_image(QImage(background_image_filename));
|
||||
}
|
||||
else if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Album) {
|
||||
else if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType::Album) {
|
||||
set_background_image(current_song_cover_art_);
|
||||
}
|
||||
else {
|
||||
@@ -1308,8 +1308,8 @@ void PlaylistView::ReloadSettings() {
|
||||
cached_scaled_background_image_ = QPixmap();
|
||||
previous_background_image_ = QPixmap();
|
||||
}
|
||||
setProperty("default_background_enabled", background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Default);
|
||||
setProperty("strawbs_background_enabled", background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Strawbs);
|
||||
setProperty("default_background_enabled", background_image_type_ == AppearanceSettingsPage::BackgroundImageType::Default);
|
||||
setProperty("strawbs_background_enabled", background_image_type_ == AppearanceSettingsPage::BackgroundImageType::Strawbs);
|
||||
emit BackgroundPropertyChanged();
|
||||
force_background_redraw_ = true;
|
||||
}
|
||||
@@ -1472,7 +1472,7 @@ void PlaylistView::AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResu
|
||||
if ((song != Song() && song_playing_ == Song()) || result.album_cover.image == current_song_cover_art_) return;
|
||||
|
||||
current_song_cover_art_ = result.album_cover.image;
|
||||
if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Album) {
|
||||
if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType::Album) {
|
||||
if (song.art_automatic().isEmpty() && song.art_manual().isEmpty()) {
|
||||
set_background_image(QImage());
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ class PlaylistView : public QTreeView {
|
||||
|
||||
signals:
|
||||
void PlayItem(QModelIndex idx, Playlist::AutoScroll autoscroll);
|
||||
void PlayPause(const quint64 offset_nanosec = 0, Playlist::AutoScroll autoscroll = Playlist::AutoScroll_Never);
|
||||
void PlayPause(const quint64 offset_nanosec = 0, Playlist::AutoScroll autoscroll = Playlist::AutoScroll::Never);
|
||||
void RightClicked(QPoint global_pos, QModelIndex idx);
|
||||
void SeekForward();
|
||||
void SeekBackward();
|
||||
|
||||
@@ -62,12 +62,12 @@ void SongLoaderInserter::Load(Playlist *destination, int row, bool play_now, boo
|
||||
|
||||
SongLoader::Result ret = loader->Load(url);
|
||||
|
||||
if (ret == SongLoader::BlockingLoadRequired) {
|
||||
if (ret == SongLoader::Result::BlockingLoadRequired) {
|
||||
pending_.append(loader);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ret == SongLoader::Success) {
|
||||
if (ret == SongLoader::Result::Success) {
|
||||
songs_ << loader->songs();
|
||||
}
|
||||
else {
|
||||
@@ -108,7 +108,7 @@ void SongLoaderInserter::LoadAudioCD(Playlist *destination, int row, bool play_n
|
||||
QObject::connect(loader, &SongLoader::LoadAudioCDFinished, this, &SongLoaderInserter::AudioCDTagsLoaded);
|
||||
qLog(Info) << "Loading audio CD...";
|
||||
SongLoader::Result ret = loader->LoadAudioCD();
|
||||
if (ret == SongLoader::Error) {
|
||||
if (ret == SongLoader::Result::Error) {
|
||||
if (loader->errors().isEmpty())
|
||||
emit Error(tr("Error while loading audio CD."));
|
||||
else {
|
||||
@@ -175,7 +175,7 @@ void SongLoaderInserter::AsyncLoad() {
|
||||
SongLoader::Result res = loader->LoadFilenamesBlocking();
|
||||
task_manager_->SetTaskProgress(async_load_id, ++async_progress);
|
||||
|
||||
if (res == SongLoader::Error) {
|
||||
if (res == SongLoader::Result::Error) {
|
||||
for (const QString &error : loader->errors()) {
|
||||
emit Error(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user