summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorck <qt-info@nokia.com>2010-01-14 10:15:08 (GMT)
committerck <qt-info@nokia.com>2010-01-14 10:15:08 (GMT)
commit54d1ad11a4f35c0484418e5d18537daaccc2c6ab (patch)
treec4c8141d5d37f00c94889fe35121c4094732d798 /tools/assistant
parentfac30831e9235bb3373a0a96c40c9b653f87e34c (diff)
downloadQt-54d1ad11a4f35c0484418e5d18537daaccc2c6ab.zip
Qt-54d1ad11a4f35c0484418e5d18537daaccc2c6ab.tar.gz
Qt-54d1ad11a4f35c0484418e5d18537daaccc2c6ab.tar.bz2
Assistant: Open non-HTML content in external application.
Task-number: QTBUG-5583 Reviewed-by: kh1
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/contentwindow.cpp12
-rw-r--r--tools/assistant/tools/assistant/helpviewer.cpp16
-rw-r--r--tools/assistant/tools/assistant/helpviewer.h3
-rw-r--r--tools/assistant/tools/assistant/indexwindow.cpp3
4 files changed, 20 insertions, 14 deletions
diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp
index 23bcae4..976ed7a 100644
--- a/tools/assistant/tools/assistant/contentwindow.cpp
+++ b/tools/assistant/tools/assistant/contentwindow.cpp
@@ -43,6 +43,7 @@
#include "contentwindow.h"
#include "centralwidget.h"
#include "helpenginewrapper.h"
+#include "helpviewer.h"
#include <QtGui/QLayout>
#include <QtGui/QFocusEvent>
@@ -143,7 +144,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e)
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
if (contentModel) {
QHelpContentItem *itm = contentModel->contentItemAt(index);
- if (itm && !isPdfFile(itm))
+ if (itm && HelpViewer::canOpenPage(itm->url().path()))
CentralWidget::instance()->setSourceInNewTab(itm->url());
}
} else if (button == Qt::LeftButton) {
@@ -169,7 +170,7 @@ void ContentWindow::showContextMenu(const QPoint &pos)
QMenu menu;
QAction *curTab = menu.addAction(tr("Open Link"));
QAction *newTab = menu.addAction(tr("Open Link in New Tab"));
- if (isPdfFile(itm))
+ if (!HelpViewer::canOpenPage(itm->url().path()))
newTab->setEnabled(false);
menu.move(m_contentWidget->mapToGlobal(pos));
@@ -194,11 +195,4 @@ void ContentWindow::itemClicked(const QModelIndex &index)
}
}
-bool ContentWindow::isPdfFile(QHelpContentItem *item) const
-{
- TRACE_OBJ
- const QString &path = item->url().path();
- return path.endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive);
-}
-
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp
index f20cbc1..d92ff13 100644
--- a/tools/assistant/tools/assistant/helpviewer.cpp
+++ b/tools/assistant/tools/assistant/helpviewer.cpp
@@ -244,7 +244,7 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *,
if (isLocalUrl(url)) {
const QString& path = url.path();
- if (path.endsWith(QLatin1String(".pdf"))) {
+ if (!HelpViewer::canOpenPage(path)) {
QTemporaryFile tmpTmpFile;
if (!tmpTmpFile.open())
return false;
@@ -476,12 +476,12 @@ void HelpViewer::zoomOut(int range)
bool HelpViewer::launchedWithExternalApp(const QUrl &url)
{
TRACE_OBJ
- bool isPdf = url.path().endsWith(QLatin1String(".pdf"));
+ const bool canOpen = canOpenPage(url.path());
if (url.scheme() == QLatin1String("http")
|| url.scheme() == QLatin1String("ftp")
- || url.scheme() == QLatin1String("mailto") || isPdf) {
+ || url.scheme() == QLatin1String("mailto") || !canOpen) {
bool launched = false;
- if (isPdf && url.scheme() == QLatin1String("qthelp")) {
+ if (!canOpen && url.scheme() == QLatin1String("qthelp")) {
const QString& path = url.path();
const int lastDash = path.lastIndexOf(QChar('/'));
QString fileName = QDir::tempPath() + QDir::separator();
@@ -638,4 +638,12 @@ void HelpViewer::home()
setSource(helpEngine.homePage());
}
+bool HelpViewer::canOpenPage(const QString &url)
+{
+ TRACE_OBJ
+ return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive)
+ || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive);
+}
+
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h
index ab46208..cfe4c3e 100644
--- a/tools/assistant/tools/assistant/helpviewer.h
+++ b/tools/assistant/tools/assistant/helpviewer.h
@@ -97,6 +97,8 @@ public:
inline qreal zoom() const
{ return textSizeMultiplier(); }
+ static bool canOpenPage(const QString &url);
+
public Q_SLOTS:
void home();
void backward() { back(); }
@@ -143,6 +145,7 @@ public:
{ return textCursor().hasSelection(); }
bool launchedWithExternalApp(const QUrl &url);
+ static bool canOpenPage(const QString &url);
public Q_SLOTS:
void home();
diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp
index a61ab70..82242e5 100644
--- a/tools/assistant/tools/assistant/indexwindow.cpp
+++ b/tools/assistant/tools/assistant/indexwindow.cpp
@@ -43,6 +43,7 @@
#include "indexwindow.h"
#include "centralwidget.h"
#include "helpenginewrapper.h"
+#include "helpviewer.h"
#include "topicchooser.h"
#include <QtGui/QLayout>
@@ -218,7 +219,7 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index)
return;
}
- if (url.path().endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive))
+ if (!HelpViewer::canOpenPage(url.path()))
CentralWidget::instance()->setSource(url);
else
CentralWidget::instance()->setSourceInNewTab(url);