From c1405bfac11f5a762f2fdd6e3c0e67c3933b6068 Mon Sep 17 00:00:00 2001 From: parax0 Date: Tue, 12 Jul 2016 04:49:56 -0600 Subject: [PATCH] Applied some minor optimizations to the resource browser and right-aligned the file size column --- src/Editor/ResourceBrowser/CResourceBrowser.cpp | 2 +- src/Editor/ResourceBrowser/CResourceBrowser.ui | 3 +++ src/Editor/ResourceBrowser/CResourceProxyModel.h | 12 ++++++------ src/Editor/ResourceBrowser/CResourceTableModel.h | 3 +++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Editor/ResourceBrowser/CResourceBrowser.cpp b/src/Editor/ResourceBrowser/CResourceBrowser.cpp index ee0a9958..ab0f7143 100644 --- a/src/Editor/ResourceBrowser/CResourceBrowser.cpp +++ b/src/Editor/ResourceBrowser/CResourceBrowser.cpp @@ -49,7 +49,7 @@ void CResourceBrowser::OnSortModeChanged(int Index) void CResourceBrowser::OnSearchStringChanged() { - mpProxyModel->SetSearchString( mpUI->SearchBar->text() ); + mpProxyModel->SetSearchString( TO_TWIDESTRING(mpUI->SearchBar->text()) ); } void CResourceBrowser::OnDirectorySelectionChanged(const QModelIndex& rkNewIndex, const QModelIndex& /*rkPrevIndex*/) diff --git a/src/Editor/ResourceBrowser/CResourceBrowser.ui b/src/Editor/ResourceBrowser/CResourceBrowser.ui index c964722b..0e60da9c 100644 --- a/src/Editor/ResourceBrowser/CResourceBrowser.ui +++ b/src/Editor/ResourceBrowser/CResourceBrowser.ui @@ -83,6 +83,9 @@ true + + QAbstractItemView::SingleSelection + 16 diff --git a/src/Editor/ResourceBrowser/CResourceProxyModel.h b/src/Editor/ResourceBrowser/CResourceProxyModel.h index 75ac0a84..50ba6dfd 100644 --- a/src/Editor/ResourceBrowser/CResourceProxyModel.h +++ b/src/Editor/ResourceBrowser/CResourceProxyModel.h @@ -17,7 +17,7 @@ public: private: CResourceTableModel *mpModel; CVirtualDirectory *mpDirectory; - QString mSearchString; + TWideString mSearchString; ESortMode mSortMode; public: @@ -56,7 +56,7 @@ public: if (mpDirectory && !pEntry->IsInDirectory(mpDirectory)) return false; - if (!mSearchString.isEmpty() && !pEntry->Name().Contains(TO_TWIDESTRING(mSearchString), false)) + if (!mSearchString.IsEmpty() && !pEntry->UppercaseName().Contains(mSearchString)) return false; return true; @@ -74,14 +74,14 @@ public: inline void SetDirectory(CVirtualDirectory *pDir) { mpDirectory = pDir; - invalidateFilter(); + invalidate(); } public slots: - void SetSearchString(const QString& rkString) + void SetSearchString(const TWideString& rkString) { - mSearchString = rkString; - invalidateFilter(); + mSearchString = rkString.ToUpper(); + invalidate(); } }; diff --git a/src/Editor/ResourceBrowser/CResourceTableModel.h b/src/Editor/ResourceBrowser/CResourceTableModel.h index 92e3dda8..6cf637cb 100644 --- a/src/Editor/ResourceBrowser/CResourceTableModel.h +++ b/src/Editor/ResourceBrowser/CResourceTableModel.h @@ -49,6 +49,9 @@ public: else if (Role == Qt::ToolTipRole) return TO_QSTRING(pEntry->Directory()->FullPath() + pEntry->Name()); + else if (Role == Qt::TextAlignmentRole && rkIndex.column() == 2) + return Qt::AlignRight; + return QVariant::Invalid; }