Clang format

This commit is contained in:
Mark Furneaux 2018-04-14 16:57:06 -04:00
parent 2793cfa7fb
commit d28a318437
12 changed files with 94 additions and 70 deletions

View File

@ -27,8 +27,8 @@ class MimeData : public QMimeData {
Q_OBJECT Q_OBJECT
public: public:
MimeData(bool clear = false, bool play_now = false, bool enqueue = false, bool enqueue_next_now = false, MimeData(bool clear = false, bool play_now = false, bool enqueue = false,
bool open_in_new_playlist = false) bool enqueue_next_now = false, bool open_in_new_playlist = false)
: override_user_settings_(false), : override_user_settings_(false),
clear_first_(clear), clear_first_(clear),
play_now_(play_now), play_now_(play_now),
@ -54,7 +54,8 @@ class MimeData : public QMimeData {
// If this is set then the items are added to the queue after being inserted. // If this is set then the items are added to the queue after being inserted.
bool enqueue_now_; bool enqueue_now_;
// If this is set then the items are added to the beginning of the queue after being inserted. // If this is set then the items are added to the beginning of the queue after
// being inserted.
bool enqueue_next_now_; bool enqueue_next_now_;
// If this is set then the items are inserted into a newly created playlist. // If this is set then the items are inserted into a newly created playlist.

View File

@ -394,7 +394,7 @@ void LibraryView::contextMenuEvent(QContextMenuEvent* e) {
SLOT(AddToPlaylistEnqueue())); SLOT(AddToPlaylistEnqueue()));
add_to_playlist_enqueue_next_ = context_menu_->addAction( add_to_playlist_enqueue_next_ = context_menu_->addAction(
IconLoader::Load("go-next", IconLoader::Base), tr("Play next"), this, IconLoader::Load("go-next", IconLoader::Base), tr("Play next"), this,
SLOT(AddToPlaylistEnqueueNext())); SLOT(AddToPlaylistEnqueueNext()));
context_menu_->addSeparator(); context_menu_->addSeparator();
search_for_this_ = context_menu_->addAction( search_for_this_ = context_menu_->addAction(
IconLoader::Load("system-search", IconLoader::Base), IconLoader::Load("system-search", IconLoader::Base),
@ -620,11 +620,11 @@ void LibraryView::AddToPlaylistEnqueue() {
} }
void LibraryView::AddToPlaylistEnqueueNext() { void LibraryView::AddToPlaylistEnqueueNext() {
QMimeData* data = model()->mimeData(selectedIndexes()); QMimeData* data = model()->mimeData(selectedIndexes());
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) { if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
mime_data->enqueue_next_now_ = true; mime_data->enqueue_next_now_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(data);
} }
void LibraryView::OpenInNewPlaylist() { void LibraryView::OpenInNewPlaylist() {

View File

@ -773,10 +773,12 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action,
row, play_now, enqueue_now, enqueue_next_now); row, play_now, enqueue_now, enqueue_next_now);
} else if (const GeneratorMimeData* generator_data = } else if (const GeneratorMimeData* generator_data =
qobject_cast<const GeneratorMimeData*>(data)) { qobject_cast<const GeneratorMimeData*>(data)) {
InsertSmartPlaylist(generator_data->generator_, row, play_now, enqueue_now, enqueue_next_now); InsertSmartPlaylist(generator_data->generator_, row, play_now, enqueue_now,
enqueue_next_now);
} else if (const PlaylistItemMimeData* item_data = } else if (const PlaylistItemMimeData* item_data =
qobject_cast<const PlaylistItemMimeData*>(data)) { qobject_cast<const PlaylistItemMimeData*>(data)) {
InsertItems(item_data->items_, row, play_now, enqueue_now, enqueue_next_now); InsertItems(item_data->items_, row, play_now, enqueue_now,
enqueue_next_now);
} else if (data->hasFormat(kRowsMimetype)) { } else if (data->hasFormat(kRowsMimetype)) {
// Dragged from the playlist // Dragged from the playlist
// Rearranging it is tricky... // Rearranging it is tricky...
@ -849,7 +851,8 @@ void Playlist::InsertUrls(const QList<QUrl>& urls, int pos, bool play_now,
} }
void Playlist::InsertSmartPlaylist(GeneratorPtr generator, int pos, void Playlist::InsertSmartPlaylist(GeneratorPtr generator, int pos,
bool play_now, bool enqueue, bool enqueue_next) { bool play_now, bool enqueue,
bool enqueue_next) {
// Hack: If the generator hasn't got a library set then use the main one // Hack: If the generator hasn't got a library set then use the main one
if (!generator->library()) { if (!generator->library()) {
generator->set_library(library_); generator->set_library(library_);
@ -1031,8 +1034,8 @@ void Playlist::InsertItems(const PlaylistItemList& itemsIn, int pos,
InsertItemsWithoutUndo(items, pos, enqueue, enqueue_next); InsertItemsWithoutUndo(items, pos, enqueue, enqueue_next);
undo_stack_->clear(); undo_stack_->clear();
} else { } else {
undo_stack_->push( undo_stack_->push(new PlaylistUndoCommands::InsertItems(
new PlaylistUndoCommands::InsertItems(this, items, pos, enqueue, enqueue_next)); this, items, pos, enqueue, enqueue_next));
} }
if (play_now) emit PlayRequested(index(start, 0)); if (play_now) emit PlayRequested(index(start, 0));
@ -1077,7 +1080,7 @@ void Playlist::InsertItemsWithoutUndo(const PlaylistItemList& items, int pos,
if (enqueue_next) { if (enqueue_next) {
QModelIndexList indexes; QModelIndexList indexes;
for (int i = start; i <= end; ++i) { for (int i = start; i <= end; ++i) {
indexes << index(i, 0); indexes << index(i, 0);
} }
queue_->InsertFirst(indexes); queue_->InsertFirst(indexes);
} }
@ -1088,16 +1091,19 @@ void Playlist::InsertItemsWithoutUndo(const PlaylistItemList& items, int pos,
void Playlist::InsertLibraryItems(const SongList& songs, int pos, bool play_now, void Playlist::InsertLibraryItems(const SongList& songs, int pos, bool play_now,
bool enqueue, bool enqueue_next) { bool enqueue, bool enqueue_next) {
InsertSongItems<LibraryPlaylistItem>(songs, pos, play_now, enqueue, enqueue_next); InsertSongItems<LibraryPlaylistItem>(songs, pos, play_now, enqueue,
enqueue_next);
} }
void Playlist::InsertSongs(const SongList& songs, int pos, bool play_now, void Playlist::InsertSongs(const SongList& songs, int pos, bool play_now,
bool enqueue, bool enqueue_next) { bool enqueue, bool enqueue_next) {
InsertSongItems<SongPlaylistItem>(songs, pos, play_now, enqueue, enqueue_next); InsertSongItems<SongPlaylistItem>(songs, pos, play_now, enqueue,
enqueue_next);
} }
void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos, void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos,
bool play_now, bool enqueue, bool enqueue_next) { bool play_now, bool enqueue,
bool enqueue_next) {
PlaylistItemList items; PlaylistItemList items;
for (const Song& song : songs) { for (const Song& song : songs) {
if (song.is_library_song()) { if (song.is_library_song()) {
@ -1111,7 +1117,8 @@ void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos,
void Playlist::InsertInternetItems(const InternetModel* model, void Playlist::InsertInternetItems(const InternetModel* model,
const QModelIndexList& items, int pos, const QModelIndexList& items, int pos,
bool play_now, bool enqueue, bool enqueue_next) { bool play_now, bool enqueue,
bool enqueue_next) {
PlaylistItemList playlist_items; PlaylistItemList playlist_items;
QList<QUrl> song_urls; QList<QUrl> song_urls;
@ -1139,7 +1146,8 @@ void Playlist::InsertInternetItems(const InternetModel* model,
void Playlist::InsertInternetItems(InternetService* service, void Playlist::InsertInternetItems(InternetService* service,
const SongList& songs, int pos, const SongList& songs, int pos,
bool play_now, bool enqueue, bool enqueue_next) { bool play_now, bool enqueue,
bool enqueue_next) {
PlaylistItemList playlist_items; PlaylistItemList playlist_items;
for (const Song& song : songs) { for (const Song& song : songs) {
playlist_items << shared_ptr<PlaylistItem>( playlist_items << shared_ptr<PlaylistItem>(

View File

@ -235,15 +235,19 @@ class Playlist : public QAbstractListModel {
// Changing the playlist // Changing the playlist
void InsertItems(const PlaylistItemList& items, int pos = -1, void InsertItems(const PlaylistItemList& items, int pos = -1,
bool play_now = false, bool enqueue = false, bool enqueue_next = false); bool play_now = false, bool enqueue = false,
bool enqueue_next = false);
void InsertLibraryItems(const SongList& items, int pos = -1, void InsertLibraryItems(const SongList& items, int pos = -1,
bool play_now = false, bool enqueue = false, bool enqueue_next = false); bool play_now = false, bool enqueue = false,
bool enqueue_next = false);
void InsertSongs(const SongList& items, int pos = -1, bool play_now = false, void InsertSongs(const SongList& items, int pos = -1, bool play_now = false,
bool enqueue = false, bool enqueue_next = false); bool enqueue = false, bool enqueue_next = false);
void InsertSongsOrLibraryItems(const SongList& items, int pos = -1, void InsertSongsOrLibraryItems(const SongList& items, int pos = -1,
bool play_now = false, bool enqueue = false, bool enqueue_next = false); bool play_now = false, bool enqueue = false,
bool enqueue_next = false);
void InsertSmartPlaylist(smart_playlists::GeneratorPtr gen, int pos = -1, void InsertSmartPlaylist(smart_playlists::GeneratorPtr gen, int pos = -1,
bool play_now = false, bool enqueue = false, bool enqueue_next = false); bool play_now = false, bool enqueue = false,
bool enqueue_next = false);
void InsertInternetItems(InternetService* service, const SongList& songs, void InsertInternetItems(InternetService* service, const SongList& songs,
int pos = -1, bool play_now = false, int pos = -1, bool play_now = false,
bool enqueue = false, bool enqueue_next = false); bool enqueue = false, bool enqueue_next = false);

View File

@ -24,12 +24,16 @@ Base::Base(Playlist* playlist) : QUndoCommand(0), playlist_(playlist) {}
InsertItems::InsertItems(Playlist* playlist, const PlaylistItemList& items, InsertItems::InsertItems(Playlist* playlist, const PlaylistItemList& items,
int pos, bool enqueue, bool enqueue_next) int pos, bool enqueue, bool enqueue_next)
: Base(playlist), items_(items), pos_(pos), enqueue_(enqueue), enqueue_next_(enqueue_next) { : Base(playlist),
items_(items),
pos_(pos),
enqueue_(enqueue),
enqueue_next_(enqueue_next) {
setText(tr("add %n songs", "", items_.count())); setText(tr("add %n songs", "", items_.count()));
} }
void InsertItems::redo() { void InsertItems::redo() {
playlist_->InsertItemsWithoutUndo(items_, pos_, enqueue_, enqueue_next_); playlist_->InsertItemsWithoutUndo(items_, pos_, enqueue_, enqueue_next_);
} }
void InsertItems::undo() { void InsertItems::undo() {

View File

@ -40,7 +40,8 @@ class Base : public QUndoCommand {
class InsertItems : public Base { class InsertItems : public Base {
public: public:
InsertItems(Playlist* playlist, const PlaylistItemList& items, int pos, bool enqueue = false, bool enqueue_next = false); InsertItems(Playlist* playlist, const PlaylistItemList& items, int pos,
bool enqueue = false, bool enqueue_next = false);
void undo(); void undo();
void redo(); void redo();

View File

@ -152,26 +152,26 @@ void Queue::ToggleTracks(const QModelIndexList& source_indexes) {
} }
void Queue::InsertFirst(const QModelIndexList& source_indexes) { void Queue::InsertFirst(const QModelIndexList& source_indexes) {
for (const QModelIndex& source_index : source_indexes) { for (const QModelIndex& source_index : source_indexes) {
QModelIndex proxy_index = mapFromSource(source_index); QModelIndex proxy_index = mapFromSource(source_index);
if (proxy_index.isValid()) { if (proxy_index.isValid()) {
// Already in the queue, so remove it to be reinserted later // Already in the queue, so remove it to be reinserted later
const int row = proxy_index.row(); const int row = proxy_index.row();
beginRemoveRows(QModelIndex(), row, row); beginRemoveRows(QModelIndex(), row, row);
source_indexes_.removeAt(row); source_indexes_.removeAt(row);
endRemoveRows(); endRemoveRows();
}
} }
}
const int rows = source_indexes.count(); const int rows = source_indexes.count();
// Enqueue the tracks at the beginning // Enqueue the tracks at the beginning
beginInsertRows(QModelIndex(), 0, rows - 1); beginInsertRows(QModelIndex(), 0, rows - 1);
int offset = 0; int offset = 0;
for (const QModelIndex& source_index : source_indexes) { for (const QModelIndex& source_index : source_indexes) {
source_indexes_.insert(offset, QPersistentModelIndex(source_index)); source_indexes_.insert(offset, QPersistentModelIndex(source_index));
offset++; offset++;
} }
endInsertRows(); endInsertRows();
} }
int Queue::PositionOf(const QModelIndex& source_index) const { int Queue::PositionOf(const QModelIndex& source_index) const {

View File

@ -37,7 +37,8 @@ SongLoaderInserter::SongLoaderInserter(TaskManager* task_manager,
SongLoaderInserter::~SongLoaderInserter() { qDeleteAll(pending_); } SongLoaderInserter::~SongLoaderInserter() { qDeleteAll(pending_); }
void SongLoaderInserter::Load(Playlist* destination, int row, bool play_now, void SongLoaderInserter::Load(Playlist* destination, int row, bool play_now,
bool enqueue, bool enqueue_next, const QList<QUrl>& urls) { bool enqueue, bool enqueue_next,
const QList<QUrl>& urls) {
destination_ = destination; destination_ = destination;
row_ = row; row_ = row;
play_now_ = play_now; play_now_ = play_now;
@ -79,7 +80,8 @@ void SongLoaderInserter::Load(Playlist* destination, int row, bool play_now,
// In the meantime, MusicBrainz will be queried to get songs' metadata. // In the meantime, MusicBrainz will be queried to get songs' metadata.
// AudioCDTagsLoaded will be called next, and playlist's items will be updated. // AudioCDTagsLoaded will be called next, and playlist's items will be updated.
void SongLoaderInserter::LoadAudioCD(Playlist* destination, int row, void SongLoaderInserter::LoadAudioCD(Playlist* destination, int row,
bool play_now, bool enqueue, bool enqueue_next) { bool play_now, bool enqueue,
bool enqueue_next) {
destination_ = destination; destination_ = destination;
row_ = row; row_ = row;
play_now_ = play_now; play_now_ = play_now;
@ -121,7 +123,8 @@ void SongLoaderInserter::InsertSongs() {
// Insert songs (that haven't been completely loaded) to allow user to see // Insert songs (that haven't been completely loaded) to allow user to see
// and play them while not loaded completely // and play them while not loaded completely
if (destination_) { if (destination_) {
destination_->InsertSongsOrLibraryItems(songs_, row_, play_now_, enqueue_, enqueue_next_); destination_->InsertSongsOrLibraryItems(songs_, row_, play_now_, enqueue_,
enqueue_next_);
} }
} }

View File

@ -39,11 +39,12 @@ class SongLoaderInserter : public QObject {
LibraryBackendInterface* library, const Player* player); LibraryBackendInterface* library, const Player* player);
~SongLoaderInserter(); ~SongLoaderInserter();
void Load(Playlist* destination, int row, bool play_now, bool enqueue, bool enqueue_next, void Load(Playlist* destination, int row, bool play_now, bool enqueue,
const QList<QUrl>& urls); bool enqueue_next, const QList<QUrl>& urls);
void LoadAudioCD(Playlist* destination, int row, bool play_now, bool enqueue, bool enqueue_now); void LoadAudioCD(Playlist* destination, int row, bool play_now, bool enqueue,
bool enqueue_now);
signals: signals:
void Error(const QString& message); void Error(const QString& message);
void PreloadFinished(); void PreloadFinished();
void EffectiveLoadFinished(const SongList& songs); void EffectiveLoadFinished(const SongList& songs);

View File

@ -43,8 +43,8 @@ static PlaylistItemList Generate(GeneratorPtr generator, int dynamic_count) {
} }
void GeneratorInserter::Load(Playlist* destination, int row, bool play_now, void GeneratorInserter::Load(Playlist* destination, int row, bool play_now,
bool enqueue, bool enqueue_next, GeneratorPtr generator, bool enqueue, bool enqueue_next,
int dynamic_count) { GeneratorPtr generator, int dynamic_count) {
task_id_ = task_manager_->StartTask(tr("Loading smart playlist")); task_id_ = task_manager_->StartTask(tr("Loading smart playlist"));
destination_ = destination; destination_ = destination;

View File

@ -40,10 +40,10 @@ class GeneratorInserter : public QObject {
GeneratorInserter(TaskManager* task_manager, LibraryBackend* library, GeneratorInserter(TaskManager* task_manager, LibraryBackend* library,
QObject* parent); QObject* parent);
void Load(Playlist* destination, int row, bool play_now, bool enqueue, bool enqueue_next, void Load(Playlist* destination, int row, bool play_now, bool enqueue,
GeneratorPtr generator, int dynamic_count = 0); bool enqueue_next, GeneratorPtr generator, int dynamic_count = 0);
signals: signals:
void Error(const QString& message); void Error(const QString& message);
void PlayRequested(const QModelIndex& index); void PlayRequested(const QModelIndex& index);

View File

@ -677,7 +677,8 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
playlist_queue_ = playlist_menu_->addAction("", this, SLOT(PlaylistQueue())); playlist_queue_ = playlist_menu_->addAction("", this, SLOT(PlaylistQueue()));
playlist_queue_->setShortcut(QKeySequence("Ctrl+D")); playlist_queue_->setShortcut(QKeySequence("Ctrl+D"));
ui_->playlist->addAction(playlist_queue_); ui_->playlist->addAction(playlist_queue_);
playlist_queue_play_next_ = playlist_menu_->addAction("", this, SLOT(PlaylistQueuePlayNext())); playlist_queue_play_next_ =
playlist_menu_->addAction("", this, SLOT(PlaylistQueuePlayNext()));
playlist_queue_play_next_->setShortcut(QKeySequence("Ctrl+Shift+D")); playlist_queue_play_next_->setShortcut(QKeySequence("Ctrl+Shift+D"));
ui_->playlist->addAction(playlist_queue_play_next_); ui_->playlist->addAction(playlist_queue_play_next_);
playlist_skip_ = playlist_menu_->addAction("", this, SLOT(PlaylistSkip())); playlist_skip_ = playlist_menu_->addAction("", this, SLOT(PlaylistSkip()));
@ -1763,10 +1764,10 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos,
else else
playlist_queue_->setText(tr("Toggle queue status")); playlist_queue_->setText(tr("Toggle queue status"));
if (all > 1) if (all > 1)
playlist_queue_play_next_->setText(tr("Play selected tracks next")); playlist_queue_play_next_->setText(tr("Play selected tracks next"));
else else
playlist_queue_play_next_->setText(tr("Play next")); playlist_queue_play_next_->setText(tr("Play next"));
if (in_skipped == 1 && not_in_skipped == 0) if (in_skipped == 1 && not_in_skipped == 0)
playlist_skip_->setText(tr("Unskip track")); playlist_skip_->setText(tr("Unskip track"));
@ -1782,7 +1783,8 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos,
else else
playlist_queue_->setIcon(IconLoader::Load("go-next", IconLoader::Base)); playlist_queue_->setIcon(IconLoader::Load("go-next", IconLoader::Base));
playlist_queue_play_next_->setIcon(IconLoader::Load("go-next", IconLoader::Base)); playlist_queue_play_next_->setIcon(
IconLoader::Load("go-next", IconLoader::Base));
if (!index.isValid()) { if (!index.isValid()) {
ui_->action_selection_set_value->setVisible(false); ui_->action_selection_set_value->setVisible(false);
@ -2511,14 +2513,14 @@ void MainWindow::PlaylistQueue() {
} }
void MainWindow::PlaylistQueuePlayNext() { void MainWindow::PlaylistQueuePlayNext() {
QModelIndexList indexes; QModelIndexList indexes;
for (const QModelIndex& proxy_index : for (const QModelIndex& proxy_index :
ui_->playlist->view()->selectionModel()->selectedRows()) { ui_->playlist->view()->selectionModel()->selectedRows()) {
indexes << app_->playlist_manager()->current()->proxy()->mapToSource( indexes << app_->playlist_manager()->current()->proxy()->mapToSource(
proxy_index); proxy_index);
} }
app_->playlist_manager()->current()->queue()->InsertFirst(indexes); app_->playlist_manager()->current()->queue()->InsertFirst(indexes);
} }
void MainWindow::PlaylistSkip() { void MainWindow::PlaylistSkip() {