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

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

Issue 9187027: Attempt 2 at: Adds a trivial views based table implementation (only supports single (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
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_GROUP_TABLE_VIEW_VIEWS_H_ 5 #ifndef UI_VIEWS_CONTROLS_TABLE_GROUP_TABLE_VIEW_VIEWS_H_
6 #define UI_VIEWS_CONTROLS_TABLE_GROUP_TABLE_VIEW_VIEWS_H_ 6 #define UI_VIEWS_CONTROLS_TABLE_GROUP_TABLE_VIEW_VIEWS_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/weak_ptr.h"
10 #include "ui/base/models/table_model.h"
11 #include "ui/views/controls/table/table_view.h" 9 #include "ui/views/controls/table/table_view.h"
12 10
13 namespace views { 11 namespace views {
14 12
15 class GroupTableModel; 13 class GroupTableModel;
16 14
17 // GroupTableView adds grouping to the TableView class. 15 // GroupTableView adds grouping to the TableView class.
18 // It allows to have groups of rows that act as a single row from the selection 16 // It allows to have groups of rows that act as a single row from the selection
19 // perspective. Groups are visually separated by a horizontal line. 17 // perspective. Groups are visually separated by a horizontal line.
20 class VIEWS_EXPORT GroupTableView : public TableView { 18 class VIEWS_EXPORT GroupTableView : public TableView {
21 public: 19 public:
22 // The view class name. 20 // The view class name.
23 static const char kViewClassName[]; 21 static const char kViewClassName[];
24 22
25 GroupTableView(GroupTableModel* model, 23 GroupTableView(GroupTableModel* model,
26 const std::vector<ui::TableColumn>& columns, 24 const std::vector<ui::TableColumn>& columns,
27 TableTypes table_type, bool single_selection, 25 TableTypes table_type, bool single_selection,
28 bool resizable_columns, bool autosize_columns, 26 bool resizable_columns, bool autosize_columns,
29 bool draw_group_separators); 27 bool draw_group_separators);
30 virtual ~GroupTableView(); 28 virtual ~GroupTableView();
31 29
32 virtual std::string GetClassName() const; 30 virtual std::string GetClassName() const OVERRIDE;
33
34 protected:
35 // Notification from the ListView that the selected state of an item has
36 // changed.
37 void OnSelectedStateChanged();
38
39 // Extra-painting required to draw the separator line between groups.
40 virtual bool ImplementPostPaint() { return true; }
41 virtual void PostPaint(int model_row, int column, bool selected,
42 const gfx::Rect& bounds, HDC device_context);
43
44 // In order to make keyboard navigation possible (using the Up and Down
45 // keys), we must take action when an arrow key is pressed. The reason we
46 // need to process this message has to do with the manner in which the focus
47 // needs to be set on a group item when a group is selected.
48 virtual bool OnKeyDown(ui::KeyboardCode virtual_keycode);
49
50 // Overriden to make sure rows in the same group stay grouped together.
51 virtual int CompareRows(int model_row1, int model_row2);
52
53 // Updates model_index_to_range_start_map_ from the model.
54 virtual void PrepareForSort();
55
56 private:
57 // Make the selection of group consistent.
58 void SyncSelection();
59
60 GroupTableModel* model_;
61
62 // If true, draw separators between groups.
63 bool draw_group_separators_;
64
65 // A factory to make the selection consistent among groups.
66 base::WeakPtrFactory<GroupTableView> sync_selection_factory_;
67
68 // Maps from model row to start of group.
69 std::map<int,int> model_index_to_range_start_map_;
70 31
71 DISALLOW_COPY_AND_ASSIGN(GroupTableView); 32 DISALLOW_COPY_AND_ASSIGN(GroupTableView);
72 }; 33 };
73 34
74 } // namespace views 35 } // namespace views
75 36
76 #endif // UI_VIEWS_CONTROLS_TABLE_GROUP_TABLE_VIEW_VIEWS_H_ 37 #endif // UI_VIEWS_CONTROLS_TABLE_GROUP_TABLE_VIEW_VIEWS_H_
OLDNEW
« no previous file with comments | « ui/views/controls/table/group_table_view.h ('k') | ui/views/controls/table/group_table_view_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698