mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 03:09:57 +01:00
Menu option to set all fields from selected tracks to the same value. Thanks christoph.gysin. Fixes issue #102
This commit is contained in:
parent
4176251892
commit
821e524b5f
@ -131,6 +131,7 @@ MainWindow::MainWindow(QNetworkAccessManager* network, QWidget *parent)
|
||||
connect(ui_.action_clear_playlist, SIGNAL(triggered()), playlist_, SLOT(Clear()));
|
||||
connect(ui_.action_edit_track, SIGNAL(triggered()), SLOT(EditTracks()));
|
||||
connect(ui_.action_renumber_tracks, SIGNAL(triggered()), SLOT(RenumberTracks()));
|
||||
connect(ui_.action_selection_set_value, SIGNAL(triggered()), SLOT(SelectionSetValue()));
|
||||
connect(ui_.action_configure, SIGNAL(triggered()), settings_dialog_, SLOT(show()));
|
||||
connect(ui_.action_about, SIGNAL(triggered()), about_dialog_, SLOT(show()));
|
||||
connect(ui_.action_shuffle, SIGNAL(triggered()), playlist_, SLOT(Shuffle()));
|
||||
@ -236,8 +237,10 @@ MainWindow::MainWindow(QNetworkAccessManager* network, QWidget *parent)
|
||||
playlist_play_pause_ = playlist_menu_->addAction(tr("Play"), this, SLOT(PlaylistPlay()));
|
||||
playlist_menu_->addAction(ui_.action_stop);
|
||||
playlist_stop_after_ = playlist_menu_->addAction(QIcon(":media-playback-stop.png"), tr("Stop after this track"), this, SLOT(PlaylistStopAfter()));
|
||||
playlist_menu_->addSeparator();
|
||||
playlist_menu_->addAction(ui_.action_edit_track);
|
||||
playlist_menu_->addAction(ui_.action_renumber_tracks);
|
||||
playlist_menu_->addAction(ui_.action_selection_set_value);
|
||||
playlist_menu_->addSeparator();
|
||||
playlist_menu_->addAction(ui_.action_clear_playlist);
|
||||
playlist_menu_->addAction(ui_.action_shuffle);
|
||||
@ -569,18 +572,28 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex&
|
||||
playlist_stop_after_->setEnabled(index.isValid());
|
||||
|
||||
// Are any of the selected songs editable?
|
||||
bool editable = false;
|
||||
int editable = 0;
|
||||
foreach (const QModelIndex& index,
|
||||
ui_.playlist->selectionModel()->selection().indexes()) {
|
||||
if (index.column() != 0)
|
||||
continue;
|
||||
if (playlist_->item_at(index.row())->Metadata().IsEditable()) {
|
||||
editable = true;
|
||||
break;
|
||||
editable++;
|
||||
}
|
||||
}
|
||||
ui_.action_edit_track->setEnabled(editable);
|
||||
ui_.action_renumber_tracks->setEnabled(editable);
|
||||
ui_.action_selection_set_value->setEnabled(editable >= 2);
|
||||
|
||||
Playlist::Column column = (Playlist::Column)playlist_menu_index_.column();
|
||||
ui_.action_selection_set_value->setVisible(
|
||||
column <= Playlist::Column_Genre &&
|
||||
column != Playlist::Column_Length);
|
||||
|
||||
QString column_name = Playlist::column_name(column);
|
||||
QString column_value = playlist_->data(playlist_menu_index_).toString();
|
||||
ui_.action_selection_set_value->setText(tr("Set %1 to \"%2\"...")
|
||||
.arg(column_name.toLower()).arg(column_value));
|
||||
|
||||
playlist_menu_->popup(global_pos);
|
||||
}
|
||||
@ -647,6 +660,54 @@ void MainWindow::RenumberTracks() {
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::SelectionSetValue() {
|
||||
Playlist::Column column = (Playlist::Column)playlist_menu_index_.column();
|
||||
QVariant column_value = playlist_->data(playlist_menu_index_);
|
||||
|
||||
QModelIndexList indexes=ui_.playlist->selectionModel()->selection().indexes();
|
||||
foreach (const QModelIndex& index, indexes) {
|
||||
if (index.column() != 0)
|
||||
continue;
|
||||
|
||||
int row = index.row();
|
||||
Song song = playlist_->item_at(row)->Metadata();
|
||||
|
||||
if (song.IsEditable()) {
|
||||
switch(column) {
|
||||
case Playlist::Column_Title:
|
||||
song.set_title(column_value.toString());
|
||||
break;
|
||||
case Playlist::Column_Artist:
|
||||
song.set_artist(column_value.toString());
|
||||
break;
|
||||
case Playlist::Column_Album:
|
||||
song.set_album(column_value.toString());
|
||||
break;
|
||||
case Playlist::Column_AlbumArtist:
|
||||
song.set_albumartist(column_value.toString());
|
||||
break;
|
||||
case Playlist::Column_Composer:
|
||||
song.set_composer(column_value.toString());
|
||||
break;
|
||||
case Playlist::Column_Track:
|
||||
song.set_track(column_value.toInt());
|
||||
break;
|
||||
case Playlist::Column_Disc:
|
||||
song.set_disc(column_value.toInt());
|
||||
break;
|
||||
case Playlist::Column_Year:
|
||||
song.set_year(column_value.toInt());
|
||||
break;
|
||||
case Playlist::Column_Genre:
|
||||
song.set_genre(column_value.toString());
|
||||
break;
|
||||
}
|
||||
song.Save();
|
||||
playlist_->item_at(row)->Reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::LibraryScanStarted() {
|
||||
multi_loading_indicator_->TaskStarted(MultiLoadingIndicator::UpdatingLibrary);
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ class MainWindow : public QMainWindow {
|
||||
void PlaylistStopAfter();
|
||||
void EditTracks();
|
||||
void RenumberTracks();
|
||||
void SelectionSetValue();
|
||||
|
||||
void PlayIndex(const QModelIndex& index);
|
||||
void StopAfterCurrent();
|
||||
|
@ -656,14 +656,15 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_renumber_tracks">
|
||||
<property name="icon">
|
||||
<iconset resource="../data/data.qrc">
|
||||
<normaloff>:/edit-track.png</normaloff>:/edit-track.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Renumber tracks in this order...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_selection_set_value">
|
||||
<property name="text">
|
||||
<string>Set value for all selected tracks...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_configure">
|
||||
<property name="icon">
|
||||
<iconset resource="../data/data.qrc">
|
||||
|
@ -57,28 +57,9 @@ QVariant Playlist::headerData(int section, Qt::Orientation, int role) const {
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
switch (section) {
|
||||
case Column_Title: return tr("Title");
|
||||
case Column_Artist: return tr("Artist");
|
||||
case Column_Album: return tr("Album");
|
||||
case Column_Length: return tr("Length");
|
||||
case Column_Track: return tr("Track");
|
||||
case Column_Disc: return tr("Disc");
|
||||
case Column_Year: return tr("Year");
|
||||
case Column_Genre: return tr("Genre");
|
||||
case Column_AlbumArtist: return tr("Album artist");
|
||||
case Column_Composer: return tr("Composer");
|
||||
|
||||
case Column_BPM: return tr("BPM");
|
||||
case Column_Bitrate: return tr("Bit rate");
|
||||
case Column_Samplerate: return tr("Sample rate");
|
||||
case Column_Filename: return tr("File name");
|
||||
case Column_BaseFilename: return tr("File name (without path)");
|
||||
case Column_Filesize: return tr("File size");
|
||||
case Column_Filetype: return tr("File type");
|
||||
case Column_DateModified: return tr("Date modified");
|
||||
case Column_DateCreated: return tr("Date created");
|
||||
}
|
||||
QString name = column_name((Playlist::Column)section);
|
||||
if(name.size())
|
||||
return name;
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
@ -468,6 +449,32 @@ bool Playlist::CompareItems(int column, Qt::SortOrder order,
|
||||
return false;
|
||||
}
|
||||
|
||||
QString Playlist::column_name(Column column) {
|
||||
switch (column) {
|
||||
case Column_Title: return tr("Title");
|
||||
case Column_Artist: return tr("Artist");
|
||||
case Column_Album: return tr("Album");
|
||||
case Column_Length: return tr("Length");
|
||||
case Column_Track: return tr("Track");
|
||||
case Column_Disc: return tr("Disc");
|
||||
case Column_Year: return tr("Year");
|
||||
case Column_Genre: return tr("Genre");
|
||||
case Column_AlbumArtist: return tr("Album artist");
|
||||
case Column_Composer: return tr("Composer");
|
||||
|
||||
case Column_BPM: return tr("BPM");
|
||||
case Column_Bitrate: return tr("Bit rate");
|
||||
case Column_Samplerate: return tr("Sample rate");
|
||||
case Column_Filename: return tr("File name");
|
||||
case Column_BaseFilename: return tr("File name (without path)");
|
||||
case Column_Filesize: return tr("File size");
|
||||
case Column_Filetype: return tr("File type");
|
||||
case Column_DateModified: return tr("Date modified");
|
||||
case Column_DateCreated: return tr("Date created");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void Playlist::sort(int column, Qt::SortOrder order) {
|
||||
if (ignore_sorting_)
|
||||
return;
|
||||
|
@ -71,6 +71,8 @@ class Playlist : public QAbstractListModel {
|
||||
static bool CompareItems(int column, Qt::SortOrder order,
|
||||
const PlaylistItem* a, const PlaylistItem* b);
|
||||
|
||||
static QString column_name(Column column);
|
||||
|
||||
// Persistence
|
||||
void Save() const;
|
||||
void Restore();
|
||||
|
Loading…
Reference in New Issue
Block a user