summaryrefslogtreecommitdiffstats
path: root/demos/browser/browsermainwindow.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-11-19 04:38:46 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-11-19 04:38:46 (GMT)
commitc9333d1700bb7d063d6e1fe98b5a5900109a5d43 (patch)
tree48b4d9b10cfd176853c250107cb7d076b7bdf533 /demos/browser/browsermainwindow.cpp
parentaab933d997a303f22864f8c1d843f6882a38d496 (diff)
parentadb1994279333ff7356790649548d62f623739ac (diff)
downloadQt-c9333d1700bb7d063d6e1fe98b5a5900109a5d43.zip
Qt-c9333d1700bb7d063d6e1fe98b5a5900109a5d43.tar.gz
Qt-c9333d1700bb7d063d6e1fe98b5a5900109a5d43.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'demos/browser/browsermainwindow.cpp')
-rw-r--r--demos/browser/browsermainwindow.cpp43
1 files changed, 1 insertions, 42 deletions
diff --git a/demos/browser/browsermainwindow.cpp b/demos/browser/browsermainwindow.cpp
index fba3ac5..8e3986b 100644
--- a/demos/browser/browsermainwindow.cpp
+++ b/demos/browser/browsermainwindow.cpp
@@ -552,47 +552,6 @@ void BrowserMainWindow::slotViewStatusbar()
m_autoSaver->changeOccurred();
}
-QUrl BrowserMainWindow::guessUrlFromString(const QString &string)
-{
- QString urlStr = string.trimmed();
- QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*"));
-
- // Check if it looks like a qualified URL. Try parsing it and see.
- bool hasSchema = test.exactMatch(urlStr);
- if (hasSchema) {
- QUrl url = QUrl::fromEncoded(urlStr.toUtf8(), QUrl::TolerantMode);
- if (url.isValid())
- return url;
- }
-
- // Might be a file.
- if (QFile::exists(urlStr)) {
- QFileInfo info(urlStr);
- return QUrl::fromLocalFile(info.absoluteFilePath());
- }
-
- // Might be a shorturl - try to detect the schema.
- if (!hasSchema) {
- int dotIndex = urlStr.indexOf(QLatin1Char('.'));
- if (dotIndex != -1) {
- QString prefix = urlStr.left(dotIndex).toLower();
- QByteArray schema = (prefix == QLatin1String("ftp")) ? prefix.toLatin1() : QByteArray("http");
- QUrl url =
- QUrl::fromEncoded(schema + "://" + urlStr.toUtf8(), QUrl::TolerantMode);
- if (url.isValid())
- return url;
- }
- }
-
- // Fall back to QUrl's own tolerant parser.
- QUrl url = QUrl::fromEncoded(string.toUtf8(), QUrl::TolerantMode);
-
- // finally for cases where the user just types in a hostname add http
- if (url.scheme().isEmpty())
- url = QUrl::fromEncoded("http://" + string.toUtf8(), QUrl::TolerantMode);
- return url;
-}
-
void BrowserMainWindow::loadUrl(const QUrl &url)
{
if (!currentTab() || !url.isValid())
@@ -873,7 +832,7 @@ void BrowserMainWindow::slotSwapFocus()
void BrowserMainWindow::loadPage(const QString &page)
{
- QUrl url = guessUrlFromString(page);
+ QUrl url = QUrl::fromUserInput(page);
loadUrl(url);
}