diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-05-11 00:16:34 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-11 00:16:34 +0200 |
commit | dd7406ce3fb6db638cc523c92aad344731ee1036 (patch) | |
tree | a5a24f06cb705e288217685f5a93b6a6239d5d8d /LibGUI/GTableView.cpp | |
parent | b54eefa25e07a4a8833e1331fc40c854cc3f489c (diff) | |
download | serenity-dd7406ce3fb6db638cc523c92aad344731ee1036.zip |
GTableView: Don't include hidden columns in content width.
Diffstat (limited to 'LibGUI/GTableView.cpp')
-rw-r--r-- | LibGUI/GTableView.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/LibGUI/GTableView.cpp b/LibGUI/GTableView.cpp index e6d1531139..bb2c49a552 100644 --- a/LibGUI/GTableView.cpp +++ b/LibGUI/GTableView.cpp @@ -28,8 +28,10 @@ void GTableView::update_content_size() int content_width = 0; int column_count = model()->column_count(); - for (int i = 0; i < column_count; ++i) - content_width += column_width(i) + horizontal_padding() * 2; + for (int i = 0; i < column_count; ++i) { + if (!is_column_hidden(i)) + content_width += column_width(i) + horizontal_padding() * 2; + } int content_height = item_count() * item_height(); set_content_size({ content_width, content_height }); @@ -423,7 +425,8 @@ GMenu& GTableView::ensure_header_context_menu() for (int column = 0; column < model()->column_count(); ++column) { auto& column_data = this->column_data(column); - column_data.visibility_action = GAction::create(model()->column_name(column), [this, column] (GAction& action) { + auto name = model()->column_name(column); + column_data.visibility_action = GAction::create(name, [this, column] (GAction& action) { action.set_checked(!action.is_checked()); set_column_hidden(column, !action.is_checked()); }); |