Code clean up

This commit is contained in:
Christophe Dumez 2010-12-30 19:12:03 +00:00
parent a9fbef62b6
commit 5696944c6f
7 changed files with 57 additions and 69 deletions

View file

@ -752,3 +752,19 @@ QString misc::branchPath(QString file_path)
file_path.replace("\\", "/");
return file_path.left(file_path.lastIndexOf('/'));
}
bool misc::isUrl(const QString &s)
{
const QString scheme = QUrl(s).scheme();
QRegExp is_url("http[s]?|ftp", Qt::CaseInsensitive);
return is_url.exactMatch(scheme);
}
QString misc::fileName(QString file_path)
{
file_path.replace("\\", "/");
const int slash_index = file_path.lastIndexOf('/');
if(slash_index == -1)
return file_path;
return file_path.mid(slash_index);
}