CStringEditor: Make use of in-class initializers where applicable

This commit is contained in:
Lioncash 2020-06-28 05:57:22 -04:00
parent 53cd2a09e9
commit d70c9faea0
2 changed files with 23 additions and 29 deletions

View File

@ -9,7 +9,7 @@
#include <QShortcut>
/** Settings strings */
const char* gkpLanguageSetting = "StringEditor/EditLanguage";
constexpr char gkpLanguageSetting[] = "StringEditor/EditLanguage";
/** Command classes */
class CSetStringIndexCommand : public IUndoCommand
@ -21,9 +21,9 @@ public:
: IUndoCommand("Select String"), mpEditor(pEditor), mOldIndex(OldIndex), mNewIndex(NewIndex)
{}
virtual void undo() override { mpEditor->SetActiveString(mOldIndex); }
virtual void redo() override { mpEditor->SetActiveString(mNewIndex); }
virtual bool AffectsCleanState() const override { return false; }
void undo() override { mpEditor->SetActiveString(mOldIndex); }
void redo() override { mpEditor->SetActiveString(mNewIndex); }
bool AffectsCleanState() const override { return false; }
};
class CSetLanguageCommand : public IUndoCommand
@ -35,30 +35,22 @@ public:
: IUndoCommand("Select Language"), mpEditor(pEditor), mOldLanguage(OldLanguage), mNewLanguage(NewLanguage)
{}
virtual void undo() override { mpEditor->SetActiveLanguage(mOldLanguage); }
virtual void redo() override { mpEditor->SetActiveLanguage(mNewLanguage); }
virtual bool AffectsCleanState() const override { return false; }
void undo() override { mpEditor->SetActiveLanguage(mOldLanguage); }
void redo() override { mpEditor->SetActiveLanguage(mNewLanguage); }
bool AffectsCleanState() const override { return false; }
};
/** Constructor */
CStringEditor::CStringEditor(CStringTable* pStringTable, QWidget* pParent)
: IEditor(pParent)
, mpUI(new Ui::CStringEditor)
, mpUI(std::make_unique<Ui::CStringEditor>())
, mpStringTable(pStringTable)
, mCurrentLanguage(ELanguage::English)
, mCurrentStringIndex(-1)
, mCurrentStringCount(0)
, mIsEditingStringName(false)
, mIsEditingStringData(false)
{
InitUI();
// LoadSettings(); // Disabled for now
}
CStringEditor::~CStringEditor()
{
delete mpUI;
}
CStringEditor::~CStringEditor() = default;
bool CStringEditor::Save()
{

View File

@ -8,6 +8,8 @@
#include <QMainWindow>
#include <memory>
namespace Ui {
class CStringEditor;
}
@ -18,33 +20,33 @@ class CStringEditor : public IEditor
Q_OBJECT
/** Qt UI */
Ui::CStringEditor* mpUI;
std::unique_ptr<Ui::CStringEditor> mpUI;
/** String table asset being edited */
TResPtr<CStringTable> mpStringTable;
/** Language being edited */
ELanguage mCurrentLanguage;
ELanguage mCurrentLanguage{ELanguage::English};
/** Index of the string being edited */
uint mCurrentStringIndex;
uint32 mCurrentStringIndex = UINT32_MAX;
/** Current string count */
uint mCurrentStringCount;
uint32 mCurrentStringCount = 0;
/** Model for the string list view */
CStringListModel* mpListModel;
CStringListModel* mpListModel = nullptr;
/** Editor state flags */
bool mIsEditingStringName;
bool mIsEditingStringData;
bool mIsEditingStringName = false;
bool mIsEditingStringData = false;
public:
explicit CStringEditor(CStringTable* pStringTable, QWidget* pParent = 0);
~CStringEditor();
explicit CStringEditor(CStringTable* pStringTable, QWidget* pParent = nullptr);
~CStringEditor() override;
virtual bool Save() override;
virtual bool eventFilter(QObject* pWatched, QEvent* pEvent) override;
bool Save() override;
bool eventFilter(QObject* pWatched, QEvent* pEvent) override;
void InitUI();
void UpdateStatusBar();
@ -55,7 +57,7 @@ public:
void SaveSettings();
// Accessors
inline CStringTable* StringTable() const { return mpStringTable; }
CStringTable* StringTable() const { return mpStringTable; }
public slots:
void UpdateUI();