CResourceProxyModel: Make use of override

This commit is contained in:
Lioncash 2020-07-03 12:35:08 -04:00
parent 9e976606ff
commit 1463974b1e

View File

@ -16,24 +16,23 @@ public:
}; };
private: private:
CResourceTableModel *mpModel; CResourceTableModel *mpModel = nullptr;
TString mSearchString; TString mSearchString;
ESortMode mSortMode; ESortMode mSortMode{};
QSet<CResTypeInfo*> mTypeFilter; QSet<CResTypeInfo*> mTypeFilter;
uint64 mCompareID; uint64 mCompareID = 0;
uint64 mCompareMask; uint64 mCompareMask = 0;
uint32 mCompareBitLength; uint32 mCompareBitLength = 0;
public: public:
explicit CResourceProxyModel(QObject *pParent = 0) explicit CResourceProxyModel(QObject *pParent = nullptr)
: QSortFilterProxyModel(pParent) : QSortFilterProxyModel(pParent)
, mpModel(nullptr)
{ {
SetSortMode(ESortMode::ByName); SetSortMode(ESortMode::ByName);
} }
void setSourceModel(QAbstractItemModel *pSourceModel) void setSourceModel(QAbstractItemModel* pSourceModel) override
{ {
CResourceTableModel *pResModel = qobject_cast<CResourceTableModel*>(pSourceModel); CResourceTableModel *pResModel = qobject_cast<CResourceTableModel*>(pSourceModel);
mpModel = pResModel; mpModel = pResModel;
@ -41,7 +40,7 @@ public:
sort(0); sort(0);
} }
bool lessThan(const QModelIndex& rkLeft, const QModelIndex& rkRight) const bool lessThan(const QModelIndex& rkLeft, const QModelIndex& rkRight) const override
{ {
// Parent directory is always row 0 and should always be at the top // Parent directory is always row 0 and should always be at the top
if (mpModel->HasParentDirectoryEntry()) if (mpModel->HasParentDirectoryEntry())
@ -75,7 +74,7 @@ public:
return pLeftRes->Size() < pRightRes->Size(); return pLeftRes->Size() < pRightRes->Size();
} }
bool filterAcceptsRow(int SourceRow, const QModelIndex& rkSourceParent) const bool filterAcceptsRow(int SourceRow, const QModelIndex& rkSourceParent) const override
{ {
QModelIndex Index = mpModel->index(SourceRow, 0, rkSourceParent); QModelIndex Index = mpModel->index(SourceRow, 0, rkSourceParent);
CResourceEntry *pEntry = mpModel->IndexEntry(Index); CResourceEntry *pEntry = mpModel->IndexEntry(Index);
@ -126,7 +125,7 @@ public:
return true; return true;
} }
inline void SetTypeFilter(CResTypeInfo *pInfo, bool Allow) void SetTypeFilter(CResTypeInfo *pInfo, bool Allow)
{ {
if (Allow) if (Allow)
mTypeFilter.insert(pInfo); mTypeFilter.insert(pInfo);
@ -134,22 +133,22 @@ public:
mTypeFilter.remove(pInfo); mTypeFilter.remove(pInfo);
} }
inline void ClearTypeFilter() void ClearTypeFilter()
{ {
mTypeFilter.clear(); mTypeFilter.clear();
} }
inline bool HasTypeFilter() const bool HasTypeFilter() const
{ {
return !mTypeFilter.isEmpty(); return !mTypeFilter.isEmpty();
} }
inline bool IsTypeAccepted(CResTypeInfo *pTypeInfo) const bool IsTypeAccepted(CResTypeInfo *pTypeInfo) const
{ {
return mTypeFilter.isEmpty() || mTypeFilter.contains(pTypeInfo); return mTypeFilter.isEmpty() || mTypeFilter.contains(pTypeInfo);
} }
inline void SetSortMode(ESortMode Mode) void SetSortMode(ESortMode Mode)
{ {
if (mSortMode != Mode) if (mSortMode != Mode)
{ {