[yast-commit] r58215 - in /trunk/control-center/src: kcategorizedsortfilterproxymodel.cpp kcategorizedsortfilterproxymodel.h kcategorizedsortfilterproxymodel_p.h yqmodulesmodel.cpp yqmodulesmodel.h

Author: kmachalkova Date: Thu Jul 30 14:32:55 2009 New Revision: 58215 URL: http://svn.opensuse.org/viewcvs/yast?rev=58215&view=rev Log: Support search in keywords (X-SuSE-YaST-Keywords -> comma-separated list of those) (FaTE #305845) Modified: trunk/control-center/src/kcategorizedsortfilterproxymodel.cpp trunk/control-center/src/kcategorizedsortfilterproxymodel.h trunk/control-center/src/kcategorizedsortfilterproxymodel_p.h trunk/control-center/src/yqmodulesmodel.cpp trunk/control-center/src/yqmodulesmodel.h Modified: trunk/control-center/src/kcategorizedsortfilterproxymodel.cpp URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center/src/kcategorizedso... ============================================================================== --- trunk/control-center/src/kcategorizedsortfilterproxymodel.cpp (original) +++ trunk/control-center/src/kcategorizedsortfilterproxymodel.cpp Thu Jul 30 14:32:55 2009 @@ -300,22 +300,28 @@ bool KCategorizedSortFilterProxyModel::filterAcceptsRow( int row, const QModelIndex &srcindex ) const { - bool ret = QSortFilterProxyModel::filterAcceptsRow( row, srcindex ); QModelIndex i0 = sourceModel()->index( row, YQDesktopFilesModel::Group, srcindex); + QModelIndex i1 = sourceModel()->index( row, 0, srcindex); + QStringList keywordList = sourceModel()->data( i1, KeywordsRole ).toStringList(); + QString keywords = keywordList.join(" "); - if( ret ) + bool nameMatches = QSortFilterProxyModel::filterAcceptsRow( row, srcindex ); + bool keywordMatches = ( !keywords.isEmpty() && keywords.contains( filterFixedString()) ); + + if( nameMatches || keywordMatches ) { QString gr = sourceModel()->data(i0, Qt::UserRole).toString(); d->filterGroups.insert( gr ); } - return ret; + + return ( nameMatches || keywordMatches ); } void KCategorizedSortFilterProxyModel::bublisFilterFunction( const QString &s ) { d->filterGroups.clear(); setFilterFixedString( s ); - + d->filterString = s; } QString KCategorizedSortFilterProxyModel::matchingGroupFilterRegexp() @@ -328,3 +334,8 @@ // dumb constant, make sure nothing matches if the list of matching groups is empty return QString("zzzz"); } + +QString KCategorizedSortFilterProxyModel::filterFixedString() const +{ + return d->filterString; +} Modified: trunk/control-center/src/kcategorizedsortfilterproxymodel.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center/src/kcategorizedso... ============================================================================== --- trunk/control-center/src/kcategorizedsortfilterproxymodel.h (original) +++ trunk/control-center/src/kcategorizedsortfilterproxymodel.h Thu Jul 30 14:32:55 2009 @@ -60,6 +60,8 @@ ///< value won't be shown on the view, is only for sorting purposes. What will ///< be shown as "Category" on the view will be asked with the role ///< CategoryDisplayRole. + + KeywordsRole = 0x09B2C2AA }; KCategorizedSortFilterProxyModel(QObject *parent = 0); @@ -118,6 +120,8 @@ QString matchingGroupFilterRegexp(); + QString filterFixedString() const; + protected: /** * Overridden from QSortFilterProxyModel. If you are subclassing @@ -184,6 +188,7 @@ private: class Private; Private *const d; + }; Modified: trunk/control-center/src/kcategorizedsortfilterproxymodel_p.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center/src/kcategorizedso... ============================================================================== --- trunk/control-center/src/kcategorizedsortfilterproxymodel_p.h (original) +++ trunk/control-center/src/kcategorizedsortfilterproxymodel_p.h Thu Jul 30 14:32:55 2009 @@ -47,6 +47,7 @@ bool sortCategoriesByNaturalComparison; QSet<QString> filterGroups; + QString filterString; }; #endif Modified: trunk/control-center/src/yqmodulesmodel.cpp URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center/src/yqmodulesmodel... ============================================================================== --- trunk/control-center/src/yqmodulesmodel.cpp (original) +++ trunk/control-center/src/yqmodulesmodel.cpp Thu Jul 30 14:32:55 2009 @@ -159,11 +159,15 @@ } else if ( role == GenericNameRole ) { - //QString tooltip = d->infoProvider.provideInfo( this, index ); QString tooltip = translatedPropertyValue(index, "GenericName").toString(); return tooltip; } + else if ( role == KCategorizedSortFilterProxyModel::KeywordsRole ) + { + //FIXME: use translatedPropertyValue + return propertyValue( index, "X-SuSE-YaST-Keywords" ); + } else if ( role == Qt::DecorationRole ) { QVariant icon = YQDesktopFilesModel::data( index, role ); Modified: trunk/control-center/src/yqmodulesmodel.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center/src/yqmodulesmodel... ============================================================================== --- trunk/control-center/src/yqmodulesmodel.h (original) +++ trunk/control-center/src/yqmodulesmodel.h Thu Jul 30 14:32:55 2009 @@ -30,7 +30,7 @@ enum UserRoleData { - GenericNameRole = 0x1BA81D0E + GenericNameRole = 0x1BA81D0E }; YQModulesModel( QObject * parent = 0 ); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
kmachalkova@svn.opensuse.org