summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-08-10 14:46:49 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-08-10 14:46:49 +0200
commit644d6b6f5b4997227691513d0654584a9e9a24c7 (patch)
treec54e0e986b6ef52dd53e07d5c7f161aff3412b0a
parentNew rekonq.kcfg version, according to krazy suggestions (diff)
downloadrekonq-644d6b6f5b4997227691513d0654584a9e9a24c7.tar.xz
Removing unuseful QUrl class from guessUrlFromString method
-rw-r--r--src/application.cpp38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 3817098d..ebd99004 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -201,29 +201,24 @@ KUrl Application::guessUrlFromString(const QString &string)
QString urlStr = string.trimmed();
QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*"));
+ // Might be a file.
+ if (QFile::exists(urlStr))
+ {
+ QFileInfo info(urlStr);
+ return KUrl::fromPath(info.absoluteFilePath());
+ }
+
// Check if it looks like a qualified URL. Try parsing it and see.
- bool hasSchema = test.exactMatch(urlStr);
-
- if (hasSchema)
+ if (test.exactMatch(urlStr))
{
- QUrl qurl(urlStr, QUrl::TolerantMode);
- KUrl url(qurl);
-
+ KUrl url(urlStr);
+
if (url.isValid())
{
return url;
}
}
-
- // Might be a file.
- if (QFile::exists(urlStr))
- {
- QFileInfo info(urlStr);
- return KUrl::fromPath(info.absoluteFilePath());
- }
-
- // Might be a shorturl - try to detect the schema.
- if (!hasSchema)
+ else // Might be a shorturl - try to detect the schema.
{
int dotIndex = urlStr.indexOf(QLatin1Char('.'));
@@ -240,17 +235,10 @@ KUrl Application::guessUrlFromString(const QString &string)
}
}
}
-
+
// Fall back to QUrl's own tolerant parser.
- QUrl qurl = QUrl(string, QUrl::TolerantMode);
- KUrl url(qurl);
+ KUrl url = KUrl(string);
- // finally for cases where the user just types in a hostname add http
- if (qurl.scheme().isEmpty())
- {
- qurl = QUrl(QLatin1String("http://") + string, QUrl::TolerantMode);
- url = KUrl(qurl);
- }
return url;
}