From 0c508410dd42714b9854b523c851ef699ebcf7d7 Mon Sep 17 00:00:00 2001 From: kh Date: Thu, 2 Apr 2009 17:58:51 +0200 Subject: fixes empty tab after pdf file open Task-number: none Reviewed-by: --global --- tools/assistant/tools/assistant/contentwindow.cpp | 21 +++++++++++++++------ tools/assistant/tools/assistant/contentwindow.h | 2 ++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index 24e7ca9..89060bd 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -132,7 +132,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e) qobject_cast(m_contentWidget->model()); if (contentModel) { QHelpContentItem *itm = contentModel->contentItemAt(index); - if (itm) + if (itm && !isPdfFile(itm)) CentralWidget::instance()->setSourceInNewTab(itm->url()); } } @@ -146,16 +146,19 @@ void ContentWindow::showContextMenu(const QPoint &pos) if (!m_contentWidget->indexAt(pos).isValid()) return; - QMenu menu; - QAction *curTab = menu.addAction(tr("Open Link")); - QAction *newTab = menu.addAction(tr("Open Link in New Tab")); - menu.move(m_contentWidget->mapToGlobal(pos)); - QHelpContentModel *contentModel = qobject_cast(m_contentWidget->model()); QHelpContentItem *itm = contentModel->contentItemAt(m_contentWidget->currentIndex()); + QMenu menu; + QAction *curTab = menu.addAction(tr("Open Link")); + QAction *newTab = menu.addAction(tr("Open Link in New Tab")); + if (isPdfFile(itm)) + newTab->setEnabled(false); + + menu.move(m_contentWidget->mapToGlobal(pos)); + QAction *action = menu.exec(); if (curTab == action) emit linkActivated(itm->url()); @@ -175,4 +178,10 @@ void ContentWindow::itemClicked(const QModelIndex &index) } } +bool ContentWindow::isPdfFile(QHelpContentItem *item) const +{ + const QString &path = item->url().path(); + return path.endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive); +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/contentwindow.h b/tools/assistant/tools/assistant/contentwindow.h index ab8f8dd..ddc3e7c 100644 --- a/tools/assistant/tools/assistant/contentwindow.h +++ b/tools/assistant/tools/assistant/contentwindow.h @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE class QHelpEngine; +class QHelpContentItem; class QHelpContentWidget; class ContentWindow : public QWidget @@ -75,6 +76,7 @@ private: void focusInEvent(QFocusEvent *e); void keyPressEvent(QKeyEvent *e); bool eventFilter(QObject *o, QEvent *e); + bool isPdfFile(QHelpContentItem *item) const; QHelpEngine *m_helpEngine; QHelpContentWidget *m_contentWidget; -- cgit v0.12