diff options
author | Andreas Kling <kling@serenityos.org> | 2020-08-13 16:07:58 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-13 20:18:11 +0200 |
commit | 4088beb8eb6b1879bd1e0291d356cdf82eaa1d8c (patch) | |
tree | 23b9957e4fc20fcfd65ae1ba2dd7d3c72fe8ab80 /Libraries/LibGUI | |
parent | fe19cf0ff2b04b5f442706a96aa6974488c9cd6c (diff) | |
download | serenity-4088beb8eb6b1879bd1e0291d356cdf82eaa1d8c.zip |
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().
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r-- | Libraries/LibGUI/ColumnsView.cpp | 4 | ||||
-rw-r--r-- | Libraries/LibGUI/Model.cpp | 10 | ||||
-rw-r--r-- | Libraries/LibGUI/Model.h | 1 | ||||
-rw-r--r-- | Libraries/LibGUI/TreeView.cpp | 2 |
4 files changed, 3 insertions, 14 deletions
diff --git a/Libraries/LibGUI/ColumnsView.cpp b/Libraries/LibGUI/ColumnsView.cpp index 29a2ca9117..ffc1e63cbf 100644 --- a/Libraries/LibGUI/ColumnsView.cpp +++ b/Libraries/LibGUI/ColumnsView.cpp @@ -289,7 +289,7 @@ void ColumnsView::keydown_event(KeyEvent& event) auto old_index = selection().first(); auto parent_index = model.parent_index(old_index); 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 { new_index = model.index(0, m_model_column, {}); } @@ -306,7 +306,7 @@ void ColumnsView::keydown_event(KeyEvent& event) auto old_index = selection().first(); auto parent_index = model.parent_index(old_index); 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 { new_index = model.index(0, m_model_column, {}); } diff --git a/Libraries/LibGUI/Model.cpp b/Libraries/LibGUI/Model.cpp index 6ed496e551..a47e462521 100644 --- a/Libraries/LibGUI/Model.cpp +++ b/Libraries/LibGUI/Model.cpp @@ -73,16 +73,6 @@ ModelIndex Model::index(int row, int column, const ModelIndex&) const 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&) { return false; diff --git a/Libraries/LibGUI/Model.h b/Libraries/LibGUI/Model.h index c9404dc46a..0d647e32e7 100644 --- a/Libraries/LibGUI/Model.h +++ b/Libraries/LibGUI/Model.h @@ -81,7 +81,6 @@ public: virtual void update() = 0; virtual ModelIndex parent_index(const ModelIndex&) const { return {}; } 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 void set_data(const ModelIndex&, const Variant&) { } virtual int tree_column() const { return 0; } diff --git a/Libraries/LibGUI/TreeView.cpp b/Libraries/LibGUI/TreeView.cpp index 8411332c73..63f23156db 100644 --- a/Libraries/LibGUI/TreeView.cpp +++ b/Libraries/LibGUI/TreeView.cpp @@ -288,7 +288,7 @@ void TreeView::paint_event(PaintEvent& event) if (column_index != tree_column) { 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()) { delegate->paint(painter, cell_rect, palette(), model, cell_index); |