11#include <source_location>
32 Items_ = std::move (items);
37 requires std::is_constructible_v<T, U&&>
42 Items_.reserve (items.size ());
43 for (
auto&& item : items)
44 Items_ << T { std::move (item) };
60 const auto pos =
Items_.size ();
74 beginInsertRows ({},
Items_.size (),
Items_.size () + items.size () - 1);
82 emit dataChanged (
index (idx, 0),
89 std::invoke (std::forward<F> (editor),
ItemAt (idx));
90 emit dataChanged (
index (idx, 0),
96 CheckRow (idx, std::source_location::current ());
97 beginRemoveRows ({}, idx, idx);
112 auto&
ItemAt (
this auto&& self,
int row,
const std::source_location& loc = std::source_location::current ())
114 self.CheckRow (row, loc);
115 return self.Items_ [row];
118 void CheckRow (
int row,
const std::source_location& loc)
const
120 if (row < 0 || row >=
Items_.size ())
QModelIndex index(int row, int col, const QModelIndex &parent={}) const override
int columnCount(const QModelIndex &index={}) const override
QModelIndex parent(const QModelIndex &) const override
static void NotifyRowOutOfRange(const FlatItemsModelBase &model, int row, int count, const std::source_location &loc)
FlatItemsModelBase(QStringList headers, QObject *=nullptr)
void RemoveItem(QList< T >::const_iterator it)
const QList< T > & GetItems() const
QList< T > & GetMutItems()
void AddItems(const QList< T > &items)
void SetItems(QList< U > items)
void SetItems(QList< T > items)
void EditItem(int idx, F &&editor)
void SetItem(int idx, const T &item)
auto & ItemAt(this auto &&self, int row, const std::source_location &loc=std::source_location::current())
qsizetype AddItem(const T &item)
int GetItemsCount() const override
FlatItemsModelTypedBase(QStringList headers, QObject *parent=nullptr)
void InstallModelSanitizer(QAbstractItemModel &model)
Attaches a QAbstractItemModelTester to model for the rest of its lifetime.