NDEVR
API Documentation
DesignSortFilterProxyModel

Provides the ability to pull data from a DesignObjectLookup for display in tables within the NDEVR API and filter and sort it. More...

Collaboration diagram for DesignSortFilterProxyModel:
[legend]

Public Member Functions

 DesignSortFilterProxyModel (DesignTableModel *model, QObject *parent=nullptr)
 Constructs a DesignSortFilterProxyModel wrapping the given table model.
ModelTableColumnSpec columnSpec (const QModelIndex &index)
 Returns the column specification for the given proxy index.
Model getModel (const QModelIndex &index)
 Returns the Model for the row of the given proxy index.
UUID getUUID (const QModelIndex &index)
 Returns the UUID for the row of the given proxy index.
bool isEditable () const
 Returns whether the table is currently editable.
bool isMaterialIndex (const QModelIndex &index) const
 Returns whether the given proxy index represents a material column.
bool isSpecialCallbackIndex (const QModelIndex &index) const
 Returns whether the given proxy index represents a custom callback column.
DesignTableModelmodel ()
 Returns the underlying DesignTableModel.
QTModelManagermodelManager () const
 Returns the model manager from the underlying table model.
void onSelected (const QModelIndex &index, const QRect &rect)
 Handles a row selection event on the proxy model.
void searchByParameterChangedSignal ()
 Emitted when the search-by parameter changes.
TranslatedString searchByTitle () const
 Returns the display title of the current search parameter.
const std::function< void(Model, PopupInfo)> & selectedCallback () const
 Returns the current selection callback.
void setColumnEditable (uint04 column, bool is_editable)
 Sets whether a specific column is editable.
void setIsEditable (bool is_editable)
 Sets whether the table is editable.
void setSearchParameter (const ModelTableColumnSpec &search_parameter)
 Sets the column parameter used for search filtering.
void setSearchString (const StringView &search_string)
 Sets the search string used for filtering rows.
void setSelectedCallback (const std::function< void(Model, PopupInfo)> &callback)
 Sets the callback invoked when a row is selected.
void setSortCallback (const std::function< bool(const Model &a, const Model &b)> &callback)
 Sets a custom sort comparison callback for ordering rows.
void sort (int column, Qt::SortOrder order=Qt::DescendingOrder) override
 Sorts the table by the given column.
void sort (Qt::SortOrder order=Qt::DescendingOrder)
 Sorts the table using the current sort specifications.
void sortBy (const Buffer< ModelTableColumnSpec > &specs, Qt::SortOrder order=Qt::DescendingOrder)
 Sorts the table by multiple column specifications as tiebreakers.
void sortBy (ModelTableColumnSpec spec, Qt::SortOrder order=Qt::DescendingOrder)
 Sorts the table by a single column specification.
void sortBy (NDPO property, Qt::SortOrder order=Qt::DescendingOrder)
 Sorts the table by the given NDPO property.

Protected Member Functions

ModelTableColumnSpec currentSearchParameter () const
 Returns the currently active search parameter column specification.
virtual bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override
 Returns whether the row at the given source index passes the current filter.
virtual bool lessThan (const QModelIndex &left, const QModelIndex &right) const override
 Compares two source model indices for sorting.
bool modelIsShown (const DynamicPointer< QTDesignObject > &a) const
 Returns whether the given design object should be shown after filtering.

Protected Attributes

ModelTableColumnSpec m_current_search_parameter
 The currently active search parameter.
DesignTableModelm_design_model
 The underlying DesignTableModel.
ModelTableColumnSpec m_search_parameter
 The user-configured search parameter.
String m_search_string
 The current search/filter text.
std::function< void(Model, PopupInfo)> m_selected_callback
 Callback invoked when a row is selected.
Buffer< ModelTableColumnSpecm_sort_by
 The column specifications used for sorting.
std::function< bool(const Model &a, const Model &b)> m_sort_function
 Custom sort comparison function.

Detailed Description

Provides the ability to pull data from a DesignObjectLookup for display in tables within the NDEVR API and filter and sort it.


Definition at line 522 of file DesignTableModel.h.

Constructor & Destructor Documentation

◆ DesignSortFilterProxyModel()

DesignSortFilterProxyModel::DesignSortFilterProxyModel ( DesignTableModel * model,
QObject * parent = nullptr )
explicit

Constructs a DesignSortFilterProxyModel wrapping the given table model.

Parameters
[in]modelThe underlying DesignTableModel.
[in]parentThe parent QObject.

References model().

Member Function Documentation

◆ columnSpec()

ModelTableColumnSpec DesignSortFilterProxyModel::columnSpec ( const QModelIndex & index)

Returns the column specification for the given proxy index.

Parameters
[in]indexThe proxy model index.
Returns
The ModelTableColumnSpec for that column.

◆ currentSearchParameter()

ModelTableColumnSpec DesignSortFilterProxyModel::currentSearchParameter ( ) const
protected

Returns the currently active search parameter column specification.

Returns
The ModelTableColumnSpec used for searching.

◆ filterAcceptsRow()

virtual bool DesignSortFilterProxyModel::filterAcceptsRow ( int sourceRow,
const QModelIndex & sourceParent ) const
overrideprotectedvirtual

Returns whether the row at the given source index passes the current filter.

Parameters
[in]sourceRowThe row in the source model.
[in]sourceParentThe parent index in the source model.
Returns
True if the row is accepted.

◆ getModel()

Model DesignSortFilterProxyModel::getModel ( const QModelIndex & index)

Returns the Model for the row of the given proxy index.

Parameters
[in]indexThe proxy model index.
Returns
The Model at that row.

◆ getUUID()

UUID DesignSortFilterProxyModel::getUUID ( const QModelIndex & index)

Returns the UUID for the row of the given proxy index.

Parameters
[in]indexThe proxy model index.
Returns
The UUID at that row.

◆ isEditable()

bool DesignSortFilterProxyModel::isEditable ( ) const

Returns whether the table is currently editable.

Returns
True if editable.

◆ isMaterialIndex()

bool DesignSortFilterProxyModel::isMaterialIndex ( const QModelIndex & index) const
nodiscard

Returns whether the given proxy index represents a material column.

Parameters
[in]indexThe proxy model index.
Returns
True if it is a material index.

◆ isSpecialCallbackIndex()

bool DesignSortFilterProxyModel::isSpecialCallbackIndex ( const QModelIndex & index) const
nodiscard

Returns whether the given proxy index represents a custom callback column.

Parameters
[in]indexThe proxy model index.
Returns
True if it is a special callback index.

◆ lessThan()

virtual bool DesignSortFilterProxyModel::lessThan ( const QModelIndex & left,
const QModelIndex & right ) const
overrideprotectedvirtual

Compares two source model indices for sorting.

Parameters
[in]leftThe left source index.
[in]rightThe right source index.
Returns
True if left sorts before right.

◆ model()

DesignTableModel * DesignSortFilterProxyModel::model ( )

Returns the underlying DesignTableModel.

Returns
A pointer to the DesignTableModel.

Referenced by DesignSortFilterProxyModel().

◆ modelIsShown()

bool DesignSortFilterProxyModel::modelIsShown ( const DynamicPointer< QTDesignObject > & a) const
protected

Returns whether the given design object should be shown after filtering.

Parameters
[in]aThe design object to check.
Returns
True if the object passes the filter.

◆ modelManager()

QTModelManager * DesignSortFilterProxyModel::modelManager ( ) const
inlinenodiscard

Returns the model manager from the underlying table model.

Returns
A pointer to the QTModelManager.

Definition at line 637 of file DesignTableModel.h.

References m_design_model.

◆ onSelected()

void DesignSortFilterProxyModel::onSelected ( const QModelIndex & index,
const QRect & rect )

Handles a row selection event on the proxy model.

Parameters
[in]indexThe proxy model index of the selected row.
[in]rectThe bounding rectangle of the selected cell.

◆ searchByTitle()

TranslatedString DesignSortFilterProxyModel::searchByTitle ( ) const

Returns the display title of the current search parameter.

Returns
The translated search-by title.

◆ selectedCallback()

const std::function< void(Model, PopupInfo)> & DesignSortFilterProxyModel::selectedCallback ( ) const
inlinenodiscard

Returns the current selection callback.

Returns
A const reference to the selection callback function.

Definition at line 652 of file DesignTableModel.h.

References m_selected_callback.

◆ setColumnEditable()

void DesignSortFilterProxyModel::setColumnEditable ( uint04 column,
bool is_editable )

Sets whether a specific column is editable.

Parameters
[in]columnThe column index.
[in]is_editableWhether editing is allowed for that column.

◆ setIsEditable()

void DesignSortFilterProxyModel::setIsEditable ( bool is_editable)

Sets whether the table is editable.

Parameters
[in]is_editableWhether editing is allowed.

◆ setSearchParameter()

void DesignSortFilterProxyModel::setSearchParameter ( const ModelTableColumnSpec & search_parameter)

Sets the column parameter used for search filtering.

Parameters
[in]search_parameterThe column spec to search against.

◆ setSearchString()

void DesignSortFilterProxyModel::setSearchString ( const StringView & search_string)

Sets the search string used for filtering rows.

Parameters
[in]search_stringThe text to filter by.

◆ setSelectedCallback()

void DesignSortFilterProxyModel::setSelectedCallback ( const std::function< void(Model, PopupInfo)> & callback)
inline

Sets the callback invoked when a row is selected.

Parameters
[in]callbackThe callback receiving the selected Model and popup info.

Definition at line 642 of file DesignTableModel.h.

References m_selected_callback.

◆ setSortCallback()

void DesignSortFilterProxyModel::setSortCallback ( const std::function< bool(const Model &a, const Model &b)> & callback)

Sets a custom sort comparison callback for ordering rows.

Parameters
[in]callbackA comparison function returning true if a should appear before b.

◆ sort() [1/2]

void DesignSortFilterProxyModel::sort ( int column,
Qt::SortOrder order = Qt::DescendingOrder )
override

Sorts the table by the given column.

Parameters
[in]columnThe column index to sort by.
[in]orderThe sort order.

◆ sort() [2/2]

void DesignSortFilterProxyModel::sort ( Qt::SortOrder order = Qt::DescendingOrder)

Sorts the table using the current sort specifications.

Parameters
[in]orderThe sort order.

◆ sortBy() [1/3]

void DesignSortFilterProxyModel::sortBy ( const Buffer< ModelTableColumnSpec > & specs,
Qt::SortOrder order = Qt::DescendingOrder )

Sorts the table by multiple column specifications as tiebreakers.

Parameters
[in]specsThe column specifications to sort by in order of priority.
[in]orderThe sort order.

◆ sortBy() [2/3]

void DesignSortFilterProxyModel::sortBy ( ModelTableColumnSpec spec,
Qt::SortOrder order = Qt::DescendingOrder )

Sorts the table by a single column specification.

Parameters
[in]specThe column specification to sort by.
[in]orderThe sort order.

◆ sortBy() [3/3]

void DesignSortFilterProxyModel::sortBy ( NDPO property,
Qt::SortOrder order = Qt::DescendingOrder )

Sorts the table by the given NDPO property.

Parameters
[in]propertyThe property to sort by.
[in]orderThe sort order.

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