>
</File>
<File
+ RelativePath=".\src\Model_Artwork.cpp"
+ >
+ </File>
+ <File
RelativePath=".\src\Model_AudioFile.cpp"
>
</File>
>
</File>
<File
+ RelativePath=".\src\Model_Artwork.h"
+ >
+ </File>
+ <File
RelativePath=".\src\Model_AudioFile.h"
>
<FileConfiguration
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 1
-#define VER_LAMEXP_BUILD 390
-#define VER_LAMEXP_SUFFIX Beta-10
+#define VER_LAMEXP_BUILD 394
+#define VER_LAMEXP_SUFFIX Beta-11
/*
* Tools versions
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// LameXP - Audio Encoder Front-End
+// Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
+//
+// 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.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// http://www.gnu.org/licenses/gpl-2.0.txt
+///////////////////////////////////////////////////////////////////////////////
+
+#include "Model_Artwork.h"
+
+#include "Global.h"
+
+#include <QFile>
+#include <QMutexLocker>
+
+////////////////////////////////////////////////////////////
+
+QMutex ArtworkModel::m_mutex;
+QMap<QString, unsigned int> ArtworkModel::m_refCount;
+QMap<QString, QFile*> ArtworkModel::m_fileHandle;
+
+////////////////////////////////////////////////////////////
+// Constructor & Destructor
+////////////////////////////////////////////////////////////
+
+ArtworkModel::ArtworkModel(void)
+{
+}
+
+ArtworkModel::ArtworkModel(const QString &fileName)
+{
+ setFilePath(fileName);
+}
+
+ArtworkModel::ArtworkModel(const ArtworkModel &model)
+{
+ setFilePath(model.m_filePath);
+}
+
+ArtworkModel &ArtworkModel::operator=(const ArtworkModel &model)
+{
+ setFilePath(model.m_filePath);
+ return (*this);
+}
+
+ArtworkModel::~ArtworkModel(void)
+{
+ clear();
+}
+
+
+////////////////////////////////////////////////////////////
+// Public Functions
+////////////////////////////////////////////////////////////
+
+const QString &ArtworkModel::filePath(void) const
+{
+ return m_filePath;
+}
+
+void ArtworkModel::setFilePath(const QString &newPath)
+{
+ if(newPath.isEmpty() || m_filePath.isEmpty() || QString::compare(m_filePath, newPath,Qt::CaseInsensitive))
+ {
+ clear();
+
+ if(!newPath.isEmpty())
+ {
+ QMutexLocker lock(&m_mutex);
+
+ if(!m_refCount.contains(newPath))
+ {
+ m_refCount.insert(newPath, 0);
+ m_fileHandle.insert(newPath, new QFile(newPath));
+ m_fileHandle[newPath]->open(QIODevice::ReadOnly);
+ }
+
+ m_refCount[newPath]++;
+ }
+
+ m_filePath = newPath;
+ }
+}
+
+void ArtworkModel:: clear(void)
+{
+ if(!m_filePath.isEmpty())
+ {
+ QMutexLocker lock(&m_mutex);
+
+ if(m_refCount.contains(m_filePath))
+ {
+ if(--m_refCount[m_filePath] < 1)
+ {
+ m_refCount.remove(m_filePath);
+
+ if(m_fileHandle.contains(m_filePath))
+ {
+ if(QFile *fileHandle = m_fileHandle.take(m_filePath))
+ {
+ fileHandle->remove();
+ LAMEXP_DELETE(fileHandle);
+ }
+ }
+
+ QFile::remove(m_filePath);
+ }
+ }
+
+ m_filePath.clear();
+ }
+}
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// LameXP - Audio Encoder Front-End
+// Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
+//
+// 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.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// http://www.gnu.org/licenses/gpl-2.0.txt
+///////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#include <QString>
+#include <QMap>
+#include <QMutex>
+
+class QFile;
+
+class ArtworkModel
+{
+public:
+ ArtworkModel(void);
+ ArtworkModel(const QString &fileName);
+ ArtworkModel(const ArtworkModel &model);
+ ArtworkModel &operator=(const ArtworkModel &model);
+ ~ArtworkModel(void);
+
+ const QString &filePath(void) const;
+ void setFilePath(const QString &newPath);
+ void clear(void);
+
+private:
+ QString m_filePath;
+
+ static QMutex m_mutex;
+ static QMap<QString, unsigned int> m_refCount;
+ static QMap<QString, QFile*> m_fileHandle;
+};
#include <QMutexLocker>
#include <QFile>
-QMutex AudioFileModel::m_mutexCovers;
-QMap<QString, unsigned int> AudioFileModel::m_counterCovers;
-QMap<QString, QFile*> AudioFileModel::m_locksCovers;
-
////////////////////////////////////////////////////////////
// Constructor & Destructor
////////////////////////////////////////////////////////////
setFileAlbum(model.m_fileAlbum);
setFileGenre(model.m_fileGenre);
setFileComment(model.m_fileComment);
- setFileCover(model.m_fileCover);
+ setFileCover(model.m_fileCover.filePath());
setFileYear(model.m_fileYear);
setFilePosition(model.m_filePosition);
}
setFileAlbum(model.m_fileAlbum);
setFileGenre(model.m_fileGenre);
setFileComment(model.m_fileComment);
- setFileCover(model.m_fileCover);
+ setFileCover(model.m_fileCover.filePath());
setFileYear(model.m_fileYear);
setFilePosition(model.m_filePosition);
setFileDuration(model.m_fileDuration);
AudioFileModel::~AudioFileModel(void)
{
- if(!m_fileCover.isEmpty())
- {
- setFileCover(QString());
- }
}
////////////////////////////////////////////////////////////
const QString &AudioFileModel::fileCover(void) const
{
- return m_fileCover;
+ return m_fileCover.filePath();
}
unsigned int AudioFileModel::fileYear(void) const
void AudioFileModel::setFileCover(const QString &coverFile)
{
- QMutexLocker lock(&m_mutexCovers);
- if(m_fileCover.isEmpty() || coverFile.isEmpty() || (m_fileCover.compare(coverFile, Qt::CaseInsensitive) != 0))
- {
- if(!m_fileCover.isEmpty() && m_counterCovers.contains(m_fileCover))
- {
- if(--m_counterCovers[m_fileCover] < 1)
- {
- m_counterCovers.remove(m_fileCover);
- if(m_locksCovers.contains(m_fileCover))
- {
- delete m_locksCovers[m_fileCover];
- m_locksCovers.remove(m_fileCover);
- }
- QFile::remove(m_fileCover);
- }
- }
- if(!coverFile.isEmpty())
- {
- if(!m_counterCovers.contains(coverFile))
- {
- m_counterCovers.insert(coverFile, 0);
- m_locksCovers.insert(coverFile, new QFile(coverFile));
- m_locksCovers[coverFile]->open(QIODevice::ReadOnly);
- }
- m_counterCovers[coverFile]++;
- }
- }
-
- m_fileCover = coverFile;
+ m_fileCover = ArtworkModel(coverFile);
}
void AudioFileModel::setFileYear(unsigned int year)
#pragma once
+#include "Model_Artwork.h"
+
#include <QObject>
#include <QString>
#include <QMap>
#include <QMutex>
-class QFile;
-
class AudioFileModel : public QObject
{
Q_OBJECT
QString m_fileAlbum;
QString m_fileGenre;
QString m_fileComment;
- QString m_fileCover;
+ ArtworkModel m_fileCover;
unsigned int m_fileYear;
unsigned int m_filePosition;
unsigned int m_fileDuration;
unsigned int m_formatAudioChannels;
unsigned int m_formatAudioBitdepth;
- static QMutex m_mutexCovers;
- static QMap<QString, unsigned int> m_counterCovers;
- static QMap<QString, QFile*> m_locksCovers;
-
void resetAll(void);
};
{
if(audioFile.formatContainerProfile().isEmpty()) audioFile.setFormatContainerProfile(value);
}
+ else if(!key.compare("Cover", Qt::CaseInsensitive) || !key.compare("Cover type", Qt::CaseInsensitive))
+ {
+ if(m_currentCover == coverNone) m_currentCover = coverJpeg;
+ }
else if(!key.compare("Cover MIME", Qt::CaseInsensitive))
{
QString temp = value.split(" ", QString::SkipEmptyParts, Qt::CaseInsensitive).first();