Commit eb07fd92 authored by Tobias Hunger's avatar Tobias Hunger

CVS: Modernize

* Use pragma once
* Use some more overrides
* Tiny clean-ups here and there

Change-Id: I951afa8ed31c5f414d4ae872c79f80db19909ee0
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent bc9c5775
......@@ -30,13 +30,11 @@ using namespace Cvs::Internal;
CvsAnnotationHighlighter::CvsAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document) :
VcsBase::BaseAnnotationHighlighter(changeNumbers, document),
m_blank(QLatin1Char(' '))
{
}
VcsBase::BaseAnnotationHighlighter(changeNumbers, document)
{ }
QString CvsAnnotationHighlighter::changeNumber(const QString &block) const
{
const int pos = block.indexOf(m_blank);
const int pos = block.indexOf(QLatin1Char(' '));
return pos > 1 ? block.left(pos) : QString();
}
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef ANNOTATIONHIGHLIGHTER_H
#define ANNOTATIONHIGHLIGHTER_H
#pragma once
#include <vcsbase/baseannotationhighlighter.h>
......@@ -41,12 +40,8 @@ public:
QTextDocument *document = 0);
private:
QString changeNumber(const QString &block) const;
const QChar m_blank;
QString changeNumber(const QString &block) const override;
};
} // namespace Internal
} // namespace Cvs
#endif // ANNOTATIONHIGHLIGHTER_H
......@@ -8,8 +8,7 @@ HEADERS += annotationhighlighter.h \
cvseditor.h \
cvssubmiteditor.h \
cvssettings.h \
cvsutils.h \
cvsconstants.h
cvsutils.h
SOURCES += annotationhighlighter.cpp \
cvsplugin.cpp \
......
......@@ -16,7 +16,6 @@ QtcPlugin {
"cvs.qrc",
"cvsclient.cpp",
"cvsclient.h",
"cvsconstants.h",
"cvscontrol.cpp",
"cvscontrol.h",
"cvseditor.cpp",
......
......@@ -25,7 +25,6 @@
#include "cvsclient.h"
#include "cvssettings.h"
#include "cvsconstants.h"
#include <vcsbase/vcsbaseplugin.h>
#include <vcsbase/vcsbaseeditor.h>
......
......@@ -23,10 +23,10 @@
**
****************************************************************************/
#ifndef CVSCLIENT_H
#define CVSCLIENT_H
#pragma once
#include "cvssettings.h"
#include <vcsbase/vcsbaseclient.h>
namespace Cvs {
......@@ -43,17 +43,15 @@ public:
CvsSettings &settings() const;
void diff(const QString &workingDir, const QStringList &files,
const QStringList &extraOptions = QStringList());
QString findTopLevelForFile(const QFileInfo &file) const;
QStringList revisionSpec(const QString &revision) const;
StatusItem parseStatusLine(const QString &line) const;
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, QObject *parent) const;
Core::Id vcsEditorKind(VcsCommandTag cmd) const;
Utils::ExitCodeInterpreter *exitCodeInterpreter(VcsCommandTag cmd, QObject *parent) const override;
Core::Id vcsEditorKind(VcsCommandTag cmd) const override;
};
} // namespace Internal
} // namespace Cvs
#endif // CVSCLIENT_H
/****************************************************************************
**
** 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 CVS_CONSTANTS_H
#define CVS_CONSTANTS_H
namespace Cvs {
namespace Constants {
enum { debug = 0 };
} // namespace Constants
} // namespace Cvs
#endif // CVS_CONSTANTS_H
......@@ -42,8 +42,7 @@ using namespace Cvs::Internal;
CvsControl::CvsControl(CvsPlugin *plugin) :
m_plugin(plugin)
{
}
{ }
QString CvsControl::displayName() const
{
......
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef CVSCONTROL_H
#define CVSCONTROL_H
#pragma once
#include <coreplugin/iversioncontrol.h>
......@@ -67,10 +66,8 @@ public:
void emitFilesChanged(const QStringList &l);
private:
CvsPlugin *m_plugin;
CvsPlugin *const m_plugin;
};
} // namespace Internal
} // namespace Cvs
#endif // CVSCONTROL_H
......@@ -27,7 +27,6 @@
#include "cvsutils.h"
#include "annotationhighlighter.h"
#include "cvsconstants.h"
#include <utils/qtcassert.h>
#include <vcsbase/diffandloghighlighter.h>
......@@ -81,8 +80,6 @@ QSet<QString> CvsEditorWidget::annotationChanges() const
changes.insert(r.cap(1));
}
}
if (Constants::debug)
qDebug() << "CVSEditor::annotationChanges() returns #" << changes.size();
return changes;
}
......
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef CVSEDITOR_H
#define CVSEDITOR_H
#pragma once
#include <vcsbase/vcsbaseeditor.h>
......@@ -54,5 +53,3 @@ private:
} // namespace Internal
} // namespace Cvs
#endif // CVSEDITOR_H
......@@ -28,7 +28,6 @@
#include "cvseditor.h"
#include "cvssubmiteditor.h"
#include "cvsclient.h"
#include "cvsconstants.h"
#include "cvscontrol.h"
#include <vcsbase/basevcseditorfactory.h>
......@@ -153,11 +152,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");
}
static inline bool messageBoxQuestion(const QString &title, const QString &question)
{
return QMessageBox::question(ICore::dialogParent(), title, question, QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes;
......@@ -202,7 +196,6 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
using namespace Constants;
using namespace Core::Constants;
Context context(CVS_CONTEXT);
......@@ -711,8 +704,6 @@ void CvsPlugin::startCommit(const QString &workingDir, const QString &file)
bool CvsPlugin::commit(const QString &messageFile,
const QStringList &fileList)
{
if (Constants::debug)
qDebug() << Q_FUNC_INFO << messageFile << fileList;
QStringList args = QStringList(QLatin1String("commit"));
args << QLatin1String("-F") << messageFile;
args.append(fileList);
......@@ -1003,8 +994,6 @@ bool CvsPlugin::describe(const QString &toplevel, const QString &file, const
// This function makes use of it to find all files related to
// a commit in order to emulate a "describe global change" functionality
// if desired.
if (Constants::debug)
qDebug() << Q_FUNC_INFO << file << changeNr;
// Number must be > 1
if (isFirstRevision(changeNr)) {
*errorMessage = tr("The initial revision %1 cannot be described.").arg(changeNr);
......@@ -1179,9 +1168,6 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp
const VcsBaseEditorParameters *params = findType(editorType);
QTC_ASSERT(params, return 0);
const Id id = params->id;
if (Constants::debug)
qDebug() << "CVSPlugin::showOutputInEditor" << title << id.name()
<< "source=" << source << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);
QString s = title;
IEditor *editor = EditorManager::openEditorWithContents(id, &s, output.toUtf8());
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
......@@ -1252,12 +1238,7 @@ bool CvsPlugin::managesDirectory(const QString &directory, QString *topLevel /*
}
}
} while (false);
if (Constants::debug) {
QDebug nsp = qDebug().nospace();
nsp << "CVSPlugin::managesDirectory" << directory << manages;
if (topLevel)
nsp << *topLevel;
}
return manages;
}
......
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef CVSPLUGIN_H
#define CVSPLUGIN_H
#pragma once
#include "cvssettings.h"
#include "cvsutils.h"
......@@ -40,7 +39,7 @@ QT_END_NAMESPACE
namespace Core {
class CommandLocator;
class IVersionControl;
}
} // namespace Core
namespace Utils { class ParameterAction; }
namespace VcsBase { class VcsBaseSubmitEditor; }
......@@ -48,17 +47,16 @@ namespace VcsBase { class VcsBaseSubmitEditor; }
namespace Cvs {
namespace Internal {
struct CvsDiffParameters;
class CvsSubmitEditor;
class CvsControl;
class CvsClient;
struct CvsResponse
class CvsResponse
{
public:
enum Result { Ok, NonNullExitCode, OtherError };
CvsResponse() : result(Ok) {}
Result result;
Result result = Ok;
QString stdOut;
QString stdErr;
QString message;
......@@ -70,11 +68,11 @@ class CvsPlugin : public VcsBase::VcsBasePlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "CVS.json")
public:
~CvsPlugin();
~CvsPlugin() override;
CvsClient *client() const;
bool initialize(const QStringList &arguments, QString *errorMessage);
bool initialize(const QStringList &arguments, QString *errorMessage) override;
CvsSubmitEditor *openCVSSubmitEditor(const QString &fileName);
......@@ -102,8 +100,8 @@ private slots:
#endif
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
bool submitEditorAboutToClose();
void updateActions(VcsBase::VcsBasePlugin::ActionState) override;
bool submitEditorAboutToClose() override;
private:
void addCurrentFile();
......@@ -205,5 +203,3 @@ private:
} // namespace Cvs
} // namespace Internal
#endif // CVSPLUGIN_H
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef CVSSETTINGS_H
#define CVSSETTINGS_H
#pragma once
#include <vcsbase/vcsbaseclientsettings.h>
......@@ -52,5 +51,3 @@ protected:
} // namespace Internal
} // namespace Cvs
#endif // CVSSETTINGS_H
......@@ -36,8 +36,7 @@ CvsSubmitEditor::CvsSubmitEditor(const VcsBaseSubmitEditorParameters *parameters
m_msgAdded(tr("Added")),
m_msgRemoved(tr("Removed")),
m_msgModified(tr("Modified"))
{
}
{ }
QString CvsSubmitEditor::stateName(State st) const
{
......
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef CVSSUBMITEDITOR_H
#define CVSSUBMITEDITOR_H
#pragma once
#include <QPair>
#include <QStringList>
......@@ -58,5 +57,3 @@ private:
} // namespace Internal
} // namespace Cvs
#endif // CVSSUBMITEDITOR_H
......@@ -25,31 +25,17 @@
#include "cvsutils.h"
#include <QDebug>
#include <QRegExp>
#include <QStringList>
namespace Cvs {
namespace Internal {
CvsRevision::CvsRevision(const QString &rev) :
revision(rev)
{
}
CvsLogEntry::CvsLogEntry(const QString &f) :
file(f)
{
}
CvsRevision::CvsRevision(const QString &rev) : revision(rev)
{ }
QDebug operator<<(QDebug d, const CvsLogEntry &e)
{
QDebug nospace = d.nospace();
nospace << "File: " << e.file << e.revisions.size() << '\n';
foreach (const CvsRevision &r, e.revisions)
nospace << " " << r.revision << ' ' << r.date << ' ' << r.commitId << '\n';
return d;
}
CvsLogEntry::CvsLogEntry(const QString &f) : file(f)
{ }
/* Parse:
\code
......
......@@ -23,26 +23,22 @@
**
****************************************************************************/
#ifndef CVSUTILS_H
#define CVSUTILS_H
#pragma once
#include "cvssubmiteditor.h"
#include <QString>
#include <QList>
QT_BEGIN_NAMESPACE
class QDebug;
QT_END_NAMESPACE
namespace Cvs {
namespace Internal {
// Utilities to parse output of a CVS log.
// A revision of a file.
struct CvsRevision
class CvsRevision
{
public:
CvsRevision(const QString &rev);
QString revision;
......@@ -51,16 +47,15 @@ struct CvsRevision
};
// A log entry consisting of the file and its revisions.
struct CvsLogEntry
class CvsLogEntry
{
public:
CvsLogEntry(const QString &file);
QString file;
QList<CvsRevision> revisions;
};
QDebug operator<<(QDebug d, const CvsLogEntry &);
// Parse. Pass on a directory to obtain full paths when
// running from the repository directory.
QList<CvsLogEntry> parseLogEntries(const QString &output,
......@@ -83,5 +78,3 @@ bool isFirstRevision(const QString &r);
} // namespace Internal
} // namespace Cvs
#endif // CVSUTILS_H
......@@ -23,24 +23,13 @@
**
****************************************************************************/
#ifndef SETTINGSPAGE_H
#define SETTINGSPAGE_H
#pragma once
#include "ui_settingspage.h"
#include <vcsbase/vcsbaseoptionspage.h>
#include <QWidget>
#include <QPointer>
#include <QString>
QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE
namespace VcsBase {
class VcsBaseClientSettings;
} // namespace VcsBase
namespace VcsBase { class VcsBaseClientSettings; }
namespace Cvs {
namespace Internal {
......@@ -70,5 +59,3 @@ public:
} // namespace Cvs
} // namespace Internal
#endif // SETTINGSPAGE_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment