aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-11-28 21:19:59 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-11-28 21:19:59 +0000
commit910c5067e8d7ae22b3fde6bd483391314de1ba16 (patch)
treeaf57d00445efa54a4992ad1609cf71f59cdf9494 /src
parent26724c66d4764a77ca653ce6c0a1573e9e97e97c (diff)
downloadqmmp-910c5067e8d7ae22b3fde6bd483391314de1ba16.tar.gz
qmmp-910c5067e8d7ae22b3fde6bd483391314de1ba16.tar.bz2
qmmp-910c5067e8d7ae22b3fde6bd483391314de1ba16.zip
general api changes, removed unused code
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@647 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-rw-r--r--src/plugins/PlaylistFormats/m3u/m3uplaylistformat.cpp6
-rw-r--r--src/plugins/PlaylistFormats/m3u/m3uplaylistformat.h4
-rw-r--r--src/plugins/PlaylistFormats/pls/plsplaylistformat.cpp6
-rw-r--r--src/plugins/PlaylistFormats/pls/plsplaylistformat.h4
-rw-r--r--src/plugins/PlaylistFormats/xspf/xspfplaylistformat.cpp8
-rw-r--r--src/plugins/PlaylistFormats/xspf/xspfplaylistformat.h4
-rw-r--r--src/qmmpui/CMakeLists.txt16
-rw-r--r--src/qmmpui/abstractplaylist.cpp32
-rw-r--r--src/qmmpui/abstractplaylist.h38
-rw-r--r--src/qmmpui/abstractplaylistitem.cpp101
-rw-r--r--src/qmmpui/abstractplaylistitem.h (renamed from src/qmmpui/songinfo.h)63
-rw-r--r--src/qmmpui/general.cpp15
-rw-r--r--src/qmmpui/general.h12
-rw-r--r--src/qmmpui/generalhandler.h22
-rw-r--r--src/qmmpui/playlistformat.h6
-rw-r--r--src/qmmpui/playlistparser.h1
-rw-r--r--src/qmmpui/qmmpui.pro6
-rw-r--r--src/qmmpui/songinfo.cpp155
-rw-r--r--src/ui/eqwidget.cpp4
-rw-r--r--src/ui/mainwindow.cpp42
-rw-r--r--src/ui/mainwindow.h1
-rw-r--r--src/ui/playlistitem.cpp74
-rw-r--r--src/ui/playlistitem.h4
-rw-r--r--src/ui/playlistmodel.cpp26
24 files changed, 271 insertions, 379 deletions
diff --git a/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.cpp b/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.cpp
index 384769399..11f9fbd4c 100644
--- a/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.cpp
+++ b/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.cpp
@@ -68,15 +68,15 @@ QStringList M3UPlaylistFormat::decode(const QString & contents)
return QStringList();
}
-QString M3UPlaylistFormat::encode(const QList< SongInfo * > & contents)
+QString M3UPlaylistFormat::encode(const QList<AbstractPlaylistItem*> & contents)
{
QStringList out;
out << QString("#EXTM3U");
- foreach(SongInfo* f,contents)
+ foreach(AbstractPlaylistItem* f,contents)
{
QString info = "#EXTINF:" + QString::number(f->length()) + "," + f->title();
out.append(info);
- out.append(f->path());
+ out.append(f->url());
}
return out.join("\n");
}
diff --git a/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.h b/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.h
index e19e0e460..91b4d17ad 100644
--- a/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.h
+++ b/src/plugins/PlaylistFormats/m3u/m3uplaylistformat.h
@@ -24,7 +24,7 @@
#include <QString>
#include <QStringList>
#include <qmmpui/playlistformat.h>
-#include <qmmpui/songinfo.h>
+#include <qmmpui/abstractplaylistitem.h>
/*!
* Class for M3U playlist format parsing
@@ -39,7 +39,7 @@ public:
virtual QStringList getExtensions()const;
virtual bool hasFormat(const QString&);
virtual QStringList decode(const QString& contents);
- virtual QString encode(const QList<SongInfo*>& contents);
+ virtual QString encode(const QList<AbstractPlaylistItem*>& contents);
virtual QString name()const;
protected:
QStringList m_supported_formats;
diff --git a/src/plugins/PlaylistFormats/pls/plsplaylistformat.cpp b/src/plugins/PlaylistFormats/pls/plsplaylistformat.cpp
index a505f59cc..10437d7fa 100644
--- a/src/plugins/PlaylistFormats/pls/plsplaylistformat.cpp
+++ b/src/plugins/PlaylistFormats/pls/plsplaylistformat.cpp
@@ -81,15 +81,15 @@ QStringList PLSPlaylistFormat::decode(const QString & contents)
return QStringList();
}
-QString PLSPlaylistFormat::encode(const QList<SongInfo *> & contents)
+QString PLSPlaylistFormat::encode(const QList<AbstractPlaylistItem *> & contents)
{
QStringList out;
out << QString("[playlist]");
int counter = 1;
- foreach(SongInfo* f,contents)
+ foreach(AbstractPlaylistItem* f,contents)
{
QString begin = "File" + QString::number(counter) + "=";
- out.append(begin + f->path());
+ out.append(begin + f->url());
begin = "Title" + QString::number(counter) + "=";
out.append(begin + f->title());
begin = "Length" + QString::number(counter) + "=";
diff --git a/src/plugins/PlaylistFormats/pls/plsplaylistformat.h b/src/plugins/PlaylistFormats/pls/plsplaylistformat.h
index ac0de7364..d69901d0d 100644
--- a/src/plugins/PlaylistFormats/pls/plsplaylistformat.h
+++ b/src/plugins/PlaylistFormats/pls/plsplaylistformat.h
@@ -24,7 +24,7 @@
#include <QString>
#include <QStringList>
#include <qmmpui/playlistformat.h>
-#include <qmmpui/songinfo.h>
+#include <qmmpui/abstractplaylistitem.h>
/*!
* Class for PLS playlist format parsing
@@ -39,7 +39,7 @@ public:
virtual QStringList getExtensions()const;
virtual bool hasFormat(const QString&);
virtual QStringList decode(const QString& contents);
- virtual QString encode(const QList<SongInfo*>& contents);
+ virtual QString encode(const QList<AbstractPlaylistItem*>& contents);
virtual QString name()const;
protected:
QStringList m_supported_formats;
diff --git a/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.cpp b/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.cpp
index 6e7c9ab5f..8f2cde63d 100644
--- a/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.cpp
+++ b/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.cpp
@@ -67,7 +67,7 @@ QStringList XSPFPlaylistFormat::decode(const QString & contents)
// Needs more work - it's better use libSpiff there and put it as plugin.
-QString XSPFPlaylistFormat::encode(const QList< SongInfo * > & files)
+QString XSPFPlaylistFormat::encode(const QList<AbstractPlaylistItem*> & files)
{
QDomDocument doc;
QDomElement root = doc.createElement("playlist");
@@ -82,12 +82,12 @@ QString XSPFPlaylistFormat::encode(const QList< SongInfo * > & files)
QDomElement tracklist = doc.createElement("trackList");
int counter = 1;
- foreach(SongInfo* f,files)
+ foreach(AbstractPlaylistItem* f,files)
{
QDomElement track = doc.createElement("track");
QDomElement ch = doc.createElement("location");
- QDomText text = doc.createTextNode(/*QString("file://") + */QFileInfo(f->path()).absoluteFilePath());
+ QDomText text = doc.createTextNode(/*QString("file://") + */QFileInfo(f->url()).absoluteFilePath());
ch.appendChild(text);
track.appendChild(ch);
@@ -102,7 +102,7 @@ QString XSPFPlaylistFormat::encode(const QList< SongInfo * > & files)
track.appendChild(ch);
ch = doc.createElement("year");
- text = doc.createTextNode(QString::number(f->year()));
+ text = doc.createTextNode(f->year());
ch.appendChild(text);
track.appendChild(ch);
diff --git a/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.h b/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.h
index 4b25e994f..87c1aad80 100644
--- a/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.h
+++ b/src/plugins/PlaylistFormats/xspf/xspfplaylistformat.h
@@ -24,7 +24,7 @@
#include <QString>
#include <QStringList>
#include <qmmpui/playlistformat.h>
-#include <qmmpui/songinfo.h>
+#include <qmmpui/abstractplaylistitem.h>
/*!
* Class for XSPF playlist format parsing
@@ -39,7 +39,7 @@ public:
virtual QStringList getExtensions()const;
virtual bool hasFormat(const QString&);
virtual QStringList decode(const QString& contents);
- virtual QString encode(const QList<SongInfo*>& contents);
+ virtual QString encode(const QList<AbstractPlaylistItem*>& contents);
virtual QString name()const;
protected:
QStringList m_supported_formats;
diff --git a/src/qmmpui/CMakeLists.txt b/src/qmmpui/CMakeLists.txt
index c98b4ee8d..96517cf0f 100644
--- a/src/qmmpui/CMakeLists.txt
+++ b/src/qmmpui/CMakeLists.txt
@@ -20,7 +20,13 @@ ELSE(SVN_VERSION)
ADD_DEFINITIONS(-DQMMP_STR_VERSION=\\\"${QMMP_VERSION}\\\")
ENDIF(SVN_VERSION)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+# libqmmp
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
+
+link_directories(${CMAKE_INSTALL_PREFIX}/${LIB_DIR})
+link_directories(${CMAKE_CURRENT_BINARY_DIR}/../qmmp)
SET(libqmmpui_SRCS
general.cpp
@@ -29,7 +35,8 @@ SET(libqmmpui_SRCS
commandlinemanager.cpp
filedialog.cpp
qtfiledialog.cpp
- songinfo.cpp
+ abstractplaylist.cpp
+ abstractplaylistitem.cpp
)
SET(libqmmpui_MOC_HDRS
@@ -43,7 +50,8 @@ SET(libqmmpui_MOC_HDRS
filedialog.h
filedialogfactory.h
qtfiledialog.h
- songinfo.h
+ abstractplaylist.h
+ abstractplaylistitem.h
)
SET(libqmmpui_DEVEL_HDRS
@@ -56,6 +64,8 @@ SET(libqmmpui_DEVEL_HDRS
commandlineoption.h
filedialog.h
filedialogfactory.h
+ abstractplaylist.h
+ abstractplaylistitem.h
)
diff --git a/src/qmmpui/abstractplaylist.cpp b/src/qmmpui/abstractplaylist.cpp
new file mode 100644
index 000000000..607165426
--- /dev/null
+++ b/src/qmmpui/abstractplaylist.cpp
@@ -0,0 +1,32 @@
+/***************************************************************************
+ * Copyright (C) 2008 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 "abstractplaylist.h"
+
+AbstractPlaylist::AbstractPlaylist(QObject *parent)
+ : QObject(parent)
+{
+}
+
+
+AbstractPlaylist::~AbstractPlaylist()
+{
+}
+
+
diff --git a/src/qmmpui/abstractplaylist.h b/src/qmmpui/abstractplaylist.h
new file mode 100644
index 000000000..6190cd8b4
--- /dev/null
+++ b/src/qmmpui/abstractplaylist.h
@@ -0,0 +1,38 @@
+/***************************************************************************
+ * Copyright (C) 2008 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 ABSTRACTPLAYLIST_H
+#define ABSTRACTPLAYLIST_H
+
+#include <QObject>
+
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
+class AbstractPlaylist : public QObject
+{
+Q_OBJECT
+public:
+ AbstractPlaylist(QObject *parent = 0);
+
+ ~AbstractPlaylist();
+
+};
+
+#endif
diff --git a/src/qmmpui/abstractplaylistitem.cpp b/src/qmmpui/abstractplaylistitem.cpp
new file mode 100644
index 000000000..164d7c500
--- /dev/null
+++ b/src/qmmpui/abstractplaylistitem.cpp
@@ -0,0 +1,101 @@
+/***************************************************************************
+ * Copyright (C) 2008 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 "abstractplaylistitem.h"
+
+AbstractPlaylistItem::AbstractPlaylistItem()
+{
+ m_length = 0;
+}
+
+
+AbstractPlaylistItem::~AbstractPlaylistItem()
+{
+}
+
+const QString AbstractPlaylistItem::title () const
+{
+ return m_metaData.value(Qmmp::TITLE);
+}
+
+const QString AbstractPlaylistItem::artist () const
+{
+ return m_metaData.value(Qmmp::ARTIST);
+}
+
+const QString AbstractPlaylistItem::album () const
+{
+ return m_metaData.value(Qmmp::ALBUM);
+}
+
+const QString AbstractPlaylistItem::comment () const
+{
+ return m_metaData.value(Qmmp::COMMENT);
+}
+
+const QString AbstractPlaylistItem::genre () const
+{
+ return m_metaData.value(Qmmp::GENRE);
+}
+
+const QString AbstractPlaylistItem::track () const
+{
+ return m_metaData.value(Qmmp::TRACK);
+}
+
+const QString AbstractPlaylistItem::year () const
+{
+ return m_metaData.value(Qmmp::YEAR);
+}
+
+const QString AbstractPlaylistItem::url () const
+{
+ return m_metaData.value(Qmmp::URL);
+}
+
+qint64 AbstractPlaylistItem::length ()
+{
+ return m_length;
+}
+
+bool AbstractPlaylistItem::isEmpty()
+{
+ return m_metaData.isEmpty();
+}
+
+void AbstractPlaylistItem::clear()
+{
+ m_metaData.clear();
+ m_length = 0;
+}
+
+void AbstractPlaylistItem::setMetaData(const QMap <Qmmp::MetaData, QString> &metaData)
+{
+ m_metaData = metaData;
+}
+
+void AbstractPlaylistItem::setMetaData(Qmmp::MetaData key, const QString &value)
+{
+ m_metaData.insert(key, value);
+}
+
+void AbstractPlaylistItem::setLength(qint64 length)
+{
+ m_length = length;
+}
diff --git a/src/qmmpui/songinfo.h b/src/qmmpui/abstractplaylistitem.h
index 98600f7d3..cea50739c 100644
--- a/src/qmmpui/songinfo.h
+++ b/src/qmmpui/abstractplaylistitem.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2007 by Ilya Kotov *
+ * Copyright (C) 2008 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -17,64 +17,43 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef SONGINFO_H
-#define SONGINFO_H
+#ifndef ABSTRACTPLAYLISTITEM_H
+#define ABSTRACTPLAYLISTITEM_H
#include <QMap>
#include <QString>
+#include <qmmp/qmmp.h>
/**
- @author Ilya Kotov <forkotov02@hotmail.ru>
+ @author Ilya Kotov <forkotov02@hotmail.ru>
*/
-
-class SongInfo{
+class AbstractPlaylistItem
+{
public:
- public:
- SongInfo();
- SongInfo(const SongInfo &other);
-
- ~SongInfo();
+ AbstractPlaylistItem();
- enum Type
- {
- TITLE = 0,
- ARTIST,
- ALBUM,
- COMMENT,
- GENRE,
- YEAR,
- TRACK,
- LENGTH,
- STREAM,
- PATH
- };
+ ~AbstractPlaylistItem();
- void operator=(const SongInfo &info);
- bool operator==(const SongInfo &info);
- bool operator!=(const SongInfo &info);
- void setValue(uint key, const QString &value);
- void setValue(uint key, const uint &value);
- void setValue(uint key, const bool &value);
const QString title () const;
const QString artist () const;
const QString album () const;
const QString comment () const;
const QString genre () const;
- const QString path () const;
- const QString fileName () const;
- uint year () const;
- uint track () const;
- uint length () const;
- bool isEmpty () const;
- bool isStream () const;
+ const QString track () const;
+ const QString year () const;
+ const QString url () const;
+
+ qint64 length ();
+ bool isEmpty();
void clear();
-private:
- QMap <uint, QString> m_strValues;
- QMap <uint, uint> m_numValues;
- bool m_stream;
- QString m_path;
+ virtual void setMetaData(const QMap <Qmmp::MetaData, QString> &metaData);
+ virtual void setMetaData(Qmmp::MetaData key, const QString &value);
+ virtual void setLength(qint64 length);
+private:
+ QMap <Qmmp::MetaData, QString> m_metaData;
+ qint64 m_length;
};
#endif
diff --git a/src/qmmpui/general.cpp b/src/qmmpui/general.cpp
index d0ebe2632..a4580941e 100644
--- a/src/qmmpui/general.cpp
+++ b/src/qmmpui/general.cpp
@@ -72,15 +72,6 @@ General::General(QObject *parent)
General::~General()
{}
-/*void General::setState(const uint&)
-{}
-
-void General::setSongInfo(const SongInfo &song)
-{}
-
-void General::setTime(int)
-{}*/
-
void General::play()
{
//TODO use AbstractPlayList and SoundCore
@@ -103,12 +94,6 @@ QList<GeneralFactory*> *General::generalFactories()
return factories;
}
-/*void General::setVolume(int left, int right)
-{
- Q_UNUSED(left);
- Q_UNUSED(right);
-}*/
-
QStringList General::generalFiles()
{
checkFactories();
diff --git a/src/qmmpui/general.h b/src/qmmpui/general.h
index 981d32585..edcb884b6 100644
--- a/src/qmmpui/general.h
+++ b/src/qmmpui/general.h
@@ -39,18 +39,6 @@ public:
~General();
- /*enum State
- {
- Playing = 0,
- Paused,
- Stopped
- };
-
- virtual void setState(const uint &state);
- virtual void setSongInfo(const SongInfo &song);
- virtual void setVolume(int left, int right);
- virtual void setTime(int time);*/
-
//static methods
static QList<GeneralFactory*> *generalFactories();
static QStringList generalFiles();
diff --git a/src/qmmpui/generalhandler.h b/src/qmmpui/generalhandler.h
index 710e817a1..7a1eb3502 100644
--- a/src/qmmpui/generalhandler.h
+++ b/src/qmmpui/generalhandler.h
@@ -39,10 +39,6 @@ public:
~GeneralHandler();
- /*void setSongInfo(const SongInfo &info);
- void setVolume(int left, int right);
- void setTime(int time);*/
-
void setEnabled(GeneralFactory* factory, bool enable);
void showSettings(GeneralFactory* factory, QWidget* parentWidget);
bool visibilityControl();
@@ -51,29 +47,11 @@ public:
signals:
void playCalled();
- /*void pauseCalled();
- void stopCalled();
- void nextCalled();
- void previousCalled();
- void seekCalled(int);*/
void exitCalled();
void toggleVisibilityCalled();
- //void volumeChanged(int left, int right);
-
-/*public slots:
- void setState(uint state);*/
-
-/*private slots:
- void processCommand(uint command);*/
private:
- void connectSignals(General*);
QMap <GeneralFactory*, General*> m_generals;
- //SongInfo m_songInfo;
- //Control* m_control;
- //int m_time;
- //uint m_state;
- //int m_left, m_right;
CommandLineManager *m_commandLineManager;
static GeneralHandler* m_instance;
};
diff --git a/src/qmmpui/playlistformat.h b/src/qmmpui/playlistformat.h
index 0a5bfdbcc..c5135486c 100644
--- a/src/qmmpui/playlistformat.h
+++ b/src/qmmpui/playlistformat.h
@@ -23,7 +23,7 @@
#include <QStringList>
-class SongInfo;
+class AbstractPlaylistItem;
/*!
* Abstract interface for playlist formats.
*
@@ -43,10 +43,10 @@ public:
virtual QStringList decode(const QString& contents) = 0;
/*!
- * Takes the list of SongInfo objects, should return string of
+ * Takes the list of AbstractPlaylistItem objects, should return string of
* encoded playlist file
*/
- virtual QString encode(const QList<SongInfo*>& contents) = 0;
+ virtual QString encode(const QList<AbstractPlaylistItem*>& contents) = 0;
/*!
* Returns list of file extensions that current format supports
diff --git a/src/qmmpui/playlistparser.h b/src/qmmpui/playlistparser.h
index b2c5585ee..a3ff358e3 100644
--- a/src/qmmpui/playlistparser.h
+++ b/src/qmmpui/playlistparser.h
@@ -23,7 +23,6 @@
#include <QObject>
-class SongInfo;
class PlaylistFormat;
/**
diff --git a/src/qmmpui/qmmpui.pro b/src/qmmpui/qmmpui.pro
index 0f0f40f28..3d60de0c8 100644
--- a/src/qmmpui/qmmpui.pro
+++ b/src/qmmpui/qmmpui.pro
@@ -40,14 +40,16 @@ HEADERS += general.h \
filedialog.h \
filedialogfactory.h \
qtfiledialog.h \
- songinfo.h
+ abstractplaylist.h \
+ abstractplaylistitem.h
SOURCES += general.cpp \
generalhandler.cpp \
playlistparser.cpp \
commandlinemanager.cpp \
filedialog.cpp \
qtfiledialog.cpp \
- songinfo.cpp
+ abstractplaylist.cpp \
+ abstractplaylistitem.cpp
DESTDIR = .
diff --git a/src/qmmpui/songinfo.cpp b/src/qmmpui/songinfo.cpp
deleted file mode 100644
index 417db8a67..000000000
--- a/src/qmmpui/songinfo.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2007 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 "songinfo.h"
-
-SongInfo::SongInfo()
-{}
-
-SongInfo::SongInfo(const SongInfo &other)
-{
- *this = other;
-}
-
-SongInfo::~SongInfo()
-{}
-
-void SongInfo::operator=(const SongInfo &info)
-{
- setValue(TITLE,info.title ());
- setValue(ARTIST,info.artist ());
- setValue(ALBUM,info.album ());
- setValue(COMMENT,info.comment ());
- setValue(GENRE,info.genre ());
- setValue(YEAR,info.year ());
- setValue(TRACK,info.track ());
- setValue(LENGTH,info.length ());
- setValue(STREAM,info.isStream());
- setValue(PATH,info.path());
-}
-
-bool SongInfo::operator==(const SongInfo &info)
-{
- return title() == info.title() &&
- artist() == info.artist() &&
- album() == info.album() &&
- comment() == info.comment() &&
- genre() == info.genre() &&
- track() == info.track() &&
- year() == info.year() &&
- isStream() == info.isStream() &&
- path() == info.path();
-}
-
-bool SongInfo::operator!=(const SongInfo &info)
-{
- return !operator==(info);
-}
-
-void SongInfo::setValue(uint key, const QString &value)
-{
- if (!value.isEmpty())
- {
- if (key == PATH)
- m_path = value;
- else
- m_strValues.insert (key, value);
- }
-}
-
-void SongInfo::setValue(uint key, const uint &value)
-{
- if (value > 0)
- m_numValues.insert (key, value);
-}
-
-void SongInfo::setValue(uint key, const bool &value)
-{
- if(key == STREAM)
- m_stream = value;
-}
-
-const QString SongInfo::title () const
-{
- return m_strValues[TITLE];
-}
-
-const QString SongInfo::artist () const
-{
- return m_strValues[ARTIST];
-}
-
-const QString SongInfo::album () const
-{
- return m_strValues[ALBUM];
-}
-
-const QString SongInfo::comment () const
-{
- return m_strValues[COMMENT];
-}
-
-const QString SongInfo::genre () const
-{
- return m_strValues[GENRE];
-}
-
-const QString SongInfo::path () const
-{
- return m_path;
-}
-
-const QString SongInfo::fileName () const
-{
- return m_path.section('/',-1);
-}
-
-uint SongInfo::year () const
-{
- return m_numValues[YEAR];
-}
-
-uint SongInfo::track () const
-{
- return m_numValues[TRACK];
-}
-
-uint SongInfo::length () const
-{
- return m_numValues[LENGTH];
-}
-
-bool SongInfo::isEmpty () const
-{
- return m_strValues.isEmpty();
-}
-
-void SongInfo::clear ()
-{
- m_path.clear();
- m_strValues.clear();
- m_numValues.clear();
- m_stream = FALSE;
-}
-
-bool SongInfo::isStream () const
-{
- return m_stream;
-}
-
diff --git a/src/ui/eqwidget.cpp b/src/ui/eqwidget.cpp
index 8906389f1..659edcb7a 100644
--- a/src/ui/eqwidget.cpp
+++ b/src/ui/eqwidget.cpp
@@ -316,12 +316,12 @@ void EqWidget::saveAutoPreset()
if (!playlist->currentItem())
return;
//delete preset if it already exists
- EQPreset* preset = findPreset(playlist->currentItem()->fileName());
+ EQPreset* preset = findPreset(playlist->currentItem()->url().section("/",-1));
if (preset)
deletePreset(preset);
//create new preset
preset = new EQPreset();
- preset->setText(playlist->currentItem()->fileName());
+ preset->setText(playlist->currentItem()->url().section("/",-1));
preset->setPreamp(m_preamp->value());
for (int i = 0; i<10; ++i)
{
diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp
index 3be819487..8d36b0f4b 100644
--- a/src/ui/mainwindow.cpp
+++ b/src/ui/mainwindow.cpp
@@ -142,15 +142,8 @@ MainWindow::MainWindow(const QStringList& args, BuiltinCommandLineOption* option
m_generalHandler = new GeneralHandler(this);
connect(m_generalHandler, SIGNAL(playCalled()), SLOT(play()));
- /*connect(m_generalHandler, SIGNAL(nextCalled()), SLOT(next()));
- connect(m_generalHandler, SIGNAL(previousCalled()), SLOT(previous()));
- connect(m_generalHandler, SIGNAL(stopCalled()), SLOT(stop()));
- connect(m_generalHandler, SIGNAL(pauseCalled()), SLOT(pause()));
- connect(m_generalHandler, SIGNAL(seekCalled(int)), SLOT(seek(int)));*/
connect(m_generalHandler, SIGNAL(toggleVisibilityCalled()), SLOT(toggleVisibility()));
connect(m_generalHandler, SIGNAL(exitCalled()), SLOT(close()));
- /*connect(m_generalHandler, SIGNAL(volumeChanged(int, int)),
- m_core, SLOT(setVolume(int, int)));*/
m_playListModel->readSettings();
char buf[PATH_MAX + 1];
@@ -180,10 +173,10 @@ void MainWindow::play()
if (m_playListModel->count() == 0)
return;
- m_equalizer->loadPreset(m_playListModel->currentItem()->fileName());
+ m_equalizer->loadPreset(m_playListModel->currentItem()->url().section("/",-1));
//m_playListModel->currentItem()->updateTags();
m_playlist->listWidget()->updateList();
- QString s = m_playListModel->currentItem()->path();
+ QString s = m_playListModel->currentItem()->url();
if (s.isEmpty())
return;
if (m_core->play(s))
@@ -320,14 +313,6 @@ void MainWindow::showState(Qmmp::State state)
{
case Qmmp::Playing:
{
- //m_generalHandler->setState(General::Playing);
- /*if (m_playListModel->currentItem())
- {
- SongInfo info = *m_playListModel->currentItem();
- if (info.isEmpty())
- info.setValue(SongInfo::TITLE, m_playlist->currentItem()->text());
- m_generalHandler->setSongInfo(info);
- }*/
if (m_playlist->listWidget())
m_playlist->listWidget()->updateList(); //removes progress message from TextScroller
break;
@@ -360,34 +345,11 @@ void MainWindow::showMetaData()
if (m_playlist->currentItem())
{
- SongInfo info;
- info.setValue(SongInfo::TITLE, m_core->metaData(Qmmp::TITLE));
- info.setValue(SongInfo::ARTIST, m_core->metaData(Qmmp::ARTIST));
- info.setValue(SongInfo::ALBUM, m_core->metaData(Qmmp::ALBUM));
- info.setValue(SongInfo::COMMENT, m_core->metaData(Qmmp::COMMENT));
- info.setValue(SongInfo::GENRE, m_core->metaData(Qmmp::GENRE));
- info.setValue(SongInfo::YEAR, m_core->metaData(Qmmp::YEAR).toUInt());
- info.setValue(SongInfo::TRACK, m_core->metaData(Qmmp::TRACK).toUInt());
- info.setValue(SongInfo::STREAM, !QFile::exists(m_playlist->currentItem()->path()));
- info.setValue(SongInfo::PATH, m_playlist->currentItem()->path());
- info.setValue(SongInfo::LENGTH, m_playlist->currentItem()->length());
- //m_generalHandler->setSongInfo(info);
m_playlist->currentItem()->updateMetaData(m_core->metaData());
m_playlist->listWidget()->updateList();
}
}
-void MainWindow::changeTitle(const QString &title)
-{
- if (m_playlist->currentItem())
- m_playlist->currentItem()->setText(title);
- m_playlist->listWidget()->updateList();
- SongInfo info;
- info.setValue(SongInfo::TITLE, title);
- info.setValue(SongInfo::STREAM, TRUE);
- //m_generalHandler->setSongInfo(info);
-}
-
void MainWindow::closeEvent ( QCloseEvent *)
{
writeSettings();
diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h
index 0f7890460..7a8562827 100644
--- a/src/ui/mainwindow.h
+++ b/src/ui/mainwindow.h
@@ -95,7 +95,6 @@ protected:
private slots:
void showState(Qmmp::State state);
void showMetaData();
- void changeTitle(const QString&);
void clear();
void startSeek();
void endSeek();
diff --git a/src/ui/playlistitem.cpp b/src/ui/playlistitem.cpp
index f287ec0f5..bfbaa354c 100644
--- a/src/ui/playlistitem.cpp
+++ b/src/ui/playlistitem.cpp
@@ -24,19 +24,16 @@
#include "playlistitem.h"
-PlayListItem::PlayListItem() : SongInfo(), m_flag(FREE)
+PlayListItem::PlayListItem() : AbstractPlaylistItem(), m_flag(FREE)
{
m_info = 0;
}
-//PlayListItem::PlayListItem(const QString& path) : SongInfo(), m_flag(FREE)
-PlayListItem::PlayListItem(FileInfo *info, QSettings *settings) : SongInfo(), m_flag(FREE)
+PlayListItem::PlayListItem(FileInfo *info, QSettings *settings) : AbstractPlaylistItem(), m_flag(FREE)
{
m_selected = FALSE;
m_current = FALSE;
m_info = info;
- setValue(SongInfo::PATH, info->path()); //TODO path?
- setValue(SongInfo::STREAM, path().startsWith("http://")); //TODO do this inside SongInfo
//use external settings or create new
QSettings *s = settings;
@@ -53,15 +50,10 @@ PlayListItem::PlayListItem(FileInfo *info, QSettings *settings) : SongInfo(), m_
if (!settings) //delete created settings only
delete s;
- if (m_use_meta && !path().startsWith("http://"))
- {
- //m_info = Decoder::createFileInfo(path);
- readMetadata();
- }
- else if (path().startsWith("http://") && m_fullStreamPath)
- m_title = path();
- else
- m_title = path().split('/',QString::SkipEmptyParts).takeLast ();
+ setMetaData(info->metaData());
+ setMetaData(Qmmp::URL, m_info->path());
+ setLength(m_info->length());
+ readMetadata();
}
PlayListItem::~PlayListItem()
@@ -102,25 +94,22 @@ PlayListItem::FLAGS PlayListItem::flag() const
void PlayListItem::updateMetaData(const QMap <Qmmp::MetaData, QString> &metaData)
{
- if (!m_info)
- m_info = new FileInfo();
-
- m_info->setMetaData(metaData);
- m_use_meta = TRUE;
+ setMetaData(metaData);
readMetadata();
}
void PlayListItem::updateTags()
{
- if (path().startsWith("http://"))
+ if (url().startsWith("http://"))
return;
if (m_info)
{
delete m_info;
m_info = 0;
}
- //m_info = Decoder::createFileInfo(path());
- m_info = Decoder::createPlayList(path()).at(0);
+ m_info = Decoder::createPlayList(url()).at(0);
+ setMetaData(m_info->metaData());
+ setMetaData(Qmmp::URL, m_info->path());
readMetadata();
}
@@ -136,37 +125,22 @@ void PlayListItem::setText(const QString &title)
void PlayListItem::readMetadata()
{
- //clear();
- m_title.clear();
- if (m_info) //read length first //TODO fix this
- setValue(SongInfo::LENGTH, uint(m_info->length()));
- if (m_use_meta && m_info && !m_info->isEmpty())
- {
- //fill SongInfo //TODO optimize
- setValue(SongInfo::TITLE, m_info->metaData(Qmmp::TITLE));
- setValue(SongInfo::ARTIST, m_info->metaData(Qmmp::ARTIST));
- setValue(SongInfo::ALBUM, m_info->metaData(Qmmp::ALBUM));
- setValue(SongInfo::COMMENT, m_info->metaData(Qmmp::COMMENT));
- setValue(SongInfo::GENRE, m_info->metaData(Qmmp::GENRE));
- setValue(SongInfo::YEAR, m_info->metaData(Qmmp::YEAR).toUInt());
- setValue(SongInfo::TRACK, m_info->metaData(Qmmp::TRACK).toUInt());
- //generate playlist string
- m_title = m_format;
- m_title = printTag(m_title, "%p", artist());
- m_title = printTag(m_title, "%a", album());
- m_title = printTag(m_title, "%t", title());
- m_title = printTag(m_title, "%n", QString("%1").arg(track()));
- m_title = printTag(m_title, "%g", genre());
- m_title = printTag(m_title, "%f", path().section('/',-1));
- m_title = printTag(m_title, "%F", path());
- m_title = printTag(m_title, "%y", QString("%1").arg(year ()));
- }
+ m_title = m_format;
+ m_title = printTag(m_title, "%p", artist());
+ m_title = printTag(m_title, "%a", album());
+ m_title = printTag(m_title, "%t", title());
+ m_title = printTag(m_title, "%n", QString("%1").arg(track()));
+ m_title = printTag(m_title, "%g", genre());
+ m_title = printTag(m_title, "%f", url().section('/',-1));
+ m_title = printTag(m_title, "%F", url());
+ m_title = printTag(m_title, "%y", QString("%1").arg(year ()));
+
if (m_title.isEmpty())
{
- if (path().startsWith("http://") && m_fullStreamPath)
- m_title = path();
+ if (url().startsWith("http://") && m_fullStreamPath)
+ m_title = url();
else
- m_title = path().split('/',QString::SkipEmptyParts).takeLast ();
+ m_title = url().split('/',QString::SkipEmptyParts).takeLast ();
}
if (m_info)
delete m_info;
diff --git a/src/ui/playlistitem.h b/src/ui/playlistitem.h
index 842691a68..ce26ca2f5 100644
--- a/src/ui/playlistitem.h
+++ b/src/ui/playlistitem.h
@@ -20,15 +20,15 @@
#ifndef PLAYLISTITEM_H
#define PLAYLISTITEM_H
-#include <qmmpui/songinfo.h>
#include <qmmp/qmmp.h>
+#include <qmmpui/abstractplaylistitem.h>
class FileInfo;
class QSettings;
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
*/
-class PlayListItem : public SongInfo
+class PlayListItem : public AbstractPlaylistItem
{
public:
/*!
diff --git a/src/ui/playlistmodel.cpp b/src/ui/playlistmodel.cpp
index 1259db965..333cd7993 100644
--- a/src/ui/playlistmodel.cpp
+++ b/src/ui/playlistmodel.cpp
@@ -305,7 +305,7 @@ void PlayListModel::showDetails()
{
if (m_items.at(i)->isSelected())
{
- if (!QFile::exists(m_items.at(i)->path()))
+ if (!QFile::exists(m_items.at(i)->url()))
{
PlayListItem *item = m_items.at(i);
QString str;
@@ -314,19 +314,19 @@ void PlayListModel::showDetails()
str.append(tr("Artist:") + " %3\n");
str.append(tr("Album:") + " %4\n");
str.append(tr("Comment:") + " %5");
- str = str.arg(item->path())
+ str = str.arg(item->url())
.arg(item->title().isEmpty() ? item->text() : item->title())
.arg(item->artist())
.arg(item->album())
.arg(item->comment());
- QMessageBox::information(0, m_items.at(i)->path(), str);
+ QMessageBox::information(0, m_items.at(i)->url(), str);
return;
}
- DecoderFactory *fact = Decoder::findByPath(m_items.at(i)->path());
+ DecoderFactory *fact = Decoder::findByPath(m_items.at(i)->url());
if (fact)
{
- QObject* o = fact->showDetails(0, m_items.at(i)->path());
+ QObject* o = fact->showDetails(0, m_items.at(i)->url());
if (o)
{
TagUpdater *updater = new TagUpdater(o,m_items.at(i));
@@ -399,7 +399,7 @@ void PlayListModel::writeSettings()
file.open(QIODevice::WriteOnly);
foreach(PlayListItem* m, m_items)
{
- file.write(QString("file=%1").arg(m->path()).toUtf8() +"\n");
+ file.write(QString("file=%1").arg(m->url()).toUtf8() +"\n");
file.write(QString("title=%1").arg(m->title()).toUtf8() +"\n");
file.write(QString("artist=%1").arg(m->artist()).toUtf8() +"\n");
file.write(QString("album=%1").arg(m->album()).toUtf8() +"\n");
@@ -694,25 +694,25 @@ static bool _titleGreaterComparator(PlayListItem* s1,PlayListItem* s2)
static bool _pathAndFilenameLessComparator(PlayListItem* s1,PlayListItem* s2)
{
- return s1->path() < s2->path();
+ return s1->url() < s2->url();
}
static bool _pathAndFilenameGreaterComparator(PlayListItem* s1,PlayListItem* s2)
{
- return s1->path() > s2->path();
+ return s1->url() > s2->url();
}
static bool _filenameLessComparator(PlayListItem* s1,PlayListItem* s2)
{
- QFileInfo i_s1(s1->path());
- QFileInfo i_s2(s2->path());
+ QFileInfo i_s1(s1->url());
+ QFileInfo i_s2(s2->url());
return i_s1.baseName() < i_s2.baseName();
}
static bool _filenameGreaterComparator(PlayListItem* s1,PlayListItem* s2)
{
- QFileInfo i_s1(s1->path());
- QFileInfo i_s2(s2->path());
+ QFileInfo i_s1(s1->url());
+ QFileInfo i_s2(s2->url());
return i_s1.baseName() > i_s2.baseName();
}
@@ -881,7 +881,7 @@ void PlayListModel::savePlaylist(const QString & f_name)
if (file.open(QIODevice::WriteOnly))
{
QTextStream ts(&file);
- QList <SongInfo *> songs;
+ QList <AbstractPlaylistItem *> songs;
foreach(PlayListItem* item, m_items)
songs << item;
ts << prs->encode(songs);