mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-08 21:17:53 +00:00
CVirtualDirectory: Pass by const in IsDescendantOf
This isn't modified.
This commit is contained in:
@@ -43,7 +43,7 @@ bool CVirtualDirectory::IsEmpty(bool CheckFilesystem) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CVirtualDirectory::IsDescendantOf(CVirtualDirectory *pDir) const
|
||||
bool CVirtualDirectory::IsDescendantOf(const CVirtualDirectory *pDir) const
|
||||
{
|
||||
return (this == pDir) || (mpParent != nullptr && pDir != nullptr && (mpParent == pDir || mpParent->IsDescendantOf(pDir)));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
~CVirtualDirectory();
|
||||
|
||||
bool IsEmpty(bool CheckFilesystem) const;
|
||||
bool IsDescendantOf(CVirtualDirectory *pDir) const;
|
||||
bool IsDescendantOf(const CVirtualDirectory *pDir) const;
|
||||
bool IsSafeToDelete() const;
|
||||
TString FullPath() const;
|
||||
TString AbsolutePath() const;
|
||||
|
||||
@@ -84,21 +84,17 @@ bool CResourceTableModel::canDropMimeData(const QMimeData *pkData, Qt::DropActio
|
||||
if (Row != -1 || Column != -1)
|
||||
return false;
|
||||
|
||||
const CResourceMimeData *pkMimeData = qobject_cast<const CResourceMimeData*>(pkData);
|
||||
|
||||
if (pkMimeData)
|
||||
if (const auto* pkMimeData = qobject_cast<const CResourceMimeData*>(pkData))
|
||||
{
|
||||
// Don't allow dropping onto blank space in asset list mode
|
||||
if (!rkParent.isValid() && mIsAssetListMode)
|
||||
return false;
|
||||
|
||||
// Make sure we're dropping onto a directory
|
||||
CVirtualDirectory *pDir = (rkParent.isValid() ? IndexDirectory(rkParent) : mpCurrentDir);
|
||||
|
||||
if (pDir)
|
||||
if (const CVirtualDirectory* pDir = (rkParent.isValid() ? IndexDirectory(rkParent) : mpCurrentDir))
|
||||
{
|
||||
// Make sure this directory isn't part of the mime data, or a subdirectory of a directory in the mime data
|
||||
for (CVirtualDirectory *pMimeDir : pkMimeData->Directories())
|
||||
for (const CVirtualDirectory* pMimeDir : pkMimeData->Directories())
|
||||
{
|
||||
if (pDir == pMimeDir || pDir->IsDescendantOf(pMimeDir))
|
||||
return false;
|
||||
@@ -159,9 +155,9 @@ Qt::DropActions CResourceTableModel::supportedDropActions() const
|
||||
}
|
||||
|
||||
// ************ FUNCTIONALITY ************
|
||||
QModelIndex CResourceTableModel::GetIndexForEntry(CResourceEntry *pEntry) const
|
||||
QModelIndex CResourceTableModel::GetIndexForEntry(const CResourceEntry *pEntry) const
|
||||
{
|
||||
const auto Iter = std::find(mEntries.begin(), mEntries.end(), pEntry);
|
||||
const auto Iter = std::find(mEntries.cbegin(), mEntries.cend(), pEntry);
|
||||
|
||||
if (Iter == mEntries.cend())
|
||||
return QModelIndex();
|
||||
@@ -170,7 +166,7 @@ QModelIndex CResourceTableModel::GetIndexForEntry(CResourceEntry *pEntry) const
|
||||
return index(mDirectories.size() + Index, 0, QModelIndex());
|
||||
}
|
||||
|
||||
QModelIndex CResourceTableModel::GetIndexForDirectory(CVirtualDirectory *pDir) const
|
||||
QModelIndex CResourceTableModel::GetIndexForDirectory(const CVirtualDirectory *pDir) const
|
||||
{
|
||||
for (int DirIdx = 0; DirIdx < mDirectories.size(); DirIdx++)
|
||||
{
|
||||
@@ -277,9 +273,9 @@ void CResourceTableModel::RecursiveAddDirectoryContents(CVirtualDirectory *pDir)
|
||||
RecursiveAddDirectoryContents(pDir->SubdirectoryByIndex(iDir));
|
||||
}
|
||||
|
||||
int CResourceTableModel::EntryListIndex(CResourceEntry *pEntry)
|
||||
int CResourceTableModel::EntryListIndex(const CResourceEntry *pEntry) const
|
||||
{
|
||||
return std::lower_bound(mEntries.begin(), mEntries.end(), pEntry) - mEntries.begin();
|
||||
return std::lower_bound(mEntries.cbegin(), mEntries.cend(), pEntry) - mEntries.cbegin();
|
||||
}
|
||||
|
||||
void CResourceTableModel::RefreshAllIndices()
|
||||
@@ -344,7 +340,7 @@ void CResourceTableModel::CheckRemoveDirectory(CVirtualDirectory *pDir)
|
||||
|
||||
void CResourceTableModel::OnResourceMoved(CResourceEntry *pEntry, CVirtualDirectory *pOldDir, const TString& OldName)
|
||||
{
|
||||
CVirtualDirectory *pNewDir = pEntry->Directory();
|
||||
const CVirtualDirectory* pNewDir = pEntry->Directory();
|
||||
const bool WasInModel = (pOldDir == mpCurrentDir || (mIsAssetListMode && pOldDir->IsDescendantOf(mpCurrentDir)));
|
||||
const bool IsInModel = (pNewDir == mpCurrentDir || (mIsAssetListMode && pNewDir->IsDescendantOf(mpCurrentDir)));
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
|
||||
// Functionality
|
||||
QModelIndex GetIndexForEntry(CResourceEntry *pEntry) const;
|
||||
QModelIndex GetIndexForDirectory(CVirtualDirectory *pDir) const;
|
||||
QModelIndex GetIndexForEntry(const CResourceEntry *pEntry) const;
|
||||
QModelIndex GetIndexForDirectory(const CVirtualDirectory *pDir) const;
|
||||
CResourceEntry* IndexEntry(const QModelIndex& rkIndex) const;
|
||||
CVirtualDirectory* IndexDirectory(const QModelIndex& rkIndex) const;
|
||||
bool IsIndexDirectory(const QModelIndex& rkIndex) const;
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
void DisplayEntryList(QList<CResourceEntry*> rkEntries, QString rkListDescription);
|
||||
protected:
|
||||
void RecursiveAddDirectoryContents(CVirtualDirectory *pDir);
|
||||
int EntryListIndex(CResourceEntry *pEntry);
|
||||
int EntryListIndex(const CResourceEntry *pEntry) const;
|
||||
|
||||
public:
|
||||
// Accessors
|
||||
|
||||
@@ -38,9 +38,7 @@ void CVirtualDirectoryTreeView::dragEnterEvent(QDragEnterEvent *pEvent)
|
||||
|
||||
void CVirtualDirectoryTreeView::setModel(QAbstractItemModel *pModel)
|
||||
{
|
||||
CVirtualDirectoryModel *pDirModel = qobject_cast<CVirtualDirectoryModel*>(pModel);
|
||||
|
||||
if (pDirModel)
|
||||
if (auto* pDirModel = qobject_cast<CVirtualDirectoryModel*>(pModel))
|
||||
{
|
||||
mpModel = pDirModel;
|
||||
QTreeView::setModel(pModel);
|
||||
|
||||
Reference in New Issue
Block a user