diff options
author | kh <qtc-committer@nokia.com> | 2009-04-01 14:18:12 (GMT) |
---|---|---|
committer | kh <qtc-committer@nokia.com> | 2009-04-01 14:18:12 (GMT) |
commit | ef46fa38e50b807c6122dc37d84d2944069ef3ea (patch) | |
tree | 8b604c65ba4d4d787c12f3afb5b76a9a97919098 | |
parent | 6eac95b553f4a2958c2c58127441f2705b05b0a3 (diff) | |
download | Qt-ef46fa38e50b807c6122dc37d84d2944069ef3ea.zip Qt-ef46fa38e50b807c6122dc37d84d2944069ef3ea.tar.gz Qt-ef46fa38e50b807c6122dc37d84d2944069ef3ea.tar.bz2 |
don't invoke the current item without selection
Task-number: none
Reviewed-by: hjk
-rw-r--r-- | tools/assistant/tools/assistant/contentwindow.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index ef272e8..24e7ca9 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -118,19 +118,24 @@ void ContentWindow::keyPressEvent(QKeyEvent *e) bool ContentWindow::eventFilter(QObject *o, QEvent *e) { - if (m_contentWidget && o == m_contentWidget->viewport() && e->type() - == QEvent::MouseButtonRelease) { + if (m_contentWidget && o == m_contentWidget->viewport() + && e->type() == QEvent::MouseButtonRelease) { QMouseEvent *me = static_cast<QMouseEvent*>(e); - if (m_contentWidget->indexAt(me->pos()).isValid() - && me->button() == Qt::LeftButton) { - itemClicked(m_contentWidget->currentIndex()); - } else if (m_contentWidget->indexAt(me->pos()).isValid() - && me->button() == Qt::MidButton) { - QHelpContentModel *contentModel = - qobject_cast<QHelpContentModel*>(m_contentWidget->model()); - QHelpContentItem *itm = - contentModel->contentItemAt(m_contentWidget->currentIndex()); - CentralWidget::instance()->setSourceInNewTab(itm->url()); + QModelIndex index = m_contentWidget->indexAt(me->pos()); + QItemSelectionModel *sm = m_contentWidget->selectionModel(); + + if (index.isValid() && (sm && sm->isSelected(index))) { + if (me->button() == Qt::LeftButton) { + itemClicked(index); + } else if (me->button() == Qt::MidButton) { + QHelpContentModel *contentModel = + qobject_cast<QHelpContentModel*>(m_contentWidget->model()); + if (contentModel) { + QHelpContentItem *itm = contentModel->contentItemAt(index); + if (itm) + CentralWidget::instance()->setSourceInNewTab(itm->url()); + } + } } } return QWidget::eventFilter(o, e); @@ -160,14 +165,14 @@ void ContentWindow::showContextMenu(const QPoint &pos) void ContentWindow::itemClicked(const QModelIndex &index) { - if (!index.isValid()) - return; QHelpContentModel *contentModel = qobject_cast<QHelpContentModel*>(m_contentWidget->model()); - QHelpContentItem *itm = - contentModel->contentItemAt(index); - if (itm) - emit linkActivated(itm->url()); + + if (contentModel) { + QHelpContentItem *itm = contentModel->contentItemAt(index); + if (itm) + emit linkActivated(itm->url()); + } } QT_END_NAMESPACE |