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