aboutsummaryrefslogtreecommitdiff
path: root/src/qmmpui/playlistparser.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2012-12-22 09:13:31 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2012-12-22 09:13:31 +0000
commit0e9d21145a61416615419dc97a801a82f3e97fe6 (patch)
treeab10a526c10a2ba6b38420f5907c9d11b6f88dff /src/qmmpui/playlistparser.cpp
parentc7848bc541b316324ed3fe1ff8f5613ccf13a142 (diff)
downloadqmmp-0e9d21145a61416615419dc97a801a82f3e97fe6.tar.gz
qmmp-0e9d21145a61416615419dc97a801a82f3e97fe6.tar.bz2
qmmp-0e9d21145a61416615419dc97a801a82f3e97fe6.zip
changed PlayListParser class
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3083 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui/playlistparser.cpp')
-rw-r--r--src/qmmpui/playlistparser.cpp50
1 files changed, 15 insertions, 35 deletions
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);
}
}