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

Side by Side Diff: ui/views/controls/table/table_view.h

Issue 2146033003: TableView: 3-phase ToggleSortOrder (sorted/reversed/unsorted) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bug. Created 4 years, 5 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
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 #ifndef UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_ 5 #ifndef UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_
6 #define UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_ 6 #define UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 TableViewObserver* observer() const { return table_view_observer_; } 148 TableViewObserver* observer() const { return table_view_observer_; }
149 149
150 const std::vector<VisibleColumn>& visible_columns() const { 150 const std::vector<VisibleColumn>& visible_columns() const {
151 return visible_columns_; 151 return visible_columns_;
152 } 152 }
153 153
154 // Sets the width of the column. |index| is in terms of |visible_columns_|. 154 // Sets the width of the column. |index| is in terms of |visible_columns_|.
155 void SetVisibleColumnWidth(int index, int width); 155 void SetVisibleColumnWidth(int index, int width);
156 156
157 // Toggles the sort order of the specified visible column index. 157 // Modify the table sort order, depending on a clicked column and the previous
158 // table sort order. Does nothing if this column is not sortable.
159 //
160 // When called repeatedly on the same sortable column, the sort order will
161 // cycle through three states in order: sorted -> reverse-sorted -> unsorted.
162 // When switching from one sort column to another, the previous sort column
163 // will be remembered and used as a secondary sort key.
158 void ToggleSortOrder(int visible_column_index); 164 void ToggleSortOrder(int visible_column_index);
159 165
160 const SortDescriptors& sort_descriptors() const { return sort_descriptors_; } 166 const SortDescriptors& sort_descriptors() const { return sort_descriptors_; }
167 void SetSortDescriptors(SortDescriptors descriptors);
sky 2016/07/18 16:18:58 nit: const SortDescriptors& . I realize what you h
ncarter (slow) 2016/07/25 20:04:01 Done.
161 bool is_sorted() const { return !sort_descriptors_.empty(); } 168 bool is_sorted() const { return !sort_descriptors_.empty(); }
162 169
163 // Maps from the index in terms of the model to that of the view. 170 // Maps from the index in terms of the model to that of the view.
164 int ModelToView(int model_index) const; 171 int ModelToView(int model_index) const;
165 172
166 // Maps from the index in terms of the view to that of the model. 173 // Maps from the index in terms of the view to that of the model.
167 int ViewToModel(int view_index) const; 174 int ViewToModel(int view_index) const;
168 175
169 int row_height() const { return row_height_; } 176 int row_height() const { return row_height_; }
170 177
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Used by AdvanceSelection() to determine the direction to change the 227 // Used by AdvanceSelection() to determine the direction to change the
221 // selection. 228 // selection.
222 enum AdvanceDirection { 229 enum AdvanceDirection {
223 ADVANCE_DECREMENT, 230 ADVANCE_DECREMENT,
224 ADVANCE_INCREMENT, 231 ADVANCE_INCREMENT,
225 }; 232 };
226 233
227 // Invoked when the number of rows changes in some way. 234 // Invoked when the number of rows changes in some way.
228 void NumRowsChanged(); 235 void NumRowsChanged();
229 236
230 // Resets the sort descriptions.
231 void SetSortDescriptors(const SortDescriptors& sort_descriptors);
sky 2016/07/18 16:18:58 Move implementation to match new location.
ncarter (slow) 2016/07/25 20:04:01 Done.
232
233 // Does the actual sort and updates the mappings (|view_to_model_| and 237 // Does the actual sort and updates the mappings (|view_to_model_| and
234 // |model_to_view_|) appropriately. 238 // |model_to_view_|) appropriately.
235 void SortItemsAndUpdateMapping(); 239 void SortItemsAndUpdateMapping();
236 240
237 // Used to sort the two rows. Returns a value < 0, == 0 or > 0 indicating 241 // Used to sort the two rows. Returns a value < 0, == 0 or > 0 indicating
238 // whether the row2 comes before row1, row2 is the same as row1 or row1 comes 242 // whether the row2 comes before row1, row2 is the same as row1 or row1 comes
239 // after row2. This invokes CompareValues on the model with the sorted column. 243 // after row2. This invokes CompareValues on the model with the sorted column.
240 int CompareRows(int model_row1, int model_row2); 244 int CompareRows(int model_row1, int model_row2);
241 245
242 // Returns the bounds of the specified row. 246 // Returns the bounds of the specified row.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 361
358 // True if in SetVisibleColumnWidth(). 362 // True if in SetVisibleColumnWidth().
359 bool in_set_visible_column_width_; 363 bool in_set_visible_column_width_;
360 364
361 DISALLOW_COPY_AND_ASSIGN(TableView); 365 DISALLOW_COPY_AND_ASSIGN(TableView);
362 }; 366 };
363 367
364 } // namespace views 368 } // namespace views
365 369
366 #endif // UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_ 370 #endif // UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698