Clementine-audio-player-Mac.../src/ui/edittagdialog.h

182 lines
4.6 KiB
C
Raw Normal View History

/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
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>
#include <QModelIndexList>
2010-01-16 17:12:47 +01:00
#include "config.h"
#include "core/backgroundthread.h"
#include "core/song.h"
#ifdef HAVE_LIBTUNEPIMP
# include "core/tagfetcher.h"
#endif
#include "playlist/playlistitem.h"
#include "widgets/lineedit.h"
#include "trackselectiondialog.h"
2010-01-16 17:12:47 +01:00
#ifdef HAVE_LIBLASTFM
class AlbumCoverFetcher;
class AlbumCoverSearcher;
#endif
class AlbumCoverLoader;
class CoverFromURLDialog;
class LibraryBackend;
class Ui_EditTagDialog;
class QAbstractButton;
class QItemSelection;
class QLabel;
class QPushButton;
2010-01-16 17:12:47 +01:00
class EditTagDialog : public QDialog {
Q_OBJECT
public:
2010-01-16 17:12:47 +01:00
EditTagDialog(QWidget* parent = 0);
~EditTagDialog();
2010-01-16 17:12:47 +01:00
static const char* kHintText;
static const char* kTagFetchText;
static const char* kTagFetchOnLoadText;
void SetSongs(const SongList& songs, const PlaylistItemList& items = PlaylistItemList());
void SetTagCompleter(LibraryBackend* backend);
2010-01-16 17:12:47 +01:00
PlaylistItemList playlist_items() const { return playlist_items_; }
void accept();
signals:
void Error(const QString& message);
protected:
bool eventFilter(QObject* o, QEvent* e);
void showEvent(QShowEvent*);
private slots:
void SetSongsFinished();
void AcceptFinished();
void SelectionChanged();
void FieldValueEdited();
void ResetField();
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();
void FetchTag();
void FetchTagFinished(const QString& filename, const SongList& songs_guessed);
void FetchTagSongChoosen(const QString& filename, const Song& song);
2010-01-16 17:12:47 +01:00
void ArtLoaded(quint64 id, const QImage& image);
void LoadCoverFromFile();
void LoadCoverFromURL();
void SearchCover();
void UnsetCover();
void ZoomCover();
void PreviousSong();
void NextSong();
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_;
};
struct FieldData {
FieldData(QLabel* label = NULL, QWidget* editor = NULL,
const QString& id = QString())
: label_(label), editor_(editor), id_(id) {}
2010-01-16 17:12:47 +01:00
QLabel* label_;
QWidget* editor_;
QString id_;
};
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);
void ResetFieldValue(const FieldData& field, const QModelIndexList& sel);
void UpdateSummaryTab(const Song& song);
void UpdateStatisticsTab(const Song& song);
void SetAlbumArt(const QString& path);
bool SetLoading(const QString& message);
// Called by QtConcurrentRun
QList<Data> LoadData(const SongList& songs) const;
void SaveData(const QList<Data>& data);
private:
Ui_EditTagDialog* ui_;
CoverFromURLDialog* cover_from_url_dialog_;
LibraryBackend* backend_;
bool loading_;
PlaylistItemList playlist_items_;
QList<Data> data_;
QList<FieldData> fields_;
bool ignore_edits_;
#ifdef HAVE_LIBTUNEPIMP
TagFetcher* tag_fetcher_;
#endif
#ifdef HAVE_LIBLASTFM
AlbumCoverSearcher* cover_searcher_;
AlbumCoverFetcher* cover_fetcher_;
#endif
BackgroundThread<AlbumCoverLoader>* cover_loader_;
quint64 cover_art_id_;
bool cover_art_is_set_;
QMenu* cover_menu_;
QAction* choose_cover_;
QAction* download_cover_;
QAction* search_for_cover_;
QAction* unset_cover_;
QAction* show_cover_;
QPushButton* previous_button_;
QPushButton* next_button_;
TrackSelectionDialog *resultsDialog_;
2010-01-16 17:12:47 +01:00
};
#endif // EDITTAGDIALOG_H