From 954146ff9b69591f0cf3895e96922bb55ad88502 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 22 Dec 2012 10:46:29 +0000 Subject: playlist format api cleanup git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3088 90c681e8-e032-0410-971d-27865f9a5e38 --- .../PlayListFormats/m3u/m3uplaylistformat.cpp | 24 ++++---------- .../PlayListFormats/m3u/m3uplaylistformat.h | 14 +++----- .../PlayListFormats/pls/plsplaylistformat.cpp | 30 ++++-------------- .../PlayListFormats/pls/plsplaylistformat.h | 12 +++---- .../PlayListFormats/xspf/xspfplaylistformat.cpp | 37 ++++++---------------- .../PlayListFormats/xspf/xspfplaylistformat.h | 13 +++----- 6 files changed, 34 insertions(+), 96 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp index 8349f1274..3f1270eec 100644 --- a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp +++ b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2012 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -22,19 +22,12 @@ #include #include "m3uplaylistformat.h" -bool M3UPlaylistFormat::hasFormat(const QString &f) +const PlayListFormatProperties M3UPlaylistFormat::properties() const { - return m_supported_formats.contains(f); -} - -QStringList M3UPlaylistFormat::getExtensions() const -{ - return m_supported_formats; -} - -M3UPlaylistFormat::M3UPlaylistFormat() -{ - m_supported_formats << "m3u"; + PlayListFormatProperties p; + p.filters << "*.m3u"; + p.shortName = "m3u"; + return p; } QStringList M3UPlaylistFormat::decode(const QString & contents) @@ -70,9 +63,4 @@ QString M3UPlaylistFormat::encode(const QList & contents) return out.join("\n"); } -QString M3UPlaylistFormat::name() const -{ - return "M3UPlaylistFormat"; -} - Q_EXPORT_PLUGIN2(m3uplaylistformat,M3UPlaylistFormat) diff --git a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.h b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.h index 4a5414894..4c2405abf 100644 --- a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.h +++ b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2012 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -35,14 +35,10 @@ class M3UPlaylistFormat : public QObject, public PlayListFormat Q_OBJECT Q_INTERFACES(PlayListFormat) public: - M3UPlaylistFormat(); - virtual QStringList getExtensions()const; - virtual bool hasFormat(const QString&); - virtual QStringList decode(const QString& contents); - virtual QString encode(const QList& contents); - virtual QString name()const; -protected: - QStringList m_supported_formats; + const PlayListFormatProperties properties() const; + QStringList decode(const QString& contents); + QString encode(const QList& contents); + }; #endif diff --git a/src/plugins/PlayListFormats/pls/plsplaylistformat.cpp b/src/plugins/PlayListFormats/pls/plsplaylistformat.cpp index a251276d0..602e29199 100644 --- a/src/plugins/PlayListFormats/pls/plsplaylistformat.cpp +++ b/src/plugins/PlayListFormats/pls/plsplaylistformat.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2012 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -20,34 +20,16 @@ #include #include - #include "plsplaylistformat.h" -bool PLSPlaylistFormat::hasFormat(const QString & f) -{ - foreach(QString s,m_supported_formats) - if (f == s) - return true; - - return false; -} - -QStringList PLSPlaylistFormat::getExtensions() const -{ - return m_supported_formats; -} - -PLSPlaylistFormat::PLSPlaylistFormat() -{ - m_supported_formats << "pls"; -} - -QString PLSPlaylistFormat::name() const +const PlayListFormatProperties PLSPlaylistFormat::properties() const { - return "PLSPlaylistFormat"; + PlayListFormatProperties p; + p.filters << "*.pls"; + p.shortName = "pls"; + return p; } - QStringList PLSPlaylistFormat::decode(const QString & contents) { QStringList out; diff --git a/src/plugins/PlayListFormats/pls/plsplaylistformat.h b/src/plugins/PlayListFormats/pls/plsplaylistformat.h index 4d770ee74..42fbb48f6 100644 --- a/src/plugins/PlayListFormats/pls/plsplaylistformat.h +++ b/src/plugins/PlayListFormats/pls/plsplaylistformat.h @@ -35,14 +35,10 @@ class PLSPlaylistFormat : public QObject, public PlayListFormat Q_OBJECT Q_INTERFACES(PlayListFormat) public: - PLSPlaylistFormat(); - virtual QStringList getExtensions()const; - virtual bool hasFormat(const QString&); - virtual QStringList decode(const QString& contents); - virtual QString encode(const QList& contents); - virtual QString name()const; -protected: - QStringList m_supported_formats; + const PlayListFormatProperties properties() const; + QStringList decode(const QString& contents); + QString encode(const QList& contents); + }; #endif diff --git a/src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp index 2e1296b48..4e6c2a349 100644 --- a/src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp +++ b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2009 by Ilya Kotov * + * Copyright (C) 2008-2012 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -23,13 +23,19 @@ #include #include #include - #include - #include "xspfplaylistformat.h" // Needs more work - it's better use libSpiff there and put it as plugin. +const PlayListFormatProperties XSPFPlaylistFormat::XSPFPlaylistFormat::properties() const +{ + PlayListFormatProperties p; + p.filters << "*.xspf"; + p.shortName = "xspf"; + return p; +} + QStringList XSPFPlaylistFormat::decode(const QString & contents) { QStringList out; @@ -138,29 +144,4 @@ QString XSPFPlaylistFormat::encode(const QList & files) return doc.toString().prepend(xml_header); } -XSPFPlaylistFormat::XSPFPlaylistFormat() -{ - m_supported_formats << "xspf"; -} - -bool XSPFPlaylistFormat::hasFormat(const QString & f) -{ - foreach(QString s,m_supported_formats) - if (f == s) - return true; - - return false; -} - -QStringList XSPFPlaylistFormat::getExtensions() const -{ - return m_supported_formats; -} - - -QString XSPFPlaylistFormat::name() const -{ - return "XSPFPlaylistFormat"; -} - Q_EXPORT_PLUGIN2(xspfplaylistformat,XSPFPlaylistFormat) diff --git a/src/plugins/PlayListFormats/xspf/xspfplaylistformat.h b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.h index 2b72c8613..4570c041d 100644 --- a/src/plugins/PlayListFormats/xspf/xspfplaylistformat.h +++ b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2012 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -35,14 +35,9 @@ class XSPFPlaylistFormat : public QObject, public PlayListFormat Q_OBJECT Q_INTERFACES(PlayListFormat) public: - XSPFPlaylistFormat(); - virtual QStringList getExtensions()const; - virtual bool hasFormat(const QString&); - virtual QStringList decode(const QString& contents); - virtual QString encode(const QList& contents); - virtual QString name()const; -protected: - QStringList m_supported_formats; + const PlayListFormatProperties properties() const; + QStringList decode(const QString& contents); + QString encode(const QList& contents); }; #endif -- cgit v1.2.3-13-gbd6f