19#include "AListModelIndex.h"
20#include "AListModelRange.h"
21#include <AUI/Common/ASet.h>
22#include <AUI/Common/AVector.h>
28class AListModelSelection {
34 AListModelSelection() =
default;
36 mModel(std::move(model)) {}
40 ASet<AListModelIndex>::iterator mIterator;
46 mIterator(
iterator), mModel(std::move(model)) {}
49 Iterator& operator*() {
54 return mModel->listItemAt(*mIterator);
57 return mModel->listItemAt(*mIterator);
60 Iterator& operator++() {
65 bool operator!=(
const Iterator& other)
const {
67 return mIterator != other.mIterator;
70 bool operator==(
const Iterator& other)
const {
72 return mIterator == other.mIterator;
82 return {mIndices.begin(), mModel};
84 AListModelSelection<T>::Iterator end()
const {
85 return {mIndices.end(), mModel};
88 [[nodiscard]]
size_t size()
const {
89 return mIndices.size();
91 [[nodiscard]]
bool empty()
const {
92 return mIndices.empty();
95 const _<IListModel<T>>& getModel()
const {
99 const ASet<AListModelIndex>& getIndices()
const {
103 AListModelIndex first() {
104 AUI_ASSERTX(mIndices.begin() != mIndices.end(),
"selection model is empty");
105 return *mIndices.begin();
108 AVector<AListModelRange<T>> ranges() const noexcept;
111#include "IListModel.h"
114AVector<AListModelRange<T>> AListModelSelection<T>::ranges() const noexcept {
115 return mModel->rangesIncluding([&](
size_t i) {
116 return mIndices.contains(i);
Definition AListModelIndex.h:20
Definition AListModelSelection.h:38
A std::set with AUI extensions.
Definition ASet.h:25
Definition IListModel.h:23
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:178
#define AUI_ASSERT(condition)
Asserts that the passed condition evaluates to true.
Definition Assert.h:55
#define AUI_ASSERTX(condition, what)
Asserts that the passed condition evaluates to true. Adds extra message string.
Definition Assert.h:74