mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-07-01 19:03:36 +00:00
CWorldTreeModel: Tidy up warnings
This commit is contained in:
parent
32041a843d
commit
9c8749d5b0
@ -6,6 +6,8 @@
|
|||||||
#include <Core/GameProject/CResourceIterator.h>
|
#include <Core/GameProject/CResourceIterator.h>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
CWorldTreeModel::CWorldTreeModel(CWorldEditor *pEditor)
|
CWorldTreeModel::CWorldTreeModel(CWorldEditor *pEditor)
|
||||||
{
|
{
|
||||||
connect(gpEdApp, &CEditorApplication::ActiveProjectChanged, this, &CWorldTreeModel::OnProjectChanged);
|
connect(gpEdApp, &CEditorApplication::ActiveProjectChanged, this, &CWorldTreeModel::OnProjectChanged);
|
||||||
@ -14,9 +16,13 @@ CWorldTreeModel::CWorldTreeModel(CWorldEditor *pEditor)
|
|||||||
|
|
||||||
int CWorldTreeModel::rowCount(const QModelIndex& rkParent) const
|
int CWorldTreeModel::rowCount(const QModelIndex& rkParent) const
|
||||||
{
|
{
|
||||||
if (!rkParent.isValid()) return mWorldList.size();
|
if (!rkParent.isValid())
|
||||||
else if (IndexIsWorld(rkParent)) return mWorldList[rkParent.row()].Areas.size();
|
return mWorldList.size();
|
||||||
else return 0;
|
|
||||||
|
if (IndexIsWorld(rkParent))
|
||||||
|
return mWorldList[rkParent.row()].Areas.size();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CWorldTreeModel::columnCount(const QModelIndex&) const
|
int CWorldTreeModel::columnCount(const QModelIndex&) const
|
||||||
@ -34,16 +40,15 @@ QModelIndex CWorldTreeModel::index(int Row, int Column, const QModelIndex& rkPar
|
|||||||
return createIndex(Row, Column, quint64((Row << 16) | 0xFFFF));
|
return createIndex(Row, Column, quint64((Row << 16) | 0xFFFF));
|
||||||
|
|
||||||
// Area
|
// Area
|
||||||
else
|
return createIndex(Row, Column, quint64((rkParent.row() << 16) | (Row & 0xFFFF)) );
|
||||||
return createIndex(Row, Column, quint64((rkParent.row() << 16) | (Row & 0xFFFF)) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex CWorldTreeModel::parent(const QModelIndex& rkChild) const
|
QModelIndex CWorldTreeModel::parent(const QModelIndex& rkChild) const
|
||||||
{
|
{
|
||||||
if (IndexIsWorld(rkChild))
|
if (IndexIsWorld(rkChild))
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
else
|
|
||||||
return createIndex((rkChild.internalId() >> 16) & 0xFFFF, 0, rkChild.internalId() | 0xFFFF);
|
return createIndex((rkChild.internalId() >> 16) & 0xFFFF, 0, rkChild.internalId() | 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant CWorldTreeModel::data(const QModelIndex& rkIndex, int Role) const
|
QVariant CWorldTreeModel::data(const QModelIndex& rkIndex, int Role) const
|
||||||
@ -59,31 +64,26 @@ QVariant CWorldTreeModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
// are often missing, confusing, or just straight-up inaccurate, which makes the internal name a better
|
// are often missing, confusing, or just straight-up inaccurate, which makes the internal name a better
|
||||||
// means of telling worlds apart.
|
// means of telling worlds apart.
|
||||||
// For DKCR worlds, we only display the world name in the first column.
|
// For DKCR worlds, we only display the world name in the first column.
|
||||||
uint32 InternalNameCol = (gpEdApp->ActiveProject()->Game() >= EGame::Corruption ? 0 : 1);
|
const int InternalNameCol = (gpEdApp->ActiveProject()->Game() >= EGame::Corruption ? 0 : 1);
|
||||||
|
|
||||||
// Internal name
|
// Internal name
|
||||||
if (rkIndex.column() == InternalNameCol)
|
if (rkIndex.column() == InternalNameCol)
|
||||||
return rkInfo.WorldName;
|
return rkInfo.WorldName;
|
||||||
|
|
||||||
// In-Game name
|
// In-Game name
|
||||||
else
|
if (rkInfo.pWorld != nullptr)
|
||||||
{
|
return TO_QSTRING(rkInfo.pWorld->InGameName());
|
||||||
if (rkInfo.pWorld)
|
|
||||||
return TO_QSTRING( rkInfo.pWorld->InGameName() );
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Area
|
return QString{};
|
||||||
else
|
}
|
||||||
|
else // Area
|
||||||
{
|
{
|
||||||
CWorld *pWorld = WorldForIndex(rkIndex);
|
const CWorld *pWorld = WorldForIndex(rkIndex);
|
||||||
int AreaIndex = AreaIndexForIndex(rkIndex);
|
const int AreaIndex = AreaIndexForIndex(rkIndex);
|
||||||
ASSERT(pWorld);
|
ASSERT(pWorld);
|
||||||
|
|
||||||
TString AreaInternalName = pWorld->AreaInternalName(AreaIndex);
|
const TString AreaInternalName = pWorld->AreaInternalName(AreaIndex);
|
||||||
TString AreaInGameName = (gpEdApp->ActiveProject()->Game() == EGame::DKCReturns ? pWorld->InGameName() : pWorld->AreaInGameName( AreaIndexForIndex(rkIndex) ));
|
const TString AreaInGameName = (gpEdApp->ActiveProject()->Game() == EGame::DKCReturns ? pWorld->InGameName() : pWorld->AreaInGameName(AreaIndexForIndex(rkIndex)));
|
||||||
|
|
||||||
// Return name
|
// Return name
|
||||||
if (rkIndex.column() == 1)
|
if (rkIndex.column() == 1)
|
||||||
@ -93,7 +93,7 @@ QVariant CWorldTreeModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Role == Qt::DecorationRole)
|
if (Role == Qt::DecorationRole)
|
||||||
{
|
{
|
||||||
static const QIcon sWorldIcon = QIcon(QStringLiteral(":/icons/World_16px.svg"));
|
static const QIcon sWorldIcon = QIcon(QStringLiteral(":/icons/World_16px.svg"));
|
||||||
static const QIcon sAreaIcon = QIcon(QStringLiteral(":/icons/New_16px.svg"));
|
static const QIcon sAreaIcon = QIcon(QStringLiteral(":/icons/New_16px.svg"));
|
||||||
@ -106,7 +106,7 @@ QVariant CWorldTreeModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
return sAreaIcon;
|
return sAreaIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Role == Qt::FontRole)
|
if (Role == Qt::FontRole)
|
||||||
{
|
{
|
||||||
QFont Font;
|
QFont Font;
|
||||||
int PointSize = Font.pointSize() + 2;
|
int PointSize = Font.pointSize() + 2;
|
||||||
@ -116,14 +116,12 @@ QVariant CWorldTreeModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
PointSize += 1;
|
PointSize += 1;
|
||||||
|
|
||||||
const SWorldInfo& rkInfo = WorldInfoForIndex(rkIndex);
|
const SWorldInfo& rkInfo = WorldInfoForIndex(rkIndex);
|
||||||
CWorld *pActiveWorld = gpEdApp->WorldEditor()->ActiveWorld();
|
|
||||||
|
|
||||||
if (pActiveWorld)
|
if (CWorld* pActiveWorld = gpEdApp->WorldEditor()->ActiveWorld())
|
||||||
{
|
{
|
||||||
EGame Game = gpEdApp->ActiveProject()->Game();
|
const EGame Game = gpEdApp->ActiveProject()->Game();
|
||||||
|
const bool IsActiveWorld = (Game <= EGame::Corruption && rkInfo.pWorld == pActiveWorld) ||
|
||||||
bool IsActiveWorld = (Game <= EGame::Corruption && rkInfo.pWorld == pActiveWorld) ||
|
(Game == EGame::DKCReturns && rkInfo.Areas.contains(pActiveWorld->Entry()));
|
||||||
(Game == EGame::DKCReturns && rkInfo.Areas.contains(pActiveWorld->Entry()));
|
|
||||||
|
|
||||||
if (IsActiveWorld)
|
if (IsActiveWorld)
|
||||||
Font.setBold(true);
|
Font.setBold(true);
|
||||||
@ -131,9 +129,9 @@ QVariant CWorldTreeModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CResourceEntry *pEntry = AreaEntryForIndex(rkIndex);
|
const CResourceEntry *pEntry = AreaEntryForIndex(rkIndex);
|
||||||
|
|
||||||
if (pEntry && pEntry->IsLoaded())
|
if (pEntry != nullptr && pEntry->IsLoaded())
|
||||||
{
|
{
|
||||||
if (gpEdApp->WorldEditor()->ActiveArea() == pEntry->Resource())
|
if (gpEdApp->WorldEditor()->ActiveArea() == pEntry->Resource())
|
||||||
Font.setBold(true);
|
Font.setBold(true);
|
||||||
@ -163,8 +161,8 @@ QVariant CWorldTreeModel::headerData(int Section, Qt::Orientation Orientation, i
|
|||||||
|
|
||||||
bool CWorldTreeModel::IndexIsWorld(const QModelIndex& rkIndex) const
|
bool CWorldTreeModel::IndexIsWorld(const QModelIndex& rkIndex) const
|
||||||
{
|
{
|
||||||
int AreaIndex = (int) rkIndex.internalId() & 0xFFFF;
|
const auto AreaIndex = static_cast<int>(rkIndex.internalId()) & 0xFFFF;
|
||||||
return (AreaIndex == 0xFFFF);
|
return AreaIndex == 0xFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CWorldTreeModel::AreaIndexForIndex(const QModelIndex& rkIndex) const
|
int CWorldTreeModel::AreaIndexForIndex(const QModelIndex& rkIndex) const
|
||||||
@ -172,11 +170,8 @@ int CWorldTreeModel::AreaIndexForIndex(const QModelIndex& rkIndex) const
|
|||||||
if (gpEdApp->ActiveProject()->Game() == EGame::DKCReturns)
|
if (gpEdApp->ActiveProject()->Game() == EGame::DKCReturns)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
else
|
const auto InternalID = static_cast<int>(rkIndex.internalId());
|
||||||
{
|
return InternalID & 0xFFFF;
|
||||||
int InternalID = (int) rkIndex.internalId();
|
|
||||||
return (InternalID & 0xFFFF);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CWorld* CWorldTreeModel::WorldForIndex(const QModelIndex& rkIndex) const
|
CWorld* CWorldTreeModel::WorldForIndex(const QModelIndex& rkIndex) const
|
||||||
@ -186,28 +181,31 @@ CWorld* CWorldTreeModel::WorldForIndex(const QModelIndex& rkIndex) const
|
|||||||
|
|
||||||
if (gpEdApp->ActiveProject()->Game() == EGame::DKCReturns && !IndexIsWorld(rkIndex))
|
if (gpEdApp->ActiveProject()->Game() == EGame::DKCReturns && !IndexIsWorld(rkIndex))
|
||||||
{
|
{
|
||||||
int AreaIndex = (int) rkIndex.internalId() & 0xFFFF;
|
const auto AreaIndex = static_cast<int>(rkIndex.internalId() & 0xFFFF);
|
||||||
CResourceEntry *pEntry = rkInfo.Areas[AreaIndex];
|
CResourceEntry *pEntry = rkInfo.Areas[AreaIndex];
|
||||||
return pEntry ? (CWorld*) pEntry->Load() : nullptr;
|
return pEntry != nullptr ? static_cast<CWorld*>(pEntry->Load()) : nullptr;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return rkInfo.pWorld;
|
return rkInfo.pWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
CResourceEntry* CWorldTreeModel::AreaEntryForIndex(const QModelIndex& rkIndex) const
|
CResourceEntry* CWorldTreeModel::AreaEntryForIndex(const QModelIndex& rkIndex) const
|
||||||
{
|
{
|
||||||
ASSERT(rkIndex.isValid() && !IndexIsWorld(rkIndex));
|
ASSERT(rkIndex.isValid() && !IndexIsWorld(rkIndex));
|
||||||
CWorld *pWorld = WorldForIndex(rkIndex);
|
|
||||||
int AreaIndex = AreaIndexForIndex(rkIndex);
|
|
||||||
|
|
||||||
CAssetID AreaID;
|
CAssetID AreaID;
|
||||||
if (pWorld) AreaID = pWorld->AreaResourceID(AreaIndex);
|
if (const CWorld* pWorld = WorldForIndex(rkIndex))
|
||||||
|
{
|
||||||
|
const int AreaIndex = AreaIndexForIndex(rkIndex);
|
||||||
|
AreaID = pWorld->AreaResourceID(AreaIndex);
|
||||||
|
}
|
||||||
|
|
||||||
return gpResourceStore->FindEntry(AreaID);
|
return gpResourceStore->FindEntry(AreaID);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CWorldTreeModel::SWorldInfo& CWorldTreeModel::WorldInfoForIndex(const QModelIndex& rkIndex) const
|
const CWorldTreeModel::SWorldInfo& CWorldTreeModel::WorldInfoForIndex(const QModelIndex& rkIndex) const
|
||||||
{
|
{
|
||||||
int WorldIndex = ((int) rkIndex.internalId() >> 16) & 0xFFFF;
|
const int WorldIndex = (static_cast<int>(rkIndex.internalId()) >> 16) & 0xFFFF;
|
||||||
return mWorldList[WorldIndex];
|
return mWorldList[WorldIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +215,7 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj)
|
|||||||
beginResetModel();
|
beginResetModel();
|
||||||
mWorldList.clear();
|
mWorldList.clear();
|
||||||
|
|
||||||
if (pProj)
|
if (pProj != nullptr)
|
||||||
{
|
{
|
||||||
if (pProj->Game() != EGame::DKCReturns)
|
if (pProj->Game() != EGame::DKCReturns)
|
||||||
{
|
{
|
||||||
@ -228,13 +226,11 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj)
|
|||||||
|
|
||||||
for (const CAssetID& rkID : QWorldIDs)
|
for (const CAssetID& rkID : QWorldIDs)
|
||||||
{
|
{
|
||||||
CResourceEntry *pEntry = pProj->ResourceStore()->FindEntry(rkID);
|
if (CResourceEntry* pEntry = pProj->ResourceStore()->FindEntry(rkID))
|
||||||
|
|
||||||
if (pEntry)
|
|
||||||
{
|
{
|
||||||
TResPtr<CWorld> pWorld = pEntry->Load();
|
TResPtr<CWorld> pWorld = pEntry->Load();
|
||||||
|
|
||||||
if (pWorld)
|
if (pWorld != nullptr)
|
||||||
{
|
{
|
||||||
SWorldInfo Info;
|
SWorldInfo Info;
|
||||||
Info.WorldName = TO_QSTRING( pWorld->Name() );
|
Info.WorldName = TO_QSTRING( pWorld->Name() );
|
||||||
@ -262,23 +258,21 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else // DKCR - Get worlds from areas.lst
|
||||||
// DKCR - Get worlds from areas.lst
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
TString AreaListPath = pProj->DiscFilesystemRoot(false) + "areas.lst";
|
TString AreaListPath = pProj->DiscFilesystemRoot(false) + "areas.lst";
|
||||||
|
|
||||||
// I really need a good text stream class at some point
|
// I really need a good text stream class at some point
|
||||||
FILE* pAreaList = fopen(*AreaListPath, "r");
|
using FILEPtr = std::unique_ptr<FILE, decltype(&std::fclose)>;
|
||||||
|
FILEPtr pAreaList{std::fopen(*AreaListPath, "r"), std::fclose};
|
||||||
SWorldInfo *pInfo = nullptr;
|
SWorldInfo *pInfo = nullptr;
|
||||||
std::set<CAssetID> UsedWorlds;
|
std::set<CAssetID> UsedWorlds;
|
||||||
|
|
||||||
while (!feof(pAreaList))
|
while (!std::feof(pAreaList.get()))
|
||||||
{
|
{
|
||||||
char LineBuffer[256];
|
char LineBuffer[256] = {};
|
||||||
memset(LineBuffer, 0, 256);
|
std::fgets(LineBuffer, sizeof(LineBuffer), pAreaList.get());
|
||||||
fgets(LineBuffer, 256, pAreaList);
|
const TString Line(LineBuffer);
|
||||||
TString Line(LineBuffer);
|
|
||||||
|
|
||||||
CAssetID WorldID;
|
CAssetID WorldID;
|
||||||
TString WorldName;
|
TString WorldName;
|
||||||
@ -287,13 +281,13 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj)
|
|||||||
if (IDSplit != -1)
|
if (IDSplit != -1)
|
||||||
{
|
{
|
||||||
// Get world ID
|
// Get world ID
|
||||||
TString IDString = (IDSplit == -1 ? "" : Line.SubString(2, IDSplit - 2));
|
const TString IDString = (IDSplit == -1 ? "" : Line.SubString(2, IDSplit - 2));
|
||||||
WorldID = CAssetID::FromString(IDString);
|
WorldID = CAssetID::FromString(IDString);
|
||||||
|
|
||||||
// Get world name
|
// Get world name
|
||||||
TString WorldPath = (IDSplit == -1 ? "" : Line.SubString(IDSplit + 1, Line.Size() - IDSplit - 1));
|
const TString WorldPath = (IDSplit == -1 ? "" : Line.SubString(IDSplit + 1, Line.Size() - IDSplit - 1));
|
||||||
uint32 UnderscoreIdx = WorldPath.IndexOf('_');
|
const uint32 UnderscoreIdx = WorldPath.IndexOf('_');
|
||||||
uint32 WorldDirEnd = WorldPath.IndexOf("\\/", UnderscoreIdx);
|
const uint32 WorldDirEnd = WorldPath.IndexOf("\\/", UnderscoreIdx);
|
||||||
|
|
||||||
if (UnderscoreIdx != -1 && WorldDirEnd != -1)
|
if (UnderscoreIdx != -1 && WorldDirEnd != -1)
|
||||||
WorldName = WorldPath.SubString(UnderscoreIdx + 1, WorldDirEnd - UnderscoreIdx - 1);
|
WorldName = WorldPath.SubString(UnderscoreIdx + 1, WorldDirEnd - UnderscoreIdx - 1);
|
||||||
@ -301,9 +295,7 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj)
|
|||||||
|
|
||||||
if (WorldID.IsValid() && !WorldName.IsEmpty())
|
if (WorldID.IsValid() && !WorldName.IsEmpty())
|
||||||
{
|
{
|
||||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(WorldID);
|
if (CResourceEntry* pEntry = gpResourceStore->FindEntry(WorldID))
|
||||||
|
|
||||||
if (pEntry)
|
|
||||||
{
|
{
|
||||||
QString WorldNameQ = TO_QSTRING(WorldName);
|
QString WorldNameQ = TO_QSTRING(WorldName);
|
||||||
|
|
||||||
@ -319,10 +311,10 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(pAreaList);
|
pAreaList.reset();
|
||||||
|
|
||||||
// Add remaining worlds to FrontEnd world
|
// Add remaining worlds to FrontEnd world
|
||||||
mWorldList.prepend( SWorldInfo() );
|
mWorldList.prepend(SWorldInfo());
|
||||||
pInfo = &mWorldList.front();
|
pInfo = &mWorldList.front();
|
||||||
pInfo->WorldName = "FrontEnd";
|
pInfo->WorldName = "FrontEnd";
|
||||||
|
|
||||||
@ -333,11 +325,10 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort FrontEnd world
|
// Sort FrontEnd world
|
||||||
std::sort( pInfo->Areas.begin(), pInfo->Areas.end(), [](CResourceEntry *pA, CResourceEntry *pB) -> bool {
|
std::sort( pInfo->Areas.begin(), pInfo->Areas.end(), [](const CResourceEntry *pA, const CResourceEntry *pB) {
|
||||||
return pA->UppercaseName() < pB->UppercaseName();
|
return pA->UppercaseName() < pB->UppercaseName();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
@ -347,25 +338,25 @@ void CWorldTreeModel::OnMapChanged()
|
|||||||
{
|
{
|
||||||
// Flag all data as changed to ensure the font updates correctly based on which areas are loaded
|
// Flag all data as changed to ensure the font updates correctly based on which areas are loaded
|
||||||
// note we don't know which areas used to be loaded, so flagging those specific indices isn't an option
|
// note we don't know which areas used to be loaded, so flagging those specific indices isn't an option
|
||||||
int MaxRow = rowCount(QModelIndex()) - 1;
|
const int MaxRow = rowCount(QModelIndex()) - 1;
|
||||||
int MaxCol = columnCount(QModelIndex()) - 1;
|
const int MaxCol = columnCount(QModelIndex()) - 1;
|
||||||
emit dataChanged(index(0, 0, QModelIndex()), index(MaxRow, MaxCol, QModelIndex()));
|
emit dataChanged(index(0, 0, QModelIndex()), index(MaxRow, MaxCol, QModelIndex()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ PROXY MODEL ************
|
// ************ PROXY MODEL ************
|
||||||
bool CWorldTreeProxyModel::lessThan(const QModelIndex& rkSourceLeft, const QModelIndex& rkSourceRight) const
|
bool CWorldTreeProxyModel::lessThan(const QModelIndex& rkSourceLeft, const QModelIndex& rkSourceRight) const
|
||||||
{
|
{
|
||||||
CWorldTreeModel *pModel = qobject_cast<CWorldTreeModel*>(sourceModel());
|
const CWorldTreeModel *pModel = qobject_cast<CWorldTreeModel*>(sourceModel());
|
||||||
ASSERT(pModel != nullptr);
|
ASSERT(pModel != nullptr);
|
||||||
|
|
||||||
if (pModel->IndexIsWorld(rkSourceLeft))
|
if (pModel->IndexIsWorld(rkSourceLeft))
|
||||||
{
|
{
|
||||||
ASSERT(pModel->IndexIsWorld(rkSourceRight));
|
ASSERT(pModel->IndexIsWorld(rkSourceRight));
|
||||||
bool IsLessThan = (rkSourceLeft.row() < rkSourceRight.row());
|
const bool IsLessThan = (rkSourceLeft.row() < rkSourceRight.row());
|
||||||
return (sortOrder() == Qt::AscendingOrder ? IsLessThan : !IsLessThan);
|
return (sortOrder() == Qt::AscendingOrder ? IsLessThan : !IsLessThan);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return pModel->data(rkSourceLeft, Qt::DisplayRole).toString().toUpper() < pModel->data(rkSourceRight, Qt::DisplayRole).toString().toUpper();
|
return pModel->data(rkSourceLeft, Qt::DisplayRole).toString().toUpper() < pModel->data(rkSourceRight, Qt::DisplayRole).toString().toUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWorldTreeProxyModel::filterAcceptsRow(int SourceRow, const QModelIndex& rkSourceParent) const
|
bool CWorldTreeProxyModel::filterAcceptsRow(int SourceRow, const QModelIndex& rkSourceParent) const
|
||||||
@ -374,12 +365,12 @@ bool CWorldTreeProxyModel::filterAcceptsRow(int SourceRow, const QModelIndex& rk
|
|||||||
if (!rkSourceParent.isValid() || mFilterString.isEmpty())
|
if (!rkSourceParent.isValid() || mFilterString.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
CWorldTreeModel *pModel = qobject_cast<CWorldTreeModel*>(sourceModel());
|
const CWorldTreeModel *pModel = qobject_cast<CWorldTreeModel*>(sourceModel());
|
||||||
ASSERT(pModel != nullptr);
|
ASSERT(pModel != nullptr);
|
||||||
|
|
||||||
for (int iCol = 0; iCol < pModel->columnCount(rkSourceParent); iCol++)
|
for (int iCol = 0; iCol < pModel->columnCount(rkSourceParent); iCol++)
|
||||||
{
|
{
|
||||||
QModelIndex Index = pModel->index(SourceRow, iCol, rkSourceParent);
|
const QModelIndex Index = pModel->index(SourceRow, iCol, rkSourceParent);
|
||||||
if (pModel->data(Index, Qt::DisplayRole).toString().contains(mFilterString, Qt::CaseInsensitive))
|
if (pModel->data(Index, Qt::DisplayRole).toString().contains(mFilterString, Qt::CaseInsensitive))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user