24template <
typename ItemClass,
class ContainerType = QList<ItemClass> >
35 const ItemClass&
GetAt(
int index)
const;
39 ItemClass&
InsertAt(
const ItemClass& item,
int index);
63 inline const ItemClass&
operator[](qsizetype index)
const
69 typename Container::iterator
insert(qsizetype index,
const ItemClass& item)
78 typename Container::iterator
insert(qsizetype index, ItemClass&& item)
91#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
104#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
129 typename Container::iterator
begin()
135 typename Container::iterator
end()
141 typename Container::const_iterator
begin()
const
147 typename Container::const_iterator
end()
const
153 typename Container::const_iterator
cbegin()
const
159 typename Container::const_iterator
cend()
const
187template <
typename ItemClass,
typename ContainerType>
193template <
typename ItemClass,
typename ContainerType>
199template <
typename ItemClass,
typename ContainerType>
204 return m_items[index];
208template <
typename ItemClass,
typename ContainerType>
213 return m_items[index];
217template <
typename ItemClass,
typename ContainerType>
220 auto changes = ElementAddChanges(m_items.size());
224 m_items.push_back(item);
226 return m_items.back();
230template <
typename ItemClass,
typename ContainerType>
233 auto changes = ElementAddChanges(0);
237 m_items.push_front(item);
239 return m_items.front();
243template <
typename ItemClass,
typename ContainerType>
246 if ((index < 0) || (index >= m_items.size())){
247 return PushBack(item);
250 auto changes = ElementAddChanges(index);
252 m_items.insert(index, item);
254 return m_items[index];
259template <
typename ItemClass,
typename ContainerType>
262 auto changes = ElementRemoveChanges(m_items.size() - 1);
270template <
typename ItemClass,
typename ContainerType>
273 auto changes = ElementRemoveChanges(0);
281template <
typename ItemClass,
typename ContainerType>
284 Q_ASSERT(index >= 0);
285 Q_ASSERT(index <
int(m_items.size()));
287 if (index <
int(m_items.size())){
288 auto changes = ElementRemoveChanges(index);
292 m_items.erase(m_items.begin() + index);
297template <
typename ItemClass,
typename ContainerType>
307template <
typename ItemClass,
typename ContainerType>
319template <
typename ItemClass,
typename ContainerType>
322 return int(m_items.size());
326template <
typename ItemClass,
typename ContainerType>
329 return (m_items.size() == 0);
333template <
typename ItemClass,
typename ContainerType>
336 return (index >= 0 && index <
int(m_items.size()));
342template <
typename ItemClass,
typename ContainerType>
346 if (containerPtr !=
NULL){
347 m_items = containerPtr->
m_items;
358template <
typename ItemClass,
typename ContainerType>
Base implementation for creating simple observable collection.
static istd::IChangeable::ChangeSet ElementRemoveChanges(qsizetype index)
static istd::IChangeable::ChangeSet ElementAddChanges(qsizetype index)
Common implementation of an abstract container.
virtual void Resize(int count)
Container::iterator insert(qsizetype index, ItemClass &&item)
virtual void RemoveAt(int index)
TContainer & operator=(const TContainer &container)
ItemClass & PushBack(const ItemClass &item)
Container::iterator insert(qsizetype index, const ItemClass &item)
Container::const_iterator end() const
Container::const_iterator begin() const
ItemClass & PushFront(const ItemClass &item)
static const ChangeSet s_resetChange
ItemClass & InsertAt(const ItemClass &item, int index)
virtual bool CopyFrom(const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
void resize(qsizetype size)
virtual bool IsEmpty() const override
Returns a true if container is empty, otherwise a false.
ItemClass & operator[](qsizetype index)
Container::const_iterator cbegin() const
virtual void Reserve(int count)
const ItemClass & GetAt(int index) const
bool operator!=(const TContainer &other) const
void push_front(const ItemClass &item)
virtual int GetItemsCount() const override
Returns number of elements in the container.
void push_back(const ItemClass &item)
Container::const_iterator cend() const
virtual bool IsIndexValid(int index) const override
bool operator==(const TContainer &other) const
ItemClass & GetAt(int index)
Container::iterator end()
Container::iterator begin()
const ItemClass & operator[](qsizetype index) const
Help class which provides the automatic update mechanism of the model.
Set of change flags (its IDs).
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
Common interface for all container implementations.
This namespace contains basic implementations of standard primitives on the component level.