From e0a2883eaf6902ac4319b8850eb4eb9ce694591c Mon Sep 17 00:00:00 2001 From: thunder2 Date: Thu, 9 Dec 2010 20:49:41 +0000 Subject: [PATCH] Commited changes from Imanuel Added flac and m4a to the audio extensions. Optimized "toUpper" on searching for the extension. Convert the extension to lower case to find mixed cases too - mP3, AVi, ... git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3903 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/SearchDialog.cpp | 13 ++++++------ retroshare-gui/src/gui/SearchDialog.h | 2 +- retroshare-gui/src/gui/TransfersDialog.cpp | 23 +++++++++++----------- retroshare-gui/src/gui/TransfersDialog.h | 2 +- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/retroshare-gui/src/gui/SearchDialog.cpp b/retroshare-gui/src/gui/SearchDialog.cpp index 57b919580..e0ffe6d8b 100644 --- a/retroshare-gui/src/gui/SearchDialog.cpp +++ b/retroshare-gui/src/gui/SearchDialog.cpp @@ -192,7 +192,7 @@ void SearchDialog::initialiseFileTypeMappings() /* edit these strings to change the range of extensions recognised by the search */ SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_ANY, ""); SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_AUDIO, - "aac aif iff m3u mid midi mp3 mpa ogg ra ram wav wma"); + "aac aif flac iff m3u m4a mid midi mp3 mpa ogg ra ram wav wma"); SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_ARCHIVE, "7z bz2 gz pkg rar sea sit sitx tar zip"); SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_CDIMAGE, @@ -624,11 +624,11 @@ void SearchDialog::updateFiles(qulonglong search_id,FileDetail file) if (extIndex >= 0) { - QString qExt = qName.mid(extIndex+1); + QString qExt = qName.mid(extIndex+1).toUpper(); if (qExt != "" ) for (int i = 0; i < extList.size(); ++i) - if (qExt.toUpper() == extList.at(i).toUpper()) + if (qExt == extList.at(i).toUpper()) insertFile(txt,search_id,file); } } @@ -1088,10 +1088,11 @@ void SearchDialog::selectSearchResults(int index) ui.searchResultWidget->update(); } -void SearchDialog::setIconAndType(QTreeWidgetItem *item, QString &ext) +void SearchDialog::setIconAndType(QTreeWidgetItem *item, QString ext) { + ext = ext.toLower(); if (ext == "jpg" || ext == "jpeg" || ext == "png" || ext == "gif" || ext == "bmp" || ext == "ico" - || ext == "svg" || ext == "tif" || ext == "tiff" || ext == "JPG") + || ext == "svg" || ext == "tif" || ext == "tiff") { item->setIcon(SR_NAME_COL, QIcon(":/images/FileTypePicture.png")); item->setText(SR_TYPE_COL, QString::fromUtf8("Picture")); @@ -1103,7 +1104,7 @@ void SearchDialog::setIconAndType(QTreeWidgetItem *item, QString &ext) item->setIcon(SR_NAME_COL, QIcon(":/images/FileTypeVideo.png")); item->setText(SR_TYPE_COL, QString::fromUtf8("Video")); } - else if (ext == "ogg" || ext == "mp3" || ext == "MP3" || ext == "mp1" || ext == "mp2" || ext == "wav" || ext == "wma") + else if (ext == "flac" || ext == "ogg" || ext == "mp3" || ext == "m4a" || ext == "mp1" || ext == "mp2" || ext == "wav" || ext == "wma") { item->setIcon(SR_NAME_COL, QIcon(":/images/FileTypeAudio.png")); item->setText(SR_TYPE_COL, QString::fromUtf8("Audio")); diff --git a/retroshare-gui/src/gui/SearchDialog.h b/retroshare-gui/src/gui/SearchDialog.h index b3201e0b3..de3c0efdc 100644 --- a/retroshare-gui/src/gui/SearchDialog.h +++ b/retroshare-gui/src/gui/SearchDialog.h @@ -96,7 +96,7 @@ private: void insertFile(const std::string& txt,qulonglong searchId, const FileDetail& file, int searchType = ANONYMOUS_SEARCH) ; void insertDirectory(const std::string &txt, qulonglong searchId, const DirDetails &dir, QTreeWidgetItem *item); void insertDirectory(const std::string &txt, qulonglong searchId, const DirDetails &dir); - void setIconAndType(QTreeWidgetItem *item, QString &ext); + void setIconAndType(QTreeWidgetItem *item, QString ext); void downloadDirectory(const QTreeWidgetItem *item, const QString &base); void getSourceFriendsForHash(const std::string& hash,std::list& srcIds); diff --git a/retroshare-gui/src/gui/TransfersDialog.cpp b/retroshare-gui/src/gui/TransfersDialog.cpp index 5e52decbf..c3f1ba4b6 100644 --- a/retroshare-gui/src/gui/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/TransfersDialog.cpp @@ -531,32 +531,33 @@ int TransfersDialog::addItem(const QString&, const QString& name, const QString& return row ; } -QIcon TransfersDialog::getIconFromExtension(const QString& ext) +QIcon TransfersDialog::getIconFromExtension(QString ext) { - if (ext == "jpg" || ext == "jpeg" || ext == "tif" || ext == "tiff" || ext == "JPG"|| ext == "png" || ext == "gif" || ext == "bmp" || ext == "ico" || ext == "svg") + ext = ext.toLower(); + if (ext == "jpg" || ext == "jpeg" || ext == "tif" || ext == "tiff" || ext == "png" || ext == "gif" || ext == "bmp" || ext == "ico" || ext == "svg") return QIcon(QString::fromUtf8(":/images/FileTypePicture.png")) ; - else if (ext == "avi" ||ext == "AVI" || ext == "mpg" || ext == "mpeg" || ext == "wmv" || ext == "divx" || ext == "ts" + else if (ext == "avi" || ext == "mpg" || ext == "mpeg" || ext == "wmv" || ext == "divx" || ext == "ts" || ext == "mkv" || ext == "mp4" || ext == "flv" || ext == "mov" || ext == "asf" || ext == "xvid" - || ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp" || ext == "mpeg" || ext == "ogm") + || ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp" || ext == "ogm") return QIcon(QString::fromUtf8(":/images/FileTypeVideo.png")) ; - else if (ext == "ogg" || ext == "mp3" || ext == "MP3" || ext == "mp1" || ext == "mp2" || ext == "wav" || ext == "wma") + else if (ext == "ogg" || ext == "mp3" || ext == "mp1" || ext == "mp2" || ext == "wav" || ext == "wma" || ext == "m4a" || ext == "flac") return QIcon(QString::fromUtf8(":/images/FileTypeAudio.png")) ; else if (ext == "tar" || ext == "bz2" || ext == "zip" || ext == "gz" || ext == "7z" || ext == "msi" || ext == "rar" || ext == "rpm" || ext == "ace" || ext == "jar" || ext == "tgz" || ext == "lha" - || ext == "cab" || ext == "cbz"|| ext == "cbr" || ext == "alz" || ext == "sit" || ext == "arj" || ext == "deb") + || ext == "cab" || ext == "cbz"|| ext == "cbr" || ext == "alz" || ext == "sit" || ext == "arj" || ext == "deb") return QIcon(QString::fromUtf8(":/images/FileTypeArchive.png")) ; else if (ext == "app" || ext == "bat" || ext == "cgi" || ext == "com" || ext == "exe" || ext == "js" || ext == "pif" - || ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws") + || ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws") return QIcon(QString::fromUtf8(":/images/FileTypeProgram.png")) ; - else if (ext == "iso" || ext == "nrg" || ext == "mdf" || ext == "img" || ext == "dmg" || ext == "bin" ) + else if (ext == "iso" || ext == "nrg" || ext == "mdf" || ext == "img" || ext == "dmg" || ext == "bin" ) return QIcon(QString::fromUtf8(":/images/FileTypeCDImage.png")) ; - else if (ext == "txt" || ext == "cpp" || ext == "c" || ext == "h") + else if (ext == "txt" || ext == "cpp" || ext == "c" || ext == "h") return QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")) ; else if (ext == "doc" || ext == "rtf" || ext == "sxw" || ext == "xls" || ext == "pps" || ext == "xml" - || ext == "sxc" || ext == "odt" || ext == "ods" || ext == "dot" || ext == "ppt" || ext == "css" ) + || ext == "sxc" || ext == "odt" || ext == "ods" || ext == "dot" || ext == "ppt" || ext == "css" ) return QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")) ; - else if (ext == "html" || ext == "htm" || ext == "php") + else if (ext == "html" || ext == "htm" || ext == "php") return QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")) ; else return QIcon(QString::fromUtf8(":/images/FileTypeAny.png")) ; diff --git a/retroshare-gui/src/gui/TransfersDialog.h b/retroshare-gui/src/gui/TransfersDialog.h index 55e808e7a..ade1c7482 100644 --- a/retroshare-gui/src/gui/TransfersDialog.h +++ b/retroshare-gui/src/gui/TransfersDialog.h @@ -106,7 +106,7 @@ signals: private: QString getPeerName(const std::string& peer_id) const ; - static QIcon getIconFromExtension(const QString&) ; + static QIcon getIconFromExtension(QString) ; QStandardItemModel *DLListModel; QStandardItemModel *ULListModel;