aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-10-03 18:05:33 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-10-03 18:05:33 +0000
commit0bb73fcbfda56e4cb064a7bc1ceda89312087f3d (patch)
tree71b494d898c1a715d175057334ea4b8e570a7dc0
parent4bd77573e83df590f114bbe845506458d2981d50 (diff)
downloadqmmp-0bb73fcbfda56e4cb064a7bc1ceda89312087f3d.tar.gz
qmmp-0bb73fcbfda56e4cb064a7bc1ceda89312087f3d.tar.bz2
qmmp-0bb73fcbfda56e4cb064a7bc1ceda89312087f3d.zip
some FileInfo class improvements
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@574 90c681e8-e032-0410-971d-27865f9a5e38
-rw-r--r--src/qmmp/decoder.cpp3
-rw-r--r--src/qmmp/fileinfo.cpp50
-rw-r--r--src/qmmp/fileinfo.h15
3 files changed, 41 insertions, 27 deletions
diff --git a/src/qmmp/decoder.cpp b/src/qmmp/decoder.cpp
index c4404b739..25643e435 100644
--- a/src/qmmp/decoder.cpp
+++ b/src/qmmp/decoder.cpp
@@ -405,6 +405,9 @@ FileInfo *Decoder::createFileInfo(const QString &fileName)
DecoderFactory *fact = Decoder::findByPath(fileName);
if (fact && QFile::exists(fileName))
{
+ FileInfo *info = fact->createFileInfo(fileName);
+ if (info && info->url().isEmpty())
+ info->setUrl(QUrl::fromLocalFile (fileName));
return fact->createFileInfo(fileName);
}
return 0;
diff --git a/src/qmmp/fileinfo.cpp b/src/qmmp/fileinfo.cpp
index 4cb0811ac..055cec343 100644
--- a/src/qmmp/fileinfo.cpp
+++ b/src/qmmp/fileinfo.cpp
@@ -22,45 +22,35 @@
FileInfo::FileInfo()
{
m_length = 0;
+ m_count = 1;
}
-/*FileInfo::FileInfo(const FileInfo &other)
+FileInfo::FileInfo(const FileInfo &other)
{
*this = other;
-}*/
+}
FileInfo::~FileInfo()
{}
-/*void FileInfo::operator=(const FileInfo &tag)
+void FileInfo::operator=(const FileInfo &info)
{
- setValue(TITLE,tag.title ());
- setValue(ARTIST,tag.artist ());
- setValue(ALBUM,tag.album ());
- setValue(COMMENT,tag.comment ());
- setValue(GENRE,tag.genre ());
- setValue(YEAR,tag.year ());
- setValue(TRACK,tag.track ());
- setValue(LENGTH,tag.length ());
+ setLength(info.length());
+ setMetaData(info.metaData());
+ setUrl(info.url());
}
-bool FileInfo::operator==(const FileInfo &tag)
+bool FileInfo::operator==(const FileInfo &info)
{
- return title() == tag.title() &&
- artist() == tag.artist() &&
- album() == tag.album() &&
- comment() == tag.comment() &&
- genre() == tag.genre() &&
- year() == tag.year() &&
- track() == tag.track() &&
- length() == tag.length() &&
- isEmpty() == tag.isEmpty();
+ return metaData () == info.metaData () &&
+ length () == info.length ();
+ url() == info.url();
}
-bool FileInfo::operator!=(const FileInfo &tag)
+bool FileInfo::operator!=(const FileInfo &info)
{
- return !operator==(tag);
-}*/
+ return !operator==(info);
+}
const qint64 FileInfo::length () const
{
@@ -82,11 +72,16 @@ void FileInfo::setMetaData(const QMap<Qmmp::MetaData, QString> &metaData)
m_metaData = metaData;
}
-bool FileInfo::isEmpty()
+bool FileInfo::isEmpty() const
{
return m_metaData.isEmpty(); //TODO add correct test
}
+const QUrl FileInfo::url() const
+{
+ return m_url;
+}
+
void FileInfo::setLength(qint64 length)
{
m_length = length;
@@ -101,3 +96,8 @@ void FileInfo::setMetaData(Qmmp::MetaData key, int value)
{
m_metaData.insert(key, QString::number(value));
}
+
+void FileInfo::setUrl(const QUrl &url)
+{
+ m_url = url;
+}
diff --git a/src/qmmp/fileinfo.h b/src/qmmp/fileinfo.h
index 367c34a5c..a2e70188e 100644
--- a/src/qmmp/fileinfo.h
+++ b/src/qmmp/fileinfo.h
@@ -22,6 +22,7 @@
#include <QString>
#include <QMap>
+#include <QUrl>
#include "qmmp.h"
@@ -32,23 +33,33 @@ class FileInfo
{
public:
FileInfo();
- //FileInfo(const FileInfo &other);
+ FileInfo(const FileInfo &other);
~FileInfo();
+ void operator=(const FileInfo &info);
+ bool operator==(const FileInfo &info);
+ bool operator!=(const FileInfo &info);
+
const qint64 length () const;
const QString metaData (Qmmp::MetaData key) const;
const QMap<Qmmp::MetaData, QString> metaData () const;
- bool isEmpty();
+ bool isEmpty() const;
+ const QUrl url() const;
+ int count();
void setLength(qint64 length);
void setMetaData(Qmmp::MetaData key, const QString &value);
void setMetaData(Qmmp::MetaData key, int value);
void setMetaData(const QMap <Qmmp::MetaData, QString> &metaData);
+ void setUrl(const QUrl &url);
private:
QMap <Qmmp::MetaData, QString> m_metaData;
qint64 m_length;
+ QUrl m_url;
+ int m_count;
+ QList<QMap<int, int> > map;
};
#endif