summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/assistant/tools/assistant/contentwindow.cpp41
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