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 "centralwidget.h"
|
||||
#include "helpmanager.h"
|
||||
#include "helpviewer.h"
|
||||
#include "openpagesmanager.h"
|
||||
|
||||
#include <QtGui/QLayout>
|
||||
@@ -102,18 +104,21 @@ 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();
|
||||
if (!me || !sm)
|
||||
return QWidget::eventFilter(o, e);
|
||||
|
||||
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))
|
||||
|| (button == Qt::MidButton)) {
|
||||
QHelpContentModel *contentModel =
|
||||
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
|
||||
if (contentModel) {
|
||||
QHelpContentItem *itm = contentModel->contentItemAt(index);
|
||||
if (itm && !isPdfFile(itm))
|
||||
if (itm && HelpViewer::canOpenPage(itm->url().path()))
|
||||
OpenPagesManager::instance().createPage(itm->url());
|
||||
}
|
||||
} else if (button == Qt::LeftButton) {
|
||||
@@ -137,7 +142,7 @@ void ContentWindow::showContextMenu(const QPoint &pos)
|
||||
QMenu menu;
|
||||
QAction *curTab = menu.addAction(tr("Open Link"));
|
||||
QAction *newTab = menu.addAction(tr("Open Link as New Page"));
|
||||
if (isPdfFile(itm))
|
||||
if (!HelpViewer::canOpenPage(itm->url().path()))
|
||||
newTab->setEnabled(false);
|
||||
|
||||
menu.move(m_contentWidget->mapToGlobal(pos));
|
||||
@@ -155,14 +160,10 @@ void ContentWindow::itemClicked(const QModelIndex &index)
|
||||
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
|
||||
|
||||
if (contentModel) {
|
||||
QHelpContentItem *itm = contentModel->contentItemAt(index);
|
||||
if (itm)
|
||||
emit linkActivated(itm->url());
|
||||
if (QHelpContentItem *itm = contentModel->contentItemAt(index)) {
|
||||
const QUrl &url = 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:
|
||||
bool eventFilter(QObject *o, QEvent *e);
|
||||
bool isPdfFile(QHelpContentItem *item) const;
|
||||
|
||||
QHelpContentWidget *m_contentWidget;
|
||||
int m_expandDepth;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "centralwidget.h"
|
||||
|
||||
#include "helpmanager.h"
|
||||
#include "helpviewer.h"
|
||||
#include "indexwindow.h"
|
||||
#include "openpagesmanager.h"
|
||||
#include "topicchooser.h"
|
||||
@@ -209,8 +210,8 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index)
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.path().endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive))
|
||||
Help::Internal::CentralWidget::instance()->setSource(url);
|
||||
if (!HelpViewer::canOpenPage(url.path()))
|
||||
CentralWidget::instance()->setSource(url);
|
||||
else
|
||||
OpenPagesManager::instance().createPage(url);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user