22class AListModelObserver:
public AObject {
26 virtual void insertItem(
size_t at,
const T& value) = 0;
27 virtual void updateItem(
size_t at,
const T& value) = 0;
28 virtual void removeItem(
size_t at) = 0;
30 virtual void onDataCountChanged() = 0;
31 virtual void onDataChanged() = 0;
40 setSlotsCallsOnlyOnMyThread(
true);
46 mModel->dataInserted.clearAllConnectionsWith(
this);
47 mModel->dataChanged.clearAllConnectionsWith(
this);
48 mModel->dataRemoved.clearAllConnectionsWith(
this);
53 for (
size_t i = 0; i < model->listSize(); ++i) {
54 mListener->insertItem(i, model->listItemAt(i));
56 mListener->onDataCountChanged();
57 mListener->onDataChanged();
59 connect(mModel->dataInserted,
this, [&](
const AListModelRange<T>& data) {
60 for (const auto& row : data) {
61 mListener->insertItem(row.getIndex().getRow(), row.get());
63 mListener->onDataCountChanged();
64 mListener->onDataChanged();
66 connect(mModel->dataChanged,
this, [&](
const AListModelRange<T>& data) {
67 for (const auto& row : data) {
68 mListener->updateItem(row.getIndex().getRow(), row.get());
70 mListener->onDataChanged();
72 connect(mModel->dataRemoved,
this, [&](
const AListModelRange<T>& data) {
73 for (const auto& row : data) {
74 mListener->removeItem(data.begin().getIndex().getRow());
76 mListener->onDataCountChanged();
77 mListener->onDataChanged();
static void connect(const Signal &signal, Object *object, Function &&function)
Connects signal to the slot of the specified object.
Definition AObject.h:65