/*! 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); }
ProgrameList::ProgrameList(QWidget *parent) : AbstractList(parent) { _tf=new TextFilter; _model=0; _zModel=new QSortFilterProxyModel(this); _zModel->setFilterCaseSensitivity(Qt::CaseInsensitive); connect(_tf,SIGNAL(filterExp(QString)),_zModel,SLOT(setFilterRegExp(QString))); QVBoxLayout *vbl=new QVBoxLayout; vbl->setMargin(0);vbl->setSpacing(0); vbl->addWidget(_tf); _ml=new MyListWidget; _zL=_ml; vbl->addWidget(_ml); setLayout(vbl); }