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.
5 #include "ui/base/models/table_model.h"
7 #include "base/i18n/string_compare.h"
8 #include "base/logging.h"
9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/gfx/image/image_skia.h"
14 // TableColumn -----------------------------------------------------------------
16 TableColumn::TableColumn()
26 TableColumn::TableColumn(int id
, Alignment alignment
, int width
, float percent
)
28 title(l10n_util::GetStringUTF16(id
)),
36 // TableModel -----------------------------------------------------------------
39 static icu::Collator
* collator
= NULL
;
41 gfx::ImageSkia
TableModel::GetIcon(int row
) {
42 return gfx::ImageSkia();
45 base::string16
TableModel::GetTooltip(int row
) {
46 return base::string16();
49 bool TableModel::ShouldIndent(int row
) {
53 bool TableModel::HasGroups() {
57 TableModel::Groups
TableModel::GetGroups() {
58 // If you override HasGroups to return true, you must override this as
61 return std::vector
<Group
>();
64 int TableModel::GetGroupID(int row
) {
65 // If you override HasGroups to return true, you must override this as
71 int TableModel::CompareValues(int row1
, int row2
, int column_id
) {
72 DCHECK(row1
>= 0 && row1
< RowCount() &&
73 row2
>= 0 && row2
< RowCount());
74 base::string16 value1
= GetText(row1
, column_id
);
75 base::string16 value2
= GetText(row2
, column_id
);
76 icu::Collator
* collator
= GetCollator();
79 return base::i18n::CompareString16WithCollator(collator
, value1
, value2
);
85 void TableModel::ClearCollator() {
90 icu::Collator
* TableModel::GetCollator() {
92 UErrorCode create_status
= U_ZERO_ERROR
;
93 collator
= icu::Collator::createInstance(create_status
);
94 if (!U_SUCCESS(create_status
)) {