mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 18:05:08 +00:00
LibCore: Make Core::Object::add<ChildType> return a ChildType&
Since the returned object is now owned by the callee object, we can simply vend a ChildType&. This allows us to use "." instead of "->" at the call site, which is quite nice. :^)
This commit is contained in:
parent
fb09b6a8ce
commit
028c011760
46 changed files with 1035 additions and 1039 deletions
|
@ -61,30 +61,30 @@ int main(int argc, char** argv)
|
|||
widget.set_fill_with_background_color(true);
|
||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto board_combo = widget.add<GUI::ComboBox>();
|
||||
board_combo->set_only_allow_values_from_model(true);
|
||||
board_combo->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
board_combo->set_preferred_size(0, 20);
|
||||
board_combo->set_model(BoardListModel::create());
|
||||
auto& board_combo = widget.add<GUI::ComboBox>();
|
||||
board_combo.set_only_allow_values_from_model(true);
|
||||
board_combo.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
board_combo.set_preferred_size(0, 20);
|
||||
board_combo.set_model(BoardListModel::create());
|
||||
|
||||
auto catalog_view = widget.add<GUI::TableView>();
|
||||
catalog_view->set_model(ThreadCatalogModel::create());
|
||||
auto& catalog_model = *static_cast<ThreadCatalogModel*>(catalog_view->model());
|
||||
auto& catalog_view = widget.add<GUI::TableView>();
|
||||
catalog_view.set_model(ThreadCatalogModel::create());
|
||||
auto& catalog_model = *static_cast<ThreadCatalogModel*>(catalog_view.model());
|
||||
|
||||
auto statusbar = widget.add<GUI::StatusBar>();
|
||||
auto& statusbar = widget.add<GUI::StatusBar>();
|
||||
|
||||
board_combo->on_change = [&] (auto&, const GUI::ModelIndex& index) {
|
||||
auto selected_board = board_combo->model()->data(index, GUI::Model::Role::Custom);
|
||||
board_combo.on_change = [&] (auto&, const GUI::ModelIndex& index) {
|
||||
auto selected_board = board_combo.model()->data(index, GUI::Model::Role::Custom);
|
||||
ASSERT(selected_board.is_string());
|
||||
catalog_model.set_board(selected_board.to_string());
|
||||
};
|
||||
|
||||
catalog_model.on_load_started = [&] {
|
||||
statusbar->set_text(String::format("Loading /%s/...", catalog_model.board().characters()));
|
||||
statusbar.set_text(String::format("Loading /%s/...", catalog_model.board().characters()));
|
||||
};
|
||||
|
||||
catalog_model.on_load_finished = [&](bool success) {
|
||||
statusbar->set_text(success ? "Load finished" : "Load failed");
|
||||
statusbar.set_text(success ? "Load finished" : "Load failed");
|
||||
if (success) {
|
||||
window->set_title(String::format("/%s/ - ChanViewer", catalog_model.board().characters()));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue