mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:02:44 +00:00 
			
		
		
		
	 3f3f45580a
			
		
	
	
		3f3f45580a
		
	
	
	
	
		
			
			Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
		
			
				
	
	
		
			105 lines
		
	
	
	
		
			4.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			105 lines
		
	
	
	
		
			4.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include "StorageWidget.h"
 | |
| #include "CookiesModel.h"
 | |
| #include "StorageModel.h"
 | |
| #include <AK/Variant.h>
 | |
| #include <Applications/Browser/StorageWidgetGML.h>
 | |
| #include <LibGUI/TabWidget.h>
 | |
| #include <LibGUI/TableView.h>
 | |
| #include <LibWeb/Cookie/Cookie.h>
 | |
| 
 | |
| namespace Browser {
 | |
| 
 | |
| StorageWidget::StorageWidget()
 | |
| {
 | |
|     load_from_gml(storage_widget_gml);
 | |
|     auto& tab_widget = *find_descendant_of_type_named<GUI::TabWidget>("tab_widget");
 | |
| 
 | |
|     m_cookies_table_view = tab_widget.find_descendant_of_type_named<GUI::TableView>("cookies_tableview");
 | |
|     m_cookies_textbox = tab_widget.find_descendant_of_type_named<GUI::TextBox>("cookies_filter_textbox");
 | |
|     m_cookies_model = adopt_ref(*new CookiesModel());
 | |
| 
 | |
|     m_cookies_filtering_model = MUST(GUI::FilteringProxyModel::create(*m_cookies_model));
 | |
|     m_cookies_filtering_model->set_filter_term(""sv);
 | |
| 
 | |
|     m_cookies_textbox->on_change = [this] {
 | |
|         m_cookies_filtering_model->set_filter_term(m_cookies_textbox->text());
 | |
|         if (m_cookies_filtering_model->row_count() != 0)
 | |
|             m_cookies_table_view->set_cursor(m_cookies_filtering_model->index(0, 0), GUI::AbstractView::SelectionUpdate::Set);
 | |
|     };
 | |
| 
 | |
|     m_cookies_table_view->set_model(m_cookies_filtering_model);
 | |
|     m_cookies_table_view->set_column_headers_visible(true);
 | |
|     m_cookies_table_view->set_alternating_row_colors(true);
 | |
| 
 | |
|     m_local_storage_table_view = tab_widget.find_descendant_of_type_named<GUI::TableView>("local_storage_tableview");
 | |
|     m_local_storage_textbox = tab_widget.find_descendant_of_type_named<GUI::TextBox>("local_storage_filter_textbox");
 | |
|     m_local_storage_model = adopt_ref(*new StorageModel());
 | |
| 
 | |
|     m_local_storage_filtering_model = MUST(GUI::FilteringProxyModel::create(*m_local_storage_model));
 | |
|     m_local_storage_filtering_model->set_filter_term(""sv);
 | |
| 
 | |
|     m_local_storage_textbox->on_change = [this] {
 | |
|         m_local_storage_filtering_model->set_filter_term(m_local_storage_textbox->text());
 | |
|         if (m_local_storage_filtering_model->row_count() != 0)
 | |
|             m_local_storage_table_view->set_cursor(m_local_storage_filtering_model->index(0, 0), GUI::AbstractView::SelectionUpdate::Set);
 | |
|     };
 | |
| 
 | |
|     m_local_storage_table_view->set_model(m_local_storage_filtering_model);
 | |
|     m_local_storage_table_view->set_column_headers_visible(true);
 | |
|     m_local_storage_table_view->set_alternating_row_colors(true);
 | |
| 
 | |
|     m_session_storage_table_view = tab_widget.find_descendant_of_type_named<GUI::TableView>("session_storage_tableview");
 | |
|     m_session_storage_textbox = tab_widget.find_descendant_of_type_named<GUI::TextBox>("session_storage_filter_textbox");
 | |
|     m_session_storage_model = adopt_ref(*new StorageModel());
 | |
| 
 | |
|     m_session_storage_filtering_model = MUST(GUI::FilteringProxyModel::create(*m_session_storage_model));
 | |
|     m_session_storage_filtering_model->set_filter_term(""sv);
 | |
| 
 | |
|     m_session_storage_textbox->on_change = [this] {
 | |
|         m_session_storage_filtering_model->set_filter_term(m_session_storage_textbox->text());
 | |
|         if (m_session_storage_filtering_model->row_count() != 0)
 | |
|             m_session_storage_table_view->set_cursor(m_session_storage_filtering_model->index(0, 0), GUI::AbstractView::SelectionUpdate::Set);
 | |
|     };
 | |
| 
 | |
|     m_session_storage_table_view->set_model(m_session_storage_filtering_model);
 | |
|     m_session_storage_table_view->set_column_headers_visible(true);
 | |
|     m_session_storage_table_view->set_alternating_row_colors(true);
 | |
| }
 | |
| 
 | |
| void StorageWidget::set_cookies_entries(Vector<Web::Cookie::Cookie> entries)
 | |
| {
 | |
|     m_cookies_model->set_items(entries);
 | |
| }
 | |
| 
 | |
| void StorageWidget::clear_cookies()
 | |
| {
 | |
|     m_cookies_model->clear_items();
 | |
| }
 | |
| 
 | |
| void StorageWidget::set_local_storage_entries(OrderedHashMap<String, String> entries)
 | |
| {
 | |
|     m_local_storage_model->set_items(entries);
 | |
| }
 | |
| 
 | |
| void StorageWidget::clear_local_storage_entries()
 | |
| {
 | |
|     m_local_storage_model->clear_items();
 | |
| }
 | |
| 
 | |
| void StorageWidget::set_session_storage_entries(OrderedHashMap<String, String> entries)
 | |
| {
 | |
|     m_session_storage_model->set_items(entries);
 | |
| }
 | |
| 
 | |
| void StorageWidget::clear_session_storage_entries()
 | |
| {
 | |
|     m_session_storage_model->clear_items();
 | |
| }
 | |
| 
 | |
| }
 |