Sayonara Player
Editor.h
1 /* TagEdit.h */
2 
3 /* Copyright (C) 2011-2019 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef TAGEDIT_H
22 #define TAGEDIT_H
23 
24 #include <QThread>
25 #include <QPixmap>
26 
27 #include "Utils/Pimpl.h"
28 
29 class Genre;
30 namespace Tagging
31 {
41  class Editor :
42  public QThread
43  {
44  Q_OBJECT
45  PIMPL(Editor)
46 
47  private:
48  using QThread::finished;
49 
50  signals:
51  void sig_started();
52  void sig_finished();
53  void sig_progress(int);
54  void sig_metadata_received(const MetaDataList& v_md);
55 
56 
57  public:
58  explicit Editor(QObject* parent=nullptr);
59  explicit Editor(const MetaDataList& v_md, QObject* parent=nullptr);
60  ~Editor();
61 
62  enum FailReason
63  {
64  FileNotWriteable=1,
65  FileNotFound,
66  TagLibError
67  };
68 
69 
74  void undo(int idx);
75 
79  void undo_all();
80 
81 
87  const MetaData& metadata(int idx) const;
88 
89 
94  const MetaDataList& metadata() const;
95 
96 
97  bool apply_regex(const QString& regex, int idx);
98 
99 
104  void add_genre(int idx, const Genre& genre);
105 
106 
107  void delete_genre(int idx, const Genre& genre);
108 
109  void rename_genre(int idx, const Genre& genre, const Genre& new_genre);
110 
111 
112 
117  int count() const;
118 
119 
123  bool has_changes() const;
124 
125 
131  void update_track(int idx, const MetaData& md);
132 
138  void update_cover(int idx, const QPixmap& cover);
139 
144  // void remove_cover(int idx);
145 
151  bool has_cover_replacement(int idx) const;
152 
153 
158  void set_metadata(const MetaDataList& v_md);
159 
160  bool is_cover_supported(int idx) const;
161 
162  bool can_load_entire_album() const;
163  void load_entire_album();
164 
165 
166  QMap<QString, FailReason> failed_files() const;
167 
168 
169  public slots:
170 
174  void commit();
175 
176 
177  private:
181  void apply_artists_and_albums_to_md();
182 
183  void run() override;
184 
185  private slots:
186  void thread_finished();
187  void load_entire_album_finished();
188  };
189 }
190 
191 #endif // TAGEDIT_H
void update_track(int idx, const MetaData &md)
writes changes to (changed) metadata for a specific track
void commit()
Commits changes to db.
void set_metadata(const MetaDataList &v_md)
initializes the TagEdit object with a MetaDataList
bool has_changes() const
indicates if there are pending changes
void update_cover(int idx, const QPixmap &cover)
update the cover for a specific track.
The MetaData class.
Definition: MetaData.h:44
const MetaDataList & metadata() const
get all (changed) metadata
The MetaDataList class.
Definition: MetaDataList.h:37
The GUI_TagEdit class.
Definition: GenreFetcher.h:33
void undo_all()
undo changes for all tracks
Definition: Genre.h:30
bool has_cover_replacement(int idx) const
remove_cover for a specific track
void add_genre(int idx, const Genre &genre)
Add a genre to all (changed) metdata.
int count() const
gets the number of tracks
void undo(int idx)
undo changes for a specific track
The TagEdit class Metadata has to be added using the set_metadata(const MetaDataList&) method....
Definition: Editor.h:41
Definition: org_mpris_media_player2_adaptor.h:21