mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 14:55:07 +00:00
LibGUI: Remove Model::sibling() since it's the same as index()
... I'm not sure what the idea was here, but since these functions do the same thing, let's only have index().
This commit is contained in:
parent
fe19cf0ff2
commit
4088beb8eb
5 changed files with 4 additions and 15 deletions
|
@ -325,7 +325,7 @@ void DirectoryView::update_statusbar()
|
||||||
|
|
||||||
current_view().selection().for_each_index([&](auto& index) {
|
current_view().selection().for_each_index([&](auto& index) {
|
||||||
auto& model = *current_view().model();
|
auto& model = *current_view().model();
|
||||||
auto size_index = model.sibling(index.row(), GUI::FileSystemModel::Column::Size, model.parent_index(index));
|
auto size_index = model.index(index.row(), GUI::FileSystemModel::Column::Size, model.parent_index(index));
|
||||||
auto file_size = model.data(size_index).to_i32();
|
auto file_size = model.data(size_index).to_i32();
|
||||||
selected_byte_count += file_size;
|
selected_byte_count += file_size;
|
||||||
});
|
});
|
||||||
|
|
|
@ -289,7 +289,7 @@ void ColumnsView::keydown_event(KeyEvent& event)
|
||||||
auto old_index = selection().first();
|
auto old_index = selection().first();
|
||||||
auto parent_index = model.parent_index(old_index);
|
auto parent_index = model.parent_index(old_index);
|
||||||
int row = old_index.row() > 0 ? old_index.row() - 1 : 0;
|
int row = old_index.row() > 0 ? old_index.row() - 1 : 0;
|
||||||
new_index = model.sibling(row, old_index.column(), parent_index);
|
new_index = model.index(row, old_index.column(), parent_index);
|
||||||
} else {
|
} else {
|
||||||
new_index = model.index(0, m_model_column, {});
|
new_index = model.index(0, m_model_column, {});
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ void ColumnsView::keydown_event(KeyEvent& event)
|
||||||
auto old_index = selection().first();
|
auto old_index = selection().first();
|
||||||
auto parent_index = model.parent_index(old_index);
|
auto parent_index = model.parent_index(old_index);
|
||||||
int row = old_index.row() + 1;
|
int row = old_index.row() + 1;
|
||||||
new_index = model.sibling(row, old_index.column(), parent_index);
|
new_index = model.index(row, old_index.column(), parent_index);
|
||||||
} else {
|
} else {
|
||||||
new_index = model.index(0, m_model_column, {});
|
new_index = model.index(0, m_model_column, {});
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,16 +73,6 @@ ModelIndex Model::index(int row, int column, const ModelIndex&) const
|
||||||
return create_index(row, column);
|
return create_index(row, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelIndex Model::sibling(int row, int column, const ModelIndex& parent) const
|
|
||||||
{
|
|
||||||
if (!parent.is_valid())
|
|
||||||
return index(row, column, {});
|
|
||||||
int row_count = this->row_count(parent);
|
|
||||||
if (row < 0 || row > row_count)
|
|
||||||
return {};
|
|
||||||
return index(row, column, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Model::accepts_drag(const ModelIndex&, const StringView&)
|
bool Model::accepts_drag(const ModelIndex&, const StringView&)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -81,7 +81,6 @@ public:
|
||||||
virtual void update() = 0;
|
virtual void update() = 0;
|
||||||
virtual ModelIndex parent_index(const ModelIndex&) const { return {}; }
|
virtual ModelIndex parent_index(const ModelIndex&) const { return {}; }
|
||||||
virtual ModelIndex index(int row, int column = 0, const ModelIndex& parent = ModelIndex()) const;
|
virtual ModelIndex index(int row, int column = 0, const ModelIndex& parent = ModelIndex()) const;
|
||||||
virtual ModelIndex sibling(int row, int column, const ModelIndex& parent) const;
|
|
||||||
virtual bool is_editable(const ModelIndex&) const { return false; }
|
virtual bool is_editable(const ModelIndex&) const { return false; }
|
||||||
virtual void set_data(const ModelIndex&, const Variant&) { }
|
virtual void set_data(const ModelIndex&, const Variant&) { }
|
||||||
virtual int tree_column() const { return 0; }
|
virtual int tree_column() const { return 0; }
|
||||||
|
|
|
@ -288,7 +288,7 @@ void TreeView::paint_event(PaintEvent& event)
|
||||||
|
|
||||||
if (column_index != tree_column) {
|
if (column_index != tree_column) {
|
||||||
Gfx::IntRect cell_rect(horizontal_padding() + x_offset, rect.y(), column_width, item_height());
|
Gfx::IntRect cell_rect(horizontal_padding() + x_offset, rect.y(), column_width, item_height());
|
||||||
auto cell_index = model.sibling(index.row(), column_index, index.parent());
|
auto cell_index = model.index(index.row(), column_index, index.parent());
|
||||||
|
|
||||||
if (auto* delegate = column_data(column_index).cell_painting_delegate.ptr()) {
|
if (auto* delegate = column_data(column_index).cell_painting_delegate.ptr()) {
|
||||||
delegate->paint(painter, cell_rect, palette(), model, cell_index);
|
delegate->paint(painter, cell_rect, palette(), model, cell_index);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue