aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app/qmmpstarter.cpp1
-rw-r--r--src/plugins/Ui/skinned/addurldialog.cpp4
-rw-r--r--src/qmmpui/playlistmodel.cpp4
-rw-r--r--src/qmmpui/playlistparser.cpp50
-rw-r--r--src/qmmpui/playlistparser.h36
-rw-r--r--src/qmmpui/qmmpui.pro1
-rw-r--r--src/qmmpui/uihelper.cpp14
7 files changed, 35 insertions, 75 deletions
diff --git a/src/app/qmmpstarter.cpp b/src/app/qmmpstarter.cpp
index 6ea21be5a..4e740c493 100644
--- a/src/app/qmmpstarter.cpp
+++ b/src/app/qmmpstarter.cpp
@@ -165,7 +165,6 @@ void QMMPStarter::startPlayer()
m_core = SoundCore::instance();
//additional featuries
- new PlayListParser(this);
new UiHelper(this);
//interface
diff --git a/src/plugins/Ui/skinned/addurldialog.cpp b/src/plugins/Ui/skinned/addurldialog.cpp
index 6b4f13c9f..fd10ce8ba 100644
--- a/src/plugins/Ui/skinned/addurldialog.cpp
+++ b/src/plugins/Ui/skinned/addurldialog.cpp
@@ -99,7 +99,7 @@ void AddUrlDialog::accept( )
if (s.startsWith("http://"))
{
//try to download playlist
- PlayListFormat* prs = PlayListParser::instance()->findByPath(s);
+ PlayListFormat* prs = PlayListParser::findByPath(s);
if (prs)
{
connect(m_http, SIGNAL(finished (QNetworkReply *)), SLOT(readResponse(QNetworkReply *)));
@@ -138,7 +138,7 @@ void AddUrlDialog::readResponse(QNetworkReply *reply)
m_redirect_url.clear();
QString s = urlComboBox->currentText();
- PlayListFormat* prs = PlayListParser::instance()->findByPath(s);
+ PlayListFormat* prs = PlayListParser::findByPath(s);
if (prs)
{
m_model->add(prs->decode(reply->readAll()));
diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp
index 30f7cfe3c..6f67e6e22 100644
--- a/src/qmmpui/playlistmodel.cpp
+++ b/src/qmmpui/playlistmodel.cpp
@@ -840,7 +840,7 @@ void PlayListModel::doCurrentVisibleRequest()
void PlayListModel::loadPlaylist(const QString &f_name)
{
- PlayListFormat* prs = PlayListParser::instance()->findByPath(f_name);
+ PlayListFormat* prs = PlayListParser::findByPath(f_name);
if(!prs)
{
//qWarning("PlayListModel: unsupported playlist format");
@@ -874,7 +874,7 @@ void PlayListModel::loadPlaylist(const QString &f_name)
void PlayListModel::savePlaylist(const QString & f_name)
{
- PlayListFormat* prs = PlayListParser::instance()->findByPath(f_name);
+ PlayListFormat* prs = PlayListParser::findByPath(f_name);
if (prs)
{
QFile file(f_name);
diff --git a/src/qmmpui/playlistparser.cpp b/src/qmmpui/playlistparser.cpp
index 08e9e18b4..9e11db1f2 100644
--- a/src/qmmpui/playlistparser.cpp
+++ b/src/qmmpui/playlistparser.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 *
@@ -26,41 +26,26 @@
#include "playlistformat.h"
#include "playlistparser.h"
-PlayListParser *PlayListParser::m_instance = 0;
+QList<PlayListFormat*> *PlayListParser::m_formats = 0;
-PlayListParser::PlayListParser(QObject *parent) : QObject (parent)
+QStringList PlayListParser::filters()
{
- m_instance = this;
-}
-
-PlayListParser::~PlayListParser()
-{
- m_instance = 0;
-}
-
-QStringList PlayListParser::extensions()
-{
- loadExternalPlaylistFormats();
+ checkFormats();
QStringList extensions;
- foreach(PlayListFormat *format, m_formats)
+ foreach(PlayListFormat *format, *m_formats)
extensions << format->getExtensions();
return extensions;
}
-bool PlayListParser::supports(const QString &filePath)
+QList<PlayListFormat*> *PlayListParser::formats()
{
- return findByPath(filePath) != 0;
-}
-
-QList<PlayListFormat*> PlayListParser::formats()
-{
- loadExternalPlaylistFormats();
+ checkFormats();
return m_formats;
}
PlayListFormat *PlayListParser::findByPath(const QString &filePath)
{
- loadExternalPlaylistFormats();
+ checkFormats();
QString ext;
if(filePath.contains("://")) //is it url?
{
@@ -70,7 +55,7 @@ PlayListFormat *PlayListParser::findByPath(const QString &filePath)
else
ext = QFileInfo(filePath).suffix().toLower();
- foreach(PlayListFormat* format, m_formats)
+ foreach(PlayListFormat* format, *m_formats)
{
if (format->hasFormat(ext))
return format;
@@ -78,19 +63,14 @@ PlayListFormat *PlayListParser::findByPath(const QString &filePath)
return 0;
}
-PlayListParser* PlayListParser::instance()
-{
- if(!m_instance)
- qFatal("PlayListParser: object is not created");
- return m_instance;
-}
-
-void PlayListParser::loadExternalPlaylistFormats()
+void PlayListParser::checkFormats()
{
- if (!m_formats.isEmpty())
+ if (m_formats)
return;
+
+ m_formats = new QList<PlayListFormat*>();
QDir pluginsDir (Qmmp::pluginsPath());
- pluginsDir.cd("PlayListFormats");
+ pluginsDir.cd("PlaylistFormats");
foreach (QString fileName, pluginsDir.entryList(QDir::Files))
{
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
@@ -105,6 +85,6 @@ void PlayListParser::loadExternalPlaylistFormats()
fmt = qobject_cast<PlayListFormat *>(plugin);
if (fmt)
- m_formats << fmt;
+ m_formats->append(fmt);
}
}
diff --git a/src/qmmpui/playlistparser.h b/src/qmmpui/playlistparser.h
index 5ae770b4a..643730323 100644
--- a/src/qmmpui/playlistparser.h
+++ b/src/qmmpui/playlistparser.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 *
@@ -20,51 +20,33 @@
#ifndef PLAYLISTPARSER_H
#define PLAYLISTPARSER_H
-#include <QObject>
#include "playlistformat.h"
/*! @brief The PlaylistParser class provides a simple api to access playlist format plugins.
* @author Ilya Kotov <forkotov02@hotmail.ru>
*/
-class PlayListParser : public QObject
+class PlayListParser
{
- Q_OBJECT
public:
/*!
- * Object constructor,
- * @param parent Parent object
- */
- PlayListParser(QObject *parent);
- /*!
- * Destructor
- */
- ~PlayListParser();
- /*!
* Returns a list of supported file extensions.
*/
- QStringList extensions();
- /*!
- * Returns \b true if file \b filePath is supported, otherwise returns \b false
- */
- bool supports(const QString &filePath);
+ static QStringList filters();
/*!
* Returns a list of the installed playlist formats.
*/
- QList<PlayListFormat*> formats();
- /*!
- * Returns a pointer to the object's instance.
- */
- static PlayListParser* instance();
+ static QList<PlayListFormat*> *formats();
/*!
* Finds playlist format by file path \b filePath
* Returns \b 0 if file \b filePath is unsupported.
*/
- PlayListFormat *findByPath(const QString &filePath);
+ static PlayListFormat *findByPath(const QString &filePath);
private:
- void loadExternalPlaylistFormats();
- QList<PlayListFormat*> m_formats;
- static PlayListParser* m_instance;
+ PlayListParser(){}
+ static void checkFormats();
+ static QList<PlayListFormat*> *m_formats;
+
};
diff --git a/src/qmmpui/qmmpui.pro b/src/qmmpui/qmmpui.pro
index 29f538b83..5ef7d6908 100644
--- a/src/qmmpui/qmmpui.pro
+++ b/src/qmmpui/qmmpui.pro
@@ -18,6 +18,7 @@ TEMPLATE = lib
unix:isEmpty(LIB_DIR):LIB_DIR = /lib
VERSION = $$QMMP_VERSION
unix:target.path = $$LIB_DIR
+QT += network
HEADERS += general.h \
generalfactory.h \
playlistformat.h \
diff --git a/src/qmmpui/uihelper.cpp b/src/qmmpui/uihelper.cpp
index 77d4a81a9..c9247640e 100644
--- a/src/qmmpui/uihelper.cpp
+++ b/src/qmmpui/uihelper.cpp
@@ -45,8 +45,6 @@ UiHelper::UiHelper(QObject *parent)
General::create(parent);
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
m_lastDir = settings.value("General/last_dir", QDir::homePath()).toString(); //last directory
- if(!PlayListParser::instance())
- new PlayListParser(parent);
}
UiHelper::~UiHelper()
@@ -150,10 +148,10 @@ void UiHelper::addDirectory(QWidget *parent, PlayListModel *model)
void UiHelper::loadPlayList(QWidget *parent, PlayListModel *model)
{
QStringList l;
- QList<PlayListFormat*> p_list = PlayListParser::instance()->formats();
- if (!p_list.isEmpty())
+ QList<PlayListFormat*> *p_list = PlayListParser::formats();
+ if (!p_list->isEmpty())
{
- foreach(PlayListFormat* fmt,p_list)
+ foreach(PlayListFormat* fmt, *p_list)
l << fmt->getExtensions();
QString mask = tr("Playlist Files")+" (" + l.join(" *.").prepend("*.") + ")";
@@ -176,10 +174,10 @@ void UiHelper::loadPlayList(QWidget *parent, PlayListModel *model)
void UiHelper::savePlayList(QWidget *parent, PlayListModel *model)
{
QStringList l;
- QList<PlayListFormat*> p_list = PlayListParser::instance()->formats();
- if (!p_list.isEmpty())
+ QList<PlayListFormat*> *p_list = PlayListParser::formats();
+ if (!p_list->isEmpty())
{
- foreach(PlayListFormat* fmt,p_list)
+ foreach(PlayListFormat* fmt,*p_list)
l << fmt->getExtensions();
QString mask = tr("Playlist Files")+" (" + l.join(" *.").prepend("*.") + ")";