瀏覽代碼

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 年之前
父節點
當前提交
ffff150435
共有 2 個文件被更改,包括 6 次插入0 次删除
  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;