BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FilterPropertyProxy Class Reference

The FilterPropertyProxy class filters out all PropertyItem's and similar from SessionModel to have only top level items. More...

Inheritance diagram for FilterPropertyProxy:
[legend]
Collaboration diagram for FilterPropertyProxy:
[legend]

Public Member Functions

 FilterPropertyProxy (int columns, QObject *parent=0)
 
int columnCount (const QModelIndex &parent) const
 

Static Public Member Functions

static QModelIndex toSourceIndex (QModelIndex index)
 

Protected Member Functions

bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const
 

Private Attributes

int m_columns
 

Detailed Description

The FilterPropertyProxy class filters out all PropertyItem's and similar from SessionModel to have only top level items.

Definition at line 24 of file FilterPropertyProxy.h.

Constructor & Destructor Documentation

◆ FilterPropertyProxy()

FilterPropertyProxy::FilterPropertyProxy ( int  columns,
QObject *  parent = 0 
)
inline

Definition at line 28 of file FilterPropertyProxy.h.

29  : QSortFilterProxyModel(parent), m_columns(columns)
30  {
31  }

Member Function Documentation

◆ columnCount()

int FilterPropertyProxy::columnCount ( const QModelIndex &  parent) const

Definition at line 18 of file FilterPropertyProxy.cpp.

19 {
20  Q_UNUSED(parent);
21  return m_columns;
22 }

References m_columns.

◆ filterAcceptsRow()

bool FilterPropertyProxy::filterAcceptsRow ( int  sourceRow,
const QModelIndex &  sourceParent 
) const
protected

Definition at line 33 of file FilterPropertyProxy.cpp.

34 {
35  QModelIndex index = sourceModel()->index(sourceRow, 1, sourceParent);
36  if (!sourceParent.isValid())
37  return true;
38  const QString modelType = index.data(SessionFlags::ModelTypeRole).toString();
39  if (modelType == "Property" || modelType == "GroupProperty" || modelType == "Vector")
40  return false;
41 
42  return true; //! sourceModel()->data(index, Qt::DisplayRole).isValid();
43 }

References SessionFlags::ModelTypeRole.

◆ toSourceIndex()

QModelIndex FilterPropertyProxy::toSourceIndex ( QModelIndex  index)
static

Definition at line 24 of file FilterPropertyProxy.cpp.

25 {
26  FilterPropertyProxy* proxy =
27  dynamic_cast<FilterPropertyProxy*>(const_cast<QAbstractItemModel*>(index.model()));
28  if (proxy)
29  return proxy->mapToSource(index);
30  return index;
31 }
The FilterPropertyProxy class filters out all PropertyItem's and similar from SessionModel to have on...

Referenced by SampleTreeWidget::addItem(), ParameterTuningDelegate::createEditor(), SampleTreeWidget::deleteItem(), ParameterTuningModel::flags(), ParameterTuningModel::getParameterItem(), SampleTreeWidget::showContextMenu(), and RealSpaceCanvas::updateToSelection().

Member Data Documentation

◆ m_columns

int FilterPropertyProxy::m_columns
private

Definition at line 40 of file FilterPropertyProxy.h.

Referenced by columnCount().


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