Major redesign of the AudioFileModel class: Split data into separate AudioFileModel_M...
[LameXP.git] / src / Thread_FileAnalyzer.h
blobea47c4bd706e913bf9407d229b10429f597c3afc
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #pragma once
24 //#include "Model_AudioFile.h"
26 #include <QThread>
27 #include <QStringList>
28 #include <QHash>
29 #include <QSet>
31 class AudioFileModel;
32 class QFile;
33 class QDir;
34 class QFileInfo;
35 class LockedFile;
36 class QThreadPool;
37 class QElapsedTimer;
39 ////////////////////////////////////////////////////////////
40 // Splash Thread
41 ////////////////////////////////////////////////////////////
43 class FileAnalyzer: public QThread
45 Q_OBJECT
47 public:
48 FileAnalyzer(const QStringList &inputFiles);
49 ~FileAnalyzer(void);
50 void run();
51 bool getSuccess(void) { return (!isRunning()) && (!m_bAborted) && m_bSuccess; }
53 unsigned int filesAccepted(void);
54 unsigned int filesRejected(void);
55 unsigned int filesDenied(void);
56 unsigned int filesDummyCDDA(void);
57 unsigned int filesCueSheet(void);
59 signals:
60 void fileSelected(const QString &fileName);
61 void fileAnalyzed(const AudioFileModel &file);
62 void progressValChanged(unsigned int);
63 void progressMaxChanged(unsigned int);
65 public slots:
66 void abortProcess(void) { m_bAborted = true; exit(-1); }
68 private slots:
69 void initializeTasks(void);
70 void taskFileAnalyzed(const unsigned int taskId, const int fileType, const AudioFileModel &file);
71 void taskThreadFinish(const unsigned int);
73 private:
74 bool analyzeNextFile(void);
75 void handlePlaylistFiles(void);
76 bool createTemplate(void);
78 QThreadPool *m_pool;
79 QElapsedTimer *m_timer;
81 unsigned int m_tasksCounterNext;
82 unsigned int m_tasksCounterDone;
83 unsigned int m_completedCounter;
85 unsigned int m_filesAccepted;
86 unsigned int m_filesRejected;
87 unsigned int m_filesDenied;
88 unsigned int m_filesDummyCDDA;
89 unsigned int m_filesCueSheet;
91 QStringList m_inputFiles;
92 LockedFile *m_templateFile;
94 QSet<unsigned int> m_completedTaskIds;
95 QSet<unsigned int> m_runningTaskIds;
96 QHash<unsigned int, AudioFileModel> m_completedFiles;
98 static const char *g_tags_gen[];
99 static const char *g_tags_aud[];
101 volatile bool m_bAborted;
102 volatile bool m_bSuccess;