1 /* BEGIN_COMMON_COPYRIGHT_HEADER
2  * (c)LGPL2+
3  *
4  * Flacon - audio File Encoder
5  * https://github.com/flacon/flacon
6  *
7  * Copyright: 2021
8  *   Alexander Sokoloff <sokoloff.a@gmail.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14 
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19 
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23  *
24  * END_COMMON_COPYRIGHT_HEADER */
25 
26 #ifndef AUDIOFILEMATCHER_H
27 #define AUDIOFILEMATCHER_H
28 
29 #include <QString>
30 #include "track.h"
31 #include <QFileInfoList>
32 
33 class AudioFileMatcher
34 {
35 public:
36     AudioFileMatcher(const QString &cueFilePath, const Tracks &tracks);
37 
tracks()38     const Tracks &tracks() const { return mTracks; }
39 
fileTags()40     const QStringList &fileTags() const { return mFileTags; }
audioFiles(const QString & fileTag)41     QStringList        audioFiles(const QString &fileTag) const { return mResult[fileTag]; }
42     QStringList        audioFiles(int index) const;
43 
44     bool containsAudioFile(const QString &audioFile) const;
45 
46 private:
47     QString                    mCueFilePath;
48     Tracks                     mTracks;
49     QStringList                mFileTags;
50     QFileInfoList              mAllAudioFiles;
51     QMap<QString, QStringList> mResult;
52 
53     void        fillFileTags();
54     QStringList matchAudioFilesByTrack(const QString &fileTag, const QString &trackTitle);
55     QStringList matchAudioFiles(const QString &fileTag);
56 };
57 
58 #endif // AUDIOFILEMATCHER_H
59