From 997d64c9743149b2b400891b09ab99e9613bf273 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 27 Nov 2009 02:21:04 +0100 Subject: Last structure change, promised! Anyway, this moving/renaming helped me finding lots of strange circulary dependencies and easily solve them :) We have also a more organized structure, hopefully letting people work on different areas altogether. --- src/bookmarks/bookmarksproxy.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/bookmarks/bookmarksproxy.cpp (limited to 'src/bookmarks/bookmarksproxy.cpp') diff --git a/src/bookmarks/bookmarksproxy.cpp b/src/bookmarks/bookmarksproxy.cpp new file mode 100644 index 00000000..87d1ce71 --- /dev/null +++ b/src/bookmarks/bookmarksproxy.cpp @@ -0,0 +1,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; +} -- cgit v1.2.1