bool RKObjectListViewSettings::acceptRow (int source_row, const QModelIndex& source_parent) const { // RK_TRACE (APP); // always show the root item if (!source_parent.isValid ()) return true; RObject* object = static_cast<RObject*> (source_parent.internalPointer ()); // always show global env and search path if (!object) return true; if (!object->findChildByObjectModelIndex (source_row)) { return true; } object = object->findChildByObjectModelIndex (source_row); RK_ASSERT (object); if (!persistent_settings[ShowObjectsHidden]) { if (object->getShortName ().startsWith ('.')) return false; if (object == reinterpret_cast<RObject*> (RObjectList::getObjectList ()->orphanNamespacesObject ())) return false; } if (hide_functions && object->isType (RObject::Function)) return false; if (hide_non_functions && !object->isType (RObject::Function)) return false; if (filterRegExp ().isEmpty ()) return true; if (filter_on_name && object->getShortName ().contains (filterRegExp ())) return true; if (filter_on_label && object->getLabel ().contains (filterRegExp ())) return true; if (filter_on_class) { QStringList cnames = object->classNames (); for (int i = cnames.length () - 1; i >= 0; --i) { if (cnames[i].contains (filterRegExp ())) return true; } } return false; }
bool MimetypeFilterItemModel::filterHelper(QModelIndex& source_index) const { XdgMimeInfo* mimeInfo = source_index.data(MimeInfoRole).value<XdgMimeInfo*>(); if (!mimeInfo) { return false; } if (mimeInfo->mimeType().contains(filterRegExp())) { return true; } if (mimeInfo->comment().contains(filterRegExp())) { return true; } foreach (const QString pattern, mimeInfo->patterns()) { if (pattern.contains(filterRegExp())) { return true; } } return false; }
bool HelpProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); switch(filterRole()) { case KeywordRole: { QStringList keywordLst = sourceModel()->data(index, KeywordRole).toStringList(); foreach(QString str, keywordLst) { if(HelpUtils::findStr(str, filterRegExp().pattern()) != -1) { return true; } } return false; } case Qt::DisplayRole: { QString title = sourceModel()->data(index, Qt::DisplayRole).toString(); if(HelpUtils::findStr(title, filterRegExp().pattern()) != -1) { return true; } return false; } default: return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); } }
bool GlukSortFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { if (filterRegExp().pattern().length() < 2) { return true; } QModelIndex index = sourceModel()->index(source_row, 0, source_parent); TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); if (item->type() == TreeItem::Category) { if (index.data().toString().contains(filterRegExp())) { return true; } // WARNING: this is two levels only capable.. (FIXME) for (int i = 0; i < sourceModel()->rowCount(index); i++) { if (sourceModel()->index(i, 0, index).data().toString().contains(filterRegExp())) { return true; } } return false; } if (index.data().toString().contains(filterRegExp())) { return true; } return false; }
bool MailSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex from_index = sourceModel()->index(sourceRow, MailboxModel::From, sourceParent); QModelIndex subject_index = sourceModel()->index(sourceRow, MailboxModel::Subject, sourceParent); return sourceModel()->data(from_index).toString().contains(filterRegExp()) || sourceModel()->data(subject_index).toString().contains(filterRegExp()); }
bool ChildrenFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { // custom behaviour : if(filterRegExp().isEmpty()==false) { // get source-model index for current row QModelIndex source_index = sourceModel()->index(source_row, this->filterKeyColumn(), source_parent) ; if(source_index.isValid()) { // if any of children matches the filter, then current index matches the filter as well int i, nb = sourceModel()->rowCount(source_index) ; for(i=0; i<nb; ++i) { if(filterAcceptsRow(i, source_index)) { return true ; } } // check current index itself : QString key = sourceModel()->data(source_index, filterRole()).toString(); return key.contains(filterRegExp()) ; } } // parent call for initial behaviour return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent) ; }
bool AlbumProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const { if ( filterRegExp().isEmpty() ) return true; AlbumItem* pi = sourceModel()->itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) ); if ( !pi ) return false; const Tomahawk::album_ptr& q = pi->album(); QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts ); bool found = true; foreach( const QString& s, sl ) { if ( !q->name().contains( s, Qt::CaseInsensitive ) && !q->artist()->name().contains( s, Qt::CaseInsensitive ) ) { found = false; } } return found; }
bool FriendsProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const { if (filterRegExp ().isEmpty ()) return true; const auto& nick = sourceModel ()->index (sourceRow, CNickname, sourceParent).data ().toString (); const auto& name = sourceModel ()->index (sourceRow, CUsername, sourceParent).data ().toString (); const auto& birthday = sourceModel ()->index (sourceRow, CBirthday, sourceParent).data ().toString (); return nick.contains (filterRegExp ()) || name.contains (filterRegExp ()) || birthday.contains (filterRegExp ()); }
// Custom class for Avogadro to handle filtering files // Directories are at most 2 levels deep until we get to files bool SortFilterTreeProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const { // First we see if we're the source root node QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent); if (!sourceIndex.isValid() || !sourceParent.isValid()) return true; // viewer will handle filtering // Make sure the root is always accepted, or we become rootless // See http://stackoverflow.com/questions/3212392/qtreeview-qfilesystemmodel-setrootpath-and-qsortfilterproxymodel-with-regexp-fo if (m_sourceRoot.isValid() && sourceIndex == m_sourceRoot) { return true; // true root, always accept } // Now we see if we're a child of the root // If not, we accept -- only filter under *our* tree // Along the way, we'll see if a parent matches the filter if (sourceParent != m_sourceRoot) { bool childOfRoot = false; QModelIndex parent = sourceParent; for (int depth = 3; depth > 0; depth--) { if (sourceModel()->data(parent).toString().contains(filterRegExp())) return true; // a parent matches the pattern parent = parent.parent(); if (!parent.isValid()) return true; // tree view handles filtering, and we ascended too far if (parent == m_sourceRoot) { childOfRoot = true; break; } } // OK, we've gone up the tree, did we find our root? if (!childOfRoot) return true; } // else, sourceParent is a root, so we're good to filter // Check if the data for this row matches. If so, the default is to accept QString data = sourceModel()->data(sourceIndex).toString(); if (data.contains(filterRegExp())) return true; // Now we have to check the child nodes // We'll show the row if any child is accepted // (i.e., if a file matches, we'll show the directory path to it) // Try to fetchMore() first sourceModel()->fetchMore(sourceIndex); for(int i = 0; i < sourceModel()->rowCount(sourceIndex); ++i) { QModelIndex subRow = sourceModel()->index(i, 0, sourceIndex); if (!subRow.isValid()) continue; QString rowData = sourceModel()->data(subRow).toString(); if (rowData.contains(filterRegExp())) return true; } return false; // nothing matched }
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 ContactsSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex first_name_index = sourceModel()->index(sourceRow, AddressBookModel::FirstName, sourceParent); QModelIndex last_name_index = sourceModel()->index(sourceRow, AddressBookModel::LastName, sourceParent); QModelIndex id_index = sourceModel()->index(sourceRow, AddressBookModel::Id, sourceParent); return sourceModel()->data(first_name_index).toString().contains(filterRegExp()) || sourceModel()->data(last_name_index).toString().contains(filterRegExp()) || sourceModel()->data(id_index).toString().contains(filterRegExp()); }
// ************************************************************************* // FILTER // ************************************************************************* bool PropertiesFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent); QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent); return (sourceModel()->data(index0).toString().contains(filterRegExp()) || sourceModel()->data(index1).toString().contains(filterRegExp()) || sourceModel()->data(index2).toString().contains(filterRegExp())); }
bool PlayableProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const { PlayableItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) ); if ( !pi ) return false; if ( m_maxVisibleItems >= 0 && sourceRow > m_maxVisibleItems - 1 ) return false; if ( m_hideDupeItems ) { for ( int i = 0; i < sourceRow; i++ ) { PlayableItem* di = itemFromIndex( sourceModel()->index( i, 0, sourceParent ) ); if ( !di ) continue; bool b = ( pi->query() && pi->query()->equals( di->query() ) ) || ( pi->album() && pi->album() == di->album() ) || ( pi->artist() && pi->artist()->name() == di->artist()->name() ); if ( b && filterAcceptsRow( i, sourceParent ) ) return false; } } if ( pi->query() ) { const Tomahawk::query_ptr& q = pi->query()->displayQuery(); if ( q.isNull() ) // uh oh? filter out invalid queries i guess return false; Tomahawk::result_ptr r; if ( q->numResults() ) r = q->results().first(); if ( !m_showOfflineResults && ( r.isNull() || !r->isOnline() ) ) return false; if ( filterRegExp().isEmpty() ) return true; QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts ); foreach( QString s, sl ) { s = s.toLower(); if ( !q->artist().toLower().contains( s ) && !q->album().toLower().contains( s ) && !q->track().toLower().contains( s ) ) { return false; } } }
//! [3] bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent); QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent); return (sourceModel()->data(index0).toString().contains(filterRegExp()) || sourceModel()->data(index1).toString().contains(filterRegExp())) && dateInRange(sourceModel()->data(index2).toDate()); }
/** Redefined from MiamSortFilterProxyModel. */ bool UniqueLibraryFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QStandardItem *item = _model->itemFromIndex(_model->index(sourceRow, 1, sourceParent)); if (!item) { return false; } bool result = false; switch (item->type()) { case Miam::IT_Artist: if (MiamSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent)) { result = true; } else { QSqlQuery getArtist(*SqlDatabase::instance()); getArtist.prepare("SELECT * FROM tracks WHERE title LIKE ? AND artistId = ?"); getArtist.addBindValue("%" + filterRegExp().pattern() + "%"); getArtist.addBindValue(item->data(Miam::DF_ID).toUInt()); result = getArtist.exec() && getArtist.next(); } break; case Miam::IT_Album: if (MiamSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent)) { result = true; } else if (filterRegExp().indexIn(item->data(Miam::DF_Artist).toString()) != -1) { result = true; } else { QSqlQuery getAlbum(*SqlDatabase::instance()); getAlbum.prepare("SELECT * FROM tracks WHERE title LIKE ? AND albumId = ?"); getAlbum.addBindValue("%" + filterRegExp().pattern() + "%"); getAlbum.addBindValue(item->data(Miam::DF_ID).toUInt()); result = getAlbum.exec() && getAlbum.next(); } break; case Miam::IT_Track: if (MiamSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent)) { result = true; } else { result = filterRegExp().indexIn(item->data(Miam::DF_Artist).toString()) != -1 || filterRegExp().indexIn(item->data(Miam::DF_Album).toString()) != -1; } break; case Miam::IT_Separator: for (QModelIndex index : _topLevelItems.values(static_cast<SeparatorItem*>(item))) { if (filterAcceptsRow(index.row(), sourceParent)) { result = true; } } break; default: break; } return result; }
bool InfoKcmProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index=sourceModel()->index(sourceRow, 0, sourceParent); KcmTreeItem *indexItem = static_cast<KcmTreeItem*>(index.internalPointer()); if(indexItem->type() == KcmTreeItem::CATEGORY) { if(indexItem->childrenRegExp(filterRegExp()) == true) { return true; } } return ((indexItem->keywords().filter(filterRegExp()).count() > 0)); }
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const { QModelIndex aliasIndex = sourceModel()->index( sourceRow, AliasColumns::Alias, sourceParent ); QModelIndex commandIndex = sourceModel()->index( sourceRow, AliasColumns::Command, sourceParent ); QString alias, command; if ( !aliasIndex.isValid() || !commandIndex.isValid() ) // the column may not exist { alias = aliasIndex.data( filterRole() ).toString(); } command = commandIndex.data( filterRole() ).toString(); return alias.contains( filterRegExp() ) || command.contains( filterRegExp() ); return false; }
bool SortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourceParent*/) const { bool ok = true; if (ok && !m_columnPatterns.isEmpty() && !filterRegExp().isEmpty()) { ok = false; int col; foreach (col, m_columnPatterns) { ok = sourceModel()->index(sourceRow,col).data().toString().contains(filterRegExp()); if (ok) { break; } }
bool AdvQSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent); QModelIndex index1 = sourceModel()->index(source_row, 1, source_parent); QModelIndex index2 = sourceModel()->index(source_row, 2, source_parent); QModelIndex index3 = sourceModel()->index(source_row, 3, source_parent); if (showOffline == true) { return (sourceModel()->data(index0).toString().contains(filterRegExp()) || sourceModel()->data(index3).toString().contains(filterRegExp())); } else { return ((sourceModel()->data(index0).toString().contains(filterRegExp()) || sourceModel()->data(index3).toString().contains(filterRegExp())) && sourceModel()->data(index1).toString() != "offline"); } }
/** * @brief StoreModel::ShowThis * @param index * @return */ bool StoreModel::ShowThis(const QModelIndex index) const { bool retVal = false; //Gives you the info for number of childs with a parent if ( sourceModel()->rowCount(index) > 0 ) { for( int nChild = 0; nChild < sourceModel()->rowCount(index); nChild++) { QModelIndex childIndex = sourceModel()->index(nChild,0,index); if ( ! childIndex.isValid() ) break; retVal = ShowThis(childIndex); if (retVal) { break; } } } else { QModelIndex useIndex = sourceModel()->index(index.row(), 0, index.parent()); QString path = fs->filePath(useIndex); path.replace(QRegExp("\\.gpg$"), ""); path.replace(QRegExp("^" + store), ""); if ( ! path.contains(filterRegExp())) { retVal = false; } else { retVal = true; } } return retVal; }
bool WordsSortFilterProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const { QModelIndex wordIndex = sourceModel()->index(sourceRow, Hid_WordModel_Word, sourceParent); QModelIndex isLearnedIndex = sourceModel()->index(sourceRow, Hid_WordModel_IsLearned, sourceParent); if( !needShowLearned && sourceModel()->data( isLearnedIndex ).toBool() ) return false; QRegExp regexp = filterRegExp(); QString word = sourceModel()->data( wordIndex ).toString(); word.contains( regexp ); return sourceModel()->data( wordIndex ).toString().contains( filterRegExp() ); }
/*! 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); }
bool KSortFilterProxyModel::filterAcceptsRow ( int source_row, const QModelIndex & source_parent ) const { if( filterRegExp().isEmpty() ) return true; //Shortcut for common case if( QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent) ) return true; //one of our children might be accepted, so accept this row if one of our children are accepted. QModelIndex source_index = sourceModel()->index(source_row, 0, source_parent); for(int i = 0 ; i < sourceModel()->rowCount(source_index); i++) { if(filterAcceptsRow(i, source_index)) return true; } //one of our parents might be accepted, so accept this row if one of our parents is accepted. if(d_ptr->showAllChildren) { QModelIndex parent_index = source_parent; while(parent_index.isValid()) { int row = parent_index.row(); parent_index = parent_index.parent(); if(QSortFilterProxyModel::filterAcceptsRow(row, parent_index)) return true; } } return false; }
void OperatorProxyModel::setFilterPattern(const QString& pattern) { if (filterRegExp().pattern() == pattern) { return; } setFilterRegExp(QRegExp(pattern, Qt::CaseInsensitive, QRegExp::RegExp)); }
bool ImportsProxyModel::filterAcceptsRow(int row, const QModelIndex &parent) const { QModelIndex index = sourceModel()->index(row, 0, parent); auto import = index.data(ImportsModel::ImportDescriptionRole).value<ImportDescription>(); return import.name.contains(filterRegExp()); }
bool ChannelsListFilterProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const { const QModelIndex index = sourceModel()->index (sourceRow, 0, sourceParent); return sourceModel ()->data (index).toString ().contains (filterRegExp ()); }
void SortFilterModel::setFilterRegExp(const QString &exp) { if (exp == filterRegExp()) { return; } QSortFilterProxyModel::setFilterRegExp(QRegExp(exp, Qt::CaseInsensitive)); filterRegExpChanged(exp); }
bool DocumentFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); if( !index.isValid()) { return false; } bool accepted = false; // filter works on the document ID, the client name and the document type. const QRegExp filter = filterRegExp(); if( filter.pattern().isEmpty() ) { accepted = true; } else { const QModelIndex index0 = sourceModel()->index(sourceRow, DocumentModel::Document_Ident, sourceParent); const QString idStr = sourceModel()->data(index0).toString(); const QModelIndex index1 = sourceModel()->index(sourceRow, DocumentModel::Document_Type, sourceParent); const QString typeStr = sourceModel()->data(index1).toString(); const QModelIndex index2 = sourceModel()->index(sourceRow, DocumentModel::Document_ClientName, sourceParent); const QString clientNameStr = sourceModel()->data(index2).toString(); const QModelIndex index3 = sourceModel()->index(sourceRow, DocumentModel::Document_Whiteboard, sourceParent); const QString whiteboardStr = sourceModel()->data(index3).toString(); const QModelIndex index4 = sourceModel()->index(sourceRow, DocumentModel::Document_ProjectLabel, sourceParent); const QString projectStr = sourceModel()->data(index4).toString(); if( idStr.contains(filter) || typeStr.contains(filter) || clientNameStr.contains(filter) || whiteboardStr.contains(filter) || projectStr.contains(filter)) { accepted = true; } } // for the treeview, check all the children if( _enableTreeView ) { int rows = sourceModel()->rowCount(index); for (int row = 0; row < rows; row++) { if (filterAcceptsRow(row, index)) { accepted = true; } } } // if the entry is accepted so far, check if it is within the time limit if( accepted && m_MaxRows > -1 ) { const QModelIndex index = sourceModel()->index(sourceRow, DocumentModel::Document_CreationDateRaw, sourceParent); const QDate docDate = sourceModel()->data(index).toDate(); int dateDiff = docDate.daysTo(QDate::currentDate()); if( dateDiff > m_MaxRows ) { accepted = false; } } return accepted; }
bool QgsPluginSortFilterProxyModel::filterByPhrase( QModelIndex &index ) const { switch ( filterRole() ) { case PLUGIN_TAGS_ROLE: // search in tags only return sourceModel()->data( index, PLUGIN_TAGS_ROLE ).toString().contains( filterRegExp() ); case 0: // full search: name + description + tags + author return sourceModel()->data( index, PLUGIN_DESCRIPTION_ROLE ).toString().contains( filterRegExp() ) || sourceModel()->data( index, PLUGIN_AUTHOR_ROLE ).toString().contains( filterRegExp() ) || sourceModel()->data( index, Qt::DisplayRole ).toString().contains( filterRegExp() ) || sourceModel()->data( index, PLUGIN_TAGS_ROLE ).toString().contains( filterRegExp() ); default: // unknown filter mode, return nothing return false; } }
bool filterAcceptsRow(int row, const QModelIndex& parent) const { auto model = sourceModel(); auto label = model->index(row, AddressTableModel::Label, parent); if (model->data(label, AddressTableModel::TypeRole).toString() != m_type) { return false; } auto address = model->index(row, AddressTableModel::Address, parent); if (filterRegExp().indexIn(model->data(address).toString()) < 0 && filterRegExp().indexIn(model->data(label).toString()) < 0) { return false; } return true; }