File indexing completed on 2024-04-21 04:45:41

0001 /****************************************************************************************
0002  * Copyright (c) 2010 Stefan Derkits <stefan@derkits.at>                                *
0003  * Copyright (c) 2010 Christian Wagner <christian.wagner86@gmx.at>                      *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 #include "FileType.h"
0019 
0020 using namespace Amarok;
0021 
0022 static QStringList s_fileTypeStrings = QStringList()
0023         << QLatin1String( "" )
0024         << QStringLiteral( "mp3" )
0025         << QStringLiteral( "ogg" )
0026         << QStringLiteral( "flac" )
0027         << QStringLiteral( "mp4" )
0028         << QStringLiteral( "wma" )
0029         << QStringLiteral( "aiff" )
0030         << QStringLiteral( "mpc" )
0031         << QStringLiteral( "tta" )
0032         << QStringLiteral( "wav" )
0033         << QStringLiteral( "wv" )
0034         << QStringLiteral( "m4a" )
0035         << QStringLiteral( "m4v" )
0036         << QStringLiteral( "mod" )
0037         << QStringLiteral( "s3m" )
0038         << QStringLiteral( "it" )
0039         << QStringLiteral( "xm" )
0040         << QStringLiteral( "spx" )
0041         << QStringLiteral( "opus" );
0042 
0043 QString
0044 FileTypeSupport::toString( Amarok::FileType ft )
0045 {
0046     return s_fileTypeStrings.at( ft );
0047 }
0048 
0049 QStringList
0050 FileTypeSupport::possibleFileTypes()
0051 {
0052     return s_fileTypeStrings;
0053 }
0054 
0055 Amarok::FileType
0056 Amarok::FileTypeSupport::fileType( const QString &extension )
0057 {
0058     QString ext = extension.toLower();
0059     for( int i = 1; i < s_fileTypeStrings.size(); i++ )
0060     {
0061         if( s_fileTypeStrings.at( i ).compare( ext ) == 0 )
0062             return Amarok::FileType( i );
0063     }
0064     return Amarok::Unknown;
0065 }