diff options
author | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2009-11-12 13:22:27 (GMT) |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2009-11-12 13:22:27 (GMT) |
commit | 5e6a3e2f8f7f0b6b85534fb9cf30a5fd0fbac9ee (patch) | |
tree | 796dc22d03b45f3c11824b20a53c8005bc7aec17 /demos | |
parent | 6ef53e33e8ff3869a7d93db801a8bb57fc230d6d (diff) | |
parent | aeea26b384a362e59c335f7932a8b3915c1c8383 (diff) | |
download | Qt-5e6a3e2f8f7f0b6b85534fb9cf30a5fd0fbac9ee.zip Qt-5e6a3e2f8f7f0b6b85534fb9cf30a5fd0fbac9ee.tar.gz Qt-5e6a3e2f8f7f0b6b85534fb9cf30a5fd0fbac9ee.tar.bz2 |
Merge branch '4.6' into osloStaging1-4.6
Diffstat (limited to 'demos')
-rw-r--r-- | demos/browser/browsermainwindow.cpp | 43 | ||||
-rw-r--r-- | demos/browser/browsermainwindow.h | 1 |
2 files changed, 1 insertions, 43 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); } diff --git a/demos/browser/browsermainwindow.h b/demos/browser/browsermainwindow.h index f5c14ea..f0f95b1 100644 --- a/demos/browser/browsermainwindow.h +++ b/demos/browser/browsermainwindow.h @@ -68,7 +68,6 @@ public: QSize sizeHint() const; public: - static QUrl guessUrlFromString(const QString &url); TabWidget *tabWidget() const; WebView *currentTab() const; QByteArray saveState(bool withTabs = true) const; |