summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-07 21:38:13 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-07 21:39:44 +0200
commit2f5b2685aff4fc32de4fdeb3c5347102a27156d0 (patch)
treee85de034f2095c90f044ddab109dc7503ec4edcb
parent6dec328af7e2e712c49d2f073dadd3e86a422bd8 (diff)
downloadserenity-2f5b2685aff4fc32de4fdeb3c5347102a27156d0.zip
GModel: Remove selected_index() and set_selected_index()
This breaks GSortingProxyModel selection preservation across resorts. I'm not yet sure how we're going to solve that, but it's going to have to work a bit differently than before, since the model itself no longer knows what's selected. Selection is now managed by GModelSelection which allows us to select any arbitrary number of items, and to have different selections in different views onto the same model. Pretty sweet. :^)
-rw-r--r--Libraries/LibGUI/GModel.cpp12
-rw-r--r--Libraries/LibGUI/GModel.h4
-rw-r--r--Libraries/LibGUI/GSortingProxyModel.cpp12
3 files changed, 0 insertions, 28 deletions
diff --git a/Libraries/LibGUI/GModel.cpp b/Libraries/LibGUI/GModel.cpp
index e6cbc03af9..d1c4e94d35 100644
--- a/Libraries/LibGUI/GModel.cpp
+++ b/Libraries/LibGUI/GModel.cpp
@@ -34,18 +34,6 @@ void GModel::did_update()
});
}
-void GModel::set_selected_index(const GModelIndex& index)
-{
- if (m_selected_index == index)
- return;
- m_selected_index = index;
- if (on_selection_changed)
- on_selection_changed(index);
- for_each_view([](auto& view) {
- view.did_update_selection();
- });
-}
-
GModelIndex GModel::create_index(int row, int column, const void* data) const
{
return GModelIndex(*this, row, column, const_cast<void*>(data));
diff --git a/Libraries/LibGUI/GModel.h b/Libraries/LibGUI/GModel.h
index 8824f42a0e..05ab64a83c 100644
--- a/Libraries/LibGUI/GModel.h
+++ b/Libraries/LibGUI/GModel.h
@@ -57,9 +57,6 @@ public:
return index.row() >= 0 && index.row() < row_count() && index.column() >= 0 && index.column() < column_count();
}
- void set_selected_index(const GModelIndex&);
- GModelIndex selected_index() const { return m_selected_index; }
-
virtual int key_column() const { return -1; }
virtual GSortOrder sort_order() const { return GSortOrder::None; }
virtual void set_key_column_and_sort_order(int, GSortOrder) {}
@@ -80,7 +77,6 @@ protected:
private:
HashTable<GAbstractView*> m_views;
- GModelIndex m_selected_index;
};
inline GModelIndex GModelIndex::parent() const
diff --git a/Libraries/LibGUI/GSortingProxyModel.cpp b/Libraries/LibGUI/GSortingProxyModel.cpp
index 17859a4c2b..3205123408 100644
--- a/Libraries/LibGUI/GSortingProxyModel.cpp
+++ b/Libraries/LibGUI/GSortingProxyModel.cpp
@@ -73,7 +73,6 @@ void GSortingProxyModel::set_key_column_and_sort_order(int column, GSortOrder so
void GSortingProxyModel::resort()
{
- int previously_selected_target_row = map_to_target(selected_index()).row();
int row_count = target().row_count();
m_row_mappings.resize(row_count);
for (int i = 0; i < row_count; ++i)
@@ -94,16 +93,5 @@ void GSortingProxyModel::resort()
is_less_than = data1 < data2;
return m_sort_order == GSortOrder::Ascending ? is_less_than : !is_less_than;
});
- if (previously_selected_target_row != -1) {
- // Preserve selection.
- ASSERT(m_row_mappings.size() == row_count);
- for (int i = 0; i < row_count; ++i) {
- if (m_row_mappings[i] == previously_selected_target_row) {
- set_selected_index(index(i, 0));
- break;
- }
- }
- }
-
did_update();
}