summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorck <qt-info@nokia.com>2010-01-14 14:42:19 (GMT)
committerck <qt-info@nokia.com>2010-01-14 14:42:19 (GMT)
commit9fc2d9630169cd2466f113e259b5cae73baeb1c8 (patch)
treed17f7dc0795d7498edccdab7447f0b74e1b5ad57 /tools/assistant
parent035bb4a1363443df7bb3fd80f0b2e7d548f3d3a1 (diff)
downloadQt-9fc2d9630169cd2466f113e259b5cae73baeb1c8.zip
Qt-9fc2d9630169cd2466f113e259b5cae73baeb1c8.tar.gz
Qt-9fc2d9630169cd2466f113e259b5cae73baeb1c8.tar.bz2
Assistant: Use isLocalUrl() to decide whether a page is internal.
Reviewed-by: kh1
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/aboutdialog.cpp5
-rw-r--r--tools/assistant/tools/assistant/helpviewer.cpp32
-rw-r--r--tools/assistant/tools/assistant/helpviewer.h2
3 files changed, 18 insertions, 21 deletions
diff --git a/tools/assistant/tools/assistant/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp
index 5727528..26d488d 100644
--- a/tools/assistant/tools/assistant/aboutdialog.cpp
+++ b/tools/assistant/tools/assistant/aboutdialog.cpp
@@ -96,9 +96,8 @@ QVariant AboutLabel::loadResource(int type, const QUrl &name)
void AboutLabel::setSource(const QUrl &url)
{
TRACE_OBJ
- if (url.isValid()
- && (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("ftp")
- || url.scheme() == QLatin1String("mailto") || !HelpViewer::canOpenPage(url.path()))) {
+ if (url.isValid() && (!HelpViewer::isLocalUrl(url)
+ || !HelpViewer::canOpenPage(url.path()))) {
if (!QDesktopServices::openUrl(url)) {
QMessageBox::warning(this, tr("Warning"),
tr("Unable to launch external application.\n"),
diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp
index d92ff13..4141d64 100644
--- a/tools/assistant/tools/assistant/helpviewer.cpp
+++ b/tools/assistant/tools/assistant/helpviewer.cpp
@@ -208,20 +208,6 @@ QWebPage *HelpPage::createWindow(QWebPage::WebWindowType)
return newPage;
}
-static bool isLocalUrl(const QUrl &url)
-{
- TRACE_OBJ
- const QString scheme = url.scheme();
- if (scheme.isEmpty()
- || scheme == QLatin1String("file")
- || scheme == QLatin1String("qrc")
- || scheme == QLatin1String("data")
- || scheme == QLatin1String("qthelp")
- || scheme == QLatin1String("about"))
- return true;
- return false;
-}
-
void HelpPage::triggerAction(WebAction action, bool checked)
{
TRACE_OBJ
@@ -242,7 +228,7 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *,
const bool closeNewTab = closeNewTabIfNeeded;
closeNewTabIfNeeded = false;
- if (isLocalUrl(url)) {
+ if (HelpViewer::isLocalUrl(url)) {
const QString& path = url.path();
if (!HelpViewer::canOpenPage(path)) {
QTemporaryFile tmpTmpFile;
@@ -477,9 +463,7 @@ bool HelpViewer::launchedWithExternalApp(const QUrl &url)
{
TRACE_OBJ
const bool canOpen = canOpenPage(url.path());
- if (url.scheme() == QLatin1String("http")
- || url.scheme() == QLatin1String("ftp")
- || url.scheme() == QLatin1String("mailto") || !canOpen) {
+ if (!isLocalUrl(url) || !canOpen) {
bool launched = false;
if (!canOpen && url.scheme() == QLatin1String("qthelp")) {
const QString& path = url.path();
@@ -645,5 +629,17 @@ bool HelpViewer::canOpenPage(const QString &url)
|| url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive);
}
+bool HelpViewer::isLocalUrl(const QUrl &url)
+{
+ TRACE_OBJ
+ const QString scheme = url.scheme();
+ return scheme.isEmpty()
+ || scheme == QLatin1String("file")
+ || scheme == QLatin1String("qrc")
+ || scheme == QLatin1String("data")
+ || scheme == QLatin1String("qthelp")
+ || scheme == QLatin1String("about");
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h
index cfe4c3e..4dd8064 100644
--- a/tools/assistant/tools/assistant/helpviewer.h
+++ b/tools/assistant/tools/assistant/helpviewer.h
@@ -98,6 +98,7 @@ public:
{ return textSizeMultiplier(); }
static bool canOpenPage(const QString &url);
+ static bool isLocalUrl(const QUrl &url);
public Q_SLOTS:
void home();
@@ -146,6 +147,7 @@ public:
bool launchedWithExternalApp(const QUrl &url);
static bool canOpenPage(const QString &url);
+ static bool isLocalUrl(const QUrl &url);
public Q_SLOTS:
void home();