Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: ui/app_list/app_list_model_view.cc

Issue 10408009: ui: Change ListModel to operate in size_t instead of int. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unittest Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/app_list/app_list_model_view.h ('k') | ui/base/models/list_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/app_list/app_list_model_view.h" 5 #include "ui/app_list/app_list_model_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/app_list/app_list_item_view.h" 9 #include "ui/app_list/app_list_item_view.h"
10 #include "ui/app_list/app_list_model.h" 10 #include "ui/app_list/app_list_model.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 if (index == selected_item_index_) 129 if (index == selected_item_index_)
130 SetSelectedItemByIndex(-1); 130 SetSelectedItemByIndex(-1);
131 } 131 }
132 132
133 void AppListModelView::Update() { 133 void AppListModelView::Update() {
134 selected_item_index_ = -1; 134 selected_item_index_ = -1;
135 RemoveAllChildViews(true); 135 RemoveAllChildViews(true);
136 if (!model_ || model_->item_count() == 0) 136 if (!model_ || model_->item_count() == 0)
137 return; 137 return;
138 138
139 for (int i = 0; i < model_->item_count(); ++i) 139 for (size_t i = 0; i < model_->item_count(); ++i)
140 AddChildView(new AppListItemView(this, model_->GetItemAt(i), listener_)); 140 AddChildView(new AppListItemView(this, model_->GetItemAt(i), listener_));
141 141
142 Layout(); 142 Layout();
143 SchedulePaint(); 143 SchedulePaint();
144 } 144 }
145 145
146 AppListItemView* AppListModelView::GetItemViewAtIndex(int index) { 146 AppListItemView* AppListModelView::GetItemViewAtIndex(int index) {
147 return static_cast<AppListItemView*>(child_at(index)); 147 return static_cast<AppListItemView*>(child_at(index));
148 } 148 }
149 149
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (selected_item_index_ >= 0) 289 if (selected_item_index_ >= 0)
290 handled = GetItemViewAtIndex(selected_item_index_)->OnKeyReleased(event); 290 handled = GetItemViewAtIndex(selected_item_index_)->OnKeyReleased(event);
291 291
292 return handled; 292 return handled;
293 } 293 }
294 294
295 void AppListModelView::OnPaintFocusBorder(gfx::Canvas* canvas) { 295 void AppListModelView::OnPaintFocusBorder(gfx::Canvas* canvas) {
296 // Override to not paint focus frame. 296 // Override to not paint focus frame.
297 } 297 }
298 298
299 void AppListModelView::ListItemsAdded(int start, int count) { 299 void AppListModelView::ListItemsAdded(size_t start, size_t count) {
300 for (int i = start; i < start + count; ++i) { 300 for (size_t i = start; i < start + count; ++i) {
301 AddChildViewAt(new AppListItemView(this, model_->GetItemAt(i), listener_), 301 AddChildViewAt(new AppListItemView(this, model_->GetItemAt(i), listener_),
302 i); 302 i);
303 } 303 }
304 Layout(); 304 Layout();
305 SchedulePaint(); 305 SchedulePaint();
306 } 306 }
307 307
308 void AppListModelView::ListItemsRemoved(int start, int count) { 308 void AppListModelView::ListItemsRemoved(size_t start, size_t count) {
309 for (int i = 0; i < count; ++i) 309 for (size_t i = 0; i < count; ++i)
310 delete child_at(start); 310 delete child_at(start);
311 311
312 Layout(); 312 Layout();
313 SchedulePaint(); 313 SchedulePaint();
314 } 314 }
315 315
316 void AppListModelView::ListItemsChanged(int start, int count) { 316 void AppListModelView::ListItemsChanged(size_t start, size_t count) {
317 NOTREACHED(); 317 NOTREACHED();
318 } 318 }
319 319
320 void AppListModelView::TotalPagesChanged() { 320 void AppListModelView::TotalPagesChanged() {
321 } 321 }
322 322
323 void AppListModelView::SelectedPageChanged(int old_selected, int new_selected) { 323 void AppListModelView::SelectedPageChanged(int old_selected, int new_selected) {
324 Layout(); 324 Layout();
325 } 325 }
326 326
327 } // namespace app_list 327 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/app_list_model_view.h ('k') | ui/base/models/list_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698