/* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2021, Sam Atkins * Copyright (c) 2023, Jonah Shafran * Copyright (c) 2023, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace WebView { class PropertyTableModel { public: enum class Type { ARIAProperties, StyleProperties, }; enum class Column : int { PropertyName, PropertyValue, }; PropertyTableModel(Type, JsonValue const&); ~PropertyTableModel(); template void for_each_property_name(Callback&& callback) { for (size_t i = 0; i < m_values.size(); ++i) { ModelIndex index { static_cast(i), to_underlying(WebView::PropertyTableModel::Column::PropertyName) }; auto const& property_name = m_values[i].name; if (callback(index, property_name) == IterationDecision::Break) break; } } int row_count(ModelIndex const& parent) const; int column_count(ModelIndex const& parent) const; ErrorOr column_name(int) const; ModelIndex index(int row, int column, ModelIndex const& parent) const; String text_for_display(ModelIndex const& index) const; private: struct Value { String name; String value; }; Vector m_values; }; }