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 #include "ui/views/controls/table/table_view.h" | 5 #include "ui/views/controls/table/table_view.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <algorithm> |
9 #include <map> | 10 #include <map> |
10 #include <utility> | 11 #include <utility> |
11 | 12 |
12 #include "base/auto_reset.h" | 13 #include "base/auto_reset.h" |
13 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #include "ui/accessibility/ax_view_state.h" | 17 #include "ui/accessibility/ax_view_state.h" |
17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
18 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 } else { | 654 } else { |
654 const int row_count = RowCount(); | 655 const int row_count = RowCount(); |
655 view_to_model_.resize(row_count); | 656 view_to_model_.resize(row_count); |
656 model_to_view_.resize(row_count); | 657 model_to_view_.resize(row_count); |
657 for (int i = 0; i < row_count; ++i) | 658 for (int i = 0; i < row_count; ++i) |
658 view_to_model_[i] = i; | 659 view_to_model_[i] = i; |
659 if (grouper_) { | 660 if (grouper_) { |
660 GroupSortHelper sort_helper(this); | 661 GroupSortHelper sort_helper(this); |
661 GetModelIndexToRangeStart(grouper_, RowCount(), | 662 GetModelIndexToRangeStart(grouper_, RowCount(), |
662 &sort_helper.model_index_to_range_start); | 663 &sort_helper.model_index_to_range_start); |
663 std::sort(view_to_model_.begin(), view_to_model_.end(), sort_helper); | 664 std::stable_sort(view_to_model_.begin(), view_to_model_.end(), |
| 665 sort_helper); |
664 } else { | 666 } else { |
665 std::sort(view_to_model_.begin(), view_to_model_.end(), SortHelper(this)); | 667 std::stable_sort(view_to_model_.begin(), view_to_model_.end(), |
| 668 SortHelper(this)); |
666 } | 669 } |
667 for (int i = 0; i < row_count; ++i) | 670 for (int i = 0; i < row_count; ++i) |
668 model_to_view_[view_to_model_[i]] = i; | 671 model_to_view_[view_to_model_[i]] = i; |
669 model_->ClearCollator(); | 672 model_->ClearCollator(); |
670 } | 673 } |
671 SchedulePaint(); | 674 SchedulePaint(); |
672 } | 675 } |
673 | 676 |
674 int TableView::CompareRows(int model_row1, int model_row2) { | 677 int TableView::CompareRows(int model_row1, int model_row2) { |
675 const int sort_result = model_->CompareValues( | 678 const int sort_result = model_->CompareValues( |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 if (tooltip) | 952 if (tooltip) |
950 *tooltip = text; | 953 *tooltip = text; |
951 if (tooltip_origin) { | 954 if (tooltip_origin) { |
952 tooltip_origin->SetPoint(cell_bounds.x(), | 955 tooltip_origin->SetPoint(cell_bounds.x(), |
953 cell_bounds.y() + kTextVerticalPadding); | 956 cell_bounds.y() + kTextVerticalPadding); |
954 } | 957 } |
955 return true; | 958 return true; |
956 } | 959 } |
957 | 960 |
958 } // namespace views | 961 } // namespace views |
OLD | NEW |