diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-10-19 21:51:45 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-10-19 21:51:45 +0000 |
| commit | 4e2034621e7c09c39ba4d5f0240540ac97414e94 (patch) | |
| tree | dfc8ccf9fb0dd178744d034e2ee6bd16e5a6a8e4 /src/plugins | |
| parent | c74607021fb0cde12833dfc113b1a25546baffab (diff) | |
| download | qmmp-4e2034621e7c09c39ba4d5f0240540ac97414e94.tar.gz qmmp-4e2034621e7c09c39ba4d5f0240540ac97414e94.tar.bz2 qmmp-4e2034621e7c09c39ba4d5f0240540ac97414e94.zip | |
cue plugin: added cover support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1330 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/General/mpris/playerobject.cpp | 10 | ||||
| -rw-r--r-- | src/plugins/Input/cue/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/plugins/Input/cue/cuemetadatamodel.cpp | 54 | ||||
| -rw-r--r-- | src/plugins/Input/cue/cuemetadatamodel.h | 42 | ||||
| -rw-r--r-- | src/plugins/Input/cue/decodercuefactory.cpp | 5 |
5 files changed, 104 insertions, 9 deletions
diff --git a/src/plugins/General/mpris/playerobject.cpp b/src/plugins/General/mpris/playerobject.cpp index fbdd9c854..894b68617 100644 --- a/src/plugins/General/mpris/playerobject.cpp +++ b/src/plugins/General/mpris/playerobject.cpp @@ -128,13 +128,11 @@ QVariantMap PlayerObject::GetMetadata() { QVariantMap map; - if (QFile::exists(m_core->metaData(Qmmp::URL))) - { - map.insert("location", "file://" + m_core->metaData(Qmmp::URL)); - map.insert("arturl", MetaDataManager::instance()->getCoverPath(m_core->metaData(Qmmp::URL))); - } - else + if (m_core->metaData(Qmmp::URL).contains("://")) map.insert("location", m_core->metaData(Qmmp::URL)); + else + map.insert("location", "file://" + m_core->metaData(Qmmp::URL)); + map.insert("arturl", MetaDataManager::instance()->getCoverPath(m_core->metaData(Qmmp::URL))); map.insert("title", m_core->metaData(Qmmp::TITLE)); map.insert("artist", m_core->metaData(Qmmp::ARTIST)); map.insert("album", m_core->metaData(Qmmp::ALBUM)); diff --git a/src/plugins/Input/cue/CMakeLists.txt b/src/plugins/Input/cue/CMakeLists.txt index 3c1e032ad..27541b9e0 100644 --- a/src/plugins/Input/cue/CMakeLists.txt +++ b/src/plugins/Input/cue/CMakeLists.txt @@ -32,6 +32,7 @@ SET(libcue_SRCS decodercuefactory.cpp settingsdialog.cpp cueparser.cpp + cuemetadatamodel.cpp ) SET(libcue_MOC_HDRS @@ -39,6 +40,7 @@ SET(libcue_MOC_HDRS decoder_cue.h settingsdialog.h cueparser.h + cuemetadatamodel.h ) SET(libcue_RCCS translations/translations.qrc) diff --git a/src/plugins/Input/cue/cuemetadatamodel.cpp b/src/plugins/Input/cue/cuemetadatamodel.cpp new file mode 100644 index 000000000..e370d168b --- /dev/null +++ b/src/plugins/Input/cue/cuemetadatamodel.cpp @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2009 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include <qmmp/metadatamanager.h> +#include "cueparser.h" +#include "cuemetadatamodel.h" + +CUEMetaDataModel::CUEMetaDataModel(const QString &url, QObject *parent) : MetaDataModel(parent) +{ + QString p = QUrl(url).path(); + p.replace(QString(QUrl::toPercentEncoding("#")), "#"); + p.replace(QString(QUrl::toPercentEncoding("?")), "?"); + p.replace(QString(QUrl::toPercentEncoding("%")), "%"); + m_parser = new CUEParser(p); + if (m_parser->count() == 0) + { + qWarning("CUEMetaDataModel: invalid cue file"); + return; + } + int track = url.section("#", -1).toInt(); + m_path = m_parser->filePath(track); +} + +CUEMetaDataModel::~CUEMetaDataModel() +{ + delete m_parser; +} + +QPixmap CUEMetaDataModel::cover() +{ + return MetaDataManager::instance()->getCover(m_path); +} + +QString CUEMetaDataModel::coverPath() +{ + return MetaDataManager::instance()->getCoverPath(m_path); +} diff --git a/src/plugins/Input/cue/cuemetadatamodel.h b/src/plugins/Input/cue/cuemetadatamodel.h new file mode 100644 index 000000000..8ad6e7c6e --- /dev/null +++ b/src/plugins/Input/cue/cuemetadatamodel.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (C) 2009 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef CUEMETADATAMODEL_H +#define CUEMETADATAMODEL_H + +#include <qmmp/metadatamodel.h> + +class CUEParser; + +class CUEMetaDataModel : public MetaDataModel +{ +Q_OBJECT +public: + CUEMetaDataModel(const QString &url, QObject *parent); + ~CUEMetaDataModel(); + QPixmap cover(); + QString coverPath(); + +private: + CUEParser *m_parser; + QString m_path; +}; + +#endif // CUEMETADATAMODEL_H diff --git a/src/plugins/Input/cue/decodercuefactory.cpp b/src/plugins/Input/cue/decodercuefactory.cpp index 0a33b87ec..b57d46679 100644 --- a/src/plugins/Input/cue/decodercuefactory.cpp +++ b/src/plugins/Input/cue/decodercuefactory.cpp @@ -20,6 +20,7 @@ #include <QtGui> #include "decoder_cue.h" +#include "cuemetadatamodel.h" #include "cueparser.h" #include "settingsdialog.h" #include "decodercuefactory.h" @@ -68,9 +69,7 @@ QList<FileInfo *> DecoderCUEFactory::createPlayList(const QString &fileName, boo MetaDataModel* DecoderCUEFactory::createMetaDataModel(const QString &path, QObject *parent) { - Q_UNUSED(path); - Q_UNUSED(parent); - return 0; + return path.startsWith("cue://") ? new CUEMetaDataModel(path, parent) : 0; } void DecoderCUEFactory::showSettings(QWidget *parent) |
