Workaround crash when mapToSource() fails
This commit is contained in:
@@ -521,7 +521,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
|||||||
connect(ui_->playlist->view(), SIGNAL(doubleClicked(QModelIndex)), SLOT(PlaylistDoubleClick(QModelIndex)));
|
connect(ui_->playlist->view(), SIGNAL(doubleClicked(QModelIndex)), SLOT(PlaylistDoubleClick(QModelIndex)));
|
||||||
connect(ui_->playlist->view(), SIGNAL(PlayItem(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
|
connect(ui_->playlist->view(), SIGNAL(PlayItem(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
|
||||||
connect(ui_->playlist->view(), SIGNAL(PlayPause()), app_->player(), SLOT(PlayPause()));
|
connect(ui_->playlist->view(), SIGNAL(PlayPause()), app_->player(), SLOT(PlayPause()));
|
||||||
connect(ui_->playlist->view(), SIGNAL(RightClicked(QPoint,QModelIndex)), SLOT(PlaylistRightClick(QPoint,QModelIndex)));
|
connect(ui_->playlist->view(), SIGNAL(RightClicked(QPoint, QModelIndex)), SLOT(PlaylistRightClick(QPoint, QModelIndex)));
|
||||||
connect(ui_->playlist->view(), SIGNAL(SeekForward()), app_->player(), SLOT(SeekForward()));
|
connect(ui_->playlist->view(), SIGNAL(SeekForward()), app_->player(), SLOT(SeekForward()));
|
||||||
connect(ui_->playlist->view(), SIGNAL(SeekBackward()), app_->player(), SLOT(SeekBackward()));
|
connect(ui_->playlist->view(), SIGNAL(SeekBackward()), app_->player(), SLOT(SeekBackward()));
|
||||||
connect(ui_->playlist->view(), SIGNAL(BackgroundPropertyChanged()), SLOT(RefreshStyleSheet()));
|
connect(ui_->playlist->view(), SIGNAL(BackgroundPropertyChanged()), SLOT(RefreshStyleSheet()));
|
||||||
@@ -1411,7 +1411,7 @@ void MainWindow::UpdateTrackSliderPosition() {
|
|||||||
PlaylistItemPtr item(app_->player()->GetCurrentItem());
|
PlaylistItemPtr item(app_->player()->GetCurrentItem());
|
||||||
|
|
||||||
const int slider_position = std::floor(float(app_->player()->engine()->position_nanosec()) / kNsecPerMsec);
|
const int slider_position = std::floor(float(app_->player()->engine()->position_nanosec()) / kNsecPerMsec);
|
||||||
const int slider_length =app_->player()->engine()->length_nanosec() / kNsecPerMsec;
|
const int slider_length = app_->player()->engine()->length_nanosec() / kNsecPerMsec;
|
||||||
|
|
||||||
// Update the slider
|
// Update the slider
|
||||||
ui_->track_slider->SetValue(slider_position, slider_length);
|
ui_->track_slider->SetValue(slider_position, slider_length);
|
||||||
@@ -1491,7 +1491,7 @@ void MainWindow::AddToPlaylist(QAction *action) {
|
|||||||
int destination = action->data().toInt();
|
int destination = action->data().toInt();
|
||||||
PlaylistItemList items;
|
PlaylistItemList items;
|
||||||
|
|
||||||
// get the selected playlist items
|
// Get the selected playlist items
|
||||||
for (const QModelIndex &index : ui_->playlist->view()->selectionModel()->selection().indexes()) {
|
for (const QModelIndex &index : ui_->playlist->view()->selectionModel()->selection().indexes()) {
|
||||||
if (index.column() != 0) continue;
|
if (index.column() != 0) continue;
|
||||||
int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row();
|
int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row();
|
||||||
@@ -1503,21 +1503,21 @@ void MainWindow::AddToPlaylist(QAction *action) {
|
|||||||
songs << item->Metadata();
|
songs << item->Metadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
// we're creating a new playlist
|
// We're creating a new playlist
|
||||||
if (destination == -1) {
|
if (destination == -1) {
|
||||||
// save the current playlist to reactivate it
|
// Save the current playlist to reactivate it
|
||||||
int current_id = app_->playlist_manager()->current_id();
|
int current_id = app_->playlist_manager()->current_id();
|
||||||
// get the name from selection
|
// get the name from selection
|
||||||
app_->playlist_manager()->New(app_->playlist_manager()->GetNameForNewPlaylist(songs));
|
app_->playlist_manager()->New(app_->playlist_manager()->GetNameForNewPlaylist(songs));
|
||||||
if (app_->playlist_manager()->current()->id() != current_id) {
|
if (app_->playlist_manager()->current()->id() != current_id) {
|
||||||
//I'm sure the new playlist was created and is selected, so I can just insert items
|
// I'm sure the new playlist was created and is selected, so I can just insert items
|
||||||
app_->playlist_manager()->current()->InsertItems(items);
|
app_->playlist_manager()->current()->InsertItems(items);
|
||||||
// set back the current playlist
|
// Set back the current playlist
|
||||||
app_->playlist_manager()->SetCurrentPlaylist(current_id);
|
app_->playlist_manager()->SetCurrentPlaylist(current_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// we're inserting in a existing playlist
|
// We're inserting in a existing playlist
|
||||||
app_->playlist_manager()->playlist(destination)->InsertItems(items);
|
app_->playlist_manager()->playlist(destination)->InsertItems(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1674,7 +1674,7 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex
|
|||||||
ui_->action_edit_value->setVisible(ui_->action_edit_value->isVisible() && column_is_editable);
|
ui_->action_edit_value->setVisible(ui_->action_edit_value->isVisible() && column_is_editable);
|
||||||
|
|
||||||
QString column_name = Playlist::column_name(column);
|
QString column_name = Playlist::column_name(column);
|
||||||
QString column_value =app_->playlist_manager()->current()->data(source_index).toString();
|
QString column_value = app_->playlist_manager()->current()->data(source_index).toString();
|
||||||
if (column_value.length() > 25) column_value = column_value.left(25) + "...";
|
if (column_value.length() > 25) column_value = column_value.left(25) + "...";
|
||||||
|
|
||||||
ui_->action_selection_set_value->setText(tr("Set %1 to \"%2\"...").arg(column_name.toLower()).arg(column_value));
|
ui_->action_selection_set_value->setText(tr("Set %1 to \"%2\"...").arg(column_name.toLower()).arg(column_value));
|
||||||
@@ -1741,12 +1741,14 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PlaylistPlay() {
|
void MainWindow::PlaylistPlay() {
|
||||||
if (app_->playlist_manager()->current()->current_row() ==playlist_menu_index_.row()) {
|
|
||||||
|
if (app_->playlist_manager()->current()->current_row() == playlist_menu_index_.row()) {
|
||||||
app_->player()->PlayPause();
|
app_->player()->PlayPause();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PlayIndex(playlist_menu_index_);
|
PlayIndex(playlist_menu_index_);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PlaylistStopAfter() {
|
void MainWindow::PlaylistStopAfter() {
|
||||||
@@ -1756,18 +1758,19 @@ void MainWindow::PlaylistStopAfter() {
|
|||||||
void MainWindow::RescanSongs() {
|
void MainWindow::RescanSongs() {
|
||||||
|
|
||||||
SongList songs;
|
SongList songs;
|
||||||
PlaylistItemList items;
|
|
||||||
|
|
||||||
for (const QModelIndex& index : ui_->playlist->view()->selectionModel()->selection().indexes()) {
|
for (const QModelIndex& index : ui_->playlist->view()->selectionModel()->selection().indexes()) {
|
||||||
if (index.column() != 0) continue;
|
if (index.column() != 0) continue;
|
||||||
int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row();
|
const int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row();
|
||||||
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(row));
|
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(row));
|
||||||
|
if (!item) continue;
|
||||||
Song song = item->Metadata();
|
Song song = item->Metadata();
|
||||||
|
if (!song.is_valid() || song.source() != Song::Source_Collection) continue;
|
||||||
songs << song;
|
songs << song;
|
||||||
items << item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (songs.isEmpty()) return;
|
||||||
|
|
||||||
app_->collection()->Rescan(songs);
|
app_->collection()->Rescan(songs);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1777,18 +1780,22 @@ void MainWindow::EditTracks() {
|
|||||||
SongList songs;
|
SongList songs;
|
||||||
PlaylistItemList items;
|
PlaylistItemList items;
|
||||||
|
|
||||||
for (const QModelIndex &index : ui_->playlist->view()->selectionModel()->selection().indexes()) {
|
for (const QModelIndex &idx : ui_->playlist->view()->selectionModel()->selection().indexes()) {
|
||||||
if (index.column() != 0) continue;
|
if (idx.column() != 0) continue;
|
||||||
int row =app_->playlist_manager()->current()->proxy()->mapToSource(index).row();
|
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(idx);
|
||||||
|
if (!source_index.isValid()) continue;
|
||||||
|
const int row = source_index.row();
|
||||||
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(row));
|
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(row));
|
||||||
|
if (!item) continue;
|
||||||
Song song = item->Metadata();
|
Song song = item->Metadata();
|
||||||
|
|
||||||
if (song.IsEditable()) {
|
if (song.IsEditable()) {
|
||||||
songs << song;
|
songs << song;
|
||||||
items << item;
|
items << item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (items.isEmpty()) return;
|
||||||
|
|
||||||
edit_tag_dialog_->SetSongs(songs, items);
|
edit_tag_dialog_->SetSongs(songs, items);
|
||||||
edit_tag_dialog_->show();
|
edit_tag_dialog_->show();
|
||||||
|
|
||||||
@@ -1825,8 +1832,8 @@ void MainWindow::RenumberTracks() {
|
|||||||
for (const QModelIndex &index : indexes) {
|
for (const QModelIndex &index : indexes) {
|
||||||
if (index.column() != 0) continue;
|
if (index.column() != 0) continue;
|
||||||
|
|
||||||
const QModelIndex source_index =app_->playlist_manager()->current()->proxy()->mapToSource(index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(index);
|
||||||
int row = source_index.row();
|
const int row = source_index.row();
|
||||||
Song song = app_->playlist_manager()->current()->item_at(row)->Metadata();
|
Song song = app_->playlist_manager()->current()->item_at(row)->Metadata();
|
||||||
|
|
||||||
if (song.IsEditable()) {
|
if (song.IsEditable()) {
|
||||||
@@ -1855,13 +1862,13 @@ void MainWindow::SelectionSetValue() {
|
|||||||
Playlist::Column column = (Playlist::Column)playlist_menu_index_.column();
|
Playlist::Column column = (Playlist::Column)playlist_menu_index_.column();
|
||||||
QVariant column_value = app_->playlist_manager()->current()->data(playlist_menu_index_);
|
QVariant column_value = app_->playlist_manager()->current()->data(playlist_menu_index_);
|
||||||
|
|
||||||
QModelIndexList indexes =ui_->playlist->view()->selectionModel()->selection().indexes();
|
QModelIndexList indexes = ui_->playlist->view()->selectionModel()->selection().indexes();
|
||||||
|
|
||||||
for (const QModelIndex &index : indexes) {
|
for (const QModelIndex &index : indexes) {
|
||||||
if (index.column() != 0) continue;
|
if (index.column() != 0) continue;
|
||||||
|
|
||||||
const QModelIndex source_index =app_->playlist_manager()->current()->proxy()->mapToSource(index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(index);
|
||||||
int row = source_index.row();
|
const int row = source_index.row();
|
||||||
Song song = app_->playlist_manager()->current()->item_at(row)->Metadata();
|
Song song = app_->playlist_manager()->current()->item_at(row)->Metadata();
|
||||||
|
|
||||||
if (Playlist::set_column_value(song, column, column_value)) {
|
if (Playlist::set_column_value(song, column, column_value)) {
|
||||||
@@ -1941,11 +1948,13 @@ void MainWindow::AddFolder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddCDTracks() {
|
void MainWindow::AddCDTracks() {
|
||||||
|
|
||||||
MimeData *data = new MimeData;
|
MimeData *data = new MimeData;
|
||||||
// We are putting empty data, but we specify cdda mimetype to indicate that we want to load audio cd tracks
|
// We are putting empty data, but we specify cdda mimetype to indicate that we want to load audio cd tracks
|
||||||
data->open_in_new_playlist_ = true;
|
data->open_in_new_playlist_ = true;
|
||||||
data->setData(Playlist::kCddaMimeType, QByteArray());
|
data->setData(Playlist::kCddaMimeType, QByteArray());
|
||||||
AddToPlaylist(data);
|
AddToPlaylist(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ShowInCollection() {
|
void MainWindow::ShowInCollection() {
|
||||||
@@ -1955,7 +1964,7 @@ void MainWindow::ShowInCollection() {
|
|||||||
SongList songs;
|
SongList songs;
|
||||||
|
|
||||||
for (const QModelIndex &proxy_index : proxy_indexes) {
|
for (const QModelIndex &proxy_index : proxy_indexes) {
|
||||||
QModelIndex index =app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
||||||
if (app_->playlist_manager()->current()->item_at(index.row())->IsLocalCollectionItem()) {
|
if (app_->playlist_manager()->current()->item_at(index.row())->IsLocalCollectionItem()) {
|
||||||
songs << app_->playlist_manager()->current()->item_at(index.row())->Metadata();
|
songs << app_->playlist_manager()->current()->item_at(index.row())->Metadata();
|
||||||
break;
|
break;
|
||||||
@@ -1966,6 +1975,7 @@ void MainWindow::ShowInCollection() {
|
|||||||
search ="artist:" + songs.first().artist() + " album:" + songs.first().album();
|
search ="artist:" + songs.first().artist() + " album:" + songs.first().album();
|
||||||
}
|
}
|
||||||
collection_view_->filter()->ShowInCollection(search);
|
collection_view_->filter()->ShowInCollection(search);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PlaylistRemoveCurrent() {
|
void MainWindow::PlaylistRemoveCurrent() {
|
||||||
@@ -2100,6 +2110,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
|||||||
if (options.show_osd()) app_->player()->ShowOSD();
|
if (options.show_osd()) app_->player()->ShowOSD();
|
||||||
|
|
||||||
if (options.toggle_pretty_osd()) app_->player()->TogglePrettyOSD();
|
if (options.toggle_pretty_osd()) app_->player()->TogglePrettyOSD();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ForceShowOSD(const Song &song, const bool toggle) {
|
void MainWindow::ForceShowOSD(const Song &song, const bool toggle) {
|
||||||
@@ -2126,6 +2137,7 @@ bool MainWindow::LoadUrl(const QString &url) {
|
|||||||
AddToPlaylist(data);
|
AddToPlaylist(data);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::CheckForUpdates() {
|
void MainWindow::CheckForUpdates() {
|
||||||
@@ -2148,12 +2160,16 @@ void MainWindow::AddFilesToTranscoder() {
|
|||||||
|
|
||||||
for (const QModelIndex &index : ui_->playlist->view()->selectionModel()->selection().indexes()) {
|
for (const QModelIndex &index : ui_->playlist->view()->selectionModel()->selection().indexes()) {
|
||||||
if (index.column() != 0) continue;
|
if (index.column() != 0) continue;
|
||||||
int row =app_->playlist_manager()->current()->proxy()->mapToSource(index).row();
|
const int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row();
|
||||||
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(row));
|
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(row));
|
||||||
|
if (!item) continue;
|
||||||
Song song = item->Metadata();
|
Song song = item->Metadata();
|
||||||
|
if (!song.is_valid()) continue;
|
||||||
filenames << song.url().toLocalFile();
|
filenames << song.url().toLocalFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filenames.isEmpty()) return;
|
||||||
|
|
||||||
transcode_dialog_->SetFilenames(filenames);
|
transcode_dialog_->SetFilenames(filenames);
|
||||||
|
|
||||||
ShowTranscodeDialog();
|
ShowTranscodeDialog();
|
||||||
@@ -2184,23 +2200,29 @@ void MainWindow::PlayingWidgetPositionChanged(bool above_status_bar) {
|
|||||||
|
|
||||||
ui_->status_bar->parentWidget()->layout()->addWidget(ui_->status_bar);
|
ui_->status_bar->parentWidget()->layout()->addWidget(ui_->status_bar);
|
||||||
ui_->status_bar->show();
|
ui_->status_bar->show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::CopyFilesToCollection(const QList<QUrl> &urls) {
|
void MainWindow::CopyFilesToCollection(const QList<QUrl> &urls) {
|
||||||
|
|
||||||
organise_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
organise_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
||||||
organise_dialog_->SetUrls(urls);
|
organise_dialog_->SetUrls(urls);
|
||||||
organise_dialog_->SetCopy(true);
|
organise_dialog_->SetCopy(true);
|
||||||
organise_dialog_->show();
|
organise_dialog_->show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MoveFilesToCollection(const QList<QUrl> &urls) {
|
void MainWindow::MoveFilesToCollection(const QList<QUrl> &urls) {
|
||||||
|
|
||||||
organise_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
organise_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
||||||
organise_dialog_->SetUrls(urls);
|
organise_dialog_->SetUrls(urls);
|
||||||
organise_dialog_->SetCopy(false);
|
organise_dialog_->SetCopy(false);
|
||||||
organise_dialog_->show();
|
organise_dialog_->show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::CopyFilesToDevice(const QList<QUrl> &urls) {
|
void MainWindow::CopyFilesToDevice(const QList<QUrl> &urls) {
|
||||||
|
|
||||||
#if defined(HAVE_GSTREAMER) && !defined(Q_OS_WIN)
|
#if defined(HAVE_GSTREAMER) && !defined(Q_OS_WIN)
|
||||||
organise_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
organise_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
||||||
organise_dialog_->SetCopy(true);
|
organise_dialog_->SetCopy(true);
|
||||||
@@ -2212,6 +2234,7 @@ void MainWindow::CopyFilesToDevice(const QList<QUrl> &urls) {
|
|||||||
#else
|
#else
|
||||||
Q_UNUSED(urls);
|
Q_UNUSED(urls);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::EditFileTags(const QList<QUrl> &urls) {
|
void MainWindow::EditFileTags(const QList<QUrl> &urls) {
|
||||||
@@ -2227,6 +2250,7 @@ void MainWindow::EditFileTags(const QList<QUrl> &urls) {
|
|||||||
|
|
||||||
edit_tag_dialog_->SetSongs(songs);
|
edit_tag_dialog_->SetSongs(songs);
|
||||||
edit_tag_dialog_->show();
|
edit_tag_dialog_->show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PlaylistCopyToCollection() {
|
void MainWindow::PlaylistCopyToCollection() {
|
||||||
@@ -2237,20 +2261,24 @@ void MainWindow::PlaylistMoveToCollection() {
|
|||||||
PlaylistOrganiseSelected(false);
|
PlaylistOrganiseSelected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PlaylistOrganiseSelected(bool copy) {
|
void MainWindow::PlaylistOrganiseSelected(const bool copy) {
|
||||||
|
|
||||||
QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
|
QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
|
||||||
SongList songs;
|
SongList songs;
|
||||||
|
|
||||||
for (const QModelIndex &proxy_index : proxy_indexes) {
|
for (const QModelIndex &proxy_index : proxy_indexes) {
|
||||||
QModelIndex index =app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
||||||
songs << app_->playlist_manager()->current()->item_at(index.row())->Metadata();
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(index.row());
|
||||||
|
if (!item) continue;
|
||||||
|
songs << item->Metadata();
|
||||||
}
|
}
|
||||||
|
if (songs.isEmpty()) return;
|
||||||
|
|
||||||
organise_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
organise_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
||||||
organise_dialog_->SetSongs(songs);
|
organise_dialog_->SetSongs(songs);
|
||||||
organise_dialog_->SetCopy(copy);
|
organise_dialog_->SetCopy(copy);
|
||||||
organise_dialog_->show();
|
organise_dialog_->show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PlaylistOpenInBrowser() {
|
void MainWindow::PlaylistOpenInBrowser() {
|
||||||
@@ -2275,15 +2303,18 @@ void MainWindow::PlaylistQueue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app_->playlist_manager()->current()->queue()->ToggleTracks(indexes);
|
app_->playlist_manager()->current()->queue()->ToggleTracks(indexes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PlaylistQueuePlayNext() {
|
void MainWindow::PlaylistQueuePlayNext() {
|
||||||
|
|
||||||
QModelIndexList indexes;
|
QModelIndexList indexes;
|
||||||
for (const QModelIndex& proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex& proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
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() {
|
void MainWindow::PlaylistSkip() {
|
||||||
@@ -2299,14 +2330,20 @@ void MainWindow::PlaylistSkip() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PlaylistCopyToDevice() {
|
void MainWindow::PlaylistCopyToDevice() {
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
|
QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
|
||||||
SongList songs;
|
SongList songs;
|
||||||
|
|
||||||
for (const QModelIndex &proxy_index : proxy_indexes) {
|
for (const QModelIndex &proxy_index : proxy_indexes) {
|
||||||
QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
||||||
songs << app_->playlist_manager()->current()->item_at(index.row())->Metadata();
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
||||||
|
if (!item) continue;
|
||||||
|
Song song = item->Metadata();
|
||||||
|
if (!song.is_valid()) continue;
|
||||||
|
songs << song;
|
||||||
}
|
}
|
||||||
|
if (songs.isEmpty()) return;
|
||||||
|
|
||||||
organise_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
organise_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
||||||
organise_dialog_->SetCopy(true);
|
organise_dialog_->SetCopy(true);
|
||||||
@@ -2316,9 +2353,11 @@ void MainWindow::PlaylistCopyToDevice() {
|
|||||||
QMessageBox::warning(this, tr("Error"), tr("None of the selected songs were suitable for copying to a device"));
|
QMessageBox::warning(this, tr("Error"), tr("None of the selected songs were suitable for copying to a device"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ChangeCollectionQueryMode(QAction *action) {
|
void MainWindow::ChangeCollectionQueryMode(QAction *action) {
|
||||||
|
|
||||||
if (action == collection_show_duplicates_) {
|
if (action == collection_show_duplicates_) {
|
||||||
collection_view_->filter()->SetQueryMode(QueryOptions::QueryMode_Duplicates);
|
collection_view_->filter()->SetQueryMode(QueryOptions::QueryMode_Duplicates);
|
||||||
}
|
}
|
||||||
@@ -2328,6 +2367,7 @@ void MainWindow::ChangeCollectionQueryMode(QAction *action) {
|
|||||||
else {
|
else {
|
||||||
collection_view_->filter()->SetQueryMode(QueryOptions::QueryMode_All);
|
collection_view_->filter()->SetQueryMode(QueryOptions::QueryMode_All);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ShowCoverManager() {
|
void MainWindow::ShowCoverManager() {
|
||||||
@@ -2426,11 +2466,12 @@ void MainWindow::CheckFullRescanRevisions() {
|
|||||||
void MainWindow::PlaylistViewSelectionModelChanged() {
|
void MainWindow::PlaylistViewSelectionModelChanged() {
|
||||||
|
|
||||||
connect(ui_->playlist->view()->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(PlaylistCurrentChanged(QModelIndex)));
|
connect(ui_->playlist->view()->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(PlaylistCurrentChanged(QModelIndex)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PlaylistCurrentChanged(const QModelIndex &proxy_current) {
|
void MainWindow::PlaylistCurrentChanged(const QModelIndex &proxy_current) {
|
||||||
|
|
||||||
const QModelIndex source_current =app_->playlist_manager()->current()->proxy()->mapToSource(proxy_current);
|
const QModelIndex source_current = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_current);
|
||||||
|
|
||||||
// If the user moves the current index using the keyboard and then presses
|
// If the user moves the current index using the keyboard and then presses
|
||||||
// F2, we don't want that editing the last column that was right clicked on.
|
// F2, we don't want that editing the last column that was right clicked on.
|
||||||
@@ -2481,16 +2522,19 @@ void MainWindow::AutoCompleteTags() {
|
|||||||
autocomplete_tag_items_.clear();
|
autocomplete_tag_items_.clear();
|
||||||
for (const QModelIndex &index : ui_->playlist->view()->selectionModel()->selection().indexes()) {
|
for (const QModelIndex &index : ui_->playlist->view()->selectionModel()->selection().indexes()) {
|
||||||
if (index.column() != 0) continue;
|
if (index.column() != 0) continue;
|
||||||
int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row();
|
const QModelIndex &source_index = app_->playlist_manager()->current()->proxy()->mapToSource(index);
|
||||||
|
const int row = source_index.row();
|
||||||
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(row));
|
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(row));
|
||||||
|
if (!item) continue;
|
||||||
Song song = item->Metadata();
|
Song song = item->Metadata();
|
||||||
|
|
||||||
if (song.IsEditable()) {
|
if (song.IsEditable()) {
|
||||||
songs << song;
|
songs << song;
|
||||||
autocomplete_tag_items_ << item;
|
autocomplete_tag_items_ << item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (songs.isEmpty()) return;
|
||||||
|
|
||||||
track_selection_dialog_->Init(songs);
|
track_selection_dialog_->Init(songs);
|
||||||
tag_fetcher_->StartFetch(songs);
|
tag_fetcher_->StartFetch(songs);
|
||||||
|
|
||||||
@@ -2505,6 +2549,7 @@ void MainWindow::AutoCompleteTagsAccepted() {
|
|||||||
for (const PlaylistItemPtr item : autocomplete_tag_items_) {
|
for (const PlaylistItemPtr item : autocomplete_tag_items_) {
|
||||||
item->Reload();
|
item->Reload();
|
||||||
}
|
}
|
||||||
|
autocomplete_tag_items_.clear();
|
||||||
|
|
||||||
// This is really lame but we don't know what rows have changed
|
// This is really lame but we don't know what rows have changed
|
||||||
ui_->playlist->view()->update();
|
ui_->playlist->view()->update();
|
||||||
@@ -2520,7 +2565,7 @@ void MainWindow::HandleNotificationPreview(OSD::Behaviour type, QString line1, Q
|
|||||||
else {
|
else {
|
||||||
qLog(Debug) << "The current playlist is empty, showing a fake song";
|
qLog(Debug) << "The current playlist is empty, showing a fake song";
|
||||||
// Create a fake song
|
// Create a fake song
|
||||||
Song fake;
|
Song fake(Song::Source_LocalFile);
|
||||||
fake.Init("Title", "Artist", "Album", 123);
|
fake.Init("Title", "Artist", "Album", 123);
|
||||||
fake.set_genre("Classical");
|
fake.set_genre("Classical");
|
||||||
fake.set_composer("Anonymous");
|
fake.set_composer("Anonymous");
|
||||||
@@ -2540,6 +2585,7 @@ void MainWindow::ShowConsole() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::keyPressEvent(QKeyEvent *event) {
|
void MainWindow::keyPressEvent(QKeyEvent *event) {
|
||||||
|
|
||||||
if (event->key() == Qt::Key_Space) {
|
if (event->key() == Qt::Key_Space) {
|
||||||
app_->player()->PlayPause();
|
app_->player()->PlayPause();
|
||||||
event->accept();
|
event->accept();
|
||||||
@@ -2555,6 +2601,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) {
|
|||||||
else {
|
else {
|
||||||
QMainWindow::keyPressEvent(event);
|
QMainWindow::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::LoadCoverFromFile() {
|
void MainWindow::LoadCoverFromFile() {
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
|||||||
void PlaylistCopyToCollection();
|
void PlaylistCopyToCollection();
|
||||||
void PlaylistMoveToCollection();
|
void PlaylistMoveToCollection();
|
||||||
void PlaylistCopyToDevice();
|
void PlaylistCopyToDevice();
|
||||||
void PlaylistOrganiseSelected(bool copy);
|
void PlaylistOrganiseSelected(const bool copy);
|
||||||
void PlaylistOpenInBrowser();
|
void PlaylistOpenInBrowser();
|
||||||
void ShowInCollection();
|
void ShowInCollection();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user