General: Make use of override where applicable

This commit is contained in:
Lioncash 2020-06-28 07:36:36 -04:00
parent 5f9c58170c
commit 9bc2723498
19 changed files with 89 additions and 96 deletions

View File

@ -33,7 +33,8 @@ class CEditorApplication : public QApplication
public:
CEditorApplication(int& rArgc, char **ppArgv);
~CEditorApplication();
~CEditorApplication() override;
void InitEditor();
bool CloseAllEditors();
bool CloseProject();

View File

@ -5,16 +5,13 @@
CErrorLogDialog::CErrorLogDialog(QWidget *pParent)
: QDialog(pParent)
, ui(new Ui::CErrorLogDialog)
, ui(std::make_unique<Ui::CErrorLogDialog>())
{
ui->setupUi(this);
connect(ui->CloseButton, SIGNAL(clicked()), this, SLOT(close()));
}
CErrorLogDialog::~CErrorLogDialog()
{
delete ui;
}
CErrorLogDialog::~CErrorLogDialog() = default;
bool CErrorLogDialog::GatherErrors()
{

View File

@ -3,6 +3,8 @@
#include <QDialog>
#include <memory>
namespace Ui {
class CErrorLogDialog;
}
@ -12,12 +14,13 @@ class CErrorLogDialog : public QDialog
Q_OBJECT
public:
explicit CErrorLogDialog(QWidget *pParent = 0);
~CErrorLogDialog();
explicit CErrorLogDialog(QWidget *pParent = nullptr);
~CErrorLogDialog() override;
bool GatherErrors();
private:
Ui::CErrorLogDialog *ui;
std::unique_ptr<Ui::CErrorLogDialog> ui;
};
#endif // CERRORLOGDIALOG_H

View File

@ -36,7 +36,7 @@ class CExportGameDialog : public QDialog
public:
explicit CExportGameDialog(const QString& rkIsoPath, const QString& rkExportDir, QWidget *pParent = nullptr);
~CExportGameDialog();
~CExportGameDialog() override;
void InitUI(QString ExportDir);
bool ValidateGame();

View File

@ -11,12 +11,12 @@ class CFileNameValidator : public QValidator
bool mIsDirectory;
public:
CFileNameValidator(bool IsDirectory, QObject *pParent = 0)
CFileNameValidator(bool IsDirectory, QObject *pParent = nullptr)
: QValidator(pParent)
, mIsDirectory(IsDirectory)
{}
QValidator::State validate(QString& rInput, int&) const
QValidator::State validate(QString& rInput, int&) const override
{
QValidator::State Out = QValidator::Acceptable;
@ -41,9 +41,9 @@ public:
return Out;
}
void fixup(QString& rInput) const
void fixup(QString& rInput) const override
{
TString Sanitized = FileUtil::SanitizeName( TO_TSTRING(rInput), mIsDirectory );
const TString Sanitized = FileUtil::SanitizeName(TO_TSTRING(rInput), mIsDirectory);
rInput = TO_QSTRING(Sanitized);
}
};

View File

@ -59,7 +59,7 @@ class CGeneratePropertyNamesDialog : public QDialog
public:
explicit CGeneratePropertyNamesDialog(QWidget *pParent = nullptr);
~CGeneratePropertyNamesDialog();
~CGeneratePropertyNamesDialog() override;
/** Add a property to the ID pool */
void AddToIDPool(IProperty* pProperty);

View File

@ -7,27 +7,24 @@
// Tiny helper to make sure the grid draws at the correct depth.
class CGridRenderable : public IRenderable
{
CColor mLineColor;
CColor mBoldLineColor;
CColor mLineColor{0.6f, 0.6f, 0.6f, 0.f};
CColor mBoldLineColor{0.f, 0.f, 0.f, 0.f};
public:
CGridRenderable()
: mLineColor(0.6f, 0.6f, 0.6f, 0.f)
, mBoldLineColor(0.f, 0.f, 0.f, 0.f)
{}
CGridRenderable() = default;
inline void SetColor(const CColor& rkLineColor, const CColor& rkBoldColor)
void SetColor(const CColor& rkLineColor, const CColor& rkBoldColor)
{
mLineColor = rkLineColor;
mBoldLineColor = rkBoldColor;
}
void AddToRenderer(CRenderer *pRenderer, const SViewInfo&)
void AddToRenderer(CRenderer *pRenderer, const SViewInfo&) override
{
pRenderer->AddMesh(this, 0, CAABox::One(), false, ERenderCommand::DrawMesh);
}
void Draw(FRenderOptions, int, ERenderCommand, const SViewInfo&)
void Draw(FRenderOptions, int, ERenderCommand, const SViewInfo&) override
{
CDrawUtil::DrawGrid(mLineColor, mBoldLineColor);
}

View File

@ -7,31 +7,33 @@
#include <Core/Render/CRenderer.h>
#include <Core/Render/IRenderable.h>
#include <array>
class CLineRenderable : public IRenderable
{
CVector3f mPoints[2];
std::array<CVector3f, 2> mPoints;
CColor mColor;
public:
CLineRenderable() : IRenderable() {}
inline void SetPoints(const CVector3f& rkPointA, const CVector3f& rkPointB)
void SetPoints(const CVector3f& rkPointA, const CVector3f& rkPointB)
{
mPoints[0] = rkPointA;
mPoints[1] = rkPointB;
}
inline void SetColor(const CColor& rkColor)
void SetColor(const CColor& rkColor)
{
mColor = rkColor;
}
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& /*rkViewInfo*/)
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& /*rkViewInfo*/) override
{
pRenderer->AddMesh(this, -1, CAABox::Infinite(), false, ERenderCommand::DrawMesh);
}
void Draw(FRenderOptions, int, ERenderCommand, const SViewInfo&)
void Draw(FRenderOptions, int, ERenderCommand, const SViewInfo&) override
{
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
CGraphics::UpdateMVPBlock();

View File

@ -11,18 +11,16 @@ class CNodeSelection : public QObject
{
Q_OBJECT
FNodeFlags mAllowedNodes;
FNodeFlags mAllowedNodes{ENodeType::All};
QList<CSceneNode*> mSelectedNodes;
mutable CAABox mCachedBounds;
mutable bool mBoundsDirty;
mutable bool mBoundsDirty = true;
public:
CNodeSelection()
: mAllowedNodes(ENodeType::All)
, mBoundsDirty(true) {}
CNodeSelection() = default;
~CNodeSelection()
~CNodeSelection() override
{
foreach (CSceneNode *pNode, mSelectedNodes)
pNode->SetSelected(false);
@ -107,17 +105,17 @@ public:
return mCachedBounds;
}
inline uint32 Size() const { return mSelectedNodes.size(); }
inline bool IsEmpty() const { return Size() == 0; }
inline CSceneNode* At(uint32 Index) const { return mSelectedNodes[Index]; }
inline CSceneNode* Front() const { return mSelectedNodes.front(); }
inline CSceneNode* Back() const { return mSelectedNodes.back(); }
inline CSceneNode* operator[](uint32 Index) const { return mSelectedNodes[Index]; }
inline void UpdateBounds() { mBoundsDirty = true; }
inline void SetAllowedNodeTypes(FNodeFlags Types) { mAllowedNodes = Types; }
inline bool IsAllowedType(ENodeType Type) const { return (mAllowedNodes & Type) != 0; }
inline bool IsAllowedType(CSceneNode *pNode) const { return (mAllowedNodes & pNode->NodeType()) != 0; }
inline QList<CSceneNode*> SelectedNodeList() const { return mSelectedNodes; }
uint32 Size() const { return mSelectedNodes.size(); }
bool IsEmpty() const { return Size() == 0; }
CSceneNode* At(uint32 Index) const { return mSelectedNodes[Index]; }
CSceneNode* Front() const { return mSelectedNodes.front(); }
CSceneNode* Back() const { return mSelectedNodes.back(); }
CSceneNode* operator[](uint32 Index) const { return mSelectedNodes[Index]; }
void UpdateBounds() { mBoundsDirty = true; }
void SetAllowedNodeTypes(FNodeFlags Types) { mAllowedNodes = Types; }
bool IsAllowedType(ENodeType Type) const { return (mAllowedNodes & Type) != 0; }
bool IsAllowedType(CSceneNode *pNode) const { return (mAllowedNodes & pNode->NodeType()) != 0; }
QList<CSceneNode*> SelectedNodeList() const { return mSelectedNodes; }
signals:
void Modified();

View File

@ -9,36 +9,32 @@
class CProgressBarNotifier : public IProgressNotifier
{
/** The progress bar we are relaying updates to */
QProgressBar* mpProgressBar;
QProgressBar* mpProgressBar = nullptr;
/** Whether the user has requested to cancel */
bool mCancel;
bool mCancel = false;
public:
CProgressBarNotifier()
: IProgressNotifier()
, mpProgressBar(nullptr)
, mCancel(false)
{}
CProgressBarNotifier() = default;
inline void SetProgressBar(QProgressBar* pProgressBar)
void SetProgressBar(QProgressBar* pProgressBar)
{
mpProgressBar = pProgressBar;
}
inline void SetCanceled(bool ShouldCancel)
void SetCanceled(bool ShouldCancel)
{
mCancel = ShouldCancel;
}
/** IProgressNotifier interface */
virtual bool ShouldCancel() const
bool ShouldCancel() const override
{
return mCancel;
}
protected:
virtual void UpdateProgress(const TString &, const TString &, float ProgressPercent)
void UpdateProgress(const TString &, const TString &, float ProgressPercent) override
{
if (mpProgressBar)
{

View File

@ -36,7 +36,7 @@ class CProgressDialog : public IProgressNotifierUI
public:
explicit CProgressDialog(QString OperationName, bool UseBusyIndicator, bool AlertOnFinish, QWidget *pParent = nullptr);
~CProgressDialog();
~CProgressDialog() override;
void DisallowCanceling();

View File

@ -16,10 +16,10 @@ class CPropertyNameValidator : public QValidator
QString mTypeNameOverride;
public:
CPropertyNameValidator(QObject* pParent = 0);
explicit CPropertyNameValidator(QObject* pParent = nullptr);
/** Perform validation */
QValidator::State validate(QString& rInput, int& rPos) const;
QValidator::State validate(QString& rInput, int& rPos) const override;
public slots:
/** Set the property to validate against */

View File

@ -12,34 +12,34 @@ class CUIRelay : public QObject, public IUIRelay
{
Q_OBJECT
Qt::ConnectionType GetConnectionType()
Qt::ConnectionType GetConnectionType() const
{
bool IsUIThread = (QThread::currentThread() == gpEdApp->thread());
const bool IsUIThread = (QThread::currentThread() == gpEdApp->thread());
return IsUIThread ? Qt::DirectConnection : Qt::BlockingQueuedConnection;
}
public:
explicit CUIRelay(QObject *pParent = 0)
explicit CUIRelay(QObject *pParent = nullptr)
: QObject(pParent)
{}
// Note: All function calls should be deferred with QMetaObject::invokeMethod to ensure
// that they run on the UI thread instead of whatever thread we happen to be on.
virtual void ShowMessageBox(const TString& rkInfoBoxTitle, const TString& rkMessage)
void ShowMessageBox(const TString& rkInfoBoxTitle, const TString& rkMessage) override
{
QMetaObject::invokeMethod(this, "MessageBoxSlot", GetConnectionType(),
Q_ARG(QString, TO_QSTRING(rkInfoBoxTitle)),
Q_ARG(QString, TO_QSTRING(rkMessage)) );
}
virtual void ShowMessageBoxAsync(const TString& rkInfoBoxTitle, const TString& rkMessage)
void ShowMessageBoxAsync(const TString& rkInfoBoxTitle, const TString& rkMessage) override
{
QMetaObject::invokeMethod(this, "MessageBoxSlot", Qt::QueuedConnection,
Q_ARG(QString, TO_QSTRING(rkInfoBoxTitle)),
Q_ARG(QString, TO_QSTRING(rkMessage)) );
}
virtual bool AskYesNoQuestion(const TString& rkInfoBoxTitle, const TString& rkQuestion)
bool AskYesNoQuestion(const TString& rkInfoBoxTitle, const TString& rkQuestion) override
{
bool RetVal;
QMetaObject::invokeMethod(this, "AskYesNoQuestionSlot", GetConnectionType(),
@ -49,7 +49,7 @@ public:
return RetVal;
}
virtual bool OpenProject(const TString& kPath = "")
bool OpenProject(const TString& kPath = "") override
{
bool RetVal;
QMetaObject::invokeMethod(this, "OpenProjectSlot", GetConnectionType(),

View File

@ -43,15 +43,16 @@ class CCharacterEditor : public IEditor
public:
explicit CCharacterEditor(CAnimSet *pSet, QWidget *parent = nullptr);
~CCharacterEditor();
void EditorTick(float DeltaTime);
~CCharacterEditor() override;
void EditorTick(float DeltaTime) override;
void UpdateAnimTime(float DeltaTime);
void UpdateCameraOrbit();
CSkeleton* CurrentSkeleton() const;
CAnimation* CurrentAnimation() const;
void SetActiveAnimSet(CAnimSet *pSet);
void SetSelectedBone(CBone *pBone);
CCharacterEditorViewport* Viewport() const;
CCharacterEditorViewport* Viewport() const override;
public slots:
void ToggleGrid(bool Enable);

View File

@ -18,7 +18,8 @@ class CCharacterEditorViewport : public CBasicViewport
public:
explicit CCharacterEditorViewport(QWidget* pParent = nullptr);
~CCharacterEditorViewport();
~CCharacterEditorViewport() override;
void SetNode(CCharacterNode *pNode);
void CheckUserInput() override;
void Paint() override;

View File

@ -9,7 +9,7 @@
class IProgressNotifierUI : public QDialog, public IProgressNotifier
{
public:
explicit IProgressNotifierUI(QWidget *pParent = 0)
explicit IProgressNotifierUI(QWidget *pParent = nullptr)
: QDialog(pParent)
{}
@ -17,7 +17,7 @@ public slots:
virtual void UpdateUI(const QString& rkTaskDesc, const QString& rkStepDesc, float ProgressPercent) = 0;
private:
virtual void UpdateProgress(const TString& rkTaskDesc, const TString& rkStepDesc, float ProgressPercent) final
void UpdateProgress(const TString& rkTaskDesc, const TString& rkStepDesc, float ProgressPercent) final
{
// Defer the function call to make sure UI updates are done on the main thread
QMetaObject::invokeMethod(this, "UpdateUI", Qt::AutoConnection,

View File

@ -5,7 +5,7 @@
TestDialog::TestDialog(QWidget *pParent)
: QDialog(pParent)
, ui(new Ui::TestDialog)
, ui(std::make_unique<Ui::TestDialog>())
{
ui->setupUi(this);
connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(OnSpinBoxChanged(int)));
@ -13,10 +13,7 @@ TestDialog::TestDialog(QWidget *pParent)
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(OnFind()));
}
TestDialog::~TestDialog()
{
delete ui;
}
TestDialog::~TestDialog() = default;
void TestDialog::OnSpinBoxChanged(int NewValue)
{

View File

@ -3,6 +3,8 @@
#include <QDialog>
#include <memory>
namespace Ui {
class TestDialog;
}
@ -12,15 +14,15 @@ class TestDialog : public QDialog
Q_OBJECT
public:
explicit TestDialog(QWidget *pParent = 0);
~TestDialog();
explicit TestDialog(QWidget *pParent = nullptr);
~TestDialog() override;
public slots:
void OnSpinBoxChanged(int NewValue);
void OnFind();
private:
Ui::TestDialog *ui;
std::unique_ptr<Ui::TestDialog> ui;
};
#endif // TESTDIALOG_H

View File

@ -21,10 +21,10 @@ public:
private:
struct SEntry
{
uint32 ID;
uint32 ID = 0;
QString Name;
SEntry() {}
SEntry() = default;
SEntry(uint32 _ID, const QString& rkName)
: ID(_ID), Name(rkName) {}
@ -35,31 +35,29 @@ private:
};
QList<SEntry> mEntries;
CGameTemplate *mpGame;
CScriptTemplate *mpScript;
CGameTemplate *mpGame = nullptr;
CScriptTemplate *mpScript = nullptr;
EType mType;
public:
explicit CStateMessageModel(EType Type, QObject *pParent = 0)
explicit CStateMessageModel(EType Type, QObject *pParent = nullptr)
: QAbstractListModel(pParent)
, mType(Type)
, mpGame(nullptr)
, mpScript(nullptr)
{}
int rowCount(const QModelIndex& /*rkParent*/) const
int rowCount(const QModelIndex& /*rkParent*/) const override
{
return mEntries.size();
}
QVariant data(const QModelIndex& rkIndex, int Role) const
QVariant data(const QModelIndex& rkIndex, int Role) const override
{
if (Role == Qt::DisplayRole)
{
return mEntries[rkIndex.row()].Name;
}
else return QVariant::Invalid;
return QVariant::Invalid;
}
void SetGameTemplate(CGameTemplate *pGame)
@ -101,7 +99,7 @@ public:
return iState;
}
return -1;
return UINT32_MAX;
}
uint32 MessageIndex(uint32 MessageID) const
@ -114,20 +112,20 @@ public:
return iMsg;
}
return -1;
return UINT32_MAX;
}
inline void SetScriptTemplate(CScriptTemplate *pScript)
void SetScriptTemplate(CScriptTemplate *pScript)
{
mpScript = pScript;
}
inline uint32 State(uint32 Index) const
uint32 State(uint32 Index) const
{
return (mType == EType::States ? mEntries[Index].ID : 0);
}
inline uint32 Message(uint32 Index) const
uint32 Message(uint32 Index) const
{
return (mType == EType::Messages ? mEntries[Index].ID : 0);
}