Author: kmachalkova
Date: Tue Jun 23 12:31:09 2009
New Revision: 57699
URL: http://svn.opensuse.org/viewcvs/yast?rev=57699&view=rev
Log:
Filtering out groups that do not match the filter
Modified:
branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel.cpp
branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel.h
branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel_p.h
branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.cpp
Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel.cpp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel.cpp?rev=57699&r1=57698&r2=57699&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel.cpp (original)
+++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel.cpp Tue Jun 23 12:31:09 2009
@@ -22,6 +22,7 @@
*/
#include "kcategorizedsortfilterproxymodel.h"
+#include "yqdesktopfilesmodel.h"
#include "kcategorizedsortfilterproxymodel_p.h"
#include
@@ -30,6 +31,7 @@
#include <QItemSelection>
#include <QStringList>
#include <QSize>
+#include <QDebug>
KCategorizedSortFilterProxyModel::KCategorizedSortFilterProxyModel(QObject *parent)
: QSortFilterProxyModel(parent)
@@ -295,3 +297,29 @@
return 0;
}
+
+bool KCategorizedSortFilterProxyModel::filterAcceptsRow( int row, const QModelIndex &srcindex ) const
+{
+ bool ret = QSortFilterProxyModel::filterAcceptsRow( row, srcindex );
+ QModelIndex i0 = sourceModel()->index( row, YQDesktopFilesModel::Group, srcindex);
+
+ if( ret )
+ {
+ QString gr = sourceModel()->data(i0, Qt::UserRole).toString();
+ d->filterGroups.insert( gr );
+ }
+ return ret;
+}
+
+void KCategorizedSortFilterProxyModel::bublisFilterFunction( const QString &s )
+{
+ d->filterGroups.clear();
+ setFilterFixedString( s );
+
+}
+
+QString KCategorizedSortFilterProxyModel::matchingGroupFilterRegexp()
+{
+ QStringList slist = d->filterGroups.toList();
+ return slist.join("|");
+}
Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel.h?rev=57699&r1=57698&r2=57699&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel.h (original)
+++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel.h Tue Jun 23 12:31:09 2009
@@ -115,6 +115,10 @@
*/
static int naturalCompare(const QString &a, const QString &b);
+ void bublisFilterFunction( const QString &s );
+
+ QString matchingGroupFilterRegexp();
+
protected:
/**
* Overridden from QSortFilterProxyModel. If you are subclassing
@@ -176,6 +180,8 @@
*/
virtual int compareCategories(const QModelIndex &left, const QModelIndex &right) const;
+ virtual bool filterAcceptsRow( int row, const QModelIndex &index ) const;
+
private:
class Private;
Private *const d;
Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel_p.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel_p.h?rev=57699&r1=57698&r2=57699&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel_p.h (original)
+++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/kcategorizedsortfilterproxymodel_p.h Tue Jun 23 12:31:09 2009
@@ -22,6 +22,8 @@
#ifndef KCATEGORIZEDSORTFILTERPROXYMODEL_P_H
#define KCATEGORIZEDSORTFILTERPROXYMODEL_P_H
+#include <QSet>
+
class KCategorizedSortFilterProxyModel;
class KCategorizedSortFilterProxyModel::Private
@@ -43,6 +45,8 @@
Qt::SortOrder sortOrder;
bool categorizedModel;
bool sortCategoriesByNaturalComparison;
+
+ QSet<QString> filterGroups;
};
#endif
Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.cpp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.cpp?rev=57699&r1=57698&r2=57699&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.cpp (original)
+++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.cpp Tue Jun 23 12:31:09 2009
@@ -45,6 +45,7 @@
, groupview(0L)
, modview(0L)
, kcsfpm(0L)
+ , gcsfpm(0L)
{
}
~Private()
@@ -57,6 +58,8 @@
// category proxy model
KCategorizedSortFilterProxyModel * kcsfpm;
+ QSortFilterProxyModel *gcsfpm;
+
QLineEdit *searchField;
QQueue <QString> recentlyUsed;
@@ -92,7 +95,7 @@
d->modmodel = new YQModulesModel(this);
d->kcsfpm = new YQModulesProxyModel( this );
d->kcsfpm->setCategorizedModel( true );
- d->kcsfpm->setSourceModel( d->modmodel );
+ d->kcsfpm->setSourceModel( d->modmodel) ;
//kcsfpm->setFilterRole( KCModuleModel::UserFilterRole );
//kcsfpm->setFilterCaseSensitivity( Qt::CaseInsensitive );
@@ -113,8 +116,13 @@
leftPanelLayout->addLayout( searchLayout );
+ d->gcsfpm = new QSortFilterProxyModel( this );
+ d->gcsfpm->setSourceModel( d->modmodel->groupsModel() );
+ d->gcsfpm->setFilterKeyColumn( 2 );
+ d->gcsfpm->setFilterRole( Qt::UserRole );
+
d->groupview = new QListView( );
- d->groupview->setModel(d->modmodel->groupsModel());
+ d->groupview->setModel(d->gcsfpm);
d->groupview->setIconSize( QSize(32,32) );
leftPanelLayout->addWidget( d->groupview );
@@ -216,8 +224,10 @@
void MainWindow::slotFilterChanged()
{
QString stext = d->searchField->text();
- d->kcsfpm->setFilterFixedString( stext );
+ d->kcsfpm->bublisFilterFunction( stext );
+ QString gr_filter = d->kcsfpm->matchingGroupFilterRegexp();
+ d->gcsfpm->setFilterRegExp ( gr_filter );
}
void MainWindow::readSettings()
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org