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
This commit is contained in:
thunder2 2010-12-09 20:49:41 +00:00
parent 5617b3cdda
commit e0a2883eaf
4 changed files with 21 additions and 19 deletions

View File

@ -192,7 +192,7 @@ void SearchDialog::initialiseFileTypeMappings()
/* edit these strings to change the range of extensions recognised by the search */ /* edit these strings to change the range of extensions recognised by the search */
SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_ANY, ""); SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_ANY, "");
SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_AUDIO, 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, SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_ARCHIVE,
"7z bz2 gz pkg rar sea sit sitx tar zip"); "7z bz2 gz pkg rar sea sit sitx tar zip");
SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_CDIMAGE, SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_CDIMAGE,
@ -624,11 +624,11 @@ void SearchDialog::updateFiles(qulonglong search_id,FileDetail file)
if (extIndex >= 0) if (extIndex >= 0)
{ {
QString qExt = qName.mid(extIndex+1); QString qExt = qName.mid(extIndex+1).toUpper();
if (qExt != "" ) if (qExt != "" )
for (int i = 0; i < extList.size(); ++i) 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); insertFile(txt,search_id,file);
} }
} }
@ -1088,10 +1088,11 @@ void SearchDialog::selectSearchResults(int index)
ui.searchResultWidget->update(); 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" 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->setIcon(SR_NAME_COL, QIcon(":/images/FileTypePicture.png"));
item->setText(SR_TYPE_COL, QString::fromUtf8("Picture")); 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->setIcon(SR_NAME_COL, QIcon(":/images/FileTypeVideo.png"));
item->setText(SR_TYPE_COL, QString::fromUtf8("Video")); 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->setIcon(SR_NAME_COL, QIcon(":/images/FileTypeAudio.png"));
item->setText(SR_TYPE_COL, QString::fromUtf8("Audio")); item->setText(SR_TYPE_COL, QString::fromUtf8("Audio"));

View File

@ -96,7 +96,7 @@ private:
void insertFile(const std::string& txt,qulonglong searchId, const FileDetail& file, int searchType = ANONYMOUS_SEARCH) ; 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, QTreeWidgetItem *item);
void insertDirectory(const std::string &txt, qulonglong searchId, const DirDetails &dir); 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 downloadDirectory(const QTreeWidgetItem *item, const QString &base);
void getSourceFriendsForHash(const std::string& hash,std::list<std::string>& srcIds); void getSourceFriendsForHash(const std::string& hash,std::list<std::string>& srcIds);

View File

@ -531,15 +531,16 @@ int TransfersDialog::addItem(const QString&, const QString& name, const QString&
return row ; 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")) ; 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 == "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")) ; 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")) ; return QIcon(QString::fromUtf8(":/images/FileTypeAudio.png")) ;
else if (ext == "tar" || ext == "bz2" || ext == "zip" || ext == "gz" || ext == "7z" || ext == "msi" 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 == "rar" || ext == "rpm" || ext == "ace" || ext == "jar" || ext == "tgz" || ext == "lha"

View File

@ -106,7 +106,7 @@ signals:
private: private:
QString getPeerName(const std::string& peer_id) const ; QString getPeerName(const std::string& peer_id) const ;
static QIcon getIconFromExtension(const QString&) ; static QIcon getIconFromExtension(QString) ;
QStandardItemModel *DLListModel; QStandardItemModel *DLListModel;
QStandardItemModel *ULListModel; QStandardItemModel *ULListModel;