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
public:
MimeData(bool clear = false, bool play_now = false, bool enqueue = false, bool enqueue_next_now = false,
bool open_in_new_playlist = false)
MimeData(bool clear = false, bool play_now = false, bool enqueue = false,
bool enqueue_next_now = false, bool open_in_new_playlist = false)
: override_user_settings_(false),
clear_first_(clear),
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.
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_;
// 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()));
add_to_playlist_enqueue_next_ = context_menu_->addAction(
IconLoader::Load("go-next", IconLoader::Base), tr("Play next"), this,
SLOT(AddToPlaylistEnqueueNext()));
SLOT(AddToPlaylistEnqueueNext()));
context_menu_->addSeparator();
search_for_this_ = context_menu_->addAction(
IconLoader::Load("system-search", IconLoader::Base),
@ -620,11 +620,11 @@ void LibraryView::AddToPlaylistEnqueue() {
}
void LibraryView::AddToPlaylistEnqueueNext() {
QMimeData* data = model()->mimeData(selectedIndexes());
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
mime_data->enqueue_next_now_ = true;
}
emit AddToPlaylistSignal(data);
QMimeData* data = model()->mimeData(selectedIndexes());
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
mime_data->enqueue_next_now_ = true;
}
emit AddToPlaylistSignal(data);
}
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);
} else if (const GeneratorMimeData* generator_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 =
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)) {
// Dragged from the playlist
// 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,
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
if (!generator->library()) {
generator->set_library(library_);
@ -1031,8 +1034,8 @@ void Playlist::InsertItems(const PlaylistItemList& itemsIn, int pos,
InsertItemsWithoutUndo(items, pos, enqueue, enqueue_next);
undo_stack_->clear();
} else {
undo_stack_->push(
new PlaylistUndoCommands::InsertItems(this, items, pos, enqueue, enqueue_next));
undo_stack_->push(new PlaylistUndoCommands::InsertItems(
this, items, pos, enqueue, enqueue_next));
}
if (play_now) emit PlayRequested(index(start, 0));
@ -1077,7 +1080,7 @@ void Playlist::InsertItemsWithoutUndo(const PlaylistItemList& items, int pos,
if (enqueue_next) {
QModelIndexList indexes;
for (int i = start; i <= end; ++i) {
indexes << index(i, 0);
indexes << index(i, 0);
}
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,
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,
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,
bool play_now, bool enqueue, bool enqueue_next) {
bool play_now, bool enqueue,
bool enqueue_next) {
PlaylistItemList items;
for (const Song& song : songs) {
if (song.is_library_song()) {
@ -1111,7 +1117,8 @@ void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos,
void Playlist::InsertInternetItems(const InternetModel* model,
const QModelIndexList& items, int pos,
bool play_now, bool enqueue, bool enqueue_next) {
bool play_now, bool enqueue,
bool enqueue_next) {
PlaylistItemList playlist_items;
QList<QUrl> song_urls;
@ -1139,7 +1146,8 @@ void Playlist::InsertInternetItems(const InternetModel* model,
void Playlist::InsertInternetItems(InternetService* service,
const SongList& songs, int pos,
bool play_now, bool enqueue, bool enqueue_next) {
bool play_now, bool enqueue,
bool enqueue_next) {
PlaylistItemList playlist_items;
for (const Song& song : songs) {
playlist_items << shared_ptr<PlaylistItem>(

View File

@ -235,15 +235,19 @@ class Playlist : public QAbstractListModel {
// Changing the playlist
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,
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,
bool enqueue = false, bool enqueue_next = false);
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,
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,
int pos = -1, bool play_now = 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,
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()));
}
void InsertItems::redo() {
playlist_->InsertItemsWithoutUndo(items_, pos_, enqueue_, enqueue_next_);
playlist_->InsertItemsWithoutUndo(items_, pos_, enqueue_, enqueue_next_);
}
void InsertItems::undo() {

View File

@ -40,7 +40,8 @@ class Base : public QUndoCommand {
class InsertItems : public Base {
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 redo();

View File

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

View File

@ -37,7 +37,8 @@ SongLoaderInserter::SongLoaderInserter(TaskManager* task_manager,
SongLoaderInserter::~SongLoaderInserter() { qDeleteAll(pending_); }
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;
row_ = row;
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.
// AudioCDTagsLoaded will be called next, and playlist's items will be updated.
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;
row_ = row;
play_now_ = play_now;
@ -121,7 +123,8 @@ void SongLoaderInserter::InsertSongs() {
// Insert songs (that haven't been completely loaded) to allow user to see
// and play them while not loaded completely
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);
~SongLoaderInserter();
void Load(Playlist* destination, int row, bool play_now, bool enqueue, bool enqueue_next,
const QList<QUrl>& urls);
void LoadAudioCD(Playlist* destination, int row, bool play_now, bool enqueue, bool enqueue_now);
void Load(Playlist* destination, int row, bool play_now, bool enqueue,
bool enqueue_next, const QList<QUrl>& urls);
void LoadAudioCD(Playlist* destination, int row, bool play_now, bool enqueue,
bool enqueue_now);
signals:
signals:
void Error(const QString& message);
void PreloadFinished();
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,
bool enqueue, bool enqueue_next, GeneratorPtr generator,
int dynamic_count) {
bool enqueue, bool enqueue_next,
GeneratorPtr generator, int dynamic_count) {
task_id_ = task_manager_->StartTask(tr("Loading smart playlist"));
destination_ = destination;

View File

@ -40,10 +40,10 @@ class GeneratorInserter : public QObject {
GeneratorInserter(TaskManager* task_manager, LibraryBackend* library,
QObject* parent);
void Load(Playlist* destination, int row, bool play_now, bool enqueue, bool enqueue_next,
GeneratorPtr generator, int dynamic_count = 0);
void Load(Playlist* destination, int row, bool play_now, bool enqueue,
bool enqueue_next, GeneratorPtr generator, int dynamic_count = 0);
signals:
signals:
void Error(const QString& message);
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_->setShortcut(QKeySequence("Ctrl+D"));
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"));
ui_->playlist->addAction(playlist_queue_play_next_);
playlist_skip_ = playlist_menu_->addAction("", this, SLOT(PlaylistSkip()));
@ -1763,10 +1764,10 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos,
else
playlist_queue_->setText(tr("Toggle queue status"));
if (all > 1)
playlist_queue_play_next_->setText(tr("Play selected tracks next"));
else
playlist_queue_play_next_->setText(tr("Play next"));
if (all > 1)
playlist_queue_play_next_->setText(tr("Play selected tracks next"));
else
playlist_queue_play_next_->setText(tr("Play next"));
if (in_skipped == 1 && not_in_skipped == 0)
playlist_skip_->setText(tr("Unskip track"));
@ -1782,7 +1783,8 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos,
else
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()) {
ui_->action_selection_set_value->setVisible(false);
@ -2511,14 +2513,14 @@ void MainWindow::PlaylistQueue() {
}
void MainWindow::PlaylistQueuePlayNext() {
QModelIndexList indexes;
for (const QModelIndex& proxy_index :
ui_->playlist->view()->selectionModel()->selectedRows()) {
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(
proxy_index);
}
QModelIndexList indexes;
for (const QModelIndex& proxy_index :
ui_->playlist->view()->selectionModel()->selectedRows()) {
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(
proxy_index);
}
app_->playlist_manager()->current()->queue()->InsertFirst(indexes);
app_->playlist_manager()->current()->queue()->InsertFirst(indexes);
}
void MainWindow::PlaylistSkip() {