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

Side by Side Diff: ui/base/models/table_model.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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
« no previous file with comments | « ui/base/models/table_model.h ('k') | ui/base/models/table_model_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "ui/base/models/table_model.h"
6
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"
11
12 namespace ui {
13
14 // TableColumn -----------------------------------------------------------------
15
16 TableColumn::TableColumn()
17 : id(0),
18 title(),
19 alignment(LEFT),
20 width(-1),
21 percent(),
22 min_visible_width(0),
23 sortable(false) {
24 }
25
26 TableColumn::TableColumn(int id, Alignment alignment, int width, float percent)
27 : id(id),
28 title(l10n_util::GetStringUTF16(id)),
29 alignment(alignment),
30 width(width),
31 percent(percent),
32 min_visible_width(0),
33 sortable(false) {
34 }
35
36 // TableModel -----------------------------------------------------------------
37
38 // Used for sorting.
39 static icu::Collator* collator = NULL;
40
41 gfx::ImageSkia TableModel::GetIcon(int row) {
42 return gfx::ImageSkia();
43 }
44
45 base::string16 TableModel::GetTooltip(int row) {
46 return base::string16();
47 }
48
49 bool TableModel::ShouldIndent(int row) {
50 return false;
51 }
52
53 bool TableModel::HasGroups() {
54 return false;
55 }
56
57 TableModel::Groups TableModel::GetGroups() {
58 // If you override HasGroups to return true, you must override this as
59 // well.
60 NOTREACHED();
61 return std::vector<Group>();
62 }
63
64 int TableModel::GetGroupID(int row) {
65 // If you override HasGroups to return true, you must override this as
66 // well.
67 NOTREACHED();
68 return 0;
69 }
70
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();
77
78 if (collator)
79 return base::i18n::CompareString16WithCollator(collator, value1, value2);
80
81 NOTREACHED();
82 return 0;
83 }
84
85 void TableModel::ClearCollator() {
86 delete collator;
87 collator = NULL;
88 }
89
90 icu::Collator* TableModel::GetCollator() {
91 if (!collator) {
92 UErrorCode create_status = U_ZERO_ERROR;
93 collator = icu::Collator::createInstance(create_status);
94 if (!U_SUCCESS(create_status)) {
95 collator = NULL;
96 NOTREACHED();
97 }
98 }
99 return collator;
100 }
101
102 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/models/table_model.h ('k') | ui/base/models/table_model_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698