QAbstractItemModelReplica Class | Qt Remote Objects 6.4.1

- Qt 6.4
- Qt Remote Objects
- C++ Classes
- QAbstractItemModelReplica
- Qt 6.4.1 Reference Documentation

# QAbstractItemModelReplica Class

The QAbstractItemModelReplica class serves as a convenience class for Replicas of Sources based on QAbstractItemModel. More...

Header: | #include <QAbstractItemModelReplica>
CMake: | find_package(Qt6 REQUIRED COMPONENTS RemoteObjects) target_link_libraries(mytarget PRIVATE Qt6::RemoteObjects)
qmake: | QT += remoteobjects

- List of all members, including inherited members

## Public Functions

virtual | ~QAbstractItemModelReplica() override
QList<int> | availableRoles() const
bool | hasData(const QModelIndex &index, int role) const
bool | isInitialized() const
int | rootCacheSize() const
QItemSelectionModel * | selectionModel() const
void | setRootCacheSize(int rootCacheSize)

## Reimplemented Public Functions

virtual int | columnCount(const QModelIndex &parent = QModelIndex()) const override
virtual QVariant | data(const QModelIndex &index, int role = Qt::DisplayRole) const override
virtual Qt::ItemFlags | flags(const QModelIndex &index) const override
virtual bool | hasChildren(const QModelIndex &parent = QModelIndex()) const override
virtual QVariant | headerData(int section, Qt::Orientation orientation, int role) const override
virtual QModelIndex | index(int row, int column, const QModelIndex &parent = QModelIndex()) const override
virtual void | multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const override
virtual QModelIndex | parent(const QModelIndex &index) const override
virtual QHash<int, QByteArray> | roleNames() const override
virtual int | rowCount(const QModelIndex &parent = QModelIndex()) const override
virtual bool | setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override

## Signals

void | initialized()

## Detailed Description

QAbstractItemModelReplica makes replicating QAbstractItemModels more efficient by employing caching and pre-fetching.

See also QAbstractItemModel.

## Member Function Documentation

### `[signal]` void QAbstractItemModelReplica::initialized()

The initialized signal is emitted the first time we receive data from the Source.

See also isInitialized().

### `[override virtual]` QAbstractItemModelReplica::~QAbstractItemModelReplica()

Destroys the instance of QAbstractItemModelReplica.

### QList<int> QAbstractItemModelReplica::availableRoles() const

Returns a list of available roles.

See also QAbstractItemModel.

### `[override virtual]` int QAbstractItemModelReplica::columnCount(const QModelIndex &parent = QModelIndex()) const

### `[override virtual]` QVariant QAbstractItemModelReplica::data(const QModelIndex &index, int role = Qt::DisplayRole) const

Returns the role data for the item at index if available in cache. A default-constructed QVariant is returned if the index is invalid, the role is not one of the available roles, the Replica is uninitialized or the data was not available. If the data was not available in cache it will be requested from the Source.

See also QAbstractItemModel::data(), hasData(), setData(), and isInitialized().

### `[override virtual]` Qt::ItemFlags QAbstractItemModelReplica::flags(const QModelIndex &index) const

### `[override virtual]` bool QAbstractItemModelReplica::hasChildren(const QModelIndex &parent = QModelIndex()) const

### bool QAbstractItemModelReplica::hasData(const QModelIndex &index, int role) const

Returns `true` if there exists role data for the item at index. Returns `false` in any other case.

### `[override virtual]` QVariant QAbstractItemModelReplica::headerData(int section, Qt::Orientation orientation, int role) const

Returns the data for the given role and section in the header with the specified orientation.

If the data is not available it will be requested from the Source.

See also QAbstractItemModel::headerData().

### `[override virtual]` QModelIndex QAbstractItemModelReplica::index(int row, int column, const QModelIndex &parent = QModelIndex()) const

### bool QAbstractItemModelReplica::isInitialized() const

Returns `true` if this replica has been initialized with data from the Source object. Returns `false` otherwise.

See also initialized().

### `[override virtual]` void QAbstractItemModelReplica::multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const

### `[override virtual]` QModelIndex QAbstractItemModelReplica::parent(const QModelIndex &index) const

### `[override virtual]` QHash<int, QByteArray> QAbstractItemModelReplica::roleNames() const

### int QAbstractItemModelReplica::rootCacheSize() const

Returns the current size of the internal cache. By default this is set to the value of the `QTRO_NODES_CACHE_SIZE` environment variable, or a default of `1000` if it is invalid or doesn't exist.

See also setRootCacheSize().

### `[override virtual]` int QAbstractItemModelReplica::rowCount(const QModelIndex &parent = QModelIndex()) const

### QItemSelectionModel *QAbstractItemModelReplica::selectionModel() const

Returns a pointer to the QItemSelectionModel for the current QAbstractItemModelReplica.

### `[override virtual]` bool QAbstractItemModelReplica::setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole)

See also data().

### void QAbstractItemModelReplica::setRootCacheSize(int rootCacheSize)

Sets the size of the internal cache to rootCacheSize.

See also rootCacheSize().