diff options
-rw-r--r-- | tools/assistant/tools/assistant/contentwindow.cpp | 12 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/helpviewer.cpp | 16 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/helpviewer.h | 3 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/indexwindow.cpp | 3 |
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); |