Commit 919510e5 authored by Daniel Teske's avatar Daniel Teske
Browse files

QmlConsoleView: Use Utils::TreeView to get consistent keyboard handling



Change-Id: I3b420d19602ab5e5bd9a4afd8aba7cffeca4089f
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 28f8bf2f
......@@ -79,7 +79,7 @@ public:
///////////////////////////////////////////////////////////////////////
QmlConsoleView::QmlConsoleView(QWidget *parent) :
QTreeView(parent)
Utils::TreeView(parent)
{
setFrameStyle(QFrame::NoFrame);
setHeaderHidden(true);
......@@ -160,28 +160,18 @@ void QmlConsoleView::mousePressEvent(QMouseEvent *event)
}
}
if (!handled)
QTreeView::mousePressEvent(event);
Utils::TreeView::mousePressEvent(event);
} else {
selectionModel()->setCurrentIndex(model()->index(model()->rowCount() - 1, 0),
QItemSelectionModel::ClearAndSelect);
}
}
void QmlConsoleView::keyPressEvent(QKeyEvent *e)
{
if (!e->modifiers() && e->key() == Qt::Key_Return) {
emit activated(currentIndex());
e->accept();
return;
}
QTreeView::keyPressEvent(e);
}
void QmlConsoleView::resizeEvent(QResizeEvent *e)
{
static_cast<QmlConsoleItemDelegate *>(itemDelegate())->emitSizeHintChanged(
selectionModel()->currentIndex());
QTreeView::resizeEvent(e);
Utils::TreeView::resizeEvent(e);
}
void QmlConsoleView::drawBranches(QPainter *painter, const QRect &rect,
......@@ -189,7 +179,7 @@ void QmlConsoleView::drawBranches(QPainter *painter, const QRect &rect,
{
static_cast<QmlConsoleItemDelegate *>(itemDelegate())->drawBackground(painter, rect, index,
false);
QTreeView::drawBranches(painter, rect, index);
Utils::TreeView::drawBranches(painter, rect, index);
}
void QmlConsoleView::contextMenuEvent(QContextMenuEvent *event)
......
......@@ -30,12 +30,12 @@
#ifndef QMLCONSOLEVIEW_H
#define QMLCONSOLEVIEW_H
#include <QTreeView>
#include <utils/itemviews.h>
namespace QmlJSTools {
namespace Internal {
class QmlConsoleView : public QTreeView
class QmlConsoleView : public Utils::TreeView
{
Q_OBJECT
public:
......@@ -46,7 +46,6 @@ public slots:
protected:
void mousePressEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *e);
void resizeEvent(QResizeEvent *e);
void drawBranches(QPainter *painter, const QRect &rect,
const QModelIndex &index) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment