Browse Source

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.
Andreas Kling 6 years ago
parent
commit
ffff150435
2 changed files with 6 additions and 0 deletions
  1. 3 0
      Libraries/LibGUI/GComboBox.h
  2. 3 0
      Libraries/LibGUI/GListView.h

+ 3 - 0
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;
 

+ 3 - 0
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;