Git: Double click on branch shows log

...instead of allowing to rename inline. Renaming can still be done with
the context menu.

Inspecting the log is a more common operation.

Change-Id: Idb3fb8fe01b6a5ae57a2eba09b27a36f677e566a
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Nikolai Kosjar
2018-09-26 15:06:24 +02:00
committed by Orgad Shaneh
parent d982c362c1
commit 8b93eee3b1
3 changed files with 13 additions and 9 deletions

View File

@@ -319,9 +319,6 @@ Qt::ItemFlags BranchModel::flags(const QModelIndex &index) const
BranchNode *node = indexToNode(index); BranchNode *node = indexToNode(index);
if (!node) if (!node)
return Qt::NoItemFlags; return Qt::NoItemFlags;
if (index.column() == 0 && node->isLeaf() && node->isLocal())
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
else
return Qt::ItemIsSelectable | Qt::ItemIsEnabled; return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
} }

View File

@@ -100,6 +100,8 @@ BranchView::BranchView() :
this, &BranchView::BranchView::setIncludeTags); this, &BranchView::BranchView::setIncludeTags);
m_branchView->setContextMenuPolicy(Qt::CustomContextMenu); m_branchView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_branchView, &QAbstractItemView::doubleClicked,
this, &BranchView::log);
connect(m_branchView, &QWidget::customContextMenuRequested, connect(m_branchView, &QWidget::customContextMenuRequested,
this, &BranchView::slotCustomContextMenu); this, &BranchView::slotCustomContextMenu);
connect(m_model, &QAbstractItemModel::modelReset, connect(m_model, &QAbstractItemModel::modelReset,
@@ -192,11 +194,7 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
if (!fullName.isEmpty()) if (!fullName.isEmpty())
GitPlugin::client()->diffBranch(m_repository, fullName); GitPlugin::client()->diffBranch(m_repository, fullName);
}); });
contextMenu.addAction(tr("Log"), this, [this] { contextMenu.addAction(tr("Log"), this, [this] { log(selectedIndex()); });
const QString branchName = m_model->fullName(selectedIndex(), true);
if (!branchName.isEmpty())
GitPlugin::client()->log(m_repository, QString(), false, {branchName});
});
contextMenu.addSeparator(); contextMenu.addSeparator();
if (!currentSelected) { if (!currentSelected) {
if (currentLocal) if (currentLocal)
@@ -491,6 +489,13 @@ bool BranchView::cherryPick()
return GitPlugin::client()->synchronousCherryPick(m_repository, branch); return GitPlugin::client()->synchronousCherryPick(m_repository, branch);
} }
void BranchView::log(const QModelIndex &idx)
{
const QString branchName = m_model->fullName(idx, true);
if (!branchName.isEmpty())
GitPlugin::client()->log(m_repository, QString(), false, {branchName});
}
BranchViewFactory::BranchViewFactory() BranchViewFactory::BranchViewFactory()
{ {
setDisplayName(tr("Git Branches")); setDisplayName(tr("Git Branches"));

View File

@@ -31,6 +31,7 @@
#include <QWidget> #include <QWidget>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QModelIndex;
class QPoint; class QPoint;
class QToolButton; class QToolButton;
class QTreeView; class QTreeView;
@@ -79,6 +80,7 @@ private:
bool merge(bool allowFastForward); bool merge(bool allowFastForward);
void rebase(); void rebase();
bool cherryPick(); bool cherryPick();
void log(const QModelIndex &idx);
QToolButton *m_addButton = nullptr; QToolButton *m_addButton = nullptr;
QToolButton *m_refreshButton = nullptr; QToolButton *m_refreshButton = nullptr;