7#include <QtCore/QTimer>
9#include <QtQml/private/qqmlincubator_p.h>
10#include <QtQmlModels/private/qqmlchangeset_p.h>
11#include <QtQml/private/qqmlcomponent_p.h>
31 modelItem->
object =
nullptr;
51 for (
const auto modelItem : m_modelItems) {
63 modelItem->
object =
nullptr;
68 deleteAllFinishedIncubationTasks();
75 if (m_delegateChooser) {
82 chooser = qobject_cast<QQmlAbstractDelegateComponent *>(
delegate);
139 incubateModelItem(modelItem, incubationMode);
140 if (!isDoneIncubating(modelItem))
195 destroyModelItem(modelItem, Deferred);
202 if (
mode == Deferred)
254 destroyModelItem(modelItem, Immediate);
265 const bool alwaysEmit =
true;
266 const int newRow = m_adaptorModel.
rowAt(newModelIndex);
267 const int newColumn = m_adaptorModel.
columnAt(newModelIndex);
268 item->setModelIndex(newModelIndex, newRow, newColumn, alwaysEmit);
274 m_adaptorModel.
notify(itemAsList, newModelIndex, 1, updateAllRoles);
278 emit itemReused(newModelIndex,
item->object);
312 ctxt->setContextObject(modelItem);
348 qWarning() <<
"Error incubating delegate:" << incubationTask->
errors();
365 deleteModelItemLater(modelItem);
368 deleteIncubationTaskLater(incubationTask);
372 const auto modelItem = m_modelItems.
value(
index,
nullptr);
390 const auto modelItem = m_modelItems.
value(
index,
nullptr);
398 bool wasInRequired =
false;
409 return wasInRequired;
412void QQmlTableInstanceModel::deleteIncubationTaskLater(
QQmlIncubator *incubationTask)
417 m_finishedIncubationTasks.
append(incubationTask);
418 if (m_finishedIncubationTasks.
size() == 1)
419 QTimer::singleShot(1,
this, &QQmlTableInstanceModel::deleteAllFinishedIncubationTasks);
422void QQmlTableInstanceModel::deleteAllFinishedIncubationTasks()
425 m_finishedIncubationTasks.
clear();
430 return m_adaptorModel.
model();
455 int numberOfRowsChanged =
end.row() -
begin.row() + 1;
456 int numberOfColumnsChanged =
end.column() -
begin.column() + 1;
460 const int rowIndex =
begin.row() + (columnIndex *
rows());
461 m_adaptorModel.
notify(m_modelItems.
values(), rowIndex, numberOfRowsChanged, roles);
465void QQmlTableInstanceModel::modelAboutToBeResetCallback()
473 auto oldRoleNames = aim->roleNames();
475 if (oldRoleNames != aim->roleNames())
490 m_delegateChooser =
nullptr;
493 qobject_cast<QQmlAbstractDelegateComponent *>(
delegate);
495 m_delegateChooser = adc;
503 return m_adaptorModel.
adaptsAim() ? m_adaptorModel.
aim() :
nullptr;
534#include "moc_qqmltableinstancemodel_p.cpp"
void modelAboutToBeReset(QPrivateSignal)
void modelReset(QPrivateSignal)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
This signal is emitted whenever the data in an existing item changes.
bool remove(const Key &key)
Removes the item that has the key from the hash.
QList< T > values() const
Returns a list containing all the values in the hash, in an arbitrary order.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
T value(const Key &key) const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
qsizetype size() const noexcept
void append(parameter_type t)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
void deleteLater()
\threadsafe
void initializeRequiredProperties(QQmlDelegateModelItem *modelItemToIncubate, QObject *object)
virtual QQmlComponent * delegate(QQmlAdaptorModel *adaptorModel, int row, int column=0) const =0
bool notify(const QList< QQmlDelegateModelItem * > &items, int index, int count, const QVector< int > &roles) const
QAbstractItemModel * aim()
int rowAt(int index) const
QQmlDelegateModelItem * createItem(const QQmlRefPointer< QQmlDelegateModelItemMetaType > &metaType, int index)
int columnAt(int index) const
void useImportVersion(QTypeRevision revision)
void setModel(const QVariant &variant)
virtual void incubateObject(QQmlIncubator *incubationTask, QQmlComponent *component, QQmlEngine *engine, const QQmlRefPointer< QQmlContextData > &context, const QQmlRefPointer< QQmlContextData > &forContext)
static QQmlComponentPrivate * get(QQmlComponent *c)
static QQmlProperty removePropertyFromRequired(QObject *createdComponent, const QString &name, RequiredProperties *requiredProperties, QQmlEngine *engine, bool *wasInRequiredProperties=nullptr)
The QQmlComponent class encapsulates a QML component definition.
QQmlContext * creationContext() const
Returns the QQmlContext the component was created in.
static QQmlRefPointer< QQmlContextData > get(QQmlContext *context)
static QQmlRefPointer< QQmlContextData > createRefCounted(const QQmlRefPointer< QQmlContextData > &parent)
The QQmlContext class defines a context within a QML engine.
bool isValid() const
Returns whether the context is valid.
QQmlEngine * engine() const
Return the context's QQmlEngine, or \nullptr if the context has no QQmlEngine or the QQmlEngine was d...
QQDMIncubationTask * incubationTask
bool isReferenced() const
bool isObjectReferenced() const
QQmlRefPointer< QQmlContextData > contextData
QPointer< QObject > object
static QQmlEnginePrivate * get(QQmlEngine *e)
static QQmlIncubatorPrivate * get(QQmlIncubator *incubator)
The QQmlIncubator class allows QML objects to be created asynchronously.
QList< QQmlError > errors() const
Return the list of errors encountered while incubating the object.
QObject * object() const
Return the incubated object if the status is Ready, otherwise 0.
IncubationMode
Specifies the mode the incubator operates in.
void forceCompletion()
Force any in-progress incubation to finish synchronously.
Status status() const
Return the current status of the incubator.
Status
Specifies the status of the QQmlIncubator.
IncubationMode incubationMode() const
Return the incubation mode passed to the QQmlIncubator constructor.
void createdItem(int index, QObject *object)
void destroyingItem(QObject *object)
void initItem(int index, QObject *object)
The QQmlProperty class abstracts accessing properties on objects created from QML.
bool write(const QVariant &) const
Sets the property value to value.
void drain(int maxPoolTime, std::function< void(QQmlDelegateModelItem *cacheItem)> releaseItem)
void insertItem(QQmlDelegateModelItem *modelItem)
QQmlDelegateModelItem * takeItem(const QQmlComponent *delegate, int newIndexHint)
void statusChanged(Status status) override
Called when the status of the incubator changes.
QQmlDelegateModelItem * modelItemToIncubate
QQmlTableInstanceModel * tableInstanceModel
void setInitialState(QObject *object) override
Called after the object is first created, but before property bindings are evaluated and,...
const QAbstractItemModel * abstractItemModel() const override
void drainReusableItemsPool(int maxPoolTime) override
~QQmlTableInstanceModel() override
bool setRequiredProperty(int index, const QString &name, const QVariant &value) final
QQmlTableInstanceModel(QQmlContext *qmlContext, QObject *parent=nullptr)
void reuseItem(QQmlDelegateModelItem *item, int newModelIndex)
void setModel(const QVariant &model)
QQmlComponent * delegate() const
void useImportVersion(QTypeRevision version)
friend class QQmlTableInstanceModelIncubationTask
void setDelegate(QQmlComponent *)
QQmlIncubator::Status incubationStatus(int index) override
void dispose(QObject *object)
ReleaseFlags release(QObject *object, ReusableFlag reusable=NotReusable) override
void cancel(int) override
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool singleShot
whether the timer is a single-shot timer
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint64 GLenum void * handle
GLenum GLuint GLsizei const GLenum * props
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
GLenum GLenum GLsizei void * row
QQmlContext * qmlContext(const QObject *obj)
QT_BEGIN_NAMESPACE const char * kModelItemTag
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
QSqlQueryModel * model
[16]
myObject disconnect()
[26]
bool contains(const AT &t) const noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent