Refactor audio file model.
This commit is contained in:
parent
18bc47cb9a
commit
0fd4b56a87
@ -25,7 +25,7 @@
|
||||
#define VER_LAMEXP_MAJOR 4
|
||||
#define VER_LAMEXP_MINOR_HI 0
|
||||
#define VER_LAMEXP_MINOR_LO 0
|
||||
#define VER_LAMEXP_BUILD 291
|
||||
#define VER_LAMEXP_BUILD 293
|
||||
#define VER_LAMEXP_SUFFIX Beta-3
|
||||
|
||||
/*
|
||||
|
@ -596,18 +596,16 @@ AudioFileModel ProcessingDialog::updateMetaInfo(const AudioFileModel &audioFile)
|
||||
{
|
||||
if(!m_settings->writeMetaTags())
|
||||
{
|
||||
AudioFileModel result(audioFile, false);
|
||||
return result;
|
||||
return AudioFileModel(audioFile, false);
|
||||
}
|
||||
|
||||
AudioFileModel result = audioFile;
|
||||
result.updateMetaInfo(*m_metaInfo);
|
||||
|
||||
if(!m_metaInfo->fileArtist().isEmpty()) result.setFileArtist(m_metaInfo->fileArtist());
|
||||
if(!m_metaInfo->fileAlbum().isEmpty()) result.setFileAlbum(m_metaInfo->fileAlbum());
|
||||
if(!m_metaInfo->fileGenre().isEmpty()) result.setFileGenre(m_metaInfo->fileGenre());
|
||||
if(m_metaInfo->fileYear()) result.setFileYear(m_metaInfo->fileYear());
|
||||
if(m_metaInfo->filePosition() == UINT_MAX) result.setFilePosition(m_currentFile);
|
||||
if(!m_metaInfo->fileComment().isEmpty()) result.setFileComment(m_metaInfo->fileComment());
|
||||
if(m_metaInfo->filePosition() == UINT_MAX)
|
||||
{
|
||||
result.setFilePosition(m_currentFile);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -30,24 +30,15 @@
|
||||
|
||||
AudioFileModel::AudioFileModel(const QString &path, const QString &name)
|
||||
{
|
||||
resetAll();
|
||||
|
||||
m_filePath = path;
|
||||
m_fileName = name;
|
||||
m_fileYear = 0;
|
||||
m_filePosition = 0;
|
||||
m_fileDuration = 0;
|
||||
m_formatAudioSamplerate = 0;
|
||||
m_formatAudioChannels = 0;
|
||||
m_formatAudioBitdepth = 0;
|
||||
}
|
||||
|
||||
AudioFileModel::AudioFileModel(const AudioFileModel &model, bool copyMetaInfo)
|
||||
{
|
||||
m_fileYear = 0;
|
||||
m_filePosition = 0;
|
||||
m_fileDuration = 0;
|
||||
m_formatAudioSamplerate = 0;
|
||||
m_formatAudioChannels = 0;
|
||||
m_formatAudioBitdepth = 0;
|
||||
resetAll();
|
||||
|
||||
setFilePath(model.m_filePath);
|
||||
setFormatContainerType(model.m_formatContainerType);
|
||||
@ -100,6 +91,34 @@ AudioFileModel::~AudioFileModel(void)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Private Functions
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
void AudioFileModel::resetAll(void)
|
||||
{
|
||||
m_filePath.clear();
|
||||
m_fileName.clear();
|
||||
m_fileArtist.clear();
|
||||
m_fileAlbum.clear();
|
||||
m_fileGenre.clear();
|
||||
m_fileComment.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_formatAudioSamplerate = 0;
|
||||
m_formatAudioChannels = 0;
|
||||
m_formatAudioBitdepth = 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Public Functions
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -362,3 +381,12 @@ void AudioFileModel::setFormatAudioBitdepth(unsigned int bitdepth)
|
||||
{
|
||||
m_formatAudioBitdepth = bitdepth;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -85,6 +85,8 @@ public:
|
||||
void setFormatAudioChannels(unsigned int channels);
|
||||
void setFormatAudioBitdepth(unsigned int bitdepth);
|
||||
|
||||
void updateMetaInfo(const AudioFileModel &model);
|
||||
|
||||
private:
|
||||
QString m_filePath;
|
||||
QString m_fileName;
|
||||
@ -104,4 +106,6 @@ private:
|
||||
unsigned int m_formatAudioSamplerate;
|
||||
unsigned int m_formatAudioChannels;
|
||||
unsigned int m_formatAudioBitdepth;
|
||||
|
||||
void resetAll(void);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user