CStringEditor: Make use of in-class initializers where applicable
This commit is contained in:
parent
53cd2a09e9
commit
d70c9faea0
|
@ -9,7 +9,7 @@
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
/** Settings strings */
|
/** Settings strings */
|
||||||
const char* gkpLanguageSetting = "StringEditor/EditLanguage";
|
constexpr char gkpLanguageSetting[] = "StringEditor/EditLanguage";
|
||||||
|
|
||||||
/** Command classes */
|
/** Command classes */
|
||||||
class CSetStringIndexCommand : public IUndoCommand
|
class CSetStringIndexCommand : public IUndoCommand
|
||||||
|
@ -21,9 +21,9 @@ public:
|
||||||
: IUndoCommand("Select String"), mpEditor(pEditor), mOldIndex(OldIndex), mNewIndex(NewIndex)
|
: IUndoCommand("Select String"), mpEditor(pEditor), mOldIndex(OldIndex), mNewIndex(NewIndex)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void undo() override { mpEditor->SetActiveString(mOldIndex); }
|
void undo() override { mpEditor->SetActiveString(mOldIndex); }
|
||||||
virtual void redo() override { mpEditor->SetActiveString(mNewIndex); }
|
void redo() override { mpEditor->SetActiveString(mNewIndex); }
|
||||||
virtual bool AffectsCleanState() const override { return false; }
|
bool AffectsCleanState() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CSetLanguageCommand : public IUndoCommand
|
class CSetLanguageCommand : public IUndoCommand
|
||||||
|
@ -35,30 +35,22 @@ public:
|
||||||
: IUndoCommand("Select Language"), mpEditor(pEditor), mOldLanguage(OldLanguage), mNewLanguage(NewLanguage)
|
: IUndoCommand("Select Language"), mpEditor(pEditor), mOldLanguage(OldLanguage), mNewLanguage(NewLanguage)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void undo() override { mpEditor->SetActiveLanguage(mOldLanguage); }
|
void undo() override { mpEditor->SetActiveLanguage(mOldLanguage); }
|
||||||
virtual void redo() override { mpEditor->SetActiveLanguage(mNewLanguage); }
|
void redo() override { mpEditor->SetActiveLanguage(mNewLanguage); }
|
||||||
virtual bool AffectsCleanState() const override { return false; }
|
bool AffectsCleanState() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
CStringEditor::CStringEditor(CStringTable* pStringTable, QWidget* pParent)
|
CStringEditor::CStringEditor(CStringTable* pStringTable, QWidget* pParent)
|
||||||
: IEditor(pParent)
|
: IEditor(pParent)
|
||||||
, mpUI(new Ui::CStringEditor)
|
, mpUI(std::make_unique<Ui::CStringEditor>())
|
||||||
, mpStringTable(pStringTable)
|
, mpStringTable(pStringTable)
|
||||||
, mCurrentLanguage(ELanguage::English)
|
|
||||||
, mCurrentStringIndex(-1)
|
|
||||||
, mCurrentStringCount(0)
|
|
||||||
, mIsEditingStringName(false)
|
|
||||||
, mIsEditingStringData(false)
|
|
||||||
{
|
{
|
||||||
InitUI();
|
InitUI();
|
||||||
// LoadSettings(); // Disabled for now
|
// LoadSettings(); // Disabled for now
|
||||||
}
|
}
|
||||||
|
|
||||||
CStringEditor::~CStringEditor()
|
CStringEditor::~CStringEditor() = default;
|
||||||
{
|
|
||||||
delete mpUI;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CStringEditor::Save()
|
bool CStringEditor::Save()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class CStringEditor;
|
class CStringEditor;
|
||||||
}
|
}
|
||||||
|
@ -18,33 +20,33 @@ class CStringEditor : public IEditor
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
/** Qt UI */
|
/** Qt UI */
|
||||||
Ui::CStringEditor* mpUI;
|
std::unique_ptr<Ui::CStringEditor> mpUI;
|
||||||
|
|
||||||
/** String table asset being edited */
|
/** String table asset being edited */
|
||||||
TResPtr<CStringTable> mpStringTable;
|
TResPtr<CStringTable> mpStringTable;
|
||||||
|
|
||||||
/** Language being edited */
|
/** Language being edited */
|
||||||
ELanguage mCurrentLanguage;
|
ELanguage mCurrentLanguage{ELanguage::English};
|
||||||
|
|
||||||
/** Index of the string being edited */
|
/** Index of the string being edited */
|
||||||
uint mCurrentStringIndex;
|
uint32 mCurrentStringIndex = UINT32_MAX;
|
||||||
|
|
||||||
/** Current string count */
|
/** Current string count */
|
||||||
uint mCurrentStringCount;
|
uint32 mCurrentStringCount = 0;
|
||||||
|
|
||||||
/** Model for the string list view */
|
/** Model for the string list view */
|
||||||
CStringListModel* mpListModel;
|
CStringListModel* mpListModel = nullptr;
|
||||||
|
|
||||||
/** Editor state flags */
|
/** Editor state flags */
|
||||||
bool mIsEditingStringName;
|
bool mIsEditingStringName = false;
|
||||||
bool mIsEditingStringData;
|
bool mIsEditingStringData = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CStringEditor(CStringTable* pStringTable, QWidget* pParent = 0);
|
explicit CStringEditor(CStringTable* pStringTable, QWidget* pParent = nullptr);
|
||||||
~CStringEditor();
|
~CStringEditor() override;
|
||||||
|
|
||||||
virtual bool Save() override;
|
bool Save() override;
|
||||||
virtual bool eventFilter(QObject* pWatched, QEvent* pEvent) override;
|
bool eventFilter(QObject* pWatched, QEvent* pEvent) override;
|
||||||
|
|
||||||
void InitUI();
|
void InitUI();
|
||||||
void UpdateStatusBar();
|
void UpdateStatusBar();
|
||||||
|
@ -55,7 +57,7 @@ public:
|
||||||
void SaveSettings();
|
void SaveSettings();
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline CStringTable* StringTable() const { return mpStringTable; }
|
CStringTable* StringTable() const { return mpStringTable; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void UpdateUI();
|
void UpdateUI();
|
||||||
|
|
Loading…
Reference in New Issue