diff options
author | Marcos CARDINOT <mcardinot@gmail.com> | 2014-06-01 12:02:47 +0100 |
---|---|---|
committer | Marcos CARDINOT <mcardinot@gmail.com> | 2014-06-01 12:02:47 +0100 |
commit | 74c80e95e97929614091b78ae95e3a6b73646795 (patch) | |
tree | 84658463f83f50f3de7a4beaf205e1fd5c557760 /src/library/coverart.cpp | |
parent | 8b1b6c6e6d1d16ae8b37d1855c7728278a0a9687 (diff) |
coverart::searchInTrackDirectory() - removing regExp logic and just look for any image into track directory
- not make sense have a list with all likely names, it's not efficient
- now we list only the images and get the lighter one
Diffstat (limited to 'src/library/coverart.cpp')
-rw-r--r-- | src/library/coverart.cpp | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/src/library/coverart.cpp b/src/library/coverart.cpp index 33022c8bec..c142450f9e 100644 --- a/src/library/coverart.cpp +++ b/src/library/coverart.cpp @@ -40,30 +40,23 @@ bool CoverArt::saveImage(QImage cover, QString location) { } QString CoverArt::searchInTrackDirectory(QString directory) { - // Implements regular expressions for image extensions - static QList<QRegExp> regExpList; - QLatin1String format(".(jpe?g|png|gif|bmp)"); - if (regExpList.isEmpty()) { - regExpList << QRegExp(".*cover.*" + format, Qt::CaseInsensitive) - << QRegExp(".*album.*" + format, Qt::CaseInsensitive) - << QRegExp(".*front.*" + format, Qt::CaseInsensitive) - << QRegExp(".*folder.*" + format, Qt::CaseInsensitive); + QDir dir(directory); + dir.setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::Readable); + dir.setSorting(QDir::Size | QDir::Reversed); + + QStringList nameFilters; + nameFilters << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.bmp"; + dir.setNameFilters(nameFilters); + + QString coverLocation; + QStringList imglist = dir.entryList(); + if (imglist.size() > 0) { + coverLocation = directory; + coverLocation.append("/"); + coverLocation.append(imglist[0]); } - const QFileInfoList fileList = QDir(directory) - .entryInfoList(QDir::NoDotAndDotDot | - QDir::Files | - QDir::Readable); - foreach (QFileInfo f, fileList) { - const QString filename = f.fileName(); - foreach (QRegExp re, regExpList) { - if (filename.contains(re)) { - return f.absoluteFilePath(); - } - } - } - - return QString(); + return coverLocation; } QString CoverArt::getDefaultCoverName(QString artist, |