forked from qt-creator/qt-creator
ClangTools: Go to location on enter/space
Change-Id: I865a445207bf161213761b607f1f447b79ef7359 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -46,6 +46,7 @@ DiagnosticView::DiagnosticView(QWidget *parent)
|
|||||||
m_suppressAction = new QAction(tr("Suppress This Diagnostic"), this);
|
m_suppressAction = new QAction(tr("Suppress This Diagnostic"), this);
|
||||||
connect(m_suppressAction, &QAction::triggered,
|
connect(m_suppressAction, &QAction::triggered,
|
||||||
this, &DiagnosticView::suppressCurrentDiagnostic);
|
this, &DiagnosticView::suppressCurrentDiagnostic);
|
||||||
|
installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticView::suppressCurrentDiagnostic()
|
void DiagnosticView::suppressCurrentDiagnostic()
|
||||||
@@ -80,5 +81,27 @@ QList<QAction *> DiagnosticView::customActions() const
|
|||||||
return QList<QAction *>() << m_suppressAction;
|
return QList<QAction *>() << m_suppressAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DiagnosticView::eventFilter(QObject *watched, QEvent *event)
|
||||||
|
{
|
||||||
|
switch (event->type()) {
|
||||||
|
case QEvent::KeyRelease: {
|
||||||
|
const int key = static_cast<QKeyEvent *>(event)->key();
|
||||||
|
switch (key) {
|
||||||
|
case Qt::Key_Return:
|
||||||
|
case Qt::Key_Enter:
|
||||||
|
case Qt::Key_Space:
|
||||||
|
const QModelIndex current = currentIndex();
|
||||||
|
const QModelIndex location = model()->index(current.row(),
|
||||||
|
LocationColumn,
|
||||||
|
current.parent());
|
||||||
|
emit clicked(location);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return QObject::eventFilter(watched, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ClangTools
|
} // namespace ClangTools
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ private:
|
|||||||
void suppressCurrentDiagnostic();
|
void suppressCurrentDiagnostic();
|
||||||
|
|
||||||
QList<QAction *> customActions() const;
|
QList<QAction *> customActions() const;
|
||||||
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
QAction *m_suppressAction;
|
QAction *m_suppressAction;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user