forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.4'
Change-Id: I5b2beb01c6eaeceb897e3a81b790122af5f0d7a1
This commit is contained in:
@@ -68,6 +68,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->remoteComboBox->setParameters(m_parameters);
|
||||
m_ui->remoteComboBox->setFallbackEnabled(true);
|
||||
m_queryModel->setStringList(m_parameters->savedQueries);
|
||||
QCompleter *completer = new QCompleter(this);
|
||||
completer->setModel(m_queryModel);
|
||||
|
@@ -315,7 +315,7 @@ void GerritPlugin::addToLocator(CommandLocator *locator)
|
||||
void GerritPlugin::push(const QString &topLevel)
|
||||
{
|
||||
// QScopedPointer is required to delete the dialog when leaving the function
|
||||
GerritPushDialog dialog(topLevel, m_reviewers, ICore::mainWindow());
|
||||
GerritPushDialog dialog(topLevel, m_reviewers, m_parameters, ICore::mainWindow());
|
||||
|
||||
if (!dialog.isValid()) {
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Initialization Failed"),
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "gerritpushdialog.h"
|
||||
#include "ui_gerritpushdialog.h"
|
||||
#include "branchcombobox.h"
|
||||
#include "gerritserver.h"
|
||||
|
||||
#include "../gitplugin.h"
|
||||
#include "../gitclient.h"
|
||||
@@ -114,21 +115,11 @@ void GerritPushDialog::initRemoteBranches()
|
||||
BranchDate bd(ref.mid(refBranchIndex + 1), QDateTime::fromTime_t(timeT).date());
|
||||
m_remoteBranches.insertMulti(ref.left(refBranchIndex), bd);
|
||||
}
|
||||
QStringList remotes = GitPlugin::client()->synchronousRemotesList(m_workingDir).keys();
|
||||
remotes.removeDuplicates();
|
||||
{
|
||||
const QString origin = "origin";
|
||||
const QString gerrit = "gerrit";
|
||||
if (remotes.removeOne(origin))
|
||||
remotes.prepend(origin);
|
||||
if (remotes.removeOne(gerrit))
|
||||
remotes.prepend(gerrit);
|
||||
}
|
||||
m_ui->remoteComboBox->addItems(remotes);
|
||||
m_ui->remoteComboBox->setEnabled(remotes.count() > 1);
|
||||
m_ui->remoteComboBox->updateRemotes(false);
|
||||
}
|
||||
|
||||
GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &reviewerList, QWidget *parent) :
|
||||
GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &reviewerList,
|
||||
QSharedPointer<GerritParameters> parameters, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
m_workingDir(workingDir),
|
||||
m_ui(new Ui::GerritPushDialog)
|
||||
@@ -136,13 +127,15 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
m_ui->setupUi(this);
|
||||
m_ui->repositoryLabel->setText(QDir::toNativeSeparators(workingDir));
|
||||
m_ui->remoteComboBox->setRepository(workingDir);
|
||||
m_ui->remoteComboBox->setParameters(parameters);
|
||||
|
||||
PushItemDelegate *delegate = new PushItemDelegate(m_ui->commitView);
|
||||
delegate->setParent(this);
|
||||
|
||||
initRemoteBranches();
|
||||
|
||||
if (m_ui->remoteComboBox->count() < 1)
|
||||
if (m_ui->remoteComboBox->isEmpty())
|
||||
return;
|
||||
|
||||
m_ui->localBranchComboBox->init(workingDir);
|
||||
@@ -163,8 +156,8 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
|
||||
m_ui->reviewersLineEdit->setValidator(noSpaceValidator);
|
||||
m_ui->topicLineEdit->setValidator(noSpaceValidator);
|
||||
|
||||
connect(m_ui->remoteComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &GerritPushDialog::setRemoteBranches);
|
||||
connect(m_ui->remoteComboBox, &GerritRemoteChooser::remoteChanged,
|
||||
this, [this] { setRemoteBranches(); });
|
||||
|
||||
m_isValid = true;
|
||||
}
|
||||
@@ -285,10 +278,8 @@ void GerritPushDialog::updateCommits(int index)
|
||||
|
||||
m_suggestedRemoteBranch = remoteBranch.mid(slash + 1);
|
||||
const QString remote = remoteBranch.left(slash);
|
||||
const int index = m_ui->remoteComboBox->findText(remote);
|
||||
if (index != -1 && index != m_ui->remoteComboBox->currentIndex())
|
||||
m_ui->remoteComboBox->setCurrentIndex(index);
|
||||
else
|
||||
|
||||
if (!m_ui->remoteComboBox->setCurrentRemote(remote))
|
||||
setRemoteBranches();
|
||||
}
|
||||
validate();
|
||||
@@ -302,7 +293,7 @@ void GerritPushDialog::validate()
|
||||
|
||||
QString GerritPushDialog::selectedRemoteName() const
|
||||
{
|
||||
return m_ui->remoteComboBox->currentText();
|
||||
return m_ui->remoteComboBox->currentRemoteName();
|
||||
}
|
||||
|
||||
QString GerritPushDialog::selectedRemoteBranchName() const
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include <QDialog>
|
||||
#include <QMultiMap>
|
||||
#include <QDate>
|
||||
#include <QSharedPointer>
|
||||
|
||||
namespace Git {
|
||||
namespace Internal { class GitClient; }
|
||||
@@ -36,6 +37,8 @@ namespace Internal { class GitClient; }
|
||||
namespace Gerrit {
|
||||
namespace Internal {
|
||||
|
||||
class GerritParameters;
|
||||
|
||||
namespace Ui { class GerritPushDialog; }
|
||||
|
||||
class GerritPushDialog : public QDialog
|
||||
@@ -43,7 +46,8 @@ class GerritPushDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GerritPushDialog(const QString &workingDir, const QString &reviewerList, QWidget *parent);
|
||||
GerritPushDialog(const QString &workingDir, const QString &reviewerList,
|
||||
QSharedPointer<GerritParameters> parameters, QWidget *parent);
|
||||
~GerritPushDialog();
|
||||
|
||||
QString selectedCommit() const;
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<width>740</width>
|
||||
<height>410</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -170,7 +170,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="remoteComboBox"/>
|
||||
<widget class="Gerrit::Internal::GerritRemoteChooser" name="remoteComboBox" native="true"/>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="3">
|
||||
<widget class="QLabel" name="infoLabel">
|
||||
@@ -203,6 +203,12 @@ Partial names can be used if they are unambiguous.</string>
|
||||
<extends>QComboBox</extends>
|
||||
<header location="global">git/gerrit/branchcombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gerrit::Internal::GerritRemoteChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">git/gerrit/gerritremotechooser.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>localBranchComboBox</tabstop>
|
||||
|
@@ -35,8 +35,6 @@
|
||||
#include <QFileInfo>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
Q_DECLARE_METATYPE(Gerrit::Internal::GerritServer);
|
||||
|
||||
namespace Gerrit {
|
||||
namespace Internal {
|
||||
|
||||
@@ -53,6 +51,7 @@ GerritRemoteChooser::GerritRemoteChooser(QWidget *parent) :
|
||||
m_remoteComboBox->setMinimumSize(QSize(40, 0));
|
||||
|
||||
horizontalLayout->addWidget(m_remoteComboBox);
|
||||
horizontalLayout->setMargin(0);
|
||||
|
||||
m_resetRemoteButton = new QToolButton(this);
|
||||
m_resetRemoteButton->setToolTip(tr("Refresh Remote Servers"));
|
||||
@@ -76,10 +75,27 @@ void GerritRemoteChooser::setParameters(QSharedPointer<GerritParameters> paramet
|
||||
m_parameters = parameters;
|
||||
}
|
||||
|
||||
void GerritRemoteChooser::setFallbackEnabled(bool value)
|
||||
{
|
||||
m_enableFallback = value;
|
||||
}
|
||||
|
||||
bool GerritRemoteChooser::setCurrentRemote(const QString &remoteName)
|
||||
{
|
||||
for (int i = 0, total = m_remoteComboBox->count(); i < total; ++i) {
|
||||
if (m_remotes[i].first == remoteName) {
|
||||
m_remoteComboBox->setCurrentIndex(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GerritRemoteChooser::updateRemotes(bool forceReload)
|
||||
{
|
||||
QTC_ASSERT(!m_repository.isEmpty(), return false);
|
||||
QTC_ASSERT(!m_repository.isEmpty() || !m_parameters, return false);
|
||||
m_remoteComboBox->clear();
|
||||
m_remotes.clear();
|
||||
m_updatingRemotes = true;
|
||||
QString errorMessage; // Mute errors. We'll just fallback to the defaults
|
||||
QMap<QString, QString> remotesList =
|
||||
@@ -92,7 +108,9 @@ bool GerritRemoteChooser::updateRemotes(bool forceReload)
|
||||
continue;
|
||||
addRemote(server, mapIt.key());
|
||||
}
|
||||
if (m_enableFallback)
|
||||
addRemote(m_parameters->server, tr("Fallback"));
|
||||
m_remoteComboBox->setEnabled(m_remoteComboBox->count() > 1);
|
||||
m_updatingRemotes = false;
|
||||
handleRemoteChanged();
|
||||
return true;
|
||||
@@ -100,24 +118,38 @@ bool GerritRemoteChooser::updateRemotes(bool forceReload)
|
||||
|
||||
void GerritRemoteChooser::addRemote(const GerritServer &server, const QString &name)
|
||||
{
|
||||
for (int i = 0, total = m_remoteComboBox->count(); i < total; ++i) {
|
||||
const GerritServer s = m_remoteComboBox->itemData(i).value<GerritServer>();
|
||||
if (s == server)
|
||||
for (auto remote : m_remotes) {
|
||||
if (remote.second == server)
|
||||
return;
|
||||
}
|
||||
m_remoteComboBox->addItem(server.host + QString(" (%1)").arg(name), QVariant::fromValue(server));
|
||||
m_remoteComboBox->addItem(server.host + QString(" (%1)").arg(name));
|
||||
m_remotes.push_back({ name, server });
|
||||
if (name == "gerrit")
|
||||
m_remoteComboBox->setCurrentIndex(m_remoteComboBox->count() - 1);
|
||||
}
|
||||
|
||||
GerritServer GerritRemoteChooser::currentServer() const
|
||||
{
|
||||
return m_remoteComboBox->currentData().value<GerritServer>();
|
||||
const int index = m_remoteComboBox->currentIndex();
|
||||
QTC_ASSERT(index >= 0 && index < int(m_remotes.size()), return GerritServer());
|
||||
return m_remotes[index].second;
|
||||
}
|
||||
|
||||
QString GerritRemoteChooser::currentRemoteName() const
|
||||
{
|
||||
const int index = m_remoteComboBox->currentIndex();
|
||||
QTC_ASSERT(index >= 0 && index < int(m_remotes.size()), return QString());
|
||||
return m_remotes[index].first;
|
||||
}
|
||||
|
||||
bool GerritRemoteChooser::isEmpty() const
|
||||
{
|
||||
return m_remotes.empty();
|
||||
}
|
||||
|
||||
void GerritRemoteChooser::handleRemoteChanged()
|
||||
{
|
||||
if (m_updatingRemotes || m_remoteComboBox->count() == 0)
|
||||
if (m_updatingRemotes || m_remotes.empty())
|
||||
return;
|
||||
emit remoteChanged();
|
||||
}
|
||||
|
@@ -25,15 +25,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gerritserver.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QSharedPointer>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Gerrit {
|
||||
namespace Internal {
|
||||
|
||||
class GerritServer;
|
||||
class GerritParameters;
|
||||
|
||||
class GerritRemoteChooser : public QWidget
|
||||
@@ -44,9 +47,13 @@ public:
|
||||
GerritRemoteChooser(QWidget *parent = nullptr);
|
||||
void setRepository(const QString &repository);
|
||||
void setParameters(QSharedPointer<GerritParameters> parameters);
|
||||
void setFallbackEnabled(bool value);
|
||||
bool setCurrentRemote(const QString &remoteName);
|
||||
|
||||
bool updateRemotes(bool forceReload);
|
||||
GerritServer currentServer() const;
|
||||
QString currentRemoteName() const;
|
||||
bool isEmpty() const;
|
||||
|
||||
signals:
|
||||
void remoteChanged();
|
||||
@@ -60,6 +67,9 @@ private:
|
||||
QComboBox *m_remoteComboBox = nullptr;
|
||||
QToolButton *m_resetRemoteButton = nullptr;
|
||||
bool m_updatingRemotes = false;
|
||||
bool m_enableFallback = false;
|
||||
using NameAndServer = std::pair<QString, GerritServer>;
|
||||
std::vector<NameAndServer> m_remotes;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include "submitfilemodel.h"
|
||||
#include "ui_submiteditorwidget.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPointer>
|
||||
#include <QTextBlock>
|
||||
@@ -117,18 +119,6 @@ public slots:
|
||||
|
||||
// Helpers to retrieve model data
|
||||
// Convenience to extract a list of selected indexes
|
||||
QList<int> selectedRows(const QAbstractItemView *view)
|
||||
{
|
||||
const QModelIndexList indexList = view->selectionModel()->selectedRows(0);
|
||||
if (indexList.empty())
|
||||
return QList<int>();
|
||||
QList<int> rc;
|
||||
const QModelIndexList::const_iterator cend = indexList.constEnd();
|
||||
for (QModelIndexList::const_iterator it = indexList.constBegin(); it != cend; ++it)
|
||||
rc.push_back(it->row());
|
||||
return rc;
|
||||
}
|
||||
|
||||
// ----------- SubmitEditorWidgetPrivate
|
||||
|
||||
struct SubmitEditorWidgetPrivate
|
||||
@@ -463,7 +453,7 @@ Utils::CompletingTextEdit *SubmitEditorWidget::descriptionEdit() const
|
||||
|
||||
void SubmitEditorWidget::triggerDiffSelected()
|
||||
{
|
||||
const QList<int> sel = selectedRows(d->m_ui.fileView);
|
||||
const QList<int> sel = selectedRows();
|
||||
if (!sel.empty())
|
||||
emit diffSelected(sel);
|
||||
}
|
||||
@@ -610,6 +600,22 @@ bool SubmitEditorWidget::updateInProgress() const
|
||||
return d->m_updateInProgress;
|
||||
}
|
||||
|
||||
QList<int> SubmitEditorWidget::selectedRows() const
|
||||
{
|
||||
return Utils::transform(d->m_ui.fileView->selectionModel()->selectedRows(0), &QModelIndex::row);
|
||||
}
|
||||
|
||||
void SubmitEditorWidget::setSelectedRows(const QList<int> &rows)
|
||||
{
|
||||
if (const SubmitFileModel *model = fileModel()) {
|
||||
QItemSelectionModel *selectionModel = d->m_ui.fileView->selectionModel();
|
||||
for (int row : rows) {
|
||||
selectionModel->select(model->index(row, 0),
|
||||
QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString SubmitEditorWidget::commitName() const
|
||||
{
|
||||
return tr("&Commit");
|
||||
|
@@ -100,6 +100,9 @@ public:
|
||||
void setUpdateInProgress(bool value);
|
||||
bool updateInProgress() const;
|
||||
|
||||
QList<int> selectedRows() const;
|
||||
void setSelectedRows(const QList<int> &rows);
|
||||
|
||||
public slots:
|
||||
void updateSubmitAction();
|
||||
|
||||
|
@@ -411,10 +411,15 @@ void VcsBaseSubmitEditor::setFileModel(SubmitFileModel *model)
|
||||
{
|
||||
QTC_ASSERT(model, return);
|
||||
SubmitFileModel *oldModel = d->m_widget->fileModel();
|
||||
if (oldModel)
|
||||
QList<int> selected;
|
||||
if (oldModel) {
|
||||
model->updateSelections(oldModel);
|
||||
selected = d->m_widget->selectedRows();
|
||||
}
|
||||
d->m_widget->setFileModel(model);
|
||||
delete oldModel;
|
||||
if (!selected.isEmpty())
|
||||
d->m_widget->setSelectedRows(selected);
|
||||
|
||||
QSet<QString> uniqueSymbols;
|
||||
const CPlusPlus::Snapshot cppSnapShot = CppTools::CppModelManager::instance()->snapshot();
|
||||
|
Reference in New Issue
Block a user