// Copyright (C) 2025 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only // Qt-Security score:significant reason:default #ifndef QRANGEMODELADAPTER_H #define QRANGEMODELADAPTER_H #include QT_BEGIN_NAMESPACE template class QT_TECH_PREVIEW_API QRangeModelAdapter { using Impl = QRangeModelDetails::RangeImplementation; using Storage = QRangeModelDetails::AdapterStorage; Storage storage; #ifdef Q_QDOC using range_type = Range; #else using range_type = QRangeModelDetails::wrapped_t; #endif using const_row_reference = typename Impl::const_row_reference; using row_reference = typename Impl::row_reference; using range_features = typename QRangeModelDetails::range_traits; using row_type = std::remove_reference_t; using row_features = QRangeModelDetails::range_traits; using row_ptr = typename Impl::wrapped_row_type *; using row_traits = typename Impl::row_traits; using item_type = std::remove_reference_t; using data_type = typename QRangeModelDetails::data_type::type; using const_data_type = QRangeModelDetails::asConst_t; using protocol_traits = typename Impl::protocol_traits; template static constexpr bool is_list = I::protocol_traits::is_list; template static constexpr bool is_table = I::protocol_traits::is_table; template static constexpr bool is_tree = I::protocol_traits::is_tree; template static constexpr bool canInsertColumns = I::dynamicColumns() && I::isMutable() && row_features::has_insert; template static constexpr bool canRemoveColumns = I::dynamicColumns() && I::isMutable() && row_features::has_erase; template using if_writable = std::enable_if_t; template using if_list = std::enable_if_t, bool>; template using unless_list = std::enable_if_t, bool>; template using if_table = std::enable_if_t, bool>; template using if_tree = std::enable_if_t, bool>; template using unless_tree = std::enable_if_t, bool>; template using if_flat = std::enable_if_t || is_table, bool>; template using if_canInsertRows = std::enable_if_t; template using if_canRemoveRows = std::enable_if_t; template using if_canMoveItems = std::enable_if_t; template using if_canInsertColumns = std::enable_if_t, bool>; template using if_canRemoveColumns = std::enable_if_t, bool>; template static constexpr bool is_compatible_row = std::is_convertible_v; template using if_compatible_row = std::enable_if_t, bool>; template static constexpr bool is_compatible_row_range = is_compatible_row< decltype(*std::begin(std::declval())) >; template using if_compatible_row_range = std::enable_if_t, bool>; template static constexpr bool is_compatible_data = std::is_convertible_v; template using if_compatible_data = std::enable_if_t, bool>; template static constexpr bool is_compatible_data_range = is_compatible_data< typename QRangeModelDetails::data_type< typename QRangeModelDetails::row_traits< decltype(*std::begin(std::declval())) >::item_type >::type >; template using if_compatible_column_data = std::enable_if_t || is_compatible_data_range, bool>; template using if_compatible_column_range = std::enable_if_t, bool>; template using if_assignable_range = std::enable_if_t, bool>; friend class QRangeModel; template static constexpr bool is_adapter = QRangeModelDetails::is_any_of, QRangeModelAdapter>::value; template using unless_adapter = std::enable_if_t, bool>; #if !defined(Q_OS_VXWORKS) && !defined(Q_OS_INTEGRITY) // An adapter on a mutable range can make itself an adapter on a const // version of that same range. To make the constructor for a sub-range // accessible, befriend the mutable version. We can use more // generic pattern matching here, as we only use as input what asConst // might produce as output. template static constexpr T asMutable(const T &); template static constexpr T *asMutable(const T *); template