diff options
author | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2016-02-10 14:14:06 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2016-02-10 13:32:50 +0000 |
commit | 8b46136b60f30e2cdbd64bcfc62db47bc077f2a6 (patch) | |
tree | 01fa13203f59b7a2d4cb48a48fbd23bc5ee8d6f1 /src/plugins/perforce | |
parent | 84f2875f6d410588bd01f1d3a573b1ec0f02ef3c (diff) |
Perforce: Modernize
* use pragma once
* remove debug code
* Remove some "slots"
* Use Qt5 style connects (almost everywhere)
Change-Id: Iaa9c3bbacbb2be3c96502c52cc169ad4ec7015a5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/perforce')
24 files changed, 113 insertions, 298 deletions
diff --git a/src/plugins/perforce/annotationhighlighter.cpp b/src/plugins/perforce/annotationhighlighter.cpp index e36d21c0b38..e57f52af46e 100644 --- a/src/plugins/perforce/annotationhighlighter.cpp +++ b/src/plugins/perforce/annotationhighlighter.cpp @@ -30,14 +30,12 @@ namespace Internal { PerforceAnnotationHighlighter::PerforceAnnotationHighlighter(const ChangeNumbers &changeNumbers, QTextDocument *document) : - VcsBase::BaseAnnotationHighlighter(changeNumbers, document), - m_colon(QLatin1Char(':')) -{ -} + VcsBase::BaseAnnotationHighlighter(changeNumbers, document) +{ } QString PerforceAnnotationHighlighter::changeNumber(const QString &block) const { - const int pos = block.indexOf(m_colon); + const int pos = block.indexOf(QLatin1Char(':')); return pos > 1 ? block.left(pos) : QString(); } diff --git a/src/plugins/perforce/annotationhighlighter.h b/src/plugins/perforce/annotationhighlighter.h index 5bd3b989f0f..68d626c274f 100644 --- a/src/plugins/perforce/annotationhighlighter.h +++ b/src/plugins/perforce/annotationhighlighter.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef ANNOTATIONHIGHLIGHTER_H -#define ANNOTATIONHIGHLIGHTER_H +#pragma once #include <vcsbase/baseannotationhighlighter.h> @@ -37,15 +36,11 @@ class PerforceAnnotationHighlighter : public VcsBase::BaseAnnotationHighlighter Q_OBJECT public: explicit PerforceAnnotationHighlighter(const ChangeNumbers &changeNumbers, - QTextDocument *document = 0); + QTextDocument *document = nullptr); private: - QString changeNumber(const QString &block) const; - - const QChar m_colon; + QString changeNumber(const QString &block) const override; }; } // namespace Perforce } // namespace Internal - -#endif // ANNOTATIONHIGHLIGHTER_H diff --git a/src/plugins/perforce/changenumberdialog.cpp b/src/plugins/perforce/changenumberdialog.cpp index 50e2cc87f6e..9978c959339 100644 --- a/src/plugins/perforce/changenumberdialog.cpp +++ b/src/plugins/perforce/changenumberdialog.cpp @@ -29,8 +29,7 @@ using namespace Perforce::Internal; -ChangeNumberDialog::ChangeNumberDialog(QWidget *parent) - : QDialog(parent) +ChangeNumberDialog::ChangeNumberDialog(QWidget *parent) : QDialog(parent) { m_ui.setupUi(this); m_ui.numberLineEdit->setValidator(new QIntValidator(0, 1000000, this)); diff --git a/src/plugins/perforce/changenumberdialog.h b/src/plugins/perforce/changenumberdialog.h index 2e4d3781408..43cef0d8897 100644 --- a/src/plugins/perforce/changenumberdialog.h +++ b/src/plugins/perforce/changenumberdialog.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef CHANGENUMBERDIALOG_H -#define CHANGENUMBERDIALOG_H +#pragma once #include <QDialog> @@ -38,7 +37,7 @@ class ChangeNumberDialog : public QDialog { Q_OBJECT public: - ChangeNumberDialog(QWidget *parent = 0); + ChangeNumberDialog(QWidget *parent = nullptr); int number() const; private: @@ -48,5 +47,3 @@ private: } // namespace Perforce } // namespace Internal - -#endif // CHANGENUMBERDIALOG_H diff --git a/src/plugins/perforce/pendingchangesdialog.cpp b/src/plugins/perforce/pendingchangesdialog.cpp index fcd4539d5a9..e70dc9f4c8e 100644 --- a/src/plugins/perforce/pendingchangesdialog.cpp +++ b/src/plugins/perforce/pendingchangesdialog.cpp @@ -30,8 +30,7 @@ using namespace Perforce::Internal; -PendingChangesDialog::PendingChangesDialog(const QString &data, QWidget *parent) - : QDialog(parent) +PendingChangesDialog::PendingChangesDialog(const QString &data, QWidget *parent) : QDialog(parent) { m_ui.setupUi(this); if (!data.isEmpty()) { diff --git a/src/plugins/perforce/pendingchangesdialog.h b/src/plugins/perforce/pendingchangesdialog.h index 859d9188491..0fca396c732 100644 --- a/src/plugins/perforce/pendingchangesdialog.h +++ b/src/plugins/perforce/pendingchangesdialog.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef PENDINGCHANGESDIALOG_H -#define PENDINGCHANGESDIALOG_H +#pragma once #include <QDialog> @@ -38,7 +37,7 @@ class PendingChangesDialog : public QDialog Q_OBJECT public: - explicit PendingChangesDialog(const QString &data, QWidget *parent = 0); + explicit PendingChangesDialog(const QString &data, QWidget *parent = nullptr); int changeNumber() const; private: @@ -47,6 +46,3 @@ private: } // namespace Perforce } // namespace Internal - -#endif // PENDINGCHANGESDIALOG_H - diff --git a/src/plugins/perforce/perforce.pro b/src/plugins/perforce/perforce.pro index 796a0c7a67d..9f7b07f58bd 100644 --- a/src/plugins/perforce/perforce.pro +++ b/src/plugins/perforce/perforce.pro @@ -8,7 +8,6 @@ HEADERS += \ changenumberdialog.h \ perforcesubmiteditor.h \ pendingchangesdialog.h \ - perforceconstants.h \ perforceversioncontrol.h \ perforcesettings.h \ annotationhighlighter.h \ diff --git a/src/plugins/perforce/perforce.qbs b/src/plugins/perforce/perforce.qbs index 1f5136c65cf..26ca73698d8 100644 --- a/src/plugins/perforce/perforce.qbs +++ b/src/plugins/perforce/perforce.qbs @@ -22,7 +22,6 @@ QtcPlugin { "perforce.qrc", "perforcechecker.cpp", "perforcechecker.h", - "perforceconstants.h", "perforceeditor.cpp", "perforceeditor.h", "perforceplugin.cpp", diff --git a/src/plugins/perforce/perforcechecker.cpp b/src/plugins/perforce/perforcechecker.cpp index b0e0f67449f..7c8c27e780d 100644 --- a/src/plugins/perforce/perforcechecker.cpp +++ b/src/plugins/perforce/perforcechecker.cpp @@ -24,7 +24,6 @@ ****************************************************************************/ #include "perforcechecker.h" -#include "perforceconstants.h" #include <utils/qtcassert.h> #include <utils/synchronousprocess.h> @@ -40,12 +39,7 @@ namespace Perforce { namespace Internal { -PerforceChecker::PerforceChecker(QObject *parent) : - QObject(parent), - m_timeOutMS(-1), - m_timedOut(false), - m_useOverideCursor(false), - m_isOverrideCursor(false) +PerforceChecker::PerforceChecker(QObject *parent) : QObject(parent) { connect(&m_process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), this, &PerforceChecker::slotError); diff --git a/src/plugins/perforce/perforcechecker.h b/src/plugins/perforce/perforcechecker.h index 180f8b96b62..b8680959833 100644 --- a/src/plugins/perforce/perforcechecker.h +++ b/src/plugins/perforce/perforcechecker.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef PERFORCECHECKER_H -#define PERFORCECHECKER_H +#pragma once #include <QObject> #include <QProcess> @@ -40,10 +39,9 @@ class PerforceChecker : public QObject { Q_OBJECT public: - explicit PerforceChecker(QObject *parent = 0); + explicit PerforceChecker(QObject *parent = nullptr); ~PerforceChecker(); -public slots: void start(const QString &binary, const QString &workingDirectory, const QStringList &basicArgs = QStringList(), @@ -72,13 +70,11 @@ private: QProcess m_process; QString m_binary; - int m_timeOutMS; - bool m_timedOut; - bool m_useOverideCursor; - bool m_isOverrideCursor; + int m_timeOutMS = -1; + bool m_timedOut = false; + bool m_useOverideCursor = false; + bool m_isOverrideCursor = false; }; -} -} - -#endif // PERFORCECHECKER_H +} // namespace Internal +} // namespace Perforce diff --git a/src/plugins/perforce/perforceconstants.h b/src/plugins/perforce/perforceconstants.h deleted file mode 100644 index e1733673ed0..00000000000 --- a/src/plugins/perforce/perforceconstants.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#ifndef PERFORCE_CONSTANTS_H -#define PERFORCE_CONSTANTS_H - -#include <QtGlobal> - -namespace Perforce { -namespace Constants { - -enum { debug = 0 }; - -} // Constants -} // Perforce - -#endif // PERFORCE_CONSTANTS_H diff --git a/src/plugins/perforce/perforceeditor.cpp b/src/plugins/perforce/perforceeditor.cpp index f31fec8b5f0..e686d4e427b 100644 --- a/src/plugins/perforce/perforceeditor.cpp +++ b/src/plugins/perforce/perforceeditor.cpp @@ -26,7 +26,6 @@ #include "perforceeditor.h" #include "annotationhighlighter.h" -#include "perforceconstants.h" #include "perforceplugin.h" #include <coreplugin/editormanager/editormanager.h> @@ -85,8 +84,6 @@ QSet<QString> PerforceEditorWidget::annotationChanges() const changes.insert(r.cap(1)); } } - if (Perforce::Constants::debug) - qDebug() << "PerforceEditor::annotationChanges() returns #" << changes.size(); return changes; } diff --git a/src/plugins/perforce/perforceeditor.h b/src/plugins/perforce/perforceeditor.h index 91896d15033..2a91373aacd 100644 --- a/src/plugins/perforce/perforceeditor.h +++ b/src/plugins/perforce/perforceeditor.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef PERFORCEEDITOR_H -#define PERFORCEEDITOR_H +#pragma once #include <vcsbase/vcsbaseeditor.h> @@ -53,5 +52,3 @@ private: } // namespace Perforce } // namespace Internal - -#endif // PERFORCEEDITOR_H diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 25d5180f231..5696e55760b 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -27,7 +27,6 @@ #include "changenumberdialog.h" #include "pendingchangesdialog.h" -#include "perforceconstants.h" #include "perforceeditor.h" #include "perforcesubmiteditor.h" #include "perforceversioncontrol.h" @@ -115,11 +114,6 @@ static inline const VcsBaseEditorParameters *findType(int ie) return VcsBaseEditor::findType(editorParameters, sizeof(editorParameters)/sizeof(editorParameters[0]), et); } -static inline QString debugCodec(const QTextCodec *c) -{ - return c ? QString::fromLatin1(c->name()) : QString::fromLatin1("Null codec"); -} - // Ensure adding "..." to relative paths which is p4's convention // for the current directory static inline QString perforceRelativeFileArguments(const QString &args) @@ -177,37 +171,6 @@ PerforceResponse::PerforceResponse() : PerforcePlugin *PerforcePlugin::m_instance = NULL; -PerforcePlugin::PerforcePlugin() : - m_commandLocator(0), - m_editAction(0), - m_addAction(0), - m_deleteAction(0), - m_openedAction(0), - m_revertFileAction(0), - m_diffFileAction(0), - m_diffProjectAction(0), - m_updateProjectAction(0), - m_revertProjectAction(0), - m_revertUnchangedAction(0), - m_diffAllAction(0), - m_submitProjectAction(0), - m_pendingAction(0), - m_describeAction(0), - m_annotateCurrentAction(0), - m_annotateAction(0), - m_filelogCurrentAction(0), - m_filelogAction(0), - m_logProjectAction(0), - m_logRepositoryAction(0), - m_submitCurrentLogAction(0), - m_updateAllAction(0), - m_submitActionTriggered(false), - m_diffSelectedFiles(0), - m_undoAction(0), - m_redoAction(0) -{ -} - static const VcsBaseSubmitEditorParameters submitParameters = { SUBMIT_MIMETYPE, PERFORCE_SUBMIT_EDITOR_ID, @@ -890,10 +853,6 @@ bool PerforcePlugin::managesDirectoryFstat(const QString &directory) const PerforceResponse result = runP4Cmd(m_settings.topLevel(), args, RunFullySynchronous); - if (Perforce::Constants::debug) - qDebug() << "Perforce result:\n" << result.stdOut << "\n---\n" << result.stdErr - << "\n---\n" << result.message; - managed = result.stdOut.contains(QLatin1String("depotFile")) || result.stdErr.contains(QLatin1String("... - no such file(s)")); } while (false); @@ -904,8 +863,6 @@ bool PerforcePlugin::managesDirectoryFstat(const QString &directory) bool PerforcePlugin::vcsOpen(const QString &workingDir, const QString &fileName, bool silently) { - if (Perforce::Constants::debug) - qDebug() << "PerforcePlugin::vcsOpen" << workingDir << fileName; QStringList args; args << QLatin1String("edit") << QDir::toNativeSeparators(fileName); @@ -1053,12 +1010,8 @@ PerforceResponse PerforcePlugin::synchronousProcess(const QString &workingDir, connect(&process, SIGNAL(stdOutBuffered(QString,bool)), outputWindow, SLOT(append(QString))); } } - if (Perforce::Constants::debug) - qDebug() << "PerforcePlugin::run syncp actual args [" << process.workingDirectory() << ']' << args; process.setTimeOutMessageBoxEnabled(true); const SynchronousProcessResponse sp_resp = process.run(settings().p4BinaryPath(), args); - if (Perforce::Constants::debug) - qDebug() << sp_resp; PerforceResponse response; response.error = true; @@ -1100,9 +1053,6 @@ PerforceResponse PerforcePlugin::fullySynchronousProcess(const QString &workingD if (!workingDir.isEmpty()) process.setWorkingDirectory(workingDir); - if (Perforce::Constants::debug) - qDebug() << "PerforcePlugin::run fully syncp actual args [" << process.workingDirectory() << ']' << args; - PerforceResponse response; process.start(settings().p4BinaryPath(), args); if (stdInput.isEmpty()) @@ -1162,9 +1112,6 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QString &workingDir, const QByteArray &stdInput, QTextCodec *outputCodec) { - if (Perforce::Constants::debug) - qDebug() << "PerforcePlugin::runP4Cmd [" << workingDir << ']' << args << extraArgs << stdInput << debugCodec(outputCodec); - if (!settings().isValid()) { PerforceResponse invalidConfigResponse; invalidConfigResponse.error = true; @@ -1198,12 +1145,8 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QString &workingDir, if (flags & ShowBusyCursor) QApplication::restoreOverrideCursor(); - if (response.error) { - if (Perforce::Constants::debug) - qDebug() << response.message; - if (flags & ErrorToWindow) - VcsOutputWindow::appendError(response.message); - } + if (response.error && (flags & ErrorToWindow)) + VcsOutputWindow::appendError(response.message); return response; } @@ -1216,12 +1159,9 @@ IEditor *PerforcePlugin::showOutputInEditor(const QString &title, const VcsBaseEditorParameters *params = findType(editorType); QTC_ASSERT(params, return 0); const Id id = params->id; - if (Perforce::Constants::debug) - qDebug() << "PerforcePlugin::showOutputInEditor" << title << id.name() - << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); QString s = title; QString content = output; - const int maxSize = EditorManager::maxTextFileSize() / 2 - 1000; // ~25 MB, 600000 lines + const int maxSize = int(EditorManager::maxTextFileSize() / 2 - 1000L); // ~25 MB, 600000 lines if (content.size() >= maxSize) { content = content.left(maxSize); content += QLatin1Char('\n') + tr("[Only %n MB of output shown]", 0, maxSize / 1024 / 1024); @@ -1230,7 +1170,7 @@ IEditor *PerforcePlugin::showOutputInEditor(const QString &title, QTC_ASSERT(editor, return 0); connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)), this, SLOT(vcsAnnotate(QString,QString,QString,int))); - PerforceEditorWidget *e = qobject_cast<PerforceEditorWidget*>(editor->widget()); + auto e = qobject_cast<PerforceEditorWidget*>(editor->widget()); if (!e) return 0; e->setForceReadOnly(true); @@ -1326,12 +1266,12 @@ void PerforcePlugin::p4Diff(const PerforceDiffParameters &p) VcsBaseEditor::getSource(p.workingDir, p.files), codec); VcsBaseEditor::tagEditor(editor, tag); - VcsBaseEditorWidget *diffEditorWidget = qobject_cast<VcsBaseEditorWidget *>(editor->widget()); + auto diffEditorWidget = qobject_cast<VcsBaseEditorWidget *>(editor->widget()); // Wire up the parameter widget to trigger a re-run on // parameter change and 'revert' from inside the diff editor. auto pw = new PerforceDiffParameterWidget(p); - connect(pw, SIGNAL(reRunDiff(Perforce::Internal::PerforceDiffParameters)), - this, SLOT(p4Diff(Perforce::Internal::PerforceDiffParameters))); + connect(pw, &PerforceDiffParameterWidget::reRunDiff, + this, [this](const PerforceDiffParameters &p) { p4Diff(p); }); connect(diffEditorWidget, &VcsBaseEditorWidget::diffChunkReverted, pw, &PerforceDiffParameterWidget::triggerReRun); diffEditorWidget->setConfigurationWidget(pw); @@ -1372,7 +1312,7 @@ bool PerforcePlugin::submitEditorAboutToClose() { if (!isCommitEditorOpen()) return true; - PerforceSubmitEditor *perforceEditor = qobject_cast<PerforceSubmitEditor *>(submitEditor()); + auto perforceEditor = qobject_cast<PerforceSubmitEditor *>(submitEditor()); QTC_ASSERT(perforceEditor, return true); IDocument *editorDocument = perforceEditor->document(); QTC_ASSERT(editorDocument, return true); @@ -1437,10 +1377,7 @@ QString PerforcePlugin::clientFilePath(const QString &serverFilePath) QRegExp r(QLatin1String("\\.\\.\\.\\sclientFile\\s(.+)\n")); r.setMinimal(true); - const QString path = r.indexIn(response.stdOut) != -1 ? r.cap(1).trimmed() : QString(); - if (Perforce::Constants::debug) - qDebug() << "clientFilePath" << serverFilePath << path; - return path; + return r.indexIn(response.stdOut) != -1 ? r.cap(1).trimmed() : QString(); } QString PerforcePlugin::pendingChangesData() @@ -1466,10 +1403,6 @@ QString PerforcePlugin::pendingChangesData() return dataResponse.error ? QString() : dataResponse.stdOut; } -PerforcePlugin::~PerforcePlugin() -{ -} - const PerforceSettings& PerforcePlugin::settings() { return m_instance->m_settings; @@ -1526,10 +1459,7 @@ QString PerforcePlugin::fileNameFromPerforceName(const QString& perforceName, return QString(); } const QString p4fileSpec = output.mid(output.lastIndexOf(QLatin1Char(' ')) + 1); - const QString rc = m_instance->m_settings.mapToFileSystem(p4fileSpec); - if (Perforce::Constants::debug) - qDebug() << "fileNameFromPerforceName" << perforceName << p4fileSpec << rc; - return rc; + return m_instance->m_settings.mapToFileSystem(p4fileSpec); } PerforceVersionControl *PerforcePlugin::perforceVersionControl() @@ -1546,15 +1476,11 @@ void PerforcePlugin::setTopLevel(const QString &topLevel) const QString msg = tr("Perforce repository: %1").arg(QDir::toNativeSeparators(topLevel)); VcsOutputWindow::appendSilently(msg); - if (Perforce::Constants::debug) - qDebug() << "P4: " << topLevel; } void PerforcePlugin::slotTopLevelFailed(const QString &errorMessage) { VcsOutputWindow::appendSilently(tr("Perforce: Unable to determine the repository: %1").arg(errorMessage)); - if (Perforce::Constants::debug) - qDebug() << errorMessage; } void PerforcePlugin::getTopLevel(const QString &workingDirectory, bool isSync) diff --git a/src/plugins/perforce/perforceplugin.h b/src/plugins/perforce/perforceplugin.h index 7c105cdc547..616a1f52047 100644 --- a/src/plugins/perforce/perforceplugin.h +++ b/src/plugins/perforce/perforceplugin.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef PERFORCEPLUGIN_H -#define PERFORCEPLUGIN_H +#pragma once #include "perforcesettings.h" @@ -76,8 +75,7 @@ class PerforcePlugin : public VcsBase::VcsBasePlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Perforce.json") public: - PerforcePlugin(); - ~PerforcePlugin(); + PerforcePlugin() = default; bool initialize(const QStringList &arguments, QString *errorMessage); void extensionsInitialized(); @@ -105,19 +103,19 @@ public slots: void describe(const QString &source, const QString &n); void vcsAnnotate(const QString &workingDirectory, const QString &file, const QString &revision, int lineNumber); - void p4Diff(const Perforce::Internal::PerforceDiffParameters &p); - -#ifdef WITH_TESTS -private slots: - void testLogResolving(); -#endif protected: void updateActions(VcsBase::VcsBasePlugin::ActionState); bool submitEditorAboutToClose(); +#ifdef WITH_TESTS +private slots: + void testLogResolving(); +#endif private: + void p4Diff(const PerforceDiffParameters &p); + void openCurrentFile(); void addCurrentFile(); void revertCurrentFile(); @@ -149,8 +147,7 @@ private: public: DirectoryCacheEntry(bool isManaged, const QString &topLevel): m_isManaged(isManaged), m_topLevel(topLevel) - { - } + { } bool m_isManaged; QString m_topLevel; @@ -216,36 +213,36 @@ private: static PerforceVersionControl *perforceVersionControl(); - Core::CommandLocator *m_commandLocator; - Utils::ParameterAction *m_editAction; - Utils::ParameterAction *m_addAction; - Utils::ParameterAction *m_deleteAction; - QAction *m_openedAction; - Utils::ParameterAction *m_revertFileAction; - Utils::ParameterAction *m_diffFileAction; - Utils::ParameterAction *m_diffProjectAction; - Utils::ParameterAction *m_updateProjectAction; - Utils::ParameterAction *m_revertProjectAction; - Utils::ParameterAction *m_revertUnchangedAction; - QAction *m_diffAllAction; - Utils::ParameterAction *m_submitProjectAction; - QAction *m_pendingAction; - QAction *m_describeAction; - Utils::ParameterAction *m_annotateCurrentAction; - QAction *m_annotateAction; - Utils::ParameterAction *m_filelogCurrentAction; - QAction *m_filelogAction; - Utils::ParameterAction *m_logProjectAction; - QAction *m_logRepositoryAction; - QAction *m_submitCurrentLogAction; - QAction *m_updateAllAction; - bool m_submitActionTriggered; - QAction *m_diffSelectedFiles; + Core::CommandLocator *m_commandLocator = nullptr; + Utils::ParameterAction *m_editAction = nullptr; + Utils::ParameterAction *m_addAction = nullptr; + Utils::ParameterAction *m_deleteAction = nullptr; + QAction *m_openedAction = nullptr; + Utils::ParameterAction *m_revertFileAction = nullptr; + Utils::ParameterAction *m_diffFileAction = nullptr; + Utils::ParameterAction *m_diffProjectAction = nullptr; + Utils::ParameterAction *m_updateProjectAction = nullptr; + Utils::ParameterAction *m_revertProjectAction = nullptr; + Utils::ParameterAction *m_revertUnchangedAction = nullptr; + QAction *m_diffAllAction = nullptr; + Utils::ParameterAction *m_submitProjectAction = nullptr; + QAction *m_pendingAction = nullptr; + QAction *m_describeAction = nullptr; + Utils::ParameterAction *m_annotateCurrentAction = nullptr; + QAction *m_annotateAction = nullptr; + Utils::ParameterAction *m_filelogCurrentAction = nullptr; + QAction *m_filelogAction = nullptr; + Utils::ParameterAction *m_logProjectAction = nullptr; + QAction *m_logRepositoryAction = nullptr; + QAction *m_submitCurrentLogAction = nullptr; + QAction *m_updateAllAction = nullptr; + bool m_submitActionTriggered = false; + QAction *m_diffSelectedFiles = nullptr; QString m_commitMessageFileName; mutable QString m_tempFilePattern; - QAction *m_undoAction; - QAction *m_redoAction; - QAction *m_menuAction; + QAction *m_undoAction = nullptr; + QAction *m_redoAction = nullptr; + QAction *m_menuAction = nullptr; static PerforcePlugin *m_instance; @@ -255,5 +252,3 @@ private: } // namespace Perforce } // namespace Internal - -#endif // PERFORCEPLUGIN_H diff --git a/src/plugins/perforce/perforcesettings.cpp b/src/plugins/perforce/perforcesettings.cpp index 0b7f656655b..116861034e7 100644 --- a/src/plugins/perforce/perforcesettings.cpp +++ b/src/plugins/perforce/perforcesettings.cpp @@ -25,13 +25,11 @@ #include "perforcesettings.h" #include "perforceplugin.h" -#include "perforceconstants.h" #include <utils/qtcassert.h> #include <utils/environment.h> #include <utils/hostosinfo.h> -#include <QDebug> #include <QSettings> #include <QStringList> #include <QCoreApplication> @@ -59,14 +57,8 @@ static QString defaultCommand() namespace Perforce { namespace Internal { -Settings::Settings() : - logCount(defaultLogCount), - defaultEnv(true), - timeOutS(defaultTimeOutS), - promptToSubmit(true), - autoOpen(true) -{ -} +Settings::Settings() : logCount(defaultLogCount), timeOutS(defaultTimeOutS) +{ } bool Settings::equals(const Settings &rhs) const { @@ -93,12 +85,9 @@ QStringList Settings::commonP4Arguments() const } // --------------------PerforceSettings -PerforceSettings::PerforceSettings() -{ -} - PerforceSettings::~PerforceSettings() { + delete m_topLevelDir; } void PerforceSettings::fromSettings(QSettings *settings) @@ -220,21 +209,20 @@ void PerforceSettings::setTopLevel(const QString &t) } else { m_topLevelSymLinkTarget = m_topLevel = t; } - m_topLevelDir.reset(new QDir(m_topLevelSymLinkTarget)); - if (Perforce::Constants::debug) - qDebug() << "PerforceSettings::setTopLevel" << m_topLevel << m_topLevelSymLinkTarget; + m_topLevelDir = new QDir(m_topLevelSymLinkTarget); } } void PerforceSettings::clearTopLevel() { - m_topLevelDir.reset(); + delete m_topLevelDir; + m_topLevelDir = nullptr; m_topLevel.clear(); } QString PerforceSettings::relativeToTopLevel(const QString &dir) const { - QTC_ASSERT(!m_topLevelDir.isNull(), return QLatin1String("../") + dir); + QTC_ASSERT(m_topLevelDir, return QLatin1String("../") + dir); return m_topLevelDir->relativeFilePath(dir); } diff --git a/src/plugins/perforce/perforcesettings.h b/src/plugins/perforce/perforcesettings.h index b0a9b4725b7..e782c14c2ff 100644 --- a/src/plugins/perforce/perforcesettings.h +++ b/src/plugins/perforce/perforcesettings.h @@ -23,11 +23,9 @@ ** ****************************************************************************/ -#ifndef PERFORCESETTINGS_H -#define PERFORCESETTINGS_H +#pragma once #include <QString> -#include <QScopedPointer> QT_BEGIN_NAMESPACE class QSettings; @@ -55,10 +53,10 @@ struct Settings { QString p4User; QString errorString; int logCount; - bool defaultEnv; + bool defaultEnv = true; int timeOutS; - bool promptToSubmit; - bool autoOpen; + bool promptToSubmit = true; + bool autoOpen = true; }; inline bool operator==(const Settings &s1, const Settings &s2) { return s1.equals(s2); } @@ -80,11 +78,10 @@ inline bool operator!=(const Settings &s1, const Settings &s2) { return !s1.equa class PerforceSettings { - Q_DISABLE_COPY(PerforceSettings) - public: - PerforceSettings(); + PerforceSettings() = default; ~PerforceSettings(); + PerforceSettings(const PerforceSettings &other) = delete; inline bool isValid() const { @@ -139,10 +136,8 @@ private: Settings m_settings; QString m_topLevel; QString m_topLevelSymLinkTarget; - QScopedPointer<QDir> m_topLevelDir; + QDir *m_topLevelDir = nullptr; }; -} // Internal -} // Perforce - -#endif // PERFORCESETTINGS_H +} // namespace Internal +} // namespace Perforce diff --git a/src/plugins/perforce/perforcesubmiteditor.cpp b/src/plugins/perforce/perforcesubmiteditor.cpp index e447a7e4809..38b1a04f1ac 100644 --- a/src/plugins/perforce/perforcesubmiteditor.cpp +++ b/src/plugins/perforce/perforcesubmiteditor.cpp @@ -26,14 +26,11 @@ #include "perforcesubmiteditor.h" #include "perforcesubmiteditorwidget.h" #include "perforceplugin.h" -#include "perforceconstants.h" #include <coreplugin/idocument.h> #include <vcsbase/submitfilemodel.h> #include <utils/qtcassert.h> -#include <QDebug> - namespace Perforce { namespace Internal { @@ -62,15 +59,11 @@ QByteArray PerforceSubmitEditor::fileContents() const it.next(); out << it.key() << ":" << it.value(); } - if (Perforce::Constants::debug) - qDebug() << Q_FUNC_INFO << text; return text.toLocal8Bit(); } bool PerforceSubmitEditor::setFileContents(const QByteArray &contents) { - if (Perforce::Constants::debug) - qDebug() << Q_FUNC_INFO << contents; if (!parseText(QString::fromUtf8(contents))) return false; updateFields(); diff --git a/src/plugins/perforce/perforcesubmiteditor.h b/src/plugins/perforce/perforcesubmiteditor.h index 33b21719034..cff9b05bc71 100644 --- a/src/plugins/perforce/perforcesubmiteditor.h +++ b/src/plugins/perforce/perforcesubmiteditor.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef PERFORCESUBMITEDITOR_H -#define PERFORCESUBMITEDITOR_H +#pragma once #include <vcsbase/vcsbasesubmiteditor.h> @@ -75,5 +74,3 @@ private: } // namespace Internal } // namespace Perforce - -#endif // PERFORCESUBMITEDITOR_H diff --git a/src/plugins/perforce/perforcesubmiteditorwidget.h b/src/plugins/perforce/perforcesubmiteditorwidget.h index 14ef9f2a194..15b81befe9e 100644 --- a/src/plugins/perforce/perforcesubmiteditorwidget.h +++ b/src/plugins/perforce/perforcesubmiteditorwidget.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef PERFORCESUBMITEDITORWIDGET_H -#define PERFORCESUBMITEDITORWIDGET_H +#pragma once #include "ui_submitpanel.h" #include <vcsbase/submiteditorwidget.h> @@ -48,5 +47,3 @@ private: } // namespace Internal } // namespace Perforce - -#endif // PERFORCESUBMITEDITORWIDGET_H diff --git a/src/plugins/perforce/perforceversioncontrol.cpp b/src/plugins/perforce/perforceversioncontrol.cpp index fc84372ee7d..d436991b0f0 100644 --- a/src/plugins/perforce/perforceversioncontrol.cpp +++ b/src/plugins/perforce/perforceversioncontrol.cpp @@ -25,7 +25,6 @@ #include "perforceversioncontrol.h" #include "perforceplugin.h" -#include "perforceconstants.h" #include "perforcesettings.h" #include <vcsbase/vcsbaseconstants.h> @@ -38,8 +37,7 @@ namespace Internal { PerforceVersionControl::PerforceVersionControl(PerforcePlugin *plugin) : m_plugin(plugin) -{ -} +{ } QString PerforceVersionControl::displayName() const { @@ -140,14 +138,7 @@ QString PerforceVersionControl::vcsMakeWritableText() const bool PerforceVersionControl::managesDirectory(const QString &directory, QString *topLevel) const { - const bool rc = m_plugin->managesDirectory(directory, topLevel); - if (Perforce::Constants::debug) { - QDebug nsp = qDebug().nospace(); - nsp << "managesDirectory" << directory << rc; - if (topLevel) - nsp << topLevel; - } - return rc; + return m_plugin->managesDirectory(directory, topLevel); } bool PerforceVersionControl::managesFile(const QString &workingDirectory, const QString &fileName) const diff --git a/src/plugins/perforce/perforceversioncontrol.h b/src/plugins/perforce/perforceversioncontrol.h index 155b514eaed..5ca6c7b20e8 100644 --- a/src/plugins/perforce/perforceversioncontrol.h +++ b/src/plugins/perforce/perforceversioncontrol.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef PERFORCEVERSIONCONTROL_H -#define PERFORCEVERSIONCONTROL_H +#pragma once #include <coreplugin/iversioncontrol.h> @@ -66,7 +65,5 @@ private: PerforcePlugin *m_plugin; }; -} // Internal -} // Perforce - -#endif // PERFORCEVERSIONCONTROL_H +} // namespace Internal +} // namespace Perforce diff --git a/src/plugins/perforce/settingspage.cpp b/src/plugins/perforce/settingspage.cpp index 3e89ad64014..4a9678901c3 100644 --- a/src/plugins/perforce/settingspage.cpp +++ b/src/plugins/perforce/settingspage.cpp @@ -49,13 +49,18 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) : connect(m_ui.testPushButton, &QPushButton::clicked, this, &SettingsPageWidget::slotTest); } +SettingsPageWidget::~SettingsPageWidget() +{ + delete m_checker; +} + void SettingsPageWidget::slotTest() { if (!m_checker) { m_checker = new PerforceChecker(this); m_checker->setUseOverideCursor(true); - connect(m_checker.data(), &PerforceChecker::failed, this, &SettingsPageWidget::setStatusError); - connect(m_checker.data(), &PerforceChecker::succeeded, this, &SettingsPageWidget::testSucceeded); + connect(m_checker, &PerforceChecker::failed, this, &SettingsPageWidget::setStatusError); + connect(m_checker, &PerforceChecker::succeeded, this, &SettingsPageWidget::testSucceeded); } if (m_checker->isRunning()) @@ -118,6 +123,11 @@ SettingsPage::SettingsPage() setDisplayName(tr("Perforce")); } +SettingsPage::~SettingsPage() +{ + delete m_widget; +} + QWidget *SettingsPage::widget() { if (!m_widget) { @@ -135,4 +145,5 @@ void SettingsPage::apply() void SettingsPage::finish() { delete m_widget; + m_widget = nullptr; } diff --git a/src/plugins/perforce/settingspage.h b/src/plugins/perforce/settingspage.h index 67b8fa35123..4fb6dc903b3 100644 --- a/src/plugins/perforce/settingspage.h +++ b/src/plugins/perforce/settingspage.h @@ -23,10 +23,8 @@ ** ****************************************************************************/ -#ifndef SETTINGSPAGE_H -#define SETTINGSPAGE_H +#pragma once -#include <QPointer> #include <QWidget> #include <vcsbase/vcsbaseoptionspage.h> @@ -46,6 +44,7 @@ class SettingsPageWidget : public QWidget public: explicit SettingsPageWidget(QWidget *parent = 0); + ~SettingsPageWidget() override; void setSettings(const PerforceSettings &); Settings settings() const; @@ -57,7 +56,7 @@ private: void testSucceeded(const QString &repo); Ui::SettingsPage m_ui; - QPointer<PerforceChecker> m_checker; + PerforceChecker *m_checker = nullptr; }; class SettingsPage : public VcsBase::VcsBaseOptionsPage @@ -66,16 +65,15 @@ class SettingsPage : public VcsBase::VcsBaseOptionsPage public: SettingsPage(); + ~SettingsPage() override; - QWidget *widget(); - void apply(); - void finish(); + QWidget *widget() override; + void apply() override; + void finish() override; private: - QPointer<SettingsPageWidget> m_widget; + SettingsPageWidget *m_widget = nullptr; }; } // namespace Internal } // namespace Perforce - -#endif // SETTINGSPAGE_H |