C++ (Qt)bool ProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{ QStringList filterList; filterList << "expression1" << "expression2"<< "expression3"; return filterList.contains(sourceModel()->data(sourceModel()->index(sourceRow, 0, sourceParent)).toString());}
C++ (Qt)void ProxyModel::openFilterFile( QString const & name ){ m_filterSet.clear(); QFile file(name); if (file.open(QIODevice::ReadOnly)) { QTextStream stream(&file); while (!stream.atEnd()) { QString line = stream.readLine(); m_filterSet.insert(line); } } invalidateFilter ();}
C++ (Qt)void proxyPaneWidget::noSortProxy(){ m_proxyModel = new ProxyModel( this ); m_proxyModel ->setSourceModel( m_sourseModel ); m_proxyList->setModel( m_proxyModel );}
C++ (Qt)bool proxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{ QString word = sourceModel()->data(sourceModel()->index(sourceRow, 0, sourceParent)).toString(); if(m_filterSet.contains(word)) { QRegExp rx(filterRegExp().pattern(), Qt::CaseInsensitive, QRegExp::WildcardUnix); emit proxyDataChanged(); //HOW TO DO return word.contains(rx); } return false;}