From 5ac292ebc5070cf26c915b2a5785c991547f9d6f Mon Sep 17 00:00:00 2001 From: Aruki Date: Sun, 29 Jan 2017 08:01:33 -0700 Subject: [PATCH] Made search bar in resource browser feel more responsive --- .../ResourceBrowser/CResourceBrowser.cpp | 9 +- src/Editor/ResourceBrowser/CResourceBrowser.h | 2 + .../ResourceBrowser/CResourceBrowser.ui | 316 +++++++++--------- 3 files changed, 166 insertions(+), 161 deletions(-) diff --git a/src/Editor/ResourceBrowser/CResourceBrowser.cpp b/src/Editor/ResourceBrowser/CResourceBrowser.cpp index b2b251f2..cc51d958 100644 --- a/src/Editor/ResourceBrowser/CResourceBrowser.cpp +++ b/src/Editor/ResourceBrowser/CResourceBrowser.cpp @@ -45,6 +45,7 @@ CResourceBrowser::CResourceBrowser(QWidget *pParent) connect(mpUI->DirectoryTreeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(OnDirectorySelectionChanged(QModelIndex,QModelIndex))); connect(mpUI->ResourceTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnDoubleClickResource(QModelIndex))); connect(pImportFromContentsTxtAction, SIGNAL(triggered()), this, SLOT(OnImportPakContentsTxt())); + connect(&mUpdateFilterTimer, SIGNAL(timeout()), this, SLOT(UpdateFilter())); } CResourceBrowser::~CResourceBrowser() @@ -79,7 +80,8 @@ void CResourceBrowser::OnSortModeChanged(int Index) void CResourceBrowser::OnSearchStringChanged() { - mpProxyModel->SetSearchString( TO_TWIDESTRING(mpUI->SearchBar->text()) ); + const int kUpdateWaitTime = 500; + mUpdateFilterTimer.start(kUpdateWaitTime); } void CResourceBrowser::OnDirectorySelectionChanged(const QModelIndex& rkNewIndex, const QModelIndex& /*rkPrevIndex*/) @@ -139,3 +141,8 @@ void CResourceBrowser::OnImportPakContentsTxt() RefreshResources(); } + +void CResourceBrowser::UpdateFilter() +{ + mpProxyModel->SetSearchString( TO_TWIDESTRING(mpUI->SearchBar->text()) ); +} diff --git a/src/Editor/ResourceBrowser/CResourceBrowser.h b/src/Editor/ResourceBrowser/CResourceBrowser.h index 2d4fbac6..6ea52449 100644 --- a/src/Editor/ResourceBrowser/CResourceBrowser.h +++ b/src/Editor/ResourceBrowser/CResourceBrowser.h @@ -18,6 +18,7 @@ class CResourceBrowser : public QDialog CResourceTableModel *mpModel; CResourceProxyModel *mpProxyModel; CVirtualDirectoryModel *mpDirectoryModel; + QTimer mUpdateFilterTimer; public: explicit CResourceBrowser(QWidget *pParent = 0); @@ -31,6 +32,7 @@ public slots: void OnDirectorySelectionChanged(const QModelIndex& rkNewIndex, const QModelIndex& rkPrevIndex); void OnDoubleClickResource(QModelIndex Index); void OnImportPakContentsTxt(); + void UpdateFilter(); }; #endif // CRESOURCEBROWSER_H diff --git a/src/Editor/ResourceBrowser/CResourceBrowser.ui b/src/Editor/ResourceBrowser/CResourceBrowser.ui index 53debcf3..c53c8f05 100644 --- a/src/Editor/ResourceBrowser/CResourceBrowser.ui +++ b/src/Editor/ResourceBrowser/CResourceBrowser.ui @@ -13,192 +13,188 @@ Resource Browser - + - - - - - - 1 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - + + + + 1 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + - - - - - Store: - - - - - - - - 1 - 0 - - - - - Project - - - - - Editor - - - - - - - - - - - 5 - 0 - - - - Search + + + Store: - + - 5 + 1 0 - Sort by Name + Project - Sort by Size + Editor - - - - - 10 - - - - QAbstractItemView::NoEditTriggers - - - true - - - QAbstractItemView::SingleSelection - - - - 16 - 16 - - - - QAbstractItemView::ScrollPerPixel - - - 12 - - - false - - - - - - - - - - 3 - 0 - - - - - 10 - - - - QAbstractItemView::NoEditTriggers - - - true - - - QAbstractItemView::ExtendedSelection - - - QAbstractItemView::SelectRows - - - QAbstractItemView::ScrollPerPixel - - - QAbstractItemView::ScrollPerPixel - - - true - - - false - - - false - - - 21 - - - 21 - - - - - - - - - Import Names - + + + + + + 5 + 0 + + + + Search + + + + + + + + 5 + 0 + + + + + Sort by Name + + + + + Sort by Size + + + + + + + + + 10 + + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::SingleSelection + + + + 16 + 16 + + + + QAbstractItemView::ScrollPerPixel + + + 12 + + + false + + + + + + + Import Names + + + + + + + Export Names + + + + - - - Export Names + + + + 3 + 0 + + + + 10 + + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectRows + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + true + + + false + + + false + + + 21 + + + 21 +