A custom proxy model for sorting items in views.
More...
#include <CustomProxyModel.h>
|
| CustomProxyModel (QObject *parent=nullptr) |
| Constructs a CustomProxyModel object. More...
|
|
bool | lessThan (const QModelIndex &left, const QModelIndex &right) const override |
| Returns whether the item referred to by the given index is less than the item referred to by the given other index. Used for sorting. Sorts mount points before non-mount points. More...
|
|
void | setFilteringEnabled (bool enable) |
| Toggles the filtering behavior on/off. More...
|
|
void | setSourceModel (QAbstractItemModel *sourceModel) override |
| Sets the source model for the proxy model to sourceModel. We override this because we read the hidden file names from the .hidden file when the source model is set. More...
|
|
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
|
Qt::DropActions | supportedDropActions () const override |
|
Qt::DropActions | supportedDragActions () const override |
|
Qt::ItemFlags | flags (const QModelIndex &index) const override |
|
bool | canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override |
|
bool | isFilteringEnabled () const |
|
|
bool | filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override |
| Returns whether the item in the row indicated by the given source row and source parent should be included in the model or whether it should be filtered out. More...
|
|
A custom proxy model for sorting items in views.
The CustomProxyModel class provides a custom proxy model for sorting items in views, such as QTreeView or QListView. It extends QSortFilterProxyModel and adds custom behavior like sorting mount points before non-mount points on the desktop.
◆ CustomProxyModel()
CustomProxyModel::CustomProxyModel |
( |
QObject * |
parent = nullptr | ) |
|
◆ filterAcceptsRow()
bool CustomProxyModel::filterAcceptsRow |
( |
int |
sourceRow, |
|
|
const QModelIndex & |
sourceParent |
|
) |
| const |
|
overrideprotected |
Returns whether the item in the row indicated by the given source row and source parent should be included in the model or whether it should be filtered out.
- Parameters
-
sourceRow | The source row. |
sourceParent | The source parent. |
- Returns
- True if the item should be included; otherwise returns false.
◆ lessThan()
bool CustomProxyModel::lessThan |
( |
const QModelIndex & |
left, |
|
|
const QModelIndex & |
right |
|
) |
| const |
|
override |
Returns whether the item referred to by the given index is less than the item referred to by the given other index. Used for sorting. Sorts mount points before non-mount points.
- Parameters
-
left | The left index. |
right | The right index. |
- Returns
- True if the item referred to by the left index is less than the item referred to by the right index; otherwise returns false. Mount points come before non-mount points on the desktop.
◆ setFilteringEnabled()
void CustomProxyModel::setFilteringEnabled |
( |
bool |
enable | ) |
|
Toggles the filtering behavior on/off.
- Parameters
-
enable | True to enable filtering, false to disable it. |
◆ setSourceModel()
void CustomProxyModel::setSourceModel |
( |
QAbstractItemModel * |
sourceModel | ) |
|
|
override |
Sets the source model for the proxy model to sourceModel. We override this because we read the hidden file names from the .hidden file when the source model is set.
- Parameters
-
sourceModel | The source model. |
The documentation for this class was generated from the following files: