mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:08:11 +00:00
LibGUI: Reduce header dependencies of ComboBox
This commit is contained in:
parent
45c25ffecd
commit
00bf68adc6
3 changed files with 28 additions and 8 deletions
|
@ -30,7 +30,7 @@
|
||||||
#include <LibGUI/ListView.h>
|
#include <LibGUI/ListView.h>
|
||||||
#include <LibGUI/Model.h>
|
#include <LibGUI/Model.h>
|
||||||
#include <LibGUI/ScrollBar.h>
|
#include <LibGUI/ScrollBar.h>
|
||||||
#include <LibGUI/TextEditor.h>
|
#include <LibGUI/TextBox.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
@ -38,7 +38,7 @@ namespace GUI {
|
||||||
ComboBox::ComboBox(Widget* parent)
|
ComboBox::ComboBox(Widget* parent)
|
||||||
: Widget(parent)
|
: Widget(parent)
|
||||||
{
|
{
|
||||||
m_editor = TextEditor::construct(TextEditor::Type::SingleLine, this);
|
m_editor = add<TextBox>();
|
||||||
m_editor->on_change = [this] {
|
m_editor->on_change = [this] {
|
||||||
if (on_change)
|
if (on_change)
|
||||||
on_change(m_editor->text(), m_list_view->selection().first());
|
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);
|
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
|
#pragma once
|
||||||
|
|
||||||
#include <LibGUI/ListView.h>
|
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
@ -43,15 +42,15 @@ public:
|
||||||
void close();
|
void close();
|
||||||
void select_all();
|
void select_all();
|
||||||
|
|
||||||
Model* model() { return m_list_view->model(); }
|
Model* model();
|
||||||
const Model* model() const { return m_list_view->model(); }
|
const Model* model() const;
|
||||||
void set_model(NonnullRefPtr<Model>);
|
void set_model(NonnullRefPtr<Model>);
|
||||||
|
|
||||||
bool only_allow_values_from_model() const { return m_only_allow_values_from_model; }
|
bool only_allow_values_from_model() const { return m_only_allow_values_from_model; }
|
||||||
void set_only_allow_values_from_model(bool);
|
void set_only_allow_values_from_model(bool);
|
||||||
|
|
||||||
int model_column() const { return m_list_view->model_column(); }
|
int model_column() const;
|
||||||
void set_model_column(int column) { m_list_view->set_model_column(column); }
|
void set_model_column(int);
|
||||||
|
|
||||||
Function<void(const String&, const ModelIndex&)> on_change;
|
Function<void(const String&, const ModelIndex&)> on_change;
|
||||||
Function<void()> on_return_pressed;
|
Function<void()> on_return_pressed;
|
||||||
|
@ -61,7 +60,7 @@ protected:
|
||||||
virtual void resize_event(ResizeEvent&) override;
|
virtual void resize_event(ResizeEvent&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<TextEditor> m_editor;
|
RefPtr<TextBox> m_editor;
|
||||||
RefPtr<Button> m_open_button;
|
RefPtr<Button> m_open_button;
|
||||||
RefPtr<Window> m_list_window;
|
RefPtr<Window> m_list_window;
|
||||||
RefPtr<ListView> m_list_view;
|
RefPtr<ListView> m_list_view;
|
||||||
|
|
|
@ -45,6 +45,7 @@ class JsonArrayModel;
|
||||||
class KeyEvent;
|
class KeyEvent;
|
||||||
class Label;
|
class Label;
|
||||||
class Layout;
|
class Layout;
|
||||||
|
class ListView;
|
||||||
class Menu;
|
class Menu;
|
||||||
class MenuBar;
|
class MenuBar;
|
||||||
class MenuItem;
|
class MenuItem;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue