ClearCase: Modernize

* Use pragma once
* Use static member initialization

Change-Id: Icec025b7c3b310286c675cef30cf01e220002ca8
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Tobias Hunger
2016-02-03 17:52:09 +01:00
parent 10e6181ccf
commit 9b3016c2e4
22 changed files with 83 additions and 171 deletions

View File

@@ -38,10 +38,8 @@
using namespace ClearCase; using namespace ClearCase;
using namespace ClearCase::Internal; using namespace ClearCase::Internal;
ActivitySelector::ActivitySelector(QWidget *parent) : ActivitySelector::ActivitySelector(QWidget *parent) : QWidget(parent),
QWidget(parent), m_plugin(ClearCasePlugin::instance())
m_plugin(ClearCasePlugin::instance()),
m_changed(false)
{ {
QTC_ASSERT(m_plugin->isUcm(), return); QTC_ASSERT(m_plugin->isUcm(), return);

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef ACTIVITYSELECTOR_H #pragma once
#define ACTIVITYSELECTOR_H
#include <QWidget> #include <QWidget>
@@ -43,7 +42,7 @@ class ActivitySelector : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit ActivitySelector(QWidget *parent = 0); explicit ActivitySelector(QWidget *parent = nullptr);
QString activity() const; QString activity() const;
void setActivity(const QString &act); void setActivity(const QString &act);
void addKeep(); void addKeep();
@@ -58,11 +57,9 @@ private slots:
private: private:
ClearCasePlugin *m_plugin; ClearCasePlugin *m_plugin;
bool m_changed; bool m_changed = false;
QComboBox *m_cmbActivity; QComboBox *m_cmbActivity;
}; };
} // namespace Internal } // namespace Internal
} // namespace ClearCase } // namespace ClearCase
#endif // ACTIVITYSELECTOR_H

View File

@@ -31,10 +31,8 @@ using namespace ClearCase::Internal;
ClearCaseAnnotationHighlighter::ClearCaseAnnotationHighlighter(const ChangeNumbers &changeNumbers, ClearCaseAnnotationHighlighter::ClearCaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document) : QTextDocument *document) :
VcsBase::BaseAnnotationHighlighter(changeNumbers, document), VcsBase::BaseAnnotationHighlighter(changeNumbers, document)
m_separator(QLatin1Char('|')) { }
{
}
QString ClearCaseAnnotationHighlighter::changeNumber(const QString &block) const QString ClearCaseAnnotationHighlighter::changeNumber(const QString &block) const
{ {

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef ANNOTATIONHIGHLIGHTER_H #pragma once
#define ANNOTATIONHIGHLIGHTER_H
#include <vcsbase/baseannotationhighlighter.h> #include <vcsbase/baseannotationhighlighter.h>
@@ -38,15 +37,13 @@ class ClearCaseAnnotationHighlighter : public VcsBase::BaseAnnotationHighlighter
Q_OBJECT Q_OBJECT
public: public:
explicit ClearCaseAnnotationHighlighter(const ChangeNumbers &changeNumbers, explicit ClearCaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document = 0); QTextDocument *document = nullptr);
private: private:
QString changeNumber(const QString &block) const; QString changeNumber(const QString &block) const override;
const QChar m_separator; const QChar m_separator = QLatin1Char('|');
}; };
} // namespace Internal } // namespace Internal
} // namespace ClearCase } // namespace ClearCase
#endif // ANNOTATIONHIGHLIGHTER_H

View File

@@ -36,8 +36,9 @@
namespace ClearCase { namespace ClearCase {
namespace Internal { namespace Internal {
CheckOutDialog::CheckOutDialog(const QString &fileName, bool isUcm, bool showComment, QWidget *parent) : CheckOutDialog::CheckOutDialog(const QString &fileName, bool isUcm, bool showComment,
QDialog(parent), ui(new Ui::CheckOutDialog), m_actSelector(0) QWidget *parent) :
QDialog(parent), ui(new Ui::CheckOutDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->lblFileName->setText(fileName); ui->lblFileName->setText(fileName);

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CHECKOUTDIALOG_H #pragma once
#define CHECKOUTDIALOG_H
#include <QDialog> #include <QDialog>
@@ -57,10 +56,8 @@ private slots:
private: private:
Ui::CheckOutDialog *ui; Ui::CheckOutDialog *ui;
ActivitySelector *m_actSelector; ActivitySelector *m_actSelector = nullptr;
}; };
} // namespace Internal } // namespace Internal
} // namespace ClearCase } // namespace ClearCase
#endif // CHECKOUTDIALOG_H

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLEARCASE_CONSTANTS_H #pragma once
#define CLEARCASE_CONSTANTS_H
#include <QtGlobal> #include <QtGlobal>
@@ -44,5 +43,3 @@ enum { debug = 0 };
} // namespace Constants } // namespace Constants
} // namespace ClearCase } // namespace ClearCase
#endif // CLEARCASE_CONSTANTS_H

View File

@@ -36,10 +36,8 @@
using namespace ClearCase; using namespace ClearCase;
using namespace ClearCase::Internal; using namespace ClearCase::Internal;
ClearCaseControl::ClearCaseControl(ClearCasePlugin *plugin) : ClearCaseControl::ClearCaseControl(ClearCasePlugin *plugin) : m_plugin(plugin)
m_plugin(plugin) { }
{
}
QString ClearCaseControl::displayName() const QString ClearCaseControl::displayName() const
{ {

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLEARCASECONTROL_H #pragma once
#define CLEARCASECONTROL_H
#include <coreplugin/iversioncontrol.h> #include <coreplugin/iversioncontrol.h>
@@ -68,10 +67,8 @@ public:
void emitConfigurationChanged(); void emitConfigurationChanged();
private: private:
ClearCasePlugin *m_plugin; ClearCasePlugin *const m_plugin;
}; };
} // namespace Internal } // namespace Internal
} // namespace ClearCase } // namespace ClearCase
#endif // CLEARCASECONTROL_H

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLEARCASEEDITOR_H #pragma once
#define CLEARCASEEDITOR_H
#include <vcsbase/vcsbaseeditor.h> #include <vcsbase/vcsbaseeditor.h>
@@ -52,5 +51,3 @@ private:
} // namespace Internal } // namespace Internal
} // namespace ClearCase } // namespace ClearCase
#endif // CLEARCASEEDITOR_H

View File

@@ -156,39 +156,9 @@ static QString debugCodec(const QTextCodec *c)
// ------------- ClearCasePlugin // ------------- ClearCasePlugin
ClearCasePlugin *ClearCasePlugin::m_clearcasePluginInstance = 0; ClearCasePlugin *ClearCasePlugin::m_clearcasePluginInstance = 0;
ViewData::ViewData() :
isDynamic(false),
isUcm(false)
{
}
ClearCasePlugin::ClearCasePlugin() : ClearCasePlugin::ClearCasePlugin() :
m_commandLocator(0),
m_checkOutAction(0),
m_checkInCurrentAction(0),
m_undoCheckOutAction(0),
m_undoHijackAction(0),
m_diffCurrentAction(0),
m_historyCurrentAction(0),
m_annotateCurrentAction(0),
m_addFileAction(0),
m_diffActivityAction(0),
m_updateIndexAction(0),
m_updateViewAction(0),
m_checkInActivityAction(0),
m_checkInAllAction(0),
m_statusAction(0),
m_checkInSelectedAction(0),
m_checkInDiffAction(0),
m_submitUndoAction(0),
m_submitRedoAction(0),
m_menuAction(0),
m_submitActionTriggered(false),
m_activityMutex(new QMutex), m_activityMutex(new QMutex),
m_statusMap(new StatusMap) m_statusMap(new StatusMap)
#ifdef WITH_TESTS
,m_fakeClearTool(false)
#endif
{ {
qRegisterMetaType<ClearCase::Internal::FileStatus::Status>("ClearCase::Internal::FileStatus::Status"); qRegisterMetaType<ClearCase::Internal::FileStatus::Status>("ClearCase::Internal::FileStatus::Status");
connect(qApp, &QApplication::applicationStateChanged, connect(qApp, &QApplication::applicationStateChanged,

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLEARCASEPLUGIN_H #pragma once
#define CLEARCASEPLUGIN_H
#include "clearcasesettings.h" #include "clearcasesettings.h"
@@ -102,11 +101,9 @@ typedef QHash<QString, FileStatus> StatusMap;
class ViewData class ViewData
{ {
public: public:
ViewData();
QString name; QString name;
bool isDynamic; bool isDynamic = false;
bool isUcm; bool isUcm = false;
QString root; QString root;
}; };
@@ -119,9 +116,9 @@ class ClearCasePlugin : public VcsBase::VcsBasePlugin
public: public:
ClearCasePlugin(); ClearCasePlugin();
~ClearCasePlugin(); ~ClearCasePlugin() override;
bool initialize(const QStringList &arguments, QString *error_message); bool initialize(const QStringList &arguments, QString *error_message) override;
ClearCaseSubmitEditor *openClearCaseSubmitEditor(const QString &fileName, bool isUcm); ClearCaseSubmitEditor *openClearCaseSubmitEditor(const QString &fileName, bool isUcm);
@@ -198,8 +195,8 @@ private slots:
#endif #endif
protected: protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState); void updateActions(VcsBase::VcsBasePlugin::ActionState) override;
bool submitEditorAboutToClose(); bool submitEditorAboutToClose() override;
QString ccGet(const QString &workingDir, const QString &file, const QString &prefix = QString()); QString ccGet(const QString &workingDir, const QString &file, const QString &prefix = QString());
QList<QStringPair> ccGetActivities() const; QList<QStringPair> ccGetActivities() const;
@@ -271,40 +268,38 @@ private:
QString m_activity; QString m_activity;
QString m_diffPrefix; QString m_diffPrefix;
Core::CommandLocator *m_commandLocator; Core::CommandLocator *m_commandLocator = nullptr;
Utils::ParameterAction *m_checkOutAction; Utils::ParameterAction *m_checkOutAction = nullptr;
Utils::ParameterAction *m_checkInCurrentAction; Utils::ParameterAction *m_checkInCurrentAction = nullptr;
Utils::ParameterAction *m_undoCheckOutAction; Utils::ParameterAction *m_undoCheckOutAction = nullptr;
Utils::ParameterAction *m_undoHijackAction; Utils::ParameterAction *m_undoHijackAction = nullptr;
Utils::ParameterAction *m_diffCurrentAction; Utils::ParameterAction *m_diffCurrentAction = nullptr;
Utils::ParameterAction *m_historyCurrentAction; Utils::ParameterAction *m_historyCurrentAction = nullptr;
Utils::ParameterAction *m_annotateCurrentAction; Utils::ParameterAction *m_annotateCurrentAction = nullptr;
Utils::ParameterAction *m_addFileAction; Utils::ParameterAction *m_addFileAction = nullptr;
QAction *m_diffActivityAction; QAction *m_diffActivityAction = nullptr;
QAction *m_updateIndexAction; QAction *m_updateIndexAction = nullptr;
Utils::ParameterAction *m_updateViewAction; Utils::ParameterAction *m_updateViewAction = nullptr;
Utils::ParameterAction *m_checkInActivityAction; Utils::ParameterAction *m_checkInActivityAction = nullptr;
QAction *m_checkInAllAction; QAction *m_checkInAllAction = nullptr;
QAction *m_statusAction; QAction *m_statusAction = nullptr;
QAction *m_checkInSelectedAction; QAction *m_checkInSelectedAction = nullptr;
QAction *m_checkInDiffAction; QAction *m_checkInDiffAction = nullptr;
QAction *m_submitUndoAction; QAction *m_submitUndoAction = nullptr;
QAction *m_submitRedoAction; QAction *m_submitRedoAction = nullptr;
QAction *m_menuAction; QAction *m_menuAction = nullptr;
bool m_submitActionTriggered; bool m_submitActionTriggered = false;
QMutex *m_activityMutex; QMutex *m_activityMutex;
QList<QStringPair> m_activities; QList<QStringPair> m_activities;
QSharedPointer<StatusMap> m_statusMap; QSharedPointer<StatusMap> m_statusMap;
static ClearCasePlugin *m_clearcasePluginInstance; static ClearCasePlugin *m_clearcasePluginInstance;
#ifdef WITH_TESTS #ifdef WITH_TESTS
bool m_fakeClearTool; bool m_fakeClearTool = false;
QString m_tempFile; QString m_tempFile;
#endif #endif
}; };
} // namespace Internal } // namespace Internal
} // namespace ClearCase } // namespace ClearCase
#endif // CLEARCASEPLUGIN_H

View File

@@ -60,15 +60,7 @@ using namespace ClearCase::Internal;
ClearCaseSettings::ClearCaseSettings() : ClearCaseSettings::ClearCaseSettings() :
ccCommand(defaultCommand()), ccCommand(defaultCommand()),
diffType(GraphicalDiff),
diffArgs(QLatin1String(defaultDiffArgs)), diffArgs(QLatin1String(defaultDiffArgs)),
autoAssignActivityName(true),
autoCheckOut(true),
noComment(false),
keepFileUndoCheckout(true),
promptToCheckIn(false),
disableIndexer(false),
extDiffAvailable(false),
historyCount(defaultHistoryCount), historyCount(defaultHistoryCount),
timeOutS(defaultTimeOutS) timeOutS(defaultTimeOutS)
{ } { }

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLEARCASESETTINGS_H #pragma once
#define CLEARCASESETTINGS_H
#include <QHash> #include <QHash>
#include <QString> #include <QString>
@@ -57,17 +56,17 @@ public:
QString ccCommand; QString ccCommand;
QString ccBinaryPath; QString ccBinaryPath;
DiffType diffType; DiffType diffType = GraphicalDiff;
QString diffArgs; QString diffArgs;
QString indexOnlyVOBs; QString indexOnlyVOBs;
QHash<QString, int> totalFiles; QHash<QString, int> totalFiles;
bool autoAssignActivityName; bool autoAssignActivityName = true;
bool autoCheckOut; bool autoCheckOut = true;
bool noComment; bool noComment = false;
bool keepFileUndoCheckout; bool keepFileUndoCheckout = true;
bool promptToCheckIn; bool promptToCheckIn = false;
bool disableIndexer; bool disableIndexer = false;
bool extDiffAvailable; bool extDiffAvailable = false;
int historyCount; int historyCount;
int timeOutS; int timeOutS;
}; };
@@ -79,5 +78,3 @@ inline bool operator!=(const ClearCaseSettings &p1, const ClearCaseSettings &p2)
} // namespace Internal } // namespace Internal
} // namespace ClearCase } // namespace ClearCase
#endif // CLEARCASESETTINGS_H

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLEARCASESUBMITEDITOR_H #pragma once
#define CLEARCASESUBMITEDITOR_H
#include <vcsbase/vcsbasesubmiteditor.h> #include <vcsbase/vcsbasesubmiteditor.h>
@@ -50,10 +49,7 @@ public:
protected: protected:
QByteArray fileContents() const override; QByteArray fileContents() const override;
}; };
} // namespace Internal } // namespace Internal
} // namespace ClearCase } // namespace ClearCase
#endif // CLEARCASESUBMITEDITOR_H

View File

@@ -36,7 +36,6 @@
using namespace ClearCase::Internal; using namespace ClearCase::Internal;
ClearCaseSubmitEditorWidget::ClearCaseSubmitEditorWidget() ClearCaseSubmitEditorWidget::ClearCaseSubmitEditorWidget()
: m_actSelector(0)
{ {
setDescriptionMandatory(false); setDescriptionMandatory(false);
auto checkInWidget = new QWidget(this); auto checkInWidget = new QWidget(this);

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLEARCASESUBMITEDITORWIDGET_H #pragma once
#define CLEARCASESUBMITEDITORWIDGET_H
#include <vcsbase/submiteditorwidget.h> #include <vcsbase/submiteditorwidget.h>
@@ -58,7 +57,7 @@ protected:
QString commitName() const; QString commitName() const;
private: private:
ActivitySelector *m_actSelector; ActivitySelector *m_actSelector = nullptr;
QCheckBox *m_chkIdentical; QCheckBox *m_chkIdentical;
QCheckBox *m_chkPTime; QCheckBox *m_chkPTime;
QVBoxLayout *m_verticalLayout; QVBoxLayout *m_verticalLayout;
@@ -66,5 +65,3 @@ private:
} // namespace Internal } // namespace Internal
} // namespace ClearCase } // namespace ClearCase
#endif // CLEARCASESUBMITEDITORWIDGET_H

View File

@@ -43,8 +43,7 @@ namespace Internal {
ClearCaseSync::ClearCaseSync(ClearCasePlugin *plugin, QSharedPointer<StatusMap> statusMap) : ClearCaseSync::ClearCaseSync(ClearCasePlugin *plugin, QSharedPointer<StatusMap> statusMap) :
m_plugin(plugin), m_plugin(plugin),
m_statusMap(statusMap) m_statusMap(statusMap)
{ { }
}
QStringList ClearCaseSync::updateStatusHotFiles(const QString &viewRoot, int &total) QStringList ClearCaseSync::updateStatusHotFiles(const QString &viewRoot, int &total)
{ {

View File

@@ -23,8 +23,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLEARCASESYNC_H #pragma once
#define CLEARCASESYNC_H
#include "clearcaseplugin.h" #include "clearcaseplugin.h"
@@ -55,7 +54,7 @@ signals:
void updateStreamAndView(); void updateStreamAndView();
private: private:
ClearCasePlugin *m_plugin; ClearCasePlugin *const m_plugin;
QSharedPointer<StatusMap> m_statusMap; QSharedPointer<StatusMap> m_statusMap;
public slots: public slots:
@@ -69,10 +68,7 @@ public slots:
void verifyFileNotManagedDynamicView(); void verifyFileNotManagedDynamicView();
#endif #endif
}; };
} // namespace Internal } // namespace Internal
} // namespace ClearCase } // namespace ClearCase
#endif // CLEARCASESYNC_H

View File

@@ -42,8 +42,7 @@
using namespace ClearCase::Internal; using namespace ClearCase::Internal;
using namespace Utils; using namespace Utils;
SettingsPageWidget::SettingsPageWidget(QWidget *parent) : SettingsPageWidget::SettingsPageWidget(QWidget *parent) : QWidget(parent)
QWidget(parent)
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
m_ui.commandPathChooser->setPromptDialogTitle(tr("ClearCase Command")); m_ui.commandPathChooser->setPromptDialogTitle(tr("ClearCase Command"));
@@ -105,8 +104,7 @@ void SettingsPageWidget::setSettings(const ClearCaseSettings &s)
m_ui.indexOnlyVOBsEdit->setText(s.indexOnlyVOBs); m_ui.indexOnlyVOBsEdit->setText(s.indexOnlyVOBs);
} }
SettingsPage::SettingsPage() : SettingsPage::SettingsPage()
m_widget(0)
{ {
setId(ClearCase::Constants::VCS_ID_CLEARCASE); setId(ClearCase::Constants::VCS_ID_CLEARCASE);
setDisplayName(tr("ClearCase")); setDisplayName(tr("ClearCase"));

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef SETTINGSPAGE_H #pragma once
#define SETTINGSPAGE_H
#include <vcsbase/vcsbaseoptionspage.h> #include <vcsbase/vcsbaseoptionspage.h>
@@ -43,7 +42,7 @@ class SettingsPageWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit SettingsPageWidget(QWidget *parent = 0); explicit SettingsPageWidget(QWidget *parent = nullptr);
ClearCaseSettings settings() const; ClearCaseSettings settings() const;
void setSettings(const ClearCaseSettings &); void setSettings(const ClearCaseSettings &);
@@ -60,15 +59,13 @@ class SettingsPage : public VcsBase::VcsBaseOptionsPage
public: public:
SettingsPage(); SettingsPage();
QWidget *widget(); QWidget *widget() override;
void apply(); void apply() override;
void finish() { } void finish() override { }
private: private:
QPointer<SettingsPageWidget> m_widget; QPointer<SettingsPageWidget> m_widget = nullptr;
}; };
} // namespace ClearCase } // namespace ClearCase
} // namespace Internal } // namespace Internal
#endif // SETTINGSPAGE_H

View File

@@ -24,8 +24,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef VERSIONSELECTOR_H #pragma once
#define VERSIONSELECTOR_H
#include <QDialog> #include <QDialog>
@@ -43,18 +42,18 @@ class VersionSelector : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit VersionSelector(const QString &fileName, const QString &message, QWidget *parent = 0); explicit VersionSelector(const QString &fileName, const QString &message,
~VersionSelector(); QWidget *parent = nullptr);
~VersionSelector() override;
bool isUpdate() const; bool isUpdate() const;
private: private:
bool readValues();
Ui::VersionSelector *ui; Ui::VersionSelector *ui;
QTextStream *m_stream; QTextStream *m_stream;
QString m_versionID, m_createdBy, m_createdOn, m_message; QString m_versionID, m_createdBy, m_createdOn, m_message;
bool readValues();
}; };
} // namespace Internal } // namespace Internal
} // namespace ClearCase } // namespace ClearCase
#endif // VERSIONSELECTOR_H