summaryrefslogtreecommitdiff
path: root/src/bookmarks/bookmarksproxy.cpp
blob: 87d1ce7116087aedf065e443ce40eca77b885f95 (plain)
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
#include "bookmarksproxy.h"

BookmarksProxy::BookmarksProxy( QObject *parent ):
	QSortFilterProxyModel( parent )
{
}

bool BookmarksProxy::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
{
	QModelIndex idx = sourceModel()->index( source_row, 0, source_parent );

// 	return idx.data().toString().contains( filterRegExp() );
	return recursiveMatch( idx );
}

bool BookmarksProxy::recursiveMatch( const QModelIndex &index ) const
{
	if( index.data().toString().contains( filterRegExp() ) ) {
		return true;
	}

	for( int childRow = 0; childRow < sourceModel()->rowCount( index ); ++childRow ) {
		if( recursiveMatch( sourceModel()->index( childRow, 0, index ) ) ) {
			return true;
		}
	}

	return false;
}