GerritDialog: Fix keyboard activation

Open the change in a browser on Return/Enter

Change-Id: I6ed6d832e3bebf625adb3765415929cc0670d4e4
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Daniel Teske
2014-04-09 16:47:18 +02:00
parent c17ddb7766
commit 094a309a10
2 changed files with 10 additions and 6 deletions

View File

@@ -32,6 +32,7 @@
#include "gerritparameters.h" #include "gerritparameters.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/itemviews.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <QVBoxLayout> #include <QVBoxLayout>
@@ -96,7 +97,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
, m_filterModel(new QSortFilterProxyModel(this)) , m_filterModel(new QSortFilterProxyModel(this))
, m_model(new GerritModel(p, this)) , m_model(new GerritModel(p, this))
, m_queryModel(new QStringListModel(this)) , m_queryModel(new QStringListModel(this))
, m_treeView(new QTreeView) , m_treeView(new Utils::TreeView)
, m_detailsBrowser(new QTextBrowser) , m_detailsBrowser(new QTextBrowser)
, m_queryLineEdit(new QueryValidatingLineEdit) , m_queryLineEdit(new QueryValidatingLineEdit)
, m_filterLineEdit(new Utils::FancyLineEdit) , m_filterLineEdit(new Utils::FancyLineEdit)
@@ -143,12 +144,13 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
m_treeView->setRootIsDecorated(false); m_treeView->setRootIsDecorated(false);
m_treeView->setSelectionBehavior(QAbstractItemView::SelectRows); m_treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
m_treeView->setSortingEnabled(true); m_treeView->setSortingEnabled(true);
m_treeView->setActivationMode(Utils::DoubleClickActivation);
QItemSelectionModel *selectionModel = m_treeView->selectionModel(); QItemSelectionModel *selectionModel = m_treeView->selectionModel();
connect(selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)), connect(selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(slotCurrentChanged())); this, SLOT(slotCurrentChanged()));
connect(m_treeView, SIGNAL(doubleClicked(QModelIndex)), connect(m_treeView, SIGNAL(activated(QModelIndex)),
this, SLOT(slotDoubleClicked(QModelIndex))); this, SLOT(slotActivated(QModelIndex)));
QGroupBox *detailsGroup = new QGroupBox(tr("Details")); QGroupBox *detailsGroup = new QGroupBox(tr("Details"));
QVBoxLayout *detailsLayout = new QVBoxLayout(detailsGroup); QVBoxLayout *detailsLayout = new QVBoxLayout(detailsGroup);
@@ -224,7 +226,7 @@ GerritDialog::~GerritDialog()
{ {
} }
void GerritDialog::slotDoubleClicked(const QModelIndex &i) void GerritDialog::slotActivated(const QModelIndex &i)
{ {
if (const QStandardItem *item = itemAt(i)) if (const QStandardItem *item = itemAt(i))
QDesktopServices::openUrl(QUrl(m_model->change(item->row())->url)); QDesktopServices::openUrl(QUrl(m_model->change(item->row())->url));

View File

@@ -48,6 +48,8 @@ class QDialogButtonBox;
class QTextBrowser; class QTextBrowser;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Utils { class TreeView; }
namespace Gerrit { namespace Gerrit {
namespace Internal { namespace Internal {
class GerritParameters; class GerritParameters;
@@ -93,7 +95,7 @@ public slots:
private slots: private slots:
void slotCurrentChanged(); void slotCurrentChanged();
void slotDoubleClicked(const QModelIndex &); void slotActivated(const QModelIndex &);
void slotRefreshStateChanged(bool); void slotRefreshStateChanged(bool);
void slotFetchDisplay(); void slotFetchDisplay();
void slotFetchCherryPick(); void slotFetchCherryPick();
@@ -111,7 +113,7 @@ private:
QSortFilterProxyModel *m_filterModel; QSortFilterProxyModel *m_filterModel;
GerritModel *m_model; GerritModel *m_model;
QStringListModel *m_queryModel; QStringListModel *m_queryModel;
QTreeView *m_treeView; Utils::TreeView *m_treeView;
QTextBrowser *m_detailsBrowser; QTextBrowser *m_detailsBrowser;
QueryValidatingLineEdit *m_queryLineEdit; QueryValidatingLineEdit *m_queryLineEdit;
Utils::FancyLineEdit *m_filterLineEdit; Utils::FancyLineEdit *m_filterLineEdit;