Commit 7e59415f authored by Daniel Teske's avatar Daniel Teske

LogChangeWidget: Fix keyboard navigation on all platforms

Change-Id: I42858fd8aa8b5403e0d2a0639a6fe9fe5817f4a6
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent aeabe1a7
......@@ -99,7 +99,7 @@ void GitSubmitEditorWidget::initialize(CommitType commitType,
logChangeGroupBox->setLayout(logChangeLayout);
m_logChangeWidget = new LogChangeWidget;
m_logChangeWidget->init(repository);
connect(m_logChangeWidget, SIGNAL(doubleClicked(QString)), this, SIGNAL(show(QString)));
connect(m_logChangeWidget, SIGNAL(activated(QString)), this, SIGNAL(show(QString)));
logChangeLayout->addWidget(m_logChangeWidget);
insertTopWidget(logChangeGroupBox);
m_gitSubmitPanelUi.editGroup->hide();
......
......@@ -59,7 +59,7 @@ enum Columns
};
LogChangeWidget::LogChangeWidget(QWidget *parent)
: QTreeView(parent)
: Utils::TreeView(parent)
, m_model(new QStandardItemModel(0, ColumnCount, this))
, m_hasCustomDelegate(false)
{
......@@ -71,7 +71,8 @@ LogChangeWidget::LogChangeWidget(QWidget *parent)
setUniformRowHeights(true);
setRootIsDecorated(false);
setSelectionBehavior(QAbstractItemView::SelectRows);
connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(emitDoubleClicked(QModelIndex)));
setActivationMode(Utils::DoubleClickActivation);
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(emitActivated(QModelIndex)));
}
bool LogChangeWidget::init(const QString &repository, const QString &commit, LogFlags flags)
......@@ -114,23 +115,23 @@ QString LogChangeWidget::earliestCommit() const
void LogChangeWidget::setItemDelegate(QAbstractItemDelegate *delegate)
{
QTreeView::setItemDelegate(delegate);
Utils::TreeView::setItemDelegate(delegate);
m_hasCustomDelegate = true;
}
void LogChangeWidget::emitDoubleClicked(const QModelIndex &index)
void LogChangeWidget::emitActivated(const QModelIndex &index)
{
if (index.isValid()) {
QString commit = index.sibling(index.row(), Sha1Column).data().toString();
if (!commit.isEmpty())
emit doubleClicked(commit);
emit activated(commit);
}
}
void LogChangeWidget::selectionChanged(const QItemSelection &selected,
const QItemSelection &deselected)
{
QTreeView::selectionChanged(selected, deselected);
Utils::TreeView::selectionChanged(selected, deselected);
if (!m_hasCustomDelegate)
return;
const QModelIndexList previousIndexes = deselected.indexes();
......
......@@ -30,10 +30,11 @@
#ifndef LOGCHANGEDDIALOG_H
#define LOGCHANGEDDIALOG_H
#include <utils/itemviews.h>
#include <QDialog>
#include <QIcon>
#include <QStyledItemDelegate>
#include <QTreeView>
QT_BEGIN_NAMESPACE
class QDialogButtonBox;
......@@ -48,7 +49,7 @@ namespace Internal {
// A widget that lists SHA1 and subject of the changes
// Used for reset and interactive rebase
class LogChangeWidget : public QTreeView
class LogChangeWidget : public Utils::TreeView
{
Q_OBJECT
......@@ -70,10 +71,10 @@ public:
void setItemDelegate(QAbstractItemDelegate *delegate);
signals:
void doubleClicked(const QString &commit);
void activated(const QString &commit);
private slots:
void emitDoubleClicked(const QModelIndex &index);
void emitActivated(const QModelIndex &index);
private:
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
......
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