summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels/qrangemodeladapter.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/itemmodels/qrangemodeladapter.h')
-rw-r--r--src/corelib/itemmodels/qrangemodeladapter.h28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/corelib/itemmodels/qrangemodeladapter.h b/src/corelib/itemmodels/qrangemodeladapter.h
index 2a23e01eba2..0234c402248 100644
--- a/src/corelib/itemmodels/qrangemodeladapter.h
+++ b/src/corelib/itemmodels/qrangemodeladapter.h
@@ -19,13 +19,11 @@ class QT_TECH_PREVIEW_API QRangeModelAdapter
#ifdef Q_QDOC
using range_type = Range;
- using const_row_reference = typename std::iterator_traits<Range>::const_reference;
- using row_reference = typename std::iterator_traits<Range>::reference;
#else
using range_type = QRangeModelDetails::wrapped_t<Range>;
+#endif
using const_row_reference = typename Impl::const_row_reference;
using row_reference = typename Impl::row_reference;
-#endif
using range_features = typename QRangeModelDetails::range_traits<range_type>;
using row_type = std::remove_reference_t<row_reference>;
using row_features = QRangeModelDetails::range_traits<typename Impl::wrapped_row_type>;
@@ -78,16 +76,22 @@ class QT_TECH_PREVIEW_API QRangeModelAdapter
template <typename C>
using if_compatible_row_range = std::enable_if_t<is_compatible_row_range<C>, bool>;
template <typename Data>
- static constexpr bool is_compatible_data = true;
- // std::is_convertible_v<Data, decltype(*std::begin(std::declval<const_row_reference>()))>;
+ static constexpr bool is_compatible_data = std::is_convertible_v<Data, data_type>;
template <typename Data>
using if_compatible_data = std::enable_if_t<is_compatible_data<Data>, bool>;
template <typename C>
static constexpr bool is_compatible_data_range = is_compatible_data<
+ typename QRangeModelDetails::data_type<
+ typename QRangeModelDetails::row_traits<
decltype(*std::begin(std::declval<C&>()))
- >;
+ >::item_type
+ >::type
+ >;
+ template <typename C>
+ using if_compatible_column_data = std::enable_if_t<is_compatible_data<C>
+ || is_compatible_data_range<C>, bool>;
template <typename C>
- using if_compatible_data_range = std::enable_if_t<is_compatible_data_range<C>, bool>;
+ using if_compatible_column_range = std::enable_if_t<is_compatible_data_range<C>, bool>;
template <typename R>
using if_assignable_range = std::enable_if_t<std::is_assignable_v<range_type, R>, bool>;
@@ -1262,12 +1266,12 @@ public:
decltype(auto) operator[](int row) const { return at(row); }
template <typename I = Impl, if_table<I> = true, if_writable<I> = true>
- decltype(auto) at(int row)
+ auto at(int row)
{
return RowReference{index(row, 0), this};
}
template <typename I = Impl, if_table<I> = true, if_writable<I> = true>
- decltype(auto) operator[](int row) { return at(row); }
+ auto operator[](int row) { return at(row); }
// at/operator[int, int] for table: returns value at row/column
template <typename I = Impl, unless_list<I> = true>
@@ -1445,15 +1449,15 @@ public:
return storage.m_model->insertColumn(before);
}
- template <typename D = row_type, typename I = Impl,
- if_canInsertColumns<I> = true, if_compatible_data<D> = true>
+ template <typename D, typename I = Impl,
+ if_canInsertColumns<I> = true, if_compatible_column_data<D> = true>
bool insertColumn(int before, D &&data)
{
return insertColumnImpl(before, storage.root(), std::forward<D>(data));
}
template <typename C, typename I = Impl,
- if_canInsertColumns<I> = true, if_compatible_data_range<C> = true>
+ if_canInsertColumns<I> = true, if_compatible_column_range<C> = true>
bool insertColumns(int before, C &&data)
{
return insertColumnsImpl(before, storage.root(), std::forward<C>(data));