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: public:
CEditorApplication(int& rArgc, char **ppArgv); CEditorApplication(int& rArgc, char **ppArgv);
~CEditorApplication(); ~CEditorApplication() override;
void InitEditor(); void InitEditor();
bool CloseAllEditors(); bool CloseAllEditors();
bool CloseProject(); bool CloseProject();

View File

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

View File

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

View File

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

View File

@ -11,12 +11,12 @@ class CFileNameValidator : public QValidator
bool mIsDirectory; bool mIsDirectory;
public: public:
CFileNameValidator(bool IsDirectory, QObject *pParent = 0) CFileNameValidator(bool IsDirectory, QObject *pParent = nullptr)
: QValidator(pParent) : QValidator(pParent)
, mIsDirectory(IsDirectory) , mIsDirectory(IsDirectory)
{} {}
QValidator::State validate(QString& rInput, int&) const QValidator::State validate(QString& rInput, int&) const override
{ {
QValidator::State Out = QValidator::Acceptable; QValidator::State Out = QValidator::Acceptable;
@ -41,9 +41,9 @@ public:
return Out; 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); rInput = TO_QSTRING(Sanitized);
} }
}; };

View File

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

View File

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

View File

@ -7,31 +7,33 @@
#include <Core/Render/CRenderer.h> #include <Core/Render/CRenderer.h>
#include <Core/Render/IRenderable.h> #include <Core/Render/IRenderable.h>
#include <array>
class CLineRenderable : public IRenderable class CLineRenderable : public IRenderable
{ {
CVector3f mPoints[2]; std::array<CVector3f, 2> mPoints;
CColor mColor; CColor mColor;
public: public:
CLineRenderable() : IRenderable() {} CLineRenderable() : IRenderable() {}
inline void SetPoints(const CVector3f& rkPointA, const CVector3f& rkPointB) void SetPoints(const CVector3f& rkPointA, const CVector3f& rkPointB)
{ {
mPoints[0] = rkPointA; mPoints[0] = rkPointA;
mPoints[1] = rkPointB; mPoints[1] = rkPointB;
} }
inline void SetColor(const CColor& rkColor) void SetColor(const CColor& rkColor)
{ {
mColor = 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); 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::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
CGraphics::UpdateMVPBlock(); CGraphics::UpdateMVPBlock();

View File

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

View File

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

View File

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

View File

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

View File

@ -12,34 +12,34 @@ class CUIRelay : public QObject, public IUIRelay
{ {
Q_OBJECT 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; return IsUIThread ? Qt::DirectConnection : Qt::BlockingQueuedConnection;
} }
public: public:
explicit CUIRelay(QObject *pParent = 0) explicit CUIRelay(QObject *pParent = nullptr)
: QObject(pParent) : QObject(pParent)
{} {}
// Note: All function calls should be deferred with QMetaObject::invokeMethod to ensure // 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. // 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(), QMetaObject::invokeMethod(this, "MessageBoxSlot", GetConnectionType(),
Q_ARG(QString, TO_QSTRING(rkInfoBoxTitle)), Q_ARG(QString, TO_QSTRING(rkInfoBoxTitle)),
Q_ARG(QString, TO_QSTRING(rkMessage)) ); 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, QMetaObject::invokeMethod(this, "MessageBoxSlot", Qt::QueuedConnection,
Q_ARG(QString, TO_QSTRING(rkInfoBoxTitle)), Q_ARG(QString, TO_QSTRING(rkInfoBoxTitle)),
Q_ARG(QString, TO_QSTRING(rkMessage)) ); 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; bool RetVal;
QMetaObject::invokeMethod(this, "AskYesNoQuestionSlot", GetConnectionType(), QMetaObject::invokeMethod(this, "AskYesNoQuestionSlot", GetConnectionType(),
@ -49,7 +49,7 @@ public:
return RetVal; return RetVal;
} }
virtual bool OpenProject(const TString& kPath = "") bool OpenProject(const TString& kPath = "") override
{ {
bool RetVal; bool RetVal;
QMetaObject::invokeMethod(this, "OpenProjectSlot", GetConnectionType(), QMetaObject::invokeMethod(this, "OpenProjectSlot", GetConnectionType(),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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