blob: 64556a515e513d7da2aecda903a90df070ab7815 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/app_list/pagination_model.h"
#include "ui/app_list/pagination_model_observer.h"
namespace app_list {
PaginationModel::PaginationModel()
: total_pages_(-1),
selected_page_(-1) {
}
PaginationModel::~PaginationModel() {
}
void PaginationModel::SetTotalPages(int total_pages) {
if (total_pages == total_pages_)
return;
total_pages_ = total_pages;
FOR_EACH_OBSERVER(PaginationModelObserver,
observers_,
TotalPagesChanged());
}
void PaginationModel::SelectPage(int page) {
DCHECK(page >= 0 && page < total_pages_);
if (page == selected_page_)
return;
int old_selected = selected_page_;
selected_page_ = page;
FOR_EACH_OBSERVER(PaginationModelObserver,
observers_,
SelectedPageChanged(old_selected, selected_page_));
}
void PaginationModel::AddObserver(PaginationModelObserver* observer) {
observers_.AddObserver(observer);
}
void PaginationModel::RemoveObserver(PaginationModelObserver* observer) {
observers_.RemoveObserver(observer);
}
} // namespace app_list
|