diff options
author | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2016-02-10 11:19:27 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2016-02-10 15:01:57 +0000 |
commit | b4195d51746d86f4aa459d07d14a328c7945981a (patch) | |
tree | ca13ba842a38e2514a923eb6a9ecadd439159110 | |
parent | 7db0023e8c97336e0e449552410de674bbe2ffd0 (diff) | |
download | qt-creator-b4195d51746d86f4aa459d07d14a328c7945981a.tar.gz |
Git: Modernize
* pragma once
* member initialization
* s/struct/class/
* Introduce a static GitPlugin::client() method and use it
Change-Id: Ifdcac86dd16f3cdba11d564d03e9a15f00a6afdb
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
47 files changed, 230 insertions, 420 deletions
diff --git a/src/plugins/git/annotationhighlighter.h b/src/plugins/git/annotationhighlighter.h index d1780cfad2..b137945984 100644 --- a/src/plugins/git/annotationhighlighter.h +++ b/src/plugins/git/annotationhighlighter.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef ANNOTATIONHIGHLIGHTER_H -#define ANNOTATIONHIGHLIGHTER_H +#pragma once #include <vcsbase/baseannotationhighlighter.h> @@ -47,5 +46,3 @@ private: } // namespace Internal } // namespace Git - -#endif // ANNOTATIONHIGHLIGHTER_H diff --git a/src/plugins/git/branchadddialog.h b/src/plugins/git/branchadddialog.h index e483f9fc98..fa417b936a 100644 --- a/src/plugins/git/branchadddialog.h +++ b/src/plugins/git/branchadddialog.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef BRANCHADDDIALOG_H -#define BRANCHADDDIALOG_H +#pragma once #include <QDialog> @@ -40,7 +39,7 @@ class BranchAddDialog : public QDialog public: BranchAddDialog(const QStringList &localBranches, bool addBranch, QWidget *parent); - ~BranchAddDialog(); + ~BranchAddDialog() override; void setBranchName(const QString &); QString branchName() const; @@ -57,5 +56,3 @@ private: } // namespace Internal } // namespace Git - -#endif // BRANCHADDDIALOG_H diff --git a/src/plugins/git/branchcheckoutdialog.h b/src/plugins/git/branchcheckoutdialog.h index d139376bab..755a132e84 100644 --- a/src/plugins/git/branchcheckoutdialog.h +++ b/src/plugins/git/branchcheckoutdialog.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef BRANCHCHECKOUTDIALOG_H -#define BRANCHCHECKOUTDIALOG_H +#pragma once #include <QDialog> @@ -40,7 +39,7 @@ class BranchCheckoutDialog : public QDialog public: explicit BranchCheckoutDialog(QWidget *parent, const QString ¤tBranch, const QString &nextBranch); - ~BranchCheckoutDialog(); + ~BranchCheckoutDialog() override; void foundNoLocalChanges(); void foundStashForNextBranch(); @@ -63,5 +62,3 @@ private: } // namespace Internal } // namespace Git - -#endif // BRANCHCHECKOUTDIALOG_H diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp index 89e41d850d..81802e238f 100644 --- a/src/plugins/git/branchdialog.cpp +++ b/src/plugins/git/branchdialog.cpp @@ -54,7 +54,7 @@ namespace Internal { BranchDialog::BranchDialog(QWidget *parent) : QDialog(parent), m_ui(new Ui::BranchDialog), - m_model(new BranchModel(GitPlugin::instance()->client(), this)) + m_model(new BranchModel(GitPlugin::client(), this)) { setModal(false); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -192,13 +192,13 @@ void BranchDialog::checkout() QLatin1Char(' ') + nextBranch + QLatin1String("-AutoStash "); BranchCheckoutDialog branchCheckoutDialog(this, currentBranch, nextBranch); - GitClient *gitClient = GitPlugin::instance()->client(); + GitClient *client = GitPlugin::client(); - if (gitClient->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules)) != GitClient::StatusChanged) + if (client->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules)) != GitClient::StatusChanged) branchCheckoutDialog.foundNoLocalChanges(); QList<Stash> stashes; - gitClient->synchronousStashList(m_repository, &stashes); + client->synchronousStashList(m_repository, &stashes); foreach (const Stash &stash, stashes) { if (stash.message.startsWith(popMessageStart)) { branchCheckoutDialog.foundStashForNextBranch(); @@ -213,22 +213,22 @@ void BranchDialog::checkout() } else if (branchCheckoutDialog.exec() == QDialog::Accepted) { if (branchCheckoutDialog.makeStashOfCurrentBranch()) { - if (gitClient->synchronousStash(m_repository, + if (client->synchronousStash(m_repository, currentBranch + QLatin1String("-AutoStash")).isEmpty()) { return; } } else if (branchCheckoutDialog.moveLocalChangesToNextBranch()) { - if (!gitClient->beginStashScope(m_repository, QLatin1String("Checkout"), NoPrompt)) + if (!client->beginStashScope(m_repository, QLatin1String("Checkout"), NoPrompt)) return; } else if (branchCheckoutDialog.discardLocalChanges()) { - if (!gitClient->synchronousReset(m_repository)) + if (!client->synchronousReset(m_repository)) return; } m_model->checkoutBranch(idx); QString stashName; - gitClient->synchronousStashList(m_repository, &stashes); + client->synchronousStashList(m_repository, &stashes); foreach (const Stash &stash, stashes) { if (stash.message.startsWith(popMessageStart)) { stashName = stash.name; @@ -237,9 +237,9 @@ void BranchDialog::checkout() } if (branchCheckoutDialog.moveLocalChangesToNextBranch()) - gitClient->endStashScope(m_repository); + client->endStashScope(m_repository); else if (branchCheckoutDialog.popStashOfNextBranch()) - gitClient->synchronousStashRestore(m_repository, stashName, true); + client->synchronousStashRestore(m_repository, stashName, true); } enableButtons(); } @@ -311,7 +311,7 @@ void BranchDialog::diff() QString fullName = m_model->fullName(selectedIndex(), true); if (fullName.isEmpty()) return; - GitPlugin::instance()->client()->diffBranch(m_repository, fullName); + GitPlugin::client()->diffBranch(m_repository, fullName); } void BranchDialog::log() @@ -319,7 +319,7 @@ void BranchDialog::log() QString branchName = m_model->fullName(selectedIndex(), true); if (branchName.isEmpty()) return; - GitPlugin::instance()->client()->log(m_repository, QString(), false, QStringList(branchName)); + GitPlugin::client()->log(m_repository, QString(), false, QStringList(branchName)); } void BranchDialog::reset() @@ -332,7 +332,7 @@ void BranchDialog::reset() if (QMessageBox::question(this, tr("Git Reset"), tr("Hard reset branch \"%1\" to \"%2\"?") .arg(currentName).arg(branchName), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { - GitPlugin::instance()->client()->reset(m_repository, QLatin1String("--hard"), branchName); + GitPlugin::client()->reset(m_repository, QLatin1String("--hard"), branchName); } } @@ -344,7 +344,7 @@ void BranchDialog::merge() QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled! const QString branch = m_model->fullName(idx, true); - GitClient *client = GitPlugin::instance()->client(); + GitClient *client = GitPlugin::client(); bool allowFastForward = true; if (client->isFastForwardMerge(m_repository, branch)) { QMenu popup; @@ -367,7 +367,7 @@ void BranchDialog::rebase() QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled! const QString baseBranch = m_model->fullName(idx, true); - GitClient *client = GitPlugin::instance()->client(); + GitClient *client = GitPlugin::client(); if (client->beginStashScope(m_repository, QLatin1String("rebase"))) client->rebase(m_repository, baseBranch); } @@ -380,7 +380,7 @@ void BranchDialog::cherryPick() QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled! const QString branch = m_model->fullName(idx, true); - GitPlugin::instance()->client()->synchronousCherryPick(m_repository, branch); + GitPlugin::client()->synchronousCherryPick(m_repository, branch); } void BranchDialog::setRemoteTracking() diff --git a/src/plugins/git/branchdialog.h b/src/plugins/git/branchdialog.h index 459eb8225e..0bb45a221a 100644 --- a/src/plugins/git/branchdialog.h +++ b/src/plugins/git/branchdialog.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef BRANCHDIALOG_H -#define BRANCHDIALOG_H +#pragma once #include <QDialog> @@ -51,7 +50,7 @@ class BranchDialog : public QDialog public: explicit BranchDialog(QWidget *parent = 0); - ~BranchDialog(); + ~BranchDialog() override; public slots: void refresh(const QString &repository, bool force); @@ -81,5 +80,3 @@ private: } // namespace Internal } // namespace Git - -#endif // BRANCHDIALOG_H diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp index 4e44ae1870..86895f3897 100644 --- a/src/plugins/git/branchmodel.cpp +++ b/src/plugins/git/branchmodel.cpp @@ -193,8 +193,7 @@ public: BranchModel::BranchModel(GitClient *client, QObject *parent) : QAbstractItemModel(parent), m_client(client), - m_rootNode(new BranchNode), - m_currentBranch(0) + m_rootNode(new BranchNode) { QTC_CHECK(m_client); diff --git a/src/plugins/git/branchmodel.h b/src/plugins/git/branchmodel.h index ecfc394a1a..e7e2686f6d 100644 --- a/src/plugins/git/branchmodel.h +++ b/src/plugins/git/branchmodel.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef BRANCHMODEL_H -#define BRANCHMODEL_H +#pragma once #include <QAbstractListModel> #include <QVariant> @@ -44,8 +43,8 @@ class BranchModel : public QAbstractItemModel { Q_OBJECT public: - explicit BranchModel(GitClient *client, QObject *parent = 0); - ~BranchModel(); + explicit BranchModel(GitClient *client, QObject *parent = nullptr); + ~BranchModel() override; // QAbstractItemModel QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; @@ -93,11 +92,9 @@ private: GitClient *m_client; QString m_workingDirectory; BranchNode *m_rootNode; - BranchNode *m_currentBranch; + BranchNode *m_currentBranch = nullptr; QString m_currentSha; }; } // namespace Internal } // namespace Git - -#endif // BRANCHMODEL_H diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp index 84b33798fb..563cea0238 100644 --- a/src/plugins/git/changeselectiondialog.cpp +++ b/src/plugins/git/changeselectiondialog.cpp @@ -52,19 +52,17 @@ using namespace Utils; namespace Git { namespace Internal { -ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, Core::Id id, QWidget *parent) - : QDialog(parent) - , m_ui(new Ui::ChangeSelectionDialog) - , m_process(0) - , m_command(NoCommand) +ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, Core::Id id, + QWidget *parent) : + QDialog(parent), m_ui(new Ui::ChangeSelectionDialog) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - m_gitExecutable = GitPlugin::instance()->client()->vcsBinary(); + m_gitExecutable = GitPlugin::client()->vcsBinary(); m_ui->setupUi(this); m_ui->workingDirectoryChooser->setExpectedKind(PathChooser::ExistingDirectory); m_ui->workingDirectoryChooser->setPromptDialogTitle(tr("Select Git Directory")); m_ui->workingDirectoryChooser->setPath(workingDirectory); - m_gitEnvironment = GitPlugin::instance()->client()->processEnvironment(); + m_gitEnvironment = GitPlugin::client()->processEnvironment(); m_ui->changeNumberEdit->setFocus(); m_ui->changeNumberEdit->selectAll(); @@ -216,7 +214,7 @@ void ChangeSelectionDialog::recalculateCompletion() m_oldWorkingDir = workingDir; if (!workingDir.isEmpty()) { - GitClient *client = GitPlugin::instance()->client(); + GitClient *client = GitPlugin::client(); QStringList args; args << QLatin1String("--format=%(refname:short)"); QString output; diff --git a/src/plugins/git/changeselectiondialog.h b/src/plugins/git/changeselectiondialog.h index d04c88b387..5fad19b836 100644 --- a/src/plugins/git/changeselectiondialog.h +++ b/src/plugins/git/changeselectiondialog.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef CHANGESELECTIONDIALOG_H -#define CHANGESELECTIONDIALOG_H +#pragma once #include <coreplugin/id.h> @@ -60,7 +59,7 @@ class ChangeSelectionDialog : public QDialog Q_OBJECT public: ChangeSelectionDialog(const QString &workingDirectory, Core::Id id, QWidget *parent); - ~ChangeSelectionDialog(); + ~ChangeSelectionDialog() override; QString change() const; @@ -83,15 +82,13 @@ private: Ui::ChangeSelectionDialog *m_ui; - QProcess *m_process; + QProcess *m_process = nullptr; Utils::FileName m_gitExecutable; QProcessEnvironment m_gitEnvironment; - ChangeCommand m_command; - QStringListModel *m_changeModel; + ChangeCommand m_command = NoCommand; + QStringListModel *m_changeModel = nullptr; QString m_oldWorkingDir; }; } // namespace Internal } // namespace Git - -#endif // CHANGESELECTIONDIALOG_H diff --git a/src/plugins/git/commitdata.cpp b/src/plugins/git/commitdata.cpp index 463b98bdd1..8cb0cbee68 100644 --- a/src/plugins/git/commitdata.cpp +++ b/src/plugins/git/commitdata.cpp @@ -28,7 +28,6 @@ #include <utils/qtcassert.h> #include <QCoreApplication> -#include <QDebug> namespace Git { namespace Internal { @@ -39,12 +38,6 @@ void GitSubmitEditorPanelInfo::clear() branch.clear(); } -QDebug operator<<(QDebug d, const GitSubmitEditorPanelInfo &data) -{ - d.nospace() << "Rep: " << data.repository << " branch: " << data.branch; - return d; -} - void GitSubmitEditorPanelData::clear() { author.clear(); @@ -67,14 +60,6 @@ QString GitSubmitEditorPanelData::authorString() const return rc; } -QDebug operator<<(QDebug d, const GitSubmitEditorPanelData &data) -{ - d.nospace() << " author:" << data.author << " email: " << data.email - << " bypass hooks: " << data.bypassHooks - << " action after commit " << data.pushAction; - return d; -} - CommitData::CommitData(CommitType type) : commitType(type) , commitEncoding(0) diff --git a/src/plugins/git/commitdata.h b/src/plugins/git/commitdata.h index ba27d433a8..e9ad1abdc6 100644 --- a/src/plugins/git/commitdata.h +++ b/src/plugins/git/commitdata.h @@ -23,39 +23,34 @@ ** ****************************************************************************/ -#ifndef COMMITDATA_H -#define COMMITDATA_H +#pragma once #include "gitsettings.h" // CommitType #include <QStringList> #include <QPair> -QT_BEGIN_NAMESPACE -class QDebug; -QT_END_NAMESPACE - namespace Git { namespace Internal { // Read-only -struct GitSubmitEditorPanelInfo +class GitSubmitEditorPanelInfo { +public: void clear(); QString repository; QString branch; }; -QDebug operator<<(QDebug d, const GitSubmitEditorPanelInfo &); - enum PushAction { NoPush, NormalPush, PushToGerrit }; -struct GitSubmitEditorPanelData +class GitSubmitEditorPanelData { +public: void clear(); // Format as "John Doe <jdoe@foobar.com>" QString authorString() const; @@ -66,8 +61,6 @@ struct GitSubmitEditorPanelData PushAction pushAction; }; -QDebug operator<<(QDebug d, const GitSubmitEditorPanelData &); - enum FileState { EmptyFileState = 0x00, @@ -132,5 +125,3 @@ bool operator<(const CommitData::StateFilePair &a, } // namespace Internal } // namespace Git - -#endif // COMMITDATA_H diff --git a/src/plugins/git/gerrit/branchcombobox.cpp b/src/plugins/git/gerrit/branchcombobox.cpp index 23c336df2b..6e270961b7 100644 --- a/src/plugins/git/gerrit/branchcombobox.cpp +++ b/src/plugins/git/gerrit/branchcombobox.cpp @@ -30,17 +30,13 @@ using namespace Git::Internal; using namespace Gerrit::Internal; -BranchComboBox::BranchComboBox(QWidget *parent) : - QComboBox(parent), - m_detached(false) -{ - m_client = GitPlugin::instance()->client(); -} +BranchComboBox::BranchComboBox(QWidget *parent) : QComboBox(parent) +{ } void BranchComboBox::init(const QString &repository) { m_repository = repository; - QString currentBranch = m_client->synchronousCurrentLocalBranch(repository); + QString currentBranch = GitPlugin::client()->synchronousCurrentLocalBranch(repository); if (currentBranch.isEmpty()) { m_detached = true; currentBranch = QLatin1String("HEAD"); @@ -50,7 +46,7 @@ void BranchComboBox::init(const QString &repository) const QString branchPrefix(QLatin1String("refs/heads/")); QStringList args; args << QLatin1String("--format=%(refname)") << branchPrefix; - if (!m_client->synchronousForEachRefCmd(m_repository, args, &output)) + if (!GitPlugin::client()->synchronousForEachRefCmd(m_repository, args, &output)) return; QStringList branches = output.trimmed().split(QLatin1Char('\n')); foreach (const QString &ref, branches) { diff --git a/src/plugins/git/gerrit/branchcombobox.h b/src/plugins/git/gerrit/branchcombobox.h index 11693faaff..fe34abc61c 100644 --- a/src/plugins/git/gerrit/branchcombobox.h +++ b/src/plugins/git/gerrit/branchcombobox.h @@ -38,13 +38,12 @@ namespace Internal { class BranchComboBox : public QComboBox { public: - BranchComboBox(QWidget *parent = 0); + explicit BranchComboBox(QWidget *parent = nullptr); void init(const QString &repository); private: - Git::Internal::GitClient *m_client; QString m_repository; - bool m_detached; + bool m_detached = false; }; } // namespace Internal diff --git a/src/plugins/git/gerrit/gerritmodel.cpp b/src/plugins/git/gerrit/gerritmodel.cpp index 57ba40648d..f4dea2796a 100644 --- a/src/plugins/git/gerrit/gerritmodel.cpp +++ b/src/plugins/git/gerrit/gerritmodel.cpp @@ -272,8 +272,7 @@ QueryContext::QueryContext(const QStringList &queries, this, &QueryContext::processError); connect(&m_watcher, &QFutureWatcherBase::canceled, this, &QueryContext::terminate); m_watcher.setFuture(m_progress.future()); - m_process.setProcessEnvironment(Git::Internal::GitPlugin::instance()-> - client()->processEnvironment()); + m_process.setProcessEnvironment(Git::Internal::GitPlugin::client()->processEnvironment()); m_progress.setProgressRange(0, m_queries.size()); // Determine binary and common command line arguments. diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index 37f5fe9ed6..c273562a38 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -84,11 +84,6 @@ enum FetchMode FetchCheckout }; -static inline GitClient *gitClient() -{ - return GitPlugin::instance()->client(); -} - /* FetchContext: Retrieves the patch and displays * or applies it as desired. Does deleteLater() once it is done. */ @@ -158,7 +153,7 @@ FetchContext::FetchContext(const QSharedPointer<GerritChange> &change, connect(&m_watcher, &QFutureWatcher<void>::canceled, this, &FetchContext::terminate); m_watcher.setFuture(m_progress.future()); m_process.setWorkingDirectory(repository); - m_process.setProcessEnvironment(gitClient()->processEnvironment()); + m_process.setProcessEnvironment(GitPlugin::client()->processEnvironment()); m_process.closeWriteChannel(); } @@ -250,7 +245,7 @@ void FetchContext::show() { const QString title = QString::number(m_change->number) + QLatin1Char('/') + QString::number(m_change->currentPatchSet.patchSetNumber); - gitClient()->show(m_repository, QLatin1String("FETCH_HEAD"), title); + GitPlugin::client()->show(m_repository, QLatin1String("FETCH_HEAD"), title); } void FetchContext::cherryPick() @@ -258,12 +253,12 @@ void FetchContext::cherryPick() // Point user to errors. VcsBase::VcsOutputWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus); - gitClient()->synchronousCherryPick(m_repository, QLatin1String("FETCH_HEAD")); + GitPlugin::client()->synchronousCherryPick(m_repository, QLatin1String("FETCH_HEAD")); } void FetchContext::checkout() { - gitClient()->stashAndCheckout(m_repository, QLatin1String("FETCH_HEAD")); + GitPlugin::client()->stashAndCheckout(m_repository, QLatin1String("FETCH_HEAD")); } void FetchContext::terminate() @@ -355,7 +350,7 @@ void GerritPlugin::push(const QString &topLevel) args << target; - gitClient()->push(topLevel, args); + GitPlugin::client()->push(topLevel, args); } // Open or raise the Gerrit dialog window. @@ -393,13 +388,13 @@ void GerritPlugin::push() Utils::FileName GerritPlugin::gitBinDirectory() { - return gitClient()->gitBinDirectory(); + return GitPlugin::client()->gitBinDirectory(); } // Find the branch of a repository. QString GerritPlugin::branch(const QString &repository) { - return gitClient()->synchronousCurrentLocalBranch(repository); + return GitPlugin::client()->synchronousCurrentLocalBranch(repository); } void GerritPlugin::fetchDisplay(const QSharedPointer<GerritChange> &change) @@ -420,14 +415,12 @@ void GerritPlugin::fetchCheckout(const QSharedPointer<GerritChange> &change) void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode) { // Locate git. - const Utils::FileName git = gitClient()->vcsBinary(); + const Utils::FileName git = GitPlugin::client()->vcsBinary(); if (git.isEmpty()) { VcsBase::VcsOutputWindow::appendError(tr("Git is not available.")); return; } - GitClient *client = gitClient(); - QString repository; bool verifiedRepository = false; if (!m_dialog.isNull() && !m_parameters.isNull() && QFile::exists(m_dialog->repositoryPath())) @@ -435,7 +428,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode) if (!repository.isEmpty()) { // Check if remote from a working dir is the same as remote from patch - QMap<QString, QString> remotesList = client->synchronousRemotesList(repository); + QMap<QString, QString> remotesList = GitPlugin::client()->synchronousRemotesList(repository); if (!remotesList.isEmpty()) { QStringList remotes = remotesList.values(); foreach (QString remote, remotes) { @@ -448,7 +441,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode) } if (!verifiedRepository) { - SubmoduleDataMap submodules = client->submoduleList(repository); + SubmoduleDataMap submodules = GitPlugin::client()->submoduleList(repository); foreach (const SubmoduleData &submoduleData, submodules) { QString remote = submoduleData.url; if (remote.endsWith(QLatin1String(".git"))) diff --git a/src/plugins/git/gerrit/gerritpushdialog.cpp b/src/plugins/git/gerrit/gerritpushdialog.cpp index 4dc38a0ca1..23c3c147d9 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.cpp +++ b/src/plugins/git/gerrit/gerritpushdialog.cpp @@ -65,14 +65,14 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch) args << QLatin1String("-r") << QLatin1String("--contains") << earliestCommit + QLatin1Char('^'); - if (!m_client->synchronousBranchCmd(m_workingDir, args, &output, &error)) + if (!GitPlugin::client()->synchronousBranchCmd(m_workingDir, args, &output, &error)) return QString(); const QString head = QLatin1String("/HEAD"); QStringList refs = output.split(QLatin1Char('\n')); QString remoteTrackingBranch; if (localBranch != QLatin1String("HEAD")) - remoteTrackingBranch = m_client->synchronousTrackingBranch(m_workingDir, localBranch); + remoteTrackingBranch = GitPlugin::client()->synchronousTrackingBranch(m_workingDir, localBranch); QString remoteBranch; foreach (const QString &reference, refs) { @@ -99,7 +99,7 @@ void GerritPushDialog::initRemoteBranches() QString remotesPrefix(QLatin1String("refs/remotes/")); args << QLatin1String("--format=%(refname)\t%(committerdate:raw)") << remotesPrefix; - if (!m_client->synchronousForEachRefCmd(m_workingDir, args, &output)) + if (!GitPlugin::client()->synchronousForEachRefCmd(m_workingDir, args, &output)) return; const QStringList refs = output.split(QLatin1String("\n")); @@ -113,7 +113,7 @@ void GerritPushDialog::initRemoteBranches() BranchDate bd(ref.mid(refBranchIndex + 1), QDateTime::fromTime_t(timeT).date()); m_remoteBranches.insertMulti(ref.left(refBranchIndex), bd); } - QStringList remotes = m_client->synchronousRemotesList(m_workingDir).keys(); + QStringList remotes = GitPlugin::client()->synchronousRemotesList(m_workingDir).keys(); remotes.removeDuplicates(); { const QString origin = QLatin1String("origin"); @@ -130,10 +130,8 @@ void GerritPushDialog::initRemoteBranches() GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &reviewerList, QWidget *parent) : QDialog(parent), m_workingDir(workingDir), - m_ui(new Ui::GerritPushDialog), - m_isValid(false) + m_ui(new Ui::GerritPushDialog) { - m_client = GitPlugin::instance()->client(); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_ui->setupUi(this); m_ui->repositoryLabel->setText(QDir::toNativeSeparators(workingDir)); @@ -189,7 +187,7 @@ QString GerritPushDialog::calculateChangeRange(const QString &branch) QString number; QString error; - m_client->synchronousRevListCmd(m_workingDir, args, &number, &error); + GitPlugin::client()->synchronousRevListCmd(m_workingDir, args, &number, &error); number.chop(1); return number; @@ -228,7 +226,7 @@ void GerritPushDialog::setRemoteBranches(bool includeOld) const QString remoteName = selectedRemoteName(); if (!m_remoteBranches.contains(remoteName)) { - foreach (const QString &branch, m_client->synchronousRepositoryBranches(remoteName, m_workingDir)) + foreach (const QString &branch, GitPlugin::client()->synchronousRepositoryBranches(remoteName, m_workingDir)) m_remoteBranches.insertMulti(remoteName, qMakePair(branch, QDate())); } diff --git a/src/plugins/git/gerrit/gerritpushdialog.h b/src/plugins/git/gerrit/gerritpushdialog.h index 485cdb57da..e46a84ccf4 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.h +++ b/src/plugins/git/gerrit/gerritpushdialog.h @@ -70,8 +70,7 @@ private: QString m_suggestedRemoteBranch; Ui::GerritPushDialog *m_ui; RemoteBranchesMap m_remoteBranches; - bool m_isValid; - Git::Internal::GitClient *m_client; + bool m_isValid = false; }; diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index c8468c0d76..004fdc62c8 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -123,7 +123,6 @@ private: protected: void processDiff(const QString &output, const QString &startupFile = QString()); QStringList addConfigurationArguments(const QStringList &args) const; - GitClient *gitClient() const; QStringList addHeadWhenCommandInProgress() const; const QString m_directory; @@ -151,7 +150,7 @@ void BaseController::runCommand(const QList<QStringList> &args, QTextCodec *code m_command->cancel(); } - m_command = new VcsCommand(m_directory, gitClient()->processEnvironment()); + m_command = new VcsCommand(m_directory, GitPlugin::client()->processEnvironment()); m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec()); connect(m_command.data(), &VcsCommand::stdOutText, this, &BaseController::processOutput); connect(m_command.data(), &VcsCommand::finished, this, &BaseController::reloadFinished); @@ -160,7 +159,7 @@ void BaseController::runCommand(const QList<QStringList> &args, QTextCodec *code foreach (const QStringList &arg, args) { QTC_ASSERT(!arg.isEmpty(), continue); - m_command->addJob(gitClient()->vcsBinary(), arg, gitClient()->vcsTimeoutS()); + m_command->addJob(GitPlugin::client()->vcsBinary(), arg, GitPlugin::client()->vcsTimeoutS()); } m_command->execute(); @@ -198,18 +197,13 @@ void BaseController::processOutput(const QString &output) processDiff(output); } -GitClient *BaseController::gitClient() const -{ - return GitPlugin::instance()->client(); -} - QStringList BaseController::addHeadWhenCommandInProgress() const { QStringList args; // This is workaround for lack of support for merge commits and resolving conflicts, // we compare the current state of working tree to the HEAD of current branch // instead of showing unsupported combined diff format. - GitClient::CommandInProgress commandInProgress = gitClient()->checkCommandInProgress(m_directory); + GitClient::CommandInProgress commandInProgress = GitPlugin::client()->checkCommandInProgress(m_directory); if (commandInProgress != GitClient::NoCommand) args << QLatin1String(HEAD); return args; @@ -370,14 +364,14 @@ void ShowController::reload() args << QLatin1String("show") << QLatin1String("-s") << QLatin1String(noColorOption) << QLatin1String(decorateOption) << QLatin1String(showFormatC) << m_id; m_state = GettingDescription; - runCommand(QList<QStringList>() << args, gitClient()->encoding(m_directory, "i18n.commitEncoding")); + runCommand(QList<QStringList>() << args, GitPlugin::client()->encoding(m_directory, "i18n.commitEncoding")); } void ShowController::processOutput(const QString &output) { QTC_ASSERT(m_state != Idle, return); if (m_state == GettingDescription) - setDescription(gitClient()->extendedShowDescription(m_directory, output)); + setDescription(GitPlugin::client()->extendedShowDescription(m_directory, output)); else if (m_state == GettingDiff) processDiff(output, VcsBasePlugin::source(document())); } @@ -3232,12 +3226,6 @@ unsigned GitClient::synchronousGitVersion(QString *errorMessage) const return version(majorV, minorV, patchV); } -GitClient::StashInfo::StashInfo() : - m_client(GitPlugin::instance()->client()), - m_pushAction(NoPush) -{ -} - bool GitClient::StashInfo::init(const QString &workingDirectory, const QString &command, StashFlag flag, PushAction pushAction) { @@ -3246,8 +3234,8 @@ bool GitClient::StashInfo::init(const QString &workingDirectory, const QString & m_pushAction = pushAction; QString errorMessage; QString statusOutput; - switch (m_client->gitStatus(m_workingDir, StatusMode(NoUntracked | NoSubmodules), - &statusOutput, &errorMessage)) { + switch (GitPlugin::client()->gitStatus(m_workingDir, StatusMode(NoUntracked | NoSubmodules), + &statusOutput, &errorMessage)) { case GitClient::StatusChanged: if (m_flags & NoPrompt) executeStash(command, &errorMessage); @@ -3300,14 +3288,14 @@ void GitClient::StashInfo::stashPrompt(const QString &command, const QString &st msgBox.exec(); if (msgBox.clickedButton() == discardButton) { - m_stashResult = m_client->synchronousReset(m_workingDir, QStringList(), errorMessage) ? - StashUnchanged : StashFailed; + m_stashResult = GitPlugin::client()->synchronousReset(m_workingDir, QStringList(), errorMessage) ? + StashUnchanged : StashFailed; } else if (msgBox.clickedButton() == ignoreButton) { // At your own risk, so. m_stashResult = NotStashed; } else if (msgBox.clickedButton() == cancelButton) { m_stashResult = StashCanceled; } else if (msgBox.clickedButton() == stashButton) { - const bool result = m_client->executeSynchronousStash( + const bool result = GitPlugin::client()->executeSynchronousStash( m_workingDir, creatorStashMessage(command), false, errorMessage); m_stashResult = result ? StashUnchanged : StashFailed; } else if (msgBox.clickedButton() == stashAndPopButton) { @@ -3318,7 +3306,7 @@ void GitClient::StashInfo::stashPrompt(const QString &command, const QString &st void GitClient::StashInfo::executeStash(const QString &command, QString *errorMessage) { m_message = creatorStashMessage(command); - if (!m_client->executeSynchronousStash(m_workingDir, m_message, false, errorMessage)) + if (!GitPlugin::client()->executeSynchronousStash(m_workingDir, m_message, false, errorMessage)) m_stashResult = StashFailed; else m_stashResult = Stashed; @@ -3341,12 +3329,12 @@ void GitClient::StashInfo::end() { if (m_stashResult == Stashed) { QString stashName; - if (m_client->stashNameFromMessage(m_workingDir, m_message, &stashName)) - m_client->stashPop(m_workingDir, stashName); + if (GitPlugin::client()->stashNameFromMessage(m_workingDir, m_message, &stashName)) + GitPlugin::client()->stashPop(m_workingDir, stashName); } if (m_pushAction == NormalPush) - m_client->push(m_workingDir); + GitPlugin::client()->push(m_workingDir); else if (m_pushAction == PushToGerrit) GitPlugin::instance()->gerritPlugin()->push(m_workingDir); diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index 2e6f367e83..e6b1c3d370 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef GITCLIENT_H -#define GITCLIENT_H +#pragma once #include "gitsettings.h" #include "commitdata.h" @@ -71,7 +70,7 @@ namespace Git { namespace Internal { class CommitData; -struct GitSubmitEditorPanelData; +class GitSubmitEditorPanelData; class Stash; enum StatusMode @@ -108,7 +107,7 @@ public: class StashInfo { public: - StashInfo(); + StashInfo() = default; enum StashResult { StashUnchanged, StashCanceled, StashFailed, Stashed, NotStashed /* User did not want it */ }; @@ -126,9 +125,8 @@ public: StashResult m_stashResult; QString m_message; QString m_workingDir; - GitClient *m_client; StashFlag m_flags; - PushAction m_pushAction; + PushAction m_pushAction = NoPush; }; static const char *stashNamePrefix; @@ -340,7 +338,6 @@ public: static QString msgNoChangedFiles(); static QString msgNoCommits(bool includeRemote); -public slots: void show(const QString &source, const QString &id, const QString &name = QString()); private: @@ -401,5 +398,3 @@ private: } // namespace Internal } // namespace Git - -#endif // GITCLIENT_H diff --git a/src/plugins/git/gitconstants.h b/src/plugins/git/gitconstants.h index 17b85d6f91..352aac7c40 100644 --- a/src/plugins/git/gitconstants.h +++ b/src/plugins/git/gitconstants.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef GIT_CONSTANTS_H -#define GIT_CONSTANTS_H +#pragma once #include <QtGlobal> @@ -52,5 +51,3 @@ const char C_GITEDITORID[] = "Git Editor"; } // namespace Constants } // namespace Git - -#endif // GIT_CONSTANTS_H diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp index dc4f1c8048..9c8dd78676 100644 --- a/src/plugins/git/giteditor.cpp +++ b/src/plugins/git/giteditor.cpp @@ -124,7 +124,7 @@ static QString sanitizeBlameOutput(const QString &b) if (b.isEmpty()) return b; - const bool omitDate = GitPlugin::instance()->client()->settings().boolValue( + const bool omitDate = GitPlugin::client()->settings().boolValue( GitSettings::omitAnnotationDateKey); const QChar space(QLatin1Char(' ')); const int parenPos = b.indexOf(QLatin1Char(')')); @@ -190,31 +190,31 @@ void GitEditorWidget::setPlainText(const QString &text) void GitEditorWidget::checkoutChange() { - GitPlugin::instance()->client()->stashAndCheckout( + GitPlugin::client()->stashAndCheckout( sourceWorkingDirectory(), m_currentChange); } void GitEditorWidget::resetChange(const QByteArray &resetType) { - GitPlugin::instance()->client()->reset( + GitPlugin::client()->reset( sourceWorkingDirectory(), QLatin1String("--" + resetType), m_currentChange); } void GitEditorWidget::cherryPickChange() { - GitPlugin::instance()->client()->synchronousCherryPick( + GitPlugin::client()->synchronousCherryPick( sourceWorkingDirectory(), m_currentChange); } void GitEditorWidget::revertChange() { - GitPlugin::instance()->client()->synchronousRevert( + GitPlugin::client()->synchronousRevert( sourceWorkingDirectory(), m_currentChange); } void GitEditorWidget::logChange() { - GitPlugin::instance()->client()->log( + GitPlugin::client()->log( sourceWorkingDirectory(), QString(), false, QStringList(m_currentChange)); } @@ -229,12 +229,11 @@ void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, bool revert) patchFile.write(chunk.chunk); patchFile.close(); - GitClient *client = GitPlugin::instance()->client(); QStringList args = QStringList() << QLatin1String("--cached"); if (revert) args << QLatin1String("--reverse"); QString errorMessage; - if (client->synchronousApplyPatch(baseDir, patchFile.fileName(), &errorMessage, args)) { + if (GitPlugin::client()->synchronousApplyPatch(baseDir, patchFile.fileName(), &errorMessage, args)) { if (errorMessage.isEmpty()) VcsOutputWindow::append(tr("Chunk successfully staged")); else @@ -283,7 +282,7 @@ void GitEditorWidget::aboutToOpen(const QString &fileName, const QString &realFi const QString gitPath = fi.absolutePath(); setSource(gitPath); textDocument()->setCodec( - GitPlugin::instance()->client()->encoding(gitPath, "i18n.commitEncoding")); + GitPlugin::client()->encoding(gitPath, "i18n.commitEncoding")); } } @@ -293,18 +292,17 @@ QString GitEditorWidget::decorateVersion(const QString &revision) const const QString workingDirectory = fi.absolutePath(); // Format verbose, SHA1 being first token - return GitPlugin::instance()->client()->synchronousShortDescription(workingDirectory, revision); + return GitPlugin::client()->synchronousShortDescription(workingDirectory, revision); } QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision) const { QStringList revisions; QString errorMessage; - GitClient *client = GitPlugin::instance()->client(); const QFileInfo fi(source()); const QString workingDirectory = fi.absolutePath(); // Get the SHA1's of the file. - if (!client->synchronousParentRevisions(workingDirectory, revision, &revisions, &errorMessage)) { + if (!GitPlugin::client()->synchronousParentRevisions(workingDirectory, revision, &revisions, &errorMessage)) { VcsOutputWindow::appendSilently(errorMessage); return QStringList(); } @@ -313,7 +311,7 @@ QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision) bool GitEditorWidget::isValidRevision(const QString &revision) const { - return GitPlugin::instance()->client()->isValidRevision(revision); + return GitPlugin::client()->isValidRevision(revision); } void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change) diff --git a/src/plugins/git/giteditor.h b/src/plugins/git/giteditor.h index c1a6b7be36..d776d2ff5d 100644 --- a/src/plugins/git/giteditor.h +++ b/src/plugins/git/giteditor.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef GITEDITOR_H -#define GITEDITOR_H +#pragma once #include <vcsbase/vcsbaseeditor.h> @@ -75,5 +74,3 @@ private: } // namespace Git } // namespace Internal - -#endif // GITEDITOR_H diff --git a/src/plugins/git/gitgrep.cpp b/src/plugins/git/gitgrep.cpp index 390a546f64..ec3bff0737 100644 --- a/src/plugins/git/gitgrep.cpp +++ b/src/plugins/git/gitgrep.cpp @@ -151,8 +151,7 @@ public: m_ref = params.ref + QLatin1Char(':'); } arguments << QLatin1String("--") << m_parameters.nameFilters; - GitClient *client = GitPlugin::instance()->client(); - QScopedPointer<VcsCommand> command(client->createCommand(m_directory)); + QScopedPointer<VcsCommand> command(GitPlugin::client()->createCommand(m_directory)); command->addFlags(VcsCommand::SilentOutput); command->setProgressiveOutput(true); QFutureWatcher<FileSearchResultList> watcher; @@ -160,7 +159,7 @@ public: connect(&watcher, &QFutureWatcher<FileSearchResultList>::canceled, command.data(), &VcsCommand::cancel); connect(command.data(), &VcsCommand::stdOutText, this, &GitGrepRunner::read); - SynchronousProcessResponse resp = command->runCommand(client->vcsBinary(), arguments, 0); + SynchronousProcessResponse resp = command->runCommand(GitPlugin::client()->vcsBinary(), arguments, 0); switch (resp.result) { case SynchronousProcessResponse::TerminatedAbnormally: case SynchronousProcessResponse::StartFailed: @@ -292,11 +291,10 @@ IEditor *GitGrep::openEditor(const SearchResultItem &item, return nullptr; const QString path = QDir::fromNativeSeparators(item.path.first()); QByteArray content; - GitClient *client = GitPlugin::instance()->client(); const QString topLevel = parameters.additionalParameters.toString(); const QString relativePath = QDir(topLevel).relativeFilePath(path); - if (!client->synchronousShow(topLevel, params.ref + QLatin1String(":./") + relativePath, - &content, nullptr)) { + if (!GitPlugin::client()->synchronousShow(topLevel, params.ref + QLatin1String(":./") + relativePath, + &content, nullptr)) { return nullptr; } if (content.isEmpty()) diff --git a/src/plugins/git/gitgrep.h b/src/plugins/git/gitgrep.h index a18f8ae7fc..1bcec59d39 100644 --- a/src/plugins/git/gitgrep.h +++ b/src/plugins/git/gitgrep.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef GITGREP_H -#define GITGREP_H +#pragma once #include <texteditor/basefilefind.h> @@ -65,5 +64,3 @@ private: } // namespace Internal } // namespace Git - -#endif // FINDINFILES_H diff --git a/src/plugins/git/githighlighters.h b/src/plugins/git/githighlighters.h index 4945a3ffa6..166c6a7be8 100644 --- a/src/plugins/git/githighlighters.h +++ b/src/plugins/git/githighlighters.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef GITHIGHLIGHTERS_H -#define GITHIGHLIGHTERS_H +#pragma once #include <texteditor/syntaxhighlighter.h> @@ -81,5 +80,3 @@ private: } // namespace Internal } // namespace Git - -#endif // GITHIGHLIGHTERS_H diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index ab27d1ae74..5a76acf004 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -127,16 +127,7 @@ const VcsBaseEditorParameters editorParameters[] = { static GitPlugin *m_instance = 0; -GitPlugin::GitPlugin() : - m_commandLocator(0), - m_submitCurrentAction(0), - m_diffSelectedFilesAction(0), - m_undoAction(0), - m_redoAction(0), - m_menuAction(0), - m_applyCurrentFilePatchAction(0), - m_gitClient(0), - m_submitActionTriggered(false) +GitPlugin::GitPlugin() { m_instance = this; m_fileActions.reserve(10); @@ -169,6 +160,11 @@ GitPlugin *GitPlugin::instance() return m_instance; } +GitClient *GitPlugin::client() +{ + return m_instance->m_gitClient; +} + const VcsBaseSubmitEditorParameters submitParameters = { Git::Constants::SUBMIT_MIMETYPE, Git::Constants::GITSUBMITEDITOR_ID, @@ -1353,11 +1349,6 @@ void GitPlugin::updateRepositoryBrowserAction() m_repositoryBrowserAction->setEnabled(repositoryEnabled && hasRepositoryBrowserCmd); } -GitClient *GitPlugin::client() const -{ - return m_gitClient; -} - Gerrit::Internal::GerritPlugin *GitPlugin::gerritPlugin() const { return m_gerritPlugin; diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index 653321c895..a4bd0571e7 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef GITPLUGIN_H -#define GITPLUGIN_H +#pragma once #include "gitsettings.h" @@ -51,11 +50,12 @@ class Command; class CommandLocator; class Context; class ActionContainer; -} +} // namespace Core namespace Utils { class ParameterAction; } namespace Gerrit { namespace Internal { class GerritPlugin; } -} +} // namespace Gerrit + namespace Git { namespace Internal { @@ -79,12 +79,12 @@ public: ~GitPlugin(); static GitPlugin *instance(); + static GitClient *client(); bool initialize(const QStringList &arguments, QString *errorMessage) override; GitVersionControl *gitVersionControl() const; - GitClient *client() const; Gerrit::Internal::GerritPlugin *gerritPlugin() const; bool isCommitEditorOpen() const; @@ -191,42 +191,40 @@ private: void startCommit(CommitType commitType); void updateVersionWarning(); - Core::CommandLocator *m_commandLocator; - - QAction *m_submitCurrentAction; - QAction *m_diffSelectedFilesAction; - QAction *m_undoAction; - QAction *m_redoAction; - QAction *m_menuAction; - QAction *m_repositoryBrowserAction; - QAction *m_mergeToolAction; - QAction *m_submoduleUpdateAction; - QAction *m_abortMergeAction; - QAction *m_abortRebaseAction; - QAction *m_abortCherryPickAction; - QAction *m_abortRevertAction; - QAction *m_continueRebaseAction; - QAction *m_continueCherryPickAction; - QAction *m_continueRevertAction; - QAction *m_fixupCommitAction; - QAction *m_interactiveRebaseAction; + Core::CommandLocator *m_commandLocator = nullptr; + + QAction *m_submitCurrentAction = nullptr; + QAction *m_diffSelectedFilesAction = nullptr; + QAction *m_undoAction = nullptr; + QAction *m_redoAction = nullptr; + QAction *m_menuAction = nullptr; + QAction *m_repositoryBrowserAction = nullptr; + QAction *m_mergeToolAction = nullptr; + QAction *m_submoduleUpdateAction = nullptr; + QAction *m_abortMergeAction = nullptr; + QAction *m_abortRebaseAction = nullptr; + QAction *m_abortCherryPickAction = nullptr; + QAction *m_abortRevertAction = nullptr; + QAction *m_continueRebaseAction = nullptr; + QAction *m_continueCherryPickAction = nullptr; + QAction *m_continueRevertAction = nullptr; + QAction *m_fixupCommitAction = nullptr; + QAction *m_interactiveRebaseAction = nullptr; QVector<Utils::ParameterAction *> m_fileActions; QVector<Utils::ParameterAction *> m_projectActions; QVector<QAction *> m_repositoryActions; - Utils::ParameterAction *m_applyCurrentFilePatchAction; - Gerrit::Internal::GerritPlugin *m_gerritPlugin; + Utils::ParameterAction *m_applyCurrentFilePatchAction = nullptr; + Gerrit::Internal::GerritPlugin *m_gerritPlugin = nullptr; - GitClient *m_gitClient; + GitClient *m_gitClient = nullptr; QPointer<StashDialog> m_stashDialog; QPointer<BranchDialog> m_branchDialog; QPointer<RemoteDialog> m_remoteDialog; QString m_submitRepository; QString m_commitMessageFileName; - bool m_submitActionTriggered; + bool m_submitActionTriggered = false; }; } // namespace Internal } // namespace Git - -#endif // GITPLUGIN_H diff --git a/src/plugins/git/gitsettings.h b/src/plugins/git/gitsettings.h index 2d73ec6b34..c2f2281721 100644 --- a/src/plugins/git/gitsettings.h +++ b/src/plugins/git/gitsettings.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef GITSETTINGS_H -#define GITSETTINGS_H +#pragma once #include <vcsbase/vcsbaseclientsettings.h> @@ -65,5 +64,3 @@ public: } // namespace Internal } // namespace Git - -#endif // GITSETTINGS_H diff --git a/src/plugins/git/gitsubmiteditor.cpp b/src/plugins/git/gitsubmiteditor.cpp index ae6d1200e5..aa97bc05fa 100644 --- a/src/plugins/git/gitsubmiteditor.cpp +++ b/src/plugins/git/gitsubmiteditor.cpp @@ -97,10 +97,9 @@ public: void start() { - GitClient *client = GitPlugin::instance()->client(); QString commitTemplate; - bool success = client->getCommitData(m_workingDirectory, &commitTemplate, - m_commitData, &m_errorMessage); + bool success = GitPlugin::client()->getCommitData(m_workingDirectory, &commitTemplate, + m_commitData, &m_errorMessage); emit finished(success); } @@ -122,13 +121,7 @@ private: * according to a type flag we add to the model. */ GitSubmitEditor::GitSubmitEditor(const VcsBaseSubmitEditorParameters *parameters) : - VcsBaseSubmitEditor(parameters, new GitSubmitEditorWidget), - m_model(0), - m_commitEncoding(0), - m_commitType(SimpleCommit), - m_firstUpdate(true), - m_commitDataFetcher(0), - m_gitClient(GitPlugin::instance()->client()) + VcsBaseSubmitEditor(parameters, new GitSubmitEditorWidget) { connect(this, &VcsBaseSubmitEditor::diffSelectedRows, this, &GitSubmitEditor::slotDiffSelected); connect(submitEditorWidget(), &GitSubmitEditorWidget::show, this, &GitSubmitEditor::showCommit); @@ -238,15 +231,15 @@ void GitSubmitEditor::slotDiffSelected(const QList<int> &rows) } } if (!unstagedFiles.empty() || !stagedFiles.empty()) - m_gitClient->diffFiles(m_workingDirectory, unstagedFiles, stagedFiles); + GitPlugin::client()->diffFiles(m_workingDirectory, unstagedFiles, stagedFiles); if (!unmergedFiles.empty()) - m_gitClient->merge(m_workingDirectory, unmergedFiles); + GitPlugin::client()->merge(m_workingDirectory, unmergedFiles); } void GitSubmitEditor::showCommit(const QString &commit) { if (!m_workingDirectory.isEmpty()) - m_gitClient->show(m_workingDirectory, commit); + GitPlugin::client()->show(m_workingDirectory, commit); } void GitSubmitEditor::updateFileModel() @@ -267,7 +260,7 @@ void GitSubmitEditor::updateFileModel() QFuture<void> future = QtConcurrent::run(m_commitDataFetcher, &CommitDataFetcher::start); Core::ProgressManager::addTask(future, tr("Refreshing Commit Data"), TASK_UPDATE_COMMIT); - m_gitClient->addFuture(future); + GitPlugin::client()->addFuture(future); } void GitSubmitEditor::forceUpdateFileModel() diff --git a/src/plugins/git/gitsubmiteditor.h b/src/plugins/git/gitsubmiteditor.h index ea3f6dcb9e..3b82349f41 100644 --- a/src/plugins/git/gitsubmiteditor.h +++ b/src/plugins/git/gitsubmiteditor.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef GITSUBMITEDITOR_H -#define GITSUBMITEDITOR_H +#pragma once #include "gitsettings.h" // CommitType @@ -41,11 +40,12 @@ class GitClient; class GitSubmitEditorWidget; class CommitData; class CommitDataFetcher; -struct GitSubmitEditorPanelData; +class GitSubmitEditorPanelData; class GitSubmitEditor : public VcsBase::VcsBaseSubmitEditor { Q_OBJECT + public: explicit GitSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters); ~GitSubmitEditor() override; @@ -69,17 +69,14 @@ private: inline const GitSubmitEditorWidget *submitEditorWidget() const; void resetCommitDataFetcher(); - VcsBase::SubmitFileModel *m_model; - QTextCodec *m_commitEncoding; - CommitType m_commitType; + VcsBase::SubmitFileModel *m_model = nullptr; + QTextCodec *m_commitEncoding = nullptr; + CommitType m_commitType = SimpleCommit; QString m_amendSHA1; QString m_workingDirectory; - bool m_firstUpdate; - CommitDataFetcher *m_commitDataFetcher; - GitClient *m_gitClient; + bool m_firstUpdate = true; + CommitDataFetcher *m_commitDataFetcher = nullptr; }; } // namespace Internal } // namespace Git - -#endif // GITSUBMITEDITOR_H diff --git a/src/plugins/git/gitsubmiteditorwidget.cpp b/src/plugins/git/gitsubmiteditorwidget.cpp index 3272f9d867..6a7fab23be 100644 --- a/src/plugins/git/gitsubmiteditorwidget.cpp +++ b/src/plugins/git/gitsubmiteditorwidget.cpp @@ -46,11 +46,7 @@ namespace Internal { // ------------------ GitSubmitEditorWidget::GitSubmitEditorWidget() : - m_pushAction(NoPush), - m_gitSubmitPanel(new QWidget), - m_logChangeWidget(0), - m_hasUnmerged(false), - m_isInitialized(false) + m_gitSubmitPanel(new QWidget) { m_gitSubmitPanelUi.setupUi(m_gitSubmitPanel); new GitSubmitHighlighter(descriptionEdit()); diff --git a/src/plugins/git/gitsubmiteditorwidget.h b/src/plugins/git/gitsubmiteditorwidget.h index cdb3924ee4..42d895d7f0 100644 --- a/src/plugins/git/gitsubmiteditorwidget.h +++ b/src/plugins/git/gitsubmiteditorwidget.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef GITSUBMITEDITORWIDGET_H -#define GITSUBMITEDITORWIDGET_H +#pragma once #include "ui_gitsubmitpanel.h" #include "gitsettings.h" @@ -43,8 +42,8 @@ QT_END_NAMESPACE namespace Git { namespace Internal { -struct GitSubmitEditorPanelInfo; -struct GitSubmitEditorPanelData; +class GitSubmitEditorPanelInfo; +class GitSubmitEditorPanelData; class LogChangeWidget; /* Submit editor widget with 2 additional panes: @@ -90,18 +89,16 @@ private: void setPanelData(const GitSubmitEditorPanelData &data); void setPanelInfo(const GitSubmitEditorPanelInfo &info); - PushAction m_pushAction; + PushAction m_pushAction = NoPush; QWidget *m_gitSubmitPanel; - LogChangeWidget *m_logChangeWidget; + LogChangeWidget *m_logChangeWidget = nullptr; Ui::GitSubmitPanel m_gitSubmitPanelUi; QValidator *m_emailValidator; QString m_originalAuthor; QString m_originalEmail; - bool m_hasUnmerged; - bool m_isInitialized; + bool m_hasUnmerged = false; + bool m_isInitialized = false; }; } // namespace Internal } // namespace Git - -#endif // GITSUBMITEDITORWIDGET_H diff --git a/src/plugins/git/gitutils.cpp b/src/plugins/git/gitutils.cpp index f89536dcc7..8ddfc0072f 100644 --- a/src/plugins/git/gitutils.cpp +++ b/src/plugins/git/gitutils.cpp @@ -25,20 +25,12 @@ #include "gitutils.h" -#include <QDebug> #include <QInputDialog> #include <QLineEdit> namespace Git { namespace Internal { -QDebug operator<<(QDebug d, const Stash &s) -{ - QDebug nospace = d.nospace(); - nospace << "name=" << s.name << " branch=" << s.branch << " message=" << s.message; - return d; -} - void Stash::clear() { name.clear(); diff --git a/src/plugins/git/gitutils.h b/src/plugins/git/gitutils.h index 420cf4c0cb..c4087d4eac 100644 --- a/src/plugins/git/gitutils.h +++ b/src/plugins/git/gitutils.h @@ -23,13 +23,11 @@ ** ****************************************************************************/ -#ifndef GITUTILS_H -#define GITUTILS_H +#pragma once #include <QString> QT_BEGIN_NAMESPACE -class QDebug; class QWidget; QT_END_NAMESPACE @@ -46,8 +44,6 @@ public: QString message; }; -QDebug operator<<(QDebug d, const Stash &); - // Make QInputDialog play nicely bool inputText(QWidget *parent, const QString &title, const QString &prompt, QString *s); @@ -61,5 +57,3 @@ QString versionString(unsigned ver); } // namespace Internal } // namespace Git - -#endif // GITUTILS_H diff --git a/src/plugins/git/gitversioncontrol.h b/src/plugins/git/gitversioncontrol.h index ee5fb96f15..b46ee90484 100644 --- a/src/plugins/git/gitversioncontrol.h +++ b/src/plugins/git/gitversioncontrol.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef GITVERSIONCONTROL_H -#define GITVERSIONCONTROL_H +#pragma once #include <coreplugin/iversioncontrol.h> @@ -73,5 +72,3 @@ private: } // Internal } // Git - -#endif // GITVERSIONCONTROL_H diff --git a/src/plugins/git/logchangedialog.cpp b/src/plugins/git/logchangedialog.cpp index c24c9bba45..00c5ce97b4 100644 --- a/src/plugins/git/logchangedialog.cpp +++ b/src/plugins/git/logchangedialog.cpp @@ -79,7 +79,7 @@ bool LogChangeWidget::init(const QString &repository, const QString &commit, Log return true; if (!(flags & Silent)) { VcsOutputWindow::appendError( - GitPlugin::instance()->client()->msgNoCommits(flags & IncludeRemotes)); + GitPlugin::client()->msgNoCommits(flags & IncludeRemotes)); } return false; } @@ -152,14 +152,13 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm m_model->removeRows(0, rowCount); // Retrieve log using a custom format "Sha1:Subject [(refs)]" - GitClient *client = GitPlugin::instance()->client(); QStringList arguments; arguments << QLatin1String("--max-count=1000") << QLatin1String("--format=%h:%s %d"); arguments << (commit.isEmpty() ? QLatin1String("HEAD") : commit); if (!(flags & IncludeRemotes)) arguments << QLatin1String("--not") << QLatin1String("--remotes"); QString output; - if (!client->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput)) + if (!GitPlugin::client()->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput)) return false; foreach (const QString &line, output.split(QLatin1Char('\n'))) { const int colonPos = line.indexOf(QLatin1Char(':')); @@ -211,8 +210,7 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) : m_resetTypeComboBox->addItem(tr("Hard"), QLatin1String("--hard")); m_resetTypeComboBox->addItem(tr("Mixed"), QLatin1String("--mixed")); m_resetTypeComboBox->addItem(tr("Soft"), QLatin1String("--soft")); - GitClient *client = GitPlugin::instance()->client(); - m_resetTypeComboBox->setCurrentIndex(client->settings().intValue( + m_resetTypeComboBox->setCurrentIndex(GitPlugin::client()->settings().intValue( GitSettings::lastResetIndexKey)); popUpLayout->addWidget(m_resetTypeComboBox); popUpLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); @@ -241,9 +239,8 @@ bool LogChangeDialog::runDialog(const QString &repository, if (QDialog::exec() == QDialog::Accepted) { if (m_resetTypeComboBox) { - GitClient *client = GitPlugin::instance()->client(); - client->settings().setValue(GitSettings::lastResetIndexKey, - m_resetTypeComboBox->currentIndex()); + GitPlugin::client()->settings().setValue(GitSettings::lastResetIndexKey, + m_resetTypeComboBox->currentIndex()); } return true; } diff --git a/src/plugins/git/logchangedialog.h b/src/plugins/git/logchangedialog.h index 74bb9425f9..06aae75844 100644 --- a/src/plugins/git/logchangedialog.h +++ b/src/plugins/git/logchangedialog.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef LOGCHANGEDDIALOG_H -#define LOGCHANGEDDIALOG_H +#pragma once #include <utils/itemviews.h> @@ -128,5 +127,3 @@ private: } // namespace Internal } // namespace Git - -#endif // LOGCHANGEDDIALOG_H diff --git a/src/plugins/git/mergetool.cpp b/src/plugins/git/mergetool.cpp index b54ddfaefa..a0a8de0fed 100644 --- a/src/plugins/git/mergetool.cpp +++ b/src/plugins/git/mergetool.cpp @@ -45,38 +45,28 @@ namespace Internal { class MergeToolProcess : public QProcess { public: - MergeToolProcess(QObject *parent = 0) : - QProcess(parent) - { - } + MergeToolProcess(QObject *parent = 0) : QProcess(parent) + { } protected: qint64 readData(char *data, qint64 maxlen) override { qint64 res = QProcess::readData(data, maxlen); if (res > 0) - VcsOutputWindow::append(QString::fromLocal8Bit(data, res)); + VcsOutputWindow::append(QString::fromLocal8Bit(data, int(res))); return res; } qint64 writeData(const char *data, qint64 len) override { if (len > 0) - VcsOutputWindow::append(QString::fromLocal8Bit(data, len)); + VcsOutputWindow::append(QString::fromLocal8Bit(data, int(len))); return QProcess::writeData(data, len); } }; -MergeTool::MergeTool(QObject *parent) : - QObject(parent), - m_process(0), - m_mergeType(NormalMerge), - m_localState(UnknownState), - m_remoteState(UnknownState), - m_client(GitPlugin::instance()->client()), - m_merging(false) -{ -} +MergeTool::MergeTool(QObject *parent) : QObject(parent) +{ } MergeTool::~MergeTool() { @@ -89,7 +79,7 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files) arguments << QLatin1String("mergetool") << QLatin1String("-y") << files; m_process = new MergeToolProcess(this); m_process->setWorkingDirectory(workingDirectory); - const Utils::FileName binary = m_client->vcsBinary(); + const Utils::FileName binary = GitPlugin::client()->vcsBinary(); VcsOutputWindow::appendCommand(workingDirectory, binary, arguments); m_process->start(binary.toString(), arguments); if (m_process->waitForStarted()) { @@ -265,7 +255,7 @@ void MergeTool::done() VcsOutputWindow::appendError(tr("Merge tool process terminated with exit code %1") .arg(exitCode)); } - m_client->continueCommandIfNeeded(workingDirectory, exitCode == 0); + GitPlugin::client()->continueCommandIfNeeded(workingDirectory, exitCode == 0); GitPlugin::instance()->gitVersionControl()->emitRepositoryChanged(workingDirectory); deleteLater(); } diff --git a/src/plugins/git/mergetool.h b/src/plugins/git/mergetool.h index 974230c09b..cb776e7627 100644 --- a/src/plugins/git/mergetool.h +++ b/src/plugins/git/mergetool.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef MERGETOOL_H -#define MERGETOOL_H +#pragma once #include <QObject> #include <QStringList> @@ -74,18 +73,15 @@ private: void chooseAction(); void addButton(QMessageBox *msgBox, const QString &text, char key); - MergeToolProcess *m_process; - MergeType m_mergeType; + MergeToolProcess *m_process = nullptr; + MergeType m_mergeType = NormalMerge; QString m_fileName; - FileState m_localState; + FileState m_localState = UnknownState; QString m_localInfo; - FileState m_remoteState; + FileState m_remoteState = UnknownState; QString m_remoteInfo; - GitClient *m_client; - bool m_merging; + bool m_merging = false; }; } // namespace Internal } // namespace Git - -#endif // MERGETOOL_H diff --git a/src/plugins/git/remotedialog.cpp b/src/plugins/git/remotedialog.cpp index 0313a39b9b..d15cc250e3 100644 --- a/src/plugins/git/remotedialog.cpp +++ b/src/plugins/git/remotedialog.cpp @@ -81,8 +81,7 @@ void RemoteAdditionDialog::clear() RemoteDialog::RemoteDialog(QWidget *parent) : QDialog(parent), m_ui(new Ui::RemoteDialog), - m_remoteModel(new RemoteModel(GitPlugin::instance()->client(), this)), - m_addDialog(0) + m_remoteModel(new RemoteModel(this)) { setModal(false); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -166,7 +165,7 @@ void RemoteDialog::pushToRemote() const int row = indexList.at(0).row(); const QString remoteName = m_remoteModel->remoteName(row); - m_remoteModel->client()->push(m_remoteModel->workingDirectory(), + GitPlugin::client()->push(m_remoteModel->workingDirectory(), QStringList() << remoteName); } @@ -178,7 +177,7 @@ void RemoteDialog::fetchFromRemote() int row = indexList.at(0).row(); const QString remoteName = m_remoteModel->remoteName(row); - m_remoteModel->client()->fetch(m_remoteModel->workingDirectory(), remoteName); + GitPlugin::client()->fetch(m_remoteModel->workingDirectory(), remoteName); } void RemoteDialog::updateButtonState() diff --git a/src/plugins/git/remotedialog.h b/src/plugins/git/remotedialog.h index 444c835b9c..dab24c9b2d 100644 --- a/src/plugins/git/remotedialog.h +++ b/src/plugins/git/remotedialog.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef REMOTEDIALOG_H -#define REMOTEDIALOG_H +#pragma once #include <QDialog> @@ -34,7 +33,7 @@ namespace Internal { namespace Ui { class RemoteDialog; class RemoteAdditionDialog; -} +} // namespace Ui class GitClient; class RemoteModel; @@ -49,7 +48,7 @@ class RemoteAdditionDialog : public QDialog public: explicit RemoteAdditionDialog(QWidget *parent = 0); - ~RemoteAdditionDialog(); + ~RemoteAdditionDialog() override; QString remoteName() const; QString remoteUrl() const; @@ -70,9 +69,8 @@ class RemoteDialog : public QDialog public: explicit RemoteDialog(QWidget *parent = 0); - ~RemoteDialog(); + ~RemoteDialog() override; -public slots: void refresh(const QString &repository, bool force); private: @@ -87,10 +85,8 @@ private: Ui::RemoteDialog *m_ui; RemoteModel *m_remoteModel; - RemoteAdditionDialog *m_addDialog; + RemoteAdditionDialog *m_addDialog = nullptr; }; } // namespace Internal } // namespace Git - -#endif // REMOTEDIALOG_H diff --git a/src/plugins/git/remotemodel.cpp b/src/plugins/git/remotemodel.cpp index e77c2505a9..5983e64dc2 100644 --- a/src/plugins/git/remotemodel.cpp +++ b/src/plugins/git/remotemodel.cpp @@ -24,16 +24,14 @@ ****************************************************************************/ #include "remotemodel.h" +#include "gitplugin.h" #include "gitclient.h" namespace Git { namespace Internal { // ------ RemoteModel -RemoteModel::RemoteModel(GitClient *client, QObject *parent) : - QAbstractTableModel(parent), - m_flags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable), - m_client(client) +RemoteModel::RemoteModel(QObject *parent) : QAbstractTableModel(parent) { } QString RemoteModel::remoteName(int row) const @@ -50,9 +48,9 @@ bool RemoteModel::removeRemote(int row) { QString output; QString error; - bool success = m_client->synchronousRemoteCmd(m_workingDirectory, - QStringList() << QLatin1String("rm") << remoteName(row), - &output, &error); + bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory, + QStringList() << QLatin1String("rm") << remoteName(row), + &output, &error); if (success) success = refresh(m_workingDirectory, &error); return success; @@ -65,9 +63,9 @@ bool RemoteModel::addRemote(const QString &name, const QString &url) if (name.isEmpty() || url.isEmpty()) return false; - bool success = m_client->synchronousRemoteCmd(m_workingDirectory, - QStringList() << QLatin1String("add") << name << url, - &output, &error); + bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory, + QStringList() << QLatin1String("add") << name << url, + &output, &error); if (success) success = refresh(m_workingDirectory, &error); return success; @@ -77,9 +75,9 @@ bool RemoteModel::renameRemote(const QString &oldName, const QString &newName) { QString output; QString error; - bool success = m_client->synchronousRemoteCmd(m_workingDirectory, - QStringList() << QLatin1String("rename") << oldName << newName, - &output, &error); + bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory, + QStringList() << QLatin1String("rename") << oldName << newName, + &output, &error); if (success) success = refresh(m_workingDirectory, &error); return success; @@ -89,9 +87,9 @@ bool RemoteModel::updateUrl(const QString &name, const QString &newUrl) { QString output; QString error; - bool success = m_client->synchronousRemoteCmd(m_workingDirectory, - QStringList() << QLatin1String("set-url") << name << newUrl, - &output, &error); + bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory, + QStringList() << QLatin1String("set-url") << name << newUrl, + &output, &error); if (success) success = refresh(m_workingDirectory, &error); return success; @@ -184,8 +182,8 @@ bool RemoteModel::refresh(const QString &workingDirectory, QString *errorMessage m_workingDirectory = workingDirectory; // get list of remotes. - QMap<QString,QString> remotesList = - m_client->synchronousRemotesList(workingDirectory, errorMessage); + QMap<QString,QString> remotesList + = GitPlugin::client()->synchronousRemotesList(workingDirectory, errorMessage); if (remotesList.isEmpty()) return false; @@ -211,11 +209,6 @@ int RemoteModel::findRemoteByName(const QString &name) const return -1; } -GitClient *RemoteModel::client() const -{ - return m_client; -} - } // namespace Internal } // namespace Git diff --git a/src/plugins/git/remotemodel.h b/src/plugins/git/remotemodel.h index ed6cb81ac0..c6b976ac5c 100644 --- a/src/plugins/git/remotemodel.h +++ b/src/plugins/git/remotemodel.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef REMOTEMODEL_H -#define REMOTEMODEL_H +#pragma once #include <QAbstractTableModel> #include <QList> @@ -38,7 +37,7 @@ class GitClient; class RemoteModel : public QAbstractTableModel { Q_OBJECT public: - explicit RemoteModel(GitClient *client, QObject *parent = 0); + explicit RemoteModel(QObject *parent = 0); void clear(); bool refresh(const QString &workingDirectory, QString *errorMessage); @@ -64,24 +63,21 @@ public: QString workingDirectory() const; int findRemoteByName(const QString &name) const; - GitClient *client() const; protected: - struct Remote { + class Remote { + public: QString name; QString url; }; typedef QList<Remote> RemoteList; private: - const Qt::ItemFlags m_flags; + const Qt::ItemFlags m_flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable; - GitClient *m_client; QString m_workingDirectory; RemoteList m_remotes; }; } // namespace Internal } // namespace Git - -#endif // REMOTEMODEL_H diff --git a/src/plugins/git/settingspage.cpp b/src/plugins/git/settingspage.cpp index 06f4869a8b..ccc56dd05a 100644 --- a/src/plugins/git/settingspage.cpp +++ b/src/plugins/git/settingspage.cpp @@ -92,7 +92,7 @@ void SettingsPageWidget::setSettings(const VcsBaseClientSettings &s) // -------- SettingsPage SettingsPage::SettingsPage(Core::IVersionControl *control) : - VcsClientOptionsPage(control, GitPlugin::instance()->client()) + VcsClientOptionsPage(control, GitPlugin::client()) { setId(VcsBase::Constants::VCS_ID_GIT); setDisplayName(tr("Git")); diff --git a/src/plugins/git/settingspage.h b/src/plugins/git/settingspage.h index f7f1503f1a..bfa1b57b49 100644 --- a/src/plugins/git/settingspage.h +++ b/src/plugins/git/settingspage.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef SETTINGSPAGE_H -#define SETTINGSPAGE_H +#pragma once #include <vcsbase/vcsbaseoptionspage.h> @@ -46,6 +45,7 @@ namespace Internal { class SettingsPageWidget : public VcsBase::VcsClientOptionsPageWidget { Q_OBJECT + public: explicit SettingsPageWidget(QWidget *parent = 0); @@ -67,5 +67,3 @@ public: } // namespace Internal } // namespace Git - -#endif // SETTINGSPAGE_H diff --git a/src/plugins/git/stashdialog.cpp b/src/plugins/git/stashdialog.cpp index b1d075dff8..00ee6f56ef 100644 --- a/src/plugins/git/stashdialog.cpp +++ b/src/plugins/git/stashdialog.cpp @@ -46,11 +46,6 @@ enum { NameColumn, BranchColumn, MessageColumn, ColumnCount }; namespace Git { namespace Internal { -static inline GitClient *gitClient() -{ - return GitPlugin::instance()->client(); -} - static inline QList<QStandardItem*> stashModelRowItems(const Stash &s) { Qt::ItemFlags itemFlags = Qt::ItemIsSelectable | Qt::ItemIsEnabled; @@ -95,8 +90,7 @@ void StashModel::setStashes(const QList<Stash> &stashes) } // ---------- StashDialog -StashDialog::StashDialog(QWidget *parent) : - QDialog(parent), +StashDialog::StashDialog(QWidget *parent) : QDialog(parent), ui(new Ui::StashDialog), m_model(new StashModel), m_proxyModel(new QSortFilterProxyModel), @@ -175,7 +169,7 @@ void StashDialog::refresh(const QString &repository, bool force) m_model->setStashes(QList<Stash>()); } else { QList<Stash> stashes; - gitClient()->synchronousStashList(m_repository, &stashes); + GitPlugin::client()->synchronousStashList(m_repository, &stashes); m_model->setStashes(stashes); if (!stashes.isEmpty()) { for (int c = 0; c < ColumnCount; c++) @@ -191,7 +185,7 @@ void StashDialog::deleteAll() if (!ask(title, tr("Do you want to delete all stashes?"))) return; QString errorMessage; - if (gitClient()->synchronousStashRemove(m_repository, QString(), &errorMessage)) + if (GitPlugin::client()->synchronousStashRemove(m_repository, QString(), &errorMessage)) refresh(m_repository, true); else warning(title, errorMessage); @@ -208,7 +202,7 @@ void StashDialog::deleteSelection() QStringList errors; // Delete in reverse order as stashes rotate for (int r = rows.size() - 1; r >= 0; r--) - if (!gitClient()->synchronousStashRemove(m_repository, m_model->at(rows.at(r)).name, &errorMessage)) + if (!GitPlugin::client()->synchronousStashRemove(m_repository, m_model->at(rows.at(r)).name, &errorMessage)) errors.push_back(errorMessage); refresh(m_repository, true); if (!errors.isEmpty()) @@ -219,7 +213,7 @@ void StashDialog::showCurrent() { const int index = currentRow(); QTC_ASSERT(index >= 0, return); - gitClient()->show(m_repository, QString(m_model->at(index).name)); + GitPlugin::client()->show(m_repository, QString(m_model->at(index).name)); } // Suggest Branch name to restore 'stash@{0}' -> 'stash0-date' @@ -280,7 +274,7 @@ bool StashDialog::promptForRestore(QString *stash, { const QString stashIn = *stash; bool modifiedPromptShown = false; - switch (gitClient()->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules), 0, errorMessage)) { + switch (GitPlugin::client()->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules), 0, errorMessage)) { case GitClient::StatusFailed: return false; case GitClient::StatusChanged: { @@ -288,13 +282,13 @@ bool StashDialog::promptForRestore(QString *stash, case ModifiedRepositoryCancel: return false; case ModifiedRepositoryStash: - if (gitClient()->synchronousStash(m_repository, QString(), GitClient::StashPromptDescription).isEmpty()) + if (GitPlugin::client()->synchronousStash(m_repository, QString(), GitClient::StashPromptDescription).isEmpty()) return false; *stash = nextStash(*stash); // Our stash id to be restored changed QTC_ASSERT(!stash->isEmpty(), return false); break; case ModifiedRepositoryDiscard: - if (!gitClient()->synchronousReset(m_repository)) + if (!GitPlugin::client()->synchronousReset(m_repository)) return false; break; } @@ -331,7 +325,7 @@ void StashDialog::restoreCurrent() // Make sure repository is not modified, restore. The command will // output to window on success. if (promptForRestore(&name, 0, &errorMessage) - && gitClient()->synchronousStashRestore(m_repository, name)) { + && GitPlugin::client()->synchronousStashRestore(m_repository, name)) { refresh(m_repository, true); // Might have stashed away local changes. } else if (!errorMessage.isEmpty()) { warning(msgRestoreFailedTitle(name), errorMessage); @@ -346,7 +340,7 @@ void StashDialog::restoreCurrentInBranch() QString branch; QString name = m_model->at(index).name; if (promptForRestore(&name, &branch, &errorMessage) - && gitClient()->synchronousStashRestore(m_repository, name, false, branch)) { + && GitPlugin::client()->synchronousStashRestore(m_repository, name, false, branch)) { refresh(m_repository, true); // git deletes the stash, unfortunately. } else if (!errorMessage.isEmpty()) { warning(msgRestoreFailedTitle(name), errorMessage); diff --git a/src/plugins/git/stashdialog.h b/src/plugins/git/stashdialog.h index be00e02e8b..400c67a3a4 100644 --- a/src/plugins/git/stashdialog.h +++ b/src/plugins/git/stashdialog.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef STASHDIALOG_H -#define STASHDIALOG_H +#pragma once #include <QDialog> @@ -51,11 +50,10 @@ class StashDialog : public QDialog public: explicit StashDialog(QWidget *parent = 0); - ~StashDialog(); + ~StashDialog() override; static QString msgRepositoryLabel(const QString &repository); -public slots: void refresh(const QString &repository, bool force); private: @@ -95,5 +93,3 @@ private: } // namespace Internal } // namespace Git - -#endif // STASHDIALOG_H |