mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-23 08:20:01 +01:00
playlistparser: Add error mechanism for parsers.
Add a new Error signal to parser implementations. Display an error when user tries to use the unimplemented CueParser::Save.
This commit is contained in:
parent
f4108b5a0c
commit
4e4fccc07a
@ -348,7 +348,9 @@ qint64 CueParser::IndexToMarker(const QString& index) const {
|
||||
|
||||
void CueParser::Save(const SongList& songs, QIODevice* device, const QDir& dir,
|
||||
Playlist::Path path_type) const {
|
||||
// TODO
|
||||
// TODO: Not yet implemented. Cue files represent tracks within a single
|
||||
// file, so the song list would need to be composed properly.
|
||||
emit Error(tr("Saving cue files is not yet supported."));
|
||||
}
|
||||
|
||||
// Looks for a track starting with one of the .cue's keywords.
|
||||
|
@ -55,6 +55,9 @@ class ParserBase : public QObject {
|
||||
const SongList& songs, QIODevice* device, const QDir& dir = QDir(),
|
||||
Playlist::Path path_type = Playlist::Path_Automatic) const = 0;
|
||||
|
||||
signals:
|
||||
void Error(const QString& msg) const;
|
||||
|
||||
protected:
|
||||
// Loads a song. If filename_or_url is a URL (with a scheme other than
|
||||
// "file") then it is set on the song and the song marked as a stream.
|
||||
|
@ -35,13 +35,18 @@ PlaylistParser::PlaylistParser(LibraryBackendInterface* library,
|
||||
QObject* parent)
|
||||
: QObject(parent) {
|
||||
default_parser_ = new XSPFParser(library, this);
|
||||
parsers_ << new M3UParser(library, this);
|
||||
parsers_ << default_parser_;
|
||||
parsers_ << new PLSParser(library, this);
|
||||
parsers_ << new ASXParser(library, this);
|
||||
parsers_ << new AsxIniParser(library, this);
|
||||
parsers_ << new CueParser(library, this);
|
||||
parsers_ << new WplParser(library, this);
|
||||
AddParser(new M3UParser(library, this));
|
||||
AddParser(default_parser_);
|
||||
AddParser(new PLSParser(library, this));
|
||||
AddParser(new ASXParser(library, this));
|
||||
AddParser(new AsxIniParser(library, this));
|
||||
AddParser(new CueParser(library, this));
|
||||
AddParser(new WplParser(library, this));
|
||||
}
|
||||
|
||||
void PlaylistParser::AddParser(ParserBase* parser) {
|
||||
parsers_ << parser;
|
||||
connect(parser, SIGNAL(Error(QString)), this, SIGNAL(Error(QString)));
|
||||
}
|
||||
|
||||
QStringList PlaylistParser::file_extensions() const {
|
||||
|
@ -59,6 +59,8 @@ class PlaylistParser : public QObject {
|
||||
void Error(const QString& msg) const;
|
||||
|
||||
private:
|
||||
void AddParser(ParserBase* parser);
|
||||
|
||||
QString FilterForParser(const ParserBase* parser,
|
||||
QStringList* all_extensions = nullptr) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user