Editor code: tidy up BOOLs,NULLs and overrides pt1.

Merge pull request #2872 from nemerle/tidy_up_editor_code_a_bit_split1
This commit is contained in:
hultonha
2021-08-06 09:44:14 +01:00
committed by GitHub
30 changed files with 123 additions and 127 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ public:
CBitmapToolTip(QWidget* parent = nullptr);
virtual ~CBitmapToolTip();
BOOL Create(const RECT& rect);
bool Create(const RECT& rect);
// Attributes
public:
+3 -3
View File
@@ -29,7 +29,7 @@ CColorGradientCtrl::CColorGradientCtrl(QWidget* parent)
m_nHitKeyIndex = -1;
m_nKeyDrawRadius = 3;
m_bTracking = false;
m_pSpline = 0;
m_pSpline = nullptr;
m_fMinTime = -1;
m_fMaxTime = 1;
m_fMinValue = -1;
@@ -474,7 +474,7 @@ void CColorGradientCtrl::SetActiveKey(int nIndex)
}
/////////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::SetSpline(ISplineInterpolator* pSpline, BOOL bRedraw)
void CColorGradientCtrl::SetSpline(ISplineInterpolator* pSpline, bool bRedraw)
{
if (pSpline != m_pSpline)
{
@@ -501,7 +501,7 @@ ISplineInterpolator* CColorGradientCtrl::GetSpline()
/////////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::keyPressEvent(QKeyEvent* event)
{
BOOL bProcessed = false;
bool bProcessed = false;
if (m_nActiveKey != -1 && m_pSpline)
{
+1 -1
View File
@@ -54,7 +54,7 @@ public:
// Lock value of first and last key to be the same.
void LockFirstAndLastKeys(bool bLock) { m_bLockFirstLastKey = bLock; }
void SetSpline(ISplineInterpolator* pSpline, BOOL bRedraw = FALSE);
void SetSpline(ISplineInterpolator* pSpline, bool bRedraw = false);
ISplineInterpolator* GetSpline();
void SetTimeMarker(float fTime);
+3 -3
View File
@@ -62,14 +62,14 @@ public:
}
protected:
void highlightBlock(const QString &text)
void highlightBlock(const QString &text) override
{
auto pos = -1;
QTextCharFormat myClassFormat;
myClassFormat.setFontWeight(QFont::Bold);
myClassFormat.setBackground(Qt::yellow);
while (1)
while (true)
{
pos = text.indexOf(m_searchTerm, pos+1, Qt::CaseInsensitive);
@@ -571,7 +571,7 @@ static CVarBlock* VarBlockFromConsoleVars()
size_t cmdCount = console->GetSortedVars(&cmds[0], cmds.size());
CVarBlock* vb = new CVarBlock;
IVariable* pVariable = 0;
IVariable* pVariable = nullptr;
for (int i = 0; i < cmdCount; i++)
{
ICVar* pCVar = console->GetCVar(cmds[i]);
+4 -4
View File
@@ -19,22 +19,22 @@ CHotTrackingTreeCtrl::CHotTrackingTreeCtrl(QWidget* parent)
: QTreeWidget(parent)
{
setMouseTracking(true);
m_hHoverItem = NULL;
m_hHoverItem = nullptr;
}
void CHotTrackingTreeCtrl::mouseMoveEvent(QMouseEvent* event)
{
QTreeWidgetItem* hItem = itemAt(event->pos());
if (m_hHoverItem != NULL)
if (m_hHoverItem != nullptr)
{
QFont font = m_hHoverItem->font(0);
font.setBold(false);
m_hHoverItem->setFont(0, font);
m_hHoverItem = NULL;
m_hHoverItem = nullptr;
}
if (hItem != NULL)
if (hItem != nullptr)
{
QFont font = hItem->font(0);
font.setBold(true);
@@ -27,7 +27,7 @@ void ReflectedPropertiesPanel::DeleteVars()
{
ClearVarBlock();
m_updateCallbacks.clear();
m_varBlock = 0;
m_varBlock = nullptr;
}
//////////////////////////////////////////////////////////////////////////
@@ -198,7 +198,7 @@ void ReflectedPropertyControl::CreateItems(XmlNodeRef node)
void ReflectedPropertyControl::CreateItems(XmlNodeRef node, CVarBlockPtr& outBlockPtr, IVariable::OnSetCallback* func, bool splitCamelCaseIntoWords)
{
SelectItem(0);
SelectItem(nullptr);
outBlockPtr = new CVarBlock;
for (size_t i = 0, iGroupCount(node->getChildCount()); i < iGroupCount; ++i)
@@ -505,7 +505,7 @@ void ReflectedPropertyControl::RemoveAllItems()
void ReflectedPropertyControl::ClearVarBlock()
{
RemoveAllItems();
m_pVarBlock = 0;
m_pVarBlock = nullptr;
}
void ReflectedPropertyControl::RecreateAllItems()
@@ -688,11 +688,11 @@ void ReflectedPropertyControl::OnItemChange(ReflectedPropertyItem *item, bool de
// callback until after the current event queue is processed, so that we aren't changing other widgets
// as a ton of them are still being created.
Qt::ConnectionType connectionType = deferCallbacks ? Qt::QueuedConnection : Qt::DirectConnection;
if (m_updateVarFunc != 0 && m_bEnableCallback)
if (m_updateVarFunc && m_bEnableCallback)
{
QMetaObject::invokeMethod(this, "DoUpdateCallback", connectionType, Q_ARG(IVariable*, item->GetVariable()));
}
if (m_updateObjectFunc != 0 && m_bEnableCallback)
if (m_updateObjectFunc && m_bEnableCallback)
{
// KDAB: This callback has same signature as DoUpdateCallback. I think the only reason there are 2 is because some
// EntityObject registers callback and some derived objects want to register their own callback. the normal UpdateCallback
@@ -709,7 +709,7 @@ void ReflectedPropertyControl::DoUpdateCallback(IVariable *var)
const bool variableStillExists = FindVariable(var);
AZ_Assert(variableStillExists, "This variable and the item containing it were destroyed during a deferred callback. Change to non-deferred callback.");
if (m_updateVarFunc == 0 || !variableStillExists)
if (!m_updateVarFunc || !variableStillExists)
{
return;
}
@@ -724,7 +724,7 @@ void ReflectedPropertyControl::DoUpdateObjectCallback(IVariable *var)
const bool variableStillExists = FindVariable(var);
AZ_Assert(variableStillExists, "This variable and the item containing it were destroyed during a deferred callback. Change to non-deferred callback.");
if (m_updateVarFunc == 0 || !variableStillExists)
if ( !m_updateVarFunc || !variableStillExists)
{
return;
}
@@ -904,7 +904,7 @@ void ReflectedPropertyControl::SetUndoCallback(UndoCallback &callback)
void ReflectedPropertyControl::ClearUndoCallback()
{
m_undoFunc = 0;
m_undoFunc = nullptr;
}
bool ReflectedPropertyControl::FindVariable(IVariable *categoryItem) const
@@ -82,7 +82,7 @@ public:
}
//helps implement ReflectedPropertyControl::ReplaceVarBlock
void ReplaceVarBlock(CVarBlock *varBlock)
void ReplaceVarBlock(CVarBlock *varBlock) override
{
m_containerVar->Clear();
UpdateCommon(m_item->GetVariable(), varBlock);
@@ -207,7 +207,7 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
ReleaseVariable();
m_pVariable = pInputVar;
assert(m_pVariable != NULL);
assert(m_pVariable != nullptr);
m_pVariable->AddOnSetCallback(&m_onSetCallback);
m_pVariable->AddOnSetEnumCallback(&m_onSetEnumCallback);
@@ -332,7 +332,7 @@ void ReflectedPropertyItem::RemoveAllChildren()
{
for (int i = 0; i < m_childs.size(); i++)
{
m_childs[i]->m_parent = 0;
m_childs[i]->m_parent = nullptr;
}
m_childs.clear();
@@ -473,7 +473,7 @@ void ReflectedPropertyItem::ReleaseVariable()
m_pVariable->RemoveOnSetCallback(&m_onSetCallback);
m_pVariable->RemoveOnSetEnumCallback(&m_onSetEnumCallback);
}
m_pVariable = 0;
m_pVariable = nullptr;
delete m_reflectedVarAdapter;
m_reflectedVarAdapter = nullptr;
}
@@ -473,7 +473,7 @@ void ReflectedVarUserAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
//extract the list of custom items from the IVariable user data
IVariable::IGetCustomItems* pGetCustomItems = static_cast<IVariable::IGetCustomItems*> (pVariable->GetUserData().value<void *>());
if (pGetCustomItems != 0)
if (pGetCustomItems != nullptr)
{
std::vector<IVariable::IGetCustomItems::SItem> items;
QString dlgTitle;
+5 -5
View File
@@ -30,7 +30,7 @@ CSplineCtrl::CSplineCtrl(QWidget* parent)
m_nHitKeyIndex = -1;
m_nKeyDrawRadius = 3;
m_bTracking = false;
m_pSpline = 0;
m_pSpline = nullptr;
m_gridX = 10;
m_gridY = 10;
m_fMinTime = -1;
@@ -40,7 +40,7 @@ CSplineCtrl::CSplineCtrl(QWidget* parent)
m_fTooltipScaleX = 1;
m_fTooltipScaleY = 1;
m_bLockFirstLastKey = false;
m_pTimelineCtrl = 0;
m_pTimelineCtrl = nullptr;
m_bSelectedKeys.reserve(0);
@@ -417,7 +417,7 @@ void CSplineCtrl::SetActiveKey(int nIndex)
}
/////////////////////////////////////////////////////////////////////////////
void CSplineCtrl::SetSpline(ISplineInterpolator* pSpline, BOOL bRedraw)
void CSplineCtrl::SetSpline(ISplineInterpolator* pSpline, bool bRedraw)
{
if (pSpline != m_pSpline)
{
@@ -596,7 +596,7 @@ CSplineCtrl::EHitCode CSplineCtrl::HitTest(const QPoint& point)
///////////////////////////////////////////////////////////////////////////////
void CSplineCtrl::StartTracking()
{
m_bTracking = TRUE;
m_bTracking = true;
GetIEditor()->BeginUndo();
@@ -674,7 +674,7 @@ void CSplineCtrl::StopTracking()
GetIEditor()->AcceptUndo("Spline Move");
m_bTracking = FALSE;
m_bTracking = false;
}
//////////////////////////////////////////////////////////////////////////
+1 -1
View File
@@ -59,7 +59,7 @@ public:
// Lock value of first and last key to be the same.
void LockFirstAndLastKeys(bool bLock) { m_bLockFirstLastKey = bLock; }
void SetSpline(ISplineInterpolator* pSpline, BOOL bRedraw = FALSE);
void SetSpline(ISplineInterpolator* pSpline, bool bRedraw = false);
ISplineInterpolator* GetSpline();
void SetTimeMarker(float fTime);
+38 -38
View File
@@ -69,8 +69,8 @@ protected:
AbstractSplineWidget* pCtrl = FindControl(m_pCtrl);
m_splineEntries.resize(m_splineEntries.size() + 1);
SplineEntry& entry = m_splineEntries.back();
ISplineSet* pSplineSet = (pCtrl ? pCtrl->m_pSplineSet : 0);
entry.id = (pSplineSet ? pSplineSet->GetIDFromSpline(pSpline) : 0);
ISplineSet* pSplineSet = (pCtrl ? pCtrl->m_pSplineSet : nullptr);
entry.id = (pSplineSet ? pSplineSet->GetIDFromSpline(pSpline) : nullptr);
entry.pSpline = pSpline;
const int numKeys = pSpline->GetKeyCount();
@@ -81,10 +81,10 @@ protected:
}
}
virtual int GetSize() { return sizeof(*this); }
virtual QString GetDescription() { return "UndoSplineCtrlEx"; };
int GetSize() override { return sizeof(*this); }
QString GetDescription() override { return "UndoSplineCtrlEx"; };
virtual void Undo(bool bUndo)
void Undo(bool bUndo) override
{
AbstractSplineWidget* pCtrl = FindControl(m_pCtrl);
if (pCtrl)
@@ -104,7 +104,7 @@ protected:
}
}
virtual void Redo()
void Redo() override
{
AbstractSplineWidget* pCtrl = FindControl(m_pCtrl);
if (pCtrl)
@@ -134,7 +134,7 @@ private:
void SerializeSplines(_smart_ptr<ISplineBackup> SplineEntry::* backup, bool bLoading)
{
AbstractSplineWidget* pCtrl = FindControl(m_pCtrl);
ISplineSet* pSplineSet = (pCtrl ? pCtrl->m_pSplineSet : 0);
ISplineSet* pSplineSet = (pCtrl ? pCtrl->m_pSplineSet : nullptr);
for (auto it = m_splineEntries.begin(); it != m_splineEntries.end(); ++it)
{
SplineEntry& entry = *it;
@@ -157,19 +157,19 @@ private:
}
public:
typedef std::list<AbstractSplineWidget*> CSplineCtrls;
using CSplineCtrls = std::list<AbstractSplineWidget *>;
static AbstractSplineWidget* FindControl(AbstractSplineWidget* pCtrl)
{
if (!pCtrl)
{
return 0;
return nullptr;
}
auto iter = std::find(s_activeCtrls.begin(), s_activeCtrls.end(), pCtrl);
if (iter == s_activeCtrls.end())
{
return 0;
return nullptr;
}
return *iter;
@@ -193,10 +193,10 @@ public:
static CSplineCtrls s_activeCtrls;
virtual bool IsSelectionChanged() const
bool IsSelectionChanged() const override
{
AbstractSplineWidget* pCtrl = FindControl(m_pCtrl);
ISplineSet* pSplineSet = (pCtrl ? pCtrl->m_pSplineSet : 0);
ISplineSet* pSplineSet = (pCtrl ? pCtrl->m_pSplineSet : nullptr);
for (auto it = m_splineEntries.begin(); it != m_splineEntries.end(); ++it)
{
@@ -256,11 +256,11 @@ SplineWidget::~SplineWidget()
AbstractSplineWidget::AbstractSplineWidget()
: m_defaultKeyTangentType(SPLINE_KEY_TANGENT_NONE)
{
m_pTimelineCtrl = 0;
m_pTimelineCtrl = nullptr;
m_totalSplineCount = 0;
m_pHitSpline = 0;
m_pHitDetailSpline = 0;
m_pHitSpline = nullptr;
m_pHitDetailSpline = nullptr;
m_nHitKeyIndex = -1;
m_nHitDimension = -1;
m_bHitIncomingHandle = true;
@@ -301,7 +301,7 @@ AbstractSplineWidget::AbstractSplineWidget()
m_boLeftMouseButtonDown = false;
m_pSplineSet = 0;
m_pSplineSet = nullptr;
m_controlAmplitude = false;
@@ -1633,7 +1633,7 @@ void SplineWidget::wheelEvent(QWheelEvent* event)
void SplineWidget::keyPressEvent(QKeyEvent* e)
{
BOOL bProcessed = false;
bool bProcessed = false;
switch (e->key())
{
@@ -1780,7 +1780,7 @@ void AbstractSplineWidget::SetHorizontalExtent([[maybe_unused]] int min, [[maybe
//si.nPage = max(0,m_rcClient.Width() - m_leftOffset*2);
//si.nPage = 1;
//si.nPage = 1;
SetScrollInfo( SB_HORZ,&si,TRUE );
SetScrollInfo( SB_HORZ,&si,true );
*/
}
@@ -1792,7 +1792,7 @@ ISplineInterpolator* AbstractSplineWidget::HitSpline(const QPoint& point)
return m_pHitSpline;
}
return NULL;
return nullptr;
}
//////////////////////////////////////////////////////////////////////////////
@@ -1806,8 +1806,8 @@ AbstractSplineWidget::EHitCode AbstractSplineWidget::HitTest(const QPoint& point
PointToTimeValue(point, time, val);
m_hitCode = HIT_NOTHING;
m_pHitSpline = NULL;
m_pHitDetailSpline = NULL;
m_pHitSpline = nullptr;
m_pHitDetailSpline = nullptr;
m_nHitKeyIndex = -1;
m_nHitDimension = -1;
m_bHitIncomingHandle = true;
@@ -1968,8 +1968,8 @@ void AbstractSplineWidget::StopTracking()
void AbstractSplineWidget::ScaleAmplitudeKeys(float time, float startValue, float offset)
{
//TODO: Test it in the facial animation pane and fix it...
m_pHitSpline = 0;
m_pHitDetailSpline = 0;
m_pHitSpline = nullptr;
m_pHitDetailSpline = nullptr;
m_nHitKeyIndex = -1;
m_nHitDimension = -1;
@@ -2071,8 +2071,8 @@ void AbstractSplineWidget::TimeScaleKeys(float time, float startTime, float endT
float timeScaleC = endTime - startTime * timeScaleM;
// Loop through all keys that are selected.
m_pHitSpline = 0;
m_pHitDetailSpline = 0;
m_pHitSpline = nullptr;
m_pHitDetailSpline = nullptr;
m_nHitKeyIndex = -1;
float affectedRangeMin = FLT_MAX;
@@ -2179,8 +2179,8 @@ void AbstractSplineWidget::ValueScaleKeys(float startValue, float endValue)
}
// Loop through all keys that are selected.
m_pHitSpline = 0;
m_pHitDetailSpline = 0;
m_pHitSpline = nullptr;
m_pHitDetailSpline = nullptr;
m_nHitKeyIndex = -1;
m_nHitDimension = -1;
@@ -2212,8 +2212,8 @@ void AbstractSplineWidget::ValueScaleKeys(float startValue, float endValue)
//////////////////////////////////////////////////////////////////////////
void AbstractSplineWidget::MoveSelectedKeys(Vec2 offset, bool copyKeys)
{
m_pHitSpline = 0;
m_pHitDetailSpline = 0;
m_pHitSpline = nullptr;
m_pHitDetailSpline = nullptr;
m_nHitKeyIndex = -1;
m_nHitDimension = -1;
@@ -2275,8 +2275,8 @@ void AbstractSplineWidget::RemoveKey(ISplineInterpolator* pSpline, int nKey)
SendNotifyEvent(SPLN_BEFORE_CHANGE);
m_pHitSpline = 0;
m_pHitDetailSpline = 0;
m_pHitSpline = nullptr;
m_pHitDetailSpline = nullptr;
m_nHitKeyIndex = -1;
if (nKey != -1)
{
@@ -2294,8 +2294,8 @@ void AbstractSplineWidget::RemoveSelectedKeys()
SendNotifyEvent(SPLN_BEFORE_CHANGE);
m_pHitSpline = 0;
m_pHitDetailSpline = 0;
m_pHitSpline = nullptr;
m_pHitDetailSpline = nullptr;
m_nHitKeyIndex = -1;
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
@@ -2558,11 +2558,11 @@ public:
};
void AbstractSplineWidget::DuplicateSelectedKeys()
{
m_pHitSpline = 0;
m_pHitDetailSpline = 0;
m_pHitSpline = nullptr;
m_pHitDetailSpline = nullptr;
m_nHitKeyIndex = -1;
typedef std::vector<CKeyCopyInfo> KeysToAddContainer;
using KeysToAddContainer = std::vector<CKeyCopyInfo>;
KeysToAddContainer keysToInsert;
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
{
@@ -2600,7 +2600,7 @@ void AbstractSplineWidget::ZeroAll()
{
GetIEditor()->BeginUndo();
typedef std::vector<ISplineInterpolator*> SplineContainer;
using SplineContainer = std::vector<ISplineInterpolator *>;
SplineContainer splines;
for (int splineIndex = 0; splineIndex < int(m_splines.size()); ++splineIndex)
{
@@ -2632,7 +2632,7 @@ void AbstractSplineWidget::KeyAll()
{
GetIEditor()->BeginUndo();
typedef std::vector<ISplineInterpolator*> SplineContainer;
using SplineContainer = std::vector<ISplineInterpolator *>;
SplineContainer splines;
for (int splineIndex = 0; splineIndex < int(m_splines.size()); ++splineIndex)
{
+1 -1
View File
@@ -58,7 +58,7 @@ TimelineWidget::TimelineWidget(QWidget* parent /* = nullptr */)
m_bIgnoreSetTime = false;
m_pKeyTimeSet = 0;
m_pKeyTimeSet = nullptr;
m_markerStyle = MARKER_STYLE_SECONDS;
m_fps = 30.0f;