forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.8'
Conflicts: src/plugins/debugger/debuggermainwindow.cpp src/plugins/qbsprojectmanager/qbsbuildstep.cpp src/plugins/winrt/winrtdevicefactory.cpp tests/unit/unittest/gtest-creator-printing.cpp tests/unit/unittest/gtest-creator-printing.h tests/unit/unittest/unittest.pro Change-Id: Ie9b80b87a8a4fa81baf72a2daa7919b21371c15e
This commit is contained in:
@@ -24,9 +24,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "branchadddialog.h"
|
||||
#include "branchmodel.h"
|
||||
#include "ui_branchadddialog.h"
|
||||
#include "gitplugin.h"
|
||||
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QPushButton>
|
||||
@@ -87,6 +89,21 @@ private:
|
||||
QStringList m_localBranches;
|
||||
};
|
||||
|
||||
BranchValidationDelegate::BranchValidationDelegate(QWidget *parent, BranchModel *model)
|
||||
: QItemDelegate(parent)
|
||||
, m_model(model)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget *BranchValidationDelegate::createEditor(QWidget *parent,
|
||||
const QStyleOptionViewItem & /*option*/,
|
||||
const QModelIndex & /*index*/) const
|
||||
{
|
||||
auto lineEdit = new Utils::FancyLineEdit(parent);
|
||||
BranchNameValidator *validator = new BranchNameValidator(m_model->localBranchNames(), lineEdit);
|
||||
lineEdit->setValidator(validator);
|
||||
return lineEdit;
|
||||
}
|
||||
|
||||
BranchAddDialog::BranchAddDialog(const QStringList &localBranches, bool addBranch, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
|
||||
@@ -26,13 +26,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QItemDelegate>
|
||||
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
class BranchModel;
|
||||
|
||||
namespace Ui { class BranchAddDialog; }
|
||||
|
||||
class BranchValidationDelegate : public QItemDelegate
|
||||
{
|
||||
public:
|
||||
BranchValidationDelegate(QWidget *parent, BranchModel *model);
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
BranchModel *m_model;
|
||||
};
|
||||
|
||||
class BranchAddDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -317,7 +317,10 @@ Qt::ItemFlags BranchModel::flags(const QModelIndex &index) const
|
||||
BranchNode *node = indexToNode(index);
|
||||
if (!node)
|
||||
return Qt::NoItemFlags;
|
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||
Qt::ItemFlags res = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||
if (node->isLeaf() && node->isLocal())
|
||||
res |= Qt::ItemIsEditable;
|
||||
return res;
|
||||
}
|
||||
|
||||
void BranchModel::clear()
|
||||
|
||||
@@ -126,6 +126,9 @@ BranchView::BranchView() :
|
||||
this, &BranchView::BranchView::setIncludeTags);
|
||||
|
||||
m_branchView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_branchView->setEditTriggers(QAbstractItemView::SelectedClicked
|
||||
| QAbstractItemView::EditKeyPressed);
|
||||
m_branchView->setItemDelegate(new BranchValidationDelegate(this, m_model));
|
||||
connect(m_branchView, &QAbstractItemView::doubleClicked,
|
||||
this, [this](const QModelIndex &idx) { log(m_filterModel->mapToSource(idx)); });
|
||||
connect(m_branchView, &QWidget::customContextMenuRequested,
|
||||
@@ -194,7 +197,7 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
|
||||
|
||||
const QModelIndex index = m_filterModel->mapToSource(filteredIndex);
|
||||
const QModelIndex currentBranch = m_model->currentBranch();
|
||||
const bool currentSelected = index.row() == currentBranch.row();
|
||||
const bool currentSelected = index.sibling(index.row(), 0) == currentBranch;
|
||||
const bool isLocal = m_model->isLocal(index);
|
||||
const bool isTag = m_model->isTag(index);
|
||||
const bool hasActions = m_model->isLeaf(index);
|
||||
@@ -432,7 +435,6 @@ bool BranchView::remove()
|
||||
bool BranchView::rename()
|
||||
{
|
||||
const QModelIndex selected = selectedIndex();
|
||||
QTC_CHECK(selected != m_model->currentBranch());
|
||||
const bool isTag = m_model->isTag(selected);
|
||||
QTC_CHECK(m_model->isLocal(selected) || isTag);
|
||||
|
||||
|
||||
@@ -769,22 +769,24 @@ GitClient::GitClient() : VcsBase::VcsBaseClientImpl(new GitSettings),
|
||||
.arg(QCoreApplication::applicationPid());
|
||||
}
|
||||
|
||||
QString GitClient::findRepositoryForDirectory(const QString &dir) const
|
||||
QString GitClient::findRepositoryForDirectory(const QString &directory) const
|
||||
{
|
||||
if (dir.isEmpty() || dir.endsWith("/.git") || dir.contains("/.git/"))
|
||||
if (directory.isEmpty() || directory.endsWith("/.git") || directory.contains("/.git/"))
|
||||
return QString();
|
||||
QDir directory(dir);
|
||||
// QFileInfo is outside loop, because it is faster this way
|
||||
QFileInfo fileInfo;
|
||||
do {
|
||||
if (directory.exists(GIT_DIRECTORY)) {
|
||||
fileInfo.setFile(directory, GIT_DIRECTORY);
|
||||
if (fileInfo.isFile())
|
||||
return directory.absolutePath();
|
||||
else if (directory.exists(".git/config"))
|
||||
return directory.absolutePath();
|
||||
}
|
||||
} while (!directory.isRoot() && directory.cdUp());
|
||||
FileName parent;
|
||||
for (FileName dir = FileName::fromString(directory); !dir.isEmpty(); dir = dir.parentDir()) {
|
||||
FileName gitName = FileName(dir).appendPath(GIT_DIRECTORY);
|
||||
if (!gitName.exists())
|
||||
continue; // parent might exist
|
||||
fileInfo.setFile(gitName.toString());
|
||||
if (fileInfo.isFile())
|
||||
return dir.toString();
|
||||
gitName.appendPath("config");
|
||||
if (gitName.exists())
|
||||
return dir.toString();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
const QStringList &arguments,
|
||||
bool isRebase = false);
|
||||
|
||||
QString findRepositoryForDirectory(const QString &dir) const;
|
||||
QString findRepositoryForDirectory(const QString &directory) const;
|
||||
QString findGitDirForRepository(const QString &repositoryDir) const;
|
||||
bool managesFile(const QString &workingDirectory, const QString &fileName) const;
|
||||
|
||||
|
||||
@@ -286,21 +286,17 @@ void GitEditorWidget::aboutToOpen(const QString &fileName, const QString &realFi
|
||||
|
||||
QString GitEditorWidget::decorateVersion(const QString &revision) const
|
||||
{
|
||||
const QFileInfo fi(source());
|
||||
const QString workingDirectory = fi.absolutePath();
|
||||
|
||||
// Format verbose, SHA1 being first token
|
||||
return GitPlugin::client()->synchronousShortDescription(workingDirectory, revision);
|
||||
return GitPlugin::client()->synchronousShortDescription(sourceWorkingDirectory(), revision);
|
||||
}
|
||||
|
||||
QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision) const
|
||||
{
|
||||
QStringList revisions;
|
||||
QString errorMessage;
|
||||
const QFileInfo fi(source());
|
||||
const QString workingDirectory = fi.absolutePath();
|
||||
// Get the SHA1's of the file.
|
||||
if (!GitPlugin::client()->synchronousParentRevisions(workingDirectory, revision, &revisions, &errorMessage)) {
|
||||
if (!GitPlugin::client()->synchronousParentRevisions(sourceWorkingDirectory(),
|
||||
revision, &revisions, &errorMessage)) {
|
||||
VcsOutputWindow::appendSilently(errorMessage);
|
||||
return QStringList();
|
||||
}
|
||||
@@ -371,8 +367,12 @@ QString GitEditorWidget::fileNameForLine(int line) const
|
||||
|
||||
QString GitEditorWidget::sourceWorkingDirectory() const
|
||||
{
|
||||
const QFileInfo fi(source());
|
||||
return fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath();
|
||||
Utils::FileName path = Utils::FileName::fromString(source());
|
||||
if (!path.isEmpty() && !path.toFileInfo().isDir())
|
||||
path = path.parentDir();
|
||||
while (!path.isEmpty() && !path.exists())
|
||||
path = path.parentDir();
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user