QIdentityProxyModel Class
QIdentityProxyModel クラスは、ソースモデルを変更せずにプロキシします。さらに...
ヘッダ | #include <QIdentityProxyModel> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
継承: | QAbstractProxyModel |
パブリック関数
QIdentityProxyModel(QObject *parent = nullptr) | |
virtual | ~QIdentityProxyModel() |
(since 6.8) bool | handleSourceDataChanges() const |
(since 6.8) bool | handleSourceLayoutChanges() const |
再実装パブリック関数
virtual int | columnCount(const QModelIndex &parent = QModelIndex()) const override |
virtual bool | dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
virtual QVariant | headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override |
virtual QModelIndex | index(int row, int column, const QModelIndex &parent = QModelIndex()) const override |
virtual bool | insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override |
virtual bool | insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override |
virtual QModelIndex | mapFromSource(const QModelIndex &sourceIndex) const override |
virtual QItemSelection | mapSelectionFromSource(const QItemSelection &selection) const override |
virtual QItemSelection | mapSelectionToSource(const QItemSelection &selection) const override |
virtual QModelIndex | mapToSource(const QModelIndex &proxyIndex) const override |
virtual QModelIndexList | match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const override |
virtual bool | moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) override |
virtual bool | moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override |
virtual QModelIndex | parent(const QModelIndex &child) const override |
virtual bool | removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override |
virtual bool | removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override |
virtual int | rowCount(const QModelIndex &parent = QModelIndex()) const override |
virtual void | setSourceModel(QAbstractItemModel *newSourceModel) override |
virtual QModelIndex | sibling(int row, int column, const QModelIndex &idx) const override |
保護された関数
(since 6.8) void | setHandleSourceDataChanges(bool b) |
(since 6.8) void | setHandleSourceLayoutChanges(bool b) |
詳細説明
QIdentityProxyModel は、ソート、フィルタリング、その他の変換を行わずに、ソースモデルの構造を正確に転送するために使用することができます。これは、A.I = A となる同一行列に似た概念です。
ソートやフィルタリングを行わないため、このクラスはソースモデルのdata() を変換するプロキシモデルに最も適しています。例えば、使用するフォントや背景色、ツールチップなどを定義するプロキシモデルを作成することができます。これによって、モデルの構造を作成するのと同じクラスで全てのデータ処理を実装する必要がなくなり、再利用可能なコンポーネントを作成するためにも使うことができます。
また、これは、ソースモデルがサードパーティから提供され、変更することができない場合に、データを変更する方法を提供します。
class DateFormatProxyModel : public QIdentityProxyModel { // ... void setDateFormatString(const QString &formatString) { m_formatString = formatString; } QVariant data(const QModelIndex &index, int role) const override { if (role != Qt::DisplayRole) return QIdentityProxyModel::data(index, role); const QModelIndex sourceIndex = mapToSource(index); const QDateTime dateTime = sourceModel()->data(sourceIndex, SourceClass::DateRole).toDateTime(); return dateTime.toString(m_formatString); } QMap<int, QVariant> itemData(const QModelIndex &proxyIndex) const override { QMap<int, QVariant> map = QIdentityProxyModel::itemData(proxyIndex); map[Qt::DisplayRole] = data(proxyIndex); return map; } private: QString m_formatString; };
QAbstractProxyModel 、モデル/ビュー・プログラミング、QAbstractItemModelも参照して ください。
メンバ関数のドキュメント
[explicit]
QIdentityProxyModel::QIdentityProxyModel(QObject *parent = nullptr)
与えられたparent で ID モデルを構築する。
[virtual noexcept]
QIdentityProxyModel::~QIdentityProxyModel()
このアイデンティティ・モデルを破壊する。
[override virtual]
int QIdentityProxyModel::columnCount(const QModelIndex &parent = QModelIndex()) const
再実装:QAbstractItemModel::columnCount(const QModelIndex &parent) const.
[override virtual]
bool QIdentityProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
再実装:QAbstractProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent).
[since 6.8]
bool QIdentityProxyModel::handleSourceDataChanges() const
このプロキシモデルがソースモデルのデータ変更を処理する場合はtrue
を返し、そうでない場合はfalse
を返します。
この関数は Qt 6.8 で導入されました。
setHandleSourceDataChanges()も参照してください 。
[since 6.8]
bool QIdentityProxyModel::handleSourceLayoutChanges() const
このプロキシモデルがソースモデルのレイアウト変更を処理する場合はtrue
を返し、そうでない場合はfalse
を返します。
この関数は Qt 6.8 で導入されました。
setHandleSourceLayoutChanges()も参照してください 。
[override virtual]
QVariant QIdentityProxyModel::headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
再実装:QAbstractProxyModel::headerData(int section, Qt::Orientation orientation, int role) const.
[override virtual]
QModelIndex QIdentityProxyModel::index(int row, int column, const QModelIndex &parent = QModelIndex()) const
再実装:QAbstractItemModel::index(int row, int column, const QModelIndex &parent) const.
[override virtual]
bool QIdentityProxyModel::insertColumns(int column, int count, const QModelIndex &parent = QModelIndex())
再実装:QAbstractItemModel::insertColumns(int column, int count, const QModelIndex &parent).
[override virtual]
bool QIdentityProxyModel::insertRows(int row, int count, const QModelIndex &parent = QModelIndex())
再実装:QAbstractItemModel::insertRows(int row, int count, const QModelIndex &parent).
[override virtual]
QModelIndex QIdentityProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
再実装:QAbstractProxyModel::mapFromSource(const QModelIndex &sourceIndex) const.
[override virtual]
QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection &selection) const
再実装:QAbstractProxyModel::mapSelectionFromSource(const QItemSelection &sourceSelection) const.
[override virtual]
QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection &selection) const
再実装:QAbstractProxyModel::mapSelectionToSource(const QItemSelection &proxySelection) const.
[override virtual]
QModelIndex QIdentityProxyModel::mapToSource(const QModelIndex &proxyIndex) const
再実装:QAbstractProxyModel::mapToSource(const QModelIndex &proxyIndex) const.
[override virtual]
QModelIndexList QIdentityProxyModel::match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
再実装:QAbstractItemModel::match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const.
[override virtual]
bool QIdentityProxyModel::moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild)
再実装:QAbstractItemModel::moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild).
[override virtual]
bool QIdentityProxyModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
再実装:QAbstractItemModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild).
[override virtual]
QModelIndex QIdentityProxyModel::parent(const QModelIndex &child) const
再実装:QAbstractItemModel::parent(const QModelIndex &index) const.
[override virtual]
bool QIdentityProxyModel::removeColumns(int column, int count, const QModelIndex &parent = QModelIndex())
再実装:QAbstractItemModel::removeColumns(int column, int count, const QModelIndex &parent).
[override virtual]
bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex &parent = QModelIndex())
再実装:QAbstractItemModel::removeRows(int row, int count, const QModelIndex &parent).
[override virtual]
int QIdentityProxyModel::rowCount(const QModelIndex &parent = QModelIndex()) const
再実装:QAbstractItemModel::rowCount(const QModelIndex &parent) const.
[protected, since 6.8]
void QIdentityProxyModel::setHandleSourceDataChanges(bool b)
b がtrue
の場合、このプロキシ・モデルはソース・モデルのデータ変更を(QAbstractItemModel::dataChanged
シグナルに接続して)処理します。
デフォルトでは、このプロキシモデルがソースモデルのデータ変更を処理します。
QIdentityProxyModel のサブクラスでは、ソース・モデルのデータ変更を特別に処理する必要がある場合、これをfalse
に設定すると便利です。
注意: このメソッドの呼び出しは、setSourceModel() を呼び出した後にのみ効果があります。
この関数は Qt 6.8 で導入されました。
handleSourceDataChanges()も参照してください 。
[protected, since 6.8]
void QIdentityProxyModel::setHandleSourceLayoutChanges(bool b)
b がtrue
の場合、このプロキシ・モデルは(QAbstractItemModel::layoutAboutToBeChanged
とQAbstractItemModel::layoutChanged
のシグナルに接続して)ソース・モデルのレイアウト変更を処理します。
デフォルトでは、このプロキシモデルがソースモデルのレイアウト変更を処理します。
QIdentityProxyModel のサブクラスでは、ソースモデルのレイアウト変更を特別に処理する必要がある場合、これをfalse
に設定すると便利です。
注意: このメソッドの呼び出しは、setSourceModel() を呼び出した後にのみ効果があります。
この関数は Qt 6.8 で導入されました。
handleSourceLayoutChanges()も参照してください 。
[override virtual]
void QIdentityProxyModel::setSourceModel(QAbstractItemModel *newSourceModel)
再実装:QAbstractProxyModel::setSourceModel(QAbstractItemModel *sourceModel).
[override virtual]
QModelIndex QIdentityProxyModel::sibling(int row, int column, const QModelIndex &idx) const
再実装:QAbstractProxyModel::sibling(int row, int column, const QModelIndex &idx) const.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.