From d206eccac9d08d17911f358fe26ec53d7d0c5d7d Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 13 Oct 2013 21:28:06 +0200 Subject: [PATCH] Improved CueSheet import progress indicator. --- src/Config.h | 2 +- src/Model_AudioFile.cpp | 10 ---------- src/Thread_CueSplitter.cpp | 23 +++++++++++++---------- src/Thread_CueSplitter.h | 2 +- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/Config.h b/src/Config.h index f0ef197a..d0a8a28f 100644 --- a/src/Config.h +++ b/src/Config.h @@ -34,7 +34,7 @@ #define VER_LAMEXP_MINOR_LO 9 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 2 -#define VER_LAMEXP_BUILD 1385 +#define VER_LAMEXP_BUILD 1386 #define VER_LAMEXP_CONFG 1348 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Model_AudioFile.cpp b/src/Model_AudioFile.cpp index 00247b6b..9680ccf1 100644 --- a/src/Model_AudioFile.cpp +++ b/src/Model_AudioFile.cpp @@ -81,12 +81,6 @@ AudioFileModel_MetaInfo &AudioFileModel_MetaInfo::operator=(const AudioFileModel void AudioFileModel_MetaInfo::update(const AudioFileModel_MetaInfo &model, const bool replace) { - qDebug("\n-------[AudioFileModel_MetaInfo::update]-------"); - qDebug("Updating (%p):", this); - print(); - qDebug("\nUpdating with (%p):", &model); - model.print(); - if((!model.m_titel.isEmpty()) && (replace || m_titel.isEmpty())) m_titel = model.m_titel; if((!model.m_artist.isEmpty()) && (replace || m_artist.isEmpty())) m_artist = model.m_artist; if((!model.m_album.isEmpty()) && (replace || m_album.isEmpty())) m_album = model.m_album; @@ -95,10 +89,6 @@ void AudioFileModel_MetaInfo::update(const AudioFileModel_MetaInfo &model, const if((!model.m_cover.isEmpty()) && (replace || m_cover.isEmpty())) m_cover = model.m_cover; if((model.m_year > 0) && (replace || (m_year == 0))) m_year = model.m_year; if((model.m_position > 0) && (replace || (m_position == 0))) m_position = model.m_position; - - qDebug("\nResult:"); - print(); - qDebug("-----------------------------------------------\n\n"); } AudioFileModel_MetaInfo::~AudioFileModel_MetaInfo(void) diff --git a/src/Thread_CueSplitter.cpp b/src/Thread_CueSplitter.cpp index d98834fd..3360f9e6 100644 --- a/src/Thread_CueSplitter.cpp +++ b/src/Thread_CueSplitter.cpp @@ -162,7 +162,7 @@ void CueSplitter::run() nTracksTotal += m_model->getTrackCount(i); } - emit progressMaxChanged(nTracksTotal); + emit progressMaxChanged(10 * nTracksTotal); emit progressValChanged(0); const AudioFileModel_MetaInfo *albumInfo = m_model->getAlbumInfo(); @@ -172,7 +172,6 @@ void CueSplitter::run() { int nTracks = m_model->getTrackCount(i); QString trackFile = m_model->getFileName(i); - int maxProgress = 0; //Process all tracks for(int j = 0; j < nTracks; j++) @@ -209,8 +208,8 @@ void CueSplitter::run() //Call split function emit fileSelected(shortName(QFileInfo(outputFile).fileName())); - splitFile(outputFile, trackNo, trackFile, trackOffset, trackLength, trackMetaInfo, maxProgress); - emit progressValChanged(++nTracksComplete); + splitFile(outputFile, trackNo, trackFile, trackOffset, trackLength, trackMetaInfo, nTracksComplete); + emit progressValChanged(nTracksComplete += 10); if(m_abortFlag) { @@ -221,7 +220,7 @@ void CueSplitter::run() } } - emit progressValChanged(nTracksTotal); + emit progressValChanged(10 * nTracksTotal); lamexp_sleep(333); qDebug("All files were split.\n"); @@ -241,7 +240,7 @@ void CueSplitter::handleUpdate(int progress) // Privtae Functions //////////////////////////////////////////////////////////// -void CueSplitter::splitFile(const QString &output, const int trackNo, const QString &file, const double offset, const double length, const AudioFileModel_MetaInfo &metaInfo, int &maxProgress) +void CueSplitter::splitFile(const QString &output, const int trackNo, const QString &file, const double offset, const double length, const AudioFileModel_MetaInfo &metaInfo, const int baseProgress) { qDebug("[Track %02d]", trackNo); qDebug("File: <%s>", file.toUtf8().constData()); @@ -251,6 +250,8 @@ void CueSplitter::splitFile(const QString &output, const int trackNo, const QStr qDebug("Title: <%s>", metaInfo.title().toUtf8().constData()); qDebug("Album: <%s>", metaInfo.album().toUtf8().constData()); + int prevProgress = baseProgress; + if(!m_decompressedFiles.contains(file)) { qWarning("Unknown or unsupported input file, skipping!"); @@ -262,8 +263,6 @@ void CueSplitter::splitFile(const QString &output, const int trackNo, const QStr QString decompressedInput = m_decompressedFiles[file]; qDebug("Input: <%s>", decompressedInput.toUtf8().constData()); - //emit fileSelected(QString("%1 [%2%]").arg(baseName, QString::number(maxProgress))); - AudioFileModel outFileInfo(output); outFileInfo.setMetaInfo(metaInfo); @@ -337,8 +336,12 @@ void CueSplitter::splitFile(const QString &output, const int trackNo, const QStr int progress = rxProgress.cap(1).toInt(&ok); if(ok) { - maxProgress = qMax(maxProgress, progress); - //emit fileSelected(QString("%1 [%2%]").arg(baseName, QString::number(maxProgress))); + const int newProgress = baseProgress + qRound(static_cast(qBound(0, progress, 100)) / 10.0); + if(newProgress > prevProgress) + { + emit progressValChanged(newProgress); + prevProgress = newProgress; + } } } else if(rxChannels.lastIndexIn(text) >= 0) diff --git a/src/Thread_CueSplitter.h b/src/Thread_CueSplitter.h index 23c6e70e..644e5c8a 100644 --- a/src/Thread_CueSplitter.h +++ b/src/Thread_CueSplitter.h @@ -63,7 +63,7 @@ public slots: void abortProcess(void) { m_abortFlag = true; } private: - void splitFile(const QString &output, const int trackNo, const QString &file, const double offset, const double length, const AudioFileModel_MetaInfo &metaInfo, int &maxProgress); + void splitFile(const QString &output, const int trackNo, const QString &file, const double offset, const double length, const AudioFileModel_MetaInfo &metaInfo, const int baseProgress); QString indexToString(const double index) const; QString shortName(const QString &longName) const;