CPropertyModel: Make use of in-class initializers where applicable

This commit is contained in:
Lioncash 2020-06-28 04:47:40 -04:00
parent e5e2b4be1a
commit 0abff06954
2 changed files with 20 additions and 25 deletions

View File

@ -5,14 +5,8 @@
#include <QFont> #include <QFont>
#include <QSize> #include <QSize>
CPropertyModel::CPropertyModel(QObject *pParent /*= 0*/) CPropertyModel::CPropertyModel(QObject *pParent)
: QAbstractItemModel(pParent) : QAbstractItemModel(pParent)
, mpProject(nullptr)
, mpRootProperty(nullptr)
, mpPropertyData(nullptr)
, mBoldModifiedProperties(true)
, mShowNameValidity(false)
, mFirstUnusedID(-1)
{ {
} }

View File

@ -18,34 +18,35 @@ class CPropertyModel : public QAbstractItemModel
}; };
QVector<SProperty> mProperties; QVector<SProperty> mProperties;
QMap<IProperty*, int> mPropertyToIDMap; QMap<IProperty*, int> mPropertyToIDMap;
int mFirstUnusedID; int mFirstUnusedID = -1;
CGameProject* mpProject; CGameProject* mpProject = nullptr;
CScriptObject* mpObject; // may be null CScriptObject* mpObject = nullptr; // may be null
IProperty* mpRootProperty; IProperty* mpRootProperty = nullptr;
void* mpPropertyData; void* mpPropertyData = nullptr;
bool mBoldModifiedProperties; bool mBoldModifiedProperties = true;
bool mShowNameValidity; bool mShowNameValidity = false;
QFont mFont; QFont mFont;
int RecursiveBuildArrays(IProperty* pProperty, int ParentID); int RecursiveBuildArrays(IProperty* pProperty, int ParentID);
public: public:
CPropertyModel(QObject *pParent = 0); explicit CPropertyModel(QObject *pParent = nullptr);
void ConfigureIntrinsic(CGameProject* pProject, IProperty* pRootProperty, void* pPropertyData); void ConfigureIntrinsic(CGameProject* pProject, IProperty* pRootProperty, void* pPropertyData);
void ConfigureScript(CGameProject* pProject, IProperty* pRootProperty, CScriptObject* pObject); void ConfigureScript(CGameProject* pProject, IProperty* pRootProperty, CScriptObject* pObject);
IProperty* PropertyForIndex(const QModelIndex& rkIndex, bool HandleFlaggedIndices) const; IProperty* PropertyForIndex(const QModelIndex& rkIndex, bool HandleFlaggedIndices) const;
QModelIndex IndexForProperty(IProperty *pProp) const; QModelIndex IndexForProperty(IProperty *pProp) const;
void* DataPointerForIndex(const QModelIndex& rkIndex) const; void* DataPointerForIndex(const QModelIndex& rkIndex) const;
int columnCount(const QModelIndex& rkParent) const; int columnCount(const QModelIndex& rkParent) const override;
int rowCount(const QModelIndex& rkParent) const; int rowCount(const QModelIndex& rkParent) const override;
QVariant headerData(int Section, Qt::Orientation Orientation, int Role) const; QVariant headerData(int Section, Qt::Orientation Orientation, int Role) const override;
QVariant data(const QModelIndex& rkIndex, int Role) const; QVariant data(const QModelIndex& rkIndex, int Role) const override;
QModelIndex index(int Row, int Column, const QModelIndex& rkParent) const; QModelIndex index(int Row, int Column, const QModelIndex& rkParent) const override;
QModelIndex parent(const QModelIndex& rkChild) const; QModelIndex parent(const QModelIndex& rkChild) const override;
Qt::ItemFlags flags(const QModelIndex& rkIndex) const; Qt::ItemFlags flags(const QModelIndex& rkIndex) const override;
void ArrayAboutToBeResized(const QModelIndex& rkIndex, uint32 NewSize); void ArrayAboutToBeResized(const QModelIndex& rkIndex, uint32 NewSize);
void ArrayResized(const QModelIndex& rkIndex, uint32 OldSize); void ArrayResized(const QModelIndex& rkIndex, uint32 OldSize);
@ -55,9 +56,9 @@ public:
EPropertyType GetEffectiveFieldType(IProperty* pProperty) const; EPropertyType GetEffectiveFieldType(IProperty* pProperty) const;
void SetShowPropertyNameValidity(bool Enable); void SetShowPropertyNameValidity(bool Enable);
inline void SetFont(QFont Font) { mFont = Font; } void SetFont(QFont Font) { mFont = Font; }
inline void SetBoldModifiedProperties(bool Enable) { mBoldModifiedProperties = Enable; } void SetBoldModifiedProperties(bool Enable) { mBoldModifiedProperties = Enable; }
inline CScriptObject* GetScriptObject() const { return mpObject; } CScriptObject* GetScriptObject() const { return mpObject; }
public slots: public slots:
void NotifyPropertyModified(class CScriptObject *pInst, IProperty *pProp); void NotifyPropertyModified(class CScriptObject *pInst, IProperty *pProp);