CTweakEditor: Make use of in-class initializers where applicable

This commit is contained in:
Lioncash 2020-06-28 06:12:06 -04:00
parent 2cf3ac718b
commit 43250fb5ce
2 changed files with 16 additions and 18 deletions

View File

@ -16,17 +16,15 @@ public:
, mNewIndex(NewIndex)
{}
virtual void undo() override { mpEditor->SetActiveTweakIndex(mOldIndex); }
virtual void redo() override { mpEditor->SetActiveTweakIndex(mNewIndex); }
virtual bool AffectsCleanState() const override { return false; }
void undo() override { mpEditor->SetActiveTweakIndex(mOldIndex); }
void redo() override { mpEditor->SetActiveTweakIndex(mNewIndex); }
bool AffectsCleanState() const override { return false; }
};
/** CTweakEditor functions */
CTweakEditor::CTweakEditor(QWidget* pParent)
: IEditor(pParent)
, mpUI(new Ui::CTweakEditor)
, mCurrentTweakIndex(-1)
, mHasBeenShown(false)
, mpUI(std::make_unique<Ui::CTweakEditor>())
{
mpUI->setupUi(this);
mpUI->TweakTabs->setExpanding(false);
@ -39,12 +37,9 @@ CTweakEditor::CTweakEditor(QWidget* pParent)
connect(mpUI->ActionSaveAndRepack, SIGNAL(triggered(bool)), this, SLOT(SaveAndRepack()));
}
CTweakEditor::~CTweakEditor()
{
delete mpUI;
}
CTweakEditor::~CTweakEditor() = default;
bool CTweakEditor::HasTweaks()
bool CTweakEditor::HasTweaks() const
{
return !mTweakAssets.isEmpty();
}

View File

@ -2,6 +2,9 @@
#define CTWEAKEDITOR_H
#include "Editor/IEditor.h"
#include "Tweaks/CTweakData.h"
#include <memory>
namespace Ui {
class CTweakEditor;
@ -12,23 +15,23 @@ class CTweakEditor : public IEditor
Q_OBJECT
/** Qt UI */
Ui::CTweakEditor* mpUI;
std::unique_ptr<Ui::CTweakEditor> mpUI;
/** List of editable tweak assets */
QVector<CTweakData*> mTweakAssets;
/** Whether the editor window has been shown before */
bool mHasBeenShown;
bool mHasBeenShown = false;
/** Index of tweak data currently being edited */
int mCurrentTweakIndex;
int mCurrentTweakIndex = -1;
public:
explicit CTweakEditor(QWidget* pParent = 0);
~CTweakEditor();
bool HasTweaks();
explicit CTweakEditor(QWidget* pParent = nullptr);
~CTweakEditor() override;
virtual bool Save() override;
bool HasTweaks() const;
bool Save() override;
public slots:
void SetActiveTweakData(CTweakData* pTweakData);