Sayonara Player
Editor.h
1 /* TagEdit.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (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 
31 namespace Tagging
32 {
41  class Editor :
42  public QObject
43  {
44  Q_OBJECT
45  PIMPL(Editor)
46 
47  signals:
48  void sigStarted();
49  void sigFinished();
50  void sigProgress(int);
51  void sigMetadataReceived(const MetaDataList& tracks);
52 
53  public:
54  explicit Editor(QObject* parent=nullptr);
55  explicit Editor(const MetaDataList& tracks, QObject* parent=nullptr);
56  ~Editor() override;
57 
58  enum FailReason
59  {
60  FileNotWriteable=1,
61  FileNotFound,
62  TagLibError
63  };
64 
65 
70  void undo(int idx);
71 
75  void undoAll();
76 
77 
83  MetaData metadata(int idx) const;
84 
85 
91 
92 
93  bool applyRegularExpression(const QString& regex, int idx);
94 
99  void addGenre(int idx, const Genre& genre);
100 
101 
102  void deleteGenre(int idx, const Genre& genre);
103 
104  void renameGenre(int idx, const Genre& genre, const Genre& new_genre);
105 
110  int count() const;
111 
112 
116  bool hasChanges() const;
117 
118 
124  void updateTrack(int idx, const MetaData& md);
125 
131  void updateCover(int idx, const QPixmap& cover);
132 
137  // void remove_cover(int idx);
138 
144  bool hasCoverReplacement(int idx) const;
145 
146 
151  void setMetadata(const MetaDataList& tracks);
152 
153  bool isCoverSupported(int idx) const;
154 
155  bool canLoadEntireAlbum() const;
156  void loadEntireAlbum();
157 
158  QMap<QString, FailReason> failedFiles() const;
159 
160  public slots:
161 
165  void commit();
166 
167 
168  private:
172  void insertMissingArtistsAndAlbums();
173 
174  private slots:
175  void loadEntireAlbumFinished();
176  };
177 }
178 
179 #endif // TAGEDIT_H
Tagging::Editor::commit
void commit()
Commits changes to db.
Tagging::Editor::hasChanges
bool hasChanges() const
indicates if there are pending changes
Tagging::Editor::updateTrack
void updateTrack(int idx, const MetaData &md)
writes changes to (changed) metadata for a specific track
Tagging::Editor::updateCover
void updateCover(int idx, const QPixmap &cover)
update the cover for a specific track.
MetaDataList
The MetaDataList class.
Definition: MetaDataList.h:37
Genre
Definition: Genre.h:31
Tagging::Editor::undoAll
void undoAll()
undo changes for all tracks
Tagging::Editor
The TagEdit class Metadata has to be added using the set_metadata(const MetaDataList&) method....
Definition: Editor.h:43
Tagging::Editor::hasCoverReplacement
bool hasCoverReplacement(int idx) const
remove_cover for a specific track
Tagging::Editor::addGenre
void addGenre(int idx, const Genre &genre)
Add a genre to all (changed) metdata.
QMap
Definition: org_mpris_media_player2_adaptor.h:21
Tagging::Editor::metadata
MetaDataList metadata() const
get all (changed) metadata
Tagging
The GUI_TagEdit class.
Definition: GenreFetcher.h:34
MetaData
The MetaData class.
Definition: MetaData.h:47
Tagging::Editor::metadata
MetaData metadata(int idx) const
get the (changed) metadata for a specific index
Tagging::Editor::count
int count() const
gets the number of tracks
Tagging::Editor::undo
void undo(int idx)
undo changes for a specific track
Tagging::Editor::setMetadata
void setMetadata(const MetaDataList &tracks)
initializes the TagEdit object with a MetaDataList