mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 17:05:37 +00:00
CWorldInforSidebar: Pass QModelIndex by const reference
Avoids some trivial copies.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
#include "CWorldInfoSidebar.h"
|
#include "CWorldInfoSidebar.h"
|
||||||
#include "ui_CWorldInfoSidebar.h"
|
#include "ui_CWorldInfoSidebar.h"
|
||||||
|
|
||||||
|
|
||||||
#include "Editor/CEditorApplication.h"
|
#include "Editor/CEditorApplication.h"
|
||||||
#include "Editor/UICommon.h"
|
#include "Editor/UICommon.h"
|
||||||
#include "Editor/WorldEditor/CWorldEditor.h"
|
#include "Editor/WorldEditor/CWorldEditor.h"
|
||||||
@@ -51,7 +50,7 @@ CWorldInfoSidebar::CWorldInfoSidebar(CWorldEditor *pEditor)
|
|||||||
CWorldInfoSidebar::~CWorldInfoSidebar() = default;
|
CWorldInfoSidebar::~CWorldInfoSidebar() = default;
|
||||||
|
|
||||||
// ************ SLOTS ************
|
// ************ SLOTS ************
|
||||||
void CWorldInfoSidebar::OnActiveProjectChanged(CGameProject *pProj)
|
void CWorldInfoSidebar::OnActiveProjectChanged(const CGameProject* pProj)
|
||||||
{
|
{
|
||||||
mpUI->ProjectInfoWidget->setHidden(pProj == nullptr);
|
mpUI->ProjectInfoWidget->setHidden(pProj == nullptr);
|
||||||
mpUI->WorldInfoWidget->setHidden(true);
|
mpUI->WorldInfoWidget->setHidden(true);
|
||||||
@@ -64,7 +63,7 @@ void CWorldInfoSidebar::OnActiveProjectChanged(CGameProject *pProj)
|
|||||||
// Add/remove widgets from the form layout based on the game. This is needed because
|
// Add/remove widgets from the form layout based on the game. This is needed because
|
||||||
// simply hiding the widgets causes a minor spacing issue. The only fix seems to be
|
// simply hiding the widgets causes a minor spacing issue. The only fix seems to be
|
||||||
// actually entirely removing the widgets from the layout when not in use.
|
// actually entirely removing the widgets from the layout when not in use.
|
||||||
bool IsEchoes = pProj && (pProj->Game() == EGame::EchoesDemo || pProj->Game() == EGame::Echoes);
|
const bool IsEchoes = pProj && (pProj->Game() == EGame::EchoesDemo || pProj->Game() == EGame::Echoes);
|
||||||
mpUI->DarkWorldNameStringLabel->setHidden(!IsEchoes);
|
mpUI->DarkWorldNameStringLabel->setHidden(!IsEchoes);
|
||||||
mpUI->DarkWorldNameSelector->setHidden(!IsEchoes);
|
mpUI->DarkWorldNameSelector->setHidden(!IsEchoes);
|
||||||
|
|
||||||
@@ -97,9 +96,9 @@ void CWorldInfoSidebar::OnAreaFilterStringChanged(const QString& rkFilter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorldInfoSidebar::OnWorldTreeClicked(QModelIndex Index)
|
void CWorldInfoSidebar::OnWorldTreeClicked(const QModelIndex& Index)
|
||||||
{
|
{
|
||||||
QModelIndex RealIndex = mProxyModel.mapToSource(Index);
|
const QModelIndex RealIndex = mProxyModel.mapToSource(Index);
|
||||||
|
|
||||||
// Fill in world info
|
// Fill in world info
|
||||||
CWorld* pWorld = mModel.WorldForIndex(RealIndex);
|
CWorld* pWorld = mModel.WorldForIndex(RealIndex);
|
||||||
@@ -115,12 +114,12 @@ void CWorldInfoSidebar::OnWorldTreeClicked(QModelIndex Index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fill in area info
|
// Fill in area info
|
||||||
bool IsArea = !mModel.IndexIsWorld(RealIndex);
|
const bool IsArea = !mModel.IndexIsWorld(RealIndex);
|
||||||
mpUI->AreaInfoWidget->setHidden(!IsArea);
|
mpUI->AreaInfoWidget->setHidden(!IsArea);
|
||||||
|
|
||||||
if (IsArea)
|
if (IsArea)
|
||||||
{
|
{
|
||||||
int AreaIndex = Editor()->CurrentGame() == EGame::DKCReturns ? 0 : mModel.AreaIndexForIndex(RealIndex);
|
const int AreaIndex = Editor()->CurrentGame() == EGame::DKCReturns ? 0 : mModel.AreaIndexForIndex(RealIndex);
|
||||||
mpUI->AreaNameLabel->setText(TO_QSTRING(pWorld->AreaInGameName(AreaIndex)));
|
mpUI->AreaNameLabel->setText(TO_QSTRING(pWorld->AreaInGameName(AreaIndex)));
|
||||||
mpUI->AreaSelector->SetResource(pWorld->AreaResourceID(AreaIndex));
|
mpUI->AreaSelector->SetResource(pWorld->AreaResourceID(AreaIndex));
|
||||||
mpUI->AreaNameLineEdit->setText(TO_QSTRING(pWorld->AreaInternalName(AreaIndex)));
|
mpUI->AreaNameLineEdit->setText(TO_QSTRING(pWorld->AreaInternalName(AreaIndex)));
|
||||||
@@ -137,17 +136,17 @@ void CWorldInfoSidebar::OnWorldTreeClicked(QModelIndex Index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorldInfoSidebar::OnWorldTreeDoubleClicked(QModelIndex Index)
|
void CWorldInfoSidebar::OnWorldTreeDoubleClicked(const QModelIndex& Index)
|
||||||
{
|
{
|
||||||
QModelIndex RealIndex = mProxyModel.mapToSource(Index);
|
const QModelIndex RealIndex = mProxyModel.mapToSource(Index);
|
||||||
|
|
||||||
if (!mModel.IndexIsWorld(RealIndex))
|
if (!mModel.IndexIsWorld(RealIndex))
|
||||||
{
|
{
|
||||||
TResPtr<CWorld> pWorld = mModel.WorldForIndex(RealIndex);
|
TResPtr<CWorld> pWorld = mModel.WorldForIndex(RealIndex);
|
||||||
int AreaIndex = mModel.AreaIndexForIndex(RealIndex);
|
const int AreaIndex = mModel.AreaIndexForIndex(RealIndex);
|
||||||
|
|
||||||
// Validate area actually exists... DKCR has worlds that contain areas that don't exist
|
// Validate area actually exists... DKCR has worlds that contain areas that don't exist
|
||||||
CAssetID AreaAssetID = pWorld->AreaResourceID(AreaIndex);
|
const CAssetID AreaAssetID = pWorld->AreaResourceID(AreaIndex);
|
||||||
|
|
||||||
if (gpResourceStore->IsResourceRegistered(AreaAssetID))
|
if (gpResourceStore->IsResourceRegistered(AreaAssetID))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ public:
|
|||||||
~CWorldInfoSidebar() override;
|
~CWorldInfoSidebar() override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnActiveProjectChanged(CGameProject *pProj);
|
void OnActiveProjectChanged(const CGameProject* pProj);
|
||||||
void OnAreaFilterStringChanged(const QString& rkFilter);
|
void OnAreaFilterStringChanged(const QString& rkFilter);
|
||||||
void OnWorldTreeClicked(QModelIndex Index);
|
void OnWorldTreeClicked(const QModelIndex& Index);
|
||||||
void OnWorldTreeDoubleClicked(QModelIndex Index);
|
void OnWorldTreeDoubleClicked(const QModelIndex& Index);
|
||||||
void ClearWorldInfo();
|
void ClearWorldInfo();
|
||||||
void ClearAreaInfo();
|
void ClearAreaInfo();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user