2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 00:11:46 +01:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-01-16 17:12:47 +01:00
|
|
|
#ifndef EDITTAGDIALOG_H
|
|
|
|
#define EDITTAGDIALOG_H
|
|
|
|
|
|
|
|
#include <QDialog>
|
2010-12-20 00:40:36 +01:00
|
|
|
#include <QModelIndexList>
|
2010-01-16 17:12:47 +01:00
|
|
|
|
2010-12-26 13:42:47 +01:00
|
|
|
#include "config.h"
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "core/song.h"
|
2012-02-13 21:44:04 +01:00
|
|
|
#include "covers/albumcoverloaderoptions.h"
|
2011-03-12 22:19:41 +01:00
|
|
|
#include "musicbrainz/tagfetcher.h"
|
2010-12-21 14:42:06 +01:00
|
|
|
#include "playlist/playlistitem.h"
|
2011-01-21 00:42:28 +01:00
|
|
|
#include "trackselectiondialog.h"
|
2020-09-18 16:15:19 +02:00
|
|
|
#include "widgets/lineedit.h"
|
2010-01-16 17:12:47 +01:00
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
class Application;
|
2011-01-24 01:09:57 +01:00
|
|
|
class AlbumCoverChoiceController;
|
2010-05-09 02:10:26 +02:00
|
|
|
class LibraryBackend;
|
2010-05-10 23:50:31 +02:00
|
|
|
class Ui_EditTagDialog;
|
2010-03-29 18:59:01 +02:00
|
|
|
|
2010-12-21 14:42:06 +01:00
|
|
|
class QAbstractButton;
|
2010-12-20 00:40:36 +01:00
|
|
|
class QItemSelection;
|
2010-12-20 15:12:40 +01:00
|
|
|
class QLabel;
|
2010-12-20 17:36:16 +01:00
|
|
|
class QPushButton;
|
2010-12-20 00:40:36 +01:00
|
|
|
|
2010-01-16 17:12:47 +01:00
|
|
|
class EditTagDialog : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
EditTagDialog(Application* app, QWidget* parent = nullptr);
|
2010-05-10 23:50:31 +02:00
|
|
|
~EditTagDialog();
|
2010-01-16 17:12:47 +01:00
|
|
|
|
2010-04-27 19:19:07 +02:00
|
|
|
static const char* kHintText;
|
2011-11-27 21:36:54 +01:00
|
|
|
static const char* kSettingsGroup;
|
2010-04-27 19:19:07 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void SetSongs(const SongList& songs,
|
|
|
|
const PlaylistItemList& items = PlaylistItemList());
|
2010-01-16 17:12:47 +01:00
|
|
|
|
2010-12-21 14:42:06 +01:00
|
|
|
PlaylistItemList playlist_items() const { return playlist_items_; }
|
|
|
|
|
|
|
|
void accept();
|
|
|
|
|
2020-09-18 16:15:19 +02:00
|
|
|
signals:
|
2010-12-21 14:42:06 +01:00
|
|
|
void Error(const QString& message);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
2010-12-25 00:22:09 +01:00
|
|
|
bool eventFilter(QObject* o, QEvent* e);
|
2010-12-25 01:15:05 +01:00
|
|
|
void showEvent(QShowEvent*);
|
2011-11-27 21:36:54 +01:00
|
|
|
void hideEvent(QHideEvent*);
|
2010-12-25 00:22:09 +01:00
|
|
|
|
2015-11-27 15:22:59 +01:00
|
|
|
private:
|
|
|
|
struct Data {
|
|
|
|
Data(const Song& song = Song()) : original_(song), current_(song) {}
|
|
|
|
|
|
|
|
static QVariant value(const Song& song, const QString& id);
|
|
|
|
QVariant original_value(const QString& id) const {
|
|
|
|
return value(original_, id);
|
|
|
|
}
|
|
|
|
QVariant current_value(const QString& id) const {
|
|
|
|
return value(current_, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_value(const QString& id, const QVariant& value);
|
|
|
|
|
|
|
|
Song original_;
|
|
|
|
Song current_;
|
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2015-11-27 15:22:59 +01:00
|
|
|
void SetSongsFinished(QFuture<QList<EditTagDialog::Data>> future);
|
2010-12-21 14:42:06 +01:00
|
|
|
void AcceptFinished();
|
|
|
|
|
2010-12-20 00:40:36 +01:00
|
|
|
void SelectionChanged();
|
|
|
|
void FieldValueEdited();
|
|
|
|
void ResetField();
|
2010-12-21 14:42:06 +01:00
|
|
|
void ButtonClicked(QAbstractButton* button);
|
2010-12-25 01:33:53 +01:00
|
|
|
void SongRated(float rating);
|
2010-12-25 12:54:21 +01:00
|
|
|
void ResetPlayCounts();
|
2011-01-15 21:00:39 +01:00
|
|
|
void FetchTag();
|
2011-03-06 15:07:41 +01:00
|
|
|
void FetchTagSongChosen(const Song& original_song, const Song& new_metadata);
|
2010-01-16 17:12:47 +01:00
|
|
|
|
2011-02-02 17:22:04 +01:00
|
|
|
void ArtLoaded(quint64 id, const QImage& scaled, const QImage& original);
|
2010-12-20 15:12:40 +01:00
|
|
|
|
2010-12-20 16:46:38 +01:00
|
|
|
void LoadCoverFromFile();
|
2011-02-02 17:22:04 +01:00
|
|
|
void SaveCoverToFile();
|
2011-01-23 21:24:17 +01:00
|
|
|
void LoadCoverFromURL();
|
2011-01-24 01:09:57 +01:00
|
|
|
void SearchForCover();
|
2010-12-20 16:46:38 +01:00
|
|
|
void UnsetCover();
|
2011-01-24 01:09:57 +01:00
|
|
|
void ShowCover();
|
2010-12-20 16:46:38 +01:00
|
|
|
|
2010-12-20 17:36:16 +01:00
|
|
|
void PreviousSong();
|
|
|
|
void NextSong();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-12-20 00:40:36 +01:00
|
|
|
struct FieldData {
|
2014-02-21 17:24:49 +01:00
|
|
|
FieldData(QLabel* label = nullptr, QWidget* editor = nullptr,
|
2010-12-20 00:40:36 +01:00
|
|
|
const QString& id = QString())
|
2014-02-07 16:34:20 +01:00
|
|
|
: label_(label), editor_(editor), id_(id) {}
|
2010-01-16 17:12:47 +01:00
|
|
|
|
2010-12-20 00:40:36 +01:00
|
|
|
QLabel* label_;
|
|
|
|
QWidget* editor_;
|
|
|
|
QString id_;
|
|
|
|
};
|
|
|
|
|
2011-01-24 18:53:31 +01:00
|
|
|
Song* GetFirstSelected();
|
|
|
|
void UpdateCoverOf(const Song& selected, const QModelIndexList& sel,
|
|
|
|
const QString& cover);
|
2011-01-24 01:09:57 +01:00
|
|
|
|
2010-12-20 00:40:36 +01:00
|
|
|
bool DoesValueVary(const QModelIndexList& sel, const QString& id) const;
|
|
|
|
bool IsValueModified(const QModelIndexList& sel, const QString& id) const;
|
|
|
|
|
|
|
|
void InitFieldValue(const FieldData& field, const QModelIndexList& sel);
|
|
|
|
void UpdateFieldValue(const FieldData& field, const QModelIndexList& sel);
|
2016-01-04 18:56:28 +01:00
|
|
|
void UpdateModifiedField(const FieldData& field, const QModelIndexList& sel);
|
2010-12-20 00:40:36 +01:00
|
|
|
void ResetFieldValue(const FieldData& field, const QModelIndexList& sel);
|
|
|
|
|
2010-12-20 15:12:40 +01:00
|
|
|
void UpdateSummaryTab(const Song& song);
|
|
|
|
void UpdateStatisticsTab(const Song& song);
|
|
|
|
|
2016-02-09 21:56:22 +01:00
|
|
|
void UpdateUI(const QModelIndexList& sel);
|
|
|
|
|
2010-12-21 14:42:06 +01:00
|
|
|
bool SetLoading(const QString& message);
|
2012-01-29 19:44:00 +01:00
|
|
|
void SetSongListVisibility(bool visible);
|
2010-12-21 14:42:06 +01:00
|
|
|
|
|
|
|
// Called by QtConcurrentRun
|
|
|
|
QList<Data> LoadData(const SongList& songs) const;
|
|
|
|
void SaveData(const QList<Data>& data);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-12-20 00:40:36 +01:00
|
|
|
Ui_EditTagDialog* ui_;
|
2011-01-24 01:09:57 +01:00
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
Application* app_;
|
2011-01-24 01:09:57 +01:00
|
|
|
AlbumCoverChoiceController* album_cover_choice_controller_;
|
2011-01-23 21:24:17 +01:00
|
|
|
|
2010-12-21 14:42:06 +01:00
|
|
|
bool loading_;
|
|
|
|
|
|
|
|
PlaylistItemList playlist_items_;
|
2010-12-20 00:40:36 +01:00
|
|
|
QList<Data> data_;
|
|
|
|
QList<FieldData> fields_;
|
2010-08-02 17:07:26 +02:00
|
|
|
|
2010-12-20 00:40:36 +01:00
|
|
|
bool ignore_edits_;
|
2010-12-20 16:46:38 +01:00
|
|
|
|
2011-01-15 21:00:39 +01:00
|
|
|
TagFetcher* tag_fetcher_;
|
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
AlbumCoverLoaderOptions cover_options_;
|
2010-12-20 16:46:38 +01:00
|
|
|
quint64 cover_art_id_;
|
|
|
|
bool cover_art_is_set_;
|
|
|
|
|
2011-02-02 17:22:04 +01:00
|
|
|
// A copy of the original, unscaled album cover.
|
|
|
|
QImage original_;
|
|
|
|
|
2010-12-20 16:46:38 +01:00
|
|
|
QMenu* cover_menu_;
|
2011-01-24 01:09:57 +01:00
|
|
|
|
2010-12-20 17:36:16 +01:00
|
|
|
QPushButton* previous_button_;
|
|
|
|
QPushButton* next_button_;
|
2011-01-21 00:42:28 +01:00
|
|
|
|
2011-03-05 20:24:44 +01:00
|
|
|
TrackSelectionDialog* results_dialog_;
|
2010-01-16 17:12:47 +01:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // EDITTAGDIALOG_H
|