1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 15:27:54 +00:00

Add m4v to the list of previewable file extensions (closes #216)

Also optimize the misc::isPreviewable() function.
This commit is contained in:
Christophe Dumez 2012-11-11 19:23:10 +02:00
parent 634be0012f
commit 051341a42a
2 changed files with 51 additions and 47 deletions

View File

@ -247,52 +247,56 @@ QString misc::friendlyUnit(qreal val, bool is_speed) {
return ret; return ret;
} }
bool misc::isPreviewable(QString extension) { bool misc::isPreviewable(const QString& extension) {
if (extension.isEmpty()) return false; static QSet<QString> multimedia_extensions;
extension = extension.toUpper(); if (multimedia_extensions.empty()) {
if (extension == "AVI") return true; multimedia_extensions.insert("3GP");
if (extension == "MP3") return true; multimedia_extensions.insert("AAC");
if (extension == "OGG") return true; multimedia_extensions.insert("AC3");
if (extension == "OGV") return true; multimedia_extensions.insert("AIF");
if (extension == "OGM") return true; multimedia_extensions.insert("AIFF");
if (extension == "WMV") return true; multimedia_extensions.insert("AIFC");
if (extension == "WMA") return true; multimedia_extensions.insert("ASF");
if (extension == "MPEG") return true; multimedia_extensions.insert("AU");
if (extension == "MPG") return true; multimedia_extensions.insert("AVI");
if (extension == "ASF") return true; multimedia_extensions.insert("FLAC");
if (extension == "QT") return true; multimedia_extensions.insert("FLV");
if (extension == "RM") return true; multimedia_extensions.insert("M3U");
if (extension == "RMVB") return true; multimedia_extensions.insert("M4A");
if (extension == "RMV") return true; multimedia_extensions.insert("M4P");
if (extension == "SWF") return true; multimedia_extensions.insert("M4V");
if (extension == "FLV") return true; multimedia_extensions.insert("MID");
if (extension == "WAV") return true; multimedia_extensions.insert("MKV");
if (extension == "MOV") return true; multimedia_extensions.insert("MOV");
if (extension == "VOB") return true; multimedia_extensions.insert("MP2");
if (extension == "MID") return true; multimedia_extensions.insert("MP3");
if (extension == "AC3") return true; multimedia_extensions.insert("MP4");
if (extension == "MP4") return true; multimedia_extensions.insert("MPE");
if (extension == "MP2") return true; multimedia_extensions.insert("MPEG");
if (extension == "AVI") return true; multimedia_extensions.insert("MPC");
if (extension == "FLAC") return true; multimedia_extensions.insert("MPG");
if (extension == "AU") return true; multimedia_extensions.insert("MPP");
if (extension == "MPE") return true; multimedia_extensions.insert("OGG");
if (extension == "MOV") return true; multimedia_extensions.insert("OGV");
if (extension == "MKV") return true; multimedia_extensions.insert("OGM");
if (extension == "AIF") return true; multimedia_extensions.insert("QT");
if (extension == "AIFF") return true; multimedia_extensions.insert("RA");
if (extension == "AIFC") return true; multimedia_extensions.insert("RAM");
if (extension == "RA") return true; multimedia_extensions.insert("RM");
if (extension == "RAM") return true; multimedia_extensions.insert("RMV");
if (extension == "M4P") return true; multimedia_extensions.insert("RMVB");
if (extension == "M4A") return true; multimedia_extensions.insert("SWA");
if (extension == "3GP") return true; multimedia_extensions.insert("SWF");
if (extension == "AAC") return true; multimedia_extensions.insert("VOB");
if (extension == "SWA") return true; multimedia_extensions.insert("WAV");
if (extension == "MPC") return true; multimedia_extensions.insert("WMV");
if (extension == "MPP") return true; multimedia_extensions.insert("WMA");
if (extension == "M3U") return true; }
if (extension.isEmpty())
return false; return false;
return multimedia_extensions.contains(extension.toUpper());
} }
QString misc::bcLinkToMagnet(QString bc_link) { QString misc::bcLinkToMagnet(QString bc_link) {

View File

@ -99,7 +99,7 @@ public:
// see http://en.wikipedia.org/wiki/Kilobyte // see http://en.wikipedia.org/wiki/Kilobyte
// value must be given in bytes // value must be given in bytes
static QString friendlyUnit(qreal val, bool is_speed = false); static QString friendlyUnit(qreal val, bool is_speed = false);
static bool isPreviewable(QString extension); static bool isPreviewable(const QString& extension);
static QString magnetUriToName(const QString& magnet_uri); static QString magnetUriToName(const QString& magnet_uri);
static QString magnetUriToHash(const QString& magnet_uri); static QString magnetUriToHash(const QString& magnet_uri);
static QList<QUrl> magnetUriToTrackers(const QString& magnet_uri); static QList<QUrl> magnetUriToTrackers(const QString& magnet_uri);