diff --git a/Userland/Applications/Assistant/Providers.cpp b/Userland/Applications/Assistant/Providers.cpp index 695669bf65..5b23546127 100644 --- a/Userland/Applications/Assistant/Providers.cpp +++ b/Userland/Applications/Assistant/Providers.cpp @@ -120,6 +120,11 @@ Gfx::Bitmap const* FileResult::bitmap() const return GUI::FileIconProvider::icon_for_path(title()).bitmap_for_size(16); } +FileProvider::FileProvider() +{ + build_filesystem_cache(); +} + void FileProvider::query(const String& query, Function)> on_complete) { build_filesystem_cache(); diff --git a/Userland/Applications/Assistant/Providers.h b/Userland/Applications/Assistant/Providers.h index 31987cfc11..9120e64192 100644 --- a/Userland/Applications/Assistant/Providers.h +++ b/Userland/Applications/Assistant/Providers.h @@ -145,6 +145,8 @@ public: class FileProvider : public Provider { public: + FileProvider(); + void query(String const& query, Function)> on_complete) override; void build_filesystem_cache(); diff --git a/Userland/Applications/Assistant/main.cpp b/Userland/Applications/Assistant/main.cpp index 7ee79fbbed..a995c9c43f 100644 --- a/Userland/Applications/Assistant/main.cpp +++ b/Userland/Applications/Assistant/main.cpp @@ -120,36 +120,26 @@ public: explicit Database(AppState& state) : m_state(state) { - m_file_provider.build_filesystem_cache(); + m_providers.append(make()); + m_providers.append(make()); + m_providers.append(make()); + m_providers.append(make()); + m_providers.append(make()); } Function)> on_new_results; void search(String const& query) { - m_file_provider.query(query, [=, this](auto results) { - recv_results(query, results); - }); - - m_app_provider.query(query, [=, this](auto results) { - recv_results(query, results); - }); - - m_calculator_provider.query(query, [=, this](auto results) { - recv_results(query, results); - }); - - m_terminal_provider.query(query, [=, this](auto results) { - recv_results(query, results); - }); - - m_url_provider.query(query, [=, this](auto results) { - recv_results(query, results); - }); + for (auto& provider : m_providers) { + provider.query(query, [=, this](auto results) { + did_receive_results(query, results); + }); + } } private: - void recv_results(String const& query, NonnullRefPtrVector const& results) + void did_receive_results(String const& query, NonnullRefPtrVector const& results) { { Threading::Locker db_locker(m_lock); @@ -188,11 +178,7 @@ private: AppState& m_state; - AppProvider m_app_provider; - CalculatorProvider m_calculator_provider; - FileProvider m_file_provider; - TerminalProvider m_terminal_provider; - URLProvider m_url_provider; + NonnullOwnPtrVector m_providers; Threading::Lock m_lock; HashMap> m_result_cache;