2 * SomePlayer - An alternate music player for Maemo 5
3 * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "coverfinder.h"
26 CoverFinder::CoverFinder(QObject *parent) :
29 _defaultCover = QImage(":/images/defaultcover.png");
30 SUFFIXES << "png" << "jpg" << "jpeg" << "bmp" << "gif";
31 NAMES << "cover" << "folder" << "album";
32 DIRS << "cover" << "folder" << ".cover" << ".folder" << ".mediaartlocal";
35 bool CoverFinder::find(QString path) {
37 QFileInfoList items = dir.entryInfoList(QDir::Files);
38 QFileInfoList dirs = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Hidden);
40 foreach (QFileInfo item, items) {
41 if (SUFFIXES.contains(item.suffix().toLower())) {
43 if (NAMES.contains(item.baseName().toLower())) {
44 emit found(QImage(item.absoluteFilePath()));
49 foreach (QFileInfo item, pics) {
50 QImage i(item.absoluteFilePath());
51 if (0.8 <= (i.width()*1.0/(i.height()+1.0)) <= 1.2) {
56 foreach(QFileInfo item, dirs) {
57 if (DIRS.contains(item.fileName().toLower())) {
58 if (find(item.absoluteFilePath())) {
63 emit found(_defaultCover);
67 QImage &CoverFinder::defaultCover() {