/*! From QSortFilterProxyModel. Called for each index in the source model. Returns true if the index satisfies the filter criteria. \sa QSortFilterProxyModel. */ bool ClockCityListProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent) const { OstTraceFunctionEntry0( CLOCKCITYLISTPROXYMODEL_FILTERACCEPTSROW_ENTRY ); // Get the model index of the source model. QModelIndex modelIndex = sourceModel()->index( sourceRow, filterKeyColumn(), sourceParent); if (!modelIndex.isValid()) { OstTraceFunctionExit0( CLOCKCITYLISTPROXYMODEL_FILTERACCEPTSROW_EXIT ); return false; } // Get the data corresponding to that model. int role = filterRole(); QString filterExp(filterRegExp().pattern()); QVariant modelData = sourceModel()->data(modelIndex, role); // We just have one item and search is done only on data set with // Qt::DisplayRole. if (Qt::UserRole + 100 == role) { QString string = modelData.value<QString>(); if (string.contains(filterExp)) { OstTraceFunctionExit0( DUP1_CLOCKCITYLISTPROXYMODEL_FILTERACCEPTSROW_EXIT ); return true; } } return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); }
/** * Check if the source_row index is identical to the previous index */ bool DeduplicateProxy::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const { // Get both source QModelIndex and compare them if (source_row > 0) { const QModelIndex idx = sourceModel()->index(source_row, filterKeyColumn(), source_parent); // It is correct to assume sourceModelIndex - 1 will be part of the same group if (idx.row() > 0) { const QModelIndex sibling = sourceModel()->index(idx.row() - 1, idx.column(), idx.parent()); bool accept = false; // Allow to filter with more than one role, apply only if they exist foreach(const int r, d_ptr->m_lOtherRoles) { const QVariant v1 = idx.data (r); const QVariant v2 = sibling.data(r); // Yes, this is an "=", not "==" if ((accept = !(v1.isValid() && v2.isValid() && (v1 == v2)))) break; } return accept || idx.data(filterRole()) != sibling.data(filterRole()); } } return true; }
bool RecipeListProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { bool accept = QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); bool matches = accept; if (!recipelist && tags.isEmpty()) return matches; if (filterKeyColumn() == -1) { int column_count = sourceModel()->columnCount(sourceParent); for (int column = 0; column < column_count; ++column) { QModelIndex source_index = sourceModel()->index(sourceRow, column, sourceParent); Reagent *r = sourceModel()->data(source_index, reagentRole).value<Reagent*>(); if(recipelist) { if(r->recipelist != recipelist->name || r->fromFile != recipelist->filename) { matches = false; } } if(tags.isEmpty() || !r->matches_tags(tags)) { matches = false; } } } else { QModelIndex source_index = sourceModel()->index(sourceRow, filterKeyColumn(), sourceParent); if (source_index.isValid()) { Reagent *r = sourceModel()->data(source_index, reagentRole).value<Reagent*>(); Q_ASSERT(r); if(recipelist) { if(r->recipelist != recipelist->name || r->fromFile != recipelist->filename) { matches = false; } } if(!tags.isEmpty() && !r->matches_tags(tags)) { matches = false; } } } return matches; }
bool SearchModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { if (filterRegExp().isEmpty()) return false; QModelIndex source_index = sourceModel()->index(source_row, filterKeyColumn(), source_parent); QString key = sourceModel()->data(source_index, filterRole()).toString(); return key.contains(filterRegExp()); }
bool QtSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const { if (sourceParent.isValid()) { return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); } QModelIndex index = sourceModel()->index(sourceRow, filterKeyColumn(), sourceParent); bool visibleChild = false; for (int i = 0; i < sourceModel()->rowCount(index); i++) { visibleChild |= filterAcceptsRow(i, index); } return visibleChild; }
int QSortFilterProxyModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractProxyModel::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 20) qt_static_metacall(this, _c, _id, _a); _id -= 20; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QRegExp*>(_v) = filterRegExp(); break; case 1: *reinterpret_cast< int*>(_v) = filterKeyColumn(); break; case 2: *reinterpret_cast< bool*>(_v) = dynamicSortFilter(); break; case 3: *reinterpret_cast< Qt::CaseSensitivity*>(_v) = filterCaseSensitivity(); break; case 4: *reinterpret_cast< Qt::CaseSensitivity*>(_v) = sortCaseSensitivity(); break; case 5: *reinterpret_cast< bool*>(_v) = isSortLocaleAware(); break; case 6: *reinterpret_cast< int*>(_v) = sortRole(); break; case 7: *reinterpret_cast< int*>(_v) = filterRole(); break; } _id -= 8; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setFilterRegExp(*reinterpret_cast< QRegExp*>(_v)); break; case 1: setFilterKeyColumn(*reinterpret_cast< int*>(_v)); break; case 2: setDynamicSortFilter(*reinterpret_cast< bool*>(_v)); break; case 3: setFilterCaseSensitivity(*reinterpret_cast< Qt::CaseSensitivity*>(_v)); break; case 4: setSortCaseSensitivity(*reinterpret_cast< Qt::CaseSensitivity*>(_v)); break; case 5: setSortLocaleAware(*reinterpret_cast< bool*>(_v)); break; case 6: setSortRole(*reinterpret_cast< int*>(_v)); break; case 7: setFilterRole(*reinterpret_cast< int*>(_v)); break; } _id -= 8; } else if (_c == QMetaObject::ResetProperty) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 8; } #endif // QT_NO_PROPERTIES return _id; }
bool ShortcutsFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { if (filterRegExp().isEmpty()) return true; if (source_parent.isValid()) { QModelIndex index = source_parent.child(source_row, filterKeyColumn()); QString data = sourceModel()->data(index, filterRole()).toString(); return data.contains(filterRegExp()); } else { QModelIndex index = sourceModel()->index(source_row, filterKeyColumn()); for (int row = 0; row < sourceModel()->rowCount(index); row++) { if (filterAcceptsRow(row, index)) return true; } } return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); }
bool OnlyLeavesProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { if(!source_parent.isValid()) return false; QModelIndex index = sourceModel()->index(source_row, filterKeyColumn(), source_parent); if(index.isValid()) { if((sourceModel()->data(index, TreeModel::ChildrenAreLeavesRole).toBool())) return true; } return false; }
bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index = sourceModel()->index(sourceRow, filterKeyColumn(), sourceParent); if (index.data().type()==QVariant::UserType) { coordonnee coord = index.data().value<coordonnee>(); return coord.toQString().contains(filterRegExp()); } else { return QSortFilterProxyModel::filterAcceptsRow(sourceRow,sourceParent); } }
bool SortFilterModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const { if (m_filterCallback.isCallable()) { QJSValueList args; args << QJSValue(source_row); const QModelIndex idx = sourceModel()->index(source_row, filterKeyColumn(), source_parent); QQmlEngine *engine = QQmlEngine::contextForObject(this)->engine(); args << engine->toScriptValue<QVariant>(idx.data(m_roleIds.value(m_filterRole))); return const_cast<SortFilterModel *>(this)->m_filterCallback.call(args).toBool(); } return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); }
bool omni::ui::tree_sort_filter_proxy_model::filterAcceptsRow (int sourceRow, const QModelIndex & sourceParent) const { // If this row matches, return true: if (filterAcceptsRowExactly (sourceRow, sourceParent)) { return true; } // Now check whether any of this row's child rows matches: QModelIndex row = sourceModel ()->index (sourceRow, filterKeyColumn (), sourceParent); for (int i = 0; i < sourceModel ()->rowCount (row); ++ i) { if (filterAcceptsRow (i, row)) { return true; } } // Neither this row, nor any children, match. return false; }
bool BtModuleNameFilterProxyModel::filterAcceptsRow(int row, const QModelIndex &p) const { if (!m_enabled) return true; const QAbstractItemModel *m(sourceModel()); Q_ASSERT(m != 0); QModelIndex itemIndex(m->index(row, filterKeyColumn(), p)); int numChildren(m->rowCount(itemIndex)); if (numChildren == 0) { return QSortFilterProxyModel::filterAcceptsRow(row, p); } else { for (int i(0); i < numChildren; i++) { if (filterAcceptsRow(i, itemIndex)) return true; } return false; } }
// this solution was taken from: // http://stackoverflow.com/questions/250890/using-qsortfilterproxymodel-with-a-tree-model bool TagSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { if(filterRegExp().isEmpty() == false) { QModelIndex source_index = sourceModel()->index(source_row, filterKeyColumn(), source_parent) ; if(source_index.isValid()) { int nb = sourceModel()->rowCount(source_index) ; for(int i = 0; i < nb; ++i) if(filterAcceptsRow(i, source_index)) return true; QString key = sourceModel()->data(source_index, filterRole()).toString(); return key.contains(filterRegExp()); } } return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent) ; }
bool BackupSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index1 = sourceModel()->index(sourceRow, filterKeyColumn(), sourceParent); return sourceModel()->data(index1).toString().contains(filterRegExp()); }
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override { const QModelIndex srcIdx = sourceModel()->index(source_row, filterKeyColumn(), source_parent); return !srcIdx.data((int)Media::TextRecording::Role::IsRead).toBool(); }