From 039e70c727de74368c0f7f00d36f83cc91de5ed4 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 31 Jan 2020 16:55:35 +0100 Subject: [PATCH] Cvs: Lump cvsclient.h and .cpp into plugin Given the reduction of the code, this here makes sense to have by itself, but it is actually triggered by the wish to to merge the parallel VcsPluginBase and VcsClientBase hierarchy. An immediate merge affects a lot of code (>10kloc), with mostly mechanical moving, but also some non-mechanical changes. Try to get the main part of the moves done one-by-one through do reduce size of the non-mechanical part. Change-Id: Id276a9f64ef9113567d631129662cd0607ba88d3 Reviewed-by: Orgad Shaneh --- src/plugins/cvs/CMakeLists.txt | 1 - src/plugins/cvs/cvs.pro | 2 - src/plugins/cvs/cvs.qbs | 2 - src/plugins/cvs/cvsclient.cpp | 131 --------------------------------- src/plugins/cvs/cvsclient.h | 56 -------------- src/plugins/cvs/cvsplugin.cpp | 68 ++++++++++++++++- 6 files changed, 67 insertions(+), 193 deletions(-) delete mode 100644 src/plugins/cvs/cvsclient.cpp delete mode 100644 src/plugins/cvs/cvsclient.h diff --git a/src/plugins/cvs/CMakeLists.txt b/src/plugins/cvs/CMakeLists.txt index a94d5ea942f..2498cc9e94c 100644 --- a/src/plugins/cvs/CMakeLists.txt +++ b/src/plugins/cvs/CMakeLists.txt @@ -2,7 +2,6 @@ add_qtc_plugin(CVS PLUGIN_DEPENDS Core TextEditor VcsBase SOURCES annotationhighlighter.cpp annotationhighlighter.h - cvsclient.cpp cvsclient.h cvseditor.cpp cvseditor.h cvsplugin.cpp cvsplugin.h cvssettings.cpp cvssettings.h diff --git a/src/plugins/cvs/cvs.pro b/src/plugins/cvs/cvs.pro index 8635e6993f6..c7b84d117db 100644 --- a/src/plugins/cvs/cvs.pro +++ b/src/plugins/cvs/cvs.pro @@ -2,7 +2,6 @@ include(../../qtcreatorplugin.pri) HEADERS += annotationhighlighter.h \ cvsplugin.h \ - cvsclient.h \ settingspage.h \ cvseditor.h \ cvssubmiteditor.h \ @@ -11,7 +10,6 @@ HEADERS += annotationhighlighter.h \ SOURCES += annotationhighlighter.cpp \ cvsplugin.cpp \ - cvsclient.cpp \ settingspage.cpp \ cvseditor.cpp \ cvssubmiteditor.cpp \ diff --git a/src/plugins/cvs/cvs.qbs b/src/plugins/cvs/cvs.qbs index 6f81b82065a..f86c0144a61 100644 --- a/src/plugins/cvs/cvs.qbs +++ b/src/plugins/cvs/cvs.qbs @@ -13,8 +13,6 @@ QtcPlugin { files: [ "annotationhighlighter.cpp", "annotationhighlighter.h", - "cvsclient.cpp", - "cvsclient.h", "cvseditor.cpp", "cvseditor.h", "cvsplugin.cpp", diff --git a/src/plugins/cvs/cvsclient.cpp b/src/plugins/cvs/cvsclient.cpp deleted file mode 100644 index 52a04f1c1f2..00000000000 --- a/src/plugins/cvs/cvsclient.cpp +++ /dev/null @@ -1,131 +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. -** -****************************************************************************/ - -#include "cvsclient.h" -#include "cvssettings.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -using namespace Utils; -using namespace VcsBase; - -namespace Cvs { -namespace Internal { - -// Parameter widget controlling whitespace diff mode, associated with a parameter -class CvsDiffConfig : public VcsBaseEditorConfig -{ - Q_OBJECT -public: - CvsDiffConfig(VcsBaseClientSettings &settings, QToolBar *toolBar); - QStringList arguments() const override; - -private: - VcsBaseClientSettings &m_settings; -}; - -CvsDiffConfig::CvsDiffConfig(VcsBaseClientSettings &settings, QToolBar *toolBar) : - VcsBaseEditorConfig(toolBar), - m_settings(settings) -{ - mapSetting(addToggleButton(QLatin1String("-w"), tr("Ignore Whitespace")), - settings.boolPointer(CvsSettings::diffIgnoreWhiteSpaceKey)); - mapSetting(addToggleButton(QLatin1String("-B"), tr("Ignore Blank Lines")), - settings.boolPointer(CvsSettings::diffIgnoreBlankLinesKey)); -} - -QStringList CvsDiffConfig::arguments() const -{ - QStringList args; - args = m_settings.stringValue(CvsSettings::diffOptionsKey).split(QLatin1Char(' '), - QString::SkipEmptyParts); - args += VcsBaseEditorConfig::arguments(); - return args; -} - -CvsClient::CvsClient(CvsSettings *settings) : VcsBaseClient(settings) -{ - setDiffConfigCreator([settings](QToolBar *toolBar) { - return new CvsDiffConfig(*settings, toolBar); - }); -} - -Core::Id CvsClient::vcsEditorKind(VcsCommandTag cmd) const -{ - switch (cmd) { - case DiffCommand: - return "CVS Diff Editor"; // TODO: replace by string from cvsconstants.h - default: - return Core::Id(); - } -} - -ExitCodeInterpreter CvsClient::exitCodeInterpreter(VcsCommandTag cmd) const -{ - if (cmd == DiffCommand) { - return [](int code) { - return (code < 0 || code > 2) ? SynchronousProcessResponse::FinishedError - : SynchronousProcessResponse::Finished; - }; - } - return Utils::defaultExitCodeInterpreter; -} - -void CvsClient::diff(const QString &workingDir, const QStringList &files, - const QStringList &extraOptions) -{ - VcsBaseClient::diff(workingDir, files, extraOptions); -} - -QString CvsClient::findTopLevelForFile(const QFileInfo &file) const -{ - Q_UNUSED(file) - return QString(); -} - -QStringList CvsClient::revisionSpec(const QString &revision) const -{ - Q_UNUSED(revision) - return QStringList(); -} - -VcsBaseClient::StatusItem CvsClient::parseStatusLine(const QString &line) const -{ - Q_UNUSED(line) - return VcsBaseClient::StatusItem(); -} - -} // namespace Internal -} // namespace Cvs - -#include "cvsclient.moc" diff --git a/src/plugins/cvs/cvsclient.h b/src/plugins/cvs/cvsclient.h deleted file mode 100644 index 799840ee721..00000000000 --- a/src/plugins/cvs/cvsclient.h +++ /dev/null @@ -1,56 +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. -** -****************************************************************************/ - -#pragma once - -#include "cvssettings.h" - -#include - -namespace Cvs { -namespace Internal { - -class CvsSettings; - -class CvsClient : public VcsBase::VcsBaseClient -{ - Q_OBJECT - -public: - explicit CvsClient(CvsSettings *settings); - - void diff(const QString &workingDir, const QStringList &files, - const QStringList &extraOptions = QStringList()) override; - QString findTopLevelForFile(const QFileInfo &file) const override; - QStringList revisionSpec(const QString &revision) const override; - StatusItem parseStatusLine(const QString &line) const override; - -protected: - Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const override; - Core::Id vcsEditorKind(VcsCommandTag cmd) const override; -}; - -} // namespace Internal -} // namespace Cvs diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index b2a1d0c6015..99a6498e6e3 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -27,13 +27,16 @@ #include "settingspage.h" #include "cvseditor.h" #include "cvssubmiteditor.h" -#include "cvsclient.h" #include "cvsutils.h" +#include "cvssettings.h" #include #include +#include +#include #include #include +#include #include #include #include @@ -156,6 +159,69 @@ static inline bool messageBoxQuestion(const QString &title, const QString &quest } +// Parameter widget controlling whitespace diff mode, associated with a parameter +class CvsDiffConfig : public VcsBaseEditorConfig +{ +public: + CvsDiffConfig(VcsBaseClientSettings &settings, QToolBar *toolBar) : + VcsBaseEditorConfig(toolBar), + m_settings(settings) + { + mapSetting(addToggleButton(QLatin1String("-w"), CvsPlugin::tr("Ignore Whitespace")), + settings.boolPointer(CvsSettings::diffIgnoreWhiteSpaceKey)); + mapSetting(addToggleButton(QLatin1String("-B"), CvsPlugin::tr("Ignore Blank Lines")), + settings.boolPointer(CvsSettings::diffIgnoreBlankLinesKey)); + } + + QStringList arguments() const override + { + QStringList args; + args = m_settings.stringValue(CvsSettings::diffOptionsKey).split(QLatin1Char(' '), + QString::SkipEmptyParts); + args += VcsBaseEditorConfig::arguments(); + return args; + } + +private: + VcsBaseClientSettings &m_settings; +}; + +class CvsClient : public VcsBaseClient +{ +public: + explicit CvsClient(CvsSettings *settings) : VcsBaseClient(settings) + { + setDiffConfigCreator([settings](QToolBar *toolBar) { + return new CvsDiffConfig(*settings, toolBar); + }); + } + + QString findTopLevelForFile(const QFileInfo &) const override { return {}; } + QStringList revisionSpec(const QString &) const override { return {}; } + StatusItem parseStatusLine(const QString &) const override { return {}; } + + ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const override + { + if (cmd == DiffCommand) { + return [](int code) { + return (code < 0 || code > 2) ? SynchronousProcessResponse::FinishedError + : SynchronousProcessResponse::Finished; + }; + } + return Utils::defaultExitCodeInterpreter; + } + + Core::Id vcsEditorKind(VcsCommandTag cmd) const override + { + switch (cmd) { + case DiffCommand: + return "CVS Diff Editor"; // TODO: replace by string from cvsconstants.h + default: + return Core::Id(); + } + } +}; + class CvsPluginPrivate final : public VcsBasePluginPrivate { Q_DECLARE_TR_FUNCTIONS(Cvs::Internal::CvsPlugin)