mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibGUI: Reduce header dependencies of ComboBox
This commit is contained in:
parent
45c25ffecd
commit
00bf68adc6
Notes:
sideshowbarker
2024-07-19 09:08:52 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/00bf68adc62
3 changed files with 28 additions and 8 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibGUI/ListView.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
||||
namespace GUI {
|
||||
|
@ -43,15 +42,15 @@ public:
|
|||
void close();
|
||||
void select_all();
|
||||
|
||||
Model* model() { return m_list_view->model(); }
|
||||
const Model* model() const { return m_list_view->model(); }
|
||||
Model* model();
|
||||
const Model* model() const;
|
||||
void set_model(NonnullRefPtr<Model>);
|
||||
|
||||
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); }
|
||||
int model_column() const;
|
||||
void set_model_column(int);
|
||||
|
||||
Function<void(const String&, const ModelIndex&)> on_change;
|
||||
Function<void()> on_return_pressed;
|
||||
|
@ -61,7 +60,7 @@ protected:
|
|||
virtual void resize_event(ResizeEvent&) override;
|
||||
|
||||
private:
|
||||
RefPtr<TextEditor> m_editor;
|
||||
RefPtr<TextBox> m_editor;
|
||||
RefPtr<Button> m_open_button;
|
||||
RefPtr<Window> m_list_window;
|
||||
RefPtr<ListView> m_list_view;
|
||||
|
|
|
@ -45,6 +45,7 @@ class JsonArrayModel;
|
|||
class KeyEvent;
|
||||
class Label;
|
||||
class Layout;
|
||||
class ListView;
|
||||
class Menu;
|
||||
class MenuBar;
|
||||
class MenuItem;
|
||||
|
|
Loading…
Add table
Reference in a new issue