bool ContentWindow::eventFilter(QObject *o, QEvent *e) { if (m_contentWidget && o == m_contentWidget->viewport() && e->type() == QEvent::MouseButtonRelease) { QMouseEvent *me = static_cast<QMouseEvent*>(e); QItemSelectionModel *sm = m_contentWidget->selectionModel(); if (!me || !sm) return QWidget::eventFilter(o, e); Qt::MouseButtons button = me->button(); const QModelIndex &index = m_contentWidget->indexAt(me->pos()); if (index.isValid() && sm->isSelected(index)) { if ((button == Qt::LeftButton && (me->modifiers() & Qt::ControlModifier)) || (button == Qt::MidButton)) { QHelpContentModel *contentModel = qobject_cast<QHelpContentModel*>(m_contentWidget->model()); if (contentModel) { QHelpContentItem *itm = contentModel->contentItemAt(index); if (itm && HelpViewer::canOpenPage(itm->url().path())) OpenPagesManager::instance().createPage(itm->url()); } } else if (button == Qt::LeftButton) { itemClicked(index); } } } return QWidget::eventFilter(o, e); }
bool ContentWindow::eventFilter(QObject *o, QEvent *e) { if (m_contentWidget && o == m_contentWidget->viewport() && e->type() == QEvent::MouseButtonRelease) { QMouseEvent *me = static_cast<QMouseEvent*>(e); QModelIndex index = m_contentWidget->indexAt(me->pos()); QItemSelectionModel *sm = m_contentWidget->selectionModel(); Qt::MouseButtons button = me->button(); if (index.isValid() && (sm && sm->isSelected(index))) { if ((button == Qt::LeftButton && (me->modifiers() & Qt::ControlModifier)) || (button == Qt::MidButton)) { QHelpContentModel *contentModel = qobject_cast<QHelpContentModel*>(m_contentWidget->model()); if (contentModel) { QHelpContentItem *itm = contentModel->contentItemAt(index); if (itm && !isPdfFile(itm)) CentralWidget::instance()->setSourceInNewTab(itm->url()); } } else if (button == Qt::LeftButton) { itemClicked(index); } } } return QWidget::eventFilter(o, e); }
void ContentWindow::itemClicked(const QModelIndex &index) { QHelpContentModel *contentModel = qobject_cast<QHelpContentModel*>(m_contentWidget->model()); if (contentModel) { QHelpContentItem *itm = contentModel->contentItemAt(index); if (itm) emit linkActivated(itm->url()); } }
void ContentWindow::itemClicked(const QModelIndex &index) { QHelpContentModel *contentModel = qobject_cast<QHelpContentModel*>(m_contentWidget->model()); if (contentModel) { if (QHelpContentItem *itm = contentModel->contentItemAt(index)) { const QUrl &url = itm->url(); if (url != CentralWidget::instance()->currentHelpViewer()->source()) emit linkActivated(itm->url()); } } }
void ContentWindow::showContextMenu(const QPoint &pos) { if (!m_contentWidget->indexAt(pos).isValid()) return; 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 as New Page")); if (!HelpViewer::canOpenPage(itm->url().path())) newTab->setEnabled(false); menu.move(m_contentWidget->mapToGlobal(pos)); QAction *action = menu.exec(); if (curTab == action) emit linkActivated(itm->url()); else if (newTab == action) OpenPagesManager::instance().createPage(itm->url()); }
void ContentWindow::showContextMenu(const QPoint &pos) { if (!m_contentWidget->indexAt(pos).isValid()) return; 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()); else if (newTab == action) CentralWidget::instance()->setSourceInNewTab(itm->url()); }