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