aboutsummaryrefslogtreecommitdiffstats
path: root/CollectionFilter.h
blob: dba647a2442239096170d0b3311bf04580a714d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright 2008 Jason A. Donenfeld <Jason@zx2c4.com>
 */

#ifndef COLLECTIONFILTER_H
#define COLLECTIONFILTER_H

#include <QSortFilterProxyModel>

class CollectionModel;

class CollectionFilter : public QSortFilterProxyModel
{
	Q_OBJECT
public:	
	CollectionFilter(QObject *parent, CollectionModel *parentModel);
	void setFilter(QString filter);
	QString filter() const { return m_filter; }
	QModelIndex currentItem() const;
	QModelIndex peekNext() const;
	QModelIndex moveNext();
	QModelIndex peekPrevious() const;
	QModelIndex movePrevious();
	void setCurrentItem(const QModelIndex&);

private:
	bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
	QString m_filter;
	CollectionModel *m_parent;
	int m_selected;

signals:
	void filterChanged();
};

#endif //COLLECTIONFILTER_H