mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
View/Model support push_back
This commit is contained in:
@@ -972,6 +972,38 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::push_back(const ObjectType &value, bool resize)
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
if (this->rowCount() < 1)
|
||||
{
|
||||
// this allows presizing
|
||||
this->updateContainerMaybeAsync(ContainerType({value}), true, resize);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_model->push_back(value);
|
||||
if (resize) { this->performModeBasedResizeToContent(); }
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::push_back(const ContainerType &container, bool resize)
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
if (this->rowCount() < 1)
|
||||
{
|
||||
// this allows presizing
|
||||
this->updateContainerMaybeAsync(container, true, resize);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_model->push_back(container);
|
||||
if (resize) { this->performModeBasedResizeToContent(); }
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
const ObjectType &CViewBase<ModelClass, ContainerType, ObjectType>::at(const QModelIndex &index) const
|
||||
{
|
||||
|
||||
@@ -580,6 +580,12 @@ namespace BlackGui
|
||||
//! Insert
|
||||
void insert(const ContainerType &container, bool resize = true);
|
||||
|
||||
//! Push back
|
||||
void push_back(const ObjectType &value, bool resize = true);
|
||||
|
||||
//! Push back
|
||||
void push_back(const ContainerType &container, bool resize = true);
|
||||
|
||||
//! Value object at
|
||||
const ObjectType &at(const QModelIndex &index) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user