mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
LibGUI: Rename ModelClient::on_model_update() => model_did_update()
This follows the typical client callback naming scheme used elsewhere and doesn't collide with the "on_foo" Function hook convention.
This commit is contained in:
parent
4088beb8eb
commit
686ee2bf04
10 changed files with 30 additions and 17 deletions
|
@ -108,7 +108,7 @@ void BookmarksBarWidget::resize_event(GUI::ResizeEvent& event)
|
||||||
update_content_size();
|
update_content_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarksBarWidget::on_model_update(unsigned)
|
void BookmarksBarWidget::model_did_update(unsigned)
|
||||||
{
|
{
|
||||||
for (auto* child : child_widgets()) {
|
for (auto* child : child_widgets()) {
|
||||||
child->remove_from_parent();
|
child->remove_from_parent();
|
||||||
|
|
|
@ -32,9 +32,11 @@
|
||||||
|
|
||||||
namespace Browser {
|
namespace Browser {
|
||||||
|
|
||||||
class BookmarksBarWidget final : public GUI::Widget
|
class BookmarksBarWidget final
|
||||||
|
: public GUI::Widget
|
||||||
, private GUI::ModelClient {
|
, private GUI::ModelClient {
|
||||||
C_OBJECT(BookmarksBarWidget)
|
C_OBJECT(BookmarksBarWidget);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BookmarksBarWidget& the();
|
static BookmarksBarWidget& the();
|
||||||
|
|
||||||
|
@ -54,7 +56,10 @@ public:
|
||||||
private:
|
private:
|
||||||
BookmarksBarWidget(const String&, bool enabled);
|
BookmarksBarWidget(const String&, bool enabled);
|
||||||
|
|
||||||
virtual void on_model_update(unsigned) override;
|
// ^GUI::ModelClient
|
||||||
|
virtual void model_did_update(unsigned) override;
|
||||||
|
|
||||||
|
// ^GUI::Widget
|
||||||
virtual void resize_event(GUI::ResizeEvent&) override;
|
virtual void resize_event(GUI::ResizeEvent&) override;
|
||||||
|
|
||||||
void update_content_size();
|
void update_content_size();
|
||||||
|
|
|
@ -219,7 +219,7 @@ DirectoryView::~DirectoryView()
|
||||||
m_model->unregister_client(*this);
|
m_model->unregister_client(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirectoryView::on_model_update(unsigned flags)
|
void DirectoryView::model_did_update(unsigned flags)
|
||||||
{
|
{
|
||||||
if (flags & GUI::Model::UpdateFlag::InvalidateAllIndexes) {
|
if (flags & GUI::Model::UpdateFlag::InvalidateAllIndexes) {
|
||||||
for_each_view_implementation([](auto& view) {
|
for_each_view_implementation([](auto& view) {
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <LibGUI/TableView.h>
|
#include <LibGUI/TableView.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
class LauncherHandler: public RefCounted<LauncherHandler> {
|
class LauncherHandler : public RefCounted<LauncherHandler> {
|
||||||
public:
|
public:
|
||||||
LauncherHandler(const NonnullRefPtr<Desktop::Launcher::Details>& details)
|
LauncherHandler(const NonnullRefPtr<Desktop::Launcher::Details>& details)
|
||||||
: m_details(details)
|
: m_details(details)
|
||||||
|
@ -51,9 +51,11 @@ private:
|
||||||
NonnullRefPtr<Desktop::Launcher::Details> m_details;
|
NonnullRefPtr<Desktop::Launcher::Details> m_details;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DirectoryView final : public GUI::StackWidget
|
class DirectoryView final
|
||||||
|
: public GUI::StackWidget
|
||||||
, private GUI::ModelClient {
|
, private GUI::ModelClient {
|
||||||
C_OBJECT(DirectoryView)
|
C_OBJECT(DirectoryView);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~DirectoryView() override;
|
virtual ~DirectoryView() override;
|
||||||
|
|
||||||
|
@ -118,7 +120,8 @@ private:
|
||||||
DirectoryView();
|
DirectoryView();
|
||||||
const GUI::FileSystemModel& model() const { return *m_model; }
|
const GUI::FileSystemModel& model() const { return *m_model; }
|
||||||
|
|
||||||
virtual void on_model_update(unsigned) override;
|
// ^GUI::ModelClient
|
||||||
|
virtual void model_did_update(unsigned) override;
|
||||||
|
|
||||||
void handle_activation(const GUI::ModelIndex&);
|
void handle_activation(const GUI::ModelIndex&);
|
||||||
GUI::ModelIndex map_table_view_index(const GUI::ModelIndex&) const;
|
GUI::ModelIndex map_table_view_index(const GUI::ModelIndex&) const;
|
||||||
|
|
|
@ -287,7 +287,7 @@ FilePicker::~FilePicker()
|
||||||
m_model->unregister_client(*this);
|
m_model->unregister_client(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilePicker::on_model_update(unsigned)
|
void FilePicker::model_did_update(unsigned)
|
||||||
{
|
{
|
||||||
m_location_textbox->set_text(m_model->root_path());
|
m_location_textbox->set_text(m_model->root_path());
|
||||||
if (have_preview())
|
if (have_preview())
|
||||||
|
|
|
@ -35,8 +35,11 @@
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
class FilePicker final : public Dialog, private ModelClient {
|
class FilePicker final
|
||||||
C_OBJECT(FilePicker)
|
: public Dialog
|
||||||
|
, private ModelClient {
|
||||||
|
C_OBJECT(FilePicker);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class Mode {
|
enum class Mode {
|
||||||
Open,
|
Open,
|
||||||
|
@ -69,7 +72,8 @@ private:
|
||||||
|
|
||||||
void set_path(const String&);
|
void set_path(const String&);
|
||||||
|
|
||||||
virtual void on_model_update(unsigned) override;
|
// ^GUI::ModelClient
|
||||||
|
virtual void model_did_update(unsigned) override;
|
||||||
|
|
||||||
FilePicker(Window* parent_window, Mode type = Mode::Open, Options = Options::None, const StringView& file_name = "Untitled", const StringView& path = Core::StandardPaths::home_directory());
|
FilePicker(Window* parent_window, Mode type = Mode::Open, Options = Options::None, const StringView& file_name = "Untitled", const StringView& path = Core::StandardPaths::home_directory());
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ void Model::for_each_view(Function<void(AbstractView&)> callback)
|
||||||
void Model::did_update(unsigned flags)
|
void Model::did_update(unsigned flags)
|
||||||
{
|
{
|
||||||
for (auto* client : m_clients)
|
for (auto* client : m_clients)
|
||||||
client->on_model_update(flags);
|
client->model_did_update(flags);
|
||||||
|
|
||||||
for_each_view([&](auto& view) {
|
for_each_view([&](auto& view) {
|
||||||
view.did_update_model(flags);
|
view.did_update_model(flags);
|
||||||
|
|
|
@ -48,7 +48,7 @@ class ModelClient {
|
||||||
public:
|
public:
|
||||||
virtual ~ModelClient() { }
|
virtual ~ModelClient() { }
|
||||||
|
|
||||||
virtual void on_model_update(unsigned flags) = 0;
|
virtual void model_did_update(unsigned flags) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Model : public RefCounted<Model> {
|
class Model : public RefCounted<Model> {
|
||||||
|
|
|
@ -50,7 +50,7 @@ SortingProxyModel::~SortingProxyModel()
|
||||||
m_source->unregister_client(*this);
|
m_source->unregister_client(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SortingProxyModel::on_model_update(unsigned flags)
|
void SortingProxyModel::model_did_update(unsigned flags)
|
||||||
{
|
{
|
||||||
resort(flags);
|
resort(flags);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,8 @@ public:
|
||||||
private:
|
private:
|
||||||
explicit SortingProxyModel(NonnullRefPtr<Model> source);
|
explicit SortingProxyModel(NonnullRefPtr<Model> source);
|
||||||
|
|
||||||
virtual void on_model_update(unsigned) override;
|
// ^ModelClient
|
||||||
|
virtual void model_did_update(unsigned) override;
|
||||||
|
|
||||||
Model& source() { return *m_source; }
|
Model& source() { return *m_source; }
|
||||||
const Model& source() const { return *m_source; }
|
const Model& source() const { return *m_source; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue