Git: Modernize

* Use auto
* Use override
* Use some member initializers

Change-Id: I3ca000d1c8e4d02331d58b85e68e4d771c636b29
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2018-09-18 15:53:35 +03:00
committed by Orgad Shaneh
parent c83b5afa9b
commit 202d40f256
37 changed files with 68 additions and 74 deletions

View File

@@ -36,7 +36,7 @@ class GitAnnotationHighlighter : public VcsBase::BaseAnnotationHighlighter
Q_OBJECT Q_OBJECT
public: public:
explicit GitAnnotationHighlighter(const ChangeNumbers &changeNumbers, explicit GitAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document = 0); QTextDocument *document = nullptr);
private: private:
QString changeNumber(const QString &block) const override; QString changeNumber(const QString &block) const override;

View File

@@ -46,7 +46,7 @@ namespace Internal {
class BranchNameValidator : public QValidator class BranchNameValidator : public QValidator
{ {
public: public:
BranchNameValidator(const QStringList &localBranches, QObject *parent = 0) : BranchNameValidator(const QStringList &localBranches, QObject *parent = nullptr) :
QValidator(parent), QValidator(parent),
m_invalidChars(GitPlugin::invalidBranchAndRemoteNamePattern()), m_invalidChars(GitPlugin::invalidBranchAndRemoteNamePattern()),
m_localBranches(localBranches) m_localBranches(localBranches)

View File

@@ -33,9 +33,7 @@ BranchCheckoutDialog::BranchCheckoutDialog(QWidget *parent,
const QString &currentBranch, const QString &currentBranch,
const QString &nextBranch) : const QString &nextBranch) :
QDialog(parent), QDialog(parent),
m_ui(new Ui::BranchCheckoutDialog), m_ui(new Ui::BranchCheckoutDialog)
m_foundStashForNextBranch(false),
m_hasLocalChanges(true)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);

View File

@@ -56,8 +56,8 @@ private:
void updatePopStashCheckBox(bool moveChangesChecked); void updatePopStashCheckBox(bool moveChangesChecked);
Ui::BranchCheckoutDialog *m_ui; Ui::BranchCheckoutDialog *m_ui;
bool m_foundStashForNextBranch; bool m_foundStashForNextBranch = false;
bool m_hasLocalChanges; bool m_hasLocalChanges = true;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -204,7 +204,7 @@ void ChangeSelectionDialog::terminateProcess()
m_process->kill(); m_process->kill();
m_process->waitForFinished(); m_process->waitForFinished();
delete m_process; delete m_process;
m_process = 0; m_process = nullptr;
} }
void ChangeSelectionDialog::recalculateCompletion() void ChangeSelectionDialog::recalculateCompletion()

View File

@@ -64,8 +64,6 @@ QString GitSubmitEditorPanelData::authorString() const
CommitData::CommitData(CommitType type) CommitData::CommitData(CommitType type)
: commitType(type) : commitType(type)
, commitEncoding(0)
, enablePush(false)
{ {
} }

View File

@@ -105,10 +105,10 @@ public:
CommitType commitType; CommitType commitType;
QString amendSHA1; QString amendSHA1;
QTextCodec *commitEncoding; QTextCodec *commitEncoding = nullptr;
GitSubmitEditorPanelInfo panelInfo; GitSubmitEditorPanelInfo panelInfo;
GitSubmitEditorPanelData panelData; GitSubmitEditorPanelData panelData;
bool enablePush; bool enablePush = false;
QList<StateFilePair> files; QList<StateFilePair> files;

View File

@@ -45,7 +45,7 @@ class AuthenticationDialog : public QDialog
public: public:
AuthenticationDialog(GerritServer *server); AuthenticationDialog(GerritServer *server);
~AuthenticationDialog(); ~AuthenticationDialog() override;
bool isAuthenticated() const { return m_authenticated; } bool isAuthenticated() const { return m_authenticated; }
private: private:

View File

@@ -69,7 +69,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
m_ui->remoteComboBox->setParameters(m_parameters); m_ui->remoteComboBox->setParameters(m_parameters);
m_ui->remoteComboBox->setFallbackEnabled(true); m_ui->remoteComboBox->setFallbackEnabled(true);
m_queryModel->setStringList(m_parameters->savedQueries); m_queryModel->setStringList(m_parameters->savedQueries);
QCompleter *completer = new QCompleter(this); auto completer = new QCompleter(this);
completer->setModel(m_queryModel); completer->setModel(m_queryModel);
m_ui->queryLineEdit->setSpecialCompleter(completer); m_ui->queryLineEdit->setSpecialCompleter(completer);
m_ui->queryLineEdit->setOkColor(Utils::creatorTheme()->color(Utils::Theme::TextColorNormal)); m_ui->queryLineEdit->setOkColor(Utils::creatorTheme()->color(Utils::Theme::TextColorNormal));

View File

@@ -56,7 +56,7 @@ public:
const QSharedPointer<GerritServer> &s, const QSharedPointer<GerritServer> &s,
const QString &repository, const QString &repository,
QWidget *parent = nullptr); QWidget *parent = nullptr);
~GerritDialog(); ~GerritDialog() override;
QString repositoryPath() const; QString repositoryPath() const;
void setCurrentPath(const QString &path); void setCurrentPath(const QString &path);
void fetchStarted(const QSharedPointer<Gerrit::Internal::GerritChange> &change); void fetchStarted(const QSharedPointer<Gerrit::Internal::GerritChange> &change);

View File

@@ -227,7 +227,7 @@ public:
const GerritServer &server, const GerritServer &server,
QObject *parent = nullptr); QObject *parent = nullptr);
~QueryContext(); ~QueryContext() override;
void start(); void start();
void terminate(); void terminate();
@@ -845,7 +845,7 @@ QList<QStandardItem *> GerritModel::changeToRow(const GerritChangePtr &c) const
const QVariant filterV = QVariant(c->filterString()); const QVariant filterV = QVariant(c->filterString());
const QVariant changeV = qVariantFromValue(c); const QVariant changeV = qVariantFromValue(c);
for (int i = 0; i < GerritModel::ColumnCount; ++i) { for (int i = 0; i < GerritModel::ColumnCount; ++i) {
QStandardItem *item = new QStandardItem; auto item = new QStandardItem;
item->setData(changeV, GerritModel::GerritChangeRole); item->setData(changeV, GerritModel::GerritChangeRole);
item->setData(filterV, GerritModel::FilterRole); item->setData(filterV, GerritModel::FilterRole);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

View File

@@ -105,7 +105,7 @@ public:
SortRole = Qt::UserRole + 3 SortRole = Qt::UserRole + 3
}; };
GerritModel(const QSharedPointer<GerritParameters> &, QObject *parent = nullptr); GerritModel(const QSharedPointer<GerritParameters> &, QObject *parent = nullptr);
~GerritModel(); ~GerritModel() override;
QVariant data(const QModelIndex &index, int role) const override; QVariant data(const QModelIndex &index, int role) const override;

View File

@@ -91,7 +91,7 @@ GerritOptionsWidget::GerritOptionsWidget(QWidget *parent)
, m_portSpinBox(new QSpinBox(this)) , m_portSpinBox(new QSpinBox(this))
, m_httpsCheckBox(new QCheckBox(tr("HTTPS"))) , m_httpsCheckBox(new QCheckBox(tr("HTTPS")))
{ {
QFormLayout *formLayout = new QFormLayout(this); auto formLayout = new QFormLayout(this);
formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
formLayout->addRow(tr("&Host:"), m_hostLineEdit); formLayout->addRow(tr("&Host:"), m_hostLineEdit);
formLayout->addRow(tr("&User:"), m_userLineEdit); formLayout->addRow(tr("&User:"), m_userLineEdit);

View File

@@ -67,7 +67,7 @@ class GerritOptionsPage : public VcsBase::VcsBaseOptionsPage
public: public:
GerritOptionsPage(const QSharedPointer<GerritParameters> &p, QObject *parent = nullptr); GerritOptionsPage(const QSharedPointer<GerritParameters> &p, QObject *parent = nullptr);
~GerritOptionsPage(); ~GerritOptionsPage() override;
QWidget *widget() override; QWidget *widget() override;
void apply() override; void apply() override;

View File

@@ -99,8 +99,7 @@ void GerritParameters::setPortFlagBySshType()
} }
GerritParameters::GerritParameters() GerritParameters::GerritParameters()
: https(true) : portFlag(defaultPortFlag)
, portFlag(defaultPortFlag)
{ {
} }

View File

@@ -50,7 +50,7 @@ public:
QString ssh; QString ssh;
QString curl; QString curl;
QStringList savedQueries; QStringList savedQueries;
bool https; bool https = true;
QString portFlag; QString portFlag;
}; };

View File

@@ -94,7 +94,7 @@ public:
const QString &repository, const Utils::FileName &git, const QString &repository, const Utils::FileName &git,
const GerritServer &server, const GerritServer &server,
FetchMode fm, QObject *parent = nullptr); FetchMode fm, QObject *parent = nullptr);
~FetchContext(); ~FetchContext() override;
void start(); void start();
private: private:
@@ -467,8 +467,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
if (repository.isEmpty()) if (repository.isEmpty())
return; return;
FetchContext *fc = new FetchContext(change, repository, git, auto fc = new FetchContext(change, repository, git, *m_server, FetchMode(mode), this);
*m_server, FetchMode(mode), this);
connect(fc, &QObject::destroyed, this, &GerritPlugin::fetchFinished); connect(fc, &QObject::destroyed, this, &GerritPlugin::fetchFinished);
emit fetchStarted(change); emit fetchStarted(change);
fc->start(); fc->start();

View File

@@ -53,7 +53,7 @@ class GerritPlugin : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit GerritPlugin(QObject *parent = nullptr); explicit GerritPlugin(QObject *parent = nullptr);
~GerritPlugin(); ~GerritPlugin() override;
bool initialize(Core::ActionContainer *ac); bool initialize(Core::ActionContainer *ac);

View File

@@ -135,7 +135,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
m_ui->remoteComboBox->setParameters(parameters); m_ui->remoteComboBox->setParameters(parameters);
m_ui->remoteComboBox->setAllowDups(true); m_ui->remoteComboBox->setAllowDups(true);
PushItemDelegate *delegate = new PushItemDelegate(m_ui->commitView); auto delegate = new PushItemDelegate(m_ui->commitView);
delegate->setParent(this); delegate->setParent(this);
initRemoteBranches(); initRemoteBranches();

View File

@@ -48,7 +48,7 @@ class GerritPushDialog : public QDialog
public: public:
GerritPushDialog(const QString &workingDir, const QString &reviewerList, GerritPushDialog(const QString &workingDir, const QString &reviewerList,
QSharedPointer<GerritParameters> parameters, QWidget *parent); QSharedPointer<GerritParameters> parameters, QWidget *parent);
~GerritPushDialog(); ~GerritPushDialog() override;
QString selectedCommit() const; QString selectedCommit() const;
QString selectedRemoteName() const; QString selectedRemoteName() const;

View File

@@ -139,7 +139,7 @@ static QString branchesDisplay(const QString &prefix, QStringList *branches, boo
//: Displayed after the untranslated message "Branches: branch1, branch2 'and %n more'" //: Displayed after the untranslated message "Branches: branch1, branch2 'and %n more'"
// in git show. // in git show.
if (more > 0) if (more > 0)
output += ' ' + GitClient::tr("and %n more", 0, more); output += ' ' + GitClient::tr("and %n more", nullptr, more);
return output; return output;
} }
@@ -187,7 +187,7 @@ bool DescriptionWidgetDecorator::eventFilter(QObject *watched, QEvent *event)
return QObject::eventFilter(watched, event); return QObject::eventFilter(watched, event);
if (event->type() == QEvent::MouseMove) { if (event->type() == QEvent::MouseMove) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); auto mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->buttons()) if (mouseEvent->buttons())
return QObject::eventFilter(watched, event); return QObject::eventFilter(watched, event);
@@ -207,7 +207,7 @@ bool DescriptionWidgetDecorator::eventFilter(QObject *watched, QEvent *event)
textEditor->viewport()->setCursor(cursorShape); textEditor->viewport()->setCursor(cursorShape);
return ret; return ret;
} else if (event->type() == QEvent::MouseButtonRelease) { } else if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); auto mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::LeftButton && !(mouseEvent->modifiers() & Qt::ShiftModifier)) { if (mouseEvent->button() == Qt::LeftButton && !(mouseEvent->modifiers() & Qt::ShiftModifier)) {
const QTextCursor cursor = textEditor->cursorForPosition(mouseEvent->pos()); const QTextCursor cursor = textEditor->cursorForPosition(mouseEvent->pos());
@@ -624,12 +624,12 @@ public:
} }
}; };
class ConflictHandler : public QObject class ConflictHandler final : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
static void attachToCommand(VcsCommand *command, const QString &abortCommand = QString()) { static void attachToCommand(VcsCommand *command, const QString &abortCommand = QString()) {
ConflictHandler *handler = new ConflictHandler(command->defaultWorkingDirectory(), abortCommand); auto handler = new ConflictHandler(command->defaultWorkingDirectory(), abortCommand);
handler->setParent(command); // delete when command goes out of scope handler->setParent(command); // delete when command goes out of scope
command->addFlags(VcsCommand::ExpectRepoChanges); command->addFlags(VcsCommand::ExpectRepoChanges);
@@ -655,7 +655,7 @@ private:
m_abortCommand(abortCommand) m_abortCommand(abortCommand)
{ } { }
~ConflictHandler() ~ConflictHandler() final
{ {
// If interactive rebase editor window is closed, plugin is terminated // If interactive rebase editor window is closed, plugin is terminated
// but referenced here when the command ends // but referenced here when the command ends
@@ -1296,7 +1296,7 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
if (files.isEmpty()) { if (files.isEmpty()) {
msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage); msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage);
} else { } else {
msgCannotRun(tr("Cannot reset %n files in \"%1\": %2", 0, files.size()) msgCannotRun(tr("Cannot reset %n files in \"%1\": %2", nullptr, files.size())
.arg(QDir::toNativeSeparators(workingDirectory), resp.stdErr()), .arg(QDir::toNativeSeparators(workingDirectory), resp.stdErr()),
errorMessage); errorMessage);
} }
@@ -2632,9 +2632,9 @@ bool GitClient::getCommitData(const QString &workingDirectory,
static inline QString msgCommitted(const QString &amendSHA1, int fileCount) static inline QString msgCommitted(const QString &amendSHA1, int fileCount)
{ {
if (amendSHA1.isEmpty()) if (amendSHA1.isEmpty())
return GitClient::tr("Committed %n files.", 0, fileCount) + '\n'; return GitClient::tr("Committed %n files.", nullptr, fileCount) + '\n';
if (fileCount) if (fileCount)
return GitClient::tr("Amended \"%1\" (%n files).", 0, fileCount).arg(amendSHA1) + '\n'; return GitClient::tr("Amended \"%1\" (%n files).", nullptr, fileCount).arg(amendSHA1) + '\n';
return GitClient::tr("Amended \"%1\".").arg(amendSHA1); return GitClient::tr("Amended \"%1\".").arg(amendSHA1);
} }
@@ -2725,7 +2725,7 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
VcsOutputWindow::appendError(stdErr); VcsOutputWindow::appendError(stdErr);
return true; return true;
} else { } else {
VcsOutputWindow::appendError(tr("Cannot commit %n files: %1\n", 0, commitCount).arg(stdErr)); VcsOutputWindow::appendError(tr("Cannot commit %n files: %1\n", nullptr, commitCount).arg(stdErr));
return false; return false;
} }
} }
@@ -3241,9 +3241,9 @@ unsigned GitClient::synchronousGitVersion(QString *errorMessage) const
QRegExp versionPattern("^[^\\d]+(\\d+)\\.(\\d+)\\.(\\d+|rc\\d).*$"); QRegExp versionPattern("^[^\\d]+(\\d+)\\.(\\d+)\\.(\\d+|rc\\d).*$");
QTC_ASSERT(versionPattern.isValid(), return 0); QTC_ASSERT(versionPattern.isValid(), return 0);
QTC_ASSERT(versionPattern.exactMatch(output), return 0); QTC_ASSERT(versionPattern.exactMatch(output), return 0);
const unsigned majorV = versionPattern.cap(1).toUInt(0, 16); const unsigned majorV = versionPattern.cap(1).toUInt(nullptr, 16);
const unsigned minorV = versionPattern.cap(2).toUInt(0, 16); const unsigned minorV = versionPattern.cap(2).toUInt(nullptr, 16);
const unsigned patchV = versionPattern.cap(3).toUInt(0, 16); const unsigned patchV = versionPattern.cap(3).toUInt(nullptr, 16);
return version(majorV, minorV, patchV); return version(majorV, minorV, patchV);
} }

View File

@@ -214,7 +214,7 @@ static bool isGitDirectory(const QString &path)
{ {
static IVersionControl *gitVc = VcsManager::versionControl(VcsBase::Constants::VCS_ID_GIT); static IVersionControl *gitVc = VcsManager::versionControl(VcsBase::Constants::VCS_ID_GIT);
QTC_ASSERT(gitVc, return false); QTC_ASSERT(gitVc, return false);
return gitVc == VcsManager::findVersionControlForDirectory(path, 0); return gitVc == VcsManager::findVersionControlForDirectory(path, nullptr);
} }
GitGrep::GitGrep(QObject *parent) GitGrep::GitGrep(QObject *parent)
@@ -303,7 +303,8 @@ IEditor *GitGrep::openEditor(const SearchResultItem &item,
if (content.isEmpty()) if (content.isEmpty())
return nullptr; return nullptr;
QByteArray fileContent; QByteArray fileContent;
if (TextFileFormat::readFileUTF8(path, 0, &fileContent, 0) == TextFileFormat::ReadSuccess) { if (TextFileFormat::readFileUTF8(path, nullptr, &fileContent, nullptr)
== TextFileFormat::ReadSuccess) {
if (fileContent == content) if (fileContent == content)
return nullptr; // open the file for read/write return nullptr; // open the file for read/write
} }

View File

@@ -46,7 +46,7 @@ GitSubmitHighlighter::GitSubmitHighlighter(QTextEdit * parent) :
void GitSubmitHighlighter::highlightBlock(const QString &text) void GitSubmitHighlighter::highlightBlock(const QString &text)
{ {
// figure out current state // figure out current state
State state = static_cast<State>(previousBlockState()); auto state = static_cast<State>(previousBlockState());
if (text.trimmed().isEmpty()) { if (text.trimmed().isEmpty()) {
if (state == Header) if (state == Header)
state = Other; state = Other;

View File

@@ -51,7 +51,7 @@ enum Format {
class GitSubmitHighlighter : public TextEditor::SyntaxHighlighter class GitSubmitHighlighter : public TextEditor::SyntaxHighlighter
{ {
public: public:
explicit GitSubmitHighlighter(QTextEdit *parent = 0); explicit GitSubmitHighlighter(QTextEdit *parent = nullptr);
void highlightBlock(const QString &text) override; void highlightBlock(const QString &text) override;
private: private:
@@ -65,7 +65,7 @@ private:
class GitRebaseHighlighter : public TextEditor::SyntaxHighlighter class GitRebaseHighlighter : public TextEditor::SyntaxHighlighter
{ {
public: public:
explicit GitRebaseHighlighter(QTextDocument *parent = 0); explicit GitRebaseHighlighter(QTextDocument *parent = nullptr);
void highlightBlock(const QString &text) override; void highlightBlock(const QString &text) override;
private: private:

View File

@@ -128,7 +128,7 @@ const VcsBaseEditorParameters editorParameters[] = {
// GitPlugin // GitPlugin
static GitPlugin *m_instance = 0; static GitPlugin *m_instance = nullptr;
GitPlugin::GitPlugin() GitPlugin::GitPlugin()
{ {
@@ -142,7 +142,7 @@ GitPlugin::~GitPlugin()
{ {
cleanCommitMessageFile(); cleanCommitMessageFile();
delete m_gitClient; delete m_gitClient;
m_instance = 0; m_instance = nullptr;
} }
void GitPlugin::cleanCommitMessageFile() void GitPlugin::cleanCommitMessageFile()
@@ -986,8 +986,8 @@ void GitPlugin::updateVersionWarning()
IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &cd) IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &cd)
{ {
IEditor *editor = EditorManager::openEditor(fileName, Constants::GITSUBMITEDITOR_ID); IEditor *editor = EditorManager::openEditor(fileName, Constants::GITSUBMITEDITOR_ID);
GitSubmitEditor *submitEditor = qobject_cast<GitSubmitEditor*>(editor); auto submitEditor = qobject_cast<GitSubmitEditor*>(editor);
QTC_ASSERT(submitEditor, return 0); QTC_ASSERT(submitEditor, return nullptr);
setSubmitEditor(submitEditor); setSubmitEditor(submitEditor);
submitEditor->setCommitData(cd); submitEditor->setCommitData(cd);
submitEditor->setCheckScriptWorkingDirectory(m_submitRepository); submitEditor->setCheckScriptWorkingDirectory(m_submitRepository);
@@ -1020,7 +1020,7 @@ bool GitPlugin::submitEditorAboutToClose()
{ {
if (!isCommitEditorOpen()) if (!isCommitEditorOpen())
return true; return true;
GitSubmitEditor *editor = qobject_cast<GitSubmitEditor *>(submitEditor()); auto editor = qobject_cast<GitSubmitEditor *>(submitEditor());
QTC_ASSERT(editor, return true); QTC_ASSERT(editor, return true);
IDocument *editorDocument = editor->document(); IDocument *editorDocument = editor->document();
QTC_ASSERT(editorDocument, return true); QTC_ASSERT(editorDocument, return true);
@@ -1052,7 +1052,7 @@ bool GitPlugin::submitEditorAboutToClose()
// Go ahead! // Go ahead!
SubmitFileModel *model = qobject_cast<SubmitFileModel *>(editor->fileModel()); auto model = qobject_cast<SubmitFileModel *>(editor->fileModel());
CommitType commitType = editor->commitType(); CommitType commitType = editor->commitType();
QString amendSHA1 = editor->amendSHA1(); QString amendSHA1 = editor->amendSHA1();
if (model->hasCheckedFiles() || !amendSHA1.isEmpty()) { if (model->hasCheckedFiles() || !amendSHA1.isEmpty()) {

View File

@@ -74,7 +74,7 @@ class GitPlugin : public VcsBase::VcsBasePlugin
public: public:
GitPlugin(); GitPlugin();
~GitPlugin(); ~GitPlugin() override;
static GitPlugin *instance(); static GitPlugin *instance();
static GitClient *client(); static GitClient *client();

View File

@@ -51,13 +51,13 @@ namespace Internal {
class GitSubmitFileModel : public SubmitFileModel class GitSubmitFileModel : public SubmitFileModel
{ {
public: public:
GitSubmitFileModel(QObject *parent = 0) : SubmitFileModel(parent) GitSubmitFileModel(QObject *parent = nullptr) : SubmitFileModel(parent)
{ } { }
void updateSelections(SubmitFileModel *source) override void updateSelections(SubmitFileModel *source) override
{ {
QTC_ASSERT(source, return); QTC_ASSERT(source, return);
GitSubmitFileModel *gitSource = static_cast<GitSubmitFileModel *>(source); auto gitSource = static_cast<GitSubmitFileModel *>(source);
int j = 0; int j = 0;
for (int i = 0; i < rowCount() && j < source->rowCount(); ++i) { for (int i = 0; i < rowCount() && j < source->rowCount(); ++i) {
CommitData::StateFilePair stateFile = stateFilePair(i); CommitData::StateFilePair stateFile = stateFilePair(i);

View File

@@ -74,7 +74,7 @@ bool inputText(QWidget *parent, const QString &title, const QString &prompt, QSt
dialog.setLabelText(prompt); dialog.setLabelText(prompt);
dialog.setTextValue(*s); dialog.setTextValue(*s);
// Nasty hack: // Nasty hack:
if (QLineEdit *le = dialog.findChild<QLineEdit*>()) if (auto le = dialog.findChild<QLineEdit*>())
le->setMinimumWidth(500); le->setMinimumWidth(500);
if (dialog.exec() != QDialog::Accepted) if (dialog.exec() != QDialog::Accepted)
return false; return false;

View File

@@ -159,7 +159,7 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm
arguments << "--not" << "--remotes"; arguments << "--not" << "--remotes";
arguments << "--"; arguments << "--";
QString output; QString output;
if (!GitPlugin::client()->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput)) if (!GitPlugin::client()->synchronousLog(repository, arguments, &output, nullptr, VcsCommand::NoOutput))
return false; return false;
const QStringList lines = output.split('\n'); const QStringList lines = output.split('\n');
for (const QString &line : lines) { for (const QString &line : lines) {
@@ -193,14 +193,13 @@ const QStandardItem *LogChangeWidget::currentItem(int column) const
const QModelIndex currentIndex = selectionModel()->currentIndex(); const QModelIndex currentIndex = selectionModel()->currentIndex();
if (currentIndex.isValid()) if (currentIndex.isValid())
return m_model->item(currentIndex.row(), column); return m_model->item(currentIndex.row(), column);
return 0; return nullptr;
} }
LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) : LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) :
QDialog(parent) QDialog(parent)
, m_widget(new LogChangeWidget) , m_widget(new LogChangeWidget)
, m_dialogButtonBox(new QDialogButtonBox(this)) , m_dialogButtonBox(new QDialogButtonBox(this))
, m_resetTypeComboBox(0)
{ {
auto layout = new QVBoxLayout(this); auto layout = new QVBoxLayout(this);
layout->addWidget(new QLabel(isReset ? tr("Reset to:") : tr("Select change:"), this)); layout->addWidget(new QLabel(isReset ? tr("Reset to:") : tr("Select change:"), this));

View File

@@ -96,9 +96,9 @@ public:
LogChangeWidget *widget() const; LogChangeWidget *widget() const;
private: private:
LogChangeWidget *m_widget; LogChangeWidget *m_widget = nullptr;
QDialogButtonBox *m_dialogButtonBox; QDialogButtonBox *m_dialogButtonBox = nullptr;
QComboBox *m_resetTypeComboBox; QComboBox *m_resetTypeComboBox = nullptr;
}; };
class LogItemDelegate : public QStyledItemDelegate class LogItemDelegate : public QStyledItemDelegate

View File

@@ -50,8 +50,8 @@ class MergeTool : public QObject
}; };
public: public:
explicit MergeTool(QObject *parent = 0); explicit MergeTool(QObject *parent = nullptr);
~MergeTool(); ~MergeTool() override;
bool start(const QString &workingDirectory, const QStringList &files = QStringList()); bool start(const QString &workingDirectory, const QStringList &files = QStringList());
enum MergeType { enum MergeType {

View File

@@ -39,7 +39,7 @@ class RemoteDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit RemoteDialog(QWidget *parent = 0); explicit RemoteDialog(QWidget *parent = nullptr);
~RemoteDialog() override; ~RemoteDialog() override;
void refresh(const QString &repository, bool force); void refresh(const QString &repository, bool force);

View File

@@ -35,7 +35,7 @@ namespace Internal {
class RemoteModel : public QAbstractTableModel { class RemoteModel : public QAbstractTableModel {
Q_OBJECT Q_OBJECT
public: public:
explicit RemoteModel(QObject *parent = 0); explicit RemoteModel(QObject *parent = nullptr);
void clear(); void clear();
bool refresh(const QString &workingDirectory, QString *errorMessage); bool refresh(const QString &workingDirectory, QString *errorMessage);

View File

@@ -120,7 +120,7 @@ void SettingsPage::apply()
if (widget()->isVisible()) { if (widget()->isVisible()) {
const VcsBaseClientSettings settings = widget()->settings(); const VcsBaseClientSettings settings = widget()->settings();
const GitSettings *rc = static_cast<const GitSettings *>(&settings); auto rc = static_cast<const GitSettings *>(&settings);
bool gitFoundOk; bool gitFoundOk;
QString errorMessage; QString errorMessage;
rc->gitExecutable(&gitFoundOk, &errorMessage); rc->gitExecutable(&gitFoundOk, &errorMessage);

View File

@@ -43,7 +43,7 @@ class SettingsPageWidget : public VcsBase::VcsClientOptionsPageWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit SettingsPageWidget(QWidget *parent = 0); explicit SettingsPageWidget(QWidget *parent = nullptr);
VcsBase::VcsBaseClientSettings settings() const override; VcsBase::VcsBaseClientSettings settings() const override;
void setSettings(const VcsBase::VcsBaseClientSettings &s) override; void setSettings(const VcsBase::VcsBaseClientSettings &s) override;

View File

@@ -63,7 +63,7 @@ static inline QList<QStandardItem*> stashModelRowItems(const Stash &s)
// ----------- StashModel // ----------- StashModel
class StashModel : public QStandardItemModel { class StashModel : public QStandardItemModel {
public: public:
explicit StashModel(QObject *parent = 0); explicit StashModel(QObject *parent = nullptr);
void setStashes(const QList<Stash> &stashes); void setStashes(const QList<Stash> &stashes);
const Stash &at(int i) { return m_stashes.at(i); } const Stash &at(int i) { return m_stashes.at(i); }
@@ -189,7 +189,7 @@ void StashDialog::deleteSelection()
const QList<int> rows = selectedRows(); const QList<int> rows = selectedRows();
QTC_ASSERT(!rows.isEmpty(), return); QTC_ASSERT(!rows.isEmpty(), return);
const QString title = tr("Delete Stashes"); const QString title = tr("Delete Stashes");
if (!ask(title, tr("Do you want to delete %n stash(es)?", 0, rows.size()))) if (!ask(title, tr("Do you want to delete %n stash(es)?", nullptr, rows.size())))
return; return;
QString errorMessage; QString errorMessage;
QStringList errors; QStringList errors;
@@ -267,7 +267,7 @@ bool StashDialog::promptForRestore(QString *stash,
{ {
const QString stashIn = *stash; const QString stashIn = *stash;
bool modifiedPromptShown = false; bool modifiedPromptShown = false;
switch (GitPlugin::client()->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules), 0, errorMessage)) { switch (GitPlugin::client()->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules), nullptr, errorMessage)) {
case GitClient::StatusFailed: case GitClient::StatusFailed:
return false; return false;
case GitClient::StatusChanged: { case GitClient::StatusChanged: {
@@ -317,7 +317,7 @@ void StashDialog::restoreCurrent()
QString name = m_model->at(index).name; QString name = m_model->at(index).name;
// Make sure repository is not modified, restore. The command will // Make sure repository is not modified, restore. The command will
// output to window on success. // output to window on success.
if (promptForRestore(&name, 0, &errorMessage) if (promptForRestore(&name, nullptr, &errorMessage)
&& GitPlugin::client()->synchronousStashRestore(m_repository, name)) { && GitPlugin::client()->synchronousStashRestore(m_repository, name)) {
refresh(m_repository, true); // Might have stashed away local changes. refresh(m_repository, true); // Might have stashed away local changes.
} else if (!errorMessage.isEmpty()) { } else if (!errorMessage.isEmpty()) {

View File

@@ -48,7 +48,7 @@ class StashDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit StashDialog(QWidget *parent = 0); explicit StashDialog(QWidget *parent = nullptr);
~StashDialog() override; ~StashDialog() override;
void refresh(const QString &repository, bool force); void refresh(const QString &repository, bool force);