Commit Graph

8 Commits

Author SHA1 Message Date
Volker Hilsheimer 6784a7aff7 QRM: make size() work for ranges that don't have begin/end(const R&)
Use const_cast to call the mutable overload if we cannot call the const
overload. This allows us to directly support e.g. std::views::filter.
As a drive by, use using-statements to reduce code duplication.

Use std::views::filter directly in the tests, now that it works.

Change-Id: I47f06ee8fe921d5854f676a35a750e64f4356fc0
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-09-02 18:19:44 +03:00
Volker Hilsheimer 2901cb4347 QRM: store ranges that don't provide begin/end on const as mutable
This makes it almost possible to use certain std::views, like filter or
drop_while, with QRangeModel. Only do that for such ranges, as otherwise
we'd detach from Qt's implicitly shared range types.

Almost, because we still assume that we can call begin/end on a const
range in our size() implementation. That needs a bit more work, and
probably only makes sense when we have a fetchMore implementation for
ranges that don't provide a constant-time size().

Nevertheless, add a filter-case to the auto and manual tests, but go
through std::ranges::subrange for now.

Change-Id: I07cd543d73746e6b47a03aceedee2365b6750321
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-09-01 20:37:17 +02:00
Frédéric Lefebvre 60d02e4f3f Add a conditional to handle pragma message when MSVC is used
MSVC does not support the warning preprocessor directive. To ensure
compatibility across compilers, add a conditional check to instead use
pragma message with MSVC.

Change-Id: If380ebf8b2a5bb771dbbb374158e619ce1090e65
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-08-28 17:33:58 +00:00
Volker Hilsheimer 2812579a66 QRM: fix build when a std::*map is used as the range
While unorthodox, a std::map is sequentially iterable, and yields
std::pair instances as rows. Those should then result in two columns.

However, rows in a map cannot be rotated, because swap is explicitly
deleted for the pair type (which uses a const key type). So test that we
can swap the dereferenced iterators (testing for std::rotate still
passes, so we can't test for that directly).

Pick-to: 6.10
Change-Id: I12f7c06cca9363bdb3d0497ddbbf101d05bd9e9f
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-08-27 02:39:27 +02:00
Volker Hilsheimer b7bbd2a37c QRM: fix build of manual test without Quick
Pick-to: 6.10
Change-Id: Iec70d068554e0c4e4eac2c24473b4ea2a722b26d
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-08-22 19:11:30 +00:00
Volker Hilsheimer ce02416d02 QRM: specialize row_traits for std::array
std::tuple_element is implemented for std::array, so we end up using the
tuple  specialization of row_traits for a QRangeModel(std::array<T, N>).
This is semantically wrong, but it also breaks the build when using a
large array.

The tuple specialization uses a helper to test if all elements in the
tuple have the same type. With large arrays, this hits the compiler's
limit for fold-expressions, which defaults with clang to 256.

Specialize row_traits for std::array as well as C arrays; we know that
all elements are of the same type. To avoid ambiguity,
don't consider a std::array as a tuple. Introduce a
array_like detector that is true for std::array and C arrays of any type
and overload for_element_at using that detector (we have to, as we need
the array as a universal reference).

For the same reason, avoid the fold expression in meta_type_at if the
row type is an array. All types are the same anyway, so we can just
pick the first.

Pick-to: 6.10
Change-Id: Ic49e222d7b3390f9e4cc15ec531f8a97981ab0d5
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-08-22 21:11:29 +02:00
Volker Hilsheimer ea8531dfc5 QRM: improve UI of manual test
Use delegates from Qt Quick Controls, which look better and provide
complete default behavior, while making easier to confirm that things
work as they should (ie. correct roles are reported).

Move the whole UI into a QMainWindow, using QQuickWidget for the Quick
UI.

Pick-to: 6.10
Change-Id: I2aa12ef4d6f024fa9ba1b57fd4f03f594ce50ab4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-08-15 00:21:49 +03:00
Volker Hilsheimer a554489a9a QRM: add manual test
Pick-to: 6.10
Change-Id: Id3fa877e7aa59713cd9a64bfb72d9871fe92bea8
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-08-12 04:55:21 +02:00