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 override;
49 Qt::ItemFlags
flags(
const QModelIndex &index)
const override;
58 QVariant
headerData(
int section, Qt::Orientation orientation,
59 int role = Qt::DisplayRole)
const override;
66 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
73 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
83 mutable QStandardItemModel cache;
89 bool hasModel()
const {
return sourceModel() != &cache; }
95 void resetCacheModel();
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Retrieves the header data for a given section, orientation, and role.
Definition cache_proxy_model.cpp:43
void setSourceModel(QAbstractItemModel *newSourceModel) override
Sets a new source model to be cached and proxied.
Definition cache_proxy_model.cpp:81
CacheProxyModel(QObject *parent=0)
Constructs a new CacheProxyModel.
Definition cache_proxy_model.cpp:12
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
Definition cache_proxy_model.cpp:55
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns under the given parent.
Definition cache_proxy_model.cpp:66
Qt::ItemFlags flags(const QModelIndex &index) const override
Retrieves the item flags for the given index.
Definition cache_proxy_model.cpp:33
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Retrieves data from the model for the given index and role.
Definition cache_proxy_model.cpp:16