10#ifndef CACHE_PROXY_MODEL_H
11#define CACHE_PROXY_MODEL_H
15#include <QIdentityProxyModel>
16#include <QStandardItemModel>
42 QVariant
data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const;
49 Qt::ItemFlags
flags(
const QModelIndex &index)
const;
58 QVariant
headerData(
int section, Qt::Orientation orientation,
59 int role = Qt::DisplayRole)
const;
66 int rowCount(
const QModelIndex &parent = QModelIndex())
const;
73 int columnCount(
const QModelIndex &parent = QModelIndex())
const;
83 mutable QStandardItemModel cache;
89 bool hasModel()
const {
return sourceModel() != &cache; }
95 void resetCacheModel();
Caches any data read access to the source model, returning an older copy if the source model is inval...
Definition cache_proxy_model.h:26
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns under the given parent.
Definition cache_proxy_model.cpp:66
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Retrieves data from the model for the given index and role.
Definition cache_proxy_model.cpp:16
void setSourceModel(QAbstractItemModel *newSourceModel)
Sets a new source model to be cached and proxied.
Definition cache_proxy_model.cpp:81
Qt::ItemFlags flags(const QModelIndex &index) const
Retrieves the item flags for the given index.
Definition cache_proxy_model.cpp:33
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Retrieves the header data for a given section, orientation, and role.
Definition cache_proxy_model.cpp:43
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of rows under the given parent.
Definition cache_proxy_model.cpp:55