Commit 7b3aa16d authored by Tobias Hunger's avatar Tobias Hunger

Git: Use Qt5-style connects

The heavy lifting was done by clazy.

Change-Id: I60dcd378419b92f96dc681921701c9231ef8ee57
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 8f8c1052
......@@ -67,23 +67,23 @@ BranchDialog::BranchDialog(QWidget *parent) :
m_ui->setupUi(this);
connect(m_ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(add()));
connect(m_ui->checkoutButton, SIGNAL(clicked()), this, SLOT(checkout()));
connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(remove()));
connect(m_ui->renameButton, SIGNAL(clicked()), this, SLOT(rename()));
connect(m_ui->diffButton, SIGNAL(clicked()), this, SLOT(diff()));
connect(m_ui->logButton, SIGNAL(clicked()), this, SLOT(log()));
connect(m_ui->resetButton, SIGNAL(clicked()), this, SLOT(reset()));
connect(m_ui->mergeButton, SIGNAL(clicked()), this, SLOT(merge()));
connect(m_ui->rebaseButton, SIGNAL(clicked()), this, SLOT(rebase()));
connect(m_ui->cherryPickButton, SIGNAL(clicked()), this, SLOT(cherryPick()));
connect(m_ui->trackButton, SIGNAL(clicked()), this, SLOT(setRemoteTracking()));
connect(m_ui->refreshButton, &QAbstractButton::clicked, this, &BranchDialog::refreshCurrentRepository);
connect(m_ui->addButton, &QAbstractButton::clicked, this, &BranchDialog::add);
connect(m_ui->checkoutButton, &QAbstractButton::clicked, this, &BranchDialog::checkout);
connect(m_ui->removeButton, &QAbstractButton::clicked, this, &BranchDialog::remove);
connect(m_ui->renameButton, &QAbstractButton::clicked, this, &BranchDialog::rename);
connect(m_ui->diffButton, &QAbstractButton::clicked, this, &BranchDialog::diff);
connect(m_ui->logButton, &QAbstractButton::clicked, this, &BranchDialog::log);
connect(m_ui->resetButton, &QAbstractButton::clicked, this, &BranchDialog::reset);
connect(m_ui->mergeButton, &QAbstractButton::clicked, this, &BranchDialog::merge);
connect(m_ui->rebaseButton, &QAbstractButton::clicked, this, &BranchDialog::rebase);
connect(m_ui->cherryPickButton, &QAbstractButton::clicked, this, &BranchDialog::cherryPick);
connect(m_ui->trackButton, &QAbstractButton::clicked, this, &BranchDialog::setRemoteTracking);
m_ui->branchView->setModel(m_model);
connect(m_ui->branchView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(enableButtons()));
connect(m_ui->branchView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &BranchDialog::enableButtons);
enableButtons();
}
......@@ -110,7 +110,7 @@ void BranchDialog::refresh(const QString &repository, bool force)
void BranchDialog::refreshIfSame(const QString &repository)
{
if (m_repository == repository)
refresh();
refreshCurrentRepository();
}
void BranchDialog::enableButtons()
......@@ -137,7 +137,7 @@ void BranchDialog::enableButtons()
m_ui->trackButton->setEnabled(hasActions && currentLocal && !currentSelected && !isTag);
}
void BranchDialog::refresh()
void BranchDialog::refreshCurrentRepository()
{
refresh(m_repository, true);
}
......@@ -306,7 +306,7 @@ void BranchDialog::rename()
m_model->renameTag(oldName, branchAddDialog.branchName());
else
m_model->renameBranch(oldName, branchAddDialog.branchName());
refresh();
refreshCurrentRepository();
}
enableButtons();
}
......
......@@ -62,9 +62,9 @@ public slots:
void refresh(const QString &repository, bool force);
void refreshIfSame(const QString &repository);
private slots:
private:
void enableButtons();
void refresh();
void refreshCurrentRepository();
void add();
void checkout();
void remove();
......@@ -77,7 +77,6 @@ private slots:
void cherryPick();
void setRemoteTracking();
private:
QModelIndex selectedIndex();
Ui::BranchDialog *m_ui;
......
......@@ -290,7 +290,7 @@ void ChangeSelectionDialog::changeTextChanged(const QString &text)
if (QCompleter *comp = m_ui->changeNumberEdit->completer()) {
if (text.isEmpty() && !comp->popup()->isVisible()) {
comp->setCompletionPrefix(text);
QTimer::singleShot(0, comp, SLOT(complete()));
QTimer::singleShot(0, comp, [comp]{ comp->complete(); });
}
}
recalculateDetails();
......
......@@ -346,9 +346,7 @@ public:
static QString msgNoCommits(bool includeRemote);
public slots:
void show(const QString &source,
const QString &id,
const QString &name = QString());
void show(const QString &source, const QString &id, const QString &name = QString());
private slots:
void finishSubmoduleUpdate();
......
......@@ -325,10 +325,15 @@ void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
{
m_currentChange = change;
if (contentType() != OtherContent) {
menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), this, SLOT(cherryPickChange()));
menu->addAction(tr("Re&vert Change %1").arg(change), this, SLOT(revertChange()));
menu->addAction(tr("C&heckout Change %1").arg(change), this, SLOT(checkoutChange()));
menu->addAction(tr("&Log for Change %1").arg(change), this, SLOT(logChange()));
connect(menu->addAction(tr("Cherr&y-Pick Change %1").arg(change)), &QAction::triggered,
this, &GitEditorWidget::cherryPickChange);
connect(menu->addAction(tr("Re&vert Change %1").arg(change)), &QAction::triggered,
this, &GitEditorWidget::revertChange);
connect(menu->addAction(tr("C&heckout Change %1").arg(change)), &QAction::triggered,
this, &GitEditorWidget::checkoutChange);
connect(menu->addAction(tr("&Log for Change %1").arg(change)), &QAction::triggered,
this, &GitEditorWidget::logChange);
QMenu *resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
connect(resetMenu->addAction(tr("&Hard")), &QAction::triggered,
this, [this]() { resetChange("hard"); });
......
......@@ -206,7 +206,7 @@ ParameterAction *GitPlugin::createParameterAction(ActionContainer *ac,
return action;
}
// Create an action to act on a file with a slot.
// Create an action to act on a file.
QAction *GitPlugin::createFileAction(ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
Id id, const Context &context, bool addToLocator,
......@@ -241,7 +241,7 @@ QAction *GitPlugin::createProjectAction(ActionContainer *ac, const QString &defa
return action;
}
// Create an action to act on the repository with slot
// Create an action to act on the repository
QAction *GitPlugin::createRepositoryAction(ActionContainer *ac, const QString &text, Id id,
const Context &context, bool addToLocator,
const std::function<void()> &callback,
......@@ -270,7 +270,7 @@ QAction *GitPlugin::createRepositoryAction(ActionContainer *ac, const QString &t
QTC_ASSERT(currentState().hasTopLevel(), return);
(m_gitClient->*func)(currentState().topLevel());
};
// Set the member func as data and connect to generic slot
// Set the member func as data and connect to GitClient method
return createRepositoryAction(ac, text, id, context, addToLocator, cb, keys);
}
......@@ -959,9 +959,10 @@ IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &
IDocument *document = submitEditor->document();
document->setPreferredDisplayName(title);
VcsBasePlugin::setSource(document, m_submitRepository);
connect(submitEditor, SIGNAL(diff(QStringList,QStringList)), this, SLOT(submitEditorDiff(QStringList,QStringList)));
connect(submitEditor, SIGNAL(merge(QStringList)), this, SLOT(submitEditorMerge(QStringList)));
connect(submitEditor, SIGNAL(show(QString,QString)), m_gitClient, SLOT(show(QString,QString)));
connect(submitEditor, &GitSubmitEditor::diff, this, &GitPlugin::submitEditorDiff);
connect(submitEditor, &GitSubmitEditor::merge, this, &GitPlugin::submitEditorMerge);
connect(submitEditor, &GitSubmitEditor::show,
m_gitClient, [this](const QString &wd, const QString &c) { m_gitClient->show(wd, c); });
return editor;
}
......@@ -1036,7 +1037,7 @@ bool GitPlugin::submitEditorAboutToClose()
if (editor->panelData().pushAction == NormalPush)
m_gitClient->push(m_submitRepository);
else if (editor->panelData().pushAction == PushToGerrit)
connect(editor, SIGNAL(destroyed()), this, SLOT(delayedPushToGerrit()));
connect(editor, &QObject::destroyed, this, &GitPlugin::delayedPushToGerrit);
}
return true;
......
......@@ -96,7 +96,20 @@ public slots:
void startCommit();
void updateBranches(const QString &repository);
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState) override;
bool submitEditorAboutToClose() override;
#ifdef WITH_TESTS
private slots:
void testStatusParsing_data();
void testStatusParsing();
void testDiffFileResolving_data();
void testDiffFileResolving();
void testLogResolving();
#endif
private:
void diffCurrentFile();
void diffCurrentProject();
void submitEditorDiff(const QStringList &unstaged, const QStringList &staged);
......@@ -138,21 +151,10 @@ private slots:
void updateContinueAndAbortCommands();
void delayedPushToGerrit();
#ifdef WITH_TESTS
void testStatusParsing_data();
void testStatusParsing();
void testDiffFileResolving_data();
void testDiffFileResolving();
void testLogResolving();
#endif
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState) override;
bool submitEditorAboutToClose() override;
private:
Core::Command *createCommand(QAction *action, Core::ActionContainer *ac, Core::Id id,
const Core::Context &context, bool addToLocator,
const std::function<void()> &callback, const QKeySequence &keys);
Utils::ParameterAction *createParameterAction(Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
Core::Id id, const Core::Context &context, bool addToLocator,
......
......@@ -132,9 +132,8 @@ GitSubmitEditor::GitSubmitEditor(const VcsBaseSubmitEditorParameters *parameters
m_firstUpdate(true),
m_commitDataFetcher(0)
{
connect(this, &VcsBaseSubmitEditor::diffSelectedRows,
this, &GitSubmitEditor::slotDiffSelected);
connect(submitEditorWidget(), SIGNAL(show(QString)), this, SLOT(showCommit(QString)));
connect(this, &VcsBaseSubmitEditor::diffSelectedRows, this, &GitSubmitEditor::slotDiffSelected);
connect(submitEditorWidget(), &GitSubmitEditorWidget::show, this, &GitSubmitEditor::showCommit);
}
GitSubmitEditor::~GitSubmitEditor()
......@@ -156,8 +155,8 @@ void GitSubmitEditor::resetCommitDataFetcher()
{
if (!m_commitDataFetcher)
return;
disconnect(m_commitDataFetcher, SIGNAL(finished(bool)), this, SLOT(commitDataRetrieved(bool)));
connect(m_commitDataFetcher, SIGNAL(finished(bool)), m_commitDataFetcher, SLOT(deleteLater()));
disconnect(m_commitDataFetcher, &CommitDataFetcher::finished, this, &GitSubmitEditor::commitDataRetrieved);
connect(m_commitDataFetcher, &CommitDataFetcher::finished, m_commitDataFetcher, &QObject::deleteLater);
}
void GitSubmitEditor::setCommitData(const CommitData &d)
......@@ -264,7 +263,7 @@ void GitSubmitEditor::updateFileModel()
w->setUpdateInProgress(true);
resetCommitDataFetcher();
m_commitDataFetcher = new CommitDataFetcher(m_commitType, m_workingDirectory);
connect(m_commitDataFetcher, SIGNAL(finished(bool)), this, SLOT(commitDataRetrieved(bool)));
connect(m_commitDataFetcher, &CommitDataFetcher::finished, this, &GitSubmitEditor::commitDataRetrieved);
QFuture<void> future = QtConcurrent::run(m_commitDataFetcher, &CommitDataFetcher::start);
Core::ProgressManager::addTask(future, tr("Refreshing Commit Data"), TASK_UPDATE_COMMIT);
......
......@@ -68,12 +68,11 @@ protected:
QByteArray fileContents() const override;
void updateFileModel() override;
private slots:
private:
void slotDiffSelected(const QList<int> &rows);
void showCommit(const QString &commit);
void commitDataRetrieved(bool success);
private:
inline GitSubmitEditorWidget *submitEditorWidget();
inline const GitSubmitEditorWidget *submitEditorWidget() const;
void resetCommitDataFetcher();
......
......@@ -108,8 +108,7 @@ void GitSubmitEditorWidget::initialize(CommitType commitType,
logChangeGroupBox->setLayout(logChangeLayout);
m_logChangeWidget = new LogChangeWidget;
m_logChangeWidget->init(repository);
connect(m_logChangeWidget, &LogChangeWidget::activated,
this, &GitSubmitEditorWidget::show);
connect(m_logChangeWidget, &LogChangeWidget::commitActivated, this, &GitSubmitEditorWidget::show);
logChangeLayout->addWidget(m_logChangeWidget);
insertLeftWidget(logChangeGroupBox);
m_gitSubmitPanelUi.editGroup->hide();
......@@ -121,9 +120,12 @@ void GitSubmitEditorWidget::initialize(CommitType commitType,
if (enablePush) {
auto menu = new QMenu(this);
menu->addAction(tr("&Commit only"), this, SLOT(commitOnlySlot()));
menu->addAction(tr("Commit and &Push"), this, SLOT(commitAndPushSlot()));
menu->addAction(tr("Commit and Push to &Gerrit"), this, SLOT(commitAndPushToGerritSlot()));
connect(menu->addAction(tr("&Commit only")), &QAction::triggered,
this, &GitSubmitEditorWidget::commitOnlySlot);
connect(menu->addAction(tr("Commit and &Push")), &QAction::triggered,
this, &GitSubmitEditorWidget::commitAndPushSlot);
connect(menu->addAction(tr("Commit and Push to &Gerrit")), &QAction::triggered,
this, &GitSubmitEditorWidget::commitAndPushToGerritSlot);
addSubmitButtonMenu(menu);
}
}
......
......@@ -85,13 +85,12 @@ protected:
signals:
void show(const QString &commit);
private slots:
private:
void authorInformationChanged();
void commitOnlySlot();
void commitAndPushSlot();
void commitAndPushToGerritSlot();
private:
bool emailIsValid() const;
void setPanelData(const GitSubmitEditorPanelData &data);
void setPanelInfo(const GitSubmitEditorPanelInfo &info);
......
......@@ -73,7 +73,7 @@ LogChangeWidget::LogChangeWidget(QWidget *parent)
setRootIsDecorated(false);
setSelectionBehavior(QAbstractItemView::SelectRows);
setActivationMode(Utils::DoubleClickActivation);
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(emitActivated(QModelIndex)));
connect(this, &LogChangeWidget::activated, this, &LogChangeWidget::emitCommitActivated);
}
bool LogChangeWidget::init(const QString &repository, const QString &commit, LogFlags flags)
......@@ -120,12 +120,12 @@ void LogChangeWidget::setItemDelegate(QAbstractItemDelegate *delegate)
m_hasCustomDelegate = true;
}
void LogChangeWidget::emitActivated(const QModelIndex &index)
void LogChangeWidget::emitCommitActivated(const QModelIndex &index)
{
if (index.isValid()) {
QString commit = index.sibling(index.row(), Sha1Column).data().toString();
if (!commit.isEmpty())
emit activated(commit);
emit commitActivated(commit);
}
}
......@@ -228,10 +228,10 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) :
QPushButton *okButton = m_dialogButtonBox->addButton(QDialogButtonBox::Ok);
layout->addLayout(popUpLayout);
connect(m_dialogButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_dialogButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(m_dialogButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(m_dialogButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(m_widget, SIGNAL(activated(QModelIndex)), okButton, SLOT(animateClick()));
connect(m_widget, &LogChangeWidget::activated, okButton, [okButton] { okButton->animateClick(); });
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
resize(600, 400);
......
......@@ -72,12 +72,11 @@ public:
void setItemDelegate(QAbstractItemDelegate *delegate);
signals:
void activated(const QString &commit);
private slots:
void emitActivated(const QModelIndex &index);
void commitActivated(const QString &commit);
private:
void emitCommitActivated(const QModelIndex &index);
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
bool populateLog(const QString &repository, const QString &commit, LogFlags flags);
const QStandardItem *currentItem(int column = 0) const;
......
......@@ -106,8 +106,8 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
VcsOutputWindow::appendCommand(workingDirectory, binary, arguments);
m_process->start(binary.toString(), arguments);
if (m_process->waitForStarted()) {
connect(m_process, SIGNAL(finished(int)), this, SLOT(done()));
connect(m_process, SIGNAL(readyRead()), this, SLOT(readData()));
connect(m_process, static_cast<void (QProcess::*)(int)>(&QProcess::finished), this, &MergeTool::done);
connect(m_process, &QIODevice::readyRead, this, &MergeTool::readData);
} else {
delete m_process;
m_process = 0;
......
......@@ -69,11 +69,10 @@ public:
SymbolicLinkMerge
};
private slots:
private:
void readData();
void done();
private:
FileState waitAndReadStatus(QString &extraInfo);
QString mergeTypeName();
QString stateName(FileState state, const QString &extraInfo);
......
......@@ -98,19 +98,14 @@ RemoteDialog::RemoteDialog(QWidget *parent) :
m_ui->remoteView->setModel(m_remoteModel);
new Utils::HeaderViewStretcher(m_ui->remoteView->header(), 1);
connect(m_ui->addButton, &QPushButton::clicked,
this, &RemoteDialog::addRemote);
connect(m_ui->fetchButton, &QPushButton::clicked,
this, &RemoteDialog::fetchFromRemote);
connect(m_ui->pushButton, &QPushButton::clicked,
this, &RemoteDialog::pushToRemote);
connect(m_ui->removeButton, &QPushButton::clicked,
this, &RemoteDialog::removeRemote);
connect(m_ui->refreshButton, &QPushButton::clicked,
this, &RemoteDialog::refreshRemotes);
connect(m_ui->remoteView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(updateButtonState()));
connect(m_ui->addButton, &QPushButton::clicked, this, &RemoteDialog::addRemote);
connect(m_ui->fetchButton, &QPushButton::clicked, this, &RemoteDialog::fetchFromRemote);
connect(m_ui->pushButton, &QPushButton::clicked, this, &RemoteDialog::pushToRemote);
connect(m_ui->removeButton, &QPushButton::clicked, this, &RemoteDialog::removeRemote);
connect(m_ui->refreshButton, &QPushButton::clicked, this, &RemoteDialog::refreshRemotes);
connect(m_ui->remoteView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &RemoteDialog::updateButtonState);
updateButtonState();
}
......
......@@ -80,6 +80,7 @@ public:
public slots:
void refresh(const QString &repository, bool force);
private:
void refreshRemotes();
void addRemote();
void removeRemote();
......@@ -88,7 +89,6 @@ public slots:
void updateButtonState();
private:
Ui::RemoteDialog *m_ui;
RemoteModel *m_remoteModel;
......
......@@ -148,10 +148,10 @@ StashDialog::StashDialog(QWidget *parent) :
ui->stashView->setUniformRowHeights(true);
connect(ui->filterLineEdit, &Utils::FancyLineEdit::filterChanged,
m_proxyModel, &QSortFilterProxyModel::setFilterFixedString);
connect(ui->stashView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
this, SLOT(enableButtons()));
connect(ui->stashView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(enableButtons()));
connect(ui->stashView->selectionModel(), &QItemSelectionModel::currentRowChanged,
this, &StashDialog::enableButtons);
connect(ui->stashView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &StashDialog::enableButtons);
connect(ui->stashView, &Utils::TreeView::activated,
this, &StashDialog::showCurrent);
ui->stashView->setFocus();
......
......@@ -63,15 +63,6 @@ public:
public slots:
void refresh(const QString &repository, bool force);
private slots:
void deleteAll();
void deleteSelection();
void showCurrent();
void restoreCurrent();
void restoreCurrentInBranch();
void enableButtons();
void forceRefresh();
private:
// Prompt dialog for modified repositories. Ask to undo or stash away.
enum ModifiedRepositoryAction {
......@@ -80,6 +71,14 @@ private:
ModifiedRepositoryDiscard
};
void deleteAll();
void deleteSelection();
void showCurrent();
void restoreCurrent();
void restoreCurrentInBranch();
void enableButtons();
void forceRefresh();
ModifiedRepositoryAction promptModifiedRepository(const QString &stash);
bool promptForRestore(QString *stash, QString *branch /* = 0 */, QString *errorMessage);
bool ask(const QString &title, const QString &what, bool defaultButton = true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment