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 <orgads@gmail.com>
This commit is contained in:
hjk
2020-01-31 16:55:35 +01:00
parent a09a563280
commit 039e70c727
6 changed files with 67 additions and 193 deletions

View File

@@ -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

View File

@@ -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 \

View File

@@ -13,8 +13,6 @@ QtcPlugin {
files: [
"annotationhighlighter.cpp",
"annotationhighlighter.h",
"cvsclient.cpp",
"cvsclient.h",
"cvseditor.cpp",
"cvseditor.h",
"cvsplugin.cpp",

View File

@@ -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 <vcsbase/vcsbaseplugin.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsbaseeditorconfig.h>
#include <QDir>
#include <QFileInfo>
#include <QTextStream>
#include <QDebug>
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"

View File

@@ -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 <vcsbase/vcsbaseclient.h>
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

View File

@@ -27,13 +27,16 @@
#include "settingspage.h"
#include "cvseditor.h"
#include "cvssubmiteditor.h"
#include "cvsclient.h"
#include "cvsutils.h"
#include "cvssettings.h"
#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseclient.h>
#include <vcsbase/vcsbaseclientsettings.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseeditorconfig.h>
#include <vcsbase/vcsbaseplugin.h>
#include <vcsbase/vcscommand.h>
#include <vcsbase/vcsoutputwindow.h>
@@ -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)