Major redesign of the AudioFileModel class: Split data into separate AudioFileModel_MetaInfo and AudioFileModel_TechInfo classes.
This commit is contained in:
parent
82b1249c0d
commit
feccffdfd1
@ -34,7 +34,7 @@
|
||||
#define VER_LAMEXP_MINOR_LO 9
|
||||
#define VER_LAMEXP_TYPE Alpha
|
||||
#define VER_LAMEXP_PATCH 2
|
||||
#define VER_LAMEXP_BUILD 1374
|
||||
#define VER_LAMEXP_BUILD 1378
|
||||
#define VER_LAMEXP_CONFG 1348
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -21,236 +21,183 @@
|
||||
|
||||
#include "Model_AudioFile.h"
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
#include <QTime>
|
||||
#include <QObject>
|
||||
#include <QMutexLocker>
|
||||
#include <QFile>
|
||||
#include <limits.h>
|
||||
|
||||
#define U16Str(X) QString::fromUtf16(reinterpret_cast<const unsigned short*>(L##X))
|
||||
#include <limits.h>
|
||||
|
||||
const unsigned int AudioFileModel::BITDEPTH_IEEE_FLOAT32 = UINT_MAX-1;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Constructor & Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Audio File - Meta Info
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AudioFileModel::AudioFileModel(const QString &path, const QString &name)
|
||||
AudioFileModel_MetaInfo::AudioFileModel_MetaInfo(void)
|
||||
{
|
||||
resetAll();
|
||||
|
||||
m_filePath = path;
|
||||
m_fileName = name;
|
||||
reset();
|
||||
}
|
||||
|
||||
AudioFileModel::AudioFileModel(const AudioFileModel &model, bool copyMetaInfo)
|
||||
AudioFileModel_MetaInfo::AudioFileModel_MetaInfo(const AudioFileModel_MetaInfo &model)
|
||||
{
|
||||
resetAll();
|
||||
m_titel = model.m_titel;
|
||||
m_artist = model.m_artist;
|
||||
m_album = model.m_album;
|
||||
m_genre = model.m_genre;
|
||||
m_comment = model.m_comment;
|
||||
m_cover = model.m_cover;
|
||||
m_year = model.m_year;
|
||||
m_position = model.m_position;
|
||||
m_duration = model.m_duration;
|
||||
}
|
||||
|
||||
setFilePath(model.m_filePath);
|
||||
setFormatContainerType(model.m_formatContainerType);
|
||||
setFormatContainerProfile(model.m_formatContainerProfile);
|
||||
setFormatAudioType(model.m_formatAudioType);
|
||||
setFormatAudioProfile(model.m_formatAudioProfile);
|
||||
setFormatAudioVersion(model.m_formatAudioVersion);
|
||||
setFormatAudioEncodeLib(model.m_formatAudioEncodeLib);
|
||||
setFormatAudioSamplerate(model.m_formatAudioSamplerate);
|
||||
setFormatAudioChannels(model.m_formatAudioChannels);
|
||||
setFormatAudioBitdepth(model.m_formatAudioBitdepth);
|
||||
setFormatAudioBitrate(model.m_formatAudioBitrate);
|
||||
setFormatAudioBitrateMode(model.m_formatAudioBitrateMode);
|
||||
setFileDuration(model.m_fileDuration);
|
||||
AudioFileModel_MetaInfo &AudioFileModel_MetaInfo::operator=(const AudioFileModel_MetaInfo &model)
|
||||
{
|
||||
m_titel = model.m_titel;
|
||||
m_artist = model.m_artist;
|
||||
m_album = model.m_album;
|
||||
m_genre = model.m_genre;
|
||||
m_comment = model.m_comment;
|
||||
m_cover = model.m_cover;
|
||||
m_year = model.m_year;
|
||||
m_position = model.m_position;
|
||||
m_duration = model.m_duration;
|
||||
|
||||
if(copyMetaInfo)
|
||||
{
|
||||
setFileName(model.m_fileName);
|
||||
setFileArtist(model.m_fileArtist);
|
||||
setFileAlbum(model.m_fileAlbum);
|
||||
setFileGenre(model.m_fileGenre);
|
||||
setFileComment(model.m_fileComment);
|
||||
setFileCover(model.m_fileCover);
|
||||
setFileYear(model.m_fileYear);
|
||||
setFilePosition(model.m_filePosition);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
|
||||
AudioFileModel_MetaInfo::~AudioFileModel_MetaInfo(void)
|
||||
{
|
||||
/*nothing to do*/
|
||||
}
|
||||
|
||||
void AudioFileModel_MetaInfo::reset(void)
|
||||
{
|
||||
m_titel.clear();
|
||||
m_artist.clear();
|
||||
m_album.clear();
|
||||
m_genre.clear();
|
||||
m_comment.clear();
|
||||
m_cover.clear();
|
||||
m_year = 0;
|
||||
m_position = 0;
|
||||
m_duration = 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Audio File - Technical Info
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AudioFileModel_TechInfo::AudioFileModel_TechInfo(void)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
AudioFileModel_TechInfo::AudioFileModel_TechInfo(const AudioFileModel_TechInfo &model)
|
||||
{
|
||||
m_containerType = model.m_containerType;
|
||||
m_containerProfile = model.m_containerProfile;
|
||||
m_audioType = model.m_audioType;
|
||||
m_audioProfile = model.m_audioProfile;
|
||||
m_audioVersion = model.m_audioVersion;
|
||||
m_audioEncodeLib = model.m_audioEncodeLib;
|
||||
m_audioSamplerate = model.m_audioSamplerate;
|
||||
m_audioChannels = model.m_audioChannels;
|
||||
m_audioBitdepth = model.m_audioBitdepth;
|
||||
m_audioBitrate = model.m_audioBitrate;
|
||||
m_audioBitrateMode = model.m_audioBitrateMode;
|
||||
}
|
||||
|
||||
AudioFileModel_TechInfo &AudioFileModel_TechInfo::operator=(const AudioFileModel_TechInfo &model)
|
||||
{
|
||||
m_containerType = model.m_containerType;
|
||||
m_containerProfile = model.m_containerProfile;
|
||||
m_audioType = model.m_audioType;
|
||||
m_audioProfile = model.m_audioProfile;
|
||||
m_audioVersion = model.m_audioVersion;
|
||||
m_audioEncodeLib = model.m_audioEncodeLib;
|
||||
m_audioSamplerate = model.m_audioSamplerate;
|
||||
m_audioChannels = model.m_audioChannels;
|
||||
m_audioBitdepth = model.m_audioBitdepth;
|
||||
m_audioBitrate = model.m_audioBitrate;
|
||||
m_audioBitrateMode = model.m_audioBitrateMode;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
AudioFileModel_TechInfo::~AudioFileModel_TechInfo(void)
|
||||
{
|
||||
/*nothing to do*/
|
||||
}
|
||||
|
||||
void AudioFileModel_TechInfo::reset(void)
|
||||
{
|
||||
m_containerType.clear();
|
||||
m_containerProfile.clear();
|
||||
m_audioType.clear();
|
||||
m_audioProfile.clear();
|
||||
m_audioVersion.clear();
|
||||
m_audioEncodeLib.clear();
|
||||
m_audioSamplerate = 0;
|
||||
m_audioChannels = 0;
|
||||
m_audioBitdepth = 0;
|
||||
m_audioBitrate = 0;
|
||||
m_audioBitrateMode = 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Audio File Model
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
AudioFileModel::AudioFileModel(const QString &path)
|
||||
:
|
||||
m_filePath(path)
|
||||
{
|
||||
m_metaInfo.reset();
|
||||
m_techInfo.reset();
|
||||
}
|
||||
|
||||
AudioFileModel::AudioFileModel(const AudioFileModel &model)
|
||||
{
|
||||
m_filePath = model.m_filePath;
|
||||
m_metaInfo = model.m_metaInfo;
|
||||
m_techInfo = model.m_techInfo;
|
||||
}
|
||||
|
||||
AudioFileModel &AudioFileModel::operator=(const AudioFileModel &model)
|
||||
{
|
||||
setFilePath(model.m_filePath);
|
||||
setFileName(model.m_fileName);
|
||||
setFileArtist(model.m_fileArtist);
|
||||
setFileAlbum(model.m_fileAlbum);
|
||||
setFileGenre(model.m_fileGenre);
|
||||
setFileComment(model.m_fileComment);
|
||||
setFileCover(model.m_fileCover);
|
||||
setFileYear(model.m_fileYear);
|
||||
setFilePosition(model.m_filePosition);
|
||||
setFileDuration(model.m_fileDuration);
|
||||
|
||||
setFormatContainerType(model.m_formatContainerType);
|
||||
setFormatContainerProfile(model.m_formatContainerProfile);
|
||||
setFormatAudioType(model.m_formatAudioType);
|
||||
setFormatAudioProfile(model.m_formatAudioProfile);
|
||||
setFormatAudioVersion(model.m_formatAudioVersion);
|
||||
setFormatAudioEncodeLib(model.m_formatAudioEncodeLib);
|
||||
setFormatAudioSamplerate(model.m_formatAudioSamplerate);
|
||||
setFormatAudioChannels(model.m_formatAudioChannels);
|
||||
setFormatAudioBitdepth(model.m_formatAudioBitdepth);
|
||||
setFormatAudioBitrate(model.m_formatAudioBitrate);
|
||||
setFormatAudioBitrateMode(model.m_formatAudioBitrateMode);
|
||||
m_filePath = model.m_filePath;
|
||||
m_metaInfo = model.m_metaInfo;
|
||||
m_techInfo = model.m_techInfo;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
AudioFileModel::~AudioFileModel(void)
|
||||
{
|
||||
/*nothing to do*/
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Private Functions
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
void AudioFileModel::resetAll(void)
|
||||
void AudioFileModel::reset(void)
|
||||
{
|
||||
m_filePath.clear();
|
||||
m_fileName.clear();
|
||||
m_fileArtist.clear();
|
||||
m_fileAlbum.clear();
|
||||
m_fileGenre.clear();
|
||||
m_fileComment.clear();
|
||||
m_fileCover.clear();
|
||||
|
||||
m_fileYear = 0;
|
||||
m_filePosition = 0;
|
||||
m_fileDuration = 0;
|
||||
|
||||
m_formatContainerType.clear();
|
||||
m_formatContainerProfile.clear();
|
||||
m_formatAudioType.clear();
|
||||
m_formatAudioProfile.clear();
|
||||
m_formatAudioVersion.clear();
|
||||
m_formatAudioEncodeLib.clear();
|
||||
|
||||
m_formatAudioSamplerate = 0;
|
||||
m_formatAudioChannels = 0;
|
||||
m_formatAudioBitdepth = 0;
|
||||
m_formatAudioBitrate = 0;
|
||||
m_formatAudioBitrateMode = BitrateModeUndefined;
|
||||
m_metaInfo.reset();
|
||||
m_techInfo.reset();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Public Functions
|
||||
////////////////////////////////////////////////////////////
|
||||
/*------------------------------------*/
|
||||
/* Helper functions
|
||||
/*------------------------------------*/
|
||||
|
||||
// ---------------------------------
|
||||
// Getter methods
|
||||
// ---------------------------------
|
||||
|
||||
const QString &AudioFileModel::filePath(void) const
|
||||
const QString AudioFileModel::durationInfo(void) const
|
||||
{
|
||||
return m_filePath;
|
||||
}
|
||||
|
||||
const QString &AudioFileModel::fileName(void) const
|
||||
{
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
const QString &AudioFileModel::fileArtist(void) const
|
||||
{
|
||||
return m_fileArtist;
|
||||
}
|
||||
|
||||
const QString &AudioFileModel::fileAlbum(void) const
|
||||
{
|
||||
return m_fileAlbum;
|
||||
}
|
||||
|
||||
const QString &AudioFileModel::fileGenre(void) const
|
||||
{
|
||||
return m_fileGenre;
|
||||
}
|
||||
|
||||
const QString &AudioFileModel::fileComment(void) const
|
||||
{
|
||||
return m_fileComment;
|
||||
}
|
||||
|
||||
const QString &AudioFileModel::fileCover(void) const
|
||||
{
|
||||
return m_fileCover.filePath();
|
||||
}
|
||||
|
||||
unsigned int AudioFileModel::fileYear(void) const
|
||||
{
|
||||
return m_fileYear;
|
||||
}
|
||||
|
||||
unsigned int AudioFileModel::filePosition(void) const
|
||||
{
|
||||
return m_filePosition;
|
||||
}
|
||||
|
||||
unsigned int AudioFileModel::fileDuration(void) const
|
||||
{
|
||||
return m_fileDuration;
|
||||
}
|
||||
|
||||
const QString &AudioFileModel::formatContainerType(void) const
|
||||
{
|
||||
return m_formatContainerType;
|
||||
}
|
||||
|
||||
const QString &AudioFileModel::formatContainerProfile(void) const
|
||||
{
|
||||
return m_formatContainerProfile;
|
||||
}
|
||||
|
||||
const QString &AudioFileModel::formatAudioType(void) const
|
||||
{
|
||||
return m_formatAudioType;
|
||||
}
|
||||
|
||||
const QString &AudioFileModel::formatAudioProfile(void) const
|
||||
{
|
||||
return m_formatAudioProfile;
|
||||
}
|
||||
|
||||
const QString &AudioFileModel::formatAudioVersion(void) const
|
||||
{
|
||||
return m_formatAudioVersion;
|
||||
}
|
||||
|
||||
unsigned int AudioFileModel::formatAudioSamplerate(void) const
|
||||
{
|
||||
return m_formatAudioSamplerate;
|
||||
}
|
||||
|
||||
unsigned int AudioFileModel::formatAudioChannels(void) const
|
||||
{
|
||||
return m_formatAudioChannels;
|
||||
}
|
||||
|
||||
unsigned int AudioFileModel::formatAudioBitdepth(void) const
|
||||
{
|
||||
return m_formatAudioBitdepth;
|
||||
}
|
||||
|
||||
unsigned int AudioFileModel::formatAudioBitrate(void) const
|
||||
{
|
||||
return m_formatAudioBitrate;
|
||||
}
|
||||
|
||||
unsigned int AudioFileModel::formatAudioBitrateMode(void) const
|
||||
{
|
||||
return m_formatAudioBitrateMode;
|
||||
}
|
||||
|
||||
const QString AudioFileModel::fileDurationInfo(void) const
|
||||
{
|
||||
if(m_fileDuration)
|
||||
if(m_metaInfo.duration())
|
||||
{
|
||||
QTime time = QTime().addSecs(m_fileDuration);
|
||||
QTime time = QTime().addSecs(m_metaInfo.duration());
|
||||
return time.toString("hh:mm:ss");
|
||||
}
|
||||
else
|
||||
@ -259,12 +206,12 @@ const QString AudioFileModel::fileDurationInfo(void) const
|
||||
}
|
||||
}
|
||||
|
||||
const QString AudioFileModel::formatContainerInfo(void) const
|
||||
const QString AudioFileModel::containerInfo(void) const
|
||||
{
|
||||
if(!m_formatContainerType.isEmpty())
|
||||
if(!m_techInfo.containerType().isEmpty())
|
||||
{
|
||||
QString info = m_formatContainerType;
|
||||
if(!m_formatContainerProfile.isEmpty()) info.append(QString(" (%1: %2)").arg(tr("Profile"), m_formatContainerProfile));
|
||||
QString info = m_techInfo.containerType();
|
||||
if(!m_techInfo.containerProfile().isEmpty()) info.append(QString(" (%1: %2)").arg(tr("Profile"), m_techInfo.containerProfile()));
|
||||
return info;
|
||||
}
|
||||
else
|
||||
@ -273,31 +220,31 @@ const QString AudioFileModel::formatContainerInfo(void) const
|
||||
}
|
||||
}
|
||||
|
||||
const QString AudioFileModel::formatAudioBaseInfo(void) const
|
||||
const QString AudioFileModel::audioBaseInfo(void) const
|
||||
{
|
||||
if(m_formatAudioSamplerate || m_formatAudioChannels || m_formatAudioBitdepth)
|
||||
if(m_techInfo.audioSamplerate() || m_techInfo.audioChannels() || m_techInfo.audioBitdepth())
|
||||
{
|
||||
QString info;
|
||||
if(m_formatAudioChannels)
|
||||
if(m_techInfo.audioChannels())
|
||||
{
|
||||
if(!info.isEmpty()) info.append(", ");
|
||||
info.append(QString("%1: %2").arg(tr("Channels"), QString::number(m_formatAudioChannels)));
|
||||
info.append(QString("%1: %2").arg(tr("Channels"), QString::number(m_techInfo.audioChannels())));
|
||||
}
|
||||
if(m_formatAudioSamplerate)
|
||||
if(m_techInfo.audioSamplerate())
|
||||
{
|
||||
if(!info.isEmpty()) info.append(", ");
|
||||
info.append(QString("%1: %2 Hz").arg(tr("Samplerate"), QString::number(m_formatAudioSamplerate)));
|
||||
info.append(QString("%1: %2 Hz").arg(tr("Samplerate"), QString::number(m_techInfo.audioSamplerate())));
|
||||
}
|
||||
if(m_formatAudioBitdepth)
|
||||
if(m_techInfo.audioBitdepth())
|
||||
{
|
||||
if(!info.isEmpty()) info.append(", ");
|
||||
if(m_formatAudioBitdepth == BITDEPTH_IEEE_FLOAT32)
|
||||
if(m_techInfo.audioBitdepth() == BITDEPTH_IEEE_FLOAT32)
|
||||
{
|
||||
info.append(QString("%1: %2 Bit (IEEE Float)").arg(tr("Bitdepth"), QString::number(32)));
|
||||
}
|
||||
else
|
||||
{
|
||||
info.append(QString("%1: %2 Bit").arg(tr("Bitdepth"), QString::number(m_formatAudioBitdepth)));
|
||||
info.append(QString("%1: %2 Bit").arg(tr("Bitdepth"), QString::number(m_techInfo.audioBitdepth())));
|
||||
}
|
||||
}
|
||||
return info;
|
||||
@ -308,42 +255,42 @@ const QString AudioFileModel::formatAudioBaseInfo(void) const
|
||||
}
|
||||
}
|
||||
|
||||
const QString AudioFileModel::formatAudioCompressInfo(void) const
|
||||
const QString AudioFileModel::audioCompressInfo(void) const
|
||||
{
|
||||
if(!m_formatAudioType.isEmpty())
|
||||
if(!m_techInfo.audioType().isEmpty())
|
||||
{
|
||||
QString info;
|
||||
if(!m_formatAudioProfile.isEmpty() || !m_formatAudioVersion.isEmpty())
|
||||
if(!m_techInfo.audioProfile().isEmpty() || !m_techInfo.audioVersion().isEmpty())
|
||||
{
|
||||
info.append(QString("%1: ").arg(tr("Type")));
|
||||
}
|
||||
info.append(m_formatAudioType);
|
||||
if(!m_formatAudioProfile.isEmpty())
|
||||
info.append(m_techInfo.audioType());
|
||||
if(!m_techInfo.audioProfile().isEmpty())
|
||||
{
|
||||
info.append(QString(", %1: %2").arg(tr("Profile"), m_formatAudioProfile));
|
||||
info.append(QString(", %1: %2").arg(tr("Profile"), m_techInfo.audioProfile()));
|
||||
}
|
||||
if(!m_formatAudioVersion.isEmpty())
|
||||
if(!m_techInfo.audioVersion().isEmpty())
|
||||
{
|
||||
info.append(QString(", %1: %2").arg(tr("Version"), m_formatAudioVersion));
|
||||
info.append(QString(", %1: %2").arg(tr("Version"), m_techInfo.audioVersion()));
|
||||
}
|
||||
if(m_formatAudioBitrate > 0)
|
||||
if(m_techInfo.audioBitrate() > 0)
|
||||
{
|
||||
switch(m_formatAudioBitrateMode)
|
||||
switch(m_techInfo.audioBitrateMode())
|
||||
{
|
||||
case BitrateModeConstant:
|
||||
info.append(U16Str(", %1: %2 kbps (%3)").arg(tr("Bitrate"), QString::number(m_formatAudioBitrate), tr("Constant")));
|
||||
info.append(QString(", %1: %2 kbps (%3)").arg(tr("Bitrate"), QString::number(m_techInfo.audioBitrate()), tr("Constant")));
|
||||
break;
|
||||
case BitrateModeVariable:
|
||||
info.append(U16Str(", %1: \u2248%2 kbps (%3)").arg(tr("Bitrate"), QString::number(m_formatAudioBitrate), tr("Variable")));
|
||||
info.append(WCHAR2QSTR(L", %1: \u2248%2 kbps (%3)").arg(tr("Bitrate"), QString::number(m_techInfo.audioBitrate()), tr("Variable")));
|
||||
break;
|
||||
default:
|
||||
info.append(U16Str(", %1: %2 kbps").arg(tr("Bitrate"), QString::number(m_formatAudioBitrate)));
|
||||
info.append(QString(", %1: %2 kbps").arg(tr("Bitrate"), QString::number(m_techInfo.audioBitrate())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!m_formatAudioEncodeLib.isEmpty())
|
||||
if(!m_techInfo.audioEncodeLib().isEmpty())
|
||||
{
|
||||
info.append(QString(", %1: %2").arg(tr("Encoder"), m_formatAudioEncodeLib));
|
||||
info.append(QString(", %1: %2").arg(tr("Encoder"), m_techInfo.audioEncodeLib()));
|
||||
}
|
||||
return info;
|
||||
}
|
||||
@ -352,126 +299,3 @@ const QString AudioFileModel::formatAudioCompressInfo(void) const
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------
|
||||
// Setter methods
|
||||
// ---------------------------------
|
||||
|
||||
void AudioFileModel::setFilePath(const QString &path)
|
||||
{
|
||||
m_filePath = path;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFileName(const QString &name)
|
||||
{
|
||||
m_fileName = name;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFileArtist(const QString &artist)
|
||||
{
|
||||
m_fileArtist = artist;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFileAlbum(const QString &album)
|
||||
{
|
||||
m_fileAlbum = album;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFileGenre(const QString &genre)
|
||||
{
|
||||
m_fileGenre = genre;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFileComment(const QString &comment)
|
||||
{
|
||||
m_fileComment = comment;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFileCover(const QString &coverFile, bool owner)
|
||||
{
|
||||
m_fileCover.setFilePath(coverFile, owner);
|
||||
}
|
||||
|
||||
void AudioFileModel::setFileCover(const ArtworkModel &model)
|
||||
{
|
||||
m_fileCover = model;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFileYear(unsigned int year)
|
||||
{
|
||||
m_fileYear = year;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFilePosition(unsigned int position)
|
||||
{
|
||||
m_filePosition = position;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFileDuration(unsigned int duration)
|
||||
{
|
||||
m_fileDuration = duration;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFormatContainerType(const QString &type)
|
||||
{
|
||||
m_formatContainerType = type;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFormatContainerProfile(const QString &profile)
|
||||
{
|
||||
m_formatContainerProfile = profile;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFormatAudioType(const QString &type)
|
||||
{
|
||||
m_formatAudioType = type;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFormatAudioProfile(const QString &profile)
|
||||
{
|
||||
m_formatAudioProfile = profile;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFormatAudioVersion(const QString &version)
|
||||
{
|
||||
m_formatAudioVersion = version;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFormatAudioEncodeLib(const QString &encodeLib)
|
||||
{
|
||||
m_formatAudioEncodeLib = encodeLib;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFormatAudioSamplerate(unsigned int samplerate)
|
||||
{
|
||||
m_formatAudioSamplerate = samplerate;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFormatAudioChannels(unsigned int channels)
|
||||
{
|
||||
m_formatAudioChannels = channels;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFormatAudioBitdepth(unsigned int bitdepth)
|
||||
{
|
||||
m_formatAudioBitdepth = bitdepth;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFormatAudioBitrate(unsigned int bitrate)
|
||||
{
|
||||
m_formatAudioBitrate = bitrate;
|
||||
}
|
||||
|
||||
void AudioFileModel::setFormatAudioBitrateMode(unsigned int bitrateMode)
|
||||
{
|
||||
m_formatAudioBitrateMode = bitrateMode;
|
||||
}
|
||||
|
||||
void AudioFileModel::updateMetaInfo(const AudioFileModel &model)
|
||||
{
|
||||
if(!model.fileArtist().isEmpty()) setFileArtist(model.fileArtist());
|
||||
if(!model.fileAlbum().isEmpty()) setFileAlbum(model.fileAlbum());
|
||||
if(!model.fileGenre().isEmpty()) setFileGenre(model.fileGenre());
|
||||
if(!model.fileComment().isEmpty()) setFileComment(model.fileComment());
|
||||
if(model.fileYear()) setFileYear(model.fileYear());
|
||||
}
|
||||
|
@ -21,23 +21,131 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Model_Artwork.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QMutex>
|
||||
|
||||
#include "Model_Artwork.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Audio File - Meta Info
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class AudioFileModel_MetaInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//Constructors & Destructor
|
||||
AudioFileModel_MetaInfo(void);
|
||||
AudioFileModel_MetaInfo(const AudioFileModel_MetaInfo &model);
|
||||
AudioFileModel_MetaInfo &operator=(const AudioFileModel_MetaInfo &model);
|
||||
~AudioFileModel_MetaInfo(void);
|
||||
|
||||
//Getter
|
||||
inline const QString &title(void) const { return m_titel; }
|
||||
inline const QString &artist(void) const { return m_artist; }
|
||||
inline const QString &album(void) const { return m_album; }
|
||||
inline const QString &genre(void) const { return m_genre; }
|
||||
inline const QString &comment(void) const { return m_comment; }
|
||||
inline const QString &cover(void) const { return m_cover.filePath(); }
|
||||
inline unsigned int year(void) const { return m_year; }
|
||||
inline unsigned int position(void) const { return m_position; }
|
||||
inline unsigned int duration(void) const { return m_duration; }
|
||||
|
||||
//Setter
|
||||
inline void setTitle(const QString &titel) { m_titel = titel.trimmed(); }
|
||||
inline void setArtist(const QString &artist) { m_artist = artist.trimmed(); }
|
||||
inline void setAlbum(const QString &album) { m_album = album.trimmed(); }
|
||||
inline void setGenre(const QString &genre) { m_genre = genre.trimmed(); }
|
||||
inline void setComment(const QString &comment) { m_comment = comment.trimmed(); }
|
||||
inline const ArtworkModel &cover(const QString &path, const bool isOwner) { m_cover.setFilePath(path, isOwner); }
|
||||
inline void setYear(const unsigned int year) { m_year = year; }
|
||||
inline void setPosition(const unsigned int position) { m_position = position; }
|
||||
inline void setDuration(const unsigned int duration) { m_duration = duration; }
|
||||
|
||||
//Reset
|
||||
void reset(void);
|
||||
|
||||
private:
|
||||
QString m_titel;
|
||||
QString m_artist;
|
||||
QString m_album;
|
||||
QString m_genre;
|
||||
QString m_comment;
|
||||
ArtworkModel m_cover;
|
||||
unsigned int m_year;
|
||||
unsigned int m_position;
|
||||
unsigned int m_duration;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Audio File - Technical Info
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class AudioFileModel_TechInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//Constructors & Destructor
|
||||
AudioFileModel_TechInfo(void);
|
||||
AudioFileModel_TechInfo(const AudioFileModel_TechInfo &model);
|
||||
AudioFileModel_TechInfo &operator=(const AudioFileModel_TechInfo &model);
|
||||
~AudioFileModel_TechInfo(void);
|
||||
|
||||
//Getter
|
||||
inline const QString &containerType(void) const { return m_containerType; }
|
||||
inline const QString &containerProfile(void) const { return m_containerProfile; }
|
||||
inline const QString &audioType(void) const { return m_audioType; }
|
||||
inline const QString &audioProfile(void) const { return m_audioProfile; }
|
||||
inline const QString &audioVersion(void) const { return m_audioVersion; }
|
||||
inline const QString &audioEncodeLib(void) const { return m_audioEncodeLib; }
|
||||
inline unsigned int audioSamplerate(void) const { return m_audioSamplerate; }
|
||||
inline unsigned int audioChannels(void) const { return m_audioChannels; }
|
||||
inline unsigned int audioBitdepth(void) const { return m_audioBitdepth; }
|
||||
inline unsigned int audioBitrate(void) const { return m_audioBitrate; }
|
||||
inline unsigned int audioBitrateMode(void) const { return m_audioBitrateMode; }
|
||||
|
||||
//Setter
|
||||
inline const QString &setContainerType(const QString &containerType) { m_containerType = containerType; }
|
||||
inline const QString &setContainerProfile(const QString &containerProfile) { m_containerProfile = containerProfile; }
|
||||
inline const QString &setAudioType(const QString &audioType) { m_audioType = audioType; }
|
||||
inline const QString &setAudioProfile(const QString &audioProfile) { m_audioProfile = audioProfile; }
|
||||
inline const QString &setAudioVersion(const QString &audioVersion) { m_audioVersion = audioVersion; }
|
||||
inline const QString &setAudioEncodeLib(const QString &audioEncodeLib) { m_audioEncodeLib = audioEncodeLib; }
|
||||
inline unsigned int setAudioSamplerate(const unsigned int audioSamplerate) { m_audioSamplerate = audioSamplerate; }
|
||||
inline unsigned int setAudioChannels(const unsigned int audioChannels) { m_audioChannels = audioChannels; }
|
||||
inline unsigned int setAudioBitdepth(const unsigned int audioBitdepth) { m_audioBitdepth = audioBitdepth; }
|
||||
inline unsigned int setAudioBitrate(const unsigned int audioBitrate) { m_audioBitrate = audioBitrate; }
|
||||
inline unsigned int setAudioBitrateMode(const unsigned int audioBitrateMode) { m_audioBitrateMode = audioBitrateMode; }
|
||||
|
||||
//Reset
|
||||
void reset(void);
|
||||
|
||||
private:
|
||||
QString m_containerType;
|
||||
QString m_containerProfile;
|
||||
QString m_audioType;
|
||||
QString m_audioProfile;
|
||||
QString m_audioVersion;
|
||||
QString m_audioEncodeLib;
|
||||
unsigned int m_audioSamplerate;
|
||||
unsigned int m_audioChannels;
|
||||
unsigned int m_audioBitdepth;
|
||||
unsigned int m_audioBitrate;
|
||||
unsigned int m_audioBitrateMode;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Audio File Model
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class AudioFileModel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioFileModel(const QString &path = QString(), const QString &name = QString());
|
||||
AudioFileModel(const AudioFileModel &model, bool copyMetaInfo = true);
|
||||
AudioFileModel &operator=(const AudioFileModel &model);
|
||||
~AudioFileModel(void);
|
||||
|
||||
//Types
|
||||
enum BitrateMode
|
||||
{
|
||||
BitrateModeUndefined = 0,
|
||||
@ -45,92 +153,38 @@ public:
|
||||
BitrateModeVariable = 2,
|
||||
};
|
||||
|
||||
//Constants
|
||||
static const unsigned int BITDEPTH_IEEE_FLOAT32;
|
||||
|
||||
//-----------------------
|
||||
//Getters
|
||||
//-----------------------
|
||||
//Constructors & Destructor
|
||||
AudioFileModel(const QString &path);
|
||||
AudioFileModel(const AudioFileModel &model);
|
||||
AudioFileModel &operator=(const AudioFileModel &model);
|
||||
~AudioFileModel(void);
|
||||
|
||||
const QString &filePath(void) const;
|
||||
const QString &fileName(void) const;
|
||||
const QString &fileArtist(void) const;
|
||||
const QString &fileAlbum(void) const;
|
||||
const QString &fileGenre(void) const;
|
||||
const QString &fileComment(void) const;
|
||||
const QString &fileCover(void) const;
|
||||
unsigned int fileYear(void) const;
|
||||
unsigned int filePosition(void) const;
|
||||
unsigned int fileDuration(void) const;
|
||||
//Getter
|
||||
inline const QString &filePath(void) const { return m_filePath; }
|
||||
inline const AudioFileModel_MetaInfo &metaInfo(void) const { return m_metaInfo; }
|
||||
inline const AudioFileModel_TechInfo &techInfo(void) const { return m_techInfo; }
|
||||
inline AudioFileModel_MetaInfo &metaInfo(void) { return m_metaInfo; }
|
||||
inline AudioFileModel_TechInfo &techInfo(void) { return m_techInfo; }
|
||||
|
||||
const QString &formatContainerType(void) const;
|
||||
const QString &formatContainerProfile(void) const;
|
||||
const QString &formatAudioType(void) const;
|
||||
const QString &formatAudioProfile(void) const;
|
||||
const QString &formatAudioVersion(void) const;
|
||||
unsigned int formatAudioSamplerate(void) const;
|
||||
unsigned int formatAudioChannels(void) const;
|
||||
unsigned int formatAudioBitdepth(void) const;
|
||||
unsigned int formatAudioBitrate(void) const;
|
||||
unsigned int formatAudioBitrateMode(void) const;
|
||||
//Setter
|
||||
inline const QString &setFilePath(const QString &filePath) { m_filePath = filePath; }
|
||||
inline void setMetaInfo(const AudioFileModel_MetaInfo &metaInfo) { m_metaInfo = metaInfo; }
|
||||
inline void setTechInfo(const AudioFileModel_TechInfo &techInfo) { m_techInfo = techInfo; }
|
||||
|
||||
const QString fileDurationInfo(void) const;
|
||||
const QString formatContainerInfo(void) const;
|
||||
const QString formatAudioBaseInfo(void) const;
|
||||
const QString formatAudioCompressInfo(void) const;
|
||||
//Helpers
|
||||
const QString durationInfo(void) const;
|
||||
const QString containerInfo(void) const;
|
||||
const QString audioBaseInfo(void) const;
|
||||
const QString audioCompressInfo(void) const;
|
||||
|
||||
//-----------------------
|
||||
//Setters
|
||||
//-----------------------
|
||||
|
||||
void setFilePath(const QString &path);
|
||||
void setFileName(const QString &name);
|
||||
void setFileArtist(const QString &artist);
|
||||
void setFileAlbum(const QString &album);
|
||||
void setFileGenre(const QString &genre);
|
||||
void setFileComment(const QString &comment);
|
||||
void setFileCover(const QString &coverFile, bool owner);
|
||||
void setFileCover(const ArtworkModel &model);
|
||||
void setFileYear(unsigned int year);
|
||||
void setFilePosition(unsigned int position);
|
||||
void setFileDuration(unsigned int duration);
|
||||
|
||||
void setFormatContainerType(const QString &type);
|
||||
void setFormatContainerProfile(const QString &profile);
|
||||
void setFormatAudioType(const QString &type);
|
||||
void setFormatAudioProfile(const QString &profile);
|
||||
void setFormatAudioVersion(const QString &version);
|
||||
void setFormatAudioEncodeLib(const QString &encodeLib);
|
||||
void setFormatAudioSamplerate(unsigned int samplerate);
|
||||
void setFormatAudioChannels(unsigned int channels);
|
||||
void setFormatAudioBitdepth(unsigned int bitdepth);
|
||||
void setFormatAudioBitrate(unsigned int bitrate);
|
||||
void setFormatAudioBitrateMode(unsigned int bitrateMode);
|
||||
|
||||
void updateMetaInfo(const AudioFileModel &model);
|
||||
//Reset
|
||||
void reset(void);
|
||||
|
||||
private:
|
||||
QString m_filePath;
|
||||
QString m_fileName;
|
||||
QString m_fileArtist;
|
||||
QString m_fileAlbum;
|
||||
QString m_fileGenre;
|
||||
QString m_fileComment;
|
||||
ArtworkModel m_fileCover;
|
||||
unsigned int m_fileYear;
|
||||
unsigned int m_filePosition;
|
||||
unsigned int m_fileDuration;
|
||||
|
||||
QString m_formatContainerType;
|
||||
QString m_formatContainerProfile;
|
||||
QString m_formatAudioType;
|
||||
QString m_formatAudioProfile;
|
||||
QString m_formatAudioVersion;
|
||||
QString m_formatAudioEncodeLib;
|
||||
unsigned int m_formatAudioSamplerate;
|
||||
unsigned int m_formatAudioChannels;
|
||||
unsigned int m_formatAudioBitdepth;
|
||||
unsigned int m_formatAudioBitrate;
|
||||
unsigned int m_formatAudioBitrateMode;
|
||||
|
||||
void resetAll(void);
|
||||
AudioFileModel_MetaInfo m_metaInfo;
|
||||
AudioFileModel_TechInfo m_techInfo;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user