forked from qt-creator/qt-creator
Git: Add fetch to branch view
Allow fetching from a single or from all remotes. Change-Id: I2e0e69a092c3a8bb58f65af877c9af8bb59c92d9 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
André Hartmann
parent
62072903b0
commit
8c8f166535
@@ -647,6 +647,19 @@ void BranchModel::setOldBranchesIncluded(bool value)
|
|||||||
m_oldBranchesIncluded = value;
|
m_oldBranchesIncluded = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils::optional<QString> BranchModel::remoteName(const QModelIndex &idx) const
|
||||||
|
{
|
||||||
|
const BranchNode *remotesNode = m_rootNode->children.at(RemoteBranches);
|
||||||
|
const BranchNode *node = indexToNode(idx);
|
||||||
|
if (!node)
|
||||||
|
return Utils::nullopt;
|
||||||
|
if (node == remotesNode)
|
||||||
|
return QString();
|
||||||
|
if (node->parent == remotesNode)
|
||||||
|
return node->name;
|
||||||
|
return Utils::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
void BranchModel::parseOutputLine(const QString &line)
|
void BranchModel::parseOutputLine(const QString &line)
|
||||||
{
|
{
|
||||||
if (line.size() < 3)
|
if (line.size() < 3)
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <utils/optional.h>
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
@@ -81,6 +83,7 @@ public:
|
|||||||
QModelIndex addBranch(const QString &name, bool track, const QModelIndex &trackedBranch);
|
QModelIndex addBranch(const QString &name, bool track, const QModelIndex &trackedBranch);
|
||||||
void setRemoteTracking(const QModelIndex &trackingIndex);
|
void setRemoteTracking(const QModelIndex &trackingIndex);
|
||||||
void setOldBranchesIncluded(bool value);
|
void setOldBranchesIncluded(bool value);
|
||||||
|
Utils::optional<QString> remoteName(const QModelIndex &idx) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void parseOutputLine(const QString &line);
|
void parseOutputLine(const QString &line);
|
||||||
|
|||||||
@@ -167,6 +167,12 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
|
|||||||
|
|
||||||
QMenu contextMenu;
|
QMenu contextMenu;
|
||||||
contextMenu.addAction(tr("Add..."), this, &BranchView::add);
|
contextMenu.addAction(tr("Add..."), this, &BranchView::add);
|
||||||
|
const Utils::optional<QString> remote = m_model->remoteName(index);
|
||||||
|
if (remote.has_value()) {
|
||||||
|
contextMenu.addAction(tr("Fetch"), this, [this, &remote]() {
|
||||||
|
GitPlugin::client()->fetch(m_repository, *remote);
|
||||||
|
});
|
||||||
|
}
|
||||||
if (hasActions) {
|
if (hasActions) {
|
||||||
if (!currentSelected && (isLocal || isTag))
|
if (!currentSelected && (isLocal || isTag))
|
||||||
contextMenu.addAction(tr("Remove"), this, &BranchView::remove);
|
contextMenu.addAction(tr("Remove"), this, &BranchView::remove);
|
||||||
|
|||||||
Reference in New Issue
Block a user