1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 16:55:09 +00:00

LibGUI: Reduce header dependencies of ComboBox

This commit is contained in:
Andreas Kling 2020-02-23 10:42:43 +01:00
parent 45c25ffecd
commit 00bf68adc6
3 changed files with 28 additions and 8 deletions

View file

@ -30,7 +30,7 @@
#include <LibGUI/ListView.h>
#include <LibGUI/Model.h>
#include <LibGUI/ScrollBar.h>
#include <LibGUI/TextEditor.h>
#include <LibGUI/TextBox.h>
#include <LibGUI/Window.h>
namespace GUI {
@ -38,7 +38,7 @@ namespace GUI {
ComboBox::ComboBox(Widget* parent)
: Widget(parent)
{
m_editor = TextEditor::construct(TextEditor::Type::SingleLine, this);
m_editor = add<TextBox>();
m_editor->on_change = [this] {
if (on_change)
on_change(m_editor->text(), m_list_view->selection().first());
@ -150,4 +150,24 @@ void ComboBox::set_only_allow_values_from_model(bool b)
m_editor->set_readonly(m_only_allow_values_from_model);
}
Model* ComboBox::model()
{
return m_list_view->model();
}
const Model* ComboBox::model() const
{
return m_list_view->model();
}
int ComboBox::model_column() const
{
return m_list_view->model_column();
}
void ComboBox::set_model_column(int column)
{
m_list_view->set_model_column(column);
}
}