LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
LC::Util::FlattenFilterModel Class Reference

Proxy model flattening a hierarchical model. More...

#include "flattenfiltermodel.h"

+ Inheritance diagram for LC::Util::FlattenFilterModel:
+ Collaboration diagram for LC::Util::FlattenFilterModel:

Public Member Functions

QModelIndex index (int, int, const QModelIndex &={}) const override
 Reimplemented from QAbstractItemModel. More...
 
QModelIndex parent (const QModelIndex &) const override
 Reimplemented from QAbstractItemModel. More...
 
int rowCount (const QModelIndex &parent={}) const override
 Reimplemented from QAbstractItemModel. More...
 
int columnCount (const QModelIndex &parent={}) const override
 Reimplemented from QAbstractItemModel. More...
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Reimplemented from QAbstractItemModel. More...
 
void SetSource (QAbstractItemModel *model)
 Sets the source model to model. More...
 

Protected Member Functions

virtual bool IsIndexAccepted (const QModelIndex &index) const
 Checks whether the given index should be included in the model. More...
 

Protected Attributes

QAbstractItemModel * Source_ = nullptr
 
QList< QPersistentModelIndex > SourceIndexes_
 

Detailed Description

Proxy model flattening a hierarchical model.

This model takes another model and folds its structure into a flat model, possibly filtering out some rows (via the IsIndexAccepted() method).

Since this model changes the structure of the source model quite a lot, it doesn't derive from QAbstractProxyModel.

Definition at line 33 of file flattenfiltermodel.h.

Member Function Documentation

◆ columnCount()

int LC::Util::FlattenFilterModel::columnCount ( const QModelIndex &  parent = {}) const
override

Reimplemented from QAbstractItemModel.

Definition at line 37 of file flattenfiltermodel.cpp.

References index(), and SourceIndexes_.

+ Here is the call graph for this function:

◆ data()

QVariant LC::Util::FlattenFilterModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
override

Reimplemented from QAbstractItemModel.

Definition at line 42 of file flattenfiltermodel.cpp.

References Source_.

◆ index()

QModelIndex LC::Util::FlattenFilterModel::index ( int  row,
int  column,
const QModelIndex &  parent = {} 
) const
override

Reimplemented from QAbstractItemModel.

Definition at line 19 of file flattenfiltermodel.cpp.

Referenced by columnCount(), and IsIndexAccepted().

+ Here is the caller graph for this function:

◆ IsIndexAccepted()

bool LC::Util::FlattenFilterModel::IsIndexAccepted ( const QModelIndex &  index) const
protectedvirtual

Checks whether the given index should be included in the model.

Reimplement this function in derived classes to provide filtering capabilities akin to QSortFilterProxyModel.

The children of the index will be checked even if this function returns false for index.

Note
The model operates on rows: that is, only the first column is checked, and index.column() == 0 will always hold.

The default implementation simply returns true.

Parameters
[in]indexThe index of the source model to check.
Returns
Whether the index should be included in the resulting model.

Definition at line 73 of file flattenfiltermodel.cpp.

References index(), parent(), Source_, and SourceIndexes_.

+ Here is the call graph for this function:

◆ parent()

QModelIndex LC::Util::FlattenFilterModel::parent ( const QModelIndex &  ) const
override

Reimplemented from QAbstractItemModel.

Definition at line 27 of file flattenfiltermodel.cpp.

References SourceIndexes_.

Referenced by IsIndexAccepted(), and rowCount().

+ Here is the caller graph for this function:

◆ rowCount()

int LC::Util::FlattenFilterModel::rowCount ( const QModelIndex &  parent = {}) const
override

Reimplemented from QAbstractItemModel.

Definition at line 32 of file flattenfiltermodel.cpp.

References parent().

+ Here is the call graph for this function:

◆ SetSource()

void LC::Util::FlattenFilterModel::SetSource ( QAbstractItemModel *  model)

Sets the source model to model.

If another source model has been set already, this function rebuilds the whole model, effectively resetting it.

Parameters
[in]modelThe new source model.

Definition at line 47 of file flattenfiltermodel.cpp.

Member Data Documentation

◆ Source_

QAbstractItemModel* LC::Util::FlattenFilterModel::Source_ = nullptr
protected

Definition at line 42 of file flattenfiltermodel.h.

Referenced by data(), and IsIndexAccepted().

◆ SourceIndexes_

QList<QPersistentModelIndex> LC::Util::FlattenFilterModel::SourceIndexes_
protected

Definition at line 43 of file flattenfiltermodel.h.

Referenced by columnCount(), IsIndexAccepted(), and parent().


The documentation for this class was generated from the following files: