1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 16:35:06 +00:00
serenity/Userland/Applications/Browser/History/HistoryWidget.cpp
Sam Atkins f0395a2042 LibGUI+Userland: Rename try_load_from_gml() -> load_from_gml() :^)
It's the only one, so the `try` prefix is unnecessary now.
2023-01-07 14:39:30 +01:00

44 lines
1.2 KiB
C++

/*
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "HistoryWidget.h"
#include <Applications/Browser/HistoryWidgetGML.h>
#include <LibGUI/TableView.h>
namespace Browser {
HistoryWidget::HistoryWidget()
{
load_from_gml(history_widget_gml).release_value_but_fixme_should_propagate_errors();
m_table_view = find_descendant_of_type_named<GUI::TableView>("history_tableview");
m_textbox = find_descendant_of_type_named<GUI::TextBox>("history_filter_textbox");
m_model = adopt_ref(*new HistoryModel());
m_filtering_model = MUST(GUI::FilteringProxyModel::create(*m_model));
m_filtering_model->set_filter_term(""sv);
m_textbox->on_change = [this] {
m_filtering_model->set_filter_term(m_textbox->text());
if (m_filtering_model->row_count() != 0)
m_table_view->set_cursor(m_filtering_model->index(0, 0), GUI::AbstractView::SelectionUpdate::Set);
};
m_table_view->set_model(m_filtering_model);
m_table_view->set_alternating_row_colors(true);
}
void HistoryWidget::set_history_entries(Vector<History::URLTitlePair> entries)
{
m_model->set_items(entries);
}
void HistoryWidget::clear_history_entries()
{
m_model->clear_items();
}
}