diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-08-05 18:32:04 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-05 18:32:04 +0200 |
commit | ffff150435da4bb39b557042dd54ef02a043f40d (patch) | |
tree | 4c5893617257cbf9a9f36e9c9ba36060f2f3a7fd | |
parent | 7c0f9ea2b9711c20ce5f16b4a6b26efc46d48a69 (diff) | |
download | serenity-ffff150435da4bb39b557042dd54ef02a043f40d.zip |
LibGUI: Allow specifying the model column for GListView and GComboBox
These widgets can only display a single column from the underlying data
model, and it was previously hard-coded to use column 0. Now you can
use any column you like.
-rw-r--r-- | Libraries/LibGUI/GComboBox.h | 3 | ||||
-rw-r--r-- | Libraries/LibGUI/GListView.h | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/Libraries/LibGUI/GComboBox.h b/Libraries/LibGUI/GComboBox.h index 017e538107..b243b0b8c9 100644 --- a/Libraries/LibGUI/GComboBox.h +++ b/Libraries/LibGUI/GComboBox.h @@ -26,6 +26,9 @@ public: bool only_allow_values_from_model() const { return m_only_allow_values_from_model; } void set_only_allow_values_from_model(bool); + int model_column() const { return m_list_view->model_column(); } + void set_model_column(int column) { m_list_view->set_model_column(column); } + Function<void(const String&)> on_change; Function<void()> on_return_pressed; diff --git a/Libraries/LibGUI/GListView.h b/Libraries/LibGUI/GListView.h index 1298ad4ec5..488cf319aa 100644 --- a/Libraries/LibGUI/GListView.h +++ b/Libraries/LibGUI/GListView.h @@ -27,6 +27,9 @@ public: virtual Rect content_rect(const GModelIndex&) const override; + int model_column() const { return m_model_column; } + void set_model_column(int column) { m_model_column = column; } + private: virtual void did_update_model() override; virtual void paint_event(GPaintEvent&) override; |