summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkh <qtc-committer@nokia.com>2009-04-02 15:58:51 (GMT)
committerkh <qtc-committer@nokia.com>2009-04-02 15:58:51 (GMT)
commit0c508410dd42714b9854b523c851ef699ebcf7d7 (patch)
tree716eb7edc748ae1937fa936fd2963e8e432bbab0 /tools
parentdb4040f7bf1e36b9568e7a99dc090acf03b0ddd0 (diff)
downloadQt-0c508410dd42714b9854b523c851ef699ebcf7d7.zip
Qt-0c508410dd42714b9854b523c851ef699ebcf7d7.tar.gz
Qt-0c508410dd42714b9854b523c851ef699ebcf7d7.tar.bz2
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.cpp21
-rw-r--r--tools/assistant/tools/assistant/contentwindow.h2
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<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 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;