mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
LibGUI: Get rid of Model::ColumnMetadata and always use auto-sizing
Auto-sizing of view columns is now enabled by default. This removes the last remaining need for ColumnMetadata, so this patch gets rid of it.
This commit is contained in:
parent
c666c251c8
commit
2adb0a07e5
38 changed files with 1 additions and 216 deletions
|
@ -59,9 +59,6 @@ void AbstractTableView::select_all()
|
|||
|
||||
void AbstractTableView::update_column_sizes()
|
||||
{
|
||||
if (!m_size_columns_to_fit_content)
|
||||
return;
|
||||
|
||||
if (!model())
|
||||
return;
|
||||
|
||||
|
@ -249,13 +246,7 @@ int AbstractTableView::column_width(int column_index) const
|
|||
{
|
||||
if (!model())
|
||||
return 0;
|
||||
auto& column_data = this->column_data(column_index);
|
||||
if (!column_data.has_initialized_width) {
|
||||
ASSERT(!m_size_columns_to_fit_content);
|
||||
column_data.has_initialized_width = true;
|
||||
column_data.width = model()->column_metadata(column_index).preferred_width;
|
||||
}
|
||||
return column_data.width;
|
||||
return column_data(column_index).width;
|
||||
}
|
||||
|
||||
void AbstractTableView::mousemove_event(MouseEvent& event)
|
||||
|
|
|
@ -52,9 +52,6 @@ public:
|
|||
bool is_column_hidden(int) const;
|
||||
void set_column_hidden(int, bool);
|
||||
|
||||
void set_size_columns_to_fit_content(bool b) { m_size_columns_to_fit_content = b; }
|
||||
bool size_columns_to_fit_content() const { return m_size_columns_to_fit_content; }
|
||||
|
||||
void set_cell_painting_delegate(int column, OwnPtr<TableCellPaintingDelegate>&&);
|
||||
|
||||
int horizontal_padding() const { return m_horizontal_padding; }
|
||||
|
@ -117,7 +114,6 @@ protected:
|
|||
|
||||
private:
|
||||
bool m_headers_visible { true };
|
||||
bool m_size_columns_to_fit_content { false };
|
||||
bool m_in_column_resize { false };
|
||||
bool m_alternating_row_colors { true };
|
||||
int m_horizontal_padding { 5 };
|
||||
|
|
|
@ -568,31 +568,6 @@ String FileSystemModel::column_name(int column) const
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
Model::ColumnMetadata FileSystemModel::column_metadata(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Icon:
|
||||
return { 16 };
|
||||
case Column::Name:
|
||||
return { 120 };
|
||||
case Column::Size:
|
||||
return { 80 };
|
||||
case Column::Owner:
|
||||
return { 50 };
|
||||
case Column::Group:
|
||||
return { 50 };
|
||||
case Column::ModificationTime:
|
||||
return { 110 };
|
||||
case Column::Permissions:
|
||||
return { 65 };
|
||||
case Column::Inode:
|
||||
return { 60 };
|
||||
case Column::SymlinkTarget:
|
||||
return { 120 };
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
bool FileSystemModel::accepts_drag(const ModelIndex& index, const StringView& data_type)
|
||||
{
|
||||
if (!index.is_valid())
|
||||
|
|
|
@ -141,7 +141,6 @@ public:
|
|||
virtual int row_count(const ModelIndex& = ModelIndex()) const override;
|
||||
virtual int column_count(const ModelIndex& = ModelIndex()) const override;
|
||||
virtual String column_name(int column) const override;
|
||||
virtual ColumnMetadata column_metadata(int column) const override;
|
||||
virtual Variant data(const ModelIndex&, Role = Role::Display) const override;
|
||||
virtual void update() override;
|
||||
virtual ModelIndex parent_index(const ModelIndex&) const override;
|
||||
|
|
|
@ -91,12 +91,6 @@ bool JsonArrayModel::remove(int row)
|
|||
return true;
|
||||
}
|
||||
|
||||
Model::ColumnMetadata JsonArrayModel::column_metadata(int column) const
|
||||
{
|
||||
ASSERT(column < static_cast<int>(m_fields.size()));
|
||||
return { 100 };
|
||||
}
|
||||
|
||||
Variant JsonArrayModel::data(const ModelIndex& index, Role role) const
|
||||
{
|
||||
auto& field_spec = m_fields[index.column()];
|
||||
|
|
|
@ -69,7 +69,6 @@ public:
|
|||
virtual int row_count(const ModelIndex& = ModelIndex()) const override { return m_array.size(); }
|
||||
virtual int column_count(const ModelIndex& = ModelIndex()) const override { return m_fields.size(); }
|
||||
virtual String column_name(int column) const override { return m_fields[column].column_name; }
|
||||
virtual ColumnMetadata column_metadata(int) const override;
|
||||
virtual Variant data(const ModelIndex&, Role = Role::Display) const override;
|
||||
virtual void update() override;
|
||||
|
||||
|
|
|
@ -46,10 +46,6 @@ enum class SortOrder {
|
|||
|
||||
class Model : public RefCounted<Model> {
|
||||
public:
|
||||
struct ColumnMetadata {
|
||||
int preferred_width { 0 };
|
||||
};
|
||||
|
||||
enum UpdateFlag {
|
||||
DontInvalidateIndexes = 0,
|
||||
InvalidateAllIndexes = 1 << 0,
|
||||
|
@ -73,7 +69,6 @@ public:
|
|||
virtual int column_count(const ModelIndex& = ModelIndex()) const = 0;
|
||||
virtual String row_name(int) const { return {}; }
|
||||
virtual String column_name(int) const { return {}; }
|
||||
virtual ColumnMetadata column_metadata(int) const { return {}; }
|
||||
virtual Variant data(const ModelIndex&, Role = Role::Display) const = 0;
|
||||
virtual void update() = 0;
|
||||
virtual ModelIndex parent_index(const ModelIndex&) const { return {}; }
|
||||
|
|
|
@ -74,11 +74,6 @@ String SortingProxyModel::column_name(int index) const
|
|||
return target().column_name(index);
|
||||
}
|
||||
|
||||
Model::ColumnMetadata SortingProxyModel::column_metadata(int index) const
|
||||
{
|
||||
return target().column_metadata(index);
|
||||
}
|
||||
|
||||
Variant SortingProxyModel::data(const ModelIndex& index, Role role) const
|
||||
{
|
||||
auto target_index = map_to_target(index);
|
||||
|
|
|
@ -39,7 +39,6 @@ public:
|
|||
virtual int column_count(const ModelIndex& = ModelIndex()) const override;
|
||||
virtual String row_name(int) const override;
|
||||
virtual String column_name(int) const override;
|
||||
virtual ColumnMetadata column_metadata(int) const override;
|
||||
virtual Variant data(const ModelIndex&, Role = Role::Display) const override;
|
||||
virtual void update() override;
|
||||
virtual StringView drag_data_type() const override;
|
||||
|
|
|
@ -56,7 +56,6 @@ TreeView::TreeView()
|
|||
set_fill_with_background_color(true);
|
||||
set_background_role(ColorRole::Base);
|
||||
set_foreground_role(ColorRole::BaseText);
|
||||
set_size_columns_to_fit_content(true);
|
||||
set_headers_visible(false);
|
||||
m_expand_bitmap = Gfx::Bitmap::load_from_file("/res/icons/treeview-expand.png");
|
||||
m_collapse_bitmap = Gfx::Bitmap::load_from_file("/res/icons/treeview-collapse.png");
|
||||
|
@ -515,9 +514,6 @@ int TreeView::item_count() const
|
|||
|
||||
void TreeView::update_column_sizes()
|
||||
{
|
||||
if (!size_columns_to_fit_content())
|
||||
return;
|
||||
|
||||
if (!model())
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue