diff options
| author | Bilal Akhtar <bilalakhtar@ubuntu.com> | 2012-08-28 09:14:39 -0400 |
|---|---|---|
| committer | Tarmac <> | 2012-08-28 09:14:39 -0400 |
| commit | 1fa90b0d5c8e69edf39cd7911c41d7381d7d1acd (patch) | |
| tree | 1959874e5e1891c345a12ee1c08bd4d266a492b1 | |
| parent | b108910526313f15514f4cd8ed3f361b5761c209 (diff) | |
| parent | d0cf5bd482e64590d336a2760f1f3b42d1b9ea5d (diff) | |
Fixes bug #950710 by expanding a PlacesGroup if it is the only category that contains results.. Fixes: https://bugs.launchpad.net/bugs/950710. Approved by Tim Penhey.
(bzr r2635)
| -rwxr-xr-x | dash/LensView.cpp | 32 | ||||
| -rw-r--r-- | dash/LensView.h | 2 | ||||
| -rw-r--r-- | manual-tests/Dash.txt | 21 |
3 files changed, 55 insertions, 0 deletions
diff --git a/dash/LensView.cpp b/dash/LensView.cpp index 38dbedf63..16128abc1 100755 --- a/dash/LensView.cpp +++ b/dash/LensView.cpp @@ -136,6 +136,7 @@ LensView::LensView(Lens::Ptr lens, nux::Area* show_filters) , lens_(lens) , initial_activation_(true) , no_results_active_(false) + , last_expanded_group_(nullptr) , last_good_filter_model_(-1) { SetupViews(show_filters); @@ -500,6 +501,10 @@ void LensView::OnResultAdded(Result const& result) { CheckNoResults(Lens::Hints()); } + + // Check if all results so far are from one category + // If so, then expand that category. + CheckCategoryExpansion(); } catch (std::out_of_range& oor) { LOG_WARN(logger) << "Result does not have a valid category index: " << boost::lexical_cast<unsigned int>(result.category_index) @@ -602,6 +607,33 @@ void LensView::CheckNoResults(Lens::Hints const& hints) } } +void LensView::CheckCategoryExpansion() +{ + int number_of_displayed_categories = 0; + + // Check if we had expanded a group in last run + // If so, collapse it for now + if (last_expanded_group_ != nullptr) + { + last_expanded_group_->SetExpanded(false); + last_expanded_group_ = nullptr; + } + + // Cycle through all categories + for (auto category : categories_) + { + if (counts_[category] > 0) { + number_of_displayed_categories++; + last_expanded_group_ = category; + } + } + + if (number_of_displayed_categories == 1 && last_expanded_group_ != nullptr) + last_expanded_group_->SetExpanded(true); + else + last_expanded_group_ = nullptr; +} + void LensView::HideResultsMessage() { if (no_results_active_) diff --git a/dash/LensView.h b/dash/LensView.h index 87f051138..b9867c21a 100644 --- a/dash/LensView.h +++ b/dash/LensView.h @@ -73,6 +73,7 @@ public: void PerformSearch(std::string const& search_query); void CheckNoResults(Lens::Hints const& hints); + void CheckCategoryExpansion(); void HideResultsMessage(); private: @@ -114,6 +115,7 @@ private: bool initial_activation_; bool no_results_active_; std::string search_string_; + PlacesGroup* last_expanded_group_; nux::HLayout* layout_; LensScrollView* scroll_view_; diff --git a/manual-tests/Dash.txt b/manual-tests/Dash.txt index 6e3dec861..9ab7579ca 100644 --- a/manual-tests/Dash.txt +++ b/manual-tests/Dash.txt @@ -79,6 +79,27 @@ Expected Result: "Sorry nothing matches your search" text. +Dash category expand test +-------------------------- +This tests whether the dash expands a certain search results category if it is the only one containing search results. +https://bugs.launchpad.net/unity/+bug/950710 + +Setup: + +Actions: + * Open the dash home view + * Search for something on your system that returns multiple results (more than the number that can fit in a row) + yet all results are in one category only. This differs per system; try searching for "gnome" in the home lens, or "kde" + in the app lens. + * Multiple results should be returned in both the cases, but if searching for "gnome" on the home lens returns folders in addition to apps + or "kde" returns results from two categories in the apps lens, then keep experimenting with other search strings. + * When you have at least one situation in which results from only one category are returned, and the number of results are enough to overflow one single row, + the test is complete. + +Expected result: + * When a single row of results isn't enough to contain all returned search results, and there are no other category headers, the displayed category + header expands automatically + Filter Results Tests ======================== These tests show that the dash "All" button works well. |
