forked from qt-creator/qt-creator
Sync against Assistant
Reviewed-by: ck
This commit is contained in:
@@ -29,7 +29,9 @@
|
|||||||
|
|
||||||
#include "contentwindow.h"
|
#include "contentwindow.h"
|
||||||
|
|
||||||
|
#include "centralwidget.h"
|
||||||
#include "helpmanager.h"
|
#include "helpmanager.h"
|
||||||
|
#include "helpviewer.h"
|
||||||
#include "openpagesmanager.h"
|
#include "openpagesmanager.h"
|
||||||
|
|
||||||
#include <QtGui/QLayout>
|
#include <QtGui/QLayout>
|
||||||
@@ -102,18 +104,21 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e)
|
|||||||
if (m_contentWidget && o == m_contentWidget->viewport()
|
if (m_contentWidget && o == m_contentWidget->viewport()
|
||||||
&& e->type() == QEvent::MouseButtonRelease) {
|
&& e->type() == QEvent::MouseButtonRelease) {
|
||||||
QMouseEvent *me = static_cast<QMouseEvent*>(e);
|
QMouseEvent *me = static_cast<QMouseEvent*>(e);
|
||||||
QModelIndex index = m_contentWidget->indexAt(me->pos());
|
|
||||||
QItemSelectionModel *sm = m_contentWidget->selectionModel();
|
QItemSelectionModel *sm = m_contentWidget->selectionModel();
|
||||||
|
if (!me || !sm)
|
||||||
|
return QWidget::eventFilter(o, e);
|
||||||
|
|
||||||
Qt::MouseButtons button = me->button();
|
Qt::MouseButtons button = me->button();
|
||||||
if (index.isValid() && (sm && sm->isSelected(index))) {
|
const QModelIndex &index = m_contentWidget->indexAt(me->pos());
|
||||||
|
|
||||||
|
if (index.isValid() && sm->isSelected(index)) {
|
||||||
if ((button == Qt::LeftButton && (me->modifiers() & Qt::ControlModifier))
|
if ((button == Qt::LeftButton && (me->modifiers() & Qt::ControlModifier))
|
||||||
|| (button == Qt::MidButton)) {
|
|| (button == Qt::MidButton)) {
|
||||||
QHelpContentModel *contentModel =
|
QHelpContentModel *contentModel =
|
||||||
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
|
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
|
||||||
if (contentModel) {
|
if (contentModel) {
|
||||||
QHelpContentItem *itm = contentModel->contentItemAt(index);
|
QHelpContentItem *itm = contentModel->contentItemAt(index);
|
||||||
if (itm && !isPdfFile(itm))
|
if (itm && HelpViewer::canOpenPage(itm->url().path()))
|
||||||
OpenPagesManager::instance().createPage(itm->url());
|
OpenPagesManager::instance().createPage(itm->url());
|
||||||
}
|
}
|
||||||
} else if (button == Qt::LeftButton) {
|
} else if (button == Qt::LeftButton) {
|
||||||
@@ -137,7 +142,7 @@ void ContentWindow::showContextMenu(const QPoint &pos)
|
|||||||
QMenu menu;
|
QMenu menu;
|
||||||
QAction *curTab = menu.addAction(tr("Open Link"));
|
QAction *curTab = menu.addAction(tr("Open Link"));
|
||||||
QAction *newTab = menu.addAction(tr("Open Link as New Page"));
|
QAction *newTab = menu.addAction(tr("Open Link as New Page"));
|
||||||
if (isPdfFile(itm))
|
if (!HelpViewer::canOpenPage(itm->url().path()))
|
||||||
newTab->setEnabled(false);
|
newTab->setEnabled(false);
|
||||||
|
|
||||||
menu.move(m_contentWidget->mapToGlobal(pos));
|
menu.move(m_contentWidget->mapToGlobal(pos));
|
||||||
@@ -155,14 +160,10 @@ void ContentWindow::itemClicked(const QModelIndex &index)
|
|||||||
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
|
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
|
||||||
|
|
||||||
if (contentModel) {
|
if (contentModel) {
|
||||||
QHelpContentItem *itm = contentModel->contentItemAt(index);
|
if (QHelpContentItem *itm = contentModel->contentItemAt(index)) {
|
||||||
if (itm)
|
const QUrl &url = itm->url();
|
||||||
emit linkActivated(itm->url());
|
if (url != CentralWidget::instance()->currentHelpViewer()->source())
|
||||||
|
emit linkActivated(itm->url());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContentWindow::isPdfFile(QHelpContentItem *item) const
|
|
||||||
{
|
|
||||||
const QString &path = item->url().path();
|
|
||||||
return path.endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool eventFilter(QObject *o, QEvent *e);
|
bool eventFilter(QObject *o, QEvent *e);
|
||||||
bool isPdfFile(QHelpContentItem *item) const;
|
|
||||||
|
|
||||||
QHelpContentWidget *m_contentWidget;
|
QHelpContentWidget *m_contentWidget;
|
||||||
int m_expandDepth;
|
int m_expandDepth;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "centralwidget.h"
|
#include "centralwidget.h"
|
||||||
|
|
||||||
#include "helpmanager.h"
|
#include "helpmanager.h"
|
||||||
|
#include "helpviewer.h"
|
||||||
#include "indexwindow.h"
|
#include "indexwindow.h"
|
||||||
#include "openpagesmanager.h"
|
#include "openpagesmanager.h"
|
||||||
#include "topicchooser.h"
|
#include "topicchooser.h"
|
||||||
@@ -209,8 +210,8 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url.path().endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive))
|
if (!HelpViewer::canOpenPage(url.path()))
|
||||||
Help::Internal::CentralWidget::instance()->setSource(url);
|
CentralWidget::instance()->setSource(url);
|
||||||
else
|
else
|
||||||
OpenPagesManager::instance().createPage(url);
|
OpenPagesManager::instance().createPage(url);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user