| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_APP_LIST_SEARCH_RESULT_LIST_VIEW_H_ |
| 6 #define UI_APP_LIST_SEARCH_RESULT_LIST_VIEW_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "ui/app_list/app_list_model.h" |
| 12 #include "ui/base/models/list_model_observer.h" |
| 13 #include "ui/views/controls/button/button.h" |
| 14 #include "ui/views/view.h" |
| 15 |
| 16 namespace app_list { |
| 17 |
| 18 class SearchResultListViewDelegate; |
| 19 class SearchResultView; |
| 20 |
| 21 // SearchResultListView displays AppListModel::SearchResults with a list of |
| 22 // SearchResultView. |
| 23 class SearchResultListView : public views::View, |
| 24 public views::ButtonListener, |
| 25 public ui::ListModelObserver { |
| 26 public: |
| 27 explicit SearchResultListView(SearchResultListViewDelegate* delegate); |
| 28 virtual ~SearchResultListView(); |
| 29 |
| 30 void SetResults(AppListModel::SearchResults* results); |
| 31 |
| 32 void SetSelectedIndex(int selected_index); |
| 33 |
| 34 bool IsResultViewSelected(const SearchResultView* result_view) const; |
| 35 |
| 36 private: |
| 37 // Helper function to get SearchResultView at given |index|. |
| 38 SearchResultView* GetResultViewAt(int index); |
| 39 |
| 40 // Updates UI with model. |
| 41 void Update(); |
| 42 |
| 43 // Schedules an Update call using |update_factory_|. Do nothing if there is a |
| 44 // pending call. |
| 45 void ScheduleUpdate(); |
| 46 |
| 47 // Overridden from views::View: |
| 48 virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; |
| 49 |
| 50 // Overridden from views::ButtonListener: |
| 51 virtual void ButtonPressed(views::Button* sender, |
| 52 const views::Event& event) OVERRIDE; |
| 53 |
| 54 // Overridden from ListModelObserver: |
| 55 virtual void ListItemsAdded(size_t start, size_t count) OVERRIDE; |
| 56 virtual void ListItemsRemoved(size_t start, size_t count) OVERRIDE; |
| 57 virtual void ListItemsChanged(size_t start, size_t count) OVERRIDE; |
| 58 |
| 59 SearchResultListViewDelegate* delegate_; // Not owned. |
| 60 AppListModel::SearchResults* results_; // Owned by AppListModel. |
| 61 |
| 62 int last_visible_index_; |
| 63 int selected_index_; |
| 64 |
| 65 // The factory that consolidates multiple Update calls into one. |
| 66 base::WeakPtrFactory<SearchResultListView> update_factory_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(SearchResultListView); |
| 69 }; |
| 70 |
| 71 } // namespace app_ist |
| 72 |
| 73 #endif // UI_APP_LIST_SEARCH_RESULT_LIST_VIEW_H_ |
| OLD | NEW |