diff options
author | kh <qtc-committer@nokia.com> | 2009-04-02 17:58:51 +0200 |
---|---|---|
committer | kh <qtc-committer@nokia.com> | 2009-04-02 17:58:51 +0200 |
commit | 0c508410dd42714b9854b523c851ef699ebcf7d7 (patch) | |
tree | 716eb7edc748ae1937fa936fd2963e8e432bbab0 /tools | |
parent | db4040f7bf1e36b9568e7a99dc090acf03b0ddd0 (diff) | |
download | qt4-tools-0c508410dd42714b9854b523c851ef699ebcf7d7.tar.gz |
fixes empty tab after pdf file open
Task-number: none
Reviewed-by: --global
Diffstat (limited to 'tools')
-rw-r--r-- | tools/assistant/tools/assistant/contentwindow.cpp | 21 | ||||
-rw-r--r-- | 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 24e7ca9053..89060bd069 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<QHelpContentModel*>(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<QHelpContentModel*>(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 ab8f8ddeb6..ddc3e7c025 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; |