summaryrefslogtreecommitdiff
path: root/src/shared/help
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2010-07-14 13:36:23 +0200
committerkh1 <qt-info@nokia.com>2010-07-14 13:37:20 +0200
commit6e0544a9f58e172920e7c62cac5b56de8d5bb2cd (patch)
tree91c0fdfa953c24aff0ffa5dbe9ae9abb8992df56 /src/shared/help
parent3809327a68a27e9b941888525afe0fd3abd2b952 (diff)
downloadqt-creator-6e0544a9f58e172920e7c62cac5b56de8d5bb2cd.tar.gz
Sync against Assistant
Reviewed-by: ck
Diffstat (limited to 'src/shared/help')
-rw-r--r--src/shared/help/contentwindow.cpp27
-rw-r--r--src/shared/help/contentwindow.h1
-rw-r--r--src/shared/help/indexwindow.cpp5
3 files changed, 17 insertions, 16 deletions
diff --git a/src/shared/help/contentwindow.cpp b/src/shared/help/contentwindow.cpp
index ef3479f170..f61e09f67f 100644
--- a/src/shared/help/contentwindow.cpp
+++ b/src/shared/help/contentwindow.cpp
@@ -29,7 +29,9 @@
#include "contentwindow.h"
+#include "centralwidget.h"
#include "helpmanager.h"
+#include "helpviewer.h"
#include "openpagesmanager.h"
#include <QtGui/QLayout>
@@ -102,18 +104,21 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e)
if (m_contentWidget && o == m_contentWidget->viewport()
&& e->type() == QEvent::MouseButtonRelease) {
QMouseEvent *me = static_cast<QMouseEvent*>(e);
- QModelIndex index = m_contentWidget->indexAt(me->pos());
QItemSelectionModel *sm = m_contentWidget->selectionModel();
+ if (!me || !sm)
+ return QWidget::eventFilter(o, e);
Qt::MouseButtons button = me->button();
- if (index.isValid() && (sm && sm->isSelected(index))) {
+ const QModelIndex &index = m_contentWidget->indexAt(me->pos());
+
+ if (index.isValid() && sm->isSelected(index)) {
if ((button == Qt::LeftButton && (me->modifiers() & Qt::ControlModifier))
|| (button == Qt::MidButton)) {
QHelpContentModel *contentModel =
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
if (contentModel) {
QHelpContentItem *itm = contentModel->contentItemAt(index);
- if (itm && !isPdfFile(itm))
+ if (itm && HelpViewer::canOpenPage(itm->url().path()))
OpenPagesManager::instance().createPage(itm->url());
}
} else if (button == Qt::LeftButton) {
@@ -137,7 +142,7 @@ void ContentWindow::showContextMenu(const QPoint &pos)
QMenu menu;
QAction *curTab = menu.addAction(tr("Open Link"));
QAction *newTab = menu.addAction(tr("Open Link as New Page"));
- if (isPdfFile(itm))
+ if (!HelpViewer::canOpenPage(itm->url().path()))
newTab->setEnabled(false);
menu.move(m_contentWidget->mapToGlobal(pos));
@@ -155,14 +160,10 @@ void ContentWindow::itemClicked(const QModelIndex &index)
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
if (contentModel) {
- QHelpContentItem *itm = contentModel->contentItemAt(index);
- if (itm)
- emit linkActivated(itm->url());
+ if (QHelpContentItem *itm = contentModel->contentItemAt(index)) {
+ const QUrl &url = itm->url();
+ if (url != CentralWidget::instance()->currentHelpViewer()->source())
+ emit linkActivated(itm->url());
+ }
}
}
-
-bool ContentWindow::isPdfFile(QHelpContentItem *item) const
-{
- const QString &path = item->url().path();
- return path.endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive);
-}
diff --git a/src/shared/help/contentwindow.h b/src/shared/help/contentwindow.h
index 4bfd0d0f6a..df98dac82e 100644
--- a/src/shared/help/contentwindow.h
+++ b/src/shared/help/contentwindow.h
@@ -62,7 +62,6 @@ private slots:
private:
bool eventFilter(QObject *o, QEvent *e);
- bool isPdfFile(QHelpContentItem *item) const;
QHelpContentWidget *m_contentWidget;
int m_expandDepth;
diff --git a/src/shared/help/indexwindow.cpp b/src/shared/help/indexwindow.cpp
index b12d517c6d..d58188b3f1 100644
--- a/src/shared/help/indexwindow.cpp
+++ b/src/shared/help/indexwindow.cpp
@@ -30,6 +30,7 @@
#include "centralwidget.h"
#include "helpmanager.h"
+#include "helpviewer.h"
#include "indexwindow.h"
#include "openpagesmanager.h"
#include "topicchooser.h"
@@ -209,8 +210,8 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index)
return;
}
- if (url.path().endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive))
- Help::Internal::CentralWidget::instance()->setSource(url);
+ if (!HelpViewer::canOpenPage(url.path()))
+ CentralWidget::instance()->setSource(url);
else
OpenPagesManager::instance().createPage(url);
}