Commit d40a1350 authored by Marco Martin's avatar Marco Martin

different search mode

parent a7d6e056
......@@ -24,7 +24,8 @@
#include "MenuModel.h"
MenuProxyModel::MenuProxyModel( QObject * parent )
: KCategorizedSortFilterProxyModel( parent )
: KCategorizedSortFilterProxyModel( parent ),
m_filterHighlightsEntries( true )
{
setSortRole( MenuModel::UserSortRole );
setFilterRole( MenuModel::UserFilterRole );
......@@ -69,6 +70,10 @@ bool MenuProxyModel::subSortLessThan( const QModelIndex &left, const QModelIndex
bool MenuProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
{
if (!m_filterHighlightsEntries) {
return KCategorizedSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}
QModelIndex index = sourceModel()->index( source_row, 0, source_parent );
MenuItem * mItem = index.data( Qt::UserRole ).value<MenuItem*>();
// accept only systemsettings categories that have children
......@@ -79,6 +84,16 @@ bool MenuProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source
}
}
void MenuProxyModel::setFilterHighlightsEntries (bool highlight )
{
m_filterHighlightsEntries = highlight;
}
bool MenuProxyModel::filterHighlightsEntries() const
{
return m_filterHighlightsEntries;
}
Qt::ItemFlags MenuProxyModel::flags( const QModelIndex &index ) const
{
if ( !index.isValid() ) {
......
......@@ -99,6 +99,18 @@ public:
*/
void setFilterRegExp ( const QString & pattern );
/**
* makes the filter highlight matching entries instead of hiding them
*/
void setFilterHighlightsEntries (bool highlight );
/**
* @returns the filter highlight matching entries instead of hiding them, default true
*/
bool filterHighlightsEntries() const;
private:
bool m_filterHighlightsEntries : 1;
};
#endif
......@@ -116,6 +116,7 @@ void SidebarMode::initEvent()
d->proxyModel->setCategorizedModel( true );
d->proxyModel->setSourceModel( model );
d->proxyModel->sort( 0 );
d->proxyModel->setFilterHighlightsEntries( false );
d->mainWidget = new QWidget();
d->mainLayout = new QHBoxLayout(d->mainWidget);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment