ResourceModel: implement filter functionality

So far all subclasses implemented filtering on their own which doesn't
make much sense. Now one can set filter keywords and a filter type for
all ResourceModels. Subclasses simply have to call
ResourceModel::itemMatchesFilter( ResourceItem ) in order to determine
whether an item should be hidden or not. Additionally they have to
implement the updateFilters() method in order to update their internal
management data each time the filters change.
This commit is contained in:
Tobias Doerffel
2009-08-21 16:49:27 +02:00
parent 36ec30f649
commit d3bb3ff13a
9 changed files with 80 additions and 61 deletions

View File

@@ -36,20 +36,19 @@ public:
{
}
int rowCount( const QModelIndex & _parent = QModelIndex() ) const;
virtual int rowCount( const QModelIndex & _parent = QModelIndex() ) const;
virtual QModelIndex index( int _row, int _col,
const QModelIndex & _parent = QModelIndex() ) const;
virtual QModelIndex parent( const QModelIndex & _index ) const;
virtual void setFilter( const QString & _s );
virtual void updateFilters();
private:
bool filterItems( ResourceItem::Relation * _item,
const QModelIndex & _parent,
const QStringList & _keywords );
const QModelIndex & _parent );
void setHidden( ResourceItem::Relation * _item,
const QModelIndex & _parent,
bool _hidden,