Slightly improved progress indicator for file analyzer: Additional files from playlists are now taken into account earlier.

This commit is contained in:
LoRd_MuldeR 2012-05-08 01:12:26 +02:00
parent 21154b10c4
commit 814b725fe3
8 changed files with 40 additions and 17 deletions

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 5
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 1
#define VER_LAMEXP_BUILD 1017
#define VER_LAMEXP_BUILD 1018
///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!)

View File

@ -43,7 +43,7 @@
WorkingBanner::WorkingBanner(QWidget *parent)
:
QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint),
m_progressMax(0), m_progressVal(0)
m_progressMax(0), m_progressVal(0), m_metrics(NULL)
{
//Init the dialog, from the .ui file
setupUi(this);
@ -90,6 +90,7 @@ WorkingBanner::~WorkingBanner(void)
}
LAMEXP_DELETE(m_progress);
LAMEXP_DELETE(m_metrics);
}
////////////////////////////////////////////////////////////
@ -205,15 +206,19 @@ bool WorkingBanner::winEvent(MSG *message, long *result)
void WorkingBanner::setText(const QString &text)
{
QFontMetrics metrics(labelStatus->font());
if(metrics.width(text) <= labelStatus->width())
if(!m_metrics)
{
m_metrics = new QFontMetrics(labelStatus->font());
}
if(m_metrics->width(text) <= labelStatus->width())
{
labelStatus->setText(text);
}
else
{
QString choppedText = text.simplified().append("...");
while(metrics.width(choppedText) > labelStatus->width() && choppedText.length() > 8)
while((m_metrics->width(choppedText) > labelStatus->width()) && (choppedText.length() > 8))
{
choppedText.chop(4);
choppedText = choppedText.trimmed();

View File

@ -59,6 +59,7 @@ protected:
bool winEvent(MSG *message, long *result);
QLabel *m_progress;
QFontMetrics *m_metrics;
unsigned int m_progressMax;
unsigned int m_progressVal;
};

View File

@ -23,7 +23,7 @@
#include <QUuid>
#define MAX_DISPLAY_ITEMS 32
#define MAX_DISPLAY_ITEMS 48
ProgressModel::ProgressModel(void)
:

View File

@ -155,8 +155,7 @@ void CueSplitter::run()
}
int nFiles = m_model->getFileCount();
int nTracksTotal = 0;
int nTracksComplete = 0;
int nTracksTotal = 0, nTracksComplete = 0;
for(int i = 0; i < nFiles; i++)
{

View File

@ -173,6 +173,10 @@ void FileAnalyzer::run()
}
else
{
if(int count = AnalyzeTask::getAdditionalFiles(m_inputFiles))
{
emit progressMaxChanged(nFiles += count);
}
QThread::msleep(5);
}
}
@ -181,9 +185,10 @@ void FileAnalyzer::run()
if(!m_bAborted)
{
pool->waitForDone();
AnalyzeTask::getAdditionalFiles(m_inputFiles);
nFiles += m_inputFiles.count();
emit progressMaxChanged(nFiles);
if(int count = AnalyzeTask::getAdditionalFiles(m_inputFiles))
{
emit progressMaxChanged(nFiles += count);
}
}
}

View File

@ -145,8 +145,9 @@ void AnalyzeTask::run_ex(void)
QStringList fileList;
if(PlaylistImporter::importPlaylist(fileList, currentFile))
{
QWriteLocker lock(&s_lock);
waitForPreviousThreads();
qDebug("Imported playlist file.");
QWriteLocker lock(&s_lock);
s_additionalFiles << fileList;
}
else if(!QFileInfo(currentFile).suffix().compare("cue", Qt::CaseInsensitive))
@ -164,6 +165,7 @@ void AnalyzeTask::run_ex(void)
s_filesAccepted++;
s_recentlyAdded.append(file.filePath());
lock.unlock();
waitForPreviousThreads();
emit fileAnalyzed(file);
}
@ -767,11 +769,22 @@ unsigned int AnalyzeTask::filesCueSheet(void)
return s_filesCueSheet;
}
void AnalyzeTask::getAdditionalFiles(QStringList &fileList)
int AnalyzeTask::getAdditionalFiles(QStringList &fileList)
{
QReadLocker lock(&s_lock);
fileList << s_additionalFiles;
s_additionalFiles.clear();
QReadLocker readLock(&s_lock);
int count = s_additionalFiles.count();
readLock.unlock();
if(count > 0)
{
QWriteLocker lock(&s_lock);
count = s_additionalFiles.count();
fileList << s_additionalFiles;
s_additionalFiles.clear();
return count;
}
return 0;
}
void AnalyzeTask::reset(void)

View File

@ -46,7 +46,7 @@ public:
~AnalyzeTask(void);
static void reset(void);
static void getAdditionalFiles(QStringList &fileList);
static int getAdditionalFiles(QStringList &fileList);
static unsigned int filesAccepted(void);
static unsigned int filesRejected(void);
static unsigned int filesDenied(void);