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 */
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"));

View File

@ -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<std::string>& srcIds);

View File

@ -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")) ;

View File

@ -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;